def ok_file(self, button, filesel): path = filesel.get_filename() mdpath = join(dirname(path), 'machine_database.xml') action = filesel.get_data('action') filesel.destroy() dir = dirname(path) dbm = DatabaseManager(self.conn) if action == 'backup': dbm.backup(dir) elif action == 'restore': dbm.restore(dir)
def slotDbConnected(self, dsn): #print dsn #print 'slotDbConnected' for action in self.suiteActions.values(): action.unplug(self.suitemenu) self.suite_actions = {} self.cursor = self.app.conn.cursor(statement=True) if 'suites' in self.cursor.tables(): self._suites = [ row.suite for row in self.cursor.select(table='suites') ] self._initTraitsActions(self._suites) for action in self.manageTraitsActions.values(): action.plug(self.suitemenu) self.statusbar.message('Connected to %s on host %s' % (dsn['dbname'], dsn['dbhost'])) if not self.cursor.tables(): yesno = KMessageBox.questionYesNo(self, 'create primary tables?') if yesno == KMessageBox.Yes: dbm = DatabaseManager(self.app.conn) dbm.importer.start_schema()
def _import_export_directory_selected(self): win = self._import_export_dirsel_dialog if win is None: raise RuntimeError, 'There is no import export dialog' self._import_export_dirsel_dialog = None url = win.url() fullpath = str(url.path()) action = win.db_action print 'selected fullpath', fullpath print 'action is', win.db_action win.close() #self.app.processEvents() dbm = DatabaseManager(self.app.conn) if action == 'import': #dbm.restore(fullpath) win = ImportDbProgressDialog(self) importer = dbm.importer importer.report_total_apt_sources = win.aptsrc_progress.setTotalSteps #importer.report_aptsrc_imported = win.aptsrc_progress.step_progress importer.report_importing_aptsrc = win.aptsrc_progress.start_step importer.report_aptsrc_imported = win.aptsrc_progress.finish_step aptsrc = importer.aptsrc aptsrc.report_total_packages = win.package_progress.setTotalSteps aptsrc.report_package_inserted = win.package_progress.step_progress importer.report_total_suites = win.suite_progess.setTotalSteps importer.report_importing_suite = win.suite_progess.start_step importer.report_suite_imported = win.suite_progess.finish_step #importer.report_total_traits = win.trait_progress.setTotalSteps importer.report_total_traits = win.report_total_traits importer.report_trait_imported = win.trait_progress.step_progress importer.report_total_families = win.family_progress.setTotalSteps importer.report_family_imported = win.family_progress.step_progress importer.report_total_profiles = win.profile_progress.setTotalSteps importer.report_profile_imported = win.profile_progress.step_progress win.show() dbm.import_all(fullpath) self.app.processEvents() win.close() KMessageBox.information(self, 'Database Imported') elif action == 'export': #dbm.backup(fullpath) win = ExportDbProgressDialog(self) exporter = dbm.exporter exporter.report_total_suites = win.suite_progess.setTotalSteps exporter.report_exporting_suite = win.suite_progess.start_step exporter.report_suite_exported = win.suite_progess.finish_step exporter.report_total_traits = win.trait_progress.setTotalSteps exporter.report_trait_exported = win.trait_progress.step_progress #exporter.report_all_traits_exported = win.trait_progress.progressbar.reset exporter.report_start_exporting_traits = win.trait_progress.progressbar.reset exporter.report_total_profiles = win.profile_progress.setTotalSteps exporter.report_profile_exported = win.profile_progress.step_progress family = exporter.family family.report_total_families = win.family_progress.setTotalSteps family.report_family_exported = win.family_progress.step_progress win.show() self.app.processEvents() dbm.export_all(fullpath) self.app.processEvents() win.close() else: KMessageBox.error(self, 'action %s not supported' % action)
def _import_export_directory_selected(self): win = self._import_export_dirsel_dialog if win is None: raise RuntimeError , 'There is no import export dialog' self._import_export_dirsel_dialog = None url = win.url() fullpath = str(url.path()) action = win.db_action print 'selected fullpath', fullpath print 'action is', win.db_action win.close() #self.app.processEvents() dbm = DatabaseManager(self.app.conn) if action == 'import': #dbm.restore(fullpath) win = ImportDbProgressDialog(self) importer = dbm.importer importer.report_total_apt_sources = win.aptsrc_progress.setTotalSteps #importer.report_aptsrc_imported = win.aptsrc_progress.step_progress importer.report_importing_aptsrc = win.aptsrc_progress.start_step importer.report_aptsrc_imported = win.aptsrc_progress.finish_step aptsrc = importer.aptsrc aptsrc.report_total_packages = win.package_progress.setTotalSteps aptsrc.report_package_inserted = win.package_progress.step_progress importer.report_total_suites = win.suite_progess.setTotalSteps importer.report_importing_suite = win.suite_progess.start_step importer.report_suite_imported = win.suite_progess.finish_step #importer.report_total_traits = win.trait_progress.setTotalSteps importer.report_total_traits = win.report_total_traits importer.report_trait_imported = win.trait_progress.step_progress importer.report_total_families = win.family_progress.setTotalSteps importer.report_family_imported = win.family_progress.step_progress importer.report_total_profiles = win.profile_progress.setTotalSteps importer.report_profile_imported = win.profile_progress.step_progress win.show() dbm.import_all(fullpath) self.app.processEvents() win.close() KMessageBox.information(self, 'Database Imported') elif action == 'export': #dbm.backup(fullpath) win = ExportDbProgressDialog(self) exporter = dbm.exporter exporter.report_total_suites = win.suite_progess.setTotalSteps exporter.report_exporting_suite = win.suite_progess.start_step exporter.report_suite_exported = win.suite_progess.finish_step exporter.report_total_traits = win.trait_progress.setTotalSteps exporter.report_trait_exported = win.trait_progress.step_progress #exporter.report_all_traits_exported = win.trait_progress.progressbar.reset exporter.report_start_exporting_traits = win.trait_progress.progressbar.reset exporter.report_total_profiles = win.profile_progress.setTotalSteps exporter.report_profile_exported = win.profile_progress.step_progress family = exporter.family family.report_total_families = win.family_progress.setTotalSteps family.report_family_exported = win.family_progress.step_progress win.show() self.app.processEvents() dbm.export_all(fullpath) self.app.processEvents() win.close() else: KMessageBox.error(self, 'action %s not supported' % action)