Allow "progress" in JSON

master
pictuga 2013-12-21 20:09:14 +01:00
parent cbdb61a918
commit eafbc14a58
1 changed files with 8 additions and 7 deletions

View File

@ -558,13 +558,6 @@ def Gather(url, cachePath, options):
queue.task_done() queue.task_done()
def worker(i, item): def worker(i, item):
if options.progress:
if MAX_ITEM == -1:
print '%s/%s' % (i+1, size)
else:
print '%s/%s' % (i+1, min(MAX_ITEM, size))
sys.stdout.flush()
if time.time() - startTime > LIM_TIME >= 0 or i+1 > LIM_ITEM >= 0: if time.time() - startTime > LIM_TIME >= 0 or i+1 > LIM_ITEM >= 0:
log('dropped') log('dropped')
item.remove() item.remove()
@ -588,6 +581,14 @@ def Gather(url, cachePath, options):
if not options.keep: if not options.keep:
del item.desc del item.desc
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))
else:
print "%s/%s" % (i+1, end)
sys.stdout.flush()
queue = Queue.Queue() queue = Queue.Queue()
for i in range(THREADS): for i in range(THREADS):