summaryrefslogtreecommitdiff
path: root/ttystatus/messager.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2010-06-06 15:09:28 +1200
committerLars Wirzenius <liw@liw.fi>2010-06-06 15:09:28 +1200
commit206eb1f28bd3f19f2bf7cef1d44b147bfb1294e2 (patch)
tree3284ca1178e1f3bebfbe9557fb69384b04ed6833 /ttystatus/messager.py
parent9ff7378c072ed1bd2bdcf3e7d22314b2ab567c06 (diff)
downloadpython-ttystatus-206eb1f28bd3f19f2bf7cef1d44b147bfb1294e2.tar.gz
Ignore write errors, call _get_terminal_width with right name.
Diffstat (limited to 'ttystatus/messager.py')
-rw-r--r--ttystatus/messager.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/ttystatus/messager.py b/ttystatus/messager.py
index 05d2a09..cbc8ed5 100644
--- a/ttystatus/messager.py
+++ b/ttystatus/messager.py
@@ -65,12 +65,15 @@ class Messager(object):
# Clear the terminal from old stuff, using the old width.
self.clear()
# Get new width.
- self.width = self.get_terminal_width()
+ self.width = self._get_terminal_width()
def _raw_write(self, string):
'''Write raw data if output is terminal.'''
if self.output.isatty():
- self.output.write(string)
+ try:
+ self.output.write(string)
+ except IOError:
+ pass # We ignore these.
def _overwrite(self, string):
'''Overwrite current message on terminal.'''
@@ -107,7 +110,10 @@ class Messager(object):
old = self._last_msg
self.clear()
- self.output.write('%s\n' % string)
+ try:
+ self.output.write('%s\n' % string)
+ except IOError:
+ pass # We ignore these. No point in crashing if terminal is bad.
self._overwrite(old)
def finish(self):