Skip to content

Commit 1f77ae2

Browse files
OidaTiftlajuzim
authored andcommitted
try 5 times the upload to onedrive afterwards fail
1 parent e5b170f commit 1f77ae2

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

script/onedrive.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,19 @@ def __get_folder(self): #Get folder name settings
101101

102102
def __insert_file(self):
103103
print '[+] uploading file...'
104-
item = self.__onedrive_service.item(drive='me', id=self.__get_folder())
105-
file = item.children[self.info['name']].upload(self.info['path'])
104+
tries = 5
105+
while tries > 0:
106+
try:
107+
tries -= 1
108+
item = self.__onedrive_service.item(drive='me', id=self.__get_folder())
109+
file = item.children[self.info['name']].upload(self.info['path'])
110+
tries = 0
111+
except:
112+
print '[x] upload failed'
113+
if tries <= 0:
114+
pass
115+
else:
116+
print '[x] retrying ...'
106117

107118
self.info['id'] = file.id
108119
self.info['download_url'] = file.web_url

0 commit comments

Comments
 (0)