예제 #1
0
    def run(self):
        if isinstance(self._wrapper._dst, chirp_common.LiveRadio):
            raise TestSkippedError("This is a live radio")

        filename = self._wrapper._filename

        try:
            radio = directory.get_radio_by_image(filename)
        except Exception, e:
            raise TestFailedError("Failed to detect", str(e))
예제 #2
0
파일: main.py 프로젝트: SDoradus/py3-CHIRP
    def open_file(self, filename, exists=True, select=True):

        if exists:
            radio = directory.get_radio_by_image(filename)
        else:
            CSVRadio = directory.get_radio('Generic_CSV')
            radio = CSVRadio(None)

        editorset = ChirpEditorSet(radio, filename, self._editors)
        self.add_editorset(editorset, select=select)
예제 #3
0
    def run(self):
        if isinstance(self._wrapper._dst, chirp_common.LiveRadio):
            raise TestSkippedError("This is a live radio")

        filename = self._wrapper._filename

        try:
            radio = directory.get_radio_by_image(filename)
        except Exception, e:
            raise TestFailedError("Failed to detect", str(e))
예제 #4
0
    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))
예제 #5
0
 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, e:
         common.show_error(e)
         return
예제 #6
0
 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, e:
         common.show_error(e)
         return
예제 #7
0
파일: run_tests.py 프로젝트: atpage/chirp
    def run(self):
        if isinstance(self._wrapper._dst, chirp_common.LiveRadio):
            raise TestSkippedError("This is a live radio")

        filename = self._wrapper._filename

        try:
            radio = directory.get_radio_by_image(filename)
        except Exception as e:
            raise TestFailedError("Failed to detect", str(e))

        if radio.__class__.__name__ == 'DynamicRadioAlias':
            # This was detected via metadata and wrapped, which means
            # we found the appropriate class.
            pass
        elif issubclass(self._wrapper._dstclass, radio.__class__):
            pass
        elif issubclass(radio.__class__, self._wrapper._dstclass):
            pass
        elif radio.__class__ != self._wrapper._dstclass:
            raise TestFailedError("%s detected as %s" %
                                  (self._wrapper._dstclass, radio.__class__))
        return []
예제 #8
0
 def _test_detect_finds_our_class(self, tempfn):
     radio = directory.get_radio_by_image(tempfn)
     self.assertTrue(isinstance(radio, self.test_class))
     return radio
예제 #9
0
    def __init__(self,
                 source,
                 parent_window=None,
                 filename=None,
                 tempname=None):
        gtk.VBox.__init__(self, True, 0)

        self.parent_window = parent_window

        if isinstance(source, str):
            self.filename = source
            self.radio = directory.get_radio_by_image(self.filename)
        elif isinstance(source, chirp_common.Radio):
            self.radio = source
            self.filename = filename or tempname or source.VARIANT
        else:
            raise Exception("Unknown source type")

        rthread = common.RadioThread(self.radio)
        rthread.setDaemon(True)
        rthread.start()

        rthread.connect("status", lambda e, m: self.emit("status", m))

        self.tabs = gtk.Notebook()
        self.tabs.connect("switch-page", self.tab_selected)
        self.tabs.set_tab_pos(gtk.POS_LEFT)

        self.editors = {}

        self.rf = self.radio.get_features()
        if self.rf.has_sub_devices:
            devices = self.radio.get_sub_devices()
        else:
            devices = [self.radio]

        index = 0
        for device in devices:
            devrthread = common.RadioThread(device, rthread)
            devrthread.setDaemon(True)
            devrthread.start()
            self._make_device_editors(device, devrthread, index)
            index += 1

        if self.rf.has_settings:
            editor = settingsedit.SettingsEditor(rthread)
            self.tabs.append_page(editor.root, gtk.Label(_("Settings")))
            editor.root.show()
            editor.connect("changed", self.editor_changed)
            self.editors["settings"] = editor

        conf = config.get()
        if (hasattr(self.rthread.radio, '_memobj')
                and conf.get_bool("developer", "state")):
            editor = radiobrowser.RadioBrowser(self.rthread)
            lab = gtk.Label(_("Browser"))
            self.tabs.append_page(editor.root, lab)
            editor.connect("changed", self.editor_changed)
            self.editors["browser"] = editor

        self.pack_start(self.tabs)
        self.tabs.show()

        self.label = self.text_label = None
        self.make_label()
        self.modified = (tempname is not None)
        if tempname:
            self.filename = tempname
        self.update_tab()
예제 #10
0
    def __init__(self, source, parent_window=None,
                 filename=None, tempname=None):
        gtk.VBox.__init__(self, True, 0)

        self.parent_window = parent_window

        if isinstance(source, str):
            self.filename = source
            self.radio = directory.get_radio_by_image(self.filename)
        elif isinstance(source, chirp_common.Radio):
            self.radio = source
            self.filename = filename or tempname or source.VARIANT
        else:
            raise Exception("Unknown source type")

        rthread = common.RadioThread(self.radio)
        rthread.setDaemon(True)
        rthread.start()

        rthread.connect("status", lambda e, m: self.emit("status", m))

        self.tabs = gtk.Notebook()
        self.tabs.connect("switch-page", self.tab_selected)
        self.tabs.set_tab_pos(gtk.POS_LEFT)

        self.editors = {}

        self.rf = self.radio.get_features()
        if self.rf.has_sub_devices:
            devices = self.radio.get_sub_devices()
        else:
            devices = [self.radio]

        index = 0
        for device in devices:
            devrthread = common.RadioThread(device, rthread)
            devrthread.setDaemon(True)
            devrthread.start()
            self._make_device_editors(device, devrthread, index)
            index += 1

        if self.rf.has_settings:
            editor = settingsedit.SettingsEditor(rthread)
            self.tabs.append_page(editor.root, gtk.Label(_("Settings")))
            editor.root.show()
            editor.connect("changed", self.editor_changed)
            self.editors["settings"] = editor

        conf = config.get()
        if (hasattr(self.rthread.radio, '_memobj') and
                conf.get_bool("developer", "state")):
            editor = radiobrowser.RadioBrowser(self.rthread)
            lab = gtk.Label(_("Browser"))
            self.tabs.append_page(editor.root, lab)
            editor.connect("changed", self.editor_changed)
            self.editors["browser"] = editor

        self.pack_start(self.tabs)
        self.tabs.show()

        self.label = self.text_label = None
        self.make_label()
        self.modified = (tempname is not None)
        if tempname:
            self.filename = tempname
        self.update_tab()
예제 #11
0
    (options, args) = parser.parse_args()

    if options.id:
        from chirp import icf

        s = serial.Serial(port=options.serial, baudrate=9600, timeout=0.5)

        md = icf.get_model_data(s)

        print "Model:\n%s" % util.hexprint(md)

        sys.exit(0)

    if not options.radio:
        if options.mmap:
            rclass = directory.get_radio_by_image(options.mmap).__class__
        else:
            print "Must specify a radio model"
            sys.exit(1)
    else:
        rclass = directory.get_radio(options.radio)

    if options.serial == "mmap":
        if options.mmap:
            s = options.mmap
        else:
            s = options.radio + ".img"
    else:
        print "opening %s at %i" % (options.serial, rclass.BAUD_RATE)
        s = serial.Serial(port=options.serial,
                          baudrate=rclass.BAUD_RATE,
예제 #12
0
파일: chirp.py 프로젝트: cl4u2/chirp
	if options.id:
	    from chirp import icf

	    s = serial.Serial(port=options.serial,
			      baudrate=9600,
			      timeout=0.5)

	    md = icf.get_model_data(s)

	    print "Model:\n%s" % util.hexprint(md)

	    sys.exit(0)

	if not options.radio:
            if options.mmap:
                rclass = directory.get_radio_by_image(options.mmap).__class__
            else:
                print "Must specify a radio model"
                sys.exit(1)
	else:
	    rclass = directory.get_radio(options.radio)

	if options.serial == "mmap":
	    if options.mmap:
		s = options.mmap
	    else:
		s = options.radio + ".img"
	else:
	    print "opening %s at %i" % (options.serial, rclass.BAUD_RATE)
	    s = serial.Serial(port=options.serial,
			      baudrate=rclass.BAUD_RATE,
예제 #13
0
        self._radio = rthread.radio
        self._focused = False
        self._build_ui()
        self._fill('root', self._radio._memobj)

    def focus(self):
        self._focused = True

    def unfocus(self):
        if self._focused:
            self.emit("changed")
            self._focused = False


if __name__ == "__main__":
    from chirp.drivers import *
    from chirp import directory
    import sys

    r = directory.get_radio_by_image(sys.argv[1])

    class Foo:
        radio = r

    w = gtk.Window()
    b = RadioBrowser(Foo)
    w.set_default_size(1024, 768)
    w.add(b.root)
    w.show()
    gtk.main()
예제 #14
0
        self._radio = rthread.radio
        self._focused = False
        self._build_ui()
        self._fill("root", self._radio._memobj)

    def focus(self):
        self._focused = True

    def unfocus(self):
        if self._focused:
            self.emit("changed")
            self._focused = False


if __name__ == "__main__":
    from chirp.drivers import *
    from chirp import directory
    import sys

    r = directory.get_radio_by_image(sys.argv[1])

    class Foo:
        radio = r

    w = gtk.Window()
    b = RadioBrowser(Foo)
    w.set_default_size(1024, 768)
    w.add(b.root)
    w.show()
    gtk.main()
예제 #15
0
 def _test_detect_finds_our_class(self, tempfn):
     radio = directory.get_radio_by_image(tempfn)
     self.assertTrue(isinstance(radio, self.test_class))
     return radio