comparison getan.py @ 30:fea63a224065

Stop still running projects before getan quits - even if getan crashes.
author Ingo Weinzierl <ingo_weinzierl@web.de>
date Mon, 30 Aug 2010 22:21:47 +0200
parents 5e4d2810a739
children fa5b3b1db867
comparison
equal deleted inserted replaced
29:f5426961a380 30:fea63a224065
128 logger.info("Start project '%s' at %s." 128 logger.info("Start project '%s' at %s."
129 % (project.desc, format_time(datetime.now()))) 129 % (project.desc, format_time(datetime.now())))
130 self.view.set_footer_text(" Running on '%s'" % project.desc, 'running') 130 self.view.set_footer_text(" Running on '%s'" % project.desc, 'running')
131 logger.debug('All running projects: %r' % self.running) 131 logger.debug('All running projects: %r' % self.running)
132 132
133 def stop_project(self): 133 def stop_project(self, desc='-no description-'):
134 project = self.running.pop() 134 project = self.running.pop()
135 desc = self.view.get_frame().get_footer().get_edit_text()
136 logger.info("Stop project '%s' at %s." 135 logger.info("Stop project '%s' at %s."
137 % (project.desc, format_time(datetime.now()))) 136 % (project.desc, format_time(datetime.now())))
138 project.stop = datetime.now() 137 project.stop = datetime.now()
139 self.backend.insert_project_entry(project, datetime.now(), desc) 138 self.backend.insert_project_entry(project, datetime.now(), desc)
140 self.update_entries(project) 139 self.update_entries(project)
141 self.update_project_list() 140 self.update_project_list()
142 logger.debug('Still running projects: %r' % self.running) 141 logger.debug('Still running projects: %r' % self.running)
142
143 def __enter__(self):
144 return self
145
146 def __exit__(self, type, value, traceback):
147 for project in self.running:
148 self.stop_project()
143 149
144 150
145 def main(): 151 def main():
146 config.initialize() 152 config.initialize()
147 global logger 153 global logger
151 logging.info("Use database '%s'." % sys.argv[1]) 157 logging.info("Use database '%s'." % sys.argv[1])
152 else: 158 else:
153 backend = Backend() 159 backend = Backend()
154 logging.info("Use database '%s'." % DEFAULT_DATABASE) 160 logging.info("Use database '%s'." % DEFAULT_DATABASE)
155 161
156 controller = GetanController(backend, ProjectList, EntryList) 162 with GetanController(backend, ProjectList, EntryList) as controller:
157 controller.main() 163 controller.main()
158 164
159 165
160 if __name__ == '__main__': 166 if __name__ == '__main__':
161 main() 167 main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)