diff options
author | Lars Wirzenius <liw@liw.fi> | 2015-10-10 11:52:50 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-10-10 11:52:50 +0300 |
commit | 80d809e86b4b417de32ccbe23378830b3e9d3d82 (patch) | |
tree | 455d2ebbcebe62e86f46c8b56f24fc5369644ac9 | |
parent | a81fc36cb11446ad687202eb436e29a318111bb2 (diff) | |
download | ttystatus-80d809e86b4b417de32ccbe23378830b3e9d3d82.tar.gz |
Adapt speed-test to interface changes
-rwxr-xr-x | speed-test | 25 | ||||
-rw-r--r-- | ttystatus/messager.py | 4 | ||||
-rw-r--r-- | ttystatus/status.py | 5 |
3 files changed, 23 insertions, 11 deletions
@@ -25,18 +25,30 @@ import ttystatus class FakeTTY(object): - def write(self, string): + def open_tty(self): pass - - def isatty(self): + + def has_capabilities(self): return True - def flush(self): + def get_up_sequence(self): + return '' + + def get_down_sequence(self): + return '' + + def get_erase_line_sequence(self): + return '' + + def get_width(self): + return 80 + + def write(self, raw_data): pass -output = FakeTTY() -ts = ttystatus.TerminalStatus(output=output) +tty = FakeTTY() +ts = ttystatus.TerminalStatus(_terminal=tty, period=0) ts.add(ttystatus.ElapsedTime()) ts.add(ttystatus.Literal(' ')) ts.add(ttystatus.Counter('current-file')) @@ -53,4 +65,3 @@ def loop(): ts['updated-bytes'] = i cProfile.run('loop()', 'ttystatus.prof') - diff --git a/ttystatus/messager.py b/ttystatus/messager.py index f9ab912..8743561 100644 --- a/ttystatus/messager.py +++ b/ttystatus/messager.py @@ -31,7 +31,7 @@ class Messager(object): ''' - def __init__(self, period=None): + def __init__(self, period=None, _terminal=None): self._period = 1.0 if period is None else period self._enabled = True @@ -40,7 +40,7 @@ class Messager(object): self._displayed_message = None # The latest message displayed. self._previous_write_at = 0 # When the latest message was written. - self._terminal = ttystatus.PhysicalTerminal() + self._terminal = _terminal or ttystatus.PhysicalTerminal() try: self._terminal.open_tty() except IOError: diff --git a/ttystatus/status.py b/ttystatus/status.py index 18b3057..b4232d2 100644 --- a/ttystatus/status.py +++ b/ttystatus/status.py @@ -32,8 +32,9 @@ class TerminalStatus(object): ''' - def __init__(self, period=None, messager=None): - self._m = messager or ttystatus.Messager(period=period) + def __init__(self, period=None, messager=None, _terminal=None): + self._m = messager or ttystatus.Messager( + period=period, _terminal=_terminal) self.clear() def add(self, widget): |