def run(self):
r = gtk.Dialog.run(self)
if r != gtk.RESPONSE_OK:
return None
vendor = self.__vend.get_active_text()
model = self.__modl.get_active_text()
cs = CloneSettings()
cs.port = self.__port.get_active_text()
if model == _("Detect"):
try:
cs.radio_class = detect.DETECT_FUNCTIONS[vendor](cs.port)
if not cs.radio_class:
raise Exception(
_("Unable to detect radio on {port}").format(
port=cs.port))
except Exception, e:
d = inputdialog.ExceptionDialog(e)
d.run()
d.destroy()
return None
else:
for rclass in directory.DRV_TO_RADIO.values():
if rclass.MODEL == model:
cs.radio_class = rclass
break
alias_match = None
for alias in rclass.ALIASES:
if alias.MODEL == model:
alias_match = rclass
break
if alias_match:
cs.radio_class = rclass
LOG.debug(
'Chose %s alias for %s because model %s selected' % (
alias_match, cs.radio_class, model))
break
if not cs.radio_class:
common.show_error(
_("Internal error: Unable to upload to {model}").format(
model=model))
LOG.info(self.__vendors)
return None
conf = config.get("state")
conf.set("last_port", cs.port)
conf.set("last_vendor", cs.radio_class.VENDOR)
conf.set("last_model", model)
return cs
评论列表
文章目录