diff getan.py @ 90:04dbf4c9f297

Handle KeyboardInterrupt and shutdown getan carefully afterwards
author Björn Ricks <bjoern.ricks@intevation.de>
date Mon, 30 May 2011 18:13:34 +0200
parents f0e4637ad4e4
children 99639833968d
line wrap: on
line diff
--- a/getan.py	Mon May 30 15:45:25 2011 +0200
+++ b/getan.py	Mon May 30 18:13:34 2011 +0200
@@ -133,7 +133,7 @@
         self.view.set_footer_text(" Running on '%s'" % project.desc, 'running')
         logger.debug('All running projects: %r' % self.running)
 
-    def stop_project(self, desc='-no description-'):
+    def stop_project(self, desc='-no description-', display=True):
         if not self.running: return
         project = self.running.pop()
         if not project: return
@@ -141,8 +141,9 @@
                     % (project.desc, format_time(datetime.now())))
         project.stop = datetime.now()
         self.backend.insert_project_entry(project, datetime.now(), desc)
-        self.update_entries(project)
-        self.update_project_list()
+        if display:
+            self.update_entries(project)
+            self.update_project_list()
         logger.debug('Still running projects: %r' % self.running)
 
     def add_project(self, key, description):
@@ -156,7 +157,7 @@
 
     def shutdown(self):
         for project in self.running:
-            self.stop_project()
+            self.stop_project(display=False)
 
 
 def main():
@@ -189,6 +190,8 @@
 
     try:
         controller.main()
+    except KeyboardInterrupt:
+        pass
     finally:
         controller.shutdown()
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)