def run(self): LOG.debug("Clone thread started") gobject.idle_add(self.__progw.show) self.__radio.status_fn = self.__status try: if self.__out: self.__radio.sync_out() else: self.__radio.sync_in() emsg = None except Exception as e: common.log_exception() LOG.error(_("Clone failed: {error}").format(error=e)) emsg = e gobject.idle_add(self.__progw.hide) # NB: Compulsory close of the radio's serial connection self.__radio.pipe.close() LOG.debug("Clone thread ended") if self.__cback and not self.__cancelled: gobject.idle_add(self.__cback, self.__radio, emsg)
def do_import(self, filen): current_editor = self.get_current_editor() if not isinstance(current_editor, memedit.MemoryEditor): # FIXME: We need a nice message to let the user know that they # need to select the appropriate memory editor tab before doing # and import so that we know which thread and editor to import # into and refresh. This will do for the moment. common.show_error("Memory editor must be selected before import") try: src_radio = directory.get_radio_by_image(filen) except Exception as e: common.show_error(e) return if isinstance(src_radio, chirp_common.NetworkSourceRadio): ww = importdialog.WaitWindow("Querying...", self.parent_window) ww.show() def status(status): ww.set(float(status.cur) / float(status.max)) try: src_radio.status_fn = status src_radio.do_fetch() except Exception as e: common.show_error(e) ww.hide() return ww.hide() try: if src_radio.get_features().has_sub_devices: src_radio = self.choose_sub_device(src_radio) except Exception as e: common.show_error(e) return if len(src_radio.errors) > 0: _filen = os.path.basename(filen) common.show_error_text( _("There were errors while opening {file}. " "The affected memories will not " "be importable!").format(file=_filen), "\r\n".join(src_radio.errors)) try: count = self._do_import_locked(importdialog.ImportDialog, src_radio, self.rthread) reporting.report_model_usage(src_radio, "importsrc", True) except Exception as e: common.log_exception() common.show_error( _("There was an error during " "import: {error}").format(error=e))
def do_export(self, filen): try: if filen.lower().endswith(".csv"): dst_radio = generic_csv.CSVRadio(filen) elif filen.lower().endswith(".chirp"): dst_radio = generic_xml.XMLRadio(filen) else: raise Exception(_("Unsupported file type")) except Exception, e: common.log_exception() common.show_error(e) return
def run(self): LOG.debug("Clone thread started") gobject.idle_add(self.__progw.show) self.__radio.status_fn = self.__status try: if self.__out: self.__radio.sync_out() else: self.__radio.sync_in() emsg = None except Exception, e: common.log_exception() LOG.error("Clone failed: {error}".format(error=e)) emsg = e
def run(self): LOG.debug("Clone thread started") gobject.idle_add(self.__progw.show) self.__radio.status_fn = self.__status try: if self.__out: self.__radio.sync_out() else: self.__radio.sync_in() emsg = None except Exception, e: common.log_exception() LOG.error(_("Clone failed: {error}").format(error=e)) emsg = e
def do_export(self, filen): try: if filen.lower().endswith(".csv"): dst_radio = generic_csv.CSVRadio(filen) elif filen.lower().endswith(".chirp"): dst_radio = generic_xml.XMLRadio(filen) else: raise Exception(_("Unsupported file type")) except Exception as e: common.log_exception() common.show_error(e) return dst_rthread = common.RadioThread(dst_radio) dst_rthread.setDaemon(True) dst_rthread.start() try: count = self._do_import_locked(importdialog.ExportDialog, self.rthread.radio, dst_rthread) except Exception as e: common.log_exception() common.show_error(_("There was an error during " "export: {error}").format(error=e), self.parent_window) return if count <= 0: return # Wait for thread queue to complete dst_rthread._qlock_when_idle() try: dst_radio.save(filename=filen) except Exception as e: common.log_exception() common.show_error(_("There was an error during " "export: {error}").format(error=e), self)
return if len(src_radio.errors) > 0: _filen = os.path.basename(filen) common.show_error_text( _("There were errors while opening {file}. " "The affected memories will not " "be importable!").format(file=_filen), "\r\n".join(src_radio.errors)) try: count = self._do_import_locked(importdialog.ImportDialog, src_radio, self.rthread) reporting.report_model_usage(src_radio, "importsrc", True) except Exception, e: common.log_exception() common.show_error( _("There was an error during " "import: {error}").format(error=e)) def do_export(self, filen): try: if filen.lower().endswith(".csv"): dst_radio = generic_csv.CSVRadio(filen) elif filen.lower().endswith(".chirp"): dst_radio = generic_xml.XMLRadio(filen) else: raise Exception(_("Unsupported file type")) except Exception, e: common.log_exception() common.show_error(e)
return if len(src_radio.errors) > 0: _filen = os.path.basename(filen) common.show_error_text(_("There were errors while opening {file}. " "The affected memories will not " "be importable!").format(file=_filen), "\r\n".join(src_radio.errors)) try: count = self._do_import_locked(importdialog.ImportDialog, src_radio, self.rthread) reporting.report_model_usage(src_radio, "importsrc", True) except Exception, e: common.log_exception() common.show_error(_("There was an error during " "import: {error}").format(error=e)) def do_export(self, filen): try: if filen.lower().endswith(".csv"): dst_radio = generic_csv.CSVRadio(filen) elif filen.lower().endswith(".chirp"): dst_radio = generic_xml.XMLRadio(filen) else: raise Exception(_("Unsupported file type")) except Exception, e: common.log_exception() common.show_error(e) return