def do_browse(self, _, dir): if self.filename.get_text(): start = os.path.dirname(self.filename.get_text()) else: start = None if dir: fn = platform.get_platform().gui_select_dir(start) else: fn = platform.get_platform().gui_save_file(start, types=self.types) if fn: self.filename.set_text(fn)
def validate_doc(doc): """Validate the document""" path = platform.get_platform().find_resource("chirp.xsd") try: ctx = libxml2.schemaNewParserCtxt(path) schema = ctx.schemaParse() except libxml2.parserError as e: LOG.error("Unable to load schema: %s" % e) LOG.error("Path: %s" % path) raise errors.RadioError("Unable to load schema") del ctx errs = [] warnings = [] def _err(msg, *_args): errs.append("ERROR: %s" % msg) def _wrn(msg, *_args): warnings.append("WARNING: %s" % msg) validctx = schema.schemaNewValidCtxt() validctx.setValidityErrorHandler(_err, _wrn) err = validctx.schemaValidateDoc(doc) for w in warnings: LOG.warn(w) if err: for l in [ "--- DOC ---", doc.serialize(format=1).split("\n"), "-----------", errs ]: LOG.error(l) raise errors.RadioError("Schema error")
def make_radio_sel(self): f = gtk.Frame("Radio") hbox = gtk.HBox(False, 2) hbox.set_border_width(2) self.w_radio = make_choice(RADIOS, False, RADIOS[0]) self.w_radio.connect("changed", self.select_radio) self.tips.set_tip(self.w_radio, "Select radio model") self.w_radio.show() hbox.pack_start(self.w_radio, 1, , ) l = gtk.Label(" on port ") l.show() hbox.pack_start(l, 0, , ) ports = platform.get_platform().list_serial_ports() if len(ports) > 0: default = ports[0] else: default = None self.w_port = make_choice(ports, True, default) self.w_port.connect("changed", self.select_radio) self.tips.set_tip(self.w_port, "Select serial port") self.w_port.show() hbox.pack_start(self.w_port, 1, , ) f.add(hbox) hbox.show() f.show() return f
def _check_for_updates(callback): LOG.debug("Checking for updates") proxy = xmlrpclib.ServerProxy(REPORT_URL) ver = proxy.check_for_updates(CHIRP_VERSION, platform.get_platform().os_version_string()) LOG.debug("Server reports version %s is latest" % ver) callback(ver) return True
def _check_for_updates(callback): debug("Checking for updates") proxy = xmlrpclib.ServerProxy(REPORT_URL) ver = proxy.check_for_updates(CHIRP_VERSION, platform.get_platform().os_version_string()) debug("Server reports version %s is latest" % ver) callback(ver) return True
def get(section="global"): global _CONFIG p = platform.get_platform() if not _CONFIG: _CONFIG = ChirpConfig(p.config_dir()) return ChirpConfigProxy(_CONFIG, section)
def _report_misc_error(module, data): global ENABLED LOG.debug("Reporting misc error with %s" % module) proxy = xmlrpclib.ServerProxy(REPORT_URL) id = proxy.report_misc_error(CHIRP_VERSION, platform.get_platform().os_version_string(), module, data) # If the server returns zero, it wants us to shut up return id != 0
def _report_exception(stack): global ENABLED LOG.debug("Reporting exception") proxy = xmlrpclib.ServerProxy(REPORT_URL) id = proxy.report_exception(CHIRP_VERSION, platform.get_platform().os_version_string(), "exception", stack) # If the server returns zero, it wants us to shut up return id != 0
def validate_doc(doc): """Validate the document""" path = platform.get_platform().find_resource("chirp.xsd") try: ctx = libxml2.schemaNewParserCtxt(path) schema = ctx.schemaParse() except libxml2.parserError, e: LOG.error("Unable to load schema: %s" % e) LOG.error("Path: %s" % path) raise errors.RadioError("Unable to load schema")
def _report_exception(stack): global ENABLED debug("Reporting exception") proxy = xmlrpclib.ServerProxy(REPORT_URL) id = proxy.report_exception(CHIRP_VERSION, platform.get_platform().os_version_string(), "exception", stack) # If the server returns zero, it wants us to shut up return id != 0
def _report_misc_error(module, data): global ENABLED debug("Reporting misc error with %s" % module) proxy = xmlrpclib.ServerProxy(REPORT_URL) id = proxy.report_misc_error(CHIRP_VERSION, platform.get_platform().os_version_string(), module, data) # If the server returns zero, it wants us to shut up return id != 0
def validate_doc(doc): """Validate the document""" basepath = platform.get_platform().executable_path() path = os.path.abspath(os.path.join(basepath, "chirp.xsd")) if not os.path.exists(path): path = "/usr/share/chirp/chirp.xsd" try: ctx = libxml2.schemaNewParserCtxt(path) schema = ctx.schemaParse() except libxml2.parserError, e: print "Unable to load schema: %s" % e print "Path: %s" % path raise errors.RadioError("Unable to load schema")
def validate_doc(doc): """Validate the document""" basepath = platform.get_platform().executable_path() path = os.path.abspath(os.path.join(basepath, "chirp.xsd")) if not os.path.exists(path): path = "/usr/share/chirp/chirp.xsd" try: ctx = libxml2.schemaNewParserCtxt(path) schema = ctx.schemaParse() except libxml2.parserError, e: LOG.error("Unable to load schema: %s" % e) LOG.error("Path: %s" % path) raise errors.RadioError("Unable to load schema")
def __make_port(self, port): conf = config.get("state") ports = platform.get_platform().list_serial_ports() if not port: if conf.get("last_port"): port = conf.get("last_port") elif ports: port = ports[0] else: port = "" if port not in ports: ports.insert(0, port) return miscwidgets.make_choice(ports, True, port)
def _report_model_usage(model, direction, success): global ENABLED if direction not in ["live", "download", "upload", "import", "export", "importsrc"]: LOG.warn("Invalid direction `%s'" % direction) return True # This is a bug, but not fatal model = "%s_%s" % (model.VENDOR, model.MODEL) data = "%s,%s,%s" % (model, direction, success) LOG.debug("Reporting model usage: %s" % data) proxy = xmlrpclib.ServerProxy(REPORT_URL) id = proxy.report_stats(CHIRP_VERSION, platform.get_platform().os_version_string(), "model_use", data) # If the server returns zero, it wants us to shut up return id != 0
def _report_model_usage(model, direction, success): global ENABLED if direction not in [ "live", "download", "upload", "import", "export", "importsrc" ]: print "Invalid direction `%s'" % direction return True # This is a bug, but not fatal model = "%s_%s" % (model.VENDOR, model.MODEL) data = "%s,%s,%s" % (model, direction, success) debug("Reporting model usage: %s" % data) proxy = xmlrpclib.ServerProxy(REPORT_URL) id = proxy.report_stats(CHIRP_VERSION, platform.get_platform().os_version_string(), "model_use", data) # If the server returns zero, it wants us to shut up return id != 0
def __init__(self, *a, **k): super(ChirpCloneDialog, self).__init__(*a, title='Communicate with radio', **k) panel = wx.Panel(self) try: grid = wx.FlexGridSizer(3, 2) except TypeError: grid = wx.FlexGridSizer(2, 5, 0) def _add_grid(label, control): grid.Add(wx.StaticText(panel, label=label), border=20, flag=wx.ALIGN_CENTER | wx.RIGHT | wx.LEFT) grid.Add(control, 1, flag=wx.EXPAND) ports = platform.get_platform().list_serial_ports() last_port = CONF.get('last_port', 'state') if last_port and last_port not in ports: ports.insert(0, last_port) elif not last_port: last_port = ports[0] self._port = wx.ComboBox(panel, choices=ports) self._port.SetValue(last_port) self.Bind(wx.EVT_COMBOBOX, self._selected_port, self._port) _add_grid('Port', self._port) self._vendor = wx.Choice(panel, choices=['Icom', 'Yaesu']) _add_grid('Vendor', self._vendor) self.Bind(wx.EVT_CHOICE, self._selected_vendor, self._vendor) self._model = wx.Choice(panel, choices=[]) _add_grid('Model', self._model) self.Bind(wx.EVT_CHOICE, self._selected_model, self._model) self.gauge = wx.Gauge(panel) hbox2 = wx.BoxSizer(wx.HORIZONTAL) action = self._make_action(panel) hbox2.Add(action) self._action_button = action cancel = wx.Button(panel, wx.ID_CANCEL) hbox2.Add(cancel, flag=wx.RIGHT) vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(grid, proportion=0, flag=wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, border=20) vbox.Add(self.gauge, flag=wx.EXPAND, border=10, proportion=1) vbox.Add(wx.StaticLine(panel), flag=wx.EXPAND | wx.TOP, border=10) vbox.Add(hbox2, proportion=0, flag=wx.ALIGN_RIGHT | wx.ALL, border=10) panel.SetSizer(vbox) self._vendors = collections.defaultdict(list) for rclass in directory.DRV_TO_RADIO.values(): if (not issubclass(rclass, chirp_common.CloneModeRadio) and not issubclass(rclass, chirp_common.LiveRadio)): continue self._vendors[rclass.VENDOR].append(rclass) for alias in rclass.ALIASES: self._vendors[alias.VENDOR].append(alias) self._vendor.Set(sorted(self._vendors.keys())) try: self.select_vendor_model(CONF.get('last_vendor', 'state'), CONF.get('last_model', 'state')) except ValueError as e: LOG.warning('Last vendor/model not found')
def pick_file(self, button): fn = platform.get_platform().gui_save_file() if fn: self.w_filename.set_text(fn)