From da7e5cc9be4ad76eed33c245dc008cea0d38f6b7 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Mon, 5 Feb 2024 19:16:09 +0100 Subject: [PATCH 1/2] changed loading of directory-validator --- backup-docker-to-local.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backup-docker-to-local.py b/backup-docker-to-local.py index 01325be..67fc639 100644 --- a/backup-docker-to-local.py +++ b/backup-docker-to-local.py @@ -64,6 +64,7 @@ BACKUPS_DIR = '/Backups/' VERSIONS_DIR = os.path.join(BACKUPS_DIR, MACHINE_ID, REPOSITORY_NAME) BACKUP_TIME = datetime.now().strftime("%Y%m%d%H%M%S") VERSION_DIR = create_version_directory() +SCRIPTS_DIRECTORY = pathlib.Path(os.path.realpath(__file__)).parent.parent def get_instance(container): # The function is defined to take one parameter, 'container', @@ -91,7 +92,7 @@ def get_instance(container): def stamp_directory(): """Stamp a directory using directory-validator.""" - stamp_command = f"python ../directory-validator/directory-validator.py --stamp {VERSION_DIR}" + stamp_command = f"python {SCRIPTS_DIRECTORY}/directory-validator/directory-validator.py --stamp {VERSION_DIR}" try: execute_shell_command(stamp_command) print(f"Successfully stamped directory: {VERSION_DIR}") From 6537626d771bb2484f72f1bb0afa4dd20a9956af Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Mon, 5 Feb 2024 19:18:54 +0100 Subject: [PATCH 2/2] optimized code formating --- backup-docker-to-local.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/backup-docker-to-local.py b/backup-docker-to-local.py index 67fc639..d868d5b 100644 --- a/backup-docker-to-local.py +++ b/backup-docker-to-local.py @@ -55,16 +55,16 @@ IMAGES_NO_BACKUP_REQUIRED = [ 'memcached' ] -DIRNAME = os.path.dirname(__file__) - -DATABASES = pandas.read_csv(os.path.join(DIRNAME, "databases.csv"), sep=";") -REPOSITORY_NAME = os.path.basename(DIRNAME) -MACHINE_ID = get_machine_id() -BACKUPS_DIR = '/Backups/' -VERSIONS_DIR = os.path.join(BACKUPS_DIR, MACHINE_ID, REPOSITORY_NAME) -BACKUP_TIME = datetime.now().strftime("%Y%m%d%H%M%S") -VERSION_DIR = create_version_directory() -SCRIPTS_DIRECTORY = pathlib.Path(os.path.realpath(__file__)).parent.parent +# DEFINE CONSTANTS +DIRNAME = os.path.dirname(__file__) +SCRIPTS_DIRECTORY = pathlib.Path(os.path.realpath(__file__)).parent.parent +DATABASES = pandas.read_csv(os.path.join(DIRNAME, "databases.csv"), sep=";") +REPOSITORY_NAME = os.path.basename(DIRNAME) +MACHINE_ID = get_machine_id() +BACKUPS_DIR = '/Backups/' +VERSIONS_DIR = os.path.join(BACKUPS_DIR, MACHINE_ID, REPOSITORY_NAME) +BACKUP_TIME = datetime.now().strftime("%Y%m%d%H%M%S") +VERSION_DIR = create_version_directory() def get_instance(container): # The function is defined to take one parameter, 'container',