From 7ee0e8a3ac6d33ad2a94f9d5567ce21e36c28969 Mon Sep 17 00:00:00 2001 From: Karina5005 Date: Wed, 11 Oct 2023 09:00:27 +0000 Subject: [PATCH] fix: style fixes --- backup_github/main.py | 8 +++++++- backup_github/utils.py | 18 ++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/backup_github/main.py b/backup_github/main.py index 1a1a10a..a3db496 100644 --- a/backup_github/main.py +++ b/backup_github/main.py @@ -48,7 +48,13 @@ def main(): logging.info("Finish backup of pulls") success.labels(parsed_args.organization).set(1) if parsed_args.bucket: - upload_to_s3(parsed_args.ak, parsed_args.sk, parsed_args.output_dir, parsed_args.bucket, parsed_args.organization) + upload_to_s3( + parsed_args.ak, + parsed_args.sk, + parsed_args.output_dir, + parsed_args.bucket, + parsed_args.organization, + ) except Exception as e: logging.error(e) success.labels(parsed_args.organization).set(0) diff --git a/backup_github/utils.py b/backup_github/utils.py index 7b696bd..b1515a5 100644 --- a/backup_github/utils.py +++ b/backup_github/utils.py @@ -62,17 +62,15 @@ def upload_to_s3(ak, sk, endpoint, backup_dir, bucket, organization): server=endpoint, path_style=True, signature="v2", - is_signature_negotiation=True + is_signature_negotiation=True, ) - shutil.make_archive( - base_name='backup_archive', - format='gztar', - root_dir=backup_dir + shutil.make_archive(base_name="backup_archive", format="gztar", root_dir=backup_dir) + resp = obs.putFile( + bucket, + f'{organization}-{datetime.now().strftime("%m-%d-%Y_%H-%M")}.tar.gz', + "./backup_archive.tar.gz", ) - resp = obs.putFile(bucket, - f'{organization}-{datetime.now().strftime("%m-%d-%Y_%H-%M")}.tar.gz', - './backup_archive.tar.gz') if resp.status >= 300: - logging.error(f'Uploading of backup failed, error message: {resp.errorMessage}') + logging.error(f"Uploading of backup failed, error message: {resp.errorMessage}") raise Exception(resp.errorMessage) - logging.info(f'Backup is loaded') + logging.info(f"Backup is loaded")