]> git.itanic.dy.fi Git - emerge-timer/commitdiff
Add the --quiet flag
authorEsko Kokkonen <esko.kokkonen@gmail.com>
Sun, 18 Sep 2011 19:42:06 +0000 (22:42 +0300)
committerEsko Kokkonen <esko.kokkonen@gmail.com>
Sun, 18 Sep 2011 19:42:06 +0000 (22:42 +0300)
This option gives less verbose output

emerge-timer.py

index 4e1461748d85ad07bbdb63f1a74a18766440afa0..208fffa171c64cba9d38b7cbcfc3d4db844e1206 100755 (executable)
@@ -11,6 +11,7 @@ LOGFILE = "/var/log/emerge.log"
 green_start = "\033[32m"
 color_stop = "\033[m"
 
 green_start = "\033[32m"
 color_stop = "\033[m"
 
+QUIET = False
 
 PACKAGES = []
 
 
 PACKAGES = []
 
@@ -91,11 +92,13 @@ class package:
         """This prints the emerge times for different versions in the
         normal operating mode of the script"""
 
         """This prints the emerge times for different versions in the
         normal operating mode of the script"""
 
-        for p in self.versions:
+        if QUIET == False:
 
 
-            print('-'*90 + "\n" +
-                  green_start + self.name + p[0] + color_stop + "  >>>  " +
-                  time(p[1]) + "  >>>  " + date(p[2]))
+            for p in self.versions:
+
+                print('-'*90 + "\n" +
+                      green_start + self.name + p[0] + color_stop +
+                      "  >>>  " + time(p[1]) + "  >>>  " + date(p[2]))
 
         print('-'*90 + "\n" + "Package " + green_start +
               self.name + color_stop + " emerged " +
 
         print('-'*90 + "\n" + "Package " + green_start +
               self.name + color_stop + " emerged " +
@@ -106,17 +109,21 @@ class package:
 
     def print_pretended_times(self):
         """This is used the print all the pretended times"""
 
     def print_pretended_times(self):
         """This is used the print all the pretended times"""
-        print("\t" + green_start + self.name + '-' + self.version + color_stop),
+
+        if QUIET == False:
+            print("\t" + green_start + self.name + '-' + self.version + color_stop),
 
         if len(self.versions) > 1:
             aver_time = self.average_time()
 
 
         if len(self.versions) > 1:
             aver_time = self.average_time()
 
-            print("\n\taverage time: " + time(aver_time))
+            if QUIET == False:
+                print("\n\taverage time: " + time(aver_time))
 
             return aver_time
 
         else:
 
             return aver_time
 
         else:
-            print("\n\t no previous emerges")
+            if QUIET == False:
+                print("\n\t no previous emerges")
 
             return 0
 
 
             return 0
 
@@ -400,7 +407,7 @@ Options:
 \t-c, --current \t Show time until currently compiling package finishes
 \t-p, --pretended  Calculate compile time from piped 'emerge -p' output
 \t-h, --help \t Show this helpscreen
 \t-c, --current \t Show time until currently compiling package finishes
 \t-p, --pretended  Calculate compile time from piped 'emerge -p' output
 \t-h, --help \t Show this helpscreen
-
+\t-q, --quiet \t Be less verbose
 \t--no-color \t Use colorless output"""
 
     print usage
 \t--no-color \t Use colorless output"""
 
     print usage
@@ -426,6 +433,9 @@ if __name__ == "__main__":
         if arg == "-h" or arg == "--help":
             usage()
 
         if arg == "-h" or arg == "--help":
             usage()
 
+        if arg == "-q" or arg == "--quiet":
+            QUIET = True
+
         if arg == "--no-color":
             green_start = ""
             color_stop = ""
         if arg == "--no-color":
             green_start = ""
             color_stop = ""