Permalink
Browse files

Update DummySerialGuard to have flush(), optionally not print.

  • Loading branch information...
1 parent 55cb587 commit 29445bf0278b7387cc72d827ae4ae18b65c8514d @markfickett committed Feb 11, 2012
Showing with 8 additions and 3 deletions.
  1. +8 −3 DataSender.py
View
@@ -173,16 +173,21 @@ def Format(**kwargs):
class DummySerialGuard:
"""
- Match SerialGuard, but print to stdout.
+ Match SerialGuard, but print to stdout (or do not print at all).
"""
- def __init__(self, serialDevice, readTimeout=TIMEOUT_DEFAULT):
+ def __init__(self, serialDevice, readTimeout=TIMEOUT_DEFAULT,
+ silent=False):
self.__sentReady = False
+ self.__silent = silent
def __enter__(self):
return self
def __exit__(self, excClass, excObj, tb):
pass
def write(self, s):
- print s
+ if not self.__silent:
+ print s
+ def flush(self):
+ pass
def readline(self):
if not self.__sentReady:
self.__sentReady = True

0 comments on commit 29445bf

Please sign in to comment.