From f31859e6b970e03d6a6c63d96613888031a5ecc6 Mon Sep 17 00:00:00 2001 From: Bryan Bonvallet Date: Thu, 19 Dec 2013 16:00:59 -0500 Subject: [PATCH] woops, no reason to wait only to fail. moving fail condition prior to sleep. --- karmaworld/apps/notes/gdrive.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/karmaworld/apps/notes/gdrive.py b/karmaworld/apps/notes/gdrive.py index dc9242c..e38ce3d 100644 --- a/karmaworld/apps/notes/gdrive.py +++ b/karmaworld/apps/notes/gdrive.py @@ -121,15 +121,15 @@ def upload_to_gdrive(service, media, filename, extension=None, mimetype=None): # exponentially wait for exportLinks to be returned if missing while u'exportLinks' not in file_dict or \ u'text/plain' not in file_dict[u'exportLinks']: + # if 31.5 seconds have passed, give up + if delay_exp == 5: + raise ValueError('Google Drive failed to read the document.') + # wait some seconds print "upload_check_sleep({0})".format(2. ** delay_exp) time.sleep(2. ** delay_exp) delay_exp = delay_exp + 1 - # if 31.5 seconds have passed, give up - if delay_exp == 5: - raise ValueError('Google Drive failed to read the document.') - # try to get the doc from gdrive file_dict = service.files().get(fileId=file_dict[u'id']).execute() -- 2.25.1