def on_destroy(self, widget=None, data=None): """on_destroy - called when the avernusWindow is closed. """ db.close_session() # save db on quit self.config.set_option('hpaned position', self.hpaned.get_position(), 'Gui') threads.terminate_all() Gtk.main_quit()
def main(): check_dependencies() try: init_translations() # Support for command line options. parser = optparse.OptionParser(version='%prog ' + avernus.__version__) parser.add_option("-d", "--debug", action="store_true", dest="debug", help=_("enable debug output")) parser.add_option("-f", "--file", dest="datafile", help="set database file") (options, args) = parser.parse_args() init_logger(options.debug) init_icons() db_file = options.datafile if db_file == None: configs = config.avernusConfig() default_file = os.path.join(config.config_path, 'avernus.db') db_file = configs.get_option('database file', default=default_file) from avernus.objects import db db.set_db(db_file) db.connect(True) GObject.threads_init() from avernus.gui.mainwindow import MainWindow main_window = MainWindow() try: Gtk.main() except: main_window.on_destroy() raise except: print "crashed ... !!" import traceback traceback.print_exc() db.close_session() threads.terminate_all() exit(1)
def tearDown(self): threads.terminate_all()