From 4cd2d756ae59694f2dd1d58a52885f1d2237487b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florent=20Thi=C3=A9ry?= <florent.thiery@ubicast.eu>
Date: Thu, 1 Jun 2017 11:44:44 +0200
Subject: [PATCH] add colors

---
 tests/test_backup.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tests/test_backup.py b/tests/test_backup.py
index 3fad523c..75404d39 100755
--- a/tests/test_backup.py
+++ b/tests/test_backup.py
@@ -17,6 +17,11 @@ GREEN = '\033[92m'
 RED = '\033[91m'
 DEF = '\033[0m'
 
+def print_red(string):
+    print(RED + string + DEF)
+
+def print_green(string):
+    print(GREEN + string + DEF)
 
 def test_ssh(ip):
     cmd = 'ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no %s ls /tmp' % ip
@@ -78,15 +83,15 @@ def check_local_backup(path):
         now = datetime.now()
         diff_seconds = (now - d).total_seconds()
         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 
         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')):
-        print('Backup %s still running' % backup_folder)
+        print_red('Backup %s still running' % backup_folder)
         all_ok = False
     else:
-        print('Backup %s is not working' % latest)
+        print_red('Backup %s is not working' % latest)
         all_ok = False
     return all_ok
 
-- 
GitLab