diff getan.py @ 41:f44f808e7d47

Make getan runnable if there is no project in database.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 15 Dec 2010 11:55:25 +0100
parents f96a18c10836
children a5439795ef09
line wrap: on
line diff
--- a/getan.py	Wed Dec 15 11:37:46 2010 +0100
+++ b/getan.py	Wed Dec 15 11:55:25 2010 +0100
@@ -26,7 +26,10 @@
         self.pv_class = pv_class
 
         self.projects = backend.load_projects()
-        entries       = backend.load_entries(self.projects[0].id)
+        if self.projects:
+            entries = backend.load_entries(self.projects[0].id)
+        else:
+            entries = []
         self.running  = []
 
         self.backend      = backend
@@ -119,6 +122,7 @@
         return None
 
     def start_project(self, project):
+        if not project: return
         self.running.append(project)
         project.start = datetime.now()
         logger.info("Start project '%s' at %s."
@@ -128,6 +132,7 @@
 
     def stop_project(self, desc='-no description-'):
         project = self.running.pop()
+        if not project: return
         logger.info("Stop project '%s' at %s."
                     % (project.desc, format_time(datetime.now())))
         project.stop = datetime.now()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)