[chirp_devel] [PATCH 05/17] Use logging in vx*.py (#2347)

Zachary T Welch
Wed Mar 4 21:15:01 PST 2015


# HG changeset patch
# User Zachary T Welch <zach at mandolincreekfarm.com>
# Fake Node ID 8df3538abeffbee6d71f1d89eba9dced39c0864f

Use logging in vx*.py (#2347)


diff --git a/chirp/drivers/vx2.py b/chirp/drivers/vx2.py
index b7beec1..dfec883 100644
--- a/chirp/drivers/vx2.py
+++ b/chirp/drivers/vx2.py
@@ -747,5 +747,5 @@ class VX2Radio(yaesu_clone.YaesuCloneModeRadio):
                 LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval))
                 setattr(_settings, setting, newval)
             except Exception, e:
-                print element.get_name()
+                LOG.debug(element.get_name())
                 raise
diff --git a/chirp/drivers/vx3.py b/chirp/drivers/vx3.py
index b18e056..b187b79 100644
--- a/chirp/drivers/vx3.py
+++ b/chirp/drivers/vx3.py
@@ -961,5 +961,5 @@ class VX3Radio(yaesu_clone.YaesuCloneModeRadio):
                 LOG.debug("Setting %s(%s) <= %s" % (setting, oldval, newval))
                 setattr(_settings, setting, newval)
             except Exception, e:
-                print element.get_name()
+                LOG.debug(element.get_name())
                 raise
diff --git a/chirp/drivers/vx5.py b/chirp/drivers/vx5.py
index 1afe676..aa6d4bd 100644
--- a/chirp/drivers/vx5.py
+++ b/chirp/drivers/vx5.py
@@ -99,7 +99,8 @@ class VX5BankModel(chirp_common.BankModel):
         _bank_used = self._radio._memobj.bank_used[bank.index]
         for i in range(0, len(_members)):
             if _members[i].status == 0xFF:
-                # print "empty found, inserting %d at %d" % (memory.number, i)
+                # LOG.debug("empty found, inserting %d at %d" %
+                #           (memory.number, i))
                 if self._radio._memobj.current_bank == 0xFF:
                     self._radio._memobj.current_bank = bank.index
                 _members[i].status = 0x00
diff --git a/chirp/drivers/vx7.py b/chirp/drivers/vx7.py
index 8aab994..1d7b11a 100644
--- a/chirp/drivers/vx7.py
+++ b/chirp/drivers/vx7.py
@@ -16,6 +16,9 @@
 from chirp.drivers import yaesu_clone
 from chirp import chirp_common, directory, bitwise
 from textwrap import dedent
+import logging
+
+LOG = logging.getLogger(__name__)
 
 MEM_FORMAT = """
 #seekto 0x0611;
@@ -280,8 +283,8 @@ class VX7Radio(yaesu_clone.YaesuCloneModeRadio):
         try:
             mem.power = levels[_mem.power]
         except IndexError:
-            print "Radio reported invalid power level %s (in %s)" % (
-                _mem.power, levels)
+            LOG.error("Radio reported invalid power level %s (in %s)" %
+                      (_mem.power, levels))
             mem.power = levels[0]
 
         for i in _mem.name:
diff --git a/chirp/drivers/vx8.py b/chirp/drivers/vx8.py
index e35d05c..d65e77c 100644
--- a/chirp/drivers/vx8.py
+++ b/chirp/drivers/vx8.py
@@ -415,17 +415,17 @@ class VX8BankModel(chirp_common.BankModel):
             vfo_bak = self._radio._memobj.vfo_info[(vfo_index * 2) + 1]
 
             if vfo.checksum != vfo_bak.checksum:
-                print "Warning: VFO settings are inconsistent with backup"
+                LOG.warn("VFO settings are inconsistent with backup")
             else:
                 if ((chosen_bank[vfo_index] is None) and
                         (vfo.bank_index != 0xFFFF)):
-                    print "Disabling banks for VFO %d" % vfo_index
+                    LOG.info("Disabling banks for VFO %d" % vfo_index)
                     vfo.bank_index = 0xFFFF
                     vfo.mr_index = 0xFFFF
                     vfo.bank_enable = 0xFFFF
                 elif ((chosen_bank[vfo_index] is not None) and
                         (vfo.bank_index == 0xFFFF)):
-                    print "Enabling banks for VFO %d" % vfo_index
+                    LOG.debug("Enabling banks for VFO %d" % vfo_index)
                     vfo.bank_index = chosen_bank[vfo_index]
                     vfo.mr_index = chosen_mr[vfo_index]
                     vfo.bank_enable = 0x0000
@@ -1400,8 +1400,7 @@ class VX8DRadio(VX8Radio):
             return self._get_settings()
         except:
             import traceback
-            print "Failed to parse settings:"
-            traceback.print_exc()
+            LOG.error("Failed to parse settings: %s", traceback.format_exc())
             return None
 
     @staticmethod
@@ -1491,11 +1490,11 @@ class VX8DRadio(VX8Radio):
                 continue
             try:
                 if element.has_apply_callback():
-                    print "Using apply callback"
+                    LOG.debug("Using apply callback")
                     try:
                         element.run_apply_callback()
                     except NotImplementedError as e:
-                        print e
+                        LOG.error(e)
                     continue
 
                 # Find the object containing setting.
@@ -1516,10 +1515,10 @@ class VX8DRadio(VX8Radio):
                             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" % (
-                        element.get_name(), e)
+                    LOG.error("Setting %s is not in the memory map: %s" %
+                              (element.get_name(), e))
             except Exception, e:
-                print element.get_name()
+                LOG.debug(element.get_name())
                 raise
 
     def apply_ff_padded_yaesu(cls, setting, obj):
diff --git a/chirp/drivers/vxa700.py b/chirp/drivers/vxa700.py
index a484754..3aa39d5 100644
--- a/chirp/drivers/vxa700.py
+++ b/chirp/drivers/vxa700.py
@@ -18,15 +18,13 @@ from chirp import bitwise
 
 import time
 import struct
+import logging
 
-
-def _debug(string):
-    pass
-    print string
+LOG = logging.getLogger(__name__)
 
 
 def _send(radio, data):
-    _debug("Sending %s" % repr(data))
+    LOG.debug("Sending %s" % repr(data))
     radio.pipe.write(data)
     radio.pipe.flush()
     echo = radio.pipe.read(len(data))
@@ -46,7 +44,7 @@ def _spoonfeed(radio, data):
         # so just blindly send the data
         echo = radio.pipe.read(1)
         if echo != byte:
-            print "%02x != %02x" % (ord(echo), ord(byte))
+            LOG.debug("%02x != %02x" % (ord(echo), ord(byte)))
             raise errors.RadioError("No echo?")
         # count += 1
 
@@ -105,7 +103,7 @@ def _upload(radio):
         ack = "\x06"
         time.sleep(0.5)
         if ack != "\x06":
-            print repr(ack)
+            LOG.debug(repr(ack))
             raise errors.RadioError("Radio did not ack block %i" % (i / 132))
         # radio.pipe.read(1)
         if radio.status_fn:




More information about the chirp_devel mailing list