From 5b2ac65bb3b3f74c0ab4009142b036403eb263f0 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Mon, 12 Aug 2019 11:47:23 +0200 Subject: [PATCH] working on comparing checksums --- compare_checksums.py | 15 ++++++++++++++- create_snapshot_backup.py | 8 +------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/compare_checksums.py b/compare_checksums.py index 1d53eca..9387fcc 100644 --- a/compare_checksums.py +++ b/compare_checksums.py @@ -4,7 +4,6 @@ import pathlib import subprocess from copy_snapshots_to_remote import get_member_name -from create_snapshot_backup import call, remote_call SSH_KEY_FILE = "/mnt/Datenspeicher/snap-backup-dataset/backup_key" SSH_REMOTE = "zfs_snap_backup@etha.cpi.imtek.uni-freiburg.de" @@ -17,6 +16,20 @@ ZFS_ELAB_PREFIX = "elabfs-" TMP_BACKUP_FOLDER = "/mnt/Datenspeicher/snap-backup-dataset/temporary-backups" +def remote_call(arguments): + """ makes runs an command on the remote backup server + + :params arguments: list of command line arguments and parameters + :returns: string of the command output + :raises subprocess.CalledProcessError: if command has not an exit value of 0 + """ + cmd = ["ssh", "-i", SSH_KEY_FILE, SSH_REMOTE] + cmd.extend(arguments) + result = subprocess.run(" ".join(cmd), as_text=True, check=True, + stdout=subprocess.PIPE, + universal_newlines=as_text, shell=True) + return result.stdout + def get_local_backup_members(): tmp_folder = pathlib.Path(TMP_BACKUP_FOLDER) diff --git a/create_snapshot_backup.py b/create_snapshot_backup.py index 1fdacee..7b1f725 100755 --- a/create_snapshot_backup.py +++ b/create_snapshot_backup.py @@ -46,13 +46,7 @@ def remote_call(arguments): """ cmd = ["ssh", "-i", SSH_KEY_FILE, SSH_REMOTE] cmd.extend(arguments) - try: - result = call(cmd, as_text=True) - except subprocess.CalledProcessError as e: - print("CMD:", " ".join(e.cmd)) - print("STDOUT:", e.stdout) - print("STDERR:", e.stderr) - raise + result = subprocess.run(cmd, as_text=True) def clean_split(text):