From a1d032c063cb0c4dd524ce7bc8b5b39981a54f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florent=20Thi=C3=A9ry?= Date: Fri, 17 Jan 2025 18:39:31 +0100 Subject: [PATCH] tolerate 504s --- examples/transfer_media.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/examples/transfer_media.py b/examples/transfer_media.py index ba44c69..9eff6f1 100755 --- a/examples/transfer_media.py +++ b/examples/transfer_media.py @@ -387,16 +387,22 @@ def print_progress(progress): if args.apply: print('Starting upload') - resp = msc_dest.add_media(**upload_args) - oid_dest = resp['oid'] + try: + resp = msc_dest.add_media(**upload_args) + oid_dest = resp['oid'] - if args.sync_perms: - sync_group_permissions(msc_src, oid_src, msc_dest, oid_dest) + if args.sync_perms: + sync_group_permissions(msc_src, oid_src, msc_dest, oid_dest) - if resp['success']: - print(f'File {zip_path} upload finished, object id is {oid_dest}') - else: - print(f'Upload of {zip_path} failed: {resp}') + if resp['success']: + print(f'File {zip_path} upload finished, object id is {oid_dest}') + else: + print(f'Upload of {zip_path} failed: {resp}') + except Exception as e: + if "504" in str(e): + print(f"Timeout error, perms are probably wrong: {e}") + else: + raise e else: print(f'[Dry run] Would upload {zip_path} with {upload_args}')