]> git.itanic.dy.fi Git - emerge-timer/commitdiff
list_emerge_processes(): Don't exit the program, only return from the function
authorEsko Kokkonen <esko.kokkonen@gmail.com>
Sat, 26 Nov 2011 15:11:51 +0000 (17:11 +0200)
committerEsko Kokkonen <esko.kokkonen@gmail.com>
Sat, 26 Nov 2011 15:11:51 +0000 (17:11 +0200)
Exiting the whole program at this early point is not always what we
want. It is better to exit the function and resume the main function
in case we want to do something else in the program.

emerge-timer.py

index 739f8f4c4faa3c31c0707c5370efc42e5584ab4f..2b2c8187b1dd084e6191c0f93e4e07985ad3ebcd 100755 (executable)
@@ -366,7 +366,8 @@ def list_emerge_processes():
 
     if len(PACKAGES) == 0:
         print "No current emerge process found."
-        sys.exit(0)
+
+        return 1
 
 
     for line in f:
@@ -382,6 +383,8 @@ def list_emerge_processes():
                     if difference < p.emerge_time:
                         p.emerge_time = difference
 
+    return 0
+
 
 
 def main(status, user_package=None):
@@ -404,7 +407,8 @@ def main(status, user_package=None):
 
 
     elif status == "current":
-        list_emerge_processes()
+        if list_emerge_processes():
+            return
 
         print "Currently emerging:"