Use sys.stdout.write instead of print in progress

For some reason, this avoids having multiple "lines" on top of each other, which was always due to print()' newlines. And this makes the client/js part much more stable.
master
pictuga 2013-12-21 20:11:20 +01:00
parent eafbc14a58
commit 47013c7948
1 changed files with 2 additions and 2 deletions

View File

@ -584,9 +584,9 @@ def Gather(url, cachePath, options):
if options.progress:
end = size if MAX_ITEM == -1 else min(MAX_ITEM, size)
if options.json:
print json.dumps((i+1, end, item), default=lambda o: dict(o))
sys.stdout.write(json.dumps((i+1, end, item), default=lambda o: dict(o)) + "\n")
else:
print "%s/%s" % (i+1, end)
sys.stdout.write("%s/%s\n" % (i+1, end))
sys.stdout.flush()
queue = Queue.Queue()