update info is async now

This commit is contained in:
j 2014-07-09 20:31:20 +02:00
parent 5f3f2eb4d3
commit e7cec4cc46

View file

@ -610,21 +610,7 @@ class Client(object):
r = self.api.update(post)
if r['data']['info']:
info = r['data']['info']
max_info = 100
total = len(info)
sent = 0
for offset in range(0, total, max_info):
post = {'info': {}, 'upload': True}
post['info'] = self.get_info_for_ids(info[offset:offset+max_info], prefix)
if len(post['info']):
r = self.api.update(post)
sent += len(post['info'])
if sent:
print 'sent info for %s files' % sent
#send empty list to get updated list of requested info/files/data
post = {'info': {}}
r = self.api.update(post)
r = self.update_info(r['data']['info'], prefix)
if not 'data' in r:
print r
@ -687,18 +673,8 @@ class Client(object):
info = r['data']['info']
if info:
print 'info for %d files requested' % len(info)
max_info = 100
total = len(info)
sent = 0
for offset in range(0, total, max_info):
post = {'info': {}, 'upload': True}
post['info'] = self.get_info_for_ids(info[offset:offset+max_info])
if len(post['info']):
r = self.api.update(post)
sent += len(post['info'])
if sent:
print 'uploading info for %d files' % sent
r = self.update_info(info)
sys.exit()
if data:
print 'encoding and uploading %s videos' % len(data)
@ -736,6 +712,23 @@ class Client(object):
self.api.uploadData(path, oshash)
break
def update_info(self, info, prefix=None):
if info:
post = {'info': {}, 'upload': True}
post['info'] = self.get_info_for_ids(info, prefix)
r = self.api.update(post)
if 'taskId' in r['data']:
t = self.api.taskStatus(task_id=r['data']['taskId'])
print 'waiting for server ...'
while t['data']['status'] == 'PENDING':
time.sleep(5)
t = self.api.taskStatus(task_id=r['data']['taskId'])
print 'sent info for %s files' % len(post['info'])
#send empty list to get updated list of requested info/files/data
post = {'info': {}}
r = self.api.update(post)
return r
def upload_frames(self, args):
if not self.user:
print "you need to login"