comparison 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
comparison
equal deleted inserted replaced
40:e4759cc8f5e7 41:f44f808e7d47
24 def __init__(self, backend, pv_class, ev_class): 24 def __init__(self, backend, pv_class, ev_class):
25 self.ev_class = ev_class 25 self.ev_class = ev_class
26 self.pv_class = pv_class 26 self.pv_class = pv_class
27 27
28 self.projects = backend.load_projects() 28 self.projects = backend.load_projects()
29 entries = backend.load_entries(self.projects[0].id) 29 if self.projects:
30 entries = backend.load_entries(self.projects[0].id)
31 else:
32 entries = []
30 self.running = [] 33 self.running = []
31 34
32 self.backend = backend 35 self.backend = backend
33 self.project_view = pv_class(self, self.projects) 36 self.project_view = pv_class(self, self.projects)
34 self.entries_view = ev_class(entries) 37 self.entries_view = ev_class(entries)
117 if proj.id == id: 120 if proj.id == id:
118 return proj 121 return proj
119 return None 122 return None
120 123
121 def start_project(self, project): 124 def start_project(self, project):
125 if not project: return
122 self.running.append(project) 126 self.running.append(project)
123 project.start = datetime.now() 127 project.start = datetime.now()
124 logger.info("Start project '%s' at %s." 128 logger.info("Start project '%s' at %s."
125 % (project.desc, format_time(datetime.now()))) 129 % (project.desc, format_time(datetime.now())))
126 self.view.set_footer_text(" Running on '%s'" % project.desc, 'running') 130 self.view.set_footer_text(" Running on '%s'" % project.desc, 'running')
127 logger.debug('All running projects: %r' % self.running) 131 logger.debug('All running projects: %r' % self.running)
128 132
129 def stop_project(self, desc='-no description-'): 133 def stop_project(self, desc='-no description-'):
130 project = self.running.pop() 134 project = self.running.pop()
135 if not project: return
131 logger.info("Stop project '%s' at %s." 136 logger.info("Stop project '%s' at %s."
132 % (project.desc, format_time(datetime.now()))) 137 % (project.desc, format_time(datetime.now())))
133 project.stop = datetime.now() 138 project.stop = datetime.now()
134 self.backend.insert_project_entry(project, datetime.now(), desc) 139 self.backend.insert_project_entry(project, datetime.now(), desc)
135 self.update_entries(project) 140 self.update_entries(project)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)