def open_file(self): old_db = db.get_db() try: file = QtWidgets.QFileDialog.getOpenFileName(None, ' Open log database')[0] if not os.path.isfile(file): return except: return try: db.set_db(file) self._init_filter() except DBError: db.set_db(old_db) QtWidgets.QMessageBox.critical(self, "Database Error", "Not a log database", QtWidgets.QMessageBox.Ok) else: QtWidgets.QMessageBox.information(self, "Import database", "Import successfully", QtWidgets.QMessageBox.Ok)
def __init__(self, parent, infile, outfile): super(ImportDialog, self).__init__(parent) self.parent = parent self.setupUi(self) self.imported_file = infile self.db_file = outfile self.progress.setMaximum(100) self._paused = False self._cancel = False self._importing = False self._old_db = db.get_db() try: db.set_db(outfile) except: db.set_db(self._old_db) self.close() else: self.button_import.clicked.connect(self._log_import) self.button_cancel.clicked.connect(self.cancel)