Answer the question
In order to leave comments, you need to log in
No errors synchronously, asynchronously - WRONG SSL VERSION NUMBER. How to fix it?
Problem with calling Google Drive API
Synchronous call does not throw any errors:
def backup_everything(*bases):
tasks = [
i.backup()
for i in bases
]
async def backup_coro(*bases):
loop = asyncio.get_event_loop()
tasks = [
loop.run_in_executor(None, i.backup)
for i in bases
]
return await asyncio.gather(*tasks)
asyncio.run(backup_coro(*bases))
def backup(f_name: str, f_path: str) -> None:
# удалить старые версии файлов
last_backup = drive.search({'name': f_name})
if last_backup:
del_item(last_backup[0]['id'], "Previous base deleted")
try:
# ID папки, куда заливать файл
fold_id = folder(BACKUP_FOLDER_NAME)
f_mime_type = mimeTypes[file_ext(f_name)]
drive.upload_file(f_name, f_path, f_mime_type, fold_id)
except Exception as trouble:
print(trouble, f_path, 'Terminating...', sep='\n')
else:
print(f"File: '{f_name}' uploaded")
def del_item(self, _id: str) -> None:
self.drive_service.files().delete(fileId=_id).execute()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question