def test_import_mem(self, errors=[]): radio = FakeRadio(None) src_rf = chirp_common.RadioFeatures() mem = chirp_common.Memory() self.mox.StubOutWithMock(mem, 'dupe') self.mox.StubOutWithMock(import_logic, '_import_name') self.mox.StubOutWithMock(import_logic, '_import_power') self.mox.StubOutWithMock(import_logic, '_import_tone') self.mox.StubOutWithMock(import_logic, '_import_dtcs') self.mox.StubOutWithMock(import_logic, '_import_mode') self.mox.StubOutWithMock(import_logic, '_import_duplex') self.mox.StubOutWithMock(radio, 'validate_memory') mem.dupe().AndReturn(mem) import_logic._import_name(radio, src_rf, mem) import_logic._import_power(radio, src_rf, mem) import_logic._import_tone(radio, src_rf, mem) import_logic._import_dtcs(radio, src_rf, mem) import_logic._import_mode(radio, src_rf, mem) import_logic._import_duplex(radio, src_rf, mem) radio.validate_memory(mem).AndReturn(errors) self.mox.ReplayAll() import_logic.import_mem(radio, src_rf, mem)
def run(self): src_rf = self._src.get_features() bounds = src_rf.memory_bounds dst_rf = self._wrapper.do("get_features") dst_number = dst_rf.memory_bounds[0] failures = [] for number in range(bounds[0], bounds[1]): src_mem = self._src.get_memory(number) if src_mem.empty: continue try: dst_mem = import_logic.import_mem( self._wrapper.get_radio(), src_rf, src_mem, overrides={"number": dst_number}) import_logic.import_bank(self._wrapper.get_radio(), self._src, dst_mem, src_mem) except import_logic.DestNotCompatible: continue except import_logic.ImportError, e: failures.append( TestFailedError("<%i>: Import Failed: %s" % (dst_number, e))) continue except Exception, e: raise TestCrashError(get_tb(), e, "[Import]")
def run(self): src_rf = self._src.get_features() bounds = src_rf.memory_bounds dst_rf = self._wrapper.do("get_features") dst_number = dst_rf.memory_bounds[0] failures = [] for number in range(bounds[0], bounds[1]): src_mem = self._src.get_memory(number) if src_mem.empty: continue try: dst_mem = import_logic.import_mem(self._wrapper.get_radio(), src_rf, src_mem, overrides={ "number": dst_number}) import_logic.import_bank(self._wrapper.get_radio(), self._src, dst_mem, src_mem) except import_logic.DestNotCompatible: continue except import_logic.ImportError, e: failures.append(TestFailedError("<%i>: Import Failed: %s" % (dst_number, e))) continue except Exception, e: raise TestCrashError(get_tb(), e, "[Import]")
def populate_list(self): start, end = self.src_radio.get_features().memory_bounds for i in range(start, end + 1): if end > 50 and i % (end / 50) == 0: self.ww.set(float(i) / end) try: mem = self.src_radio.get_memory(i) except errors.InvalidMemoryLocation as e: continue except Exception as e: self.__store.append(row=( False, i, i, "ERROR", chirp_common.format_freq(0), "", False, str(e), )) self.record_use_of(i) continue if mem.empty: continue self.ww.set(float(i) / end) try: msgs = self.dst_radio.validate_memory( import_logic.import_mem(self.dst_radio, self.src_radio.get_features(), mem)) except import_logic.DestNotCompatible: msgs = self.dst_radio.validate_memory(mem) errs = [ x for x in msgs if isinstance(x, chirp_common.ValidationError) ] if errs: msg = _("Cannot be imported because") + ":\r\n" msg += ",".join(errs) else: errs = [] msg = "Memory can be imported into target" self.__store.append(row=(not bool(msgs), mem.number, mem.number, mem.name, chirp_common.format_freq(mem.freq), mem.comment, not bool(errs), msg)) self.record_use_of(mem.number)
def do_import(self, dst_rthread): i = 0 error_messages = {} import_list = self.get_import_list() src_features = self.src_radio.get_features() for old, new, name, comm in import_list: i += 1 LOG.debug("%sing %i -> %i" % (self.ACTION, old, new)) src = self.src_radio.get_memory(old) try: mem = import_logic.import_mem(self.dst_radio, src_features, src, { "number": new, "name": name, "comment": comm }) except import_logic.ImportError as e: LOG.error("Import error: %s", e) error_messages[new] = str(e) continue job = common.RadioJob(None, "set_memory", mem) desc = _("Setting memory {number}").format(number=mem.number) job.set_desc(desc) dst_rthread._qsubmit(job, 0) job = ImportMemoryBankJob(None, mem, self.src_radio, src) job.set_desc(_("Importing bank information")) dst_rthread._qsubmit(job, 0) if error_messages.keys(): msg = _("Error importing memories:") + "\r\n" for num, msgs in error_messages.items(): msg += "%s: %s" % (num, ",".join(msgs)) common.show_error(msg) return i