[chirp_devel] [PATCH 1/3] Use logging in chirp[cw] (#2347)
Zach Welch
Sun Mar 1 21:19:37 PST 2015
# HG changeset patch
# User Zach Welch <zach at mandolincreekfarm.com>
# Fake Node ID 6226a149dce7276ec9885fa2d8b8b29ee48a1724
Use logging in chirp[cw] (#2347)
diff --git a/chirpc b/chirpc
index 217ca9f..dae48f6 100755
--- a/chirpc
+++ b/chirpc
@@ -30,12 +30,12 @@ RADIOS = directory.DRV_TO_RADIO
def fail_unsupported():
- print "Operation not supported by selected radio"
+ LOG.error("Operation not supported by selected radio")
sys.exit(1)
def fail_missing_mmap():
- print "mmap-only operation requires specification of an mmap file"
+ LOG.error("mmap-only operation requires specification of an mmap file")
sys.exit(1)
@@ -196,7 +196,7 @@ if __name__ == "__main__":
else:
s = options.radio + ".img"
else:
- print "opening %s at %i" % (options.serial, rclass.BAUD_RATE)
+ LOG.info("opening %s at %i" % (options.serial, rclass.BAUD_RATE))
s = serial.Serial(port=options.serial,
baudrate=rclass.BAUD_RATE,
timeout=0.5)
@@ -218,8 +218,8 @@ if __name__ == "__main__":
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: '+', '-', ''"
+ LOG.error("Invalid duplex value `%s'" % options.set_mem_dup)
+ LOG.error("Valid values are: '+', '-', ''")
sys.exit(1)
else:
_dup = options.set_mem_dup
@@ -227,9 +227,9 @@ if __name__ == "__main__":
_dup = None
if options.set_mem_mode:
- print "Set mode: %s" % options.set_mem_mode
+ LOG.info("Set mode: %s" % options.set_mem_mode)
if options.set_mem_mode not in chirp_common.MODES:
- print "Invalid mode `%s'"
+ LOG.error("Invalid mode `%s'")
sys.exit(1)
else:
_mode = options.set_mem_mode
@@ -303,7 +303,7 @@ if __name__ == "__main__":
if radio.sync_out():
print "Clone successful"
else:
- print "Clone failed"
+ LOG.error("Clone failed")
if options.mmap and isinstance(radio, chirp_common.CloneModeRadio):
radio.save_mmap(options.mmap)
diff --git a/chirpw b/chirpw
index 353edc9..4131948 100755
--- a/chirpw
+++ b/chirpw
@@ -29,6 +29,9 @@ import os
import locale
import gettext
import argparse
+import logging
+
+LOG = logging.getLogger("chirpw")
execpath = platform.get_platform().executable_path()
@@ -51,10 +54,10 @@ if manual_language and manual_language != "Auto":
"French": "fr",
}
try:
- print lang_codes[manual_language]
+ LOG.info("Language: %s", lang_codes[manual_language])
langs = [lang_codes[manual_language]]
except KeyError:
- print "Unsupported language `%s'" % manual_language
+ LOG.error("Unsupported language `%s'" % manual_language)
else:
lc, encoding = locale.getdefaultlocale()
if (lc):
@@ -125,7 +128,7 @@ if True:
a = mainapp.ChirpMain()
for i in args.files:
- print "Opening %s" % i
+ LOG.info("Opening %s", i)
a.do_open(i)
a.show()
More information about the chirp_devel
mailing list