prepare for taskStatus api change

This commit is contained in:
j 2016-02-20 18:23:02 +05:30
parent 252158a216
commit bdca487883

View file

@ -955,16 +955,19 @@ class API(ox.API):
tmp = tempfile.gettempdir()
self._resume_file = os.path.join(tmp, 'pandora_client.%s.%s.json' % (os.environ.get('USER'), netloc))
if hasattr(self, 'taskStatus') and not hasattr(self, 'getTaskStatus'):
self.getTaskStatus = self.taskStatus
def async(self, action, data, interval=5):
t = r = getattr(self, action)(data)
if r['status']['code'] == 200:
# wait for async task to finish
if 'taskId' in r['data']:
t = self.taskStatus(task_id=r['data']['taskId'])
t = self.getTaskStatus(task_id=r['data']['taskId'])
print 'waiting for server ...'
while t['data'].get('status') == 'PENDING':
time.sleep(interval)
t = self.taskStatus(task_id=r['data']['taskId'])
t = self.getTaskStatus(task_id=r['data']['taskId'])
return t
def uploadFrames(self, i, data):