This commit is contained in:
j 2024-03-21 00:08:40 +01:00
parent 99554cb461
commit 0e801f82a3

View file

@ -167,22 +167,22 @@ class API(object):
try: try:
data = self._json_request(uploadUrl, meta, files=files) data = self._json_request(uploadUrl, meta, files=files)
except KeyboardInterrupt: except KeyboardInterrupt:
if not slient: if not silent:
print("\ninterrupted by user.") print("\ninterrupted by user.")
sys.exit(1) sys.exit(1)
except: except:
if not slient: if not silent:
print("uploading chunk failed, will try again in 5 seconds\r", end='') print("uploading chunk failed, will try again in 5 seconds\r", end='')
sys.stdout.flush() sys.stdout.flush()
data = {'result': -1} data = {'result': -1}
time.sleep(5) time.sleep(5)
if data and 'status' in data: if data and 'status' in data:
if data['status']['code'] == 403: if data['status']['code'] == 403:
if not slient: if not silent:
print("login required") print("login required")
return False return False
if data['status']['code'] != 200: if data['status']['code'] != 200:
if not slient: if not silent:
print("request returned error, will try again in 5 seconds") print("request returned error, will try again in 5 seconds")
if self.DEBUG: if self.DEBUG:
print(data) print(data)
@ -190,7 +190,7 @@ class API(object):
if data and data.get('result') == 1: if data and data.get('result') == 1:
done += len(chunk) done += len(chunk)
if data.get('offset') not in (None, done): if data.get('offset') not in (None, done):
if not slient: if not silent:
print('server offset out of sync, continue from', data['offset']) print('server offset out of sync, continue from', data['offset'])
done = data['offset'] done = data['offset']
f.seek(done) f.seek(done)