Skip to content
Snippets Groups Projects
Commit 4cd2d756 authored by Florent Thiery's avatar Florent Thiery
Browse files

add colors

parent 1b506a64
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,11 @@ GREEN = '\033[92m' ...@@ -17,6 +17,11 @@ GREEN = '\033[92m'
RED = '\033[91m' RED = '\033[91m'
DEF = '\033[0m' DEF = '\033[0m'
def print_red(string):
print(RED + string + DEF)
def print_green(string):
print(GREEN + string + DEF)
def test_ssh(ip): def test_ssh(ip):
cmd = 'ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no %s ls /tmp' % ip cmd = 'ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no %s ls /tmp' % ip
...@@ -78,15 +83,15 @@ def check_local_backup(path): ...@@ -78,15 +83,15 @@ def check_local_backup(path):
now = datetime.now() now = datetime.now()
diff_seconds = (now - d).total_seconds() diff_seconds = (now - d).total_seconds()
if diff_seconds > 48*3600: if diff_seconds > 48*3600:
print('Backup %s is older than 48h (%ih)' % (backup_folder, diff_seconds/3600)) print_red('Backup %s is older than 48h (%ih)' % (backup_folder, diff_seconds/3600))
all_ok = False all_ok = False
else: else:
print('Backup %s is fine' % backup_folder) print_green('Backup %s is fine' % backup_folder)
elif os.path.exists(os.path.join(backup_folder, 'backup.inprogress')): elif os.path.exists(os.path.join(backup_folder, 'backup.inprogress')):
print('Backup %s still running' % backup_folder) print_red('Backup %s still running' % backup_folder)
all_ok = False all_ok = False
else: else:
print('Backup %s is not working' % latest) print_red('Backup %s is not working' % latest)
all_ok = False all_ok = False
return all_ok return all_ok
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment