+ def print_start(thing):
+ # Truncate to 66 characters, leaving 10 characters for a success
+ # or failure message
+ truncated_thing = thing[0:66]
+
+ # Also, space-pad to keep the cursor in a known column
+ num_spaces = 66 - len(truncated_thing)
+
+ print "%s...%s" % (truncated_thing, ' ' * num_spaces),
+ sys.stdout.flush()
+
+ if sys.stdout.isatty():
+ # stdout is a terminal; stupid backspace tricks are OK.
+ # Don't use print, because it always adds magical spaces, which
+ # makes backspace accounting harder
+
+ backspaces = [0]
+ def print_status(msg):
+ # Overwrite any status text with spaces before printing
+ sys.stdout.write('\b' * backspaces[0])
+ sys.stdout.write(' ' * backspaces[0])
+ sys.stdout.write('\b' * backspaces[0])
+ sys.stdout.write(msg)