changeset 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 3bea335c0f30
children 40f52b4b02a4
files ChangeLog getan.py
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon May 30 15:45:25 2011 +0200
+++ b/ChangeLog	Mon May 30 18:13:34 2011 +0200
@@ -1,3 +1,8 @@
+2011-05-30	Björn Ricks <bjoern.ricks@intevation.de>
+
+	* getan.py: Handle KeyboardInterrupt and shutdown getan
+	carefully afterwards
+
 2011-05-30	Björn Ricks <bjoern.ricks@intevation.de>
 
 	* getan/states.py: Save the current project when switching to Running state.
--- 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)