From eb2f2d73f93f75a60390a6646f3aa4b10b999744 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Sat, 17 Dec 2016 16:10:38 +0100 Subject: [PATCH] add file for borg backups --- borg_interface/connectivity.py | 9 +++++++++ borg_interface/interface_functions.py | 9 ++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 borg_interface/connectivity.py diff --git a/borg_interface/connectivity.py b/borg_interface/connectivity.py new file mode 100644 index 0000000..744656a --- /dev/null +++ b/borg_interface/connectivity.py @@ -0,0 +1,9 @@ +import os +hostname = "google.com" #example +response = os.system("ping -c 1 " + hostname) + +#and then check the response... +if response == 0: + print hostname, 'is up!' +else: + print hostname, 'is down!' diff --git a/borg_interface/interface_functions.py b/borg_interface/interface_functions.py index e41e0eb..e005a3a 100644 --- a/borg_interface/interface_functions.py +++ b/borg_interface/interface_functions.py @@ -57,7 +57,8 @@ def mount_archive(): int_vars.mount_point = os.path.join('/tmp', archive_name) if not os.path.exists(int_vars.mount_point): os.makedirs(int_vars.mount_point) - p = subprocess.Popen(['borg', 'mount', '::' + archive_name, int_vars.mount_point]) + p = subprocess.Popen(['borg', 'mount', '::' + archive_name, + int_vars.mount_point]) p.wait() draw_screen(2, 2, "Archive mounted at " + int_vars.mount_point + "/.") screen.addstr(3, 2, "The archive will remain mounted as long this programm " @@ -88,9 +89,11 @@ def delete_archive(): def create_archive(): archive_name = get_param("Please enter an archive name: ").decode('utf-8') - path_to_backup = get_param("Please enter the path to backup: ").decode('utf-8') + path_to_backup = get_param("Please enter the " + "path to backup: ").decode('utf-8') draw_screen(2, 2, "Please wait while the backup gets created.") - p = subprocess.Popen(['borg', 'create', '::' + archive_name, path_to_backup]) + p = subprocess.Popen(['borg', 'create', '::' + archive_name, + path_to_backup]) p.wait() draw_screen(2, 2, "Archive of " + path_to_backup + " created.") ncurses_pause(5)