[chirp_devel] [PATCH 17/17] Use logging in drivers/[hi]*.py (#2347)
Zachary T Welch
Wed Mar 4 21:15:13 PST 2015
# HG changeset patch
# User Zachary T Welch <zach at mandolincreekfarm.com>
# Fake Node ID a79b84a0f26185dd16b7fb4e40e10ae320e87087
Use logging in drivers/[hi]*.py (#2347)
diff --git a/chirp/drivers/h777.py b/chirp/drivers/h777.py
index 236c2a9..d48d34c 100644
--- a/chirp/drivers/h777.py
+++ b/chirp/drivers/h777.py
@@ -117,7 +117,7 @@ def _h777_enter_programming_mode(radio):
raise errors.RadioError("Error communicating with radio")
if not ident.startswith("P3107"):
- print util.hexprint(ident)
+ LOG.debug(util.hexprint(ident))
raise errors.RadioError("Radio returned unknown identification string")
try:
@@ -183,7 +183,7 @@ def _h777_write_block(radio, block_addr, block_size):
def do_download(radio):
- print "download"
+ LOG.debug("download")
_h777_enter_programming_mode(radio)
data = ""
@@ -502,15 +502,15 @@ class H777Radio(chirp_common.CloneModeRadio):
setting = element.get_name()
if element.has_apply_callback():
- print "Using apply callback"
+ LOG.debug("Using apply callback")
element.run_apply_callback()
elif setting == "voxlevel":
setattr(obj, setting, int(element.value) - 1)
else:
- print "Setting %s = %s" % (setting, element.value)
+ LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
except Exception, e:
- print element.get_name()
+ LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/icomciv.py b/chirp/drivers/icomciv.py
index 04ff53e..dd32ae7 100644
--- a/chirp/drivers/icomciv.py
+++ b/chirp/drivers/icomciv.py
@@ -90,9 +90,9 @@ class Frame:
if willecho:
echo = serial.read(len(raw))
if echo != raw and echo:
- print "Echo differed (%i/%i)" % (len(raw), len(echo))
- print util.hexprint(raw)
- print util.hexprint(echo)
+ LOG.debug("Echo differed (%i/%i)" % (len(raw), len(echo)))
+ LOG.debug(util.hexprint(raw))
+ LOG.debug(util.hexprint(echo))
def read(self, serial):
"""Read the frame from @serial"""
@@ -100,7 +100,7 @@ class Frame:
while not data.endswith(chr(0xFD)):
char = serial.read(1)
if not char:
- print "Read %i bytes total" % len(data)
+ LOG.debug("Read %i bytes total" % len(data))
raise errors.RadioError("Timeout")
data += char
@@ -190,7 +190,7 @@ class IcomCIVRadio(icf.IcomLiveRadio):
echo_test = "\xfe\xfe\xe0\xe0\xfa\xfd"
self.pipe.write(echo_test)
resp = self.pipe.read(6)
- print "Echo:\n%s" % util.hexprint(resp)
+ LOG.debug("Echo:\n%s" % util.hexprint(resp))
return resp == echo_test
def __init__(self, *args, **kwargs):
@@ -202,7 +202,7 @@ class IcomCIVRadio(icf.IcomLiveRadio):
if self.pipe:
self._willecho = self._detect_echo()
- print "Interface echo: %s" % self._willecho
+ LOG.debug("Interface echo: %s" % self._willecho)
self.pipe.setTimeout(1)
# f = Frame()
@@ -211,8 +211,9 @@ class IcomCIVRadio(icf.IcomLiveRadio):
#
# res = f.read(self.pipe)
# if res:
- # print "Result: %x->%x (%i)" % (res[0], res[1], len(f.get_data()))
- # print util.hexprint(f.get_data())
+ # LOG.debug("Result: %x->%x (%i)" %
+ # (res[0], res[1], len(f.get_data())))
+ # LOG.debug(util.hexprint(f.get_data()))
#
# self._id = f.get_data()[0]
self._rf = chirp_common.RadioFeatures()
@@ -237,7 +238,7 @@ class IcomCIVRadio(icf.IcomLiveRadio):
return repr(f.get_obj())
def get_memory(self, number):
- print "Getting %i" % number
+ LOG.debug("Getting %i" % number)
f = self._classes["mem"]()
f.set_location(number)
self._send_frame(f)
@@ -253,7 +254,7 @@ class IcomCIVRadio(icf.IcomLiveRadio):
return mem
memobj = f.get_obj()
- print repr(memobj)
+ LOG.debug(repr(memobj))
mem.freq = int(memobj.freq)
mem.mode = self._rf.valid_modes[memobj.mode]
@@ -307,11 +308,11 @@ class IcomCIVRadio(icf.IcomLiveRadio):
memobj.ctone = int(mem.ctone * 10)
memobj.rtone = int(mem.rtone * 10)
- print repr(memobj)
+ LOG.debug(repr(memobj))
self._send_frame(f)
f = self._recv_frame()
- print "Result:\n%s" % util.hexprint(f.get_data())
+ LOG.debug("Result:\n%s" % util.hexprint(f.get_data()))
@directory.register
@@ -415,8 +416,8 @@ def probe_model(ser):
return CIV_MODELS[(model, controller)]
if f.get_data():
- print "Got data, but not 1 byte:"
- print util.hexprint(f.get_data())
+ LOG.debug("Got data, but not 1 byte:")
+ LOG.debug(util.hexprint(f.get_data()))
raise errors.RadioError("Unknown response")
raise errors.RadioError("Unsupported model")
diff --git a/chirp/drivers/icq7.py b/chirp/drivers/icq7.py
index 44ec43e..04cf63e 100644
--- a/chirp/drivers/icq7.py
+++ b/chirp/drivers/icq7.py
@@ -14,6 +14,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import struct
+import logging
+
from chirp.drivers import icf
from chirp import chirp_common, directory, bitwise
from chirp.chirp_common import to_GHz, from_GHz
@@ -22,6 +24,9 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \
RadioSettingValueInteger, RadioSettingValueString, \
RadioSettingValueFloat, RadioSettings
+
+LOG = logging.getLogger(__name__)
+
MEM_FORMAT = """
struct {
bbcd freq[3];
@@ -154,7 +159,7 @@ class ICQ7Radio(icf.IcomCloneModeRadio):
try:
mem.tuning_step = STEPS[_mem.tune_step]
except IndexError:
- print "Invalid tune step index %i" % _mem.tune_step
+ LOG.error("Invalid tune step index %i" % _mem.tune_step)
mem.tmode = TMODES[_flag.tmode]
mem.duplex = DUPLEX[_flag.duplex]
if mem.freq < 30000000:
@@ -328,11 +333,11 @@ class ICQ7Radio(icf.IcomCloneModeRadio):
setting = element.get_name()
if element.has_apply_callback():
- print "Using apply callback"
+ LOG.debug("Using apply callback")
element.run_apply_callback()
else:
- print "Setting %s = %s" % (setting, element.value)
+ LOG.debug("Setting %s = %s" % (setting, element.value))
setattr(obj, setting, element.value)
except Exception, e:
- print element.get_name()
+ LOG.debug(element.get_name())
raise
diff --git a/chirp/drivers/icw32.py b/chirp/drivers/icw32.py
index 356d81a..dc08ea0 100644
--- a/chirp/drivers/icw32.py
+++ b/chirp/drivers/icw32.py
@@ -13,9 +13,13 @@
# 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 logging
+
from chirp.drivers import icf
from chirp import chirp_common, util, directory, bitwise
+LOG = logging.getLogger(__name__)
+
MEM_FORMAT = """
#seekto 0x%x;
struct {
@@ -174,10 +178,10 @@ class ICW32ARadio(icf.IcomCloneModeRadio):
_flg.am = mem.mode == "AM"
if self._memobj.state.left_scanning:
- print "Canceling scan on left VFO"
+ LOG.debug("Canceling scan on left VFO")
self._memobj.state.left_scanning = 0
if self._memobj.state.right_scanning:
- print "Canceling scan on right VFO"
+ LOG.debug("Canceling scan on right VFO")
self._memobj.state.right_scanning = 0
def get_sub_devices(self):
diff --git a/chirp/drivers/icx8x.py b/chirp/drivers/icx8x.py
index bf17f1a..6a5c8b0 100644
--- a/chirp/drivers/icx8x.py
+++ b/chirp/drivers/icx8x.py
@@ -13,9 +13,13 @@
# 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 logging
+
from chirp.drivers import icf, icx8x_ll
from chirp import chirp_common, errors, directory
+LOG = logging.getLogger(__name__)
+
def _isuhf(pipe):
try:
@@ -25,7 +29,7 @@ def _isuhf(pipe):
except:
raise errors.RadioError("Unable to probe radio band")
- print "Radio is a %s82" % (uhf and "U" or "V")
+ LOG.debug("Radio is a %s82" % (uhf and "U" or "V"))
return uhf
@@ -102,7 +106,7 @@ class ICx8xRadio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport):
# that flag.
if isinstance(pipe, str):
self._isuhf = (ord(self._mmap[0x1930]) != 0)
- # print "Found %s image" % (self.isUHF and "UHF" or "VHF")
+ # LOG.debug("Found %s image" % (self.isUHF and "UHF" or "VHF"))
else:
self._isuhf = None
More information about the chirp_devel
mailing list