Skip to content

Commit

Permalink
-Print
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-usielski committed Jan 18, 2024
1 parent 3dc13be commit ab36fea
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions moler/cmd/commandtextualgeneric.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ def data_received(self, data, recv_time):
self.logger.debug("{} is done".format(self))
break
except UnicodeDecodeError as ex:
print("UnicodeDecodeError")
if self._ignore_unicode_errors:
self._log(lvl=logging.WARNING,
msg="Processing data from '{}' with unicode problem: '{}'.".format(self, ex))
Expand All @@ -261,7 +260,6 @@ def data_received(self, data, recv_time):
msg="Processing data from '{}' raised: '{}'.".format(self, ex))
raise ex
except Exception as ex: # pragma: no cover # log it just to catch that rare hanging thread issue
print("Exception {}".format(ex))
self._log(lvl=logging.WARNING,
msg="Processing data from '{}' raised: '{}'.".format(self, ex))
raise ex
Expand Down Expand Up @@ -557,16 +555,21 @@ def failure_indiction(self, line, is_full_line):
if self.is_failure_indication(line=line, is_full_line=is_full_line):
self.set_exception(CommandFailure(self, "command failed in line '{}'".format(line)))

def add_failure_indication(self, indication):
def add_failure_indication(self, indication, flags=re.IGNORECASE):
"""
Add failure indication to command.
:param indication: String or regexp with ndication of failure.
:param flags: Flags for compiled regexp.
:return: None
"""
try:
indication_str = indication.pattern
except AttributeError:
indication_str = indication
if self.re_fail is None:
new_indication = indication
new_indication = indication_str
else:
current_indications = self.re_fail.pattern
new_indication = r'{}|{}'.format(current_indications, indication)
self.re_fail = re.compile(new_indication, re.IGNORECASE)
new_indication = r'{}|{}'.format(current_indications, indication_str)
self.re_fail = re.compile(new_indication, flags)

0 comments on commit ab36fea

Please sign in to comment.