zypper-log: view better error msg when logfile doesn't exist
authorDominik Heidler <dheidler@suse.de>
Wed, 13 Jul 2011 13:40:15 +0000 (15:40 +0200)
committerDominik Heidler <dheidler@suse.de>
Wed, 13 Jul 2011 13:40:15 +0000 (15:40 +0200)
tools/zypper-log

index 3909578..9d6bb03 100755 (executable)
@@ -29,7 +29,11 @@ def getLogFiles(rotate = 0):
   return logfiles[-rotate-1::]
 
 def readFile(logfile):
-  logtxt = open(logfile).read()
+  try:
+    logtxt = open(logfile).read()
+  except IOError, e:
+    print >> sys.stderr, "\rIOError: %s: '%s'" % (e.strerror, e.filename)
+    sys.exit(1)
   fext = logfile.split('.')[-1]
   if fext == 'bz2':
     logtxt = bz2.decompress(logtxt)