[chirp_devel] [PATCH v3 00/12] Third time's the charm?
The logging module now handles the magical "debug.log" file, and the version string is emitted with LOG.debug.
The regresions caused by the patch that replaced CHIRP_DEBUG checks with proper logging calls was due to uncaught AttributeErrors (exposed as side-effects of the debugging calls). Those are now caught, so all of the tests pass.
The 'cpep8.py' script (renamed to avoid naming conflict) now uses the pep8 module directly, rather than forking subprocesses. On the upside, it is now over twice as fast. Unfortunately, there is no longer any way for it to report its progress, so it's a lot quieter. Such is life. While I was tinkering, I added an option to automatically update the blacklist, and it found a number of files that were already compliant.
I fixed the blacklist to initially include the chirpc/chirpw scripts, though they are subsequently removed in the very next patch. I figured that it was best to demonstrate how we will move forward with bringing the tree into style compliance.
In that vein, I fixed many more of the low-hanging style issues. The remainder of the files have many more issues and may end up deserving their own individual patches.
I included a new patch that fixes the style of the setup.py patch (including the idiom upgrade discussed while reviewing the last series). On top of that, I included another new patch that tries to update the setup.py script to follow the moved drivers, but I am not sure that I got it entirely correct. I had overlooked that file in my last series. Likewise, I moved a few more drivers that I had overlooked.
I included a tweak to run_tests that allows it to be run from locations other than the test directory. I found myself repeatedly trying to run it from the top-level and got annoyed enough to fix it.
Zach Welch (12): Add chirp.logger module (#2347) Use new logger module (#2347) Suppress startup debugging messages (#2347) Add pep8 checker script (#2355) Fix style issues (1/4) (#2355) Fix style issues (2/4) (#2355) Fix style issues (3/4) (#2355) Fix style issues (4/4) (#2355) Fix style issues in setup.py (#2355) Move drivers into their own directory (#2351) Adjust setup.py for relocated drivers (#2351) Allow run_tests to be run from anywhere (#2343)
chirp/bandplan.py | 3 +- chirp/bitwise_grammar.py | 20 ++ chirp/detect.py | 19 +- chirp/directory.py | 31 ++- chirp/drivers/__init__.py | 10 + chirp/{ => drivers}/alinco.py | 0 chirp/{ => drivers}/anytone.py | 13 +- chirp/{ => drivers}/ap510.py | 0 chirp/{ => drivers}/baofeng_uv3r.py | 7 +- chirp/{ => drivers}/bjuv55.py | 7 +- chirp/{ => drivers}/ft1802.py | 3 +- chirp/{ => drivers}/ft1d.py | 17 +- chirp/{ => drivers}/ft2800.py | 20 +- chirp/{ => drivers}/ft50.py | 3 +- chirp/{ => drivers}/ft50_ll.py | 0 chirp/{ => drivers}/ft60.py | 11 +- chirp/{ => drivers}/ft7800.py | 31 +-- chirp/{ => drivers}/ft817.py | 37 ++- chirp/{ => drivers}/ft857.py | 15 +- chirp/{ => drivers}/ft90.py | 56 ++-- chirp/{ => drivers}/ftm350.py | 11 +- chirp/{ => drivers}/generic_csv.py | 95 ++++--- chirp/{ => drivers}/generic_tpe.py | 14 +- chirp/{ => drivers}/generic_xml.py | 9 +- chirp/{ => drivers}/h777.py | 16 +- chirp/{ => drivers}/ic208.py | 4 +- chirp/{ => drivers}/ic2100.py | 4 +- chirp/{ => drivers}/ic2200.py | 4 +- chirp/{ => drivers}/ic2720.py | 4 +- chirp/{ => drivers}/ic2820.py | 4 +- chirp/{ => drivers}/ic9x.py | 3 +- chirp/{ => drivers}/ic9x_icf.py | 3 +- chirp/{ => drivers}/ic9x_icf_ll.py | 0 chirp/{ => drivers}/ic9x_ll.py | 0 chirp/{ => drivers}/icf.py | 0 chirp/{ => drivers}/icomciv.py | 15 +- chirp/{ => drivers}/icq7.py | 4 +- chirp/{ => drivers}/ict70.py | 4 +- chirp/{ => drivers}/ict7h.py | 4 +- chirp/{ => drivers}/ict8.py | 3 +- chirp/{ => drivers}/icw32.py | 4 +- chirp/{ => drivers}/icx8x.py | 3 +- chirp/{ => drivers}/icx8x_ll.py | 0 chirp/{ => drivers}/id31.py | 3 +- chirp/{ => drivers}/id51.py | 3 +- chirp/{ => drivers}/id800.py | 4 +- chirp/{ => drivers}/id880.py | 4 +- chirp/{ => drivers}/idrp.py | 13 +- chirp/{ => drivers}/kenwood_hmk.py | 0 chirp/{ => drivers}/kenwood_itm.py | 0 chirp/{ => drivers}/kenwood_live.py | 11 +- chirp/{ => drivers}/kguv8d.py | 42 ++- chirp/{ => drivers}/kyd.py | 26 +- chirp/{ => drivers}/leixen.py | 5 - chirp/{ => drivers}/puxing.py | 7 +- chirp/{ => drivers}/template.py | 26 +- chirp/{ => drivers}/th9800.py | 36 +-- chirp/{ => drivers}/th_uv3r.py | 7 +- chirp/{ => drivers}/th_uv3r25.py | 2 +- chirp/{ => drivers}/th_uvf8d.py | 0 chirp/{ => drivers}/thd72.py | 10 +- chirp/{ => drivers}/thuv1f.py | 0 chirp/{ => drivers}/tk8102.py | 8 +- chirp/{ => drivers}/tmv71.py | 2 +- chirp/{ => drivers}/tmv71_ll.py | 10 +- chirp/{ => drivers}/uv5r.py | 26 +- chirp/{ => drivers}/uvb5.py | 0 chirp/{ => drivers}/vx170.py | 10 +- chirp/{ => drivers}/vx2.py | 32 +-- chirp/{ => drivers}/vx3.py | 35 +-- chirp/{ => drivers}/vx5.py | 4 +- chirp/{ => drivers}/vx510.py | 4 +- chirp/{ => drivers}/vx6.py | 4 +- chirp/{ => drivers}/vx7.py | 4 +- chirp/{ => drivers}/vx8.py | 15 +- chirp/{ => drivers}/vxa700.py | 0 chirp/{ => drivers}/wouxun.py | 15 +- chirp/{ => drivers}/wouxun_common.py | 9 +- chirp/{ => drivers}/yaesu_clone.py | 13 +- chirp/errors.py | 6 + chirp/import_logic.py | 34 ++- chirp/logger.py | 55 ++-- chirp/memmap.py | 5 +- chirp/platform.py | 37 ++- chirp/radioreference.py | 22 +- chirp/util.py | 15 +- chirp/xml_ll.py | 20 +- chirpc | 498 ++++++++++++++++++----------------- chirpui/bankedit.py | 33 +-- chirpui/clone.py | 19 +- chirpui/cloneprog.py | 7 +- chirpui/config.py | 7 +- chirpui/dstaredit.py | 18 +- chirpui/inputdialog.py | 10 +- chirpui/mainapp.py | 9 +- chirpui/radiobrowser.py | 20 +- chirpui/reporting.py | 32 ++- chirpui/settingsedit.py | 31 ++- chirpui/shiftdialog.py | 7 +- chirpw | 56 ++-- csvdump/__init__.py | 1 - locale/check_parameters.py | 15 +- rpttool | 12 +- run_all_tests.sh | 11 +- setup.py | 70 +++-- share/make_supported.py | 1 + tests/run_tests | 7 +- tests/unit/base.py | 1 + tests/unit/test_bitwise.py | 15 +- tests/unit/test_chirp_common.py | 3 + tests/unit/test_mappingmodel.py | 11 +- tests/unit/test_platform.py | 1 + tests/unit/test_shiftdialog.py | 2 + tools/cpep8.blacklist | 101 +++++++ tools/cpep8.manifest | 4 + tools/cpep8.py | 94 +++++++ 116 files changed, 1264 insertions(+), 927 deletions(-) create mode 100644 chirp/drivers/__init__.py rename chirp/{ => drivers}/alinco.py (100%) rename chirp/{ => drivers}/anytone.py (98%) rename chirp/{ => drivers}/ap510.py (100%) rename chirp/{ => drivers}/baofeng_uv3r.py (99%) rename chirp/{ => drivers}/bjuv55.py (99%) rename chirp/{ => drivers}/ft1802.py (98%) rename chirp/{ => drivers}/ft1d.py (99%) rename chirp/{ => drivers}/ft2800.py (94%) rename chirp/{ => drivers}/ft50.py (95%) rename chirp/{ => drivers}/ft50_ll.py (100%) rename chirp/{ => drivers}/ft60.py (99%) rename chirp/{ => drivers}/ft7800.py (97%) rename chirp/{ => drivers}/ft817.py (97%) rename chirp/{ => drivers}/ft857.py (99%) rename chirp/{ => drivers}/ft90.py (94%) rename chirp/{ => drivers}/ftm350.py (97%) rename chirp/{ => drivers}/generic_csv.py (84%) rename chirp/{ => drivers}/generic_tpe.py (82%) rename chirp/{ => drivers}/generic_xml.py (98%) rename chirp/{ => drivers}/h777.py (98%) rename chirp/{ => drivers}/ic208.py (98%) rename chirp/{ => drivers}/ic2100.py (98%) rename chirp/{ => drivers}/ic2200.py (98%) rename chirp/{ => drivers}/ic2720.py (98%) rename chirp/{ => drivers}/ic2820.py (99%) rename chirp/{ => drivers}/ic9x.py (99%) rename chirp/{ => drivers}/ic9x_icf.py (96%) rename chirp/{ => drivers}/ic9x_icf_ll.py (100%) rename chirp/{ => drivers}/ic9x_ll.py (100%) rename chirp/{ => drivers}/icf.py (100%) rename chirp/{ => drivers}/icomciv.py (96%) rename chirp/{ => drivers}/icq7.py (99%) rename chirp/{ => drivers}/ict70.py (98%) rename chirp/{ => drivers}/ict7h.py (97%) rename chirp/{ => drivers}/ict8.py (97%) rename chirp/{ => drivers}/icw32.py (98%) rename chirp/{ => drivers}/icx8x.py (98%) rename chirp/{ => drivers}/icx8x_ll.py (100%) rename chirp/{ => drivers}/id31.py (99%) rename chirp/{ => drivers}/id51.py (96%) rename chirp/{ => drivers}/id800.py (99%) rename chirp/{ => drivers}/id880.py (99%) rename chirp/{ => drivers}/idrp.py (94%) rename chirp/{ => drivers}/kenwood_hmk.py (100%) rename chirp/{ => drivers}/kenwood_itm.py (100%) rename chirp/{ => drivers}/kenwood_live.py (99%) rename chirp/{ => drivers}/kguv8d.py (96%) rename chirp/{ => drivers}/kyd.py (95%) rename chirp/{ => drivers}/leixen.py (99%) rename chirp/{ => drivers}/puxing.py (99%) rename chirp/{ => drivers}/template.py (84%) rename chirp/{ => drivers}/th9800.py (96%) rename chirp/{ => drivers}/th_uv3r.py (98%) rename chirp/{ => drivers}/th_uv3r25.py (99%) rename chirp/{ => drivers}/th_uvf8d.py (100%) rename chirp/{ => drivers}/thd72.py (98%) rename chirp/{ => drivers}/thuv1f.py (100%) rename chirp/{ => drivers}/tk8102.py (98%) rename chirp/{ => drivers}/tmv71.py (98%) rename chirp/{ => drivers}/tmv71_ll.py (98%) rename chirp/{ => drivers}/uv5r.py (99%) rename chirp/{ => drivers}/uvb5.py (100%) rename chirp/{ => drivers}/vx170.py (94%) rename chirp/{ => drivers}/vx2.py (97%) rename chirp/{ => drivers}/vx3.py (97%) rename chirp/{ => drivers}/vx5.py (98%) rename chirp/{ => drivers}/vx510.py (98%) rename chirp/{ => drivers}/vx6.py (99%) rename chirp/{ => drivers}/vx7.py (99%) rename chirp/{ => drivers}/vx8.py (99%) rename chirp/{ => drivers}/vxa700.py (100%) rename chirp/{ => drivers}/wouxun.py (99%) rename chirp/{ => drivers}/wouxun_common.py (94%) rename chirp/{ => drivers}/yaesu_clone.py (95%) create mode 100644 tools/cpep8.blacklist create mode 100644 tools/cpep8.manifest create mode 100755 tools/cpep8.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 0f651b4f02250339fc9ace7fd87075058f64cc21
Fix chirp.logger module (#2347)
This patch addresses some issues with the chirp.logger module in order to use it in chirpc and chirpw. It prints the version string when logging at DEBUG level.
In addition, it embraces and extends the "debug.log" support that was present in chirpw, ensuring all log messages and output end up in that file when running on Win32 or MacOS hosts. It also allows that feature to be tested on Linux by setting CHIRP_DEBUG_LOG in the environment.
diff --git a/chirp/logger.py b/chirp/logger.py index 4cf8fa2..eb29e6f 100644 --- a/chirp/logger.py +++ b/chirp/logger.py @@ -56,6 +56,9 @@ log_level_names = {"critical": logging.CRITICAL,
class Logger(object): + + log_format = '[%(asctime)s] %(name)s - %(levelname)s: %(message)s' + def __init__(self): # create root logger self.logger = logging.getLogger() @@ -67,20 +70,35 @@ class Logger(object): # It can be a number or a name; otherwise, level is set to 'debug' # in order to maintain backward compatibility. CHIRP_DEBUG = os.getenv("CHIRP_DEBUG") - level = logging.WARNING + self.early_level = logging.WARNING if CHIRP_DEBUG: try: - level = int(CHIRP_DEBUG) + self.early_level = int(CHIRP_DEBUG) except ValueError: try: - level = log_level_names[CHIRP_DEBUG] + self.early_level = log_level_names[CHIRP_DEBUG] except KeyError: - level = logging.DEBUG - - self.console = logging.StreamHandler() - self.console.setLevel(level) - format_str = '%(levelname)s: %(message)s' - self.console.setFormatter(logging.Formatter(format_str)) + self.early_level = logging.DEBUG + + # If we're on Win32 or MacOS, we don't use the console; instead, + # we create 'debug.log', redirect all output there, and set the + # console logging handler level to DEBUG. To test this on Linux, + # set CHIRP_DEBUG_LOG in the environment. + console_stream = None + console_format = '%(levelname)s: %(message)s' + if hasattr(sys, "frozen") or not os.isatty(0) \ + or os.getenv("CHIRP_DEBUG_LOG"): + p = platform.get_platform() + log = file(p.config_file("debug.log"), "w", 0) + sys.stdout = log + sys.stderr = log + console_stream = log + console_format = self.log_format + self.early_level = logging.DEBUG + + self.console = logging.StreamHandler(console_stream) + self.console.setLevel(self.early_level) + self.console.setFormatter(logging.Formatter(console_format)) self.logger.addHandler(self.console)
# Set CHIRP_LOG in environment to the name of log file. @@ -94,31 +112,33 @@ class Logger(object): else: self.set_log_level(logging.DEBUG)
+ if self.early_level <= logging.DEBUG: + self.LOG.debug(version_string()) + def create_log_file(self, name): if self.logfile is None: self.logname = name - lf = file(name, "w") - print >>lf, version_string() - lf.close() + # always truncate the log file + with file(name, "w") as fh: + pass self.logfile = logging.FileHandler(name) - format_str = '[%(created)s] %(name)s - %(levelname)s: %(message)s' + format_str = self.log_format self.logfile.setFormatter(logging.Formatter(format_str)) self.logger.addHandler(self.logfile) - else: self.logger.error("already logging to " + self.logname)
def set_verbosity(self, level): + self.LOG.debug("verbosity=%d", level) if level > logging.CRITICAL: level = logging.CRITICAL self.console.setLevel(level) - self.LOG.debug("verbosity=%d", level)
def set_log_level(self, level): + self.LOG.debug("log level=%d", level) if level > logging.CRITICAL: level = logging.CRITICAL self.logfile.setLevel(level) - self.LOG.debug("log level=%d", level)
def set_log_level_by_name(self, level): self.set_log_level(log_level_names[level]) @@ -153,3 +173,6 @@ def handle_options(options): logger.set_log_level(level) except ValueError: logger.set_log_level_by_name(options.log_level) + + if logger.early_level > logging.DEBUG: + logger.LOG.debug(version_string()) diff --git a/chirpc b/chirpc index 6a25e50..16c7006 100755 --- a/chirpc +++ b/chirpc @@ -19,10 +19,14 @@ import serial import sys import argparse +import logging
+from chirp import logger from chirp import * from chirp import chirp_common, errors, idrp, directory, util
+LOG = logging.getLogger("chirpc") + def fail_unsupported(): print "Operation not supported by selected radio" sys.exit(1) @@ -62,6 +66,7 @@ class DTCSPolarityAction(argparse.Action):
if __name__ == "__main__": parser = argparse.ArgumentParser() + logger.add_version_argument(parser) parser.add_argument("-s", "--serial", dest="serial", default="mmap", help="Serial port (default: mmap)") @@ -151,8 +156,10 @@ if __name__ == "__main__": action="store_true", default=False, help="Upload memory map to radio") + logger.add_arguments(parser) parser.add_argument("args", metavar="arg", nargs='*', help="Some commands require additional arguments") + if len(sys.argv) <= 1: parser.print_help() sys.exit(0) @@ -160,6 +167,8 @@ if __name__ == "__main__": options = parser.parse_args() args = options.args
+ logger.handle_options(options) + if options.list_radios: print "Supported Radios:\n\t", "\n\t".join(sorted(RADIOS.keys())) sys.exit(0) diff --git a/chirpw b/chirpw index a3a316c..67c9ee0 100755 --- a/chirpw +++ b/chirpw @@ -17,8 +17,9 @@
import os
+from chirp import logger from chirp import elib_intl -from chirp import platform, CHIRP_VERSION +from chirp import platform from chirpui import config
# Hack to setup environment @@ -30,20 +31,6 @@ import locale import gettext import argparse
-p = platform.get_platform() -if hasattr(sys, "frozen"): - log = file(p.config_file("debug.log"), "w", 0) - sys.stderr = log - sys.stdout = log -elif not os.isatty(0): - log = file(p.config_file("debug.log"), "w", 0) - sys.stdout = log - sys.stderr = log - -print "CHIRP %s on %s (Python %s)" % (CHIRP_VERSION, - platform.get_platform().os_version_string(), - sys.version.split()[0]) - execpath = platform.get_platform().executable_path() localepath = os.path.abspath(os.path.join(execpath, "locale")) if not os.path.exists(localepath): @@ -127,10 +114,14 @@ from chirpui import mainapp, config
parser = argparse.ArgumentParser() parser.add_argument("files", metavar="file", nargs='*', help="File to open") +logger.add_version_argument(parser) parser.add_argument("--profile", action="store_true", help="Enable profiling") +logger.add_arguments(parser) args = parser.parse_args()
+logger.handle_options(args) + a = mainapp.ChirpMain()
for i in args.files:
# If we're on Win32 or MacOS, we don't use the console; instead,
# we create 'debug.log', redirect all output there, and set the
# console logging handler level to DEBUG. To test this on Linux,
# set CHIRP_DEBUG_LOG in the environment.
console_stream = None
console_format = '%(levelname)s: %(message)s'
if hasattr(sys, "frozen") or not os.isatty(0) \
or os.getenv("CHIRP_DEBUG_LOG"):
p = platform.get_platform()
log = file(p.config_file("debug.log"), "w", 0)
sys.stdout = log
sys.stderr = log
console_stream = log
console_format = self.log_format
self.early_level = logging.DEBUG
self.console = logging.StreamHandler(console_stream)
self.console.setLevel(self.early_level)
self.console.setFormatter(logging.Formatter(console_format))
I think there is a better way to do this:
class LogWriter(object): def __init__(self): self._log = logging.getLogger('console') self._log.setLevel(logging.DEBUG)
def write(self, message): self._log.debug(message)
sys.stdout = LogWriter() sys.stderr = sys.stdout
With that, if I do a "print", it gets logged properly, as module "console" at debug level. If we only do that when the console logger is actually logging to the debug.log file, then things are simpler and the log is consistently formatted. Obviously continuing with converting the print statements to log statements still helps so we get the actual modules correct in the log statements.
Thoughts?
--Dan
On 02/27/2015 03:51 PM, Dan Smith wrote:
# If we're on Win32 or MacOS, we don't use the console; instead,
# we create 'debug.log', redirect all output there, and set the
# console logging handler level to DEBUG. To test this on Linux,
# set CHIRP_DEBUG_LOG in the environment.
console_stream = None
console_format = '%(levelname)s: %(message)s'
if hasattr(sys, "frozen") or not os.isatty(0) \
or os.getenv("CHIRP_DEBUG_LOG"):
p = platform.get_platform()
log = file(p.config_file("debug.log"), "w", 0)
sys.stdout = log
sys.stderr = log
console_stream = log
console_format = self.log_format
self.early_level = logging.DEBUG
self.console = logging.StreamHandler(console_stream)
self.console.setLevel(self.early_level)
self.console.setFormatter(logging.Formatter(console_format))
I think there is a better way to do this:
class LogWriter(object): def __init__(self): self._log = logging.getLogger('console') self._log.setLevel(logging.DEBUG)
def write(self, message): self._log.debug(message)
sys.stdout = LogWriter() sys.stderr = sys.stdout
With that, if I do a "print", it gets logged properly, as module "console" at debug level. If we only do that when the console logger is actually logging to the debug.log file, then things are simpler and the log is consistently formatted. Obviously continuing with converting the print statements to log statements still helps so we get the actual modules correct in the log statements.
I will give it some thought. FWIW, I am planning to scour the code to convert prints to logging calls. After all, there shouldn't be any prints in the core chirp code; everything therein should some kind of logging message, right?
As for the CLI (the only place where normal print calls are expected), I have already been thinking about enveloping stdout/stderr with a class that diverts a copy of all printed output to the log file(s). That will be necessary to produce a complete log of the CLI's output, which we will want when debugging users' issues. However, we do not want printed output to go through the logger module, as we do not want it adorned. Does that make sense?
In any event, I agree that there are still logging issues to address, but they should work themselves out as I get further into those reworks.
I will give it some thought. FWIW, I am planning to scour the code to convert prints to logging calls. After all, there shouldn't be any prints in the core chirp code; everything therein should some kind of logging message, right?
Lots of things can generate output on stdout/stderr, like poorly written libraries and such. If we direct that output to the logs without formatting, then we see it, but it's unformatted (and not timestamped).
So, IMHO, we should do it anyway.
--Dan
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID fb1897f975f805f2c6d5b51e4b790fe1a24c7292
Use new logger module (#2347)
This patch chases down all references to CHIRP_DEBUG, converting the wrapped print calls to LOG.debug calls. It also eliminates a few plain DEBUG variables and a couple of other one-off variants.
diff --git a/chirp/anytone.py b/chirp/anytone.py index 4b9c785..b7d722b 100644 --- a/chirp/anytone.py +++ b/chirp/anytone.py @@ -16,6 +16,7 @@ import os import struct import time +import logging
from chirp import bitwise from chirp import chirp_common @@ -26,6 +27,8 @@ from chirp import util from chirp.settings import RadioSettingGroup, RadioSetting, RadioSettings, \ RadioSettingValueList, RadioSettingValueString, RadioSettingValueBoolean
+LOG = logging.getLogger(__name__) + _mem_format = """ #seekto 0x0100; struct { @@ -164,10 +167,6 @@ def _should_send_addr(memobj, addr): else: return _is_loc_used(memobj, _addr_to_loc(addr))
-def _debug(string): - if "CHIRP_DEBUG" in os.environ or True: - print string - def _echo_write(radio, data): try: radio.pipe.write(data) @@ -201,7 +200,7 @@ def _ident(radio): raise errors.RadioError("Unsupported model") _echo_write(radio, "\x02") response = radio.pipe.read(16) - _debug(util.hexprint(response)) + LOG.debug(util.hexprint(response)) if response[1:8] not in valid_model: print "Response was:\n%s" % util.hexprint(response) raise errors.RadioError("Unsupported model") @@ -227,7 +226,7 @@ def _send(radio, cmd, addr, length, data=None): frame += chr(_checksum(frame[1:])) frame += "\x06" _echo_write(radio, frame) - _debug("Sent:\n%s" % util.hexprint(frame)) + LOG.debug("Sent:\n%s" % util.hexprint(frame)) if data: result = radio.pipe.read(1) if result != "\x06": @@ -236,7 +235,7 @@ def _send(radio, cmd, addr, length, data=None): addr) return result = _read(radio, length + 6) - _debug("Got:\n%s" % util.hexprint(result)) + LOG.debug("Got:\n%s" % util.hexprint(result)) header = result[0:4] data = result[4:-2] ack = result[-1] diff --git a/chirp/baofeng_uv3r.py b/chirp/baofeng_uv3r.py index 52d1a78..0827885 100644 --- a/chirp/baofeng_uv3r.py +++ b/chirp/baofeng_uv3r.py @@ -24,11 +24,6 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueString, \ RadioSettingValueFloat, RadioSettings
-if os.getenv("CHIRP_DEBUG"): - DEBUG = True -else: - DEBUG = False - def _uv3r_prep(radio): radio.pipe.write("\x05PROGRAM") ack = radio.pipe.read(1) diff --git a/chirp/bjuv55.py b/chirp/bjuv55.py index 7dd61be..9fb7e5a 100644 --- a/chirp/bjuv55.py +++ b/chirp/bjuv55.py @@ -28,11 +28,6 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ from textwrap import dedent from chirp import uv5r
-if os.getenv("CHIRP_DEBUG"): - CHIRP_DEBUG = True -else: - CHIRP_DEBUG = False - BJUV55_MODEL = "\x50\xBB\xDD\x55\x63\x98\x4D"
COLOR_LIST = ["Off", "Blue", "Red", "Pink"] diff --git a/chirp/ft1d.py b/chirp/ft1d.py index eb7a0b1..db0259f 100644 --- a/chirp/ft1d.py +++ b/chirp/ft1d.py @@ -17,6 +17,7 @@ import os import re import string +import logging
from chirp import chirp_common, yaesu_clone, directory from chirp import bitwise @@ -25,6 +26,8 @@ from chirp.settings import RadioSettingValueInteger, RadioSettingValueString from chirp.settings import RadioSettingValueList, RadioSettingValueBoolean from textwrap import dedent
+LOG = logging.getLogger(__name__) + MEM_FORMAT = """ #seekto 0x049a; struct { @@ -1549,8 +1552,7 @@ class FT1Radio(yaesu_clone.YaesuCloneModeRadio): is_latitude = name.endswith("latitude") lat_long = setting.value.get_value().strip() sign, l_d, l_m, l_s = cls._str_to_latlong(lat_long, is_latitude) - if os.getenv("CHIRP_DEBUG"): - print "%s: %d %d %d %d" % (name, sign, l_d, l_m, l_s) + LOG.debug("%s: %d %d %d %d" % (name, sign, l_d, l_m, l_s)) setattr(obj, "%s_sign" % name, sign) setattr(obj, "%s_degree" % name, l_d) setattr(obj, "%s_minute" % name, l_m) @@ -1587,9 +1589,8 @@ class FT1Radio(yaesu_clone.YaesuCloneModeRadio):
try: old_val = getattr(obj, setting) - if os.getenv("CHIRP_DEBUG"): - print "Setting %s(%r) <= %s" % ( - element.get_name(), old_val, element.value) + LOG.debug("Setting %s(%r) <= %s" % ( + element.get_name(), old_val, element.value)) setattr(obj, setting, element.value) except AttributeError as e: print "Setting %s is not in the memory map: %s" % ( @@ -1623,4 +1624,4 @@ class FT1Radio(yaesu_clone.YaesuCloneModeRadio): val = [FT1_DTMF_CHARS.index(x) for x in rawval] for x in range(len(val), 16): val.append(0xFF) - cls._memobj.dtmf[i].memory = val \ No newline at end of file + cls._memobj.dtmf[i].memory = val diff --git a/chirp/ft2800.py b/chirp/ft2800.py index fb9d10c..feac0ce 100644 --- a/chirp/ft2800.py +++ b/chirp/ft2800.py @@ -15,11 +15,12 @@
import time import os +import logging
from chirp import util, memmap, chirp_common, bitwise, directory, errors from chirp.yaesu_clone import YaesuCloneModeRadio
-DEBUG = os.getenv("CHIRP_DEBUG") and True or False +LOG = logging.getLogger(__name__)
CHUNK_SIZE = 16 def _send(s, data): @@ -41,8 +42,7 @@ def _download(radio): if data == IDBLOCK: break
- if DEBUG: - print "Header:\n%s" % util.hexprint(data) + LOG.debug("Header:\n%s" % util.hexprint(data))
if len(data) != 8: raise Exception("Failed to read header") @@ -54,8 +54,7 @@ def _download(radio): while len(data) < radio._block_sizes[1]: time.sleep(0.1) chunk = radio.pipe.read(38) - if DEBUG: - print "Got: %i:\n%s" % (len(chunk), util.hexprint(chunk)) + LOG.debug("Got: %i:\n%s" % (len(chunk), util.hexprint(chunk))) if len(chunk) == 8: print "END?" elif len(chunk) != 38: @@ -79,8 +78,7 @@ def _download(radio): status.msg = "Cloning from radio" radio.status_fn(status)
- if DEBUG: - print "Total: %i" % len(data) + LOG.debug("Total: %i" % len(data))
return memmap.MemoryMap(data)
@@ -94,8 +92,7 @@ def _upload(radio): _send(radio.pipe, IDBLOCK) time.sleep(1) ack = radio.pipe.read(300) - if DEBUG: - print "Ack was (%i):\n%s" % (len(ack), util.hexprint(ack)) + LOG.debug("Ack was (%i):\n%s" % (len(ack), util.hexprint(ack))) if ack != ACK: raise Exception("Radio did not ack ID")
@@ -108,8 +105,7 @@ def _upload(radio): cs += ord(byte) data += chr(cs & 0xFF)
- if DEBUG: - print "Writing block %i:\n%s" % (block, util.hexprint(data)) + LOG.debug("Writing block %i:\n%s" % (block, util.hexprint(data)))
_send(radio.pipe, data) time.sleep(0.1) diff --git a/chirp/ft60.py b/chirp/ft60.py index 45c92d0..74799ef 100644 --- a/chirp/ft60.py +++ b/chirp/ft60.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-import time, os +import time, os, logging from chirp import chirp_common, yaesu_clone, memmap, bitwise, directory from chirp import errors from chirp.settings import RadioSetting, RadioSettingGroup, \ @@ -22,6 +22,8 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueFloat, RadioSettings from textwrap import dedent
+LOG = logging.getLogger(__name__) + ACK = "\x06"
def _send(pipe, data): @@ -617,8 +619,7 @@ class FT60Radio(yaesu_clone.YaesuCloneModeRadio): obj = getattr(_settings, name) setattr(_settings, name, value)
- if os.getenv("CHIRP_DEBUG"): - print "Setting %s: %s" % (name, value) + LOG.debug("Setting %s: %s" % (name, value)) except Exception, e: print element.get_name() raise diff --git a/chirp/ft7800.py b/chirp/ft7800.py index 451fb08..824bd6d 100644 --- a/chirp/ft7800.py +++ b/chirp/ft7800.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-import time +import time, logging from chirp import chirp_common, yaesu_clone, memmap, directory from chirp import bitwise, errors from textwrap import dedent @@ -25,10 +25,7 @@ import os, re
from collections import defaultdict
-if os.getenv("CHIRP_DEBUG"): - CHIRP_DEBUG = True -else: - CHIRP_DEBUG = False +LOG = logging.getLogger(__name__)
ACK = chr(0x06)
@@ -540,9 +537,8 @@ class FT7800Radio(FTx800Radio): FTx800Radio.set_memory(self, memory)
def _decode_chars(self, inarr): - if CHIRP_DEBUG: - print "@_decode_chars, type: %s" % type(inarr) - print inarr + LOG.debug("@_decode_chars, type: %s" % type(inarr)) + LOG.debug(inarr) outstr = "" for i in inarr: if i == 0xFF: @@ -551,9 +547,8 @@ class FT7800Radio(FTx800Radio): return outstr.rstrip()
def _encode_chars(self, instr, length = 16): - if CHIRP_DEBUG: - print "@_encode_chars, type: %s" % type(instr) - print instr + LOG.debug("@_encode_chars, type: %s" % type(instr)) + LOG.debug(instr) outarr = [] instr = str(instr) for i in range(length): @@ -647,8 +642,7 @@ class FT7800Radio(FTx800Radio): break if c < len(DTMFCHARSET): dtmfstr += DTMFCHARSET[c] - if CHIRP_DEBUG: - print dtmfstr + LOG.debug(dtmfstr) dtmfentry = RadioSettingValueString(0, 16, dtmfstr) dtmfentry.set_charset(DTMFCHARSET + list(" ")) rs = RadioSetting(name, name.upper(), dtmfentry) @@ -721,8 +715,7 @@ class FT7800Radio(FTx800Radio): newval.append(DTMFCHARSET.index(dtmfstr[i])) else: newval.append(0xFF) - if CHIRP_DEBUG: - print newval + LOG.debug(newval) idx = int(setting[-2:]) _settings = self._memobj.dtmf[idx] _settings.memory = newval @@ -735,9 +728,7 @@ class FT7800Radio(FTx800Radio): # normal settings newval = element.value oldval = getattr(_settings, setting) - if CHIRP_DEBUG: - print "Setting %s(%s) <= %s" % (setting, - oldval, newval) + LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval)) setattr(_settings, setting, newval) except Exception, e: print element.get_name() diff --git a/chirp/ft817.py b/chirp/ft817.py index 8950f73..c0b42b2 100644 --- a/chirp/ft817.py +++ b/chirp/ft817.py @@ -22,9 +22,11 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ RadioSettings -import time, os +import time, os, logging from textwrap import dedent
+LOG = logging.getLogger(__name__) + CMD_ACK = 0x06
@directory.register @@ -319,8 +321,7 @@ class FT817Radio(yaesu_clone.YaesuCloneModeRadio): raise Exception("Unable to read block %02X expected %i got %i" % (blocknum, block + 2, len(data)))
- if os.getenv("CHIRP_DEBUG"): - print "Read %i" % len(data) + LOG.debug("Read %i" % len(data)) return data
def _clone_in(self): @@ -382,15 +383,12 @@ class FT817Radio(yaesu_clone.YaesuCloneModeRadio): for _i in range(0, repeat): time.sleep(0.01) checksum = yaesu_clone.YaesuChecksum(pos, pos + block - 1) - if os.getenv("CHIRP_DEBUG"): - print "Block %i - will send from %i to %i byte " % \ - (blocks, - pos, - pos + block) - print util.hexprint(chr(blocks)) - print util.hexprint(self.get_mmap()[pos:pos + block]) - print util.hexprint(chr(checksum.get_calculated( - self.get_mmap()))) + LOG.debug("Block %i - will send from %i to %i byte " % \ + (blocks, pos, pos + block)) + LOG.debug(util.hexprint(chr(blocks))) + LOG.debug(util.hexprint(self.get_mmap()[pos:pos + block])) + LOG.debug(util.hexprint(chr(checksum.get_calculated( + self.get_mmap())))) self.pipe.write(chr(blocks)) self.pipe.write(self.get_mmap()[pos:pos + block]) self.pipe.write(chr(checksum.get_calculated(self.get_mmap()))) @@ -399,8 +397,7 @@ class FT817Radio(yaesu_clone.YaesuCloneModeRadio): time.sleep(delay) buf = self.pipe.read(1) if not buf or buf[0] != chr(CMD_ACK): - if os.getenv("CHIRP_DEBUG"): - print util.hexprint(buf) + LOG.debug(util.hexprint(buf)) raise Exception(_("Radio did not ack block %i") % blocks) pos += block blocks += 1 @@ -1030,9 +1027,11 @@ class FT817Radio(yaesu_clone.YaesuCloneModeRadio): else: obj = _settings setting = element.get_name() - if os.getenv("CHIRP_DEBUG"): - print "Setting %s(%s) <= %s" % (setting, - getattr(obj, setting), element.value) + try: + LOG.debug("Setting %s(%s) <= %s" % (setting, + getattr(obj, setting), element.value)) + except AttributeError: + LOG.debug("Setting %s <= %s" % (setting, element.value)) if setting == "contrast": setattr(obj, setting, int(element.value) + 1) elif setting == "callsign": diff --git a/chirp/ft857.py b/chirp/ft857.py index a479623..940c62d 100644 --- a/chirp/ft857.py +++ b/chirp/ft857.py @@ -21,9 +21,11 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ RadioSettings -import os +import os, logging from textwrap import dedent
+LOG = logging.getLogger(__name__) + @directory.register class FT857Radio(ft817.FT817Radio): """Yaesu FT-857/897""" @@ -956,9 +958,11 @@ class FT857Radio(ft817.FT817Radio): else: obj = _settings setting = element.get_name() - if os.getenv("CHIRP_DEBUG"): - print "Setting %s(%s) <= %s" % (setting, - getattr(obj, setting), element.value) + try: + LOG.debug("Setting %s(%s) <= %s" % (setting, + getattr(obj, setting), element.value)) + except AttributeError: + LOG.debug("Setting %s <= %s" % (setting, element.value)) if setting == "arts_idw": self._memobj.arts_idw = \ [self._CALLSIGN_CHARSET_REV[x] for x in diff --git a/chirp/ft90.py b/chirp/ft90.py index bfbddda..b638d47 100644 --- a/chirp/ft90.py +++ b/chirp/ft90.py @@ -19,13 +19,10 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ RadioSettings -import time, os, traceback, string, re +import time, os, traceback, string, re, logging from textwrap import dedent
-if os.getenv("CHIRP_DEBUG"): - CHIRP_DEBUG = True -else: - CHIRP_DEBUG=False +LOG = logging.getLogger(__name__)
CMD_ACK = chr(0x06)
@@ -289,27 +286,24 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): blocknumbyte = chr(blocknum) payloadbytes = self.get_mmap()[pos:pos+blocksize] checksumbyte = chr(checksum.get_calculated(self.get_mmap())) - if CHIRP_DEBUG: - print "Block %i - will send from %i to %i byte " % \ - (blocknum, pos, pos + blocksize) - print util.hexprint(blocknumbyte) - print util.hexprint(payloadbytes) - print util.hexprint(checksumbyte) + LOG.debug("Block %i - will send from %i to %i byte " % \ + (blocknum, pos, pos + blocksize)) + LOG.debug(util.hexprint(blocknumbyte)) + LOG.debug(util.hexprint(payloadbytes)) + LOG.debug(util.hexprint(checksumbyte)) # send wrapped bytes time.sleep(looppredelay) self.pipe.write(blocknumbyte) self.pipe.write(payloadbytes) self.pipe.write(checksumbyte) tmp = self.pipe.read(blocksize+2) #chew echo - if CHIRP_DEBUG: - print "bytes echoed: " - print util.hexprint(tmp) + LOG.debug("bytes echoed: ") + LOG.debug(util.hexprint(tmp)) # radio is slow to write/ack: time.sleep(looppostdelay) buf = self.pipe.read(1) - if CHIRP_DEBUG: - print "ack recd:" - print util.hexprint(buf) + LOG.debug("ack recd:") + LOG.debug(util.hexprint(buf)) if buf != CMD_ACK: raise Exception("Radio did not ack block %i" % blocknum) pos += blocksize @@ -463,12 +457,10 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio):
def _decode_cwid(self, cwidarr): cwid = "" - if CHIRP_DEBUG: - print "@ +_decode_cwid:" + LOG.debug("@ +_decode_cwid:") for byte in cwidarr.get_value(): char = int(byte) - if CHIRP_DEBUG: - print char + LOG.debug(char) # bitwise wraps in quotes! get rid of those if char < len(FT90_CWID_CHARS): cwid += FT90_CWID_CHARS[char] @@ -476,21 +468,17 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio):
def _encode_cwid(self, cwidarr): cwid = "" - if CHIRP_DEBUG: - print "@ _encode_cwid:" + LOG.debug("@ _encode_cwid:") for char in cwidarr.get_value(): cwid += chr(FT90_CWID_CHARS.index(char)) - if CHIRP_DEBUG: - print cwid + LOG.debug(cwid) return cwid
def _bbcd2dtmf(self, bcdarr, strlen = 16): # doing bbcd, but with support for ABCD*# - if CHIRP_DEBUG: - print bcdarr.get_value() + LOG.debug(bcdarr.get_value()) string = ''.join("%02X" % b for b in bcdarr) - if CHIRP_DEBUG: - print "@_bbcd2dtmf, received: %s" % string + LOG.debug("@_bbcd2dtmf, received: %s" % string) string = string.replace('E','*').replace('F','#') if strlen <= 16: string = string[:strlen] @@ -501,8 +489,7 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): dtmfstr = dtmfstr.replace('*', 'E').replace('#', 'F') dtmfstr = str.ljust(dtmfstr.strip(), 16, "0" ) bcdarr = list(bytearray.fromhex(dtmfstr)) - if CHIRP_DEBUG: - print "@_dtmf2bbcd, sending: %s" % bcdarr + LOG.debug("@_dtmf2bbcd, sending: %s" % bcdarr) return bcdarr
def get_settings(self): @@ -644,9 +631,7 @@ class FT90Radio(yaesu_clone.YaesuCloneModeRadio): dtmfstrlen = len(str(newval).strip()) setattr(_settings, setting + "_len", dtmfstrlen) newval = self._dtmf2bbcd(newval) - if CHIRP_DEBUG: - print "Setting %s(%s) <= %s" % (setting, - oldval, newval) + LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval)) setattr(_settings, setting, newval) except Exception, e: print element.get_name() diff --git a/chirp/ftm350.py b/chirp/ftm350.py index 442cde1..e3fcbfe 100644 --- a/chirp/ftm350.py +++ b/chirp/ftm350.py @@ -16,12 +16,15 @@ import time import struct import os +import logging
from chirp import chirp_common, yaesu_clone, directory, errors, util from chirp import bitwise, memmap from chirp.settings import RadioSettingGroup, RadioSetting, RadioSettings from chirp.settings import RadioSettingValueInteger, RadioSettingValueString
+LOG = logging.getLogger(__name__) + mem_format = """ struct mem { u8 used:1, @@ -141,8 +144,8 @@ def _clone_in(radio): radio.pipe.write("\x06") time.sleep(0.05)
- if os.getenv("CHIRP_DEBUG") and (last_addr + 128) != addr: - print "Gap, expecting %04x, got %04x" % (last_addr+128, addr) + if (last_addr + 128) != addr: + LOG.debug("Gap, expecting %04x, got %04x" % (last_addr+128, addr)) last_addr = addr data[addr] = block length += len(block) diff --git a/chirp/h777.py b/chirp/h777.py index bce4b98..5ac0351 100644 --- a/chirp/h777.py +++ b/chirp/h777.py @@ -18,6 +18,7 @@ import time import os import struct import unittest +import logging
from chirp import chirp_common, directory, memmap from chirp import bitwise, errors, util @@ -25,7 +26,7 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettings
-DEBUG = os.getenv("CHIRP_DEBUG") and True or False +LOG = logging.getLogger(__name__)
MEM_FORMAT = """ #seekto 0x0010; @@ -139,8 +140,7 @@ def _h777_read_block(radio, block_addr, block_size):
cmd = struct.pack(">cHb", 'R', block_addr, BLOCK_SIZE) expectedresponse = "W" + cmd[1:] - if DEBUG: - print("Reading block %04x..." % (block_addr)) + LOG.debug("Reading block %04x..." % (block_addr))
try: serial.write(cmd) @@ -166,9 +166,8 @@ def _h777_write_block(radio, block_addr, block_size): cmd = struct.pack(">cHb", 'W', block_addr, BLOCK_SIZE) data = radio.get_mmap()[block_addr:block_addr + 8]
- if DEBUG: - print("Writing Data:") - print util.hexprint(cmd + data) + LOG.debug("Writing Data:") + LOG.debug(util.hexprint(cmd + data))
try: serial.write(cmd + data) @@ -197,9 +196,8 @@ def do_download(radio): block = _h777_read_block(radio, addr, BLOCK_SIZE) data += block
- if DEBUG: - print "Address: %04x" % addr - print util.hexprint(block) + LOG.debug("Address: %04x" % addr) + LOG.debug(util.hexprint(block))
_h777_exit_programming_mode(radio)
diff --git a/chirp/icomciv.py b/chirp/icomciv.py index 71af300..1d02553 100644 --- a/chirp/icomciv.py +++ b/chirp/icomciv.py @@ -1,9 +1,9 @@
-import struct +import struct, logging from chirp import chirp_common, icf, util, errors, bitwise, directory from chirp.memmap import MemoryMap
-DEBUG = True +LOG = logging.getLogger(__name__)
MEM_FORMAT = """ bbcd number[2]; @@ -80,9 +80,8 @@ class Frame: raw = struct.pack("BBBBBB", 0xFE, 0xFE, src, dst, self._cmd, self._sub) raw += str(self._data) + chr(0xFD)
- if DEBUG: - print "%02x -> %02x (%i):\n%s" % (src, dst, - len(raw), util.hexprint(raw)) + LOG.debug("%02x -> %02x (%i):\n%s" % (src, dst, + len(raw), util.hexprint(raw)))
serial.write(raw) if willecho: @@ -106,8 +105,7 @@ class Frame: raise errors.RadioError("Radio reported error")
src, dst = struct.unpack("BB", data[2:4]) - if DEBUG: - print "%02x <- %02x:\n%s" % (src, dst, util.hexprint(data)) + LOG.debug("%02x <- %02x:\n%s" % (src, dst, util.hexprint(data)))
self._cmd = ord(data[4]) self._sub = ord(data[5]) diff --git a/chirp/idrp.py b/chirp/idrp.py index e20ba07..012bb46 100644 --- a/chirp/idrp.py +++ b/chirp/idrp.py @@ -13,12 +13,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-import serial +import serial, logging
-from chirp import chirp_common, errors -from chirp import util +from chirp import chirp_common, errors, util
-DEBUG_IDRP = False +LOG = logging.getLogger(__name__)
def parse_frames(buf): """Parse frames from the radio""" @@ -49,8 +48,7 @@ def send(pipe, buf): break
data += buf - if DEBUG_IDRP: - print "Got: \n%s" % util.hexprint(buf) + LOG.debug("Got: \n%s" % util.hexprint(buf))
return parse_frames(data)
@@ -97,8 +95,7 @@ def get_freq(pipe): ord(els[2]), ord(els[1]), ord(els[0]))) - if DEBUG_IDRP: - print "Freq: %f" % freq + LOG.debug("Freq: %f" % freq) return freq
raise errors.InvalidDataError("No frequency frame received") diff --git a/chirp/kenwood_live.py b/chirp/kenwood_live.py index 971c08e..6cac1c9 100644 --- a/chirp/kenwood_live.py +++ b/chirp/kenwood_live.py @@ -17,6 +17,9 @@ import threading import os import sys import time +import logging + +LOG = logging.getLogger(__name__)
NOCACHE = os.environ.has_key("CHIRP_NOCACHE")
@@ -29,8 +32,6 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueBoolean, \ RadioSettingValueString, RadioSettingValueList, RadioSettings
-DEBUG = True - DUPLEX = { 0 : "", 1 : "+", 2 : "-" } MODES = { 0 : "FM", 1 : "AM" } STEPS = list(chirp_common.TUNING_STEPS) @@ -49,8 +50,7 @@ def command(ser, cmd, *args): LOCK.acquire() if args: cmd += " " + " ".join(args) - if DEBUG: - print "PC->RADIO: %s" % cmd + LOG.debug("PC->RADIO: %s" % cmd) ser.write(cmd + "\r")
result = "" @@ -60,8 +60,7 @@ def command(ser, cmd, *args): print "Timeout waiting for data" break
- if DEBUG: - print "D7->PC: %s" % result.strip() + LOG.debug("D7->PC: %s" % result.strip())
LOCK.release()
diff --git a/chirp/kguv8d.py b/chirp/kguv8d.py index 772b04f..d0f779f 100644 --- a/chirp/kguv8d.py +++ b/chirp/kguv8d.py @@ -17,16 +17,14 @@
import time import os +import logging from chirp import util, chirp_common, bitwise, memmap, errors, directory from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettingValueList, \ RadioSettingValueInteger, RadioSettingValueString, \ RadioSettings
-if os.getenv("CHIRP_DEBUG"): - CHIRP_DEBUG = True -else: - CHIRP_DEBUG = False +LOG = logging.getLogger(__name__)
CMD_ID = 128 CMD_END = 129 @@ -304,8 +302,7 @@ class KGUV8DRadio(chirp_common.CloneModeRadio, _packet += payload # calculate and add the checksum to the packet _packet += chr(self._checksum(_packet[1:])) - if CHIRP_DEBUG: - print "Sent:\n%s" % util.hexprint(_packet) + LOG.debug("Sent:\n%s" % util.hexprint(_packet)) self.pipe.write(_packet)
def _read_record(self): @@ -317,9 +314,8 @@ class KGUV8DRadio(chirp_common.CloneModeRadio, _cs += self._checksum(_packet) _cs %= 256 _rcs = ord(self.pipe.read(1)) - if CHIRP_DEBUG: - print "_cs =", _cs - print "_rcs=", _rcs + LOG.debug("_cs =", _cs) + LOG.debug("_rcs=", _rcs) return (_rcs != _cs, _packet)
# Identify the radio @@ -350,14 +346,12 @@ class KGUV8DRadio(chirp_common.CloneModeRadio, for _i in range(0, 10): self._write_record(CMD_ID) _chksum_err, _resp = self._read_record() - if CHIRP_DEBUG: - print "Got:\n%s" % util.hexprint(_resp) + LOG.debug("Got:\n%s" % util.hexprint(_resp)) if _chksum_err: print "Checksum error: retrying ident..." time.sleep(0.100) continue - if CHIRP_DEBUG: - print "Model %s" % util.hexprint(_resp[0:7]) + LOG.debug("Model %s" % util.hexprint(_resp[0:7])) if _resp[0:7] == self._model: return if len(_resp) == 0: @@ -407,8 +401,7 @@ class KGUV8DRadio(chirp_common.CloneModeRadio, # TODO: probably should retry a few times here print util.hexprint(resp) raise Exception("Checksum error on read") - if CHIRP_DEBUG: - print "Got:\n%s" % util.hexprint(resp) + LOG.debug("Got:\n%s" % util.hexprint(resp)) image += resp[2:] if self.status_fn: status = chirp_common.Status() @@ -436,11 +429,9 @@ class KGUV8DRadio(chirp_common.CloneModeRadio, req = chr(i / 256) + chr(i % 256) chunk = self.get_mmap()[ptr:ptr + blocksize] self._write_record(CMD_WR, req + chunk) - if CHIRP_DEBUG: - print util.hexprint(req + chunk) + LOG.debug(util.hexprint(req + chunk)) cserr, ack = self._read_record() - if CHIRP_DEBUG: - print util.hexprint(ack) + LOG.debug(util.hexprint(ack)) j = ord(ack[0]) * 256 + ord(ack[1]) if cserr or j != ptr: raise Exception("Radio did not ack block %i" % ptr) @@ -537,9 +528,8 @@ class KGUV8DRadio(chirp_common.CloneModeRadio, # always set it even if no dtcs is used mem.dtcs_polarity = "%s%s" % (tpol or "N", rpol or "N")
- if os.getenv("CHIRP_DEBUG"): - print "Got TX %s (%i) RX %s (%i)" % (txmode, _mem.txtone, - rxmode, _mem.rxtone) + LOG.debug("Got TX %s (%i) RX %s (%i)" % (txmode, _mem.txtone, + rxmode, _mem.rxtone))
def get_memory(self, number): _mem = self._memobj.memory[number] @@ -549,8 +539,7 @@ class KGUV8DRadio(chirp_common.CloneModeRadio, mem.number = number _valid = self._memobj.valid[mem.number]
- if CHIRP_DEBUG: - print number, _valid == MEM_VALID + LOG.debug("%d %s", number, _valid == MEM_VALID) if _valid != MEM_VALID: mem.empty = True return mem @@ -618,9 +607,8 @@ class KGUV8DRadio(chirp_common.CloneModeRadio, else: _mem.rxtone = 0
- if CHIRP_DEBUG: - print "Set TX %s (%i) RX %s (%i)" % (tx_mode, _mem.txtone, - rx_mode, _mem.rxtone) + LOG.debug("Set TX %s (%i) RX %s (%i)" % (tx_mode, _mem.txtone, + rx_mode, _mem.rxtone))
def set_memory(self, mem): number = mem.number diff --git a/chirp/kyd.py b/chirp/kyd.py index 2d4223d..e188df9 100644 --- a/chirp/kyd.py +++ b/chirp/kyd.py @@ -17,6 +17,7 @@ import time import os import struct +import logging
from chirp import chirp_common, directory, memmap from chirp import bitwise, errors, util @@ -24,7 +25,7 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettings
-DEBUG = os.getenv("CHIRP_DEBUG") and True or False +LOG = logging.getLogger(__name__)
MEM_FORMAT = """ #seekto 0x0010; @@ -132,8 +133,7 @@ def _nc630a_read_block(radio, block_addr, block_size):
cmd = struct.pack(">cHb", 'R', block_addr, BLOCK_SIZE) expectedresponse = "W" + cmd[1:] - if DEBUG: - print("Reading block %04x..." % (block_addr)) + LOG.debug("Reading block %04x..." % (block_addr))
try: serial.write(cmd) @@ -159,9 +159,8 @@ def _nc630a_write_block(radio, block_addr, block_size): cmd = struct.pack(">cHb", 'W', block_addr, BLOCK_SIZE) data = radio.get_mmap()[block_addr:block_addr + 8]
- if DEBUG: - print("Writing Data:") - print util.hexprint(cmd + data) + LOG.debug("Writing Data:") + LOG.debug(util.hexprint(cmd + data))
try: serial.write(cmd + data) @@ -190,9 +189,8 @@ def do_download(radio): block = _nc630a_read_block(radio, addr, BLOCK_SIZE) data += block
- if DEBUG: - print "Address: %04x" % addr - print util.hexprint(block) + LOG.debug("Address: %04x" % addr) + LOG.debug(util.hexprint(block))
_nc630a_exit_programming_mode(radio)
@@ -301,9 +299,8 @@ class NC630aRadio(chirp_common.CloneModeRadio): if mem.tmode == "DTCS": mem.dtcs_polarity = "%s%s" % (tpol, rpol)
- if os.getenv("CHIRP_DEBUG"): - print "Got TX %s (%i) RX %s (%i)" % (txmode, _mem.tx_tone, - rxmode, _mem.rx_tone) + LOG.debug("Got TX %s (%i) RX %s (%i)" % (txmode, _mem.tx_tone, + rxmode, _mem.rx_tone))
def get_memory(self, number): bitpos = (1 << ((number - 1) % 8)) @@ -387,9 +384,8 @@ class NC630aRadio(chirp_common.CloneModeRadio): else: _mem.rx_tone = 0xFFFF
- if os.getenv("CHIRP_DEBUG"): - print "Set TX %s (%i) RX %s (%i)" % (tx_mode, _mem.tx_tone, - rx_mode, _mem.rx_tone) + LOG.debug("Set TX %s (%i) RX %s (%i)" % (tx_mode, _mem.tx_tone, + rx_mode, _mem.rx_tone))
def set_memory(self, mem): bitpos = (1 << ((mem.number - 1) % 8)) diff --git a/chirp/leixen.py b/chirp/leixen.py index 1977f0c..285fe84 100644 --- a/chirp/leixen.py +++ b/chirp/leixen.py @@ -24,11 +24,6 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueFloat, InvalidValueError, RadioSettings from textwrap import dedent
-if os.getenv("CHIRP_DEBUG"): - CHIRP_DEBUG = True -else: - CHIRP_DEBUG = False - MEM_FORMAT = """ #seekto 0x0184; struct { diff --git a/chirp/puxing.py b/chirp/puxing.py index 88cbe79..f38b41e 100644 --- a/chirp/puxing.py +++ b/chirp/puxing.py @@ -20,11 +20,6 @@ import os from chirp import util, chirp_common, bitwise, errors, directory from chirp.wouxun_common import wipe_memory, do_download, do_upload
-if os.getenv("CHIRP_DEBUG"): - DEBUG = True -else: - DEBUG = False - def _puxing_prep(radio): radio.pipe.write("\x02PROGRA") ack = radio.pipe.read(1) diff --git a/chirp/th9800.py b/chirp/th9800.py index 3edc310..d1a1b0b 100644 --- a/chirp/th9800.py +++ b/chirp/th9800.py @@ -24,12 +24,10 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ from chirp_common import format_freq import os import time +import logging from datetime import date
-if os.getenv("CHIRP_DEBUG"): - CHIRP_DEBUG = True -else: - CHIRP_DEBUG = False +LOG = logging.getLogger(__name__)
TH9800_MEM_FORMAT = """ struct mem { @@ -323,8 +321,7 @@ class TYTTH9800Base(chirp_common.Radio): _prev_active = self.get_active("chan_active", mem.number) self.set_active("chan_active", mem.number, not mem.empty) if mem.empty or not _prev_active: - if CHIRP_DEBUG: - print "initializing memory channel %d" % mem.number + LOG.debug("initializing memory channel %d" % mem.number) _mem.set_raw(BLANK_MEMORY)
if mem.empty: @@ -390,8 +387,7 @@ class TYTTH9800Base(chirp_common.Radio): _mem.step = STEPS.index(mem.tuning_step)
for setting in mem.extra: - if CHIRP_DEBUG: - print "@set_mem:", setting.get_name(), setting.value + LOG.debug("@set_mem:", setting.get_name(), setting.value) setattr(_mem, setting.get_name(), setting.value)
def get_settings(self): @@ -559,9 +555,7 @@ class TYTTH9800Base(chirp_common.Radio): oldval = getattr(_settings, setting) newval = element.value
- if CHIRP_DEBUG: - print "Setting %s(%s) <= %s" % (setting, - oldval, newval) + LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval)) setattr(_settings, setting, newval) except Exception, e: print element.get_name() @@ -666,12 +660,12 @@ def _upload(radio, memsize = 0xF400, blocksize = 0x80): m = today.month d = today.day _info = radio._memobj.info - if CHIRP_DEBUG: - ly = _info.prog_yr - lm = _info.prog_mon - ld = _info.prog_day - print "Updating last program date:%d/%d/%d" % (lm,ld,ly) - print " to today:%d/%d/%d" % (m,d,y) + + ly = _info.prog_yr + lm = _info.prog_mon + ld = _info.prog_day + LOG.debug("Updating last program date:%d/%d/%d" % (lm,ld,ly)) + LOG.debug(" to today:%d/%d/%d" % (m,d,y))
_info.prog_yr = y _info.prog_mon = m @@ -680,8 +674,7 @@ def _upload(radio, memsize = 0xF400, blocksize = 0x80): offset = 0x0100 for addr in range(offset, memsize, blocksize): mapaddr = addr + radio._mmap_offset - offset - if CHIRP_DEBUG: - print "addr: 0x%04X, mmapaddr: 0x%04X" % (addr, mapaddr) + LOG.debug("addr: 0x%04X, mmapaddr: 0x%04X" % (addr, mapaddr)) msg = struct.pack(">cHB", "W", addr, blocksize) msg += radio._mmap[mapaddr:(mapaddr + blocksize)] print util.hexprint(msg) @@ -703,8 +696,7 @@ def _upload(radio, memsize = 0xF400, blocksize = 0x80):
# Checksum? final_data = radio.pipe.read(3) - if CHIRP_DEBUG: - print "final:", util.hexprint(final_data) + LOG.debug("final:", util.hexprint(final_data))
@directory.register class TYTTH9800Radio(TYTTH9800Base, chirp_common.CloneModeRadio, diff --git a/chirp/th_uv3r.py b/chirp/th_uv3r.py index 5e3e2c0..3b670fe 100644 --- a/chirp/th_uv3r.py +++ b/chirp/th_uv3r.py @@ -19,11 +19,6 @@ import os from chirp import chirp_common, bitwise, errors, directory from chirp.wouxun_common import do_download, do_upload
-if os.getenv("CHIRP_DEBUG"): - DEBUG = True -else: - DEBUG = False - def tyt_uv3r_prep(radio): try: radio.pipe.write("PROGRAMa") diff --git a/chirp/thd72.py b/chirp/thd72.py index 0d80adc..aa414de 100644 --- a/chirp/thd72.py +++ b/chirp/thd72.py @@ -15,9 +15,9 @@
from chirp import chirp_common, errors, util, directory from chirp import bitwise, memmap -import time, struct, sys +import time, struct, sys, logging
-DEBUG = True +LOG = logging.getLogger(__name__)
# TH-D72 memory map # 0x0000..0x0200: startup password and other stuff @@ -452,13 +452,11 @@ class THD72Radio(chirp_common.CloneModeRadio): start = time.time()
data = "" - if DEBUG: - print "PC->D72: %s" % cmd + LOG.debug("PC->D72: %s" % cmd) self.pipe.write(cmd + "\r") while not data.endswith("\r") and (time.time() - start) < timeout: data += self.pipe.read(1) - if DEBUG: - print "D72->PC: %s" % data.strip() + LOG.debug("D72->PC: %s" % data.strip()) return data.strip()
def get_id(self): diff --git a/chirp/tk8102.py b/chirp/tk8102.py index 32e8621..4cf291e 100644 --- a/chirp/tk8102.py +++ b/chirp/tk8102.py @@ -15,6 +15,7 @@
import struct import os +import logging
from chirp import chirp_common, directory, memmap, errors, util from chirp import bitwise @@ -22,6 +23,8 @@ from chirp.settings import RadioSettingGroup, RadioSetting from chirp.settings import RadioSettingValueBoolean, RadioSettingValueList from chirp.settings import RadioSettingValueString, RadioSettings
+LOG = logging.getLogger(__name__) + MEM_FORMAT = """ #seekto 0x0030; struct { @@ -317,9 +320,8 @@ class KenwoodTKx102Radio(chirp_common.CloneModeRadio): else: _mem.rx_tone = 0xFFFF
- if os.getenv("CHIRP_DEBUG"): - print "Set TX %s (%i) RX %s (%i)" % (tx_mode, _mem.tx_tone, - rx_mode, _mem.rx_tone) + LOG.debug("Set TX %s (%i) RX %s (%i)" % (tx_mode, _mem.tx_tone, + rx_mode, _mem.rx_tone)) def set_memory(self, mem): _mem = self._memobj.memory[mem.number - 1]
diff --git a/chirp/tmv71_ll.py b/chirp/tmv71_ll.py index dac7f36..201412e 100644 --- a/chirp/tmv71_ll.py +++ b/chirp/tmv71_ll.py @@ -13,11 +13,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-import struct, time +import struct, time, logging
from chirp import memmap, chirp_common, errors
-DEBUG = True +LOG = logging.getLogger(__name__)
POS_MODE = 5 POS_DUP = 6 @@ -50,13 +50,11 @@ def command(s, cmd, timeout=0.5): start = time.time()
data = "" - if DEBUG: - print "PC->V71: %s" % cmd + LOG.debug("PC->V71: %s" % cmd) s.write(cmd + "\r") while not data.endswith("\r") and (time.time() - start) < timeout: data += s.read(1) - if DEBUG: - print "V71->PC: %s" % data.strip() + LOG.debug("V71->PC: %s" % data.strip()) return data.strip()
def get_id(s): diff --git a/chirp/uv5r.py b/chirp/uv5r.py index 6fcbae1..646d6e2 100644 --- a/chirp/uv5r.py +++ b/chirp/uv5r.py @@ -16,6 +16,7 @@ import struct import time import os +import logging
from chirp import chirp_common, errors, util, directory, memmap from chirp import bitwise @@ -25,10 +26,7 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueFloat, InvalidValueError, RadioSettings from textwrap import dedent
-if os.getenv("CHIRP_DEBUG"): - CHIRP_DEBUG = True -else: - CHIRP_DEBUG = False +LOG = logging.getLogger(__name__)
MEM_FORMAT = """ #seekto 0x0008; @@ -394,8 +392,7 @@ def _firmware_version_from_image(radio): version = _firmware_version_from_data(radio.get_mmap(), radio._fw_ver_file_start, radio._fw_ver_file_stop) - if CHIRP_DEBUG: - print "_firmware_version_from_image: " + util.hexprint(version) + LOG.debug("_firmware_version_from_image: " + util.hexprint(version)) return version
def _special_block_from_data(data, special_block_start, special_block_stop): @@ -404,8 +401,7 @@ def _special_block_from_data(data, special_block_start, special_block_stop):
def _special_block_from_image(radio): special_block = _special_block_from_data(radio.get_mmap(), 0x0CFA, 0x0D01) - if CHIRP_DEBUG: - print "_special_block_from_image: " + util.hexprint(special_block) + LOG.debug("_special_block_from_image: " + util.hexprint(special_block)) return special_block
def _do_ident(radio, magic): @@ -504,19 +500,16 @@ def _do_download(radio): raise errors.RadioError("Incorrect 'Model' selected.")
# Main block - if CHIRP_DEBUG: - print "downloading main block..." + LOG.debug("downloading main block...") for i in range(0, 0x1800, 0x40): data += _read_block(radio, i, 0x40) _do_status(radio, i) - if CHIRP_DEBUG: - print "done." - print "downloading aux block..." + LOG.debug("done.") + LOG.debug("downloading aux block...") # Auxiliary block starts at 0x1ECO (?) for i in range(0x1EC0, 0x2000, 0x40): data += _read_block(radio, i, 0x40) - if CHIRP_DEBUG: - print "done." + LOG.debug("done.") return memmap.MemoryMap(data)
def _send_block(radio, addr, data): @@ -916,8 +909,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
def _is_orig(self): version_tag = _firmware_version_from_image(self) - if CHIRP_DEBUG: - print "@_is_orig, version_tag:", util.hexprint(version_tag) + LOG.debug("@_is_orig, version_tag: %s", util.hexprint(version_tag)) try: if 'BFB' in version_tag: idx = version_tag.index("BFB") + 3 diff --git a/chirp/vx170.py b/chirp/vx170.py index 20aac04..eaa7dbc 100644 --- a/chirp/vx170.py +++ b/chirp/vx170.py @@ -19,11 +19,6 @@ from textwrap import dedent import time, os from chirp import ft7800
-if os.getenv("CHIRP_DEBUG"): - CHIRP_DEBUG = True -else: - CHIRP_DEBUG = False - MEM_FORMAT = """ #seekto 0x018A; struct { diff --git a/chirp/vx2.py b/chirp/vx2.py index 3156806..6c6b912 100644 --- a/chirp/vx2.py +++ b/chirp/vx2.py @@ -19,12 +19,9 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ RadioSettings -import os, traceback, re +import os, traceback, re, logging
-if os.getenv("CHIRP_DEBUG"): - CHIRP_DEBUG = True -else: - CHIRP_DEBUG = False +LOG = logging.getLogger(__name__)
MEM_FORMAT = """ #seekto 0x7F52; @@ -410,9 +407,8 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio): return VX2BankModel(self)
def _decode_chars(self, inarr): - if CHIRP_DEBUG: - print "@_decode_chars, type: %s" % type(inarr) - print inarr + LOG.debug("@_decode_chars, type: %s" % type(inarr)) + LOG.debug(inarr) outstr = "" for i in inarr: if i == 0xFF: @@ -421,9 +417,8 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio): return outstr.rstrip()
def _encode_chars(self, instr, length = 16): - if CHIRP_DEBUG: - print "@_encode_chars, type: %s" % type(instr) - print instr + LOG.debug("@_encode_chars, type: %s" % type(instr)) + LOG.debug(instr) outarr = [] instr = str(instr) for i in range(0, length): @@ -648,8 +643,7 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio): for c in dtmfsetting.digits: if c < len(DTMFCHARSET): dtmfstr += DTMFCHARSET[c] - if CHIRP_DEBUG: - print dtmfstr + LOG.debug(dtmfstr) dtmfentry = RadioSettingValueString(0, 16, dtmfstr) dtmfentry.set_charset(DTMFCHARSET + list(" ")) rs = RadioSetting(name, name.upper(), dtmfentry) @@ -676,8 +670,7 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio): newval.append(DTMFCHARSET.index(dtmfstr[i])) else: newval.append(0xFF) - if CHIRP_DEBUG: - print newval + LOG.debug(newval) idx = int(setting[-1:]) - 1 _settings = self._memobj.dtmf[idx] _settings.digits = newval @@ -698,12 +691,10 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio): newval = self._encode_chars(newval) if setting == "openmsg": newval = self._encode_chars(newval, 6) - if CHIRP_DEBUG: - print "Setting %s(%s) <= %s" % (setting, - oldval, newval) + LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval)) setattr(_settings, setting, newval) except Exception, e: print element.get_name() raise
- \ No newline at end of file + diff --git a/chirp/vx3.py b/chirp/vx3.py index 99d0951..0575a46 100644 --- a/chirp/vx3.py +++ b/chirp/vx3.py @@ -21,7 +21,9 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettingValueString, \ RadioSettings from textwrap import dedent -import os, re +import os, re, logging + +LOG = logging.getLogger(__name__)
#interesting offsets which may be checksums needed later #0x0393 checksum1? @@ -29,11 +31,6 @@ import os, re #0x0409 checksum2? #0x04C9 checksum2a?
-if os.getenv("CHIRP_DEBUG"): - CHIRP_DEBUG = True -else: - CHIRP_DEBUG = False - MEM_FORMAT = """ #seekto 0x7F4A; u8 checksum; @@ -499,9 +496,8 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): return VX3BankModel(self)
def _decode_chars(self, inarr): - if CHIRP_DEBUG: - print "@_decode_chars, type: %s" % type(inarr) - print inarr + LOG.debug("@_decode_chars, type: %s" % type(inarr)) + LOG.debug(inarr) outstr = "" for i in inarr: if i == 0xFF: @@ -510,9 +506,8 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): return outstr.rstrip()
def _encode_chars(self, instr, length = 16): - if CHIRP_DEBUG: - print "@_encode_chars, type: %s" % type(instr) - print instr + LOG.debug("@_encode_chars, type: %s" % type(instr)) + LOG.debug(instr) outarr = [] instr = str(instr) for i in range(length): @@ -785,8 +780,7 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): for c in dtmfsetting.memory: if c < len(DTMFCHARSET): dtmfstr += DTMFCHARSET[c] - if CHIRP_DEBUG: - print dtmfstr + LOG.debug(dtmfstr) dtmfentry = RadioSettingValueString(0, 16, dtmfstr) dtmfentry.set_charset(DTMFCHARSET + list(" ")) rs = RadioSetting(name, name.upper(), dtmfentry) @@ -861,8 +855,7 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): newval.append(DTMFCHARSET.index(dtmfstr[i])) else: newval.append(0xFF) - if CHIRP_DEBUG: - print newval + LOG.debug(newval) idx = int(setting[-1:]) _settings = self._memobj.dtmf[idx] _settings.memory = newval @@ -885,11 +878,9 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio): newval = self._encode_chars(newval) if setting == "openmsg": newval = self._encode_chars(newval, 6) - if CHIRP_DEBUG: - print "Setting %s(%s) <= %s" % (setting, - oldval, newval) + LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval)) setattr(_settings, setting, newval) except Exception, e: print element.get_name() raise - \ No newline at end of file + diff --git a/chirp/vx8.py b/chirp/vx8.py index 02490a1..45fff7a 100644 --- a/chirp/vx8.py +++ b/chirp/vx8.py @@ -15,6 +15,7 @@
import os import re +import logging
from chirp import chirp_common, yaesu_clone, directory from chirp import bitwise @@ -23,6 +24,8 @@ from chirp.settings import RadioSettingValueInteger, RadioSettingValueString from chirp.settings import RadioSettingValueList, RadioSettingValueBoolean from textwrap import dedent
+LOG = logging.getLogger(__name__) + MEM_FORMAT = """ #seekto 0x047f; struct { @@ -1461,8 +1464,7 @@ class VX8DRadio(VX8Radio): is_latitude = name.endswith("latitude") lat_long = setting.value.get_value().strip() sign, l_d, l_m, l_s = cls._str_to_latlong(lat_long, is_latitude) - if os.getenv("CHIRP_DEBUG"): - print "%s: %d %d %d %d" % (name, sign, l_d, l_m, l_s) + LOG.debug("%s: %d %d %d %d" % (name, sign, l_d, l_m, l_s)) setattr(obj, "%s_sign" % name, sign) setattr(obj, "%s_degree" % name, l_d) setattr(obj, "%s_minute" % name, l_m) @@ -1499,9 +1501,8 @@ class VX8DRadio(VX8Radio):
try: old_val = getattr(obj, setting) - if os.getenv("CHIRP_DEBUG"): - print "Setting %s(%r) <= %s" % ( - element.get_name(), old_val, element.value) + LOG.debug("Setting %s(%r) <= %s" % ( + element.get_name(), old_val, element.value)) setattr(obj, setting, element.value) except AttributeError as e: print "Setting %s is not in the memory map: %s" % ( diff --git a/chirp/wouxun.py b/chirp/wouxun.py index 6feec42..4a3dd0b 100644 --- a/chirp/wouxun.py +++ b/chirp/wouxun.py @@ -17,6 +17,7 @@
import time import os +import logging from chirp import util, chirp_common, bitwise, memmap, errors, directory from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettingValueList, \ @@ -25,6 +26,8 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ from chirp.wouxun_common import wipe_memory, do_download, do_upload from textwrap import dedent
+LOG = logging.getLogger(__name__) + FREQ_ENCODE_TABLE = [ 0x7, 0xa, 0x0, 0x9, 0xb, 0x2, 0xe, 0x1, 0x3, 0xf ]
def encode_freq(freq): @@ -717,9 +720,8 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, # always set it even if no dtcs is used mem.dtcs_polarity = "%s%s" % (tpol or "N", rpol or "N")
- if os.getenv("CHIRP_DEBUG"): - print "Got TX %s (%i) RX %s (%i)" % (txmode, _mem.tx_tone, - rxmode, _mem.rx_tone) + LOG.debug("Got TX %s (%i) RX %s (%i)" % (txmode, _mem.tx_tone, + rxmode, _mem.rx_tone))
def _is_txinh(self, _mem): raw_tx = "" @@ -817,9 +819,8 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, else: _mem.rx_tone = 0xFFFF
- if os.getenv("CHIRP_DEBUG"): - print "Set TX %s (%i) RX %s (%i)" % (tx_mode, _mem.tx_tone, - rx_mode, _mem.rx_tone) + LOG.debug("Set TX %s (%i) RX %s (%i)" % (tx_mode, _mem.tx_tone, + rx_mode, _mem.rx_tone))
def set_memory(self, mem): _mem = self._memobj.memory[mem.number - 1] diff --git a/chirp/wouxun_common.py b/chirp/wouxun_common.py index 3c78b3a..5b51e93 100644 --- a/chirp/wouxun_common.py +++ b/chirp/wouxun_common.py @@ -18,8 +18,11 @@
import struct import os +import logging from chirp import util, chirp_common, memmap
+LOG = logging.getLogger(__name__) + def wipe_memory(_mem, byte): """Cleanup a memory""" _mem.set_raw(byte * (_mem.size() / 8)) @@ -29,8 +32,7 @@ def do_download(radio, start, end, blocksize): image = "" for i in range(start, end, blocksize): cmd = struct.pack(">cHb", "R", i, blocksize) - if os.getenv("CHIRP_DEBUG"): - print util.hexprint(cmd) + LOG.debug(util.hexprint(cmd)) radio.pipe.write(cmd) length = len(cmd) + blocksize resp = radio.pipe.read(length) @@ -61,8 +63,7 @@ def do_upload(radio, start, end, blocksize): chunk = radio.get_mmap()[ptr:ptr+blocksize] ptr += blocksize radio.pipe.write(cmd + chunk) - if os.getenv("CHIRP_DEBUG"): - print util.hexprint(cmd + chunk) + LOG.debug(util.hexprint(cmd + chunk))
ack = radio.pipe.read(1) if not ack == "\x06": diff --git a/chirp/yaesu_clone.py b/chirp/yaesu_clone.py index 57958c3..e8ec732 100644 --- a/chirp/yaesu_clone.py +++ b/chirp/yaesu_clone.py @@ -16,9 +16,11 @@ CMD_ACK = 0x06
from chirp import chirp_common, util, memmap, errors -import time, os +import time, os, logging from textwrap import dedent
+LOG = logging.getLogger(__name__) + def _safe_read(pipe, count): buf = "" first = True @@ -49,8 +51,7 @@ def _chunk_read(pipe, count, status_fn): status.max = count status.cur = len(data) status_fn(status) - if os.getenv("CHIRP_DEBUG"): - print "Read %i/%i" % (len(data), count) + LOG.debug("Read %i/%i" % (len(data), count)) return data
def __clone_in(radio): @@ -91,8 +92,7 @@ def _chunk_write(pipe, data, status_fn, block): chunk = data[i:i+block] pipe.write(chunk) count += len(chunk) - if os.getenv("CHIRP_DEBUG"): - print "@_chunk_write, count: %i, blocksize: %i" % (count,block) + LOG.debug("@_chunk_write, count: %i, blocksize: %i" % (count,block)) time.sleep(delay)
status = chirp_common.Status() @@ -120,8 +120,7 @@ def __clone_out(radio): for block in radio._block_lengths: blocks += 1 if blocks != len(radio._block_lengths): - if os.getenv("CHIRP_DEBUG"): - print "Sending %i-%i" % (pos, pos+block) + LOG.debug("Sending %i-%i" % (pos, pos+block)) pipe.write(radio.get_mmap()[pos:pos+block]) buf = pipe.read(1) if buf and buf[0] != chr(CMD_ACK): diff --git a/chirpui/reporting.py b/chirpui/reporting.py index c48c6bb..efe18c1 100644 --- a/chirpui/reporting.py +++ b/chirpui/reporting.py @@ -28,16 +28,18 @@ import threading import os import time +import logging
from chirp import CHIRP_VERSION, platform
REPORT_URL = "http://chirp.danplanet.com/report/report.php?do_report" ENABLED = True -DEBUG = os.getenv("CHIRP_DEBUG") == "y" THREAD_SEM = threading.Semaphore(10) # Maximum number of outstanding threads LAST = 0 LAST_TYPE = None
+LOG = logging.getLogger(__name__) + try: # Don't let failure to import any of these modules cause trouble from chirpui import config @@ -45,18 +47,14 @@ try: except: ENABLED = False
-def debug(string): - if DEBUG: - print string - def should_report(): if not ENABLED: - debug("Not reporting due to recent failure") + LOG.debug("Not reporting due to recent failure") return False
conf = config.get() if conf.get_bool("no_report"): - debug("Reporting disabled") + LOG.debug("Reporting disabled") return False
return True @@ -70,7 +68,7 @@ def _report_model_usage(model, direction, success): model = "%s_%s" % (model.VENDOR, model.MODEL) data = "%s,%s,%s" % (model, direction, success)
- debug("Reporting model usage: %s" % data) + LOG.debug("Reporting model usage: %s" % data)
proxy = xmlrpclib.ServerProxy(REPORT_URL) id = proxy.report_stats(CHIRP_VERSION, @@ -84,7 +82,7 @@ def _report_model_usage(model, direction, success): def _report_exception(stack): global ENABLED
- debug("Reporting exception") + LOG.debug("Reporting exception")
proxy = xmlrpclib.ServerProxy(REPORT_URL) id = proxy.report_exception(CHIRP_VERSION, @@ -98,7 +96,7 @@ def _report_exception(stack): def _report_misc_error(module, data): global ENABLED
- debug("Reporting misc error with %s" % module) + LOG.debug("Reporting misc error with %s" % module)
proxy = xmlrpclib.ServerProxy(REPORT_URL) id = proxy.report_misc_error(CHIRP_VERSION, @@ -109,12 +107,12 @@ def _report_misc_error(module, data): return id != 0
def _check_for_updates(callback): - debug("Checking for updates") + LOG.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) + LOG.debug("Server reports version %s is latest" % ver) callback(ver) return True
@@ -128,7 +126,7 @@ class ReportThread(threading.Thread): try: return self.__func(*self.__args) except Exception, e: - debug("Failed to report: %s" % e) + LOG.debug("Failed to report: %s" % e) return False
def run(self): @@ -139,7 +137,7 @@ class ReportThread(threading.Thread): ENABLED = False elif (time.time() - start) > 15: # Reporting took too long - debug("Time to report was %.2f sec -- Disabling" % \ + LOG.debug("Time to report was %.2f sec -- Disabling" % \ (time.time()-start)) ENABLED = False
@@ -151,13 +149,13 @@ def dispatch_thread(func, *args):
# If reporting is disabled or failing, bail if not should_report(): - debug("Reporting is disabled") + LOG.debug("Reporting is disabled") return
# If the time between now and the last report is less than 5 seconds, bail delta = time.time() - LAST if delta < 5 and func == LAST_TYPE: - debug("Throttling...") + LOG.debug("Throttling...") return
LAST = time.time() @@ -165,7 +163,7 @@ def dispatch_thread(func, *args):
# If there are already too many threads running, bail if not THREAD_SEM.acquire(False): - debug("Too many threads already running") + LOG.debug("Too many threads already running") return
t = ReportThread(func, *args)
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 0ff5060e83985035b8ec82315c5372ba369db6c8
Suppress startup debugging messages (#2347)
This patch changes the verbose startup messages to use LOG.info calls. This change is required to make the CLI remotely usable, as it's unreasonable to print so much information in that context.
I kept this separate from the last patch, because I can imagine that this might impact the automated/buildbot testing. To avoid regressions, the previous output can be generated by setting 'CHIRP_DEBUG=info' in the environment.
diff --git a/chirp/directory.py b/chirp/directory.py index 5fc47e3..07308ee 100644 --- a/chirp/directory.py +++ b/chirp/directory.py @@ -16,10 +16,13 @@
import os import tempfile +import logging
from chirp import icf 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) @@ -47,12 +50,12 @@ def register(cls): ident = radio_class_id(cls) if ident in DRV_TO_RADIO.keys(): if ALLOW_DUPS: - print "Replacing existing driver id `%s'" % ident + LOG.warn("Replacing existing driver id `%s'" % ident) else: raise Exception("Duplicate radio driver id `%s'" % ident) DRV_TO_RADIO[ident] = cls RADIO_TO_DRV[cls] = ident - print "Registered %s = %s" % (ident, cls.__name__) + LOG.info("Registered %s = %s" % (ident, cls.__name__))
return cls
diff --git a/chirpui/mainapp.py b/chirpui/mainapp.py index d78d64e..e22196a 100644 --- a/chirpui/mainapp.py +++ b/chirpui/mainapp.py @@ -21,11 +21,14 @@ import webbrowser from glob import glob import shutil import time +import logging
import gtk import gobject gobject.threads_init()
+LOG = logging.getLogger(__name__) + if __name__ == "__main__": import sys sys.path.insert(0, "..") @@ -526,7 +529,7 @@ If you think that it is valid, you can select a radio model below to force an op files = glob(os.path.join(basepath, "*.csv")) for fn in files: if os.path.exists(os.path.join(stock_dir, os.path.basename(fn))): - print "Skipping existing stock config" + LOG.info("Skipping existing stock config") continue try: shutil.copy(fn, stock_dir)
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 3db4f1501a5afde03ce0fbfd6d3b45d54bee5818
Add pep8 checker script (#2355)
This patch adds a new script that runs the pep8 tool on the CHIRP source code files. This script is intended to be included in the repository pre-commit hook, preventing patches from causing style regressions.
The script checks a blacklist of files that are not yet compliant with the style standards, and those files will not be scanned (unless -a is given). Since no new files should ever be added to the blacklist, it should eventually shrink to empty, and the script will check the entire codebase.
The blacklist makes it safe to begin using this tool immediately, so this patch also adds a call to it from run_all_tests.sh.
diff --git a/run_all_tests.sh b/run_all_tests.sh index 48e20a4..2437d19 100755 --- a/run_all_tests.sh +++ b/run_all_tests.sh @@ -26,8 +26,15 @@ function style_tests() { ./tools/checkpatch.sh }
-TESTS="unit_tests driver_tests make_supported style_tests" -for testname in $TESTS; do +function pep8() { + echo "Checking for PEP8 regressions..." + time ./tools/cpep8.py --stats +} + +if test -z "${TESTS[*]}"; then + TESTS=( unit_tests driver_tests make_supported style_tests pep8 ) +fi +for testname in "${TESTS[@]}"; do eval "$testname" || record_failure "$testname" done
diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist new file mode 100644 index 0000000..e74c723 --- /dev/null +++ b/tools/cpep8.blacklist @@ -0,0 +1,137 @@ +# cpep8.blacklist: The list of files that do not meet PEP8 standards. +# DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. +# Over time, this list should shrink and (eventually) be eliminated. +./chirp/__init__.py +./chirp/alinco.py +./chirp/anytone.py +./chirp/ap510.py +./chirp/bandplan.py +./chirp/bandplan_au.py +./chirp/bandplan_iaru_r1.py +./chirp/bandplan_iaru_r2.py +./chirp/bandplan_iaru_r3.py +./chirp/bandplan_na.py +./chirp/baofeng_uv3r.py +./chirp/bitwise.py +./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 +./chirp/ft1d.py +./chirp/ft2800.py +./chirp/ft50.py +./chirp/ft50_ll.py +./chirp/ft60.py +./chirp/ft7800.py +./chirp/ft817.py +./chirp/ft857.py +./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 +./chirp/ic2200.py +./chirp/ic2720.py +./chirp/ic2820.py +./chirp/ic9x.py +./chirp/ic9x_icf.py +./chirp/ic9x_icf_ll.py +./chirp/ic9x_ll.py +./chirp/icf.py +./chirp/icomciv.py +./chirp/icq7.py +./chirp/ict70.py +./chirp/ict8.py +./chirp/icw32.py +./chirp/icx8x.py +./chirp/icx8x_ll.py +./chirp/id31.py +./chirp/id800.py +./chirp/id880.py +./chirp/idrp.py +./chirp/import_logic.py +./chirp/kenwood_hmk.py +./chirp/kenwood_itm.py +./chirp/kenwood_live.py +./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 +./chirp/th_uvf8d.py +./chirp/thd72.py +./chirp/thuv1f.py +./chirp/tk8102.py +./chirp/tmv71.py +./chirp/tmv71_ll.py +./chirp/util.py +./chirp/uv5r.py +./chirp/uvb5.py +./chirp/vx170.py +./chirp/vx2.py +./chirp/vx3.py +./chirp/vx5.py +./chirp/vx510.py +./chirp/vx6.py +./chirp/vx7.py +./chirp/vx8.py +./chirp/vxa700.py +./chirp/wouxun.py +./chirp/wouxun_common.py +./chirp/xml_ll.py +./chirp/yaesu_clone.py +./chirpc +./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 +./chirpui/miscwidgets.py +./chirpui/radiobrowser.py +./chirpui/reporting.py +./chirpui/settingsedit.py +./chirpui/shiftdialog.py +./chirpw +./csvdump/__init__.py +./csvdump/csvapp.py +./csvdump/csvdump.py +./locale/check_parameters.py +./rpttool +./setup.py +./share/make_supported.py +./tests/run_tests +./tests/unit/base.py +./tests/unit/test_bitwise.py +./tests/unit/test_chirp_common.py +./tests/unit/test_import_logic.py +./tests/unit/test_mappingmodel.py +./tests/unit/test_memedit_edits.py +./tests/unit/test_platform.py +./tests/unit/test_settings.py +./tests/unit/test_shiftdialog.py +./tools/bitdiff.py +./tools/img2thd72.py diff --git a/tools/cpep8.manifest b/tools/cpep8.manifest new file mode 100644 index 0000000..2fe9d77 --- /dev/null +++ b/tools/cpep8.manifest @@ -0,0 +1,4 @@ +./chirpc +./chirpw +./rpttool +./tests/run_tests diff --git a/tools/cpep8.py b/tools/cpep8.py new file mode 100755 index 0000000..efaca7a --- /dev/null +++ b/tools/cpep8.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python +# +# cpep8.py - Check Python source files for PEP8 compliance. +# +# Copyright 2015 Zachary T Welch zach@mandolincreekfarm.com +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. + +import os +import sys +import logging +import argparse +import pep8 + +scriptdir = os.path.dirname(sys.argv[0]) + +parser = argparse.ArgumentParser() +parser.add_argument("-a", "--all", action="store_true", + help="Check all files, ignoring blacklist") +parser.add_argument("-d", "--dir", action="store", default=".", + help="Root directory of source tree") +parser.add_argument("-s", "--stats", action="store_true", + help="Only show statistics") +parser.add_argument("-u", "--update", action="store_true", + help="Update the blacklist file") +parser.add_argument("-v", "--verbose", action="store_true", + help="Display list of checked files") +parser.add_argument("files", metavar="file", nargs='*', + help="List of files to check (if none, check all)") +args = parser.parse_args() + + +def file_to_lines(name): + fh = file(name, "r") + lines = fh.read().split("\n") + lines.pop() + fh.close() + return lines + +# read manifest and search for python files +manifest = file_to_lines(os.path.join(scriptdir, "cpep8.manifest")) +for root, dirs, files in os.walk(args.dir): + for f in files: + if f.endswith('.py'): + manifest.append(os.path.join(root, f)) + +# read the blacklisted source files +blacklist_filename = os.path.join(scriptdir, "cpep8.blacklist") +blacklist = file_to_lines(blacklist_filename) + +if args.update: + bad = [] + for f in manifest: + checker = pep8.StyleGuide(quiet=True) + results = checker.check_files([f]) + if results.total_errors: + bad.append(f) + with file(blacklist_filename, "w") as fh: + print >>fh, """\ +# cpep8.blacklist: The list of files that do not meet PEP8 standards. +# DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. +# Over time, this list should shrink and (eventually) be eliminated.""" + print >>fh, "\n".join(sorted(bad)) + sys.exit(0) + +if args.files: + manifest = args.files + +check_list = [] +for f in manifest: + if args.all or f not in blacklist: + check_list.append(f) +check_list = sorted(check_list) + +if args.verbose: + print "Checking the following files:\n", "\n".join(check_list) + +checker = pep8.StyleGuide(quiet=args.stats) +results = checker.check_files(check_list) +if args.stats: + results.print_statistics() + +sys.exit(results.total_errors and 1 or 0)
# Fake Node ID 3db4f1501a5afde03ce0fbfd6d3b45d54bee5818
Thanks for this.
+import pep8
I think this is the better way. Unfortunately, it does require a newer version of pep8 than people might have on their systems.
+checker = pep8.StyleGuide(quiet=args.stats)
Fails for me here, with StyleGuide have been missing from the pep8 0.6.1 I had on my system. You might just put a try...except around this and print a helpful message about why. Maybe around the import line as well for people (like windows folk) that won't have *anything* on their systems unless they add it.
--Dan
On 02/27/2015 03:53 PM, Dan Smith wrote:
# Fake Node ID 3db4f1501a5afde03ce0fbfd6d3b45d54bee5818
Thanks for this.
+import pep8
I think this is the better way. Unfortunately, it does require a newer version of pep8 than people might have on their systems.
+checker = pep8.StyleGuide(quiet=args.stats)
Fails for me here, with StyleGuide have been missing from the pep8 0.6.1 I had on my system. You might just put a try...except around this and print a helpful message about why. Maybe around the import line as well for people (like windows folk) that won't have *anything* on their systems unless they add it.
As discussed on IRC, the problems seen on the buildbot were caused by differences in the version of pep8; I've been using 1.4.6 from stock Ubuntu, and the buildbot has 1.6.2 (from pip). Dan just committed a patch to use virtualenv to make it work for everyone using 1.4.6. I will look at moving to 1.6.2, as it obviously catches more style issues than 1.4.6.
His patch also removed --stats from the run_all_tests.sh call. That ensures that the cpep.py script emits the file:line information required to fix the issues that it sees.
Can't seem to get this to run; gives me some warnings on Windows (and then runs) and does not run on Ubunutu. Reverting the virtualenv work-around got it running again; so something must be amiss with my version.
FWIW, here is a dump of my versions:
On Windows:
$ pep8 --version 1.4.6
On Ubunutu:
$ pep8 --version 1.6.2
Also, as of today I counted 5673 errors reported by pep8. Below is a dump of the stats just to be clear on the actual error codes. May I offer a suggestion that we ease into these checks? Possibly, by begining to filter the most offensive errors at first and as we clear those up introduce more strict requirements? ie: maybe omit all whitespace errors to begin with...
106 E101 indentation contains mixed spaces and tabs 256 E111 indentation is not a multiple of four 460 E121 continuation line indentation is not a multiple of four 25 E122 continuation line missing indentation or outdented 6 E124 closing bracket does not match visual indentation 8 E125 continuation line does not distinguish itself from next logical lin e 71 E126 continuation line over-indented for hanging indent 100 E127 continuation line over-indented for visual indent 885 E128 continuation line under-indented for visual indent 462 E201 whitespace after '[' 201 E202 whitespace before ')' 438 E203 whitespace before ':' 8 E211 whitespace before '[' 100 E221 multiple spaces before operator 12 E222 multiple spaces after operator 14 E225 missing whitespace around operator 1 E227 missing whitespace around bitwise or shift operator 1 E228 missing whitespace around modulo operator 213 E231 missing whitespace after ',' 47 E251 unexpected spaces around keyword / parameter equals 129 E261 at least two spaces before inline comment 227 E262 inline comment should start with '# ' 1 E271 multiple spaces after keyword 50 E301 expected 1 blank line, found 0 673 E302 expected 2 blank lines, found 1 41 E303 too many blank lines (2) 41 E401 multiple imports on one line 307 E501 line too long (93> 79 characters) 88 E502 the backslash is redundant between brackets 12 E701 multiple statements on one line (colon) 11 E703 statement ends with a semicolon 3 E711 comparison to None should be 'if cond is not None:' 3 E712 comparison to True should be 'if cond is True:' or 'if cond:' 2 E721 do not compare types, use 'isinstance()' 114 W191 indentation contains tabs 189 W291 trailing whitespace 334 W293 blank line contains whitespace 21 W391 blank line at end of file 11 W601 .has_key() is deprecated, use 'in' ================================================
----------------------------------------
Date: Fri, 27 Feb 2015 17:29:35 -0800 From: zach@mandolincreekfarm.com To: chirp_devel@intrepid.danplanet.com Subject: Re: [chirp_devel] [PATCH 04/12] Add pep8 checker script (#2355)
On 02/27/2015 03:53 PM, Dan Smith wrote:
# Fake Node ID 3db4f1501a5afde03ce0fbfd6d3b45d54bee5818
Thanks for this.
+import pep8
I think this is the better way. Unfortunately, it does require a newer version of pep8 than people might have on their systems.
+checker = pep8.StyleGuide(quiet=args.stats)
Fails for me here, with StyleGuide have been missing from the pep8 0.6.1 I had on my system. You might just put a try...except around this and print a helpful message about why. Maybe around the import line as well for people (like windows folk) that won't have *anything* on their systems unless they add it.
As discussed on IRC, the problems seen on the buildbot were caused by differences in the version of pep8; I've been using 1.4.6 from stock Ubuntu, and the buildbot has 1.6.2 (from pip). Dan just committed a patch to use virtualenv to make it work for everyone using 1.4.6. I will look at moving to 1.6.2, as it obviously catches more style issues than 1.4.6.
His patch also removed --stats from the run_all_tests.sh call. That ensures that the cpep.py script emits the file:line information required to fix the issues that it sees.
-- Zach Welch Mandolin Creek Farm www.mandolincreekfarm.com farm: 541-453-4131 cell: 541-740-3410 _______________________________________________ chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel Developer docs: http://chirp.danplanet.com/projects/chirp/wiki/Developers
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 07893d7a7e5dd2475726926610819ae29f44c8e3
Fix style issues (1/4) (#2355)
This patch contains whitespace-only changes that eliminate all of the PEP8 style warnings in the CLI and GUI scripts.
diff --git a/chirpc b/chirpc index 16c7006..4981374 100755 --- a/chirpc +++ b/chirpc @@ -26,16 +26,18 @@ from chirp import * from chirp import chirp_common, errors, idrp, directory, util
LOG = logging.getLogger("chirpc") +RADIOS = directory.DRV_TO_RADIO +
def fail_unsupported(): print "Operation not supported by selected radio" sys.exit(1)
+ def fail_missing_mmap(): print "mmap-only operation requires specification of an mmap file" sys.exit(1)
-RADIOS = directory.DRV_TO_RADIO
class ToneAction(argparse.Action): # def __init__(self, **kwargs): @@ -46,6 +48,7 @@ class ToneAction(argparse.Action): raise argparse.ArgumentError("Invalid tone valeu: %.1f" % value) setattr(namespace, self.dest, value)
+ class DTCSAction(argparse.Action): def __call__(self, parser, namespace, value, option_string=None): try: @@ -57,6 +60,7 @@ class DTCSAction(argparse.Action): raise argparse.ArgumentError("Invalid DTCS value: %03i" % value) setattr(namespace, self.dest, value)
+ class DTCSPolarityAction(argparse.Action): def __call__(self, parser, namespace, value, option_string=None): if value not in ["NN", "RN", "NR", "RR"]: @@ -65,251 +69,244 @@ class DTCSPolarityAction(argparse.Action):
if __name__ == "__main__": - parser = argparse.ArgumentParser() - logger.add_version_argument(parser) - parser.add_argument("-s", "--serial", dest="serial", - default="mmap", - help="Serial port (default: mmap)") - - parser.add_argument("-i", "--id", dest="id", - default=False, - action="store_true", - help="Request radio ID string") - parser.add_argument("--raw", dest="raw", - default=False, - action="store_true", - help="Dump raw memory location") - - parser.add_argument("--get-mem", dest="get_mem", - default=False, - action="store_true", - help="Get and print memory location") - parser.add_argument("--set-mem-name", dest="set_mem_name", - default=None, - help="Set memory name") - parser.add_argument("--set-mem-freq", dest="set_mem_freq", - type=float, - default=None, - help="Set memory frequency") - - parser.add_argument("--set-mem-tencon", dest="set_mem_tencon", - default=False, - action="store_true", - help="Set tone encode enabled flag") - parser.add_argument("--set-mem-tencoff", dest="set_mem_tencoff", - default=False, - action="store_true", - help="Set tone decode disabled flag") - parser.add_argument("--set-mem-tsqlon", dest="set_mem_tsqlon", - default=False, - action="store_true", - help="Set tone squelch enabled flag") - parser.add_argument("--set-mem-tsqloff", dest="set_mem_tsqloff", - default=False, - action="store_true", - help="Set tone squelch disabled flag") - parser.add_argument("--set-mem-dtcson", dest="set_mem_dtcson", - default=False, - action="store_true", - help="Set DTCS enabled flag") - parser.add_argument("--set-mem-dtcsoff", dest="set_mem_dtcsoff", - default=False, - action="store_true", - help="Set DTCS disabled flag") - - parser.add_argument("--set-mem-tenc", dest="set_mem_tenc", - type=float, action=ToneAction, nargs=1, - help="Set memory encode tone") - parser.add_argument("--set-mem-tsql", dest="set_mem_tsql", - type=float, action=ToneAction, nargs=1, - help="Set memory squelch tone") - - parser.add_argument("--set-mem-dtcs", dest="set_mem_dtcs", - type=int, action=DTCSAction, nargs=1, - help="Set memory DTCS code") - parser.add_argument("--set-mem-dtcspol", dest="set_mem_dtcspol", - action=DTCSPolarityAction, nargs=1, - help="Set memory DTCS polarity (NN, NR, RN, RR)") - - parser.add_argument("--set-mem-dup", dest="set_mem_dup", - help="Set memory duplex (+,-, or blank)") - parser.add_argument("--set-mem-offset", dest="set_mem_offset", - type=float, - help="Set memory duplex offset (in MHz)") - - parser.add_argument("--set-mem-mode", dest="set_mem_mode", - default=None, - help="Set mode (%s)" % ",".join(chirp_common.MODES)) - parser.add_argument("-r", "--radio", dest="radio", - default=None, - help="Radio model (see --list-radios)") - parser.add_argument("--list-radios", action="store_true", - help="List radio models") - parser.add_argument("--mmap", dest="mmap", - default=None, - help="Radio memory map file location") - parser.add_argument("--download-mmap", dest="download_mmap", - action="store_true", - default=False, - help="Download memory map from radio") - parser.add_argument("--upload-mmap", dest="upload_mmap", - action="store_true", - default=False, - help="Upload memory map to radio") - logger.add_arguments(parser) - parser.add_argument("args", metavar="arg", nargs='*', - help="Some commands require additional arguments") - - if len(sys.argv) <= 1: - parser.print_help() - sys.exit(0) - - options = parser.parse_args() - args = options.args - - logger.handle_options(options) - - if options.list_radios: - print "Supported Radios:\n\t", "\n\t".join(sorted(RADIOS.keys())) - sys.exit(0) - - 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, - timeout=0.5) - - radio = rclass(s) - - if options.raw: - data = radio.get_raw_memory(int(args[0])) - for i in data: - if ord(i) > 0x7F: - print "Memory location %i (%i):\n%s" % (int(args[0]), - len(data), - util.hexprint(data)) - sys.exit(0) - print data - sys.exit(0) - - if options.set_mem_dup is not None: - if options.set_mem_dup != "+" and \ - options.set_mem_dup != "-" and \ - options.set_mem_dup != "": - print "Invalid duplex value `%s'" % options.set_mem_dup - print "Valid values are: '+', '-', ''" - sys.exit(1) - else: - _dup = options.set_mem_dup - else: - _dup = None - - if options.set_mem_mode: - print "Set mode: %s" % options.set_mem_mode - if options.set_mem_mode not in chirp_common.MODES: - print "Invalid mode `%s'" - sys.exit(1) - else: - _mode = options.set_mem_mode - else: - _mode = None - - if options.set_mem_name or options.set_mem_freq or \ - options.set_mem_tencon or options.set_mem_tencoff or \ - options.set_mem_tsqlon or options.set_mem_tsqloff or \ - options.set_mem_dtcson or options.set_mem_dtcsoff or \ - options.set_mem_tenc or options.set_mem_tsql or options.set_mem_dtcs or\ - options.set_mem_dup is not None or \ - options.set_mem_mode or options.set_mem_dtcspol or\ - options.set_mem_offset: - try: - mem = radio.get_memory(int(args[0])) - except errors.InvalidMemoryLocation: - mem = chirp_common.Memory() - mem.number = int(args[0]) - - mem.name = options.set_mem_name or mem.name - mem.freq = options.set_mem_freq or mem.freq - mem.rtone = options.set_mem_tenc or mem.rtone - mem.ctone = options.set_mem_tsql or mem.ctone - mem.dtcs = options.set_mem_dtcs or mem.dtcs - mem.dtcs_polarity = options.set_mem_dtcspol or mem.dtcs_polarity - if _dup is not None: - mem.duplex = _dup - mem.offset = options.set_mem_offset or mem.offset - mem.mode = _mode or mem.mode - - if options.set_mem_tencon: - mem.tencEnabled = True - elif options.set_mem_tencoff: - mem.tencEnabled = False - - if options.set_mem_tsqlon: - mem.tsqlEnabled = True - elif options.set_mem_tsqloff: - mem.tsqlEnabled = False - - if options.set_mem_dtcson: - mem.dtcsEnabled = True - elif options.set_mem_dtcsoff: - mem.dtcsEnabled = False - - radio.set_memory(mem) - - if options.get_mem: - try: - pos = int(args[0]) - except ValueError: - pos = args[0] - - try: - mem = radio.get_memory(pos) - except errors.InvalidMemoryLocation, e: - mem = chirp_common.Memory() - mem.number = pos - - print mem - - if options.download_mmap: - #isinstance(radio, chirp_common.IcomMmapRadio) or fail_unsupported() - radio.sync_in() - radio.save_mmap(options.mmap) - - if options.upload_mmap: - #isinstance(radio, chirp_common.IcomMmapRadio) or fail_unsupported() - radio.load_mmap(options.mmap) - if radio.sync_out(): - print "Clone successful" - else: - print "Clone failed" - - if options.mmap and isinstance(radio, chirp_common.CloneModeRadio): - radio.save_mmap(options.mmap) - + parser = argparse.ArgumentParser() + logger.add_version_argument(parser) + parser.add_argument("-s", "--serial", dest="serial", + default="mmap", + help="Serial port (default: mmap)") + + parser.add_argument("-i", "--id", dest="id", + default=False, + action="store_true", + help="Request radio ID string") + parser.add_argument("--raw", dest="raw", + default=False, + action="store_true", + help="Dump raw memory location") + + parser.add_argument("--get-mem", dest="get_mem", + default=False, + action="store_true", + help="Get and print memory location") + parser.add_argument("--set-mem-name", dest="set_mem_name", + default=None, + help="Set memory name") + parser.add_argument("--set-mem-freq", dest="set_mem_freq", + type=float, + default=None, + help="Set memory frequency") + + parser.add_argument("--set-mem-tencon", dest="set_mem_tencon", + default=False, + action="store_true", + help="Set tone encode enabled flag") + parser.add_argument("--set-mem-tencoff", dest="set_mem_tencoff", + default=False, + action="store_true", + help="Set tone decode disabled flag") + parser.add_argument("--set-mem-tsqlon", dest="set_mem_tsqlon", + default=False, + action="store_true", + help="Set tone squelch enabled flag") + parser.add_argument("--set-mem-tsqloff", dest="set_mem_tsqloff", + default=False, + action="store_true", + help="Set tone squelch disabled flag") + parser.add_argument("--set-mem-dtcson", dest="set_mem_dtcson", + default=False, + action="store_true", + help="Set DTCS enabled flag") + parser.add_argument("--set-mem-dtcsoff", dest="set_mem_dtcsoff", + default=False, + action="store_true", + help="Set DTCS disabled flag") + + parser.add_argument("--set-mem-tenc", dest="set_mem_tenc", + type=float, action=ToneAction, nargs=1, + help="Set memory encode tone") + parser.add_argument("--set-mem-tsql", dest="set_mem_tsql", + type=float, action=ToneAction, nargs=1, + help="Set memory squelch tone") + + parser.add_argument("--set-mem-dtcs", dest="set_mem_dtcs", + type=int, action=DTCSAction, nargs=1, + help="Set memory DTCS code") + parser.add_argument("--set-mem-dtcspol", dest="set_mem_dtcspol", + action=DTCSPolarityAction, nargs=1, + help="Set memory DTCS polarity (NN, NR, RN, RR)") + + parser.add_argument("--set-mem-dup", dest="set_mem_dup", + help="Set memory duplex (+,-, or blank)") + parser.add_argument("--set-mem-offset", dest="set_mem_offset", + type=float, + help="Set memory duplex offset (in MHz)") + + parser.add_argument("--set-mem-mode", dest="set_mem_mode", + default=None, + help="Set mode (%s)" % ",".join(chirp_common.MODES)) + parser.add_argument("-r", "--radio", dest="radio", + default=None, + help="Radio model (see --list-radios)") + parser.add_argument("--list-radios", action="store_true", + help="List radio models") + parser.add_argument("--mmap", dest="mmap", + default=None, + help="Radio memory map file location") + parser.add_argument("--download-mmap", dest="download_mmap", + action="store_true", + default=False, + help="Download memory map from radio") + parser.add_argument("--upload-mmap", dest="upload_mmap", + action="store_true", + default=False, + help="Upload memory map to radio") + logger.add_arguments(parser) + parser.add_argument("args", metavar="arg", nargs='*', + help="Some commands require additional arguments") + + if len(sys.argv) <= 1: + parser.print_help() + sys.exit(0) + + options = parser.parse_args() + args = options.args + + logger.handle_options(options) + + if options.list_radios: + print "Supported Radios:\n\t", "\n\t".join(sorted(RADIOS.keys())) + sys.exit(0) + + 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, + timeout=0.5) + + radio = rclass(s) + + if options.raw: + data = radio.get_raw_memory(int(args[0])) + for i in data: + if ord(i) > 0x7F: + print "Memory location %i (%i):\n%s" % (int(args[0]), + len(data), + util.hexprint(data)) + sys.exit(0) + print data + sys.exit(0) + + if options.set_mem_dup is not None: + if options.set_mem_dup != "+" and \ + options.set_mem_dup != "-" and \ + options.set_mem_dup != "": + print "Invalid duplex value `%s'" % options.set_mem_dup + print "Valid values are: '+', '-', ''" + sys.exit(1) + else: + _dup = options.set_mem_dup + else: + _dup = None + + if options.set_mem_mode: + print "Set mode: %s" % options.set_mem_mode + if options.set_mem_mode not in chirp_common.MODES: + print "Invalid mode `%s'" + sys.exit(1) + else: + _mode = options.set_mem_mode + else: + _mode = None + + if options.set_mem_name or options.set_mem_freq or \ + options.set_mem_tencon or options.set_mem_tencoff or \ + options.set_mem_tsqlon or options.set_mem_tsqloff or \ + options.set_mem_dtcson or options.set_mem_dtcsoff or \ + options.set_mem_tenc or options.set_mem_tsql or \ + options.set_mem_dtcs or options.set_mem_dup is not None or \ + options.set_mem_mode or options.set_mem_dtcspol or\ + options.set_mem_offset: + try: + mem = radio.get_memory(int(args[0])) + except errors.InvalidMemoryLocation: + mem = chirp_common.Memory() + mem.number = int(args[0]) + + mem.name = options.set_mem_name or mem.name + mem.freq = options.set_mem_freq or mem.freq + mem.rtone = options.set_mem_tenc or mem.rtone + mem.ctone = options.set_mem_tsql or mem.ctone + mem.dtcs = options.set_mem_dtcs or mem.dtcs + mem.dtcs_polarity = options.set_mem_dtcspol or mem.dtcs_polarity + if _dup is not None: + mem.duplex = _dup + mem.offset = options.set_mem_offset or mem.offset + mem.mode = _mode or mem.mode + + if options.set_mem_tencon: + mem.tencEnabled = True + elif options.set_mem_tencoff: + mem.tencEnabled = False + + if options.set_mem_tsqlon: + mem.tsqlEnabled = True + elif options.set_mem_tsqloff: + mem.tsqlEnabled = False + + if options.set_mem_dtcson: + mem.dtcsEnabled = True + elif options.set_mem_dtcsoff: + mem.dtcsEnabled = False + + radio.set_memory(mem) + + if options.get_mem: + try: + pos = int(args[0]) + except ValueError: + pos = args[0] + + try: + mem = radio.get_memory(pos) + except errors.InvalidMemoryLocation, e: + mem = chirp_common.Memory() + mem.number = pos + + print mem + + if options.download_mmap: + #isinstance(radio, chirp_common.IcomMmapRadio) or fail_unsupported() + radio.sync_in() + radio.save_mmap(options.mmap) + + if options.upload_mmap: + #isinstance(radio, chirp_common.IcomMmapRadio) or fail_unsupported() + radio.load_mmap(options.mmap) + if radio.sync_out(): + print "Clone successful" + else: + print "Clone failed" + + if options.mmap and isinstance(radio, chirp_common.CloneModeRadio): + radio.save_mmap(options.mmap) diff --git a/chirpw b/chirpw index 67c9ee0..073ef50 100755 --- a/chirpw +++ b/chirpw @@ -40,16 +40,16 @@ conf = config.get() manual_language = conf.get("language", "state") langs = [] if manual_language and manual_language != "Auto": - lang_codes = { "English" : "en_US", - "Polish" : "pl", - "Italian" : "it", - "Dutch" : "nl", - "German" : "de", - "Hungarian" : "hu", - "Russian" : "ru", - "Portuguese (BR)" : "pt_BR", - "French" : "fr", - } + lang_codes = {"English": "en_US", + "Polish": "pl", + "Italian": "it", + "Dutch": "nl", + "German": "de", + "Hungarian": "hu", + "Russian": "ru", + "Portuguese (BR)": "pt_BR", + "French": "fr", + } try: print lang_codes[manual_language] langs = [lang_codes[manual_language]] @@ -58,7 +58,7 @@ if manual_language and manual_language != "Auto": else: lc, encoding = locale.getdefaultlocale() if (lc): - langs = [lc] + langs = [lc] try: langs += os.getenv("LANG").split(":") except: @@ -79,6 +79,7 @@ lang = gettext.translation("CHIRP", localepath, languages=langs,
import gtk
+ # Python <2.6 does not have str.format(), which chirp uses to make translation # strings nicer. So, instead of installing the gettext standard "_()" function, # we can install our own, which returns a string of the following class, @@ -87,21 +88,22 @@ import gtk class CompatStr(str): def format(self, **kwargs): base = lang.gettext(self) - for k,v in kwargs.items(): + for k, v in kwargs.items(): base = base.replace("{%s}" % k, str(v)) return base
pyver = sys.version.split()[0]
-try : +try: vmaj, vmin, vrel = pyver.split(".", 3) -except : +except: vmaj, vmin = pyver.split(".", 2) vrel = 0
if int(vmaj) < 2 or int(vmin) < 6: # Python <2.6, emulate str.format() import __builtin__ + def lang_with_format(string): return CompatStr(string) __builtin__._ = lang_with_format @@ -131,7 +133,8 @@ for i in args.files: a.show()
if args.profile: - import cProfile, pstats + import cProfile + import pstats cProfile.run("gtk.main()", "chirpw.stats") p = pstats.Stats("chirpw.stats") p.sort_stats("cumulative").print_stats(10) diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index e74c723..1aad90b 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -96,7 +96,6 @@ ./chirp/wouxun_common.py ./chirp/xml_ll.py ./chirp/yaesu_clone.py -./chirpc ./chirpui/bankedit.py ./chirpui/clone.py ./chirpui/cloneprog.py @@ -115,7 +114,6 @@ ./chirpui/reporting.py ./chirpui/settingsedit.py ./chirpui/shiftdialog.py -./chirpw ./csvdump/__init__.py ./csvdump/csvapp.py ./csvdump/csvdump.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 7434dd966941f72b17ceedc67717095e01756bbd
Fix style issues (2/4) (#2355)
This patch fixes the style in a handful of files and removes them from pep8.blacklist.
diff --git a/chirp/bandplan.py b/chirp/bandplan.py index f2b8541..97f2425 100644 --- a/chirp/bandplan.py +++ b/chirp/bandplan.py @@ -15,6 +15,7 @@
from chirp import chirp_common
+ class Band(object): def __init__(self, limits, name, mode=None, step_khz=None, input_offset=None, output_offset=None, tones=None): @@ -79,6 +80,6 @@ class Band(object): self.step_khz and 'step_khz: %s ' % (self.step_khz,) or '', self.offset and 'offset: %s ' % (self.offset,) or '', self.tones and 'tones: %s ' % (self.tones,) or '') - + return "%s-%s %s %s %s" % ( self.limits[0], self.limits[1], self.name, self.duplex, desc) diff --git a/csvdump/__init__.py b/csvdump/__init__.py index 833c0c7..e418fca 100644 --- a/csvdump/__init__.py +++ b/csvdump/__init__.py @@ -14,4 +14,3 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. - diff --git a/locale/check_parameters.py b/locale/check_parameters.py index 431faec..f0f3d51 100755 --- a/locale/check_parameters.py +++ b/locale/check_parameters.py @@ -15,16 +15,17 @@ for name, po in pos.iteritems(): if len(entry.msgstr) > 0: try: ids = [field_name - for literal_text, field_name, format_spec, conversion - in formatter.parse(entry.msgid)] + for literal_text, field_name, format_spec, conversion + in formatter.parse(entry.msgid)] tids = [field_name - for literal_text, field_name, format_spec, conversion - in formatter.parse(entry.msgstr)] + for literal_text, field_name, format_spec, conversion + in formatter.parse(entry.msgstr)] except Exception as e: print "Got exception!", e, "for entry", entry.msgid else: - if tids != None: + if tids is not None: missing = [name for name in tids - if name is not None and name not in ids] + if name is not None and name not in ids] if len(missing) > 0: - print "Missing parameters", missing, "in translation of", entry.msgid + print "Missing parameters", missing, \ + "in translation of", entry.msgid diff --git a/tests/unit/base.py b/tests/unit/base.py index 47d16d4..ee6884c 100644 --- a/tests/unit/base.py +++ b/tests/unit/base.py @@ -4,6 +4,7 @@ import mox import warnings warnings.simplefilter('ignore', Warning)
+ class BaseTest(unittest.TestCase): def setUp(self): __builtins__['_'] = lambda s: s diff --git a/tests/unit/test_bitwise.py b/tests/unit/test_bitwise.py index 611836f..aabc7b3 100644 --- a/tests/unit/test_bitwise.py +++ b/tests/unit/test_bitwise.py @@ -18,6 +18,7 @@ import unittest from chirp import bitwise from chirp import memmap
+ class BaseTest(unittest.TestCase): def _compare_structure(self, obj, primitive): for key, value in primitive.iteritems(): @@ -26,6 +27,7 @@ class BaseTest(unittest.TestCase): else: self.assertEqual(type(value)(getattr(obj, key)), value)
+ class TestBitwiseBaseIntTypes(BaseTest): def _test_type(self, datatype, _data, value): data = memmap.MemoryMap(_data) @@ -78,6 +80,7 @@ class TestBitwiseBaseIntTypes(BaseTest): obj.foo[i] = i * 2 self.assertEqual('\x00\x02\x04\x06', data.get_packed())
+ class TestBitfieldTypes(BaseTest): def test_bitfield_u8(self): defn = "u8 foo:4, bar:4;" @@ -139,6 +142,7 @@ class TestBitfieldTypes(BaseTest): def test_bitfield_ul24(self): self._test_bitfield_24("l", "\xC2\x40\x00")
+ class TestBitType(BaseTest): def test_bit_array(self): defn = "bit foo[24];" @@ -153,6 +157,7 @@ class TestBitType(BaseTest): def test_bit_array_fail(self): self.assertRaises(ValueError, bitwise.parse, "bit foo[23];", "000")
+ class TestBitwiseBCDTypes(BaseTest): def _test_def(self, definition, name, _data, value): data = memmap.MemoryMap(_data) @@ -181,6 +186,7 @@ class TestBitwiseBCDTypes(BaseTest): def test_lbcd_array(self): self._test_def("lbcd foo[2];", "foo", "\x12\x34", 3412)
+ class TestBitwiseCharTypes(BaseTest): def test_char(self): data = memmap.MemoryMap("c") @@ -202,7 +208,6 @@ class TestBitwiseCharTypes(BaseTest): data = memmap.MemoryMap("\xFFoobar1") obj = bitwise.parse("struct {char foo[7];} bar;", data) self.assertIn('\xffoobar1', repr(obj.bar)) -
def test_string_wrong_length(self): data = memmap.MemoryMap("foobar") @@ -210,6 +215,7 @@ class TestBitwiseCharTypes(BaseTest): self.assertRaises(ValueError, setattr, obj, "foo", "bazfo") self.assertRaises(ValueError, setattr, obj, "foo", "bazfooo")
+ class TestBitwiseStructTypes(BaseTest): def _test_def(self, definition, data, primitive): obj = bitwise.parse(definition, data) @@ -218,12 +224,12 @@ class TestBitwiseStructTypes(BaseTest):
def test_struct_one_element(self): defn = "struct { u8 bar; } foo;" - value = {"foo" : {"bar": 128}} + value = {"foo": {"bar": 128}} self._test_def(defn, "\x80", value)
def test_struct_two_elements(self): defn = "struct { u8 bar; u16 baz; } foo;" - value = {"foo" : {"bar": 128, "baz": 256}} + value = {"foo": {"bar": 128, "baz": 256}} self._test_def(defn, "\x80\x01\x00", value)
def test_struct_writes(self): @@ -234,6 +240,7 @@ class TestBitwiseStructTypes(BaseTest): obj.foo.baz = 0x34 self.assertEqual(data.get_packed(), "\x12\x34")
+ class TestBitwiseSeek(BaseTest): def test_seekto(self): defn = "#seekto 4; char foo;" @@ -246,10 +253,12 @@ class TestBitwiseSeek(BaseTest): self.assertEqual(str(obj.foo), "A") self.assertEqual(str(obj.bar), "Z")
+ class TestBitwiseErrors(BaseTest): def test_missing_semicolon(self): self.assertRaises(SyntaxError, bitwise.parse, "u8 foo", "")
+ class TestBitwiseComments(BaseTest): def test_comment_inline_cppstyle(self): obj = bitwise.parse('u8 foo; // test', '\x10') diff --git a/tests/unit/test_chirp_common.py b/tests/unit/test_chirp_common.py index 1a75cbf..8393c40 100644 --- a/tests/unit/test_chirp_common.py +++ b/tests/unit/test_chirp_common.py @@ -2,6 +2,7 @@ from tests.unit import base from chirp import chirp_common from chirp import errors
+ class TestUtilityFunctions(base.BaseTest): def test_parse_freq_whole(self): self.assertEqual(chirp_common.parse_freq("146.520000"), 146520000) @@ -47,6 +48,7 @@ class TestUtilityFunctions(base.BaseTest): self.assertEqual(chirp_common.format_freq(1), "0.000001") self.assertEqual(chirp_common.format_freq(1250000000), "1250.000000")
+ class TestSplitTone(base.BaseTest): def _test_split_tone_decode(self, tx, rx, **vals): mem = chirp_common.Memory() @@ -184,6 +186,7 @@ class TestSplitTone(base.BaseTest): (('', None, None), ('Tone', 100.0, None)))
+ class TestStepFunctions(base.BaseTest): _625 = [145856250, 445856250, diff --git a/tests/unit/test_mappingmodel.py b/tests/unit/test_mappingmodel.py index 5a3c706..7ccbc86 100644 --- a/tests/unit/test_mappingmodel.py +++ b/tests/unit/test_mappingmodel.py @@ -17,6 +17,7 @@ from tests.unit import base from chirp import chirp_common from chirp import icf
+ class TestBaseMapping(base.BaseTest): CLS = chirp_common.MemoryMapping
@@ -37,9 +38,11 @@ class TestBaseMapping(base.BaseTest): self.assertEqual(mapping1, mapping2) self.assertNotEqual(mapping1, mapping3)
+ class TestBaseBank(TestBaseMapping): CLS = chirp_common.Bank
+ class _TestBaseClass(base.BaseTest): ARGS = tuple()
@@ -51,6 +54,7 @@ class _TestBaseClass(base.BaseTest): self.assertRaises(NotImplementedError, getattr(self.model, method), *args)
+ class TestBaseMappingModel(_TestBaseClass): CLS = chirp_common.MappingModel ARGS = tuple([None, 'Foo']) @@ -69,6 +73,7 @@ class TestBaseMappingModel(_TestBaseClass): def test_get_name(self): self.assertEqual(self.model.get_name(), 'Foo')
+ class TestBaseBankModel(TestBaseMappingModel): ARGS = tuple([None]) CLS = chirp_common.BankModel @@ -76,6 +81,7 @@ class TestBaseBankModel(TestBaseMappingModel): def test_get_name(self): self.assertEqual(self.model.get_name(), 'Banks')
+ class TestBaseMappingModelIndexInterface(_TestBaseClass): CLS = chirp_common.MappingModelIndexInterface
@@ -88,12 +94,14 @@ class TestBaseMappingModelIndexInterface(_TestBaseClass): for method, args in methods: self._test_base(method, *args)
+ class TestIcomBanks(TestBaseMapping): def test_icom_bank(self): bank = icf.IcomBank(None, 1, 'Foo') # IcomBank has an index attribute used by IcomBankModel self.assertTrue(hasattr(bank, 'index'))
+ class TestIcomBankModel(base.BaseTest): CLS = icf.IcomBankModel
@@ -209,6 +217,7 @@ class TestIcomBankModel(base.BaseTest): self.assertEqual(self._model.get_memory_mappings(mem1)[0], banks[2]) self.assertEqual(self._model.get_memory_mappings(mem2), [])
+ class TestIcomIndexedBankModel(TestIcomBankModel): CLS = icf.IcomIndexedBankModel
diff --git a/tests/unit/test_platform.py b/tests/unit/test_platform.py index c69c743..2148499 100644 --- a/tests/unit/test_platform.py +++ b/tests/unit/test_platform.py @@ -20,6 +20,7 @@ import os from tests.unit import base from chirp import platform
+ class Win32PlatformTest(base.BaseTest): def _test_init(self): self.mox.StubOutWithMock(platform, 'comports') diff --git a/tests/unit/test_shiftdialog.py b/tests/unit/test_shiftdialog.py index 83a0370..46f83ce 100644 --- a/tests/unit/test_shiftdialog.py +++ b/tests/unit/test_shiftdialog.py @@ -6,6 +6,7 @@ from chirpui import shiftdialog from chirp import chirp_common from chirp import errors
+ class FakeRadio(object): def __init__(self, *memories): self._mems = {} @@ -44,6 +45,7 @@ class FakeRadioThread(object): def unlock(self): pass
+ class ShiftDialogTest(base.BaseTest): def _test_hole(self, fn, starting, arg, expected): radio = FakeRadio(*tuple(starting)) diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 1aad90b..5e8f29b 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -5,7 +5,6 @@ ./chirp/alinco.py ./chirp/anytone.py ./chirp/ap510.py -./chirp/bandplan.py ./chirp/bandplan_au.py ./chirp/bandplan_iaru_r1.py ./chirp/bandplan_iaru_r2.py @@ -114,22 +113,14 @@ ./chirpui/reporting.py ./chirpui/settingsedit.py ./chirpui/shiftdialog.py -./csvdump/__init__.py ./csvdump/csvapp.py ./csvdump/csvdump.py -./locale/check_parameters.py ./rpttool ./setup.py ./share/make_supported.py ./tests/run_tests -./tests/unit/base.py -./tests/unit/test_bitwise.py -./tests/unit/test_chirp_common.py ./tests/unit/test_import_logic.py -./tests/unit/test_mappingmodel.py ./tests/unit/test_memedit_edits.py -./tests/unit/test_platform.py ./tests/unit/test_settings.py -./tests/unit/test_shiftdialog.py ./tools/bitdiff.py ./tools/img2thd72.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 48fa93c24c4b0bea112d995d8a0a03abc3f1e1e6
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".
diff --git a/chirp/detect.py b/chirp/detect.py index eeefb32..580670f 100644 --- a/chirp/detect.py +++ b/chirp/detect.py @@ -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, } diff --git a/chirp/directory.py b/chirp/directory.py index 07308ee..7b529e6 100644 --- a/chirp/directory.py +++ b/chirp/directory.py @@ -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) diff --git a/chirp/generic_tpe.py b/chirp/generic_tpe.py index f720c0f..a1f0bf6 100644 --- a/chirp/generic_tpe.py +++ b/chirp/generic_tpe.py @@ -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"), }
diff --git a/chirp/generic_xml.py b/chirp/generic_xml.py index 1153c63..b8aec0a 100644 --- a/chirp/generic_xml.py +++ b/chirp/generic_xml.py @@ -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)
diff --git a/chirp/memmap.py b/chirp/memmap.py index 2230265..73285bf 100644 --- a/chirp/memmap.py +++ b/chirp/memmap.py @@ -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""" diff --git a/chirp/radioreference.py b/chirp/radioreference.py index 9ca54aa..e7bae27 100644 --- a/chirp/radioreference.py +++ b/chirp/radioreference.py @@ -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: diff --git a/chirp/template.py b/chirp/template.py index d01dbea..1477629 100644 --- a/chirp/template.py +++ b/chirp/template.py @@ -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 - diff --git a/chirp/util.py b/chirp/util.py index 8567c45..1fc5529 100644 --- a/chirp/util.py +++ b/chirp/util.py @@ -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 = {} diff --git a/chirpui/clone.py b/chirpui/clone.py index 7210d4a..e9443b0 100644 --- a/chirpui/clone.py +++ b/chirpui/clone.py @@ -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() diff --git a/chirpui/cloneprog.py b/chirpui/cloneprog.py index 7427bd2..99beea9 100644 --- a/chirpui/cloneprog.py +++ b/chirpui/cloneprog.py @@ -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() diff --git a/chirpui/config.py b/chirpui/config.py index d7b0337..29a4bf2 100644 --- a/chirpui/config.py +++ b/chirpui/config.py @@ -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
diff --git a/chirpui/dstaredit.py b/chirpui/dstaredit.py index df0baa8..75d05b1 100644 --- a/chirpui/dstaredit.py +++ b/chirpui/dstaredit.py @@ -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() diff --git a/chirpui/inputdialog.py b/chirpui/inputdialog.py index a5c2def..a276c2d 100644 --- a/chirpui/inputdialog.py +++ b/chirpui/inputdialog.py @@ -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, diff --git a/chirpui/shiftdialog.py b/chirpui/shiftdialog.py index 0ca50a4..e3f0454 100644 --- a/chirpui/shiftdialog.py +++ b/chirpui/shiftdialog.py @@ -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) diff --git a/rpttool b/rpttool index 5cf7540..60cc4c8 100755 --- a/rpttool +++ b/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" diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 5e8f29b..39b452f 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -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
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 2c6f7fe587c81205d06c1522f68246cf7299349e
Fix style issues (4/4) (#2355)
More low-hanging style issues.
diff --git a/chirp/bitwise_grammar.py b/chirp/bitwise_grammar.py index fe81b42..b6eb20c 100644 --- a/chirp/bitwise_grammar.py +++ b/chirp/bitwise_grammar.py @@ -21,63 +21,83 @@ TYPES = ["bit", "u8", "u16", "ul16", "u24", "ul24", "u32", "ul32", "lbcd", "bbcd"] DIRECTIVES = ["seekto", "seek", "printoffset"]
+ def string(): return re.compile(r""[^"]*"")
+ def symbol(): return re.compile(r"\w+")
+ def count(): return re.compile(r"([1-9][0-9]*|0x[0-9a-fA-F]+)")
+ def bitdef(): return symbol, ":", count, -1
+ def _bitdeflist(): return bitdef, -1, (",", bitdef)
+ def bitfield(): return -2, _bitdeflist
+ def array(): return symbol, '[', count, ']'
+ def _typedef(): return re.compile(r"(%s)" % "|".join(TYPES))
+ def definition(): return _typedef, [array, bitfield, symbol], ";"
+ def seekto(): return keyword("seekto"), count
+ def seek(): return keyword("seek"), count
+ def printoffset(): return keyword("printoffset"), string
+ def directive(): return "#", [seekto, seek, printoffset], ";"
+ def _block_inner(): return -2, [definition, struct, directive]
+ def _block(): return "{", _block_inner, "}"
+ def struct_defn(): return symbol, _block
+ def struct_decl(): return [symbol, _block], [array, symbol]
+ def struct(): return keyword("struct"), [struct_defn, struct_decl], ";"
+ def _language(): return _block_inner
+ def parse(data): lines = data.split("\n") for index, line in enumerate(lines): diff --git a/chirp/errors.py b/chirp/errors.py index 3fe1027..f4d9324 100644 --- a/chirp/errors.py +++ b/chirp/errors.py @@ -13,26 +13,32 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
+ class InvalidDataError(Exception): """The radio driver encountered some invalid data""" pass
+ class InvalidValueError(Exception): """An invalid value for a given parameter was used""" pass
+ class InvalidMemoryLocation(Exception): """The requested memory location does not exist""" pass
+ class RadioError(Exception): """An error occurred while talking to the radio""" pass
+ class UnsupportedToneError(Exception): """The radio does not support the specified tone value""" pass
+ class ImageDetectFailed(Exception): """The driver for the supplied image could not be determined""" pass diff --git a/chirp/generic_csv.py b/chirp/generic_csv.py index bf7ee1e..66a6005 100644 --- a/chirp/generic_csv.py +++ b/chirp/generic_csv.py @@ -18,10 +18,12 @@ import csv
from chirp import chirp_common, errors, directory
+ class OmittedHeaderError(Exception): """Internal exception to signal that a column has been omitted""" pass
+ def get_datum_by_header(headers, data, header): """Return the column corresponding to @headers[@header] from @data""" if header not in headers: @@ -30,8 +32,9 @@ def get_datum_by_header(headers, data, header): try: return data[headers.index(header)] except IndexError: - raise OmittedHeaderError("Header %s not provided on this line" % \ - header) + raise OmittedHeaderError("Header %s not provided on this line" % + header) +
def write_memory(writer, mem): """Write @mem using @writer if not empty""" @@ -39,6 +42,7 @@ def write_memory(writer, mem): return writer.writerow(mem.to_csv())
+ @directory.register class CSVRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport): """A driver for Generic CSV files""" @@ -47,23 +51,23 @@ class CSVRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport): FILE_EXTENSION = "csv"
ATTR_MAP = { - "Location" : (int, "number"), - "Name" : (str, "name"), - "Frequency" : (chirp_common.parse_freq, "freq"), - "Duplex" : (str, "duplex"), - "Offset" : (chirp_common.parse_freq, "offset"), - "Tone" : (str, "tmode"), - "rToneFreq" : (float, "rtone"), - "cToneFreq" : (float, "ctone"), - "DtcsCode" : (int, "dtcs"), - "DtcsPolarity" : (str, "dtcs_polarity"), - "Mode" : (str, "mode"), - "TStep" : (float, "tuning_step"), - "Skip" : (str, "skip"), - "URCALL" : (str, "dv_urcall"), - "RPT1CALL" : (str, "dv_rpt1call"), - "RPT2CALL" : (str, "dv_rpt2call"), - "Comment" : (str, "comment"), + "Location": (int, "number"), + "Name": (str, "name"), + "Frequency": (chirp_common.parse_freq, "freq"), + "Duplex": (str, "duplex"), + "Offset": (chirp_common.parse_freq, "offset"), + "Tone": (str, "tmode"), + "rToneFreq": (float, "rtone"), + "cToneFreq": (float, "ctone"), + "DtcsCode": (int, "dtcs"), + "DtcsPolarity": (str, "dtcs_polarity"), + "Mode": (str, "mode"), + "TStep": (float, "tuning_step"), + "Skip": (str, "skip"), + "URCALL": (str, "dv_urcall"), + "RPT1CALL": (str, "dv_rpt1call"), + "RPT2CALL": (str, "dv_rpt2call"), + "Comment": (str, "comment"), }
def _blank(self): @@ -118,7 +122,7 @@ class CSVRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport): fname = "_clean_%s" % attr if hasattr(self, fname): mem = getattr(self, fname)(headers, line, mem) - + return mem
def _clean_tmode(self, headers, line, mem): @@ -189,7 +193,8 @@ class CSVRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport): print "Line %i has %i columns, expected %i" % (lineno, len(line), len(header)) - self.errors.append("Column number mismatch on line %i" % lineno) + self.errors.append("Column number mismatch on line %i" % + lineno) continue
try: @@ -247,7 +252,7 @@ class CSVRadio(chirp_common.FileBackedRadio, chirp_common.IcomDstarSupport): return
delta += 1 - + for i in range(len(self.memories), len(self.memories) + delta + 1): mem = chirp_common.Memory() mem.empty = True @@ -313,7 +318,7 @@ class CommanderCSVRadio(CSVRadio): def _clean_duplex(self, headers, line, mem): try: txfreq = chirp_common.parse_freq( - get_datum_by_header(headers, line, "TX Freq")) + get_datum_by_header(headers, line, "TX Freq")) except ValueError: mem.duplex = "off" return mem @@ -325,7 +330,7 @@ class CommanderCSVRadio(CSVRadio): mem.offset = txfreq
return mem - + def _clean_tmode(self, headers, line, mem): rtone = get_datum_by_header(headers, line, "Encode") ctone = get_datum_by_header(headers, line, "Decode") @@ -356,7 +361,8 @@ class CommanderCSVRadio(CSVRadio): filedata.startswith("Name,RX Freq,TX Freq,Decode,Encode,TX Pwr," "Scan,TX Dev,Busy Lck,Group/Notes") or \ filedata.startswith('"#","Name","RX Freq","TX Freq","Decode",' - '"Encode","TX Pwr","Scan","TX Dev","Busy Lck","Group/Notes"') + '"Encode","TX Pwr","Scan","TX Dev",' + '"Busy Lck","Group/Notes"')
@directory.register @@ -372,7 +378,7 @@ class RTCSVRadio(CSVRadio): "Simplex": "", "Split": "split", } - + SKIP_MAP = { "Off": "", "On": "S", @@ -391,19 +397,25 @@ class RTCSVRadio(CSVRadio): }
ATTR_MAP = { - "Channel Number": (int, "number"), - "Receive Frequency":(chirp_common.parse_freq, "freq"), - "Offset Frequency": (chirp_common.parse_freq, "offset"), - "Offset Direction": (lambda v: RTCSVRadio.DUPLEX_MAP.get(v, v), "duplex"), - "Operating Mode": (str, "mode"), - "Name": (str, "name"), - "Tone Mode": (lambda v: RTCSVRadio.TMODE_MAP.get(v, v), "tmode"), - "CTCSS": (lambda v: float(v.split(" ")[0]), "rtone"), - "DCS": (int, "dtcs"), - "Skip": (lambda v: RTCSVRadio.SKIP_MAP.get(v, v), "skip"), - "Step": (lambda v: float(v.split(" ")[0]), "tuning_step"), - "Mask": (lambda v: RTCSVRadio.BOOL_MAP.get(v, v), "empty",), - "Comment": (str, "comment"), + "Channel Number": (int, "number"), + "Receive Frequency": (chirp_common.parse_freq, "freq"), + "Offset Frequency": (chirp_common.parse_freq, "offset"), + "Offset Direction": (lambda v: + RTCSVRadio.DUPLEX_MAP.get(v, v), "duplex"), + "Operating Mode": (str, "mode"), + "Name": (str, "name"), + "Tone Mode": (lambda v: + RTCSVRadio.TMODE_MAP.get(v, v), "tmode"), + "CTCSS": (lambda v: + float(v.split(" ")[0]), "rtone"), + "DCS": (int, "dtcs"), + "Skip": (lambda v: + RTCSVRadio.SKIP_MAP.get(v, v), "skip"), + "Step": (lambda v: + float(v.split(" ")[0]), "tuning_step"), + "Mask": (lambda v: + RTCSVRadio.BOOL_MAP.get(v, v), "empty",), + "Comment": (str, "comment"), }
def _clean_duplex(self, headers, line, mem): @@ -441,5 +453,6 @@ class RTCSVRadio(CSVRadio): # consistent across radio models. return filename.lower().endswith("." + cls.FILE_EXTENSION) and \ filedata.startswith("Channel Number,Receive Frequency," - "Transmit Frequency,Offset Frequency,Offset Direction," - "Operating Mode,Name,Tone Mode,CTCSS,DCS") + "Transmit Frequency,Offset Frequency," + "Offset Direction,Operating Mode," + "Name,Tone Mode,CTCSS,DCS") diff --git a/chirp/import_logic.py b/chirp/import_logic.py index b787378..04f81ba 100644 --- a/chirp/import_logic.py +++ b/chirp/import_logic.py @@ -15,14 +15,17 @@
from chirp import chirp_common, errors
+ class ImportError(Exception): """An import error""" pass
+ class DestNotCompatible(ImportError): """Memory is not compatible with the destination radio""" pass
+ def ensure_has_calls(radio, memory): """Make sure @radio has the necessary D-STAR callsigns for @memory""" ulist_changed = rlist_changed = False @@ -62,10 +65,12 @@ def ensure_has_calls(radio, memory): if rlist_changed: radio.set_repeater_call_list(rlist)
+ # Filter the name according to the destination's rules def _import_name(dst_radio, _srcrf, mem): mem.name = dst_radio.filter_name(mem.name)
+ def _import_power(dst_radio, _srcrf, mem): levels = dst_radio.get_features().valid_power_levels if not levels: @@ -75,7 +80,7 @@ def _import_power(dst_radio, _srcrf, mem): # Source radio did not support power levels, so choose the # first (highest) level from the destination radio. mem.power = levels[0] - return + return
# If both radios support power levels, we need to decide how to # convert the source power level to a valid one for the destination @@ -86,6 +91,7 @@ def _import_power(dst_radio, _srcrf, mem): deltas = [abs(mem.power - power) for power in levels] mem.power = levels[deltas.index(min(deltas))]
+ def _import_tone(dst_radio, srcrf, mem): dstrf = dst_radio.get_features()
@@ -104,6 +110,7 @@ def _import_tone(dst_radio, srcrf, mem): if mem.tmode == "TSQL": mem.ctone = mem.rtone
+ def _import_dtcs(dst_radio, srcrf, mem): dstrf = dst_radio.get_features()
@@ -122,6 +129,7 @@ def _import_dtcs(dst_radio, srcrf, mem): if mem.tmode == "DTCS": mem.rx_dtcs = mem.dtcs
+ def _guess_mode_by_frequency(freq): ranges = [ (0, 136000000, "AM"), @@ -135,6 +143,7 @@ def _guess_mode_by_frequency(freq): # If we don't know, assume FM return "FM"
+ def _import_mode(dst_radio, srcrf, mem): dstrf = dst_radio.get_features()
@@ -148,9 +157,10 @@ def _import_mode(dst_radio, srcrf, mem): raise DestNotCompatible("Destination does not support %s" % mode) mem.mode = mode
+ def _make_offset_with_split(rxfreq, txfreq): offset = txfreq - rxfreq - + if offset == 0: return "", offset elif offset > 0: @@ -158,24 +168,25 @@ def _make_offset_with_split(rxfreq, txfreq): elif offset < 0: return "-", offset * -1
+ def _import_duplex(dst_radio, srcrf, mem): dstrf = dst_radio.get_features()
# If a radio does not support odd split, we can use an equivalent offset if mem.duplex == "split" and mem.duplex not in dstrf.valid_duplexes: mem.duplex, mem.offset = _make_offset_with_split(mem.freq, mem.offset) - + # Enforce maximum offset - ranges = [ - ( 0, 500000000, 15000000), - (500000000, 3000000000, 50000000), - ] + ranges = [(0, 500000000, 15000000), + (500000000, 3000000000, 50000000), + ] for lo, hi, limit in ranges: if lo < mem.freq <= hi: if abs(mem.offset) > limit: raise DestNotCompatible("Unable to create import memory: " "offset is abnormally large.")
+ def import_mem(dst_radio, src_features, src_mem, overrides={}): """Perform import logic to create a destination memory from src_mem that will be compatible with @dst_radio""" @@ -183,7 +194,8 @@ def import_mem(dst_radio, src_features, src_mem, overrides={}):
if isinstance(src_mem, chirp_common.DVMemory): if not isinstance(dst_radio, chirp_common.IcomDstarSupport): - raise DestNotCompatible("Destination radio does not support D-STAR") + raise DestNotCompatible( + "Destination radio does not support D-STAR") if dst_rf.requires_call_lists: ensure_has_calls(dst_radio, src_mem)
@@ -206,17 +218,19 @@ def import_mem(dst_radio, src_features, src_mem, overrides={}): msgs = dst_radio.validate_memory(dst_mem) errs = [x for x in msgs if isinstance(x, chirp_common.ValidationError)] if errs: - raise DestNotCompatible("Unable to create import memory: %s" %\ - ", ".join(errs)) + raise DestNotCompatible("Unable to create import memory: %s" % + ", ".join(errs))
return dst_mem
+ def _get_bank_model(radio): for model in radio.get_mapping_models(): if isinstance(model, chirp_common.BankModel): return model return None
+ def import_bank(dst_radio, src_radio, dst_mem, src_mem): """Attempt to set the same banks for @mem(by index) in @dst_radio that it has in @src_radio""" diff --git a/chirp/platform.py b/chirp/platform.py index 313dfbd..5429ebc 100644 --- a/chirp/platform.py +++ b/chirp/platform.py @@ -19,6 +19,7 @@ import glob import re from subprocess import Popen
+ def win32_comports_bruteforce(): import win32file import win32con @@ -36,7 +37,7 @@ def win32_comports_bruteforce(): win32con.OPEN_EXISTING, 0, None) - ports.append((portname,"Unknown","Serial")) + ports.append((portname, "Unknown", "Serial")) win32file.CloseHandle(port) port = None except Exception, e: @@ -44,19 +45,23 @@ def win32_comports_bruteforce():
return ports
+ try: from serial.tools.list_ports import comports except: comports = win32_comports_bruteforce
+ def _find_me(): return sys.modules["chirp.platform"].__file__
+ def natural_sorted(l): convert = lambda text: int(text) if text.isdigit() else text.lower() natural_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)] return sorted(l, key=natural_key)
+ class Platform: """Base class for platform-specific functions"""
@@ -229,6 +234,7 @@ class Platform: return os.path.dirname(os.path.abspath(os.path.join(_find_me(), "..")))
+ def _unix_editor(): macos_textedit = "/Applications/TextEdit.app/Contents/MacOS/TextEdit"
@@ -237,23 +243,24 @@ def _unix_editor(): else: return "gedit"
+ class UnixPlatform(Platform): """A platform module suitable for UNIX systems""" def __init__(self, basepath): if not basepath: basepath = os.path.abspath(os.path.join(self.default_dir(), ".chirp")) - + if not os.path.isdir(basepath): os.mkdir(basepath)
Platform.__init__(self, basepath)
- # This is a hack that needs to be properly fixed by importing the - # latest changes to this module from d-rats. In the interest of - # time, however, I'll throw it here + # This is a hack that needs to be properly fixed by importing the + # latest changes to this module from d-rats. In the interest of + # time, however, I'll throw it here if sys.platform == "darwin": - if not os.environ.has_key("DISPLAY"): + if "DISPLAY" not in os.environ: print "Forcing DISPLAY for MacOS" os.environ["DISPLAY"] = ":0"
@@ -302,6 +309,7 @@ class UnixPlatform(Platform):
return ver
+ class Win32Platform(Platform): """A platform module suitable for Windows systems""" def __init__(self, basepath=None): @@ -362,7 +370,7 @@ class Win32Platform(Platform): def gui_save_file(self, start_dir=None, default_name=None, types=[]): import win32gui import win32api - + (pform, _, _, _, _) = win32api.GetVersionEx()
typestrs = "" @@ -405,14 +413,16 @@ class Win32Platform(Platform): def os_version_string(self): import win32api
- vers = { 4: "Win2k", - 5: "WinXP", - 6: "WinVista/7", - } + vers = {4: "Win2k", + 5: "WinXP", + 6: "WinVista/7", + }
(pform, sub, build, _, _) = win32api.GetVersionEx()
- return vers.get(pform, "Win32 (Unknown %i.%i:%i)" % (pform, sub, build)) + return vers.get(pform, + "Win32 (Unknown %i.%i:%i)" % (pform, sub, build)) +
def _get_platform(basepath): if os.name == "nt": @@ -421,6 +431,8 @@ def _get_platform(basepath): return UnixPlatform(basepath)
PLATFORM = None + + def get_platform(basepath=None): """Return the platform singleton""" global PLATFORM @@ -430,6 +442,7 @@ def get_platform(basepath=None):
return PLATFORM
+ def _do_test(): __pform = get_platform()
diff --git a/chirp/xml_ll.py b/chirp/xml_ll.py index 28ec333..8713507 100644 --- a/chirp/xml_ll.py +++ b/chirp/xml_ll.py @@ -17,6 +17,7 @@ import re
from chirp import chirp_common, errors
+ def get_memory(doc, number): """Extract a Memory object from @doc""" ctx = doc.xpathNewContext() @@ -59,7 +60,7 @@ def get_memory(doc, number): mem.ctone = float(_get("/squelch[@id='ctone']/tone/text()")) mem.dtcs = int(_get("/squelch[@id='dtcs']/code/text()"), 10) mem.dtcs_polarity = _get("/squelch[@id='dtcs']/polarity/text()") - + try: sql = _get("/squelchSetting/text()") if sql == "rtone": @@ -73,7 +74,7 @@ def get_memory(doc, number): except IndexError: mem.tmode = ""
- dmap = {"positive" : "+", "negative" : "-", "none" : ""} + dmap = {"positive": "+", "negative": "-", "none": ""} dupx = _get("/duplex/text()") mem.duplex = dmap.get(dupx, "")
@@ -97,6 +98,7 @@ def get_memory(doc, number):
return mem
+ def set_memory(doc, mem): """Set @mem in @doc""" ctx = doc.xpathNewContext() @@ -121,11 +123,11 @@ def set_memory(doc, mem): lname_filter = "[^.A-Za-z0-9/ >-]" lname = memnode.newChild(None, "longName", None) lname.addContent(re.sub(lname_filter, "", mem.name[:16])) - + freq = memnode.newChild(None, "frequency", None) freq.newProp("units", "MHz") freq.addContent(chirp_common.format_freq(mem.freq)) - + rtone = memnode.newChild(None, "squelch", None) rtone.newProp("id", "rtone") rtone.newProp("type", "repeater") @@ -154,7 +156,7 @@ def set_memory(doc, mem): elif mem.tmode == "DTCS": sset.addContent("dtcs")
- dmap = {"+" : "positive", "-" : "negative", "" : "none"} + dmap = {"+": "positive", "-": "negative", "": "none"} dupx = memnode.newChild(None, "duplex", None) dupx.addContent(dmap[mem.duplex])
@@ -168,7 +170,7 @@ def set_memory(doc, mem): step = memnode.newChild(None, "tuningStep", None) step.newProp("units", "kHz") step.addContent("%.5f" % mem.tuning_step) - + if mem.skip: skip = memnode.newChild(None, "skip", None) skip.addContent(mem.skip) @@ -197,6 +199,7 @@ def set_memory(doc, mem): dc = dv.newChild(None, "digitalCode", None) dc.addContent(str(mem.dv_code))
+ def del_memory(doc, number): """Remove memory @number from @doc""" path = "//radio/memories/memory[@location=%i]" % number @@ -205,13 +208,15 @@ def del_memory(doc, number):
for field in fields: field.unlinkNode() - + + def _get_bank(node): bank = chirp_common.Bank(node.prop("label")) ident = int(node.prop("id"))
return ident, bank
+ def get_banks(doc): """Return a list of banks from @doc""" path = "//radio/banks/bank" @@ -229,6 +234,7 @@ def get_banks(doc):
return [x[1] for x in banks]
+ def set_banks(doc, banklist): """Set the list of banks in @doc""" path = "//radio/banks/bank" diff --git a/chirpui/bankedit.py b/chirpui/bankedit.py index 19ea3e3..009f726 100644 --- a/chirpui/bankedit.py +++ b/chirpui/bankedit.py @@ -22,6 +22,7 @@ from gobject import TYPE_INT, TYPE_STRING, TYPE_BOOLEAN from chirp import chirp_common from chirpui import common, miscwidgets
+ class MappingNamesJob(common.RadioJob): def __init__(self, model, editor, cb): common.RadioJob.__init__(self, cb, None) @@ -37,6 +38,7 @@ class MappingNamesJob(common.RadioJob):
gobject.idle_add(self.cb, *self.cb_args)
+ class MappingNameEditor(common.Editor): def refresh(self): def got_mappings(): @@ -117,6 +119,7 @@ class MappingNameEditor(common.Editor): def mappings_changed(self): pass
+ class MemoryMappingsJob(common.RadioJob): def __init__(self, model, cb, number): common.RadioJob.__init__(self, cb, None) @@ -137,6 +140,7 @@ class MemoryMappingsJob(common.RadioJob): indexes.append(self.__model.get_memory_index(mem, mapping)) self.cb(mem, mappings, indexes, *self.cb_args)
+ class MappingMembershipEditor(common.Editor): def _number_to_path(self, number): return (number - self._rf.memory_bounds[0],) @@ -160,9 +164,9 @@ class MappingMembershipEditor(common.Editor): indexes.sort() for i in range(0, num_indexes): if i not in indexes: - return i + index_bounds[0] # In case not zero-origin index + return i + index_bounds[0] # In case not zero-origin index
- return 0 # If the mapping is full, just wrap around! + return 0 # If the mapping is full, just wrap around!
def _toggled_cb(self, rend, path, colnum): try: @@ -233,7 +237,7 @@ class MappingMembershipEditor(common.Editor):
def _index_edited_cb(self, rend, path, new): loc, = self._store.get(self._store.get_iter(path), self.C_LOC) - + def refresh_memory(*args): self.refresh_memory(loc)
@@ -261,7 +265,7 @@ class MappingMembershipEditor(common.Editor): job = common.RadioJob(get_mapping, "get_memory", loc) job.set_desc(_("Getting memory {num}").format(num=loc)) self.rthread.submit(job) - + def __init__(self, rthread, editorset, model): super(MappingMembershipEditor, self).__init__(rthread)
@@ -278,16 +282,16 @@ class MappingMembershipEditor(common.Editor): ]
self._cols = [ - ("_filled", TYPE_BOOLEAN, None, ), + ("_filled", TYPE_BOOLEAN, None, ), ] + self._view_cols
self.C_FILLED = 0 - self.C_LOC = 1 - self.C_FREQ = 2 - self.C_NAME = 3 - self.C_INDEX = 4 - self.C_MAPPINGS = 5 # and beyond - + self.C_LOC = 1 + self.C_FREQ = 2 + self.C_NAME = 3 + self.C_INDEX = 4 + self.C_MAPPINGS = 5 # and beyond + cols = list(self._cols)
self._index_cache = [] @@ -296,7 +300,7 @@ class MappingMembershipEditor(common.Editor): label = "%s %i" % (self._type, (i+1)) cols.append((label, TYPE_BOOLEAN, gtk.CellRendererToggle))
- self._store = gtk.ListStore(*tuple([y for x,y,z in cols])) + self._store = gtk.ListStore(*tuple([y for x, y, z in cols])) self._view = gtk.TreeView(self._store)
is_indexed = isinstance(self._model, @@ -361,7 +365,7 @@ class MappingMembershipEditor(common.Editor): for i in range(0, len(self.mappings)): row.append(i + len(self._cols)) row.append(self.mappings[i][0] in mappings) - + self._store.set(iter, *tuple(row))
job = MemoryMappingsJob(self._model, got_mem, number) @@ -374,8 +378,7 @@ class MappingMembershipEditor(common.Editor): (min, max) = self._rf.memory_bounds for i in range(min, max+1): self.refresh_memory(i) - print "Got all %s info in %s" % (self._type, - (time.time() - start)) + print "Got all %s info in %s" % (self._type, (time.time() - start))
def refresh_mappings(self, and_memories=False): def got_mappings(): diff --git a/chirpui/radiobrowser.py b/chirpui/radiobrowser.py index a11d810..14673f9 100644 --- a/chirpui/radiobrowser.py +++ b/chirpui/radiobrowser.py @@ -9,6 +9,7 @@ from chirpui import common, config
CONF = config.get()
+ def do_insert_line_with_tags(b, line): def i(text, *tags): b.insert_with_tags_by_name(b.get_end_iter(), text, *tags) @@ -63,6 +64,7 @@ def do_insert_line_with_tags(b, line):
i(line)
+ def do_insert_with_tags(buf, text): buf.set_text('') lines = text.split(os.linesep) @@ -70,12 +72,15 @@ def do_insert_with_tags(buf, text): do_insert_line_with_tags(buf, line) buf.insert_with_tags_by_name(buf.get_end_iter(), os.linesep)
+ def classname(obj): return str(obj.__class__).split('.')[-1]
+ def bitwise_type(classname): return classname.split("DataElement")[0]
+ class FixedEntry(gtk.Entry): def __init__(self, *args, **kwargs): super(FixedEntry, self).__init__(*args, **kwargs) @@ -91,6 +96,7 @@ class FixedEntry(gtk.Entry): fontdesc = pango.FontDescription("Courier bold %i" % fontsize) self.modify_font(fontdesc)
+ class IntegerEntry(FixedEntry): def _colorize(self, _self): value = self.get_text() @@ -106,12 +112,14 @@ class IntegerEntry(FixedEntry): super(IntegerEntry, self).__init__(*args, **kwargs) self.connect("changed", self._colorize)
+ class BitwiseEditor(gtk.HBox): def __init__(self, element): super(BitwiseEditor, self).__init__(False, 3) self._element = element self._build_ui()
+ class IntegerEditor(BitwiseEditor): def _changed(self, entry, base): if not self._update: @@ -150,6 +158,7 @@ class IntegerEditor(BitwiseEditor): ent.show() self._update_entries()
+ class BCDArrayEditor(BitwiseEditor): def _changed(self, entry, hexent): self._element.set_value(int(entry.get_text())) @@ -183,6 +192,7 @@ class BCDArrayEditor(BitwiseEditor): ent.connect('changed', self._changed, hexent) self._format_hexent(hexent)
+ class CharArrayEditor(BitwiseEditor): def _changed(self, entry): self._element.set_value(entry.get_text().ljust(len(self._element))) @@ -194,6 +204,7 @@ class CharArrayEditor(BitwiseEditor): ent.show() self.pack_start(ent, 1, 1, 1)
+ class OtherEditor(BitwiseEditor): def _build_ui(self): name = classname(self._element) @@ -207,6 +218,7 @@ class OtherEditor(BitwiseEditor): l.show() self.pack_start(l, 1, 1, 1)
+ class RadioBrowser(common.Editor): def _build_ui(self): self._display = gtk.Table(20, 2) @@ -287,7 +299,7 @@ class RadioBrowser(common.Editor): pack(l, 0)
if (isinstance(item, bitwise.intDataElement) or - isinstance(item, bitwise.bcdDataElement)): + isinstance(item, bitwise.bcdDataElement)): e = IntegerEditor(item) elif (isinstance(item, bitwise.arrayDataElement) and isinstance(item[0], bitwise.bcdDataElement)): @@ -301,7 +313,6 @@ class RadioBrowser(common.Editor): pack(e, 1) next_row()
- def __init__(self, rthread): super(RadioBrowser, self).__init__(rthread) self._radio = rthread.radio @@ -317,14 +328,17 @@ class RadioBrowser(common.Editor): self.emit("changed") self._focused = False
+ if __name__ == "__main__": from chirp 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) diff --git a/chirpui/settingsedit.py b/chirpui/settingsedit.py index 69bbadf..76264c9 100644 --- a/chirpui/settingsedit.py +++ b/chirpui/settingsedit.py @@ -20,11 +20,13 @@ from chirp import chirp_common from chirp import settings from chirpui import common, miscwidgets
+ class RadioSettingProxy(settings.RadioSetting): def __init__(self, setting, editor): self._setting = setting self._editor = editor
+ class SettingsEditor(common.Editor): def __init__(self, rthread): super(SettingsEditor, self).__init__(rthread) @@ -36,13 +38,14 @@ class SettingsEditor(common.Editor): paned = gtk.HPaned() paned.show() self.root.pack_start(paned, 1, 1, 0) - + # The selection tree self._store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_INT) self._view = gtk.TreeView(self._store) self._view.set_size_request(150, -1) self._view.get_selection().connect("changed", self._view_changed_cb) - self._view.append_column(gtk.TreeViewColumn("", gtk.CellRendererText(), text=0)) + self._view.append_column( + gtk.TreeViewColumn("", gtk.CellRendererText(), text=0)) self._view.show() paned.pack1(self._view)
@@ -88,9 +91,8 @@ class SettingsEditor(common.Editor): elif isinstance(value, settings.RadioSettingValueString): value.set_value(widget.get_text()) else: - print "Unsupported widget type %s for %s" % (\ - element.value.__class__, - element.get_name()) + print "Unsupported widget type %s for %s" % \ + (element.value.__class__, element.get_name())
self._changed = True self._save_settings() @@ -127,7 +129,9 @@ class SettingsEditor(common.Editor): label.set_alignment(0.0, 0.5) label.show()
- table.attach(label, 0, 1, row, row+1, xoptions=gtk.FILL, yoptions=0, xpadding=6, ypadding=3) + table.attach(label, 0, 1, row, row + 1, + xoptions=gtk.FILL, yoptions=0, + xpadding=6, ypadding=3)
if isinstance(element.value, list) and \ isinstance(element.value[0], @@ -138,7 +142,9 @@ class SettingsEditor(common.Editor):
# Widget container box.show() - table.attach(box, 1, 2, row, row+1, xoptions=gtk.FILL, yoptions=0, xpadding=12, ypadding=3) + table.attach(box, 1, 2, row, row + 1, + xoptions=gtk.FILL, yoptions=0, + xpadding=12, ypadding=3)
for i in element.keys(): value = element[i] @@ -154,7 +160,7 @@ class SettingsEditor(common.Editor): widget.set_width_chars(16) widget.set_text(value.format()) widget.connect("focus-out-event", lambda w, e, v: - self._save_setting(w, v), value) + self._save_setting(w, v), value) elif isinstance(value, settings.RadioSettingValueBoolean): widget = gtk.CheckButton(_("Enabled")) widget.set_active(value.get_value()) @@ -179,7 +185,7 @@ class SettingsEditor(common.Editor):
widget.set_sensitive(value.get_mutable()) widget.show() - + box.pack_start(widget, 1, 1, 1)
row += 1 @@ -187,12 +193,11 @@ class SettingsEditor(common.Editor): return tab
def _build_ui_group(self, group, parent): - tab = self._build_ui_tab(group) - + iter = self._store.append(parent) self._store.set(iter, 0, group.get_shortname(), 1, tab) - + for element in group: if not isinstance(element, settings.RadioSetting): self._build_ui_group(element, iter) @@ -213,4 +218,4 @@ class SettingsEditor(common.Editor): def _view_changed_cb(self, selection): (lst, iter) = selection.get_selected() tab, = self._store.get(iter, 1) - self._notebook.set_current_page(tab) \ No newline at end of file + self._notebook.set_current_page(tab) diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 39b452f..91f4275 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -12,11 +12,9 @@ ./chirp/bandplan_na.py ./chirp/baofeng_uv3r.py ./chirp/bitwise.py -./chirp/bitwise_grammar.py ./chirp/bjuv55.py ./chirp/chirp_common.py ./chirp/elib_intl.py -./chirp/errors.py ./chirp/ft1802.py ./chirp/ft1d.py ./chirp/ft2800.py @@ -28,7 +26,6 @@ ./chirp/ft857.py ./chirp/ft90.py ./chirp/ftm350.py -./chirp/generic_csv.py ./chirp/h777.py ./chirp/ic208.py ./chirp/ic2100.py @@ -51,14 +48,12 @@ ./chirp/id800.py ./chirp/id880.py ./chirp/idrp.py -./chirp/import_logic.py ./chirp/kenwood_hmk.py ./chirp/kenwood_itm.py ./chirp/kenwood_live.py ./chirp/kguv8d.py ./chirp/kyd.py ./chirp/leixen.py -./chirp/platform.py ./chirp/puxing.py ./chirp/pyPEG.py ./chirp/rfinder.py @@ -85,9 +80,7 @@ ./chirp/vxa700.py ./chirp/wouxun.py ./chirp/wouxun_common.py -./chirp/xml_ll.py ./chirp/yaesu_clone.py -./chirpui/bankedit.py ./chirpui/common.py ./chirpui/editorset.py ./chirpui/fips.py @@ -96,9 +89,7 @@ ./chirpui/memdetail.py ./chirpui/memedit.py ./chirpui/miscwidgets.py -./chirpui/radiobrowser.py ./chirpui/reporting.py -./chirpui/settingsedit.py ./csvdump/csvapp.py ./csvdump/csvdump.py ./setup.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID aeb2e080edb948f01397cda51cbc8903b2be52a2
Fix style issues in setup.py (#2355)
This patch brings setup.py into conformance with PEP8 rules and removes it from the blacklist. It also rewrites the staticify_chirp_module routine to be more idiomatic.
diff --git a/setup.py b/setup.py index 28c4eb3..b923670 100644 --- a/setup.py +++ b/setup.py @@ -6,15 +6,16 @@ from chirp import CHIRP_VERSION from chirp import * import chirp
+ def staticify_chirp_module(): import chirp
- init = file("chirp/__init__.py", "w") - print >>init, "CHIRP_VERSION = "%s"" % CHIRP_VERSION - print >>init, "__all__ = %s\n" % str(chirp.__all__) - init.close() + with file("chirp/__init__.py", "w") as init: + print >>init, "CHIRP_VERSION = "%s"" % CHIRP_VERSION + print >>init, "__all__ = %s\n" % str(chirp.__all__) + + print "Set chirp/__init__.py::__all__ = %s" % str(chirp.__all__)
- print "Set chirp.py::__all__ = %s" % str(chirp.__all__)
def win32_build(): from distutils.core import setup @@ -26,7 +27,7 @@ def win32_build(): import win32com for p in win32com.__path__[1:]: modulefinder.AddPackagePath("win32com", p) - for extra in ["win32com.shell"]: #,"win32com.mapi" + for extra in ["win32com.shell"]: # ,"win32com.mapi" __import__(extra) m = sys.modules[extra] for p in m.__path__[1:]: @@ -38,13 +39,15 @@ def win32_build(): staticify_chirp_module()
opts = { - "py2exe" : { - "includes" : "pango,atk,gobject,cairo,pangocairo,win32gui,win32com,win32com.shell,email.iterators,email.generator,gio", - - "compressed" : 1, - "optimize" : 2, - "bundle_files" : 3, - # "packages" : "" + "py2exe": { + "includes": "pango,atk,gobject,cairo,pangocairo," + + "win32gui,win32com,win32com.shell," + + "email.iterators,email.generator,gio", + + "compressed": 1, + "optimize": 2, + "bundle_files": 3, + # "packages": "" } }
@@ -55,22 +58,22 @@ def win32_build():
setup( zipfile=None, - windows=[{'script' : "chirpw", + windows=[{'script': "chirpw", 'icon_resources': [(0x0004, 'share/chirp.ico')], - }], + }], options=opts)
+ def macos_build(): from setuptools import setup import shutil
APP = ['chirp-%s.py' % CHIRP_VERSION] shutil.copy("chirpw", APP[0]) - DATA_FILES = [('../Frameworks', - ['/opt/local/lib/libpangox-1.0.dylib']), - ('../Resources/', ['/opt/local/lib/pango']), + DATA_FILES = [('../Frameworks', ['/opt/local/lib/libpangox-1.0.dylib']), + ('../Resources/', ['/opt/local/lib/pango']), ] - OPTIONS = {'argv_emulation': True, "includes" : "gtk,atk,pangocairo,cairo"} + OPTIONS = {'argv_emulation': True, "includes": "gtk,atk,pangocairo,cairo"}
setup( app=APP, @@ -79,9 +82,11 @@ def macos_build(): setup_requires=['py2app'], )
- EXEC = 'bash ./build/macos/make_pango.sh /opt/local dist/chirp-%s.app' % CHIRP_VERSION + EXEC = 'bash ./build/macos/make_pango.sh ' + \ + '/opt/local dist/chirp-%s.app' % CHIRP_VERSION #print "exec string: %s" % EXEC - os.system(EXEC) + os.system(EXEC) +
def default_build(): from distutils.core import setup @@ -117,9 +122,10 @@ def default_build(): ('share/chirp/stock_configs', stock_configs), ] + locale_files)
+ def rpttool_build(): from distutils.core import setup - + setup(name="rpttool", packages=["chirp"], version="0.3", @@ -128,6 +134,7 @@ def rpttool_build(): data_files=[('/usr/sbin', ["tools/icomsio.sh"])], )
+ def nuke_manifest(*files): for i in ["MANIFEST", "MANIFEST.in"]: if os.path.exists(i): @@ -140,7 +147,8 @@ def nuke_manifest(*files): for fn in files: print >>f, fn f.close() - + + if sys.platform == "darwin": macos_build() elif sys.platform == "win32": @@ -157,4 +165,3 @@ else: "include stock_configs/*", "include COPYING") default_build() - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 91f4275..5dd6174 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -92,7 +92,6 @@ ./chirpui/reporting.py ./csvdump/csvapp.py ./csvdump/csvdump.py -./setup.py ./share/make_supported.py ./tests/run_tests ./tests/unit/test_import_logic.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 23bebdb319206bd30abe52d8f4568131304caf95
Move drivers into their own directory (#2351)
CHIRP now supports enough devices that the chirp/ directory has become cluttered. This creates unnecessary coupling when importing all of these modules. This patch moves all of the drivers to their own directory and then chases down all of the stale import references.
diff --git a/chirp/detect.py b/chirp/detect.py index 580670f..40869d7 100644 --- a/chirp/detect.py +++ b/chirp/detect.py @@ -15,8 +15,8 @@
import serial
-from chirp import errors, icf, directory, ic9x_ll -from chirp import kenwood_live, icomciv +from chirp import errors, directory +from chirp.drivers import ic9x_ll, icf, kenwood_live, icomciv
def _icom_model_data_to_rclass(md): diff --git a/chirp/directory.py b/chirp/directory.py index 7b529e6..0d43bd6 100644 --- a/chirp/directory.py +++ b/chirp/directory.py @@ -18,7 +18,7 @@ import os import tempfile import logging
-from chirp import icf +from chirp.drivers import icf from chirp import chirp_common, util, rfinder, radioreference, errors
LOG = logging.getLogger(__name__) diff --git a/chirp/drivers/__init__.py b/chirp/drivers/__init__.py new file mode 100644 index 0000000..ea9dd2c --- /dev/null +++ b/chirp/drivers/__init__.py @@ -0,0 +1,10 @@ +import os +import sys +from glob import glob + +module_dir = os.path.dirname(sys.modules["chirp.drivers"].__file__) +__all__ = [] +for i in sorted(glob(os.path.join(module_dir, "*.py"))): + name = os.path.basename(i)[:-3] + if not name.startswith("__"): + __all__.append(name) diff --git a/chirp/alinco.py b/chirp/drivers/alinco.py similarity index 100% rename from chirp/alinco.py rename to chirp/drivers/alinco.py diff --git a/chirp/anytone.py b/chirp/drivers/anytone.py similarity index 100% rename from chirp/anytone.py rename to chirp/drivers/anytone.py diff --git a/chirp/ap510.py b/chirp/drivers/ap510.py similarity index 100% rename from chirp/ap510.py rename to chirp/drivers/ap510.py diff --git a/chirp/baofeng_uv3r.py b/chirp/drivers/baofeng_uv3r.py similarity index 99% rename from chirp/baofeng_uv3r.py rename to chirp/drivers/baofeng_uv3r.py index 0827885..c98ab37 100644 --- a/chirp/baofeng_uv3r.py +++ b/chirp/drivers/baofeng_uv3r.py @@ -17,8 +17,8 @@
import time import os +from wouxun_common import do_download, do_upload from chirp import util, chirp_common, bitwise, errors, directory -from chirp.wouxun_common import do_download, do_upload from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettingValueList, \ RadioSettingValueInteger, RadioSettingValueString, \ diff --git a/chirp/bjuv55.py b/chirp/drivers/bjuv55.py similarity index 99% rename from chirp/bjuv55.py rename to chirp/drivers/bjuv55.py index 9fb7e5a..81bc2ed 100644 --- a/chirp/bjuv55.py +++ b/chirp/drivers/bjuv55.py @@ -19,6 +19,7 @@ import struct import time import os
+from chirp.drivers import uv5r from chirp import chirp_common, errors, util, directory, memmap from chirp import bitwise from chirp.settings import RadioSetting, RadioSettingGroup, \ @@ -26,7 +27,6 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettingValueString, \ RadioSettingValueFloat, InvalidValueError, RadioSettings from textwrap import dedent -from chirp import uv5r
BJUV55_MODEL = "\x50\xBB\xDD\x55\x63\x98\x4D"
diff --git a/chirp/ft1802.py b/chirp/drivers/ft1802.py similarity index 98% rename from chirp/ft1802.py rename to chirp/drivers/ft1802.py index 7b5945d..a491907 100644 --- a/chirp/ft1802.py +++ b/chirp/drivers/ft1802.py @@ -23,7 +23,8 @@ # 4. Press the [D/MR(MW)] key ("--WAIT--" will appear on the LCD). # 5. In Chirp, choose Upload to Radio.
-from chirp import chirp_common, bitwise, directory, yaesu_clone +from chirp.drivers import yaesu_clone +from chirp import chirp_common, bitwise, directory from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettings from textwrap import dedent diff --git a/chirp/ft1d.py b/chirp/drivers/ft1d.py similarity index 99% rename from chirp/ft1d.py rename to chirp/drivers/ft1d.py index db0259f..bc01503 100644 --- a/chirp/ft1d.py +++ b/chirp/drivers/ft1d.py @@ -19,8 +19,8 @@ import re import string import logging
-from chirp import chirp_common, yaesu_clone, directory -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, bitwise from chirp.settings import RadioSettingGroup, RadioSetting, RadioSettings from chirp.settings import RadioSettingValueInteger, RadioSettingValueString from chirp.settings import RadioSettingValueList, RadioSettingValueBoolean diff --git a/chirp/ft2800.py b/chirp/drivers/ft2800.py similarity index 99% rename from chirp/ft2800.py rename to chirp/drivers/ft2800.py index feac0ce..d091d7b 100644 --- a/chirp/ft2800.py +++ b/chirp/drivers/ft2800.py @@ -18,7 +18,7 @@ import os import logging
from chirp import util, memmap, chirp_common, bitwise, directory, errors -from chirp.yaesu_clone import YaesuCloneModeRadio +from yaesu_clone import YaesuCloneModeRadio
LOG = logging.getLogger(__name__)
diff --git a/chirp/ft50.py b/chirp/drivers/ft50.py similarity index 95% rename from chirp/ft50.py rename to chirp/drivers/ft50.py index d101360..2f726ec 100644 --- a/chirp/ft50.py +++ b/chirp/drivers/ft50.py @@ -13,7 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, ft50_ll, directory +from chirp.drivers import yaesu_clone, ft50_ll +from chirp import chirp_common, directory
# Not working, don't register #@directory.register diff --git a/chirp/ft50_ll.py b/chirp/drivers/ft50_ll.py similarity index 100% rename from chirp/ft50_ll.py rename to chirp/drivers/ft50_ll.py diff --git a/chirp/ft60.py b/chirp/drivers/ft60.py similarity index 99% rename from chirp/ft60.py rename to chirp/drivers/ft60.py index 74799ef..5720f2d 100644 --- a/chirp/ft60.py +++ b/chirp/drivers/ft60.py @@ -14,8 +14,8 @@ # along with this program. If not, see http://www.gnu.org/licenses/.
import time, os, logging -from chirp import chirp_common, yaesu_clone, memmap, bitwise, directory -from chirp import errors +from chirp.drivers import yaesu_clone +from chirp import chirp_common, memmap, bitwise, directory, errors from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ diff --git a/chirp/ft7800.py b/chirp/drivers/ft7800.py similarity index 99% rename from chirp/ft7800.py rename to chirp/drivers/ft7800.py index 824bd6d..8bd3303 100644 --- a/chirp/ft7800.py +++ b/chirp/drivers/ft7800.py @@ -14,8 +14,8 @@ # along with this program. If not, see http://www.gnu.org/licenses/.
import time, logging -from chirp import chirp_common, yaesu_clone, memmap, directory -from chirp import bitwise, errors +from chirp.drivers import yaesu_clone +from chirp import chirp_common, memmap, directory, bitwise, errors from textwrap import dedent from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ diff --git a/chirp/ft817.py b/chirp/drivers/ft817.py similarity index 99% rename from chirp/ft817.py rename to chirp/drivers/ft817.py index c0b42b2..961636f 100644 --- a/chirp/ft817.py +++ b/chirp/drivers/ft817.py @@ -16,8 +16,8 @@
"""FT817 - FT817ND - FT817ND/US management module"""
-from chirp import chirp_common, yaesu_clone, util, memmap, errors, directory -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, util, memmap, errors, directory, bitwise from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ diff --git a/chirp/ft857.py b/chirp/drivers/ft857.py similarity index 99% rename from chirp/ft857.py rename to chirp/drivers/ft857.py index 940c62d..f5fc33e 100644 --- a/chirp/ft857.py +++ b/chirp/drivers/ft857.py @@ -16,7 +16,8 @@
"""FT857 - FT857/US management module"""
-from chirp import ft817, chirp_common, errors, directory +from chirp.drivers import ft817 +from chirp import chirp_common, errors, directory from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ diff --git a/chirp/ft90.py b/chirp/drivers/ft90.py similarity index 99% rename from chirp/ft90.py rename to chirp/drivers/ft90.py index b638d47..dc7b658 100644 --- a/chirp/ft90.py +++ b/chirp/drivers/ft90.py @@ -14,7 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, bitwise, memmap, directory, errors, util, yaesu_clone +from chirp.drivers import yaesu_clone +from chirp import chirp_common, bitwise, memmap, directory, errors, util from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ diff --git a/chirp/ftm350.py b/chirp/drivers/ftm350.py similarity index 99% rename from chirp/ftm350.py rename to chirp/drivers/ftm350.py index e3fcbfe..564e1a0 100644 --- a/chirp/ftm350.py +++ b/chirp/drivers/ftm350.py @@ -18,8 +18,8 @@ import struct import os import logging
-from chirp import chirp_common, yaesu_clone, directory, errors, util -from chirp import bitwise, memmap +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, errors, util, bitwise, memmap from chirp.settings import RadioSettingGroup, RadioSetting, RadioSettings from chirp.settings import RadioSettingValueInteger, RadioSettingValueString
diff --git a/chirp/generic_csv.py b/chirp/drivers/generic_csv.py similarity index 100% rename from chirp/generic_csv.py rename to chirp/drivers/generic_csv.py diff --git a/chirp/generic_tpe.py b/chirp/drivers/generic_tpe.py similarity index 100% rename from chirp/generic_tpe.py rename to chirp/drivers/generic_tpe.py diff --git a/chirp/generic_xml.py b/chirp/drivers/generic_xml.py similarity index 100% rename from chirp/generic_xml.py rename to chirp/drivers/generic_xml.py diff --git a/chirp/h777.py b/chirp/drivers/h777.py similarity index 100% rename from chirp/h777.py rename to chirp/drivers/h777.py diff --git a/chirp/ic208.py b/chirp/drivers/ic208.py similarity index 98% rename from chirp/ic208.py rename to chirp/drivers/ic208.py index f93300c..9c3bbaa 100644 --- a/chirp/ic208.py +++ b/chirp/drivers/ic208.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, errors, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, errors, directory, bitwise
MEM_FORMAT = """ struct memory { diff --git a/chirp/ic2100.py b/chirp/drivers/ic2100.py similarity index 98% rename from chirp/ic2100.py rename to chirp/drivers/ic2100.py index 0b2dda8..8babe50 100644 --- a/chirp/ic2100.py +++ b/chirp/drivers/ic2100.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, util, directory -from chirp import bitwise, memmap +from chirp.drivers import icf +from chirp import chirp_common, util, directory, bitwise, memmap from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ diff --git a/chirp/ic2200.py b/chirp/drivers/ic2200.py similarity index 98% rename from chirp/ic2200.py rename to chirp/drivers/ic2200.py index d6b1fe2..e059f59 100644 --- a/chirp/ic2200.py +++ b/chirp/drivers/ic2200.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, util, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, util, directory, bitwise
MEM_FORMAT = """ struct { diff --git a/chirp/ic2720.py b/chirp/drivers/ic2720.py similarity index 98% rename from chirp/ic2720.py rename to chirp/drivers/ic2720.py index 24d499a..462c616 100644 --- a/chirp/ic2720.py +++ b/chirp/drivers/ic2720.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, util, directory, bitwise
MEM_FORMAT = """ struct { diff --git a/chirp/ic2820.py b/chirp/drivers/ic2820.py similarity index 99% rename from chirp/ic2820.py rename to chirp/drivers/ic2820.py index 5f5827c..8b507d9 100644 --- a/chirp/ic2820.py +++ b/chirp/drivers/ic2820.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, util, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, util, directory, bitwise
MEM_FORMAT = """ struct { diff --git a/chirp/ic9x.py b/chirp/drivers/ic9x.py similarity index 99% rename from chirp/ic9x.py rename to chirp/drivers/ic9x.py index 3d8c437..5726b09 100644 --- a/chirp/ic9x.py +++ b/chirp/drivers/ic9x.py @@ -16,7 +16,8 @@ import time import threading
-from chirp import chirp_common, errors, ic9x_ll, icf, util, directory +from chirp.drivers import ic9x_ll, icf +from chirp import chirp_common, errors, util, directory from chirp import bitwise
IC9XA_SPECIAL = {} diff --git a/chirp/ic9x_icf.py b/chirp/drivers/ic9x_icf.py similarity index 96% rename from chirp/ic9x_icf.py rename to chirp/drivers/ic9x_icf.py index 9da75b5..666307b 100644 --- a/chirp/ic9x_icf.py +++ b/chirp/drivers/ic9x_icf.py @@ -13,7 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, ic9x_icf_ll, util, directory, errors +from chirp.drivers import icf, ic9x_icf_ll +from chirp import chirp_common, util, directory, errors
# Don't register as this module is used to load icf file from File-Open menu # see do_open in mainapp.py diff --git a/chirp/ic9x_icf_ll.py b/chirp/drivers/ic9x_icf_ll.py similarity index 100% rename from chirp/ic9x_icf_ll.py rename to chirp/drivers/ic9x_icf_ll.py diff --git a/chirp/ic9x_ll.py b/chirp/drivers/ic9x_ll.py similarity index 100% rename from chirp/ic9x_ll.py rename to chirp/drivers/ic9x_ll.py diff --git a/chirp/icf.py b/chirp/drivers/icf.py similarity index 100% rename from chirp/icf.py rename to chirp/drivers/icf.py diff --git a/chirp/icomciv.py b/chirp/drivers/icomciv.py similarity index 99% rename from chirp/icomciv.py rename to chirp/drivers/icomciv.py index 1d02553..fd9090f 100644 --- a/chirp/icomciv.py +++ b/chirp/drivers/icomciv.py @@ -1,6 +1,7 @@
import struct, logging -from chirp import chirp_common, icf, util, errors, bitwise, directory +from chirp.drivers import icf +from chirp import chirp_common, util, errors, bitwise, directory from chirp.memmap import MemoryMap
LOG = logging.getLogger(__name__) diff --git a/chirp/icq7.py b/chirp/drivers/icq7.py similarity index 99% rename from chirp/icq7.py rename to chirp/drivers/icq7.py index 23333fb..ed74f19 100644 --- a/chirp/icq7.py +++ b/chirp/drivers/icq7.py @@ -14,8 +14,8 @@ # along with this program. If not, see http://www.gnu.org/licenses/.
import struct -from chirp import chirp_common, icf, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, directory, bitwise from chirp.chirp_common import to_GHz, from_GHz from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettingValueList, \ diff --git a/chirp/ict70.py b/chirp/drivers/ict70.py similarity index 98% rename from chirp/ict70.py rename to chirp/drivers/ict70.py index d035e14..eb81d7e 100644 --- a/chirp/ict70.py +++ b/chirp/drivers/ict70.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, directory, bitwise
MEM_FORMAT = """ struct { diff --git a/chirp/ict7h.py b/chirp/drivers/ict7h.py similarity index 97% rename from chirp/ict7h.py rename to chirp/drivers/ict7h.py index 768fb34..5648261 100644 --- a/chirp/ict7h.py +++ b/chirp/drivers/ict7h.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, directory, bitwise
mem_format = """ struct { diff --git a/chirp/ict8.py b/chirp/drivers/ict8.py similarity index 97% rename from chirp/ict8.py rename to chirp/drivers/ict8.py index c77d8f3..ea3d82a 100644 --- a/chirp/ict8.py +++ b/chirp/drivers/ict8.py @@ -13,7 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, util, directory +from chirp.drivers import icf +from chirp import chirp_common, util, directory from chirp import bitwise
mem_format = """ diff --git a/chirp/icw32.py b/chirp/drivers/icw32.py similarity index 98% rename from chirp/icw32.py rename to chirp/drivers/icw32.py index 2b028ad..601f113 100644 --- a/chirp/icw32.py +++ b/chirp/drivers/icw32.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, util, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, util, directory, bitwise
MEM_FORMAT = """ #seekto 0x%x; diff --git a/chirp/icx8x.py b/chirp/drivers/icx8x.py similarity index 98% rename from chirp/icx8x.py rename to chirp/drivers/icx8x.py index b9ea35c..776bd74 100644 --- a/chirp/icx8x.py +++ b/chirp/drivers/icx8x.py @@ -13,7 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, icx8x_ll, errors, directory +from chirp.drivers import icf, icx8x_ll +from chirp import chirp_common, errors, directory
def _isuhf(pipe): try: diff --git a/chirp/icx8x_ll.py b/chirp/drivers/icx8x_ll.py similarity index 100% rename from chirp/icx8x_ll.py rename to chirp/drivers/icx8x_ll.py diff --git a/chirp/id31.py b/chirp/drivers/id31.py similarity index 99% rename from chirp/id31.py rename to chirp/drivers/id31.py index 128d79d..7c91b02 100644 --- a/chirp/id31.py +++ b/chirp/drivers/id31.py @@ -13,7 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import directory, icf, bitwise, chirp_common +from chirp.drivers import icf +from chirp import directory, bitwise, chirp_common
MEM_FORMAT = """ struct { diff --git a/chirp/id51.py b/chirp/drivers/id51.py similarity index 96% rename from chirp/id51.py rename to chirp/drivers/id51.py index 4b72c44..b1b5c65 100644 --- a/chirp/id51.py +++ b/chirp/drivers/id51.py @@ -13,7 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import directory, bitwise, id31 +from chirp.drivers import id31 +from chirp import directory, bitwise
MEM_FORMAT = """ struct { diff --git a/chirp/id800.py b/chirp/drivers/id800.py similarity index 99% rename from chirp/id800.py rename to chirp/drivers/id800.py index 56350de..c0d233a 100644 --- a/chirp/id800.py +++ b/chirp/drivers/id800.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, errors, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, errors, directory, bitwise
MEM_FORMAT = """ #seekto 0x0020; diff --git a/chirp/id880.py b/chirp/drivers/id880.py similarity index 99% rename from chirp/id880.py rename to chirp/drivers/id880.py index b6c8b39..3639b30 100644 --- a/chirp/id880.py +++ b/chirp/drivers/id880.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, directory, bitwise
MEM_FORMAT = """ struct { diff --git a/chirp/idrp.py b/chirp/drivers/idrp.py similarity index 100% rename from chirp/idrp.py rename to chirp/drivers/idrp.py diff --git a/chirp/kenwood_hmk.py b/chirp/drivers/kenwood_hmk.py similarity index 100% rename from chirp/kenwood_hmk.py rename to chirp/drivers/kenwood_hmk.py diff --git a/chirp/kenwood_itm.py b/chirp/drivers/kenwood_itm.py similarity index 100% rename from chirp/kenwood_itm.py rename to chirp/drivers/kenwood_itm.py diff --git a/chirp/kenwood_live.py b/chirp/drivers/kenwood_live.py similarity index 100% rename from chirp/kenwood_live.py rename to chirp/drivers/kenwood_live.py diff --git a/chirp/kguv8d.py b/chirp/drivers/kguv8d.py similarity index 100% rename from chirp/kguv8d.py rename to chirp/drivers/kguv8d.py diff --git a/chirp/kyd.py b/chirp/drivers/kyd.py similarity index 100% rename from chirp/kyd.py rename to chirp/drivers/kyd.py diff --git a/chirp/leixen.py b/chirp/drivers/leixen.py similarity index 100% rename from chirp/leixen.py rename to chirp/drivers/leixen.py diff --git a/chirp/puxing.py b/chirp/drivers/puxing.py similarity index 99% rename from chirp/puxing.py rename to chirp/drivers/puxing.py index f38b41e..ddfee1a 100644 --- a/chirp/puxing.py +++ b/chirp/drivers/puxing.py @@ -18,7 +18,7 @@ import time import os from chirp import util, chirp_common, bitwise, errors, directory -from chirp.wouxun_common import wipe_memory, do_download, do_upload +from chirp.drivers.wouxun import wipe_memory, do_download, do_upload
def _puxing_prep(radio): radio.pipe.write("\x02PROGRA") diff --git a/chirp/template.py b/chirp/drivers/template.py similarity index 100% rename from chirp/template.py rename to chirp/drivers/template.py diff --git a/chirp/th9800.py b/chirp/drivers/th9800.py similarity index 99% rename from chirp/th9800.py rename to chirp/drivers/th9800.py index d1a1b0b..1f1d498 100644 --- a/chirp/th9800.py +++ b/chirp/drivers/th9800.py @@ -21,7 +21,7 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ RadioSettingValueFloat, InvalidValueError, RadioSettings -from chirp_common import format_freq +from chirp.chirp_common import format_freq import os import time import logging diff --git a/chirp/th_uv3r.py b/chirp/drivers/th_uv3r.py similarity index 99% rename from chirp/th_uv3r.py rename to chirp/drivers/th_uv3r.py index 3b670fe..77df451 100644 --- a/chirp/th_uv3r.py +++ b/chirp/drivers/th_uv3r.py @@ -17,7 +17,7 @@
import os from chirp import chirp_common, bitwise, errors, directory -from chirp.wouxun_common import do_download, do_upload +from chirp.drivers.wouxun import do_download, do_upload
def tyt_uv3r_prep(radio): try: diff --git a/chirp/th_uv3r25.py b/chirp/drivers/th_uv3r25.py similarity index 99% rename from chirp/th_uv3r25.py rename to chirp/drivers/th_uv3r25.py index e9b4cbb..35a3fa4 100644 --- a/chirp/th_uv3r25.py +++ b/chirp/drivers/th_uv3r25.py @@ -16,7 +16,7 @@ """TYT uv3r (2.5kHz) radio management module"""
from chirp import chirp_common, bitwise, directory -from chirp.wouxun_common import do_download, do_upload +from chirp.drivers.wouxun import do_download, do_upload
from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ diff --git a/chirp/th_uvf8d.py b/chirp/drivers/th_uvf8d.py similarity index 100% rename from chirp/th_uvf8d.py rename to chirp/drivers/th_uvf8d.py diff --git a/chirp/thd72.py b/chirp/drivers/thd72.py similarity index 100% rename from chirp/thd72.py rename to chirp/drivers/thd72.py diff --git a/chirp/thuv1f.py b/chirp/drivers/thuv1f.py similarity index 100% rename from chirp/thuv1f.py rename to chirp/drivers/thuv1f.py diff --git a/chirp/tk8102.py b/chirp/drivers/tk8102.py similarity index 100% rename from chirp/tk8102.py rename to chirp/drivers/tk8102.py diff --git a/chirp/tmv71.py b/chirp/drivers/tmv71.py similarity index 98% rename from chirp/tmv71.py rename to chirp/drivers/tmv71.py index 59ef226..cca737a 100644 --- a/chirp/tmv71.py +++ b/chirp/drivers/tmv71.py @@ -14,7 +14,7 @@ # along with this program. If not, see http://www.gnu.org/licenses/.
from chirp import chirp_common, errors, util -from chirp import tmv71_ll +from chirp.drivers import tmv71_ll
class TMV71ARadio(chirp_common.CloneModeRadio): BAUD_RATE = 9600 diff --git a/chirp/tmv71_ll.py b/chirp/drivers/tmv71_ll.py similarity index 100% rename from chirp/tmv71_ll.py rename to chirp/drivers/tmv71_ll.py diff --git a/chirp/uv5r.py b/chirp/drivers/uv5r.py similarity index 100% rename from chirp/uv5r.py rename to chirp/drivers/uv5r.py diff --git a/chirp/uvb5.py b/chirp/drivers/uvb5.py similarity index 100% rename from chirp/uvb5.py rename to chirp/drivers/uvb5.py diff --git a/chirp/vx170.py b/chirp/drivers/vx170.py similarity index 96% rename from chirp/vx170.py rename to chirp/drivers/vx170.py index eaa7dbc..347951d 100644 --- a/chirp/vx170.py +++ b/chirp/drivers/vx170.py @@ -13,11 +13,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, directory, memmap -from chirp import bitwise, errors +from chirp.drivers import yaesu_clone, ft7800 +from chirp import chirp_common, directory, memmap, bitwise, errors from textwrap import dedent import time, os -from chirp import ft7800
MEM_FORMAT = """ #seekto 0x018A; diff --git a/chirp/vx2.py b/chirp/drivers/vx2.py similarity index 99% rename from chirp/vx2.py rename to chirp/drivers/vx2.py index 6c6b912..42c7ba8 100644 --- a/chirp/vx2.py +++ b/chirp/drivers/vx2.py @@ -14,7 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, directory, bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, bitwise from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ diff --git a/chirp/vx3.py b/chirp/drivers/vx3.py similarity index 99% rename from chirp/vx3.py rename to chirp/drivers/vx3.py index 0575a46..6bd2973 100644 --- a/chirp/vx3.py +++ b/chirp/drivers/vx3.py @@ -14,8 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, directory -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, bitwise from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ diff --git a/chirp/vx5.py b/chirp/drivers/vx5.py similarity index 98% rename from chirp/vx5.py rename to chirp/drivers/vx5.py index 65a5ba4..61bce15 100644 --- a/chirp/vx5.py +++ b/chirp/drivers/vx5.py @@ -14,8 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, directory, errors -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, errors, bitwise
MEM_FORMAT = """ #seekto 0x002A; diff --git a/chirp/vx510.py b/chirp/drivers/vx510.py similarity index 98% rename from chirp/vx510.py rename to chirp/drivers/vx510.py index 7f287a9..16a9026 100644 --- a/chirp/vx510.py +++ b/chirp/drivers/vx510.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, directory -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, bitwise
# This driver is unfinished and therefore does not register itself with Chirp. # diff --git a/chirp/vx6.py b/chirp/drivers/vx6.py similarity index 99% rename from chirp/vx6.py rename to chirp/drivers/vx6.py index 0cdb115..467c9de 100644 --- a/chirp/vx6.py +++ b/chirp/drivers/vx6.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, directory -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, bitwise from textwrap import dedent
# flags.{even|odd}_pskip: These are actually "preferential *scan* channels". diff --git a/chirp/vx7.py b/chirp/drivers/vx7.py similarity index 99% rename from chirp/vx7.py rename to chirp/drivers/vx7.py index 5fff4b1..d63bf32 100644 --- a/chirp/vx7.py +++ b/chirp/drivers/vx7.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, directory -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, bitwise from textwrap import dedent
MEM_FORMAT = """ diff --git a/chirp/vx8.py b/chirp/drivers/vx8.py similarity index 99% rename from chirp/vx8.py rename to chirp/drivers/vx8.py index 45fff7a..7f6a752 100644 --- a/chirp/vx8.py +++ b/chirp/drivers/vx8.py @@ -17,8 +17,8 @@ import os import re import logging
-from chirp import chirp_common, yaesu_clone, directory -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, bitwise from chirp.settings import RadioSettingGroup, RadioSetting, RadioSettings from chirp.settings import RadioSettingValueInteger, RadioSettingValueString from chirp.settings import RadioSettingValueList, RadioSettingValueBoolean diff --git a/chirp/vxa700.py b/chirp/drivers/vxa700.py similarity index 100% rename from chirp/vxa700.py rename to chirp/drivers/vxa700.py diff --git a/chirp/wouxun.py b/chirp/drivers/wouxun.py similarity index 99% rename from chirp/wouxun.py rename to chirp/drivers/wouxun.py index 4a3dd0b..2a73f0a 100644 --- a/chirp/wouxun.py +++ b/chirp/drivers/wouxun.py @@ -23,7 +23,7 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettingValueList, \ RadioSettingValueInteger, RadioSettingValueString, \ RadioSettingValueFloat, RadioSettings -from chirp.wouxun_common import wipe_memory, do_download, do_upload +from wouxun_common import wipe_memory, do_download, do_upload from textwrap import dedent
LOG = logging.getLogger(__name__) diff --git a/chirp/wouxun_common.py b/chirp/drivers/wouxun_common.py similarity index 100% rename from chirp/wouxun_common.py rename to chirp/drivers/wouxun_common.py diff --git a/chirp/yaesu_clone.py b/chirp/drivers/yaesu_clone.py similarity index 100% rename from chirp/yaesu_clone.py rename to chirp/drivers/yaesu_clone.py diff --git a/chirpc b/chirpc index 4981374..da19187 100755 --- a/chirpc +++ b/chirpc @@ -22,8 +22,8 @@ import argparse import logging
from chirp import logger -from chirp import * -from chirp import chirp_common, errors, idrp, directory, util +from chirp.drivers import * +from chirp import chirp_common, errors, directory, util
LOG = logging.getLogger("chirpc") RADIOS = directory.DRV_TO_RADIO diff --git a/chirpui/mainapp.py b/chirpui/mainapp.py index e22196a..474b881 100644 --- a/chirpui/mainapp.py +++ b/chirpui/mainapp.py @@ -40,9 +40,9 @@ except ImportError,e: common.log_exception() common.show_error("\nThe Pyserial module is not installed!") from chirp import platform, generic_xml, generic_csv, directory, util -from chirp import ic9x, kenwood_live, idrp, vx7, vx5, vx6 +from chirp.drivers import ic9x, kenwood_live, idrp, vx7, vx5, vx6 +from chirp.drivers import icf, ic9x_icf from chirp import CHIRP_VERSION, chirp_common, detect, errors -from chirp import icf, ic9x_icf from chirpui import editorset, clone, miscwidgets, config, reporting, fips from chirpui import bandplans
diff --git a/chirpui/radiobrowser.py b/chirpui/radiobrowser.py index 14673f9..db03d68 100644 --- a/chirpui/radiobrowser.py +++ b/chirpui/radiobrowser.py @@ -330,7 +330,7 @@ class RadioBrowser(common.Editor):
if __name__ == "__main__": - from chirp import * + from chirp.drivers import * from chirp import directory import sys
diff --git a/chirpw b/chirpw index 073ef50..eab4477 100755 --- a/chirpw +++ b/chirpw @@ -111,7 +111,7 @@ else: # Python >=2.6, use normal gettext behavior lang.install()
-from chirp import * +from chirp.drivers import * from chirpui import mainapp, config
parser = argparse.ArgumentParser() diff --git a/share/make_supported.py b/share/make_supported.py index 61ddf4d..8410fcc 100755 --- a/share/make_supported.py +++ b/share/make_supported.py @@ -9,6 +9,7 @@ sys.path.insert(0, "..") tmp = sys.stdout sys.stdout = sys.stderr from chirp import * +from chirp.drivers import * sys.stdout = tmp
RF = chirp_common.RadioFeatures() diff --git a/tests/run_tests b/tests/run_tests index 26a632b..0c3b15b 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -23,7 +23,7 @@ from serial import Serial sys.path.insert(0, "../")
from chirp import CHIRP_VERSION -from chirp import * +from chirp.drivers import * from chirp import chirp_common, directory, generic_csv, import_logic, memmap, settings from chirp import errors
diff --git a/tests/unit/test_mappingmodel.py b/tests/unit/test_mappingmodel.py index 7ccbc86..2f263d7 100644 --- a/tests/unit/test_mappingmodel.py +++ b/tests/unit/test_mappingmodel.py @@ -15,7 +15,7 @@
from tests.unit import base from chirp import chirp_common -from chirp import icf +from chirp.drivers import icf
class TestBaseMapping(base.BaseTest): diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 5dd6174..a118527 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -2,85 +2,85 @@ # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. ./chirp/__init__.py -./chirp/alinco.py -./chirp/anytone.py -./chirp/ap510.py ./chirp/bandplan_au.py ./chirp/bandplan_iaru_r1.py ./chirp/bandplan_iaru_r2.py ./chirp/bandplan_iaru_r3.py ./chirp/bandplan_na.py -./chirp/baofeng_uv3r.py ./chirp/bitwise.py -./chirp/bjuv55.py ./chirp/chirp_common.py +./chirp/drivers/alinco.py +./chirp/drivers/anytone.py +./chirp/drivers/ap510.py +./chirp/drivers/baofeng_uv3r.py +./chirp/drivers/bjuv55.py +./chirp/drivers/ft1802.py +./chirp/drivers/ft1d.py +./chirp/drivers/ft2800.py +./chirp/drivers/ft50.py +./chirp/drivers/ft50_ll.py +./chirp/drivers/ft60.py +./chirp/drivers/ft7800.py +./chirp/drivers/ft817.py +./chirp/drivers/ft857.py +./chirp/drivers/ft90.py +./chirp/drivers/ftm350.py +./chirp/drivers/h777.py +./chirp/drivers/ic208.py +./chirp/drivers/ic2100.py +./chirp/drivers/ic2200.py +./chirp/drivers/ic2720.py +./chirp/drivers/ic2820.py +./chirp/drivers/ic9x.py +./chirp/drivers/ic9x_icf.py +./chirp/drivers/ic9x_icf_ll.py +./chirp/drivers/ic9x_ll.py +./chirp/drivers/icf.py +./chirp/drivers/icomciv.py +./chirp/drivers/icq7.py +./chirp/drivers/ict70.py +./chirp/drivers/ict8.py +./chirp/drivers/icw32.py +./chirp/drivers/icx8x.py +./chirp/drivers/icx8x_ll.py +./chirp/drivers/id31.py +./chirp/drivers/id800.py +./chirp/drivers/id880.py +./chirp/drivers/idrp.py +./chirp/drivers/kenwood_hmk.py +./chirp/drivers/kenwood_itm.py +./chirp/drivers/kenwood_live.py +./chirp/drivers/kguv8d.py +./chirp/drivers/kyd.py +./chirp/drivers/leixen.py +./chirp/drivers/puxing.py +./chirp/drivers/th9800.py +./chirp/drivers/th_uv3r.py +./chirp/drivers/th_uv3r25.py +./chirp/drivers/th_uvf8d.py +./chirp/drivers/thd72.py +./chirp/drivers/thuv1f.py +./chirp/drivers/tk8102.py +./chirp/drivers/tmv71.py +./chirp/drivers/tmv71_ll.py +./chirp/drivers/uv5r.py +./chirp/drivers/uvb5.py +./chirp/drivers/vx170.py +./chirp/drivers/vx2.py +./chirp/drivers/vx3.py +./chirp/drivers/vx5.py +./chirp/drivers/vx510.py +./chirp/drivers/vx6.py +./chirp/drivers/vx7.py +./chirp/drivers/vx8.py +./chirp/drivers/vxa700.py +./chirp/drivers/wouxun.py +./chirp/drivers/wouxun_common.py +./chirp/drivers/yaesu_clone.py ./chirp/elib_intl.py -./chirp/ft1802.py -./chirp/ft1d.py -./chirp/ft2800.py -./chirp/ft50.py -./chirp/ft50_ll.py -./chirp/ft60.py -./chirp/ft7800.py -./chirp/ft817.py -./chirp/ft857.py -./chirp/ft90.py -./chirp/ftm350.py -./chirp/h777.py -./chirp/ic208.py -./chirp/ic2100.py -./chirp/ic2200.py -./chirp/ic2720.py -./chirp/ic2820.py -./chirp/ic9x.py -./chirp/ic9x_icf.py -./chirp/ic9x_icf_ll.py -./chirp/ic9x_ll.py -./chirp/icf.py -./chirp/icomciv.py -./chirp/icq7.py -./chirp/ict70.py -./chirp/ict8.py -./chirp/icw32.py -./chirp/icx8x.py -./chirp/icx8x_ll.py -./chirp/id31.py -./chirp/id800.py -./chirp/id880.py -./chirp/idrp.py -./chirp/kenwood_hmk.py -./chirp/kenwood_itm.py -./chirp/kenwood_live.py -./chirp/kguv8d.py -./chirp/kyd.py -./chirp/leixen.py -./chirp/puxing.py ./chirp/pyPEG.py ./chirp/rfinder.py ./chirp/settings.py -./chirp/th9800.py -./chirp/th_uv3r.py -./chirp/th_uv3r25.py -./chirp/th_uvf8d.py -./chirp/thd72.py -./chirp/thuv1f.py -./chirp/tk8102.py -./chirp/tmv71.py -./chirp/tmv71_ll.py -./chirp/uv5r.py -./chirp/uvb5.py -./chirp/vx170.py -./chirp/vx2.py -./chirp/vx3.py -./chirp/vx5.py -./chirp/vx510.py -./chirp/vx6.py -./chirp/vx7.py -./chirp/vx8.py -./chirp/vxa700.py -./chirp/wouxun.py -./chirp/wouxun_common.py -./chirp/yaesu_clone.py ./chirpui/common.py ./chirpui/editorset.py ./chirpui/fips.py
On 02/27/2015 02:24 AM, Zach Welch wrote:
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 23bebdb319206bd30abe52d8f4568131304caf95
Move drivers into their own directory (#2351)
D'oh! This patch is no good. I will post a revised patch momentarily.
Sorry for the noise,
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID f89649e5464370b95d55c82c7aca288ac16806cc
[PATCH v2 10/12] Move drivers into their own directory (#2351)
CHIRP now supports enough devices that the chirp/ directory has become cluttered. This creates unnecessary coupling when importing all of these modules. This patch moves all of the drivers to their own directory and then chases down all of the stale import references.
diff --git a/chirp/detect.py b/chirp/detect.py index 580670f..40869d7 100644 --- a/chirp/detect.py +++ b/chirp/detect.py @@ -15,8 +15,8 @@
import serial
-from chirp import errors, icf, directory, ic9x_ll -from chirp import kenwood_live, icomciv +from chirp import errors, directory +from chirp.drivers import ic9x_ll, icf, kenwood_live, icomciv
def _icom_model_data_to_rclass(md): diff --git a/chirp/directory.py b/chirp/directory.py index 7b529e6..0d43bd6 100644 --- a/chirp/directory.py +++ b/chirp/directory.py @@ -18,7 +18,7 @@ import os import tempfile import logging
-from chirp import icf +from chirp.drivers import icf from chirp import chirp_common, util, rfinder, radioreference, errors
LOG = logging.getLogger(__name__) diff --git a/chirp/drivers/__init__.py b/chirp/drivers/__init__.py new file mode 100644 index 0000000..ea9dd2c --- /dev/null +++ b/chirp/drivers/__init__.py @@ -0,0 +1,10 @@ +import os +import sys +from glob import glob + +module_dir = os.path.dirname(sys.modules["chirp.drivers"].__file__) +__all__ = [] +for i in sorted(glob(os.path.join(module_dir, "*.py"))): + name = os.path.basename(i)[:-3] + if not name.startswith("__"): + __all__.append(name) diff --git a/chirp/alinco.py b/chirp/drivers/alinco.py similarity index 100% rename from chirp/alinco.py rename to chirp/drivers/alinco.py diff --git a/chirp/anytone.py b/chirp/drivers/anytone.py similarity index 100% rename from chirp/anytone.py rename to chirp/drivers/anytone.py diff --git a/chirp/ap510.py b/chirp/drivers/ap510.py similarity index 100% rename from chirp/ap510.py rename to chirp/drivers/ap510.py diff --git a/chirp/baofeng_uv3r.py b/chirp/drivers/baofeng_uv3r.py similarity index 99% rename from chirp/baofeng_uv3r.py rename to chirp/drivers/baofeng_uv3r.py index 0827885..c98ab37 100644 --- a/chirp/baofeng_uv3r.py +++ b/chirp/drivers/baofeng_uv3r.py @@ -17,8 +17,8 @@
import time import os +from wouxun_common import do_download, do_upload from chirp import util, chirp_common, bitwise, errors, directory -from chirp.wouxun_common import do_download, do_upload from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettingValueList, \ RadioSettingValueInteger, RadioSettingValueString, \ diff --git a/chirp/bjuv55.py b/chirp/drivers/bjuv55.py similarity index 99% rename from chirp/bjuv55.py rename to chirp/drivers/bjuv55.py index 9fb7e5a..81bc2ed 100644 --- a/chirp/bjuv55.py +++ b/chirp/drivers/bjuv55.py @@ -19,6 +19,7 @@ import struct import time import os
+from chirp.drivers import uv5r from chirp import chirp_common, errors, util, directory, memmap from chirp import bitwise from chirp.settings import RadioSetting, RadioSettingGroup, \ @@ -26,7 +27,6 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettingValueString, \ RadioSettingValueFloat, InvalidValueError, RadioSettings from textwrap import dedent -from chirp import uv5r
BJUV55_MODEL = "\x50\xBB\xDD\x55\x63\x98\x4D"
diff --git a/chirp/ft1802.py b/chirp/drivers/ft1802.py similarity index 98% rename from chirp/ft1802.py rename to chirp/drivers/ft1802.py index 7b5945d..a491907 100644 --- a/chirp/ft1802.py +++ b/chirp/drivers/ft1802.py @@ -23,7 +23,8 @@ # 4. Press the [D/MR(MW)] key ("--WAIT--" will appear on the LCD). # 5. In Chirp, choose Upload to Radio.
-from chirp import chirp_common, bitwise, directory, yaesu_clone +from chirp.drivers import yaesu_clone +from chirp import chirp_common, bitwise, directory from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettings from textwrap import dedent diff --git a/chirp/ft1d.py b/chirp/drivers/ft1d.py similarity index 99% rename from chirp/ft1d.py rename to chirp/drivers/ft1d.py index db0259f..bc01503 100644 --- a/chirp/ft1d.py +++ b/chirp/drivers/ft1d.py @@ -19,8 +19,8 @@ import re import string import logging
-from chirp import chirp_common, yaesu_clone, directory -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, bitwise from chirp.settings import RadioSettingGroup, RadioSetting, RadioSettings from chirp.settings import RadioSettingValueInteger, RadioSettingValueString from chirp.settings import RadioSettingValueList, RadioSettingValueBoolean diff --git a/chirp/ft2800.py b/chirp/drivers/ft2800.py similarity index 99% rename from chirp/ft2800.py rename to chirp/drivers/ft2800.py index feac0ce..d091d7b 100644 --- a/chirp/ft2800.py +++ b/chirp/drivers/ft2800.py @@ -18,7 +18,7 @@ import os import logging
from chirp import util, memmap, chirp_common, bitwise, directory, errors -from chirp.yaesu_clone import YaesuCloneModeRadio +from yaesu_clone import YaesuCloneModeRadio
LOG = logging.getLogger(__name__)
diff --git a/chirp/ft50.py b/chirp/drivers/ft50.py similarity index 95% rename from chirp/ft50.py rename to chirp/drivers/ft50.py index d101360..2f726ec 100644 --- a/chirp/ft50.py +++ b/chirp/drivers/ft50.py @@ -13,7 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, ft50_ll, directory +from chirp.drivers import yaesu_clone, ft50_ll +from chirp import chirp_common, directory
# Not working, don't register #@directory.register diff --git a/chirp/ft50_ll.py b/chirp/drivers/ft50_ll.py similarity index 100% rename from chirp/ft50_ll.py rename to chirp/drivers/ft50_ll.py diff --git a/chirp/ft60.py b/chirp/drivers/ft60.py similarity index 99% rename from chirp/ft60.py rename to chirp/drivers/ft60.py index 74799ef..5720f2d 100644 --- a/chirp/ft60.py +++ b/chirp/drivers/ft60.py @@ -14,8 +14,8 @@ # along with this program. If not, see http://www.gnu.org/licenses/.
import time, os, logging -from chirp import chirp_common, yaesu_clone, memmap, bitwise, directory -from chirp import errors +from chirp.drivers import yaesu_clone +from chirp import chirp_common, memmap, bitwise, directory, errors from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ diff --git a/chirp/ft7800.py b/chirp/drivers/ft7800.py similarity index 99% rename from chirp/ft7800.py rename to chirp/drivers/ft7800.py index 824bd6d..8bd3303 100644 --- a/chirp/ft7800.py +++ b/chirp/drivers/ft7800.py @@ -14,8 +14,8 @@ # along with this program. If not, see http://www.gnu.org/licenses/.
import time, logging -from chirp import chirp_common, yaesu_clone, memmap, directory -from chirp import bitwise, errors +from chirp.drivers import yaesu_clone +from chirp import chirp_common, memmap, directory, bitwise, errors from textwrap import dedent from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ diff --git a/chirp/ft817.py b/chirp/drivers/ft817.py similarity index 99% rename from chirp/ft817.py rename to chirp/drivers/ft817.py index c0b42b2..961636f 100644 --- a/chirp/ft817.py +++ b/chirp/drivers/ft817.py @@ -16,8 +16,8 @@
"""FT817 - FT817ND - FT817ND/US management module"""
-from chirp import chirp_common, yaesu_clone, util, memmap, errors, directory -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, util, memmap, errors, directory, bitwise from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ diff --git a/chirp/ft857.py b/chirp/drivers/ft857.py similarity index 99% rename from chirp/ft857.py rename to chirp/drivers/ft857.py index 940c62d..f5fc33e 100644 --- a/chirp/ft857.py +++ b/chirp/drivers/ft857.py @@ -16,7 +16,8 @@
"""FT857 - FT857/US management module"""
-from chirp import ft817, chirp_common, errors, directory +from chirp.drivers import ft817 +from chirp import chirp_common, errors, directory from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ diff --git a/chirp/ft90.py b/chirp/drivers/ft90.py similarity index 99% rename from chirp/ft90.py rename to chirp/drivers/ft90.py index b638d47..dc7b658 100644 --- a/chirp/ft90.py +++ b/chirp/drivers/ft90.py @@ -14,7 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, bitwise, memmap, directory, errors, util, yaesu_clone +from chirp.drivers import yaesu_clone +from chirp import chirp_common, bitwise, memmap, directory, errors, util from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ diff --git a/chirp/ftm350.py b/chirp/drivers/ftm350.py similarity index 99% rename from chirp/ftm350.py rename to chirp/drivers/ftm350.py index e3fcbfe..564e1a0 100644 --- a/chirp/ftm350.py +++ b/chirp/drivers/ftm350.py @@ -18,8 +18,8 @@ import struct import os import logging
-from chirp import chirp_common, yaesu_clone, directory, errors, util -from chirp import bitwise, memmap +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, errors, util, bitwise, memmap from chirp.settings import RadioSettingGroup, RadioSetting, RadioSettings from chirp.settings import RadioSettingValueInteger, RadioSettingValueString
diff --git a/chirp/generic_csv.py b/chirp/drivers/generic_csv.py similarity index 100% rename from chirp/generic_csv.py rename to chirp/drivers/generic_csv.py diff --git a/chirp/generic_tpe.py b/chirp/drivers/generic_tpe.py similarity index 96% rename from chirp/generic_tpe.py rename to chirp/drivers/generic_tpe.py index a1f0bf6..1d24492 100644 --- a/chirp/generic_tpe.py +++ b/chirp/drivers/generic_tpe.py @@ -14,7 +14,8 @@ # along with this program. If not, see http://www.gnu.org/licenses/.
import UserDict -from chirp import chirp_common, directory, generic_csv +from chirp import chirp_common, directory +from chirp.drivers import generic_csv
@directory.register diff --git a/chirp/generic_xml.py b/chirp/drivers/generic_xml.py similarity index 100% rename from chirp/generic_xml.py rename to chirp/drivers/generic_xml.py diff --git a/chirp/h777.py b/chirp/drivers/h777.py similarity index 100% rename from chirp/h777.py rename to chirp/drivers/h777.py diff --git a/chirp/ic208.py b/chirp/drivers/ic208.py similarity index 98% rename from chirp/ic208.py rename to chirp/drivers/ic208.py index f93300c..9c3bbaa 100644 --- a/chirp/ic208.py +++ b/chirp/drivers/ic208.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, errors, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, errors, directory, bitwise
MEM_FORMAT = """ struct memory { diff --git a/chirp/ic2100.py b/chirp/drivers/ic2100.py similarity index 98% rename from chirp/ic2100.py rename to chirp/drivers/ic2100.py index 0b2dda8..8babe50 100644 --- a/chirp/ic2100.py +++ b/chirp/drivers/ic2100.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, util, directory -from chirp import bitwise, memmap +from chirp.drivers import icf +from chirp import chirp_common, util, directory, bitwise, memmap from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ diff --git a/chirp/ic2200.py b/chirp/drivers/ic2200.py similarity index 98% rename from chirp/ic2200.py rename to chirp/drivers/ic2200.py index d6b1fe2..e059f59 100644 --- a/chirp/ic2200.py +++ b/chirp/drivers/ic2200.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, util, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, util, directory, bitwise
MEM_FORMAT = """ struct { diff --git a/chirp/ic2720.py b/chirp/drivers/ic2720.py similarity index 98% rename from chirp/ic2720.py rename to chirp/drivers/ic2720.py index 24d499a..462c616 100644 --- a/chirp/ic2720.py +++ b/chirp/drivers/ic2720.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, util, directory, bitwise
MEM_FORMAT = """ struct { diff --git a/chirp/ic2820.py b/chirp/drivers/ic2820.py similarity index 99% rename from chirp/ic2820.py rename to chirp/drivers/ic2820.py index 5f5827c..8b507d9 100644 --- a/chirp/ic2820.py +++ b/chirp/drivers/ic2820.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, util, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, util, directory, bitwise
MEM_FORMAT = """ struct { diff --git a/chirp/ic9x.py b/chirp/drivers/ic9x.py similarity index 99% rename from chirp/ic9x.py rename to chirp/drivers/ic9x.py index 3d8c437..5726b09 100644 --- a/chirp/ic9x.py +++ b/chirp/drivers/ic9x.py @@ -16,7 +16,8 @@ import time import threading
-from chirp import chirp_common, errors, ic9x_ll, icf, util, directory +from chirp.drivers import ic9x_ll, icf +from chirp import chirp_common, errors, util, directory from chirp import bitwise
IC9XA_SPECIAL = {} diff --git a/chirp/ic9x_icf.py b/chirp/drivers/ic9x_icf.py similarity index 96% rename from chirp/ic9x_icf.py rename to chirp/drivers/ic9x_icf.py index 9da75b5..666307b 100644 --- a/chirp/ic9x_icf.py +++ b/chirp/drivers/ic9x_icf.py @@ -13,7 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, ic9x_icf_ll, util, directory, errors +from chirp.drivers import icf, ic9x_icf_ll +from chirp import chirp_common, util, directory, errors
# Don't register as this module is used to load icf file from File-Open menu # see do_open in mainapp.py diff --git a/chirp/ic9x_icf_ll.py b/chirp/drivers/ic9x_icf_ll.py similarity index 100% rename from chirp/ic9x_icf_ll.py rename to chirp/drivers/ic9x_icf_ll.py diff --git a/chirp/ic9x_ll.py b/chirp/drivers/ic9x_ll.py similarity index 100% rename from chirp/ic9x_ll.py rename to chirp/drivers/ic9x_ll.py diff --git a/chirp/icf.py b/chirp/drivers/icf.py similarity index 100% rename from chirp/icf.py rename to chirp/drivers/icf.py diff --git a/chirp/icomciv.py b/chirp/drivers/icomciv.py similarity index 99% rename from chirp/icomciv.py rename to chirp/drivers/icomciv.py index 1d02553..fd9090f 100644 --- a/chirp/icomciv.py +++ b/chirp/drivers/icomciv.py @@ -1,6 +1,7 @@
import struct, logging -from chirp import chirp_common, icf, util, errors, bitwise, directory +from chirp.drivers import icf +from chirp import chirp_common, util, errors, bitwise, directory from chirp.memmap import MemoryMap
LOG = logging.getLogger(__name__) diff --git a/chirp/icq7.py b/chirp/drivers/icq7.py similarity index 99% rename from chirp/icq7.py rename to chirp/drivers/icq7.py index 23333fb..ed74f19 100644 --- a/chirp/icq7.py +++ b/chirp/drivers/icq7.py @@ -14,8 +14,8 @@ # along with this program. If not, see http://www.gnu.org/licenses/.
import struct -from chirp import chirp_common, icf, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, directory, bitwise from chirp.chirp_common import to_GHz, from_GHz from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettingValueList, \ diff --git a/chirp/ict70.py b/chirp/drivers/ict70.py similarity index 98% rename from chirp/ict70.py rename to chirp/drivers/ict70.py index d035e14..eb81d7e 100644 --- a/chirp/ict70.py +++ b/chirp/drivers/ict70.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, directory, bitwise
MEM_FORMAT = """ struct { diff --git a/chirp/ict7h.py b/chirp/drivers/ict7h.py similarity index 97% rename from chirp/ict7h.py rename to chirp/drivers/ict7h.py index 768fb34..5648261 100644 --- a/chirp/ict7h.py +++ b/chirp/drivers/ict7h.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, directory, bitwise
mem_format = """ struct { diff --git a/chirp/ict8.py b/chirp/drivers/ict8.py similarity index 97% rename from chirp/ict8.py rename to chirp/drivers/ict8.py index c77d8f3..ea3d82a 100644 --- a/chirp/ict8.py +++ b/chirp/drivers/ict8.py @@ -13,7 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, util, directory +from chirp.drivers import icf +from chirp import chirp_common, util, directory from chirp import bitwise
mem_format = """ diff --git a/chirp/icw32.py b/chirp/drivers/icw32.py similarity index 98% rename from chirp/icw32.py rename to chirp/drivers/icw32.py index 2b028ad..601f113 100644 --- a/chirp/icw32.py +++ b/chirp/drivers/icw32.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, util, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, util, directory, bitwise
MEM_FORMAT = """ #seekto 0x%x; diff --git a/chirp/icx8x.py b/chirp/drivers/icx8x.py similarity index 98% rename from chirp/icx8x.py rename to chirp/drivers/icx8x.py index b9ea35c..776bd74 100644 --- a/chirp/icx8x.py +++ b/chirp/drivers/icx8x.py @@ -13,7 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, icx8x_ll, errors, directory +from chirp.drivers import icf, icx8x_ll +from chirp import chirp_common, errors, directory
def _isuhf(pipe): try: diff --git a/chirp/icx8x_ll.py b/chirp/drivers/icx8x_ll.py similarity index 100% rename from chirp/icx8x_ll.py rename to chirp/drivers/icx8x_ll.py diff --git a/chirp/id31.py b/chirp/drivers/id31.py similarity index 99% rename from chirp/id31.py rename to chirp/drivers/id31.py index 128d79d..7c91b02 100644 --- a/chirp/id31.py +++ b/chirp/drivers/id31.py @@ -13,7 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import directory, icf, bitwise, chirp_common +from chirp.drivers import icf +from chirp import directory, bitwise, chirp_common
MEM_FORMAT = """ struct { diff --git a/chirp/id51.py b/chirp/drivers/id51.py similarity index 96% rename from chirp/id51.py rename to chirp/drivers/id51.py index 4b72c44..b1b5c65 100644 --- a/chirp/id51.py +++ b/chirp/drivers/id51.py @@ -13,7 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import directory, bitwise, id31 +from chirp.drivers import id31 +from chirp import directory, bitwise
MEM_FORMAT = """ struct { diff --git a/chirp/id800.py b/chirp/drivers/id800.py similarity index 99% rename from chirp/id800.py rename to chirp/drivers/id800.py index 56350de..c0d233a 100644 --- a/chirp/id800.py +++ b/chirp/drivers/id800.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, errors, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, errors, directory, bitwise
MEM_FORMAT = """ #seekto 0x0020; diff --git a/chirp/id880.py b/chirp/drivers/id880.py similarity index 99% rename from chirp/id880.py rename to chirp/drivers/id880.py index b6c8b39..3639b30 100644 --- a/chirp/id880.py +++ b/chirp/drivers/id880.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, icf, directory -from chirp import bitwise +from chirp.drivers import icf +from chirp import chirp_common, directory, bitwise
MEM_FORMAT = """ struct { diff --git a/chirp/idrp.py b/chirp/drivers/idrp.py similarity index 100% rename from chirp/idrp.py rename to chirp/drivers/idrp.py diff --git a/chirp/kenwood_hmk.py b/chirp/drivers/kenwood_hmk.py similarity index 97% rename from chirp/kenwood_hmk.py rename to chirp/drivers/kenwood_hmk.py index 59260ac..cff0162 100644 --- a/chirp/kenwood_hmk.py +++ b/chirp/drivers/kenwood_hmk.py @@ -16,7 +16,8 @@
import csv
-from chirp import chirp_common, errors, directory, generic_csv +from chirp import chirp_common, errors, directory +from chirp.drivers import generic_csv
class OmittedHeaderError(Exception): """An internal exception to indicate that a header was omitted""" diff --git a/chirp/kenwood_itm.py b/chirp/drivers/kenwood_itm.py similarity index 97% rename from chirp/kenwood_itm.py rename to chirp/drivers/kenwood_itm.py index 86414eb..a5fc8c2 100644 --- a/chirp/kenwood_itm.py +++ b/chirp/drivers/kenwood_itm.py @@ -16,7 +16,8 @@
import csv
-from chirp import chirp_common, errors, directory, generic_csv +from chirp import chirp_common, errors, directory +from chirp.drivers import generic_csv
class OmittedHeaderError(Exception): """An internal exception to indicate that a header was omitted""" diff --git a/chirp/kenwood_live.py b/chirp/drivers/kenwood_live.py similarity index 100% rename from chirp/kenwood_live.py rename to chirp/drivers/kenwood_live.py diff --git a/chirp/kguv8d.py b/chirp/drivers/kguv8d.py similarity index 100% rename from chirp/kguv8d.py rename to chirp/drivers/kguv8d.py diff --git a/chirp/kyd.py b/chirp/drivers/kyd.py similarity index 100% rename from chirp/kyd.py rename to chirp/drivers/kyd.py diff --git a/chirp/leixen.py b/chirp/drivers/leixen.py similarity index 100% rename from chirp/leixen.py rename to chirp/drivers/leixen.py diff --git a/chirp/puxing.py b/chirp/drivers/puxing.py similarity index 99% rename from chirp/puxing.py rename to chirp/drivers/puxing.py index f38b41e..ddfee1a 100644 --- a/chirp/puxing.py +++ b/chirp/drivers/puxing.py @@ -18,7 +18,7 @@ import time import os from chirp import util, chirp_common, bitwise, errors, directory -from chirp.wouxun_common import wipe_memory, do_download, do_upload +from chirp.drivers.wouxun import wipe_memory, do_download, do_upload
def _puxing_prep(radio): radio.pipe.write("\x02PROGRA") diff --git a/chirp/template.py b/chirp/drivers/template.py similarity index 100% rename from chirp/template.py rename to chirp/drivers/template.py diff --git a/chirp/th9800.py b/chirp/drivers/th9800.py similarity index 99% rename from chirp/th9800.py rename to chirp/drivers/th9800.py index d1a1b0b..1f1d498 100644 --- a/chirp/th9800.py +++ b/chirp/drivers/th9800.py @@ -21,7 +21,7 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ RadioSettingValueFloat, InvalidValueError, RadioSettings -from chirp_common import format_freq +from chirp.chirp_common import format_freq import os import time import logging diff --git a/chirp/th_uv3r.py b/chirp/drivers/th_uv3r.py similarity index 99% rename from chirp/th_uv3r.py rename to chirp/drivers/th_uv3r.py index 3b670fe..77df451 100644 --- a/chirp/th_uv3r.py +++ b/chirp/drivers/th_uv3r.py @@ -17,7 +17,7 @@
import os from chirp import chirp_common, bitwise, errors, directory -from chirp.wouxun_common import do_download, do_upload +from chirp.drivers.wouxun import do_download, do_upload
def tyt_uv3r_prep(radio): try: diff --git a/chirp/th_uv3r25.py b/chirp/drivers/th_uv3r25.py similarity index 99% rename from chirp/th_uv3r25.py rename to chirp/drivers/th_uv3r25.py index e9b4cbb..35a3fa4 100644 --- a/chirp/th_uv3r25.py +++ b/chirp/drivers/th_uv3r25.py @@ -16,7 +16,7 @@ """TYT uv3r (2.5kHz) radio management module"""
from chirp import chirp_common, bitwise, directory -from chirp.wouxun_common import do_download, do_upload +from chirp.drivers.wouxun import do_download, do_upload
from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ diff --git a/chirp/th_uvf8d.py b/chirp/drivers/th_uvf8d.py similarity index 100% rename from chirp/th_uvf8d.py rename to chirp/drivers/th_uvf8d.py diff --git a/chirp/thd72.py b/chirp/drivers/thd72.py similarity index 100% rename from chirp/thd72.py rename to chirp/drivers/thd72.py diff --git a/chirp/thuv1f.py b/chirp/drivers/thuv1f.py similarity index 100% rename from chirp/thuv1f.py rename to chirp/drivers/thuv1f.py diff --git a/chirp/tk8102.py b/chirp/drivers/tk8102.py similarity index 100% rename from chirp/tk8102.py rename to chirp/drivers/tk8102.py diff --git a/chirp/tmv71.py b/chirp/drivers/tmv71.py similarity index 98% rename from chirp/tmv71.py rename to chirp/drivers/tmv71.py index 59ef226..cca737a 100644 --- a/chirp/tmv71.py +++ b/chirp/drivers/tmv71.py @@ -14,7 +14,7 @@ # along with this program. If not, see http://www.gnu.org/licenses/.
from chirp import chirp_common, errors, util -from chirp import tmv71_ll +from chirp.drivers import tmv71_ll
class TMV71ARadio(chirp_common.CloneModeRadio): BAUD_RATE = 9600 diff --git a/chirp/tmv71_ll.py b/chirp/drivers/tmv71_ll.py similarity index 100% rename from chirp/tmv71_ll.py rename to chirp/drivers/tmv71_ll.py diff --git a/chirp/uv5r.py b/chirp/drivers/uv5r.py similarity index 100% rename from chirp/uv5r.py rename to chirp/drivers/uv5r.py diff --git a/chirp/uvb5.py b/chirp/drivers/uvb5.py similarity index 100% rename from chirp/uvb5.py rename to chirp/drivers/uvb5.py diff --git a/chirp/vx170.py b/chirp/drivers/vx170.py similarity index 96% rename from chirp/vx170.py rename to chirp/drivers/vx170.py index eaa7dbc..347951d 100644 --- a/chirp/vx170.py +++ b/chirp/drivers/vx170.py @@ -13,11 +13,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, directory, memmap -from chirp import bitwise, errors +from chirp.drivers import yaesu_clone, ft7800 +from chirp import chirp_common, directory, memmap, bitwise, errors from textwrap import dedent import time, os -from chirp import ft7800
MEM_FORMAT = """ #seekto 0x018A; diff --git a/chirp/vx2.py b/chirp/drivers/vx2.py similarity index 99% rename from chirp/vx2.py rename to chirp/drivers/vx2.py index 6c6b912..42c7ba8 100644 --- a/chirp/vx2.py +++ b/chirp/drivers/vx2.py @@ -14,7 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, directory, bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, bitwise from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ diff --git a/chirp/vx3.py b/chirp/drivers/vx3.py similarity index 99% rename from chirp/vx3.py rename to chirp/drivers/vx3.py index 0575a46..6bd2973 100644 --- a/chirp/vx3.py +++ b/chirp/drivers/vx3.py @@ -14,8 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, directory -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, bitwise from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ diff --git a/chirp/vx5.py b/chirp/drivers/vx5.py similarity index 98% rename from chirp/vx5.py rename to chirp/drivers/vx5.py index 65a5ba4..61bce15 100644 --- a/chirp/vx5.py +++ b/chirp/drivers/vx5.py @@ -14,8 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, directory, errors -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, errors, bitwise
MEM_FORMAT = """ #seekto 0x002A; diff --git a/chirp/vx510.py b/chirp/drivers/vx510.py similarity index 98% rename from chirp/vx510.py rename to chirp/drivers/vx510.py index 7f287a9..16a9026 100644 --- a/chirp/vx510.py +++ b/chirp/drivers/vx510.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, directory -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, bitwise
# This driver is unfinished and therefore does not register itself with Chirp. # diff --git a/chirp/vx6.py b/chirp/drivers/vx6.py similarity index 99% rename from chirp/vx6.py rename to chirp/drivers/vx6.py index 0cdb115..467c9de 100644 --- a/chirp/vx6.py +++ b/chirp/drivers/vx6.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, directory -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, bitwise from textwrap import dedent
# flags.{even|odd}_pskip: These are actually "preferential *scan* channels". diff --git a/chirp/vx7.py b/chirp/drivers/vx7.py similarity index 99% rename from chirp/vx7.py rename to chirp/drivers/vx7.py index 5fff4b1..d63bf32 100644 --- a/chirp/vx7.py +++ b/chirp/drivers/vx7.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-from chirp import chirp_common, yaesu_clone, directory -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, bitwise from textwrap import dedent
MEM_FORMAT = """ diff --git a/chirp/vx8.py b/chirp/drivers/vx8.py similarity index 99% rename from chirp/vx8.py rename to chirp/drivers/vx8.py index 45fff7a..7f6a752 100644 --- a/chirp/vx8.py +++ b/chirp/drivers/vx8.py @@ -17,8 +17,8 @@ import os import re import logging
-from chirp import chirp_common, yaesu_clone, directory -from chirp import bitwise +from chirp.drivers import yaesu_clone +from chirp import chirp_common, directory, bitwise from chirp.settings import RadioSettingGroup, RadioSetting, RadioSettings from chirp.settings import RadioSettingValueInteger, RadioSettingValueString from chirp.settings import RadioSettingValueList, RadioSettingValueBoolean diff --git a/chirp/vxa700.py b/chirp/drivers/vxa700.py similarity index 100% rename from chirp/vxa700.py rename to chirp/drivers/vxa700.py diff --git a/chirp/wouxun.py b/chirp/drivers/wouxun.py similarity index 99% rename from chirp/wouxun.py rename to chirp/drivers/wouxun.py index 4a3dd0b..2a73f0a 100644 --- a/chirp/wouxun.py +++ b/chirp/drivers/wouxun.py @@ -23,7 +23,7 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettingValueList, \ RadioSettingValueInteger, RadioSettingValueString, \ RadioSettingValueFloat, RadioSettings -from chirp.wouxun_common import wipe_memory, do_download, do_upload +from wouxun_common import wipe_memory, do_download, do_upload from textwrap import dedent
LOG = logging.getLogger(__name__) diff --git a/chirp/wouxun_common.py b/chirp/drivers/wouxun_common.py similarity index 100% rename from chirp/wouxun_common.py rename to chirp/drivers/wouxun_common.py diff --git a/chirp/yaesu_clone.py b/chirp/drivers/yaesu_clone.py similarity index 100% rename from chirp/yaesu_clone.py rename to chirp/drivers/yaesu_clone.py diff --git a/chirpc b/chirpc index 4981374..da19187 100755 --- a/chirpc +++ b/chirpc @@ -22,8 +22,8 @@ import argparse import logging
from chirp import logger -from chirp import * -from chirp import chirp_common, errors, idrp, directory, util +from chirp.drivers import * +from chirp import chirp_common, errors, directory, util
LOG = logging.getLogger("chirpc") RADIOS = directory.DRV_TO_RADIO diff --git a/chirpui/editorset.py b/chirpui/editorset.py index 520463f..fd83559 100644 --- a/chirpui/editorset.py +++ b/chirpui/editorset.py @@ -17,7 +17,8 @@ import os import gtk import gobject
-from chirp import chirp_common, directory, generic_csv, generic_xml +from chirp import chirp_common, directory +from chirp.drivers import generic_csv, generic_xml from chirpui import memedit, dstaredit, bankedit, common, importdialog from chirpui import inputdialog, reporting, settingsedit, radiobrowser, config
diff --git a/chirpui/importdialog.py b/chirpui/importdialog.py index b7417ce..8b8bc3c 100644 --- a/chirpui/importdialog.py +++ b/chirpui/importdialog.py @@ -17,7 +17,8 @@ import gtk import gobject import pango
-from chirp import errors, chirp_common, generic_xml, import_logic +from chirp import errors, chirp_common, import_logic +from chirp.drivers import generic_xml from chirpui import common
class WaitWindow(gtk.Window): diff --git a/chirpui/mainapp.py b/chirpui/mainapp.py index e22196a..fbf1fe3 100644 --- a/chirpui/mainapp.py +++ b/chirpui/mainapp.py @@ -39,10 +39,11 @@ try: except ImportError,e: common.log_exception() common.show_error("\nThe Pyserial module is not installed!") -from chirp import platform, generic_xml, generic_csv, directory, util -from chirp import ic9x, kenwood_live, idrp, vx7, vx5, vx6 +from chirp import platform, directory, util +from chirp.drivers import generic_xml, generic_csv +from chirp.drivers import ic9x, kenwood_live, idrp, vx7, vx5, vx6 +from chirp.drivers import icf, ic9x_icf from chirp import CHIRP_VERSION, chirp_common, detect, errors -from chirp import icf, ic9x_icf from chirpui import editorset, clone, miscwidgets, config, reporting, fips from chirpui import bandplans
diff --git a/chirpui/radiobrowser.py b/chirpui/radiobrowser.py index 14673f9..db03d68 100644 --- a/chirpui/radiobrowser.py +++ b/chirpui/radiobrowser.py @@ -330,7 +330,7 @@ class RadioBrowser(common.Editor):
if __name__ == "__main__": - from chirp import * + from chirp.drivers import * from chirp import directory import sys
diff --git a/chirpw b/chirpw index 073ef50..eab4477 100755 --- a/chirpw +++ b/chirpw @@ -111,7 +111,7 @@ else: # Python >=2.6, use normal gettext behavior lang.install()
-from chirp import * +from chirp.drivers import * from chirpui import mainapp, config
parser = argparse.ArgumentParser() diff --git a/share/make_supported.py b/share/make_supported.py index 61ddf4d..8410fcc 100755 --- a/share/make_supported.py +++ b/share/make_supported.py @@ -9,6 +9,7 @@ sys.path.insert(0, "..") tmp = sys.stdout sys.stdout = sys.stderr from chirp import * +from chirp.drivers import * sys.stdout = tmp
RF = chirp_common.RadioFeatures() diff --git a/tests/run_tests b/tests/run_tests index 26a632b..60af5a2 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -23,8 +23,8 @@ from serial import Serial sys.path.insert(0, "../")
from chirp import CHIRP_VERSION -from chirp import * -from chirp import chirp_common, directory, generic_csv, import_logic, memmap, settings +from chirp.drivers import * +from chirp import chirp_common, directory, import_logic, memmap, settings from chirp import errors
TESTS = {} diff --git a/tests/unit/test_mappingmodel.py b/tests/unit/test_mappingmodel.py index 7ccbc86..2f263d7 100644 --- a/tests/unit/test_mappingmodel.py +++ b/tests/unit/test_mappingmodel.py @@ -15,7 +15,7 @@
from tests.unit import base from chirp import chirp_common -from chirp import icf +from chirp.drivers import icf
class TestBaseMapping(base.BaseTest): diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 5dd6174..a118527 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -2,85 +2,85 @@ # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. ./chirp/__init__.py -./chirp/alinco.py -./chirp/anytone.py -./chirp/ap510.py ./chirp/bandplan_au.py ./chirp/bandplan_iaru_r1.py ./chirp/bandplan_iaru_r2.py ./chirp/bandplan_iaru_r3.py ./chirp/bandplan_na.py -./chirp/baofeng_uv3r.py ./chirp/bitwise.py -./chirp/bjuv55.py ./chirp/chirp_common.py +./chirp/drivers/alinco.py +./chirp/drivers/anytone.py +./chirp/drivers/ap510.py +./chirp/drivers/baofeng_uv3r.py +./chirp/drivers/bjuv55.py +./chirp/drivers/ft1802.py +./chirp/drivers/ft1d.py +./chirp/drivers/ft2800.py +./chirp/drivers/ft50.py +./chirp/drivers/ft50_ll.py +./chirp/drivers/ft60.py +./chirp/drivers/ft7800.py +./chirp/drivers/ft817.py +./chirp/drivers/ft857.py +./chirp/drivers/ft90.py +./chirp/drivers/ftm350.py +./chirp/drivers/h777.py +./chirp/drivers/ic208.py +./chirp/drivers/ic2100.py +./chirp/drivers/ic2200.py +./chirp/drivers/ic2720.py +./chirp/drivers/ic2820.py +./chirp/drivers/ic9x.py +./chirp/drivers/ic9x_icf.py +./chirp/drivers/ic9x_icf_ll.py +./chirp/drivers/ic9x_ll.py +./chirp/drivers/icf.py +./chirp/drivers/icomciv.py +./chirp/drivers/icq7.py +./chirp/drivers/ict70.py +./chirp/drivers/ict8.py +./chirp/drivers/icw32.py +./chirp/drivers/icx8x.py +./chirp/drivers/icx8x_ll.py +./chirp/drivers/id31.py +./chirp/drivers/id800.py +./chirp/drivers/id880.py +./chirp/drivers/idrp.py +./chirp/drivers/kenwood_hmk.py +./chirp/drivers/kenwood_itm.py +./chirp/drivers/kenwood_live.py +./chirp/drivers/kguv8d.py +./chirp/drivers/kyd.py +./chirp/drivers/leixen.py +./chirp/drivers/puxing.py +./chirp/drivers/th9800.py +./chirp/drivers/th_uv3r.py +./chirp/drivers/th_uv3r25.py +./chirp/drivers/th_uvf8d.py +./chirp/drivers/thd72.py +./chirp/drivers/thuv1f.py +./chirp/drivers/tk8102.py +./chirp/drivers/tmv71.py +./chirp/drivers/tmv71_ll.py +./chirp/drivers/uv5r.py +./chirp/drivers/uvb5.py +./chirp/drivers/vx170.py +./chirp/drivers/vx2.py +./chirp/drivers/vx3.py +./chirp/drivers/vx5.py +./chirp/drivers/vx510.py +./chirp/drivers/vx6.py +./chirp/drivers/vx7.py +./chirp/drivers/vx8.py +./chirp/drivers/vxa700.py +./chirp/drivers/wouxun.py +./chirp/drivers/wouxun_common.py +./chirp/drivers/yaesu_clone.py ./chirp/elib_intl.py -./chirp/ft1802.py -./chirp/ft1d.py -./chirp/ft2800.py -./chirp/ft50.py -./chirp/ft50_ll.py -./chirp/ft60.py -./chirp/ft7800.py -./chirp/ft817.py -./chirp/ft857.py -./chirp/ft90.py -./chirp/ftm350.py -./chirp/h777.py -./chirp/ic208.py -./chirp/ic2100.py -./chirp/ic2200.py -./chirp/ic2720.py -./chirp/ic2820.py -./chirp/ic9x.py -./chirp/ic9x_icf.py -./chirp/ic9x_icf_ll.py -./chirp/ic9x_ll.py -./chirp/icf.py -./chirp/icomciv.py -./chirp/icq7.py -./chirp/ict70.py -./chirp/ict8.py -./chirp/icw32.py -./chirp/icx8x.py -./chirp/icx8x_ll.py -./chirp/id31.py -./chirp/id800.py -./chirp/id880.py -./chirp/idrp.py -./chirp/kenwood_hmk.py -./chirp/kenwood_itm.py -./chirp/kenwood_live.py -./chirp/kguv8d.py -./chirp/kyd.py -./chirp/leixen.py -./chirp/puxing.py ./chirp/pyPEG.py ./chirp/rfinder.py ./chirp/settings.py -./chirp/th9800.py -./chirp/th_uv3r.py -./chirp/th_uv3r25.py -./chirp/th_uvf8d.py -./chirp/thd72.py -./chirp/thuv1f.py -./chirp/tk8102.py -./chirp/tmv71.py -./chirp/tmv71_ll.py -./chirp/uv5r.py -./chirp/uvb5.py -./chirp/vx170.py -./chirp/vx2.py -./chirp/vx3.py -./chirp/vx5.py -./chirp/vx510.py -./chirp/vx6.py -./chirp/vx7.py -./chirp/vx8.py -./chirp/vxa700.py -./chirp/wouxun.py -./chirp/wouxun_common.py -./chirp/yaesu_clone.py ./chirpui/common.py ./chirpui/editorset.py ./chirpui/fips.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID f89649e5464370b95d55c82c7aca288ac16806cc
[PATCH v2 10/12] Move drivers into their own directory (#2351)
I'm holding off on applying this until I hear from Jim, Marco, and Tom. All of which probably have patches pending against the tree who will be affected by this.
As much as I hate to do it, it's probably the right thing to do, but since it's not urgent, we can do it whenever it's most convenient.
--Dan
On 02/27/2015 03:58 PM, Dan Smith wrote:
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID f89649e5464370b95d55c82c7aca288ac16806cc
[PATCH v2 10/12] Move drivers into their own directory (#2351)
I'm holding off on applying this until I hear from Jim, Marco, and Tom. All of which probably have patches pending against the tree who will be affected by this.
As much as I hate to do it, it's probably the right thing to do, but since it's not urgent, we can do it whenever it's most convenient.
I know that git makes it trivially easy to rebase through file renames, and I expect hg has similar abilities. Moreover, I would be shocked if the actual changes conflicted with their patches, as I only touched the import statements at the top of the file. Worst case, it would be one or two lines to fix up, right?
Still, I agree it would be best to get their feedback. I will keep these changes in my active stack of patches, but I will leave it at the end so it won't block other patches.
I know that git makes it trivially easy to rebase through file renames, and I expect hg has similar abilities. Moreover, I would be shocked if the actual changes conflicted with their patches, as I only touched the import statements at the top of the file. Worst case, it would be one or two lines to fix up, right?
No, the mq workflow is keeping patches on disk. When they're applied, they're commits, but when they're not, they're patches. You generally can't do anything like a rebase while patches are applied, so you don't get any help on things like renames.
--Dan
On Fri, Feb 27, 2015 at 6:58 PM, Dan Smith dsmith@danplanet.com wrote:
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID f89649e5464370b95d55c82c7aca288ac16806cc
[PATCH v2 10/12] Move drivers into their own directory (#2351)
I'm holding off on applying this until I hear from Jim, Marco, and Tom. All of which probably have patches pending against the tree who will be affected by this.
As much as I hate to do it, it's probably the right thing to do, but since it's not urgent, we can do it whenever it's most convenient.
--Dan
I don't have anything pending at the moment.
Jim
On 28/02/2015 00:58, Dan Smith wrote:
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID f89649e5464370b95d55c82c7aca288ac16806cc
[PATCH v2 10/12] Move drivers into their own directory (#2351)
I'm holding off on applying this until I hear from Jim, Marco, and Tom. All of which probably have patches pending against the tree who will be affected by this.
I instead have some patches (including pep8) to prepare but I'm waiting to avoid collisions with Zach work. From my point of view GO!
73 de IZ3GME Marco
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 4072d4301c865abcded0a46d88716cc700aeac77
Adjust setup.py for relocated drivers (#2351)
This patch update setup.py to work with the moved drivers.
diff --git a/setup.py b/setup.py index b923670..b9048e5 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import sys import os
from chirp import CHIRP_VERSION -from chirp import * +from chirp.drivers import * import chirp
@@ -11,12 +11,20 @@ def staticify_chirp_module(): import chirp
with file("chirp/__init__.py", "w") as init: - print >>init, "CHIRP_VERSION = "%s"" % CHIRP_VERSION print >>init, "__all__ = %s\n" % str(chirp.__all__)
print "Set chirp/__init__.py::__all__ = %s" % str(chirp.__all__)
+def staticify_drivers_module(): + import chirp + + with file("chirp/drivers/__init__.py", "w") as init: + print >>init, "__all__ = %s\n" % str(chirp.__all__) + + print "Set chirp/drivers/__init__.py::__all__ = %s" % str(chirp.__all__) + + def win32_build(): from distutils.core import setup import py2exe @@ -37,6 +45,7 @@ def win32_build(): pass
staticify_chirp_module() + staticify_drivers_module()
opts = { "py2exe": { @@ -52,7 +61,7 @@ def win32_build(): }
mods = [] - for mod in chirp.__all__: + for mod in chirp.__all__, chirp.drivers.__all__: mods.append("chirp.%s" % mod) opts["py2exe"]["includes"] += ("," + ",".join(mods))
@@ -110,7 +119,7 @@ def default_build():
setup( name="chirp", - packages=["chirp", "chirpui"], + packages=["chirp", "chirp.drivers", "chirpui"], version=CHIRP_VERSION, scripts=["chirpw"], data_files=[('share/applications', desktop_files),
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID ec876b2c27ad8f72d1881fe505edcb8985c693ec
Allow run_tests to be run from anywhere (#2343)
Find the path to run_tests, then chdir into the tests directory.
diff --git a/tests/run_tests b/tests/run_tests index 0c3b15b..2dae5e5 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -19,7 +19,10 @@ import traceback, sys, os, shutil, glob, tempfile, time from optparse import OptionParser from serial import Serial
-# Assume we're running in the tests/ directory of the archive +# change to the tests directory +scriptdir = os.path.dirname(sys.argv[0]) +os.chdir(scriptdir) + sys.path.insert(0, "../")
from chirp import CHIRP_VERSION
participants (5)
-
Dan Smith
-
IZ3GME Marco
-
Jim Unroe
-
Kosta Arvanitis
-
Zach Welch