mirror of
https://github.com/kk7ds/chirp.git
synced 2024-09-21 10:37:15 +00:00
Fix style issues (3/4) (#2355)
This patch fixes more low-hanging style issues. For the most part, these are all whitespace changes, but there were a handful of idiomatic changes flagged by the pep8 tool too: "x.has_key(y)" is now "y in x".
This commit is contained in:
parent
ef0eb31224
commit
017ee7bf29
@ -18,6 +18,7 @@ import serial
|
||||
from chirp import errors, icf, directory, ic9x_ll
|
||||
from chirp import kenwood_live, icomciv
|
||||
|
||||
|
||||
def _icom_model_data_to_rclass(md):
|
||||
for _rtype, rclass in directory.DRV_TO_RADIO.items():
|
||||
if rclass.VENDOR != "Icom":
|
||||
@ -27,11 +28,9 @@ def _icom_model_data_to_rclass(md):
|
||||
if rclass.get_model()[:4] == md[:4]:
|
||||
return rclass
|
||||
|
||||
raise errors.RadioError("Unknown radio type %02x%02x%02x%02x" %\
|
||||
(ord(md[0]),
|
||||
ord(md[1]),
|
||||
ord(md[2]),
|
||||
ord(md[3])))
|
||||
raise errors.RadioError("Unknown radio type %02x%02x%02x%02x" %
|
||||
(ord(md[0]), ord(md[1]), ord(md[2]), ord(md[3])))
|
||||
|
||||
|
||||
def _detect_icom_radio(ser):
|
||||
# ICOM VHF/UHF Clone-type radios @ 9600 baud
|
||||
@ -65,6 +64,7 @@ def _detect_icom_radio(ser):
|
||||
|
||||
raise errors.RadioError("Unable to get radio model")
|
||||
|
||||
|
||||
def detect_icom_radio(port):
|
||||
"""Detect which Icom model is connected to @port"""
|
||||
ser = serial.Serial(port=port, timeout=0.5)
|
||||
@ -83,6 +83,7 @@ def detect_icom_radio(port):
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def detect_kenwoodlive_radio(port):
|
||||
"""Detect which Kenwood model is connected to @port"""
|
||||
ser = serial.Serial(port=port, baudrate=9600, timeout=0.5)
|
||||
@ -100,6 +101,6 @@ def detect_kenwoodlive_radio(port):
|
||||
raise errors.RadioError("Unsupported model `%s'" % r_id)
|
||||
|
||||
DETECT_FUNCTIONS = {
|
||||
"Icom" : detect_icom_radio,
|
||||
"Kenwood" : detect_kenwoodlive_radio,
|
||||
"Icom": detect_icom_radio,
|
||||
"Kenwood": detect_kenwoodlive_radio,
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ from chirp import chirp_common, util, rfinder, radioreference, errors
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def radio_class_id(cls):
|
||||
"""Return a unique identification string for @cls"""
|
||||
ident = "%s_%s" % (cls.VENDOR, cls.MODEL)
|
||||
@ -34,7 +35,10 @@ def radio_class_id(cls):
|
||||
ident = ident.replace(")", "")
|
||||
return ident
|
||||
|
||||
|
||||
ALLOW_DUPS = False
|
||||
|
||||
|
||||
def enable_reregistrations():
|
||||
"""Set the global flag ALLOW_DUPS=True, which will enable a driver
|
||||
to re-register for a slot in the directory without triggering an
|
||||
@ -44,6 +48,7 @@ def enable_reregistrations():
|
||||
print "NOTE: driver re-registration enabled"
|
||||
ALLOW_DUPS = True
|
||||
|
||||
|
||||
def register(cls):
|
||||
"""Register radio @cls with the directory"""
|
||||
global DRV_TO_RADIO
|
||||
@ -59,25 +64,29 @@ def register(cls):
|
||||
|
||||
return cls
|
||||
|
||||
|
||||
DRV_TO_RADIO = {}
|
||||
RADIO_TO_DRV = {}
|
||||
|
||||
|
||||
def get_radio(driver):
|
||||
"""Get radio driver class by identification string"""
|
||||
if DRV_TO_RADIO.has_key(driver):
|
||||
if driver in DRV_TO_RADIO:
|
||||
return DRV_TO_RADIO[driver]
|
||||
else:
|
||||
raise Exception("Unknown radio type `%s'" % driver)
|
||||
|
||||
|
||||
def get_driver(rclass):
|
||||
"""Get the identification string for a given class"""
|
||||
if RADIO_TO_DRV.has_key(rclass):
|
||||
if rclass in RADIO_TO_DRV:
|
||||
return RADIO_TO_DRV[rclass]
|
||||
elif RADIO_TO_DRV.has_key(rclass.__bases__[0]):
|
||||
elif rclass.__bases__[0] in RADIO_TO_DRV:
|
||||
return RADIO_TO_DRV[rclass.__bases__[0]]
|
||||
else:
|
||||
raise Exception("Unknown radio type `%s'" % rclass)
|
||||
|
||||
|
||||
def icf_to_image(icf_file, img_file):
|
||||
# FIXME: Why is this here?
|
||||
"""Convert an ICF file to a .img file"""
|
||||
@ -90,7 +99,7 @@ def icf_to_image(icf_file, img_file):
|
||||
img_data = mmap.get_packed()[:model._memsize]
|
||||
break
|
||||
except Exception:
|
||||
pass # Skip non-Icoms
|
||||
pass # Skip non-Icoms
|
||||
|
||||
if img_data:
|
||||
f = file(img_file, "wb")
|
||||
@ -101,6 +110,7 @@ def icf_to_image(icf_file, img_file):
|
||||
print util.hexprint(mdata)
|
||||
raise Exception("Unsupported model")
|
||||
|
||||
|
||||
def get_radio_by_image(image_file):
|
||||
"""Attempt to get the radio class that owns @image_file"""
|
||||
if image_file.startswith("radioreference://"):
|
||||
@ -108,13 +118,13 @@ def get_radio_by_image(image_file):
|
||||
rr = radioreference.RadioReferenceRadio(None)
|
||||
rr.set_params(zipcode, username, password)
|
||||
return rr
|
||||
|
||||
|
||||
if image_file.startswith("rfinder://"):
|
||||
_, _, email, passwd, lat, lon, miles = image_file.split("/")
|
||||
rf = rfinder.RFinderRadio(None)
|
||||
rf.set_params((float(lat), float(lon)), int(miles), email, passwd)
|
||||
return rf
|
||||
|
||||
|
||||
if os.path.exists(image_file) and icf.is_icf_file(image_file):
|
||||
tempf = tempfile.mktemp()
|
||||
icf_to_image(image_file, tempf)
|
||||
|
@ -25,14 +25,14 @@ class TpeRadio(generic_csv.CSVRadio):
|
||||
FILE_EXTENSION = "tpe"
|
||||
|
||||
ATTR_MAP = {
|
||||
"Sequence Number" : (int, "number"),
|
||||
"Location" : (str, "comment"),
|
||||
"Call Sign" : (str, "name"),
|
||||
"Sequence Number": (int, "number"),
|
||||
"Location": (str, "comment"),
|
||||
"Call Sign": (str, "name"),
|
||||
"Output Frequency": (chirp_common.parse_freq, "freq"),
|
||||
"Input Frequency" : (str, "duplex"),
|
||||
"CTCSS Tones" : (lambda v: float(v)
|
||||
if v and float(v) in chirp_common.TONES
|
||||
else 88.5, "rtone"),
|
||||
"Input Frequency": (str, "duplex"),
|
||||
"CTCSS Tones": (lambda v: float(v)
|
||||
if v and float(v) in chirp_common.TONES
|
||||
else 88.5, "rtone"),
|
||||
"Repeater Notes": (str, "comment"),
|
||||
}
|
||||
|
||||
|
@ -18,12 +18,13 @@ import libxml2
|
||||
|
||||
from chirp import chirp_common, errors, xml_ll, platform, directory
|
||||
|
||||
|
||||
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"
|
||||
path = "/usr/share/chirp/chirp.xsd"
|
||||
|
||||
try:
|
||||
ctx = libxml2.schemaNewParserCtxt(path)
|
||||
@ -54,6 +55,7 @@ def validate_doc(doc):
|
||||
print os.linesep.join(errs)
|
||||
raise errors.RadioError("Schema error")
|
||||
|
||||
|
||||
def default_banks():
|
||||
"""Return an empty set of banks"""
|
||||
banks = []
|
||||
@ -63,6 +65,7 @@ def default_banks():
|
||||
|
||||
return banks
|
||||
|
||||
|
||||
@directory.register
|
||||
class XMLRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport):
|
||||
"""Generic XML driver"""
|
||||
@ -94,7 +97,7 @@ class XMLRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport):
|
||||
rf.valid_name_length = 999
|
||||
rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS"]
|
||||
return rf
|
||||
|
||||
|
||||
def load(self, filename=None):
|
||||
if not self._filename and not filename:
|
||||
raise errors.RadioError("Need a location to load from")
|
||||
@ -125,7 +128,7 @@ class XMLRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport):
|
||||
pass
|
||||
|
||||
return mems
|
||||
|
||||
|
||||
def get_memory(self, number):
|
||||
mem = xml_ll.get_memory(self.doc, number)
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
from chirp import util
|
||||
|
||||
|
||||
class MemoryMap:
|
||||
"""
|
||||
A pythonic memory map interface
|
||||
@ -54,8 +55,8 @@ class MemoryMap:
|
||||
self._data[pos] = byte
|
||||
pos += 1
|
||||
else:
|
||||
raise ValueError("Unsupported type %s for value" % \
|
||||
type(value).__name__)
|
||||
raise ValueError("Unsupported type %s for value" %
|
||||
type(value).__name__)
|
||||
|
||||
def get_packed(self):
|
||||
"""Return the entire memory map as raw data"""
|
||||
|
@ -22,15 +22,16 @@ except ImportError:
|
||||
HAVE_SUDS = False
|
||||
|
||||
MODES = {
|
||||
"FM" : "FM",
|
||||
"AM" : "AM",
|
||||
"FMN" : "NFM",
|
||||
"FM": "FM",
|
||||
"AM": "AM",
|
||||
"FMN": "NFM",
|
||||
"D-STAR": "DV",
|
||||
"USB" : "USB",
|
||||
"LSB" : "LSB",
|
||||
"P25" : "P25",
|
||||
"USB": "USB",
|
||||
"LSB": "LSB",
|
||||
"P25": "P25",
|
||||
}
|
||||
|
||||
|
||||
class RadioReferenceRadio(chirp_common.NetworkSourceRadio):
|
||||
"""RadioReference.com data source"""
|
||||
VENDOR = "Radio Reference LLC"
|
||||
@ -44,7 +45,7 @@ class RadioReferenceRadio(chirp_common.NetworkSourceRadio):
|
||||
|
||||
if not HAVE_SUDS:
|
||||
raise errors.RadioError(
|
||||
"Suds library required for RadioReference.com import.\n" + \
|
||||
"Suds library required for RadioReference.com import.\n" +
|
||||
"Try installing your distribution's python-suds package.")
|
||||
|
||||
self._auth = {"appKey": self.APPKEY, "username": "", "password": ""}
|
||||
@ -64,8 +65,9 @@ class RadioReferenceRadio(chirp_common.NetworkSourceRadio):
|
||||
self._freqs = []
|
||||
|
||||
try:
|
||||
zipcode = self._client.service.getZipcodeInfo(self._zip, self._auth)
|
||||
county = self._client.service.getCountyInfo(zipcode.ctid, self._auth)
|
||||
service = self._client.service
|
||||
zipcode = service.getZipcodeInfo(self._zip, self._auth)
|
||||
county = service.getCountyInfo(zipcode.ctid, self._auth)
|
||||
except WebFault, err:
|
||||
raise errors.RadioError(err)
|
||||
|
||||
@ -130,7 +132,7 @@ class RadioReferenceRadio(chirp_common.NetworkSourceRadio):
|
||||
mem.duplex = "split"
|
||||
mem.offset = chirp_common.parse_freq(str(freq["in"]))
|
||||
if freq.tone is not None:
|
||||
if str(freq.tone) == "CSQ": # Carrier Squelch
|
||||
if str(freq.tone) == "CSQ": # Carrier Squelch
|
||||
mem.tmode = ""
|
||||
else:
|
||||
try:
|
||||
|
@ -32,6 +32,7 @@ struct {
|
||||
} memory[10];
|
||||
"""
|
||||
|
||||
|
||||
def do_download(radio):
|
||||
"""This is your download function"""
|
||||
# NOTE: Remove this in your real implementation!
|
||||
@ -49,6 +50,7 @@ def do_download(radio):
|
||||
|
||||
return memmap.MemoryMap(data)
|
||||
|
||||
|
||||
def do_upload(radio):
|
||||
"""This is your upload function"""
|
||||
# NOTE: Remove this in your real implementation!
|
||||
@ -63,22 +65,23 @@ def do_upload(radio):
|
||||
for i in range(0, 1000):
|
||||
serial.write(radio.get_mmap()[i])
|
||||
|
||||
|
||||
# Uncomment this to actually register this radio in CHIRP
|
||||
# @directory.register
|
||||
class TemplateRadio(chirp_common.CloneModeRadio):
|
||||
"""Acme Template"""
|
||||
VENDOR = "Acme" # Replace this with your vendor
|
||||
MODEL = "Template" # Replace this with your model
|
||||
BAUD_RATE = 9600 # Replace this with your baud rate
|
||||
VENDOR = "Acme" # Replace this with your vendor
|
||||
MODEL = "Template" # Replace this with your model
|
||||
BAUD_RATE = 9600 # Replace this with your baud rate
|
||||
|
||||
# Return information about this radio's features, including
|
||||
# how many memories it has, what bands it supports, etc
|
||||
def get_features(self):
|
||||
rf = chirp_common.RadioFeatures()
|
||||
rf.has_bank = False
|
||||
rf.memory_bounds = (0, 9) # This radio supports memories 0-9
|
||||
rf.valid_bands = [(144000000, 148000000), # Supports 2-meters
|
||||
(440000000, 450000000), # Supports 70-centimeters
|
||||
rf.memory_bounds = (0, 9) # This radio supports memories 0-9
|
||||
rf.valid_bands = [(144000000, 148000000), # Supports 2-meters
|
||||
(440000000, 450000000), # Supports 70-centimeters
|
||||
]
|
||||
return rf
|
||||
|
||||
@ -91,7 +94,7 @@ class TemplateRadio(chirp_common.CloneModeRadio):
|
||||
def sync_out(self):
|
||||
do_upload(self)
|
||||
|
||||
# Return a raw representation of the memory object, which
|
||||
# Return a raw representation of the memory object, which
|
||||
# is very helpful for development
|
||||
def get_raw_memory(self, number):
|
||||
return repr(self._memobj.memory[number])
|
||||
@ -105,10 +108,10 @@ class TemplateRadio(chirp_common.CloneModeRadio):
|
||||
# Create a high-level memory object to return to the UI
|
||||
mem = chirp_common.Memory()
|
||||
|
||||
mem.number = number # Set the memory number
|
||||
mem.freq = int(_mem.freq) # Convert your low-level frequency
|
||||
# to Hertz
|
||||
mem.name = str(_mem.name).rstrip() # Set the alpha tag
|
||||
mem.number = number # Set the memory number
|
||||
mem.freq = int(_mem.freq) # Convert your low-level frequency
|
||||
# to Hertz
|
||||
mem.name = str(_mem.name).rstrip() # Set the alpha tag
|
||||
|
||||
# We'll consider any blank (i.e. 0MHz frequency) to be empty
|
||||
if mem.freq == 0:
|
||||
@ -125,4 +128,3 @@ class TemplateRadio(chirp_common.CloneModeRadio):
|
||||
_mem.freq = mem.freq # Convert to low-level frequency
|
||||
# representation
|
||||
_mem.name = mem.name.ljust(8)[:8] # Store the alpha tag
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import struct
|
||||
|
||||
|
||||
def hexprint(data, addrfmt=None):
|
||||
"""Return a hexdump-like encoding of @data"""
|
||||
if addrfmt is None:
|
||||
@ -23,13 +24,13 @@ def hexprint(data, addrfmt=None):
|
||||
block_size = 8
|
||||
|
||||
lines = len(data) / block_size
|
||||
|
||||
|
||||
if (len(data) % block_size) != 0:
|
||||
lines += 1
|
||||
data += "\x00" * ((lines * block_size) - len(data))
|
||||
|
||||
out = ""
|
||||
|
||||
|
||||
for block in range(0, (len(data)/block_size)):
|
||||
addr = block * block_size
|
||||
try:
|
||||
@ -43,7 +44,7 @@ def hexprint(data, addrfmt=None):
|
||||
limit = left
|
||||
else:
|
||||
limit = block_size
|
||||
|
||||
|
||||
for j in range(0, limit):
|
||||
out += "%02x " % ord(data[(block * block_size) + j])
|
||||
|
||||
@ -61,6 +62,7 @@ def hexprint(data, addrfmt=None):
|
||||
|
||||
return out
|
||||
|
||||
|
||||
def bcd_encode(val, bigendian=True, width=None):
|
||||
"""This is really old and shouldn't be used anymore"""
|
||||
digits = []
|
||||
@ -77,14 +79,15 @@ def bcd_encode(val, bigendian=True, width=None):
|
||||
digits.append(0)
|
||||
|
||||
for i in range(0, len(digits), 2):
|
||||
newval = struct.pack("B", (digits[i+1] << 4) | digits[i])
|
||||
newval = struct.pack("B", (digits[i + 1] << 4) | digits[i])
|
||||
if bigendian:
|
||||
result = newval + result
|
||||
result = newval + result
|
||||
else:
|
||||
result = result + newval
|
||||
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def get_dict_rev(thedict, value):
|
||||
"""Return the first matching key for a given @value in @dict"""
|
||||
_dict = {}
|
||||
|
@ -24,6 +24,7 @@ from chirpui import miscwidgets, cloneprog, inputdialog, common, config
|
||||
|
||||
AUTO_DETECT_STRING = "Auto Detect (Icom Only)"
|
||||
|
||||
|
||||
class CloneSettings:
|
||||
def __init__(self):
|
||||
self.port = None
|
||||
@ -32,11 +33,12 @@ class CloneSettings:
|
||||
def __str__(self):
|
||||
s = ""
|
||||
if self.radio_class:
|
||||
return _("{vendor} {model} on {port}").format(\
|
||||
return _("{vendor} {model} on {port}").format(
|
||||
vendor=self.radio_class.VENDOR,
|
||||
model=self.radio_class.MODEL,
|
||||
port=self.port)
|
||||
|
||||
|
||||
class CloneSettingsDialog(gtk.Dialog):
|
||||
def __make_field(self, label, widget):
|
||||
l = gtk.Label(label)
|
||||
@ -73,7 +75,7 @@ class CloneSettingsDialog(gtk.Dialog):
|
||||
not issubclass(rclass, chirp_common.LiveRadio):
|
||||
continue
|
||||
|
||||
if not vendors.has_key(rclass.VENDOR):
|
||||
if rclass.VENDOR not in vendors:
|
||||
vendors[rclass.VENDOR] = []
|
||||
|
||||
vendors[rclass.VENDOR].append(rclass)
|
||||
@ -169,7 +171,9 @@ class CloneSettingsDialog(gtk.Dialog):
|
||||
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))
|
||||
raise Exception(
|
||||
_("Unable to detect radio on {port}").format(
|
||||
port=cs.port))
|
||||
except Exception, e:
|
||||
d = inputdialog.ExceptionDialog(e)
|
||||
d.run()
|
||||
@ -181,7 +185,9 @@ class CloneSettingsDialog(gtk.Dialog):
|
||||
cs.radio_class = rclass
|
||||
break
|
||||
if not cs.radio_class:
|
||||
common.show_error(_("Internal error: Unable to upload to {model}").format(model=model))
|
||||
common.show_error(
|
||||
_("Internal error: Unable to upload to {model}").format(
|
||||
model=model))
|
||||
print self.__vendors
|
||||
return None
|
||||
|
||||
@ -192,9 +198,11 @@ class CloneSettingsDialog(gtk.Dialog):
|
||||
|
||||
return cs
|
||||
|
||||
|
||||
class CloneCancelledException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class CloneThread(threading.Thread):
|
||||
def __status(self, status):
|
||||
gobject.idle_add(self.__progw.status, status)
|
||||
@ -219,7 +227,7 @@ class CloneThread(threading.Thread):
|
||||
gobject.idle_add(self.__progw.show)
|
||||
|
||||
self.__radio.status_fn = self.__status
|
||||
|
||||
|
||||
try:
|
||||
if self.__out:
|
||||
self.__radio.sync_out()
|
||||
@ -242,6 +250,7 @@ class CloneThread(threading.Thread):
|
||||
if self.__cback and not self.__cancelled:
|
||||
gobject.idle_add(self.__cback, self.__radio, emsg)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
d = CloneSettingsDialog("/dev/ttyUSB0")
|
||||
r = d.run()
|
||||
|
@ -15,15 +15,16 @@
|
||||
|
||||
import gtk
|
||||
|
||||
|
||||
class CloneProg(gtk.Window):
|
||||
def __init__(self, **args):
|
||||
if args.has_key("parent"):
|
||||
if "parent" in args:
|
||||
parent = args["parent"]
|
||||
del args["parent"]
|
||||
else:
|
||||
parent = None
|
||||
|
||||
if args.has_key("cancel"):
|
||||
if "cancel" in args:
|
||||
cancel = args["cancel"]
|
||||
del args["cancel"]
|
||||
else:
|
||||
@ -34,7 +35,7 @@ class CloneProg(gtk.Window):
|
||||
self.set_transient_for(parent)
|
||||
self.set_modal(True)
|
||||
self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
|
||||
self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
|
||||
self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
|
||||
|
||||
vbox = gtk.VBox(False, 2)
|
||||
vbox.show()
|
||||
|
@ -17,6 +17,7 @@ from chirp import platform
|
||||
from ConfigParser import ConfigParser
|
||||
import os
|
||||
|
||||
|
||||
class ChirpConfig:
|
||||
def __init__(self, basepath, name="chirp.config"):
|
||||
self.__basepath = basepath
|
||||
@ -60,6 +61,7 @@ class ChirpConfig:
|
||||
if not self.__config.items(section):
|
||||
self.__config.remove_section(section)
|
||||
|
||||
|
||||
class ChirpConfigProxy:
|
||||
def __init__(self, config, section="global"):
|
||||
self._config = config
|
||||
@ -95,7 +97,7 @@ class ChirpConfigProxy:
|
||||
raise ValueError("Value is not an integer")
|
||||
|
||||
self.set(key, "%i" % value, section)
|
||||
|
||||
|
||||
def get_bool(self, key, section=None, default=False):
|
||||
val = self.get(key, section)
|
||||
if val is None:
|
||||
@ -112,7 +114,10 @@ class ChirpConfigProxy:
|
||||
def remove_option(self, key, section):
|
||||
self._config.remove_option(section, key)
|
||||
|
||||
|
||||
_CONFIG = None
|
||||
|
||||
|
||||
def get(section="global"):
|
||||
global _CONFIG
|
||||
|
||||
|
@ -21,9 +21,10 @@ from chirpui import common, miscwidgets
|
||||
WIDGETW = 80
|
||||
WIDGETH = 30
|
||||
|
||||
|
||||
class CallsignEditor(gtk.HBox):
|
||||
__gsignals__ = {
|
||||
"changed" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
||||
"changed": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
|
||||
}
|
||||
|
||||
def _cs_changed(self, listw, callid):
|
||||
@ -35,10 +36,10 @@ class CallsignEditor(gtk.HBox):
|
||||
return True
|
||||
|
||||
def make_list(self, width):
|
||||
cols = [ (gobject.TYPE_INT, ""),
|
||||
(gobject.TYPE_INT, ""),
|
||||
(gobject.TYPE_STRING, _("Callsign")),
|
||||
]
|
||||
cols = [(gobject.TYPE_INT, ""),
|
||||
(gobject.TYPE_INT, ""),
|
||||
(gobject.TYPE_STRING, _("Callsign")),
|
||||
]
|
||||
|
||||
self.listw = miscwidgets.KeyedListWidget(cols)
|
||||
self.listw.show()
|
||||
@ -54,7 +55,7 @@ class CallsignEditor(gtk.HBox):
|
||||
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||
sw.add_with_viewport(self.listw)
|
||||
sw.show()
|
||||
|
||||
|
||||
return sw
|
||||
|
||||
def __init__(self, first_fixed=False, width=8):
|
||||
@ -90,6 +91,7 @@ class CallsignEditor(gtk.HBox):
|
||||
|
||||
return calls
|
||||
|
||||
|
||||
class DStarEditor(common.Editor):
|
||||
def __cs_changed(self, cse):
|
||||
job = None
|
||||
@ -149,7 +151,7 @@ class DStarEditor(common.Editor):
|
||||
return box
|
||||
|
||||
def focus(self):
|
||||
if self.loaded:
|
||||
if self.loaded:
|
||||
return
|
||||
self.loaded = True
|
||||
print "Loading callsigns..."
|
||||
@ -186,7 +188,7 @@ class DStarEditor(common.Editor):
|
||||
self.editor_ucall = self.editor_rcall = None
|
||||
|
||||
vbox = gtk.VBox(False, 2)
|
||||
vbox.pack_start(self.make_callsigns(), 0, 0, 0)
|
||||
vbox.pack_start(self.make_callsigns(), 0, 0, 0)
|
||||
|
||||
tmp = gtk.Label("")
|
||||
tmp.show()
|
||||
|
@ -18,6 +18,7 @@ import gtk
|
||||
from miscwidgets import make_choice
|
||||
from chirpui import reporting
|
||||
|
||||
|
||||
class TextInputDialog(gtk.Dialog):
|
||||
def respond_ok(self, _):
|
||||
self.response(gtk.RESPONSE_OK)
|
||||
@ -31,7 +32,7 @@ class TextInputDialog(gtk.Dialog):
|
||||
self.label.set_size_request(300, 100)
|
||||
# pylint: disable-msg=E1101
|
||||
self.vbox.pack_start(self.label, 1, 1, 0)
|
||||
|
||||
|
||||
self.text = gtk.Entry()
|
||||
self.text.connect("activate", self.respond_ok, None)
|
||||
# pylint: disable-msg=E1101
|
||||
@ -40,6 +41,7 @@ class TextInputDialog(gtk.Dialog):
|
||||
self.label.show()
|
||||
self.text.show()
|
||||
|
||||
|
||||
class ChoiceDialog(gtk.Dialog):
|
||||
editable = False
|
||||
|
||||
@ -66,6 +68,7 @@ class ChoiceDialog(gtk.Dialog):
|
||||
|
||||
self.set_default_response(gtk.RESPONSE_OK)
|
||||
|
||||
|
||||
class EditableChoiceDialog(ChoiceDialog):
|
||||
editable = True
|
||||
|
||||
@ -74,6 +77,7 @@ class EditableChoiceDialog(ChoiceDialog):
|
||||
|
||||
self.choice.child.set_activates_default(True)
|
||||
|
||||
|
||||
class ExceptionDialog(gtk.MessageDialog):
|
||||
def __init__(self, exception, **args):
|
||||
gtk.MessageDialog.__init__(self, buttons=gtk.BUTTONS_OK,
|
||||
@ -88,6 +92,7 @@ class ExceptionDialog(gtk.MessageDialog):
|
||||
traceback.print_exc(limit=100, file=sys.stdout)
|
||||
print "----------------------------"
|
||||
|
||||
|
||||
class FieldDialog(gtk.Dialog):
|
||||
def __init__(self, **kwargs):
|
||||
if "buttons" not in kwargs.keys():
|
||||
@ -118,12 +123,13 @@ class FieldDialog(gtk.Dialog):
|
||||
|
||||
# pylint: disable-msg=E1101
|
||||
self.vbox.pack_start(box, 0, 0, 0)
|
||||
|
||||
|
||||
self.__fields[label] = widget
|
||||
|
||||
def get_field(self, label):
|
||||
return self.__fields.get(label, None)
|
||||
|
||||
|
||||
class OverwriteDialog(gtk.MessageDialog):
|
||||
def __init__(self, filename):
|
||||
gtk.Dialog.__init__(self,
|
||||
|
@ -16,11 +16,11 @@
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
import threading
|
||||
|
||||
from chirp import errors, chirp_common
|
||||
|
||||
|
||||
class ShiftDialog(gtk.Dialog):
|
||||
def __init__(self, rthread, parent=None):
|
||||
gtk.Dialog.__init__(self,
|
||||
@ -80,7 +80,7 @@ class ShiftDialog(gtk.Dialog):
|
||||
|
||||
pos = start
|
||||
while pos <= ulimit:
|
||||
self.status(_("Looking for a free spot ({number})").format(\
|
||||
self.status(_("Looking for a free spot ({number})").format(
|
||||
number=pos), 0)
|
||||
try:
|
||||
mem = self.rthread.radio.get_memory(pos)
|
||||
@ -126,7 +126,8 @@ class ShiftDialog(gtk.Dialog):
|
||||
if self.quiet:
|
||||
gobject.idle_add(self.response, gtk.RESPONSE_OK)
|
||||
else:
|
||||
gobject.idle_add(self.set_response_sensitive, gtk.RESPONSE_OK, True)
|
||||
gobject.idle_add(self.set_response_sensitive,
|
||||
gtk.RESPONSE_OK, True)
|
||||
|
||||
def threadfn(self, newhole, func, *args):
|
||||
self.status("Waiting for radio to become available", 0)
|
||||
|
12
rpttool
12
rpttool
@ -22,6 +22,7 @@ import commands
|
||||
|
||||
from chirp import idrp, chirp_common
|
||||
|
||||
|
||||
def open_device():
|
||||
try:
|
||||
s = serial.Serial(port="/dev/icom",
|
||||
@ -35,6 +36,7 @@ def open_device():
|
||||
|
||||
return rp
|
||||
|
||||
|
||||
def read_freq():
|
||||
rp = open_device()
|
||||
if not rp:
|
||||
@ -50,6 +52,7 @@ def read_freq():
|
||||
|
||||
return mem.freq
|
||||
|
||||
|
||||
def _set_freq(rp):
|
||||
try:
|
||||
mem = rp.get_memory(0)
|
||||
@ -81,6 +84,7 @@ def _set_freq(rp):
|
||||
chirp_common.format_freq(mem.freq)
|
||||
return True
|
||||
|
||||
|
||||
def set_freq():
|
||||
rp = open_device()
|
||||
if not rp:
|
||||
@ -91,10 +95,11 @@ def set_freq():
|
||||
except Exception, e:
|
||||
print "Unknown error while setting frequency: %s" % e
|
||||
res = False
|
||||
|
||||
|
||||
rp.pipe.close()
|
||||
return res
|
||||
|
||||
|
||||
def main_menu():
|
||||
print "Looking for a repeater...",
|
||||
sys.stdout.flush()
|
||||
@ -114,7 +119,7 @@ Current Setting: %s
|
||||
3. Quit
|
||||
--------------------------------
|
||||
> """ % chirp_common.format_freq(freq),
|
||||
|
||||
|
||||
cmd = sys.stdin.readline().strip()
|
||||
|
||||
if cmd == "1":
|
||||
@ -124,9 +129,10 @@ Current Setting: %s
|
||||
freq = read_freq()
|
||||
elif cmd != "3":
|
||||
print "Invalid entry"
|
||||
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if os.path.exists("tools/icomsio.sh"):
|
||||
path = "tools/icomsio.sh"
|
||||
|
@ -15,8 +15,6 @@
|
||||
./chirp/bitwise_grammar.py
|
||||
./chirp/bjuv55.py
|
||||
./chirp/chirp_common.py
|
||||
./chirp/detect.py
|
||||
./chirp/directory.py
|
||||
./chirp/elib_intl.py
|
||||
./chirp/errors.py
|
||||
./chirp/ft1802.py
|
||||
@ -31,8 +29,6 @@
|
||||
./chirp/ft90.py
|
||||
./chirp/ftm350.py
|
||||
./chirp/generic_csv.py
|
||||
./chirp/generic_tpe.py
|
||||
./chirp/generic_xml.py
|
||||
./chirp/h777.py
|
||||
./chirp/ic208.py
|
||||
./chirp/ic2100.py
|
||||
@ -62,14 +58,11 @@
|
||||
./chirp/kguv8d.py
|
||||
./chirp/kyd.py
|
||||
./chirp/leixen.py
|
||||
./chirp/memmap.py
|
||||
./chirp/platform.py
|
||||
./chirp/puxing.py
|
||||
./chirp/pyPEG.py
|
||||
./chirp/radioreference.py
|
||||
./chirp/rfinder.py
|
||||
./chirp/settings.py
|
||||
./chirp/template.py
|
||||
./chirp/th9800.py
|
||||
./chirp/th_uv3r.py
|
||||
./chirp/th_uv3r25.py
|
||||
@ -79,7 +72,6 @@
|
||||
./chirp/tk8102.py
|
||||
./chirp/tmv71.py
|
||||
./chirp/tmv71_ll.py
|
||||
./chirp/util.py
|
||||
./chirp/uv5r.py
|
||||
./chirp/uvb5.py
|
||||
./chirp/vx170.py
|
||||
@ -96,15 +88,10 @@
|
||||
./chirp/xml_ll.py
|
||||
./chirp/yaesu_clone.py
|
||||
./chirpui/bankedit.py
|
||||
./chirpui/clone.py
|
||||
./chirpui/cloneprog.py
|
||||
./chirpui/common.py
|
||||
./chirpui/config.py
|
||||
./chirpui/dstaredit.py
|
||||
./chirpui/editorset.py
|
||||
./chirpui/fips.py
|
||||
./chirpui/importdialog.py
|
||||
./chirpui/inputdialog.py
|
||||
./chirpui/mainapp.py
|
||||
./chirpui/memdetail.py
|
||||
./chirpui/memedit.py
|
||||
@ -112,10 +99,8 @@
|
||||
./chirpui/radiobrowser.py
|
||||
./chirpui/reporting.py
|
||||
./chirpui/settingsedit.py
|
||||
./chirpui/shiftdialog.py
|
||||
./csvdump/csvapp.py
|
||||
./csvdump/csvdump.py
|
||||
./rpttool
|
||||
./setup.py
|
||||
./share/make_supported.py
|
||||
./tests/run_tests
|
||||
|
Loading…
Reference in New Issue
Block a user