Skip to content

Commit

Permalink
pyterm: use logger instead of print
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegHahm committed Aug 1, 2014
1 parent 431655a commit b1323bf
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions dist/tools/pyterm/pyterm.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def do_PYTERM_reset(self, line):
self.ser.setDTR(0)

def do_PYTERM_exit(self, line, unused=None):
print("Exiting Pyterm")
self.logger.info("Exiting Pyterm")
readline.write_history_file()
if reactor.running:
reactor.callFromThread(reactor.stop)
Expand Down Expand Up @@ -169,7 +169,7 @@ def do_PYTERM_save(self, line):

with open(self.configdir + os.path.sep + self.configfile, 'wb') as config_fd:
self.config.write(config_fd)
print("Config saved")
self.logger.info("Config saved")

def do_PYTERM_show_config(self, line):
for key in self.__dict__:
Expand All @@ -178,7 +178,7 @@ def do_PYTERM_show_config(self, line):
def do_PYTERM_alias(self, line):
if line.endswith("list"):
for alias in self.aliases:
print("{} = {}".format(alias, self.aliases[alias]))
self.logger.info("{} = {}".format(alias, self.aliases[alias]))
return
if not line.count("="):
sys.stderr.write("Usage: /alias <ALIAS> = <CMD>\n")
Expand Down Expand Up @@ -214,7 +214,7 @@ def do_PYTERM_ignore(self, line):
def do_PYTERM_unignore(self, line):
for r in self.ignores:
if (r.pattern == line.strip()):
print("Remove ignore for %s" % r.pattern)
self.logger.info("Remove ignore for %s" % r.pattern)
self.ignores.remove(r)
return
sys.stderr.write("Ignore for %s not found\n" % line.strip())
Expand All @@ -225,7 +225,7 @@ def do_PYTERM_filter(self, line):
def do_PYTERM_unfilter(self, line):
for r in self.filters:
if (r.pattern == line.strip()):
print("Remove filter for %s" % r.pattern)
self.logger.info("Remove filter for %s" % r.pattern)
self.filters.remove(r)
return
sys.stderr.write("Filter for %s not found\n" % line.strip())
Expand Down Expand Up @@ -253,7 +253,7 @@ def load_config(self):
self.ignores.append(re.compile(self.config.get(sec, opt)))
if sec == "json_regs":
for opt in self.config.options(sec):
print("add json regex for %s" % self.config.get(sec, opt))
self.logger.info("add json regex for %s" % self.config.get(sec, opt))
self.json_regs[opt] = re.compile(self.config.get(sec, opt))
if sec == "aliases":
for opt in self.config.options(sec):
Expand Down Expand Up @@ -331,11 +331,11 @@ def reader(self):
sr = codecs.getreader("UTF-8")(self.ser, errors='replace')
c = sr.read(1)
except (serial.SerialException, ValueError) as se:
sys.stderr.write("Serial port disconnected, waiting to get reconnected...\n")
self.logger.warn("Serial port disconnected, waiting to get reconnected...")
self.ser.close()
time.sleep(1)
if os.path.exists(self.port):
sys.stderr.write("Try to reconnect to %s again...\n" % (self.port))
self.logger.warn("Try to reconnect to %s again..." % (self.port))
self.ser = serial.Serial(port=self.port, baudrate=self.baudrate, dsrdtr=0, rtscts=0)
self.ser.setDTR(0)
self.ser.setRTS(0)
Expand Down

0 comments on commit b1323bf

Please sign in to comment.