[chirp_devel] [PATCH v2 0/7] logging, style, and drivers... oh, my!
This series contains largely the same patches that I posted yesterday, revised to accomodate the feedback that they received. Here are the highlights of the changes since the first version:
In addition to fixing the reported bugs, the logger module now truncates the log file when it is opened. The version module has been folded into the logger module, so the version string can be written to the beginning of the log file.
The new pep8 helper script has been moved into the tools/ directory, and I integrated it with the run_all_tests script.
The chirp drivers are now located in chirp/drivers/. I verified that the patch correctly imports into the hg repo; 'hg log --follow' works. The trick here is to use 'git format-patch -C'.
Zach Welch (7): Add chirp.logger module (#2347) Use new logger module (#2347) Suppress startup debugging messages (#2347) Add pep8 checker script (#2355) fix style issues (#2355) Fix some style issues (#2355) Move drivers into their own directory (#2351)
chirp/bandplan.py | 3 +- chirp/detect.py | 4 +- chirp/directory.py | 9 +- 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 | 34 ++- chirp/{ => drivers}/ft857.py | 12 +- chirp/{ => drivers}/ft90.py | 56 ++-- chirp/{ => drivers}/ftm350.py | 11 +- 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}/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/logger.py | 155 +++++++++++ chirpc | 498 ++++++++++++++++++----------------- chirpui/mainapp.py | 9 +- chirpui/radiobrowser.py | 2 +- chirpui/reporting.py | 32 ++- chirpw | 46 ++-- csvdump/__init__.py | 1 - locale/check_parameters.py | 15 +- run_all_tests.sh | 10 +- share/make_supported.py | 1 + tests/run_tests | 2 +- 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/pep8.blacklist | 133 ++++++++++ tools/pep8.manifest | 4 + tools/pep8.py | 75 ++++++ 94 files changed, 1015 insertions(+), 695 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}/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}/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 chirp/logger.py create mode 100644 tools/pep8.blacklist create mode 100644 tools/pep8.manifest create mode 100755 tools/pep8.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com
Add chirp.logger module (#2347)
This patch adds the chirp.logger module, using it in chirpc and chirpw. It adds a handful of optional command line arguments to control the new logging features. In addition, CHIRP_DEBUG, CHIRP_LOG, and CHIRP_LOG_LEVEL can be used to control the logging features from the environment.
It also makes the version string reusable between the GUI and CLI, and it prints that string at the start of the log file (if in use).
diff --git a/chirp/logger.py b/chirp/logger.py new file mode 100644 index 0000000..4cf8fa2 --- /dev/null +++ b/chirp/logger.py @@ -0,0 +1,155 @@ +# 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/. + + +r""" +The chirp.logger module provides the core logging facilties for CHIRP. +It sets up the console and (optionally) a log file. For early debugging, +it checks the CHIRP_DEBUG, CHIRP_LOG, and CHIRP_LOG_LEVEL environment +variables. +""" + +import os +import sys +import logging +import argparse +import platform +from chirp import CHIRP_VERSION + + +def version_string(): + args = (CHIRP_VERSION, + platform.get_platform().os_version_string(), + sys.version.split()[0]) + return "CHIRP %s on %s (Python %s)" % args + + +class VersionAction(argparse.Action): + def __call__(self, parser, namespace, value, option_string=None): + print version_string() + sys.exit(1) + + +def add_version_argument(parser): + parser.add_argument("--version", action=VersionAction, nargs=0, + help="Print version and exit") + +#: Map human-readable logging levels to their internal values. +log_level_names = {"critical": logging.CRITICAL, + "error": logging.ERROR, + "warn": logging.WARNING, + "info": logging.INFO, + "debug": logging.DEBUG, + } + + +class Logger(object): + def __init__(self): + # create root logger + self.logger = logging.getLogger() + self.logger.setLevel(logging.DEBUG) + + self.LOG = logging.getLogger(__name__) + + # Set CHIRP_DEBUG in environment for early console debugging. + # 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 + if CHIRP_DEBUG: + try: + level = int(CHIRP_DEBUG) + except ValueError: + try: + 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.logger.addHandler(self.console) + + # Set CHIRP_LOG in environment to the name of log file. + logname = os.getenv("CHIRP_LOG") + self.logfile = None + if logname is not None: + self.create_log_file(logname) + level = os.getenv("CHIRP_LOG_LEVEL") + if level is not None: + self.set_log_verbosity(level) + else: + self.set_log_level(logging.DEBUG) + + def create_log_file(self, name): + if self.logfile is None: + self.logname = name + lf = file(name, "w") + print >>lf, version_string() + lf.close() + self.logfile = logging.FileHandler(name) + format_str = '[%(created)s] %(name)s - %(levelname)s: %(message)s' + 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): + if level > logging.CRITICAL: + level = logging.CRITICAL + self.console.setLevel(level) + self.LOG.debug("verbosity=%d", level) + + def set_log_level(self, 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]) + + instance = None + +Logger.instance = Logger() + + +def add_arguments(parser): + parser.add_argument("-q", "--quiet", action="count", default=0, + help="Decrease verbosity") + parser.add_argument("-v", "--verbose", action="count", default=0, + help="Increase verbosity") + parser.add_argument("--log", dest="log_file", action="store", default=0, + help="Log messages to a file") + parser.add_argument("--log-level", action="store", default="debug", + help="Log file verbosity (critical, error, warn, " + + "info, debug). Defaults to 'debug'.") + + +def handle_options(options): + logger = Logger.instance + + if options.verbose or options.quiet: + logger.set_verbosity(30 + 10 * (options.quiet - options.verbose)) + + if options.log_file: + logger.create_log_file(options.log_file) + try: + level = int(options.log_level) + logger.set_log_level(level) + except ValueError: + logger.set_log_level_by_name(options.log_level) 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..b11ab0f 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 @@ -40,10 +41,6 @@ elif not os.isatty(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 +124,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:
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com
Can you put the git hash into this block? When people send multiple copies of the same patch before I get far enough to run the patchbot on them, I use the NodeID to make sure I'm applying the thing I'm reviewing in my mailer. The git hash would give me that for your patches as well.
+#: Map human-readable logging levels to their internal values. +log_level_names = {"critical": logging.CRITICAL,
"error": logging.ERROR,
"warn": logging.WARNING,
"info": logging.INFO,
"debug": logging.DEBUG,
}
My point in the other patch was that you shouldn't replicate the level names here when you can get them from the library. But I think the point here is to let you do CHIRP_DEBUG=info, which means they needn't be the canonical strings anyway, so, that's fine.
- def create_log_file(self, name):
if self.logfile is None:
self.logname = name
lf = file(name, "w")
print >>lf, version_string()
lf.close()
What is the point of writing the raw string into the file before we open it? That said, the above should be this for consistency:
with file(name, 'w') as lf: print >>lf, version_string()
Which auto-closes the file. Since this is at the bottom of the stack, I'll apply, but I think we should go back and just remove that (or turn it into a log), unless there is some reason I'm missing.
--Dan
On 02/26/2015 04:18 PM, Dan Smith wrote:
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com
Can you put the git hash into this block? When people send multiple copies of the same patch before I get far enough to run the patchbot on them, I use the NodeID to make sure I'm applying the thing I'm reviewing in my mailer. The git hash would give me that for your patches as well.
I will see what I can do. It does not appear anywhere in the original patches, and I don't see an option that will add it. A quick web search also failed to turn up a solution. I can make it happen, but it may take a little creativity (and time) on my part.
That said, I could just fake it, since it's apples to oranges anyway. As long as it's unique for each patch, it should serve for the purpose that you describe, yah? That would be fairly easy to add; in the git-patch-to-hg-patch script, hash the original email message (which includes a time/date string) and then emit it as part of the body.
+#: Map human-readable logging levels to their internal values. +log_level_names = {"critical": logging.CRITICAL,
"error": logging.ERROR,
"warn": logging.WARNING,
"info": logging.INFO,
"debug": logging.DEBUG,
}
My point in the other patch was that you shouldn't replicate the level names here when you can get them from the library. But I think the point here is to let you do CHIRP_DEBUG=info, which means they needn't be the canonical strings anyway, so, that's fine.
That's the point, yes. Again, I couldn't find a "getLevelForName" method in the logger module, or I would have used it instead.
- def create_log_file(self, name):
if self.logfile is None:
self.logname = name
lf = file(name, "w")
print >>lf, version_string()
lf.close()
What is the point of writing the raw string into the file before we open it? That said, the above should be this for consistency:
Well, it works. The string does make it into the log file.
with file(name, 'w') as lf: print >>lf, version_string()
Which auto-closes the file. Since this is at the bottom of the stack, I'll apply, but I think we should go back and just remove that (or turn it into a log), unless there is some reason I'm missing.
I was unaware of that convention. As it was, I copy-and-pasted that code from setup.py, so I'll fix it up at the same time as the above.
It's not a log message because that would end up on the console as well, and we should not unilaterally spam that line at every launch (as that could preclude chirpc from being usable in command pipelines).
That said, I could just fake it, since it's apples to oranges anyway. As long as it's unique for each patch, it should serve for the purpose that you describe, yah?
Yes.
That would be fairly easy to add; in the git-patch-to-hg-patch script, hash the original email message (which includes a time/date string) and then emit it as part of the body.
The hash identifies what you sent, not when you sent it. The two are the same to me, but not to you, so the timestamp is fine with me, but I think the hash is the right thing to do. Well, actually, I think the right thing to do is use our tool, but, you know.
What is the point of writing the raw string into the file before we open it? That said, the above should be this for consistency:
Well, it works. The string does make it into the log file.
Sure, but that wasn't the question, the question was: "why?"
It's not a log message because that would end up on the console as well, and we should not unilaterally spam that line at every launch (as that could preclude chirpc from being usable in command pipelines).
Logging at DEBUG level seems appropriate, regardless of where it ends up. So far, you're still relying on the stdout intervention for generating debug.log on Win32, so logging it, having it go to the console, and thus ending up there is appropriate at the moment. When you add a FileHandler for debug.log, you can set that to DEBUG, let the console handler default to INFO, and then you won't see it on the console.
--Dan
On 02/26/2015 04:49 PM, Dan Smith wrote: ....
What is the point of writing the raw string into the file before we open it? That said, the above should be this for consistency:
Well, it works. The string does make it into the log file.
Sure, but that wasn't the question, the question was: "why?"
Why does it work? No clue! :) Why write it? So when we are handed a log from a user, we know what version it came from. That would be doubly useful if the daily builds munge the version with the build date (which I haven't investigated, so I don't know either way).
It's not a log message because that would end up on the console as well, and we should not unilaterally spam that line at every launch (as that could preclude chirpc from being usable in command pipelines).
Logging at DEBUG level seems appropriate, regardless of where it ends up. So far, you're still relying on the stdout intervention for generating debug.log on Win32, so logging it, having it go to the console, and thus ending up there is appropriate at the moment. When you add a FileHandler for debug.log, you can set that to DEBUG, let the console handler default to INFO, and then you won't see it on the console.
I am not familiar with this "stdout intervention" of which you speak. How do I learn more about it (and turn it off)? That will be required for me to write a complete debug.log handler patch, as we don't want the two features fighting over the same file.
The version should appear in log files regardless of the configured logging level. As far as I can tell, there is no way to do that with the logging module. Conversely, it should never appear on the console.
Presently, the debug.log would only have contained that version string in the GUI (prior to my patches, which removed it). If this is critical, I would say the best immediate solution would be to add it back in the GUI for now. Tonight, I'll write a patch that generates a proper debug.log, and I can remove it again.
Why does it work? No clue! :) Why write it? So when we are handed a log from a user, we know what version it came from. That would be doubly useful if the daily builds munge the version with the build date (which I haven't investigated, so I don't know either way).
Obviously the version should be in the logs, and it currently is. Clearly I need to be more explicit:
Why write it instead of log it?
But I think I covered that in the rest of my previous reply.
I am not familiar with this "stdout intervention" of which you speak. How do I learn more about it (and turn it off)?
http://chirp.danplanet.com/projects/chirp/repository/entry/chirpw#L35
The version should appear in log files regardless of the configured logging level. As far as I can tell, there is no way to do that with the logging module. Conversely, it should never appear on the console.
Can you please stop speaking so definitively? If we're logging debug messages to the console, then I definitely think the version belongs there. For example:
dan@eagle:~$ ntpdate -vq time.nist.gov 26 Feb 17:23:36 ntpdate[26448]: ntpdate 4.2.6p3@1.2290-o Sat Dec 20 11:46:51 UTC 2014 (1) server 128.138.141.172, stratum 1, offset 0.003841, delay 0.06700 server 2610:20:6f15:15::27, stratum 1, offset -0.007308, delay 0.16849 26 Feb 17:23:44 ntpdate[26448]: adjust time server 128.138.141.172 offset 0.003841 sec
Or
dan@eagle:~$ ssh -vv foo OpenSSH_5.9p1 Debian-5ubuntu1.4, OpenSSL 1.0.1 14 Mar 2012 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug2: ssh_connect: needpriv 0 debug1: Connection established.
Further, if we're logging only info messages to a file, that's not going to be that useful for triaging an issue, so I don't think it matters one way or the other. The whole point of converged logging is to have the same thing (modulo the given level) appear in whatever log stream(s) we have.
Presently, the debug.log would only have contained that version string in the GUI (prior to my patches, which removed it).> If this is critical, I would say the best immediate solution would be to add it back in the GUI for now.
Ah, you're right, I didn't catch that you removed it and didn't add it back in that same patch. I've reverted that one.
--Dan
On 02/26/2015 05:30 PM, Dan Smith wrote:
Why does it work? No clue! :) Why write it? So when we are handed a log from a user, we know what version it came from. That would be doubly useful if the daily builds munge the version with the build date (which I haven't investigated, so I don't know either way).
Obviously the version should be in the logs, and it currently is. Clearly I need to be more explicit:
Why write it instead of log it?
Because logging may not always get it in the log file.
The version should appear in log files regardless of the configured logging level. As far as I can tell, there is no way to do that with the logging module. Conversely, it should never appear on the console.
Can you please stop speaking so definitively? If we're logging debug messages to the console, then I definitely think the version belongs there. For example:
Okay, I should have said "it should never appear on the console _unless the logging level is DEBUG_".
As far as speaking definitively goes, please realize that's just me trying to use a simple, clear, and direct way of writing. Please do not confuse "definitive" with "authoritative", as I will readily admit that my statements aren't worth beans unless you agree with them.
Further, if we're logging only info messages to a file, that's not going to be that useful for triaging an issue, so I don't think it matters one way or the other. The whole point of converged logging is to have the same thing (modulo the given level) appear in whatever log stream(s) we have.
After considering your examples, you have convinced me that you are right, in so far as the debug.log will always have it (since it will always be at DEBUG level) and the console or log should have it (if at DEBUG level). The other use cases don't matter as much as those. Thus, I concede: it should be a LOG.debug statement. I'll change it.
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com
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..319bc46 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,8 @@ 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) + LOG.debug("Setting %s(%s) <= %s" % (setting, + getattr(obj, 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..ebe8e12 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,8 @@ 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) + LOG.debug("Setting %s(%s) <= %s" % (setting, + getattr(obj, 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
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.
I haven't looked at why, but this causes several radios to raise an exception during the settings test.
--Dan
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com
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
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..8938a58 100755 --- a/run_all_tests.sh +++ b/run_all_tests.sh @@ -26,8 +26,14 @@ function style_tests() { ./tools/checkpatch.sh }
-TESTS="unit_tests driver_tests make_supported style_tests" -for testname in $TESTS; do +function pep8() { + ./tools/pep8.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/pep8.blacklist b/tools/pep8.blacklist new file mode 100644 index 0000000..2e87a8f --- /dev/null +++ b/tools/pep8.blacklist @@ -0,0 +1,142 @@ +# DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. +# Over time, this list should shrink and (eventually) be eliminated. +# The current list of files that do not yet meet PEP8 standards. +./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/bandplan.py +./chirp/baofeng_uv3r.py +./chirp/bitwise_grammar.py +./chirp/bitwise.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_ll.py +./chirp/ft50.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_icf_ll.py +./chirp/ic9x_icf.py +./chirp/ic9x_ll.py +./chirp/ic9x.py +./chirp/icf.py +./chirp/icomciv.py +./chirp/icq7.py +./chirp/ict70.py +./chirp/ict7h.py +./chirp/ict8.py +./chirp/icw32.py +./chirp/icx8x_ll.py +./chirp/icx8x.py +./chirp/id31.py +./chirp/id51.py +./chirp/id800.py +./chirp/id880.py +./chirp/idrp.py +./chirp/import_logic.py +./chirp/__init__.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/thd72.py +./chirp/thuv1f.py +./chirp/th_uv3r25.py +./chirp/th_uv3r.py +./chirp/th_uvf8d.py +./chirp/tk8102.py +./chirp/tmv71_ll.py +./chirp/tmv71.py +./chirpui/bandplans.py +./chirpui/bankedit.py +./chirpui/cloneprog.py +./chirpui/clone.py +./chirpui/common.py +./chirpui/config.py +./chirpui/dstaredit.py +./chirpui/editorset.py +./chirpui/fips.py +./chirpui/importdialog.py +./chirpui/__init__.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 +./chirp/util.py +./chirp/uv5r.py +./chirp/uvb5.py +./chirp/vx170.py +./chirp/vx2.py +./chirp/vx3.py +./chirp/vx510.py +./chirp/vx5.py +./chirp/vx6.py +./chirp/vx7.py +./chirp/vx8.py +./chirp/vxa700.py +./chirp/wouxun_common.py +./chirp/wouxun.py +./chirp/xml_ll.py +./chirp/yaesu_clone.py +./csvdump/csvapp.py +./csvdump/csvdump.py +./csvdump/__init__.py +./csvdump.py +./locale/check_parameters.py +./rpttool +./setup.py +./share/make_supported.py +./tests/__init__.py +./tests/run_tests +./tests/unit/base.py +./tests/unit/__init__.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/pep8.manifest b/tools/pep8.manifest new file mode 100644 index 0000000..2fe9d77 --- /dev/null +++ b/tools/pep8.manifest @@ -0,0 +1,4 @@ +./chirpc +./chirpw +./rpttool +./tests/run_tests diff --git a/tools/pep8.py b/tools/pep8.py new file mode 100755 index 0000000..efbfd14 --- /dev/null +++ b/tools/pep8.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# +# pep8.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 subprocess + +scriptdir = os.path.dirname(sys.argv[0]) +sys.path.insert(0, os.path.join(scriptdir, "..")) + +from chirp import logger + +LOG = logging.getLogger("pep8.py") + +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("--stats", action="store_true", + help="Only show statistics") +parser.add_argument("files", metavar="file", nargs='*', + help="List of files to check (if none, check all)") +logger.add_arguments(parser) +args = parser.parse_args() +logger.handle_options(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, "pep8.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 = file_to_lines(os.path.join(scriptdir, "pep8.blacklist")) + +if args.files: + manifest = args.files + +for f in manifest: + if args.all or f not in blacklist: + LOG.info("checking %s", f) + cmdline = ['pep8', f] + if args.stats: + cmdline += ['-q', '--statistics'] + returnvalue = subprocess.call(cmdline) + if not args.all and returnvalue: + sys.exit(returnvalue)
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com
Add pep8 checker script (#2355)
When I apply this and run it thusly:
TESTS=pep8 ./run_all_tests.sh
I get this:
./chirpc
... snip like a hundred lines ...
./chirpc ./chirpc ./chirpc ./chirpc ./chirpc 194 E101 indentation contains mixed spaces and tabs 6 E221 multiple spaces before operator 5 E302 expected 2 blank lines, found 1 1 E501 line too long (80 characters) 194 W191 indentation contains tabs 2 W293 blank line contains whitespace 1 W391 blank line at end of file ================================================ Tests FAILED: pep8, driver tests
Didn't look to see why.
diff --git a/tools/pep8.py b/tools/pep8.py new file mode 100755 index 0000000..efbfd14 --- /dev/null +++ b/tools/pep8.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# +# pep8.py - Check Python source files for PEP8 compliance.
So, I think this should import and use pep8 as a library instead of running the command line, as is common practice. You can customize it extensively that way and it's a little more integrated. See this for starters:
http://pep8.readthedocs.org/en/latest/advanced.html
...but there are some good examples elsewhere. Should be able to do everything you need that way.
--Dan
On 02/26/2015 04:41 PM, Dan Smith wrote:
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com
Add pep8 checker script (#2355)
When I apply this and run it thusly:
TESTS=pep8 ./run_all_tests.sh
Since TESTS is now an array, I use "TESTS=( pep8 )", but I think that it should work either way for a single test.
I get this:
./chirpc
... snip like a hundred lines ...
./chirpc ./chirpc ./chirpc ./chirpc ./chirpc 194 E101 indentation contains mixed spaces and tabs 6 E221 multiple spaces before operator 5 E302 expected 2 blank lines, found 1 1 E501 line too long (80 characters) 194 W191 indentation contains tabs 2 W293 blank line contains whitespace 1 W391 blank line at end of file ================================================ Tests FAILED: pep8, driver tests
Didn't look to see why.
Well, I bet I know why you got those pep8 failures: the next patch fixes the style issues. I reordered them and didn't think about the consequences. D'oh.
As to the 100 lines of "./chirpc", that's completely new to me.
....
So, I think this should import and use pep8 as a library instead of running the command line, as is common practice. You can customize it extensively that way and it's a little more integrated. See this for starters:
http://pep8.readthedocs.org/en/latest/advanced.html
...but there are some good examples elsewhere. Should be able to do everything you need that way.
I didn't consider that possibility. I agree. I'll revisit it tonight.
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com
fix style issues (#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 b11ab0f..efdef9f 100755 --- a/chirpw +++ b/chirpw @@ -50,16 +50,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]] @@ -68,7 +68,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: @@ -89,6 +89,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, @@ -97,21 +98,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 @@ -141,7 +143,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)
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com
Fix some style issues (#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/pep8.blacklist b/tools/pep8.blacklist index 2e87a8f..d64e3a8 100644 --- a/tools/pep8.blacklist +++ b/tools/pep8.blacklist @@ -9,7 +9,6 @@ ./chirp/bandplan_iaru_r2.py ./chirp/bandplan_iaru_r3.py ./chirp/bandplan_na.py -./chirp/bandplan.py ./chirp/baofeng_uv3r.py ./chirp/bitwise_grammar.py ./chirp/bitwise.py @@ -120,23 +119,15 @@ ./chirp/yaesu_clone.py ./csvdump/csvapp.py ./csvdump/csvdump.py -./csvdump/__init__.py ./csvdump.py -./locale/check_parameters.py ./rpttool ./setup.py ./share/make_supported.py ./tests/__init__.py ./tests/run_tests -./tests/unit/base.py ./tests/unit/__init__.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
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 radios 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 eeefb32..66c9000 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): for _rtype, rclass in directory.DRV_TO_RADIO.items(): diff --git a/chirp/directory.py b/chirp/directory.py index 07308ee..f5ec9e7 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 319bc46..1e879e2 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 ebe8e12..d7d6c7c 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/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/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 a11d810..9b3b4df 100644 --- a/chirpui/radiobrowser.py +++ b/chirpui/radiobrowser.py @@ -318,7 +318,7 @@ class RadioBrowser(common.Editor): self._focused = False
if __name__ == "__main__": - from chirp import * + from chirp.drivers import * from chirp import directory import sys
diff --git a/chirpw b/chirpw index efdef9f..5777da4 100755 --- a/chirpw +++ b/chirpw @@ -121,7 +121,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/pep8.blacklist b/tools/pep8.blacklist index d64e3a8..4c73876 100644 --- a/tools/pep8.blacklist +++ b/tools/pep8.blacklist @@ -1,86 +1,102 @@ # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. # The current list of files that do not yet meet PEP8 standards. -./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_grammar.py ./chirp/bitwise.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_ll.py -./chirp/ft50.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_icf_ll.py -./chirp/ic9x_icf.py -./chirp/ic9x_ll.py -./chirp/ic9x.py -./chirp/icf.py -./chirp/icomciv.py -./chirp/icq7.py -./chirp/ict70.py -./chirp/ict7h.py -./chirp/ict8.py -./chirp/icw32.py -./chirp/icx8x_ll.py -./chirp/icx8x.py -./chirp/id31.py -./chirp/id51.py -./chirp/id800.py -./chirp/id880.py -./chirp/idrp.py ./chirp/import_logic.py ./chirp/__init__.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/thd72.py -./chirp/thuv1f.py -./chirp/th_uv3r25.py -./chirp/th_uv3r.py -./chirp/th_uvf8d.py -./chirp/tk8102.py -./chirp/tmv71_ll.py -./chirp/tmv71.py +./chirp/util.py +./chirp/xml_ll.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_ll.py +./chirp/drivers/ft50.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_icf_ll.py +./chirp/drivers/ic9x_icf.py +./chirp/drivers/ic9x_ll.py +./chirp/drivers/ic9x.py +./chirp/drivers/icf.py +./chirp/drivers/icomciv.py +./chirp/drivers/icq7.py +./chirp/drivers/ict70.py +./chirp/drivers/ict7h.py +./chirp/drivers/ict8.py +./chirp/drivers/icw32.py +./chirp/drivers/icx8x_ll.py +./chirp/drivers/icx8x.py +./chirp/drivers/id31.py +./chirp/drivers/id51.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/thd72.py +./chirp/drivers/thuv1f.py +./chirp/drivers/th_uv3r25.py +./chirp/drivers/th_uv3r.py +./chirp/drivers/th_uvf8d.py +./chirp/drivers/tk8102.py +./chirp/drivers/tmv71_ll.py +./chirp/drivers/tmv71.py +./chirp/drivers/uv5r.py +./chirp/drivers/uvb5.py +./chirp/drivers/vx170.py +./chirp/drivers/vx2.py +./chirp/drivers/vx3.py +./chirp/drivers/vx510.py +./chirp/drivers/vx5.py +./chirp/drivers/vx6.py +./chirp/drivers/vx7.py +./chirp/drivers/vx8.py +./chirp/drivers/vxa700.py +./chirp/drivers/wouxun_common.py +./chirp/drivers/wouxun.py +./chirp/drivers/yaesu_clone.py ./chirpui/bandplans.py ./chirpui/bankedit.py ./chirpui/cloneprog.py @@ -101,22 +117,6 @@ ./chirpui/reporting.py ./chirpui/settingsedit.py ./chirpui/shiftdialog.py -./chirp/util.py -./chirp/uv5r.py -./chirp/uvb5.py -./chirp/vx170.py -./chirp/vx2.py -./chirp/vx3.py -./chirp/vx510.py -./chirp/vx5.py -./chirp/vx6.py -./chirp/vx7.py -./chirp/vx8.py -./chirp/vxa700.py -./chirp/wouxun_common.py -./chirp/wouxun.py -./chirp/xml_ll.py -./chirp/yaesu_clone.py ./csvdump/csvapp.py ./csvdump/csvdump.py ./csvdump.py
participants (2)
-
Dan Smith
-
Zach Welch