From 642f2b7328a3522c28b20fb77b073991c158a8f1 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Tue, 3 May 2011 15:57:23 +0200 Subject: [PATCH] fix error message when file is not found --- weboob/applications/pastoob/pastoob.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/weboob/applications/pastoob/pastoob.py b/weboob/applications/pastoob/pastoob.py index 24852f79..8e5ca632 100644 --- a/weboob/applications/pastoob/pastoob.py +++ b/weboob/applications/pastoob/pastoob.py @@ -77,11 +77,15 @@ class Pastoob(ReplApplication): Submit a new paste. The filename can be '-' for reading standard input (pipe). """ - if filename is None or filename == '-': + if not filename or filename == '-': contents = sys.stdin.read().decode(sys.stdin.encoding or locale.getpreferredencoding()) else: - with codecs.open(filename, encoding=locale.getpreferredencoding()) as fp: - contents = fp.read() + try: + with codecs.open(filename, encoding=locale.getpreferredencoding()) as fp: + contents = fp.read() + except IOError, e: + print >>sys.stderr, 'Unable to open file "%s": %s' % (filename, e.strerror) + return 1 # get and sort the backends able to satisfy our requirements params = self._get_params()