From 0ab9859168eb0ba4fc348843e866751cfc67181f Mon Sep 17 00:00:00 2001 From: Andrew Jorgensen Date: Fri, 25 Aug 2017 22:17:34 +0000 Subject: cloud-init analyze: fix issues running under python 2. Some Python 3 exception names crept into the cloud-init analyze code. This patches those back out at a cost of catching less specific parents of the desired exceptions. --- cloudinit/analyze/__main__.py | 4 ++-- cloudinit/analyze/show.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'cloudinit') diff --git a/cloudinit/analyze/__main__.py b/cloudinit/analyze/__main__.py index 71cba4f2..69b9e43e 100644 --- a/cloudinit/analyze/__main__.py +++ b/cloudinit/analyze/__main__.py @@ -130,7 +130,7 @@ def configure_io(args): else: try: infh = open(args.infile, 'r') - except (FileNotFoundError, PermissionError): + except OSError: sys.stderr.write('Cannot open file %s\n' % args.infile) sys.exit(1) @@ -139,7 +139,7 @@ def configure_io(args): else: try: outfh = open(args.outfile, 'w') - except PermissionError: + except OSError: sys.stderr.write('Cannot open file %s\n' % args.outfile) sys.exit(1) diff --git a/cloudinit/analyze/show.py b/cloudinit/analyze/show.py index 3b356bb8..3e778b8b 100644 --- a/cloudinit/analyze/show.py +++ b/cloudinit/analyze/show.py @@ -201,7 +201,7 @@ def load_events(infile, rawdata=None): j = None try: j = json.loads(data) - except json.JSONDecodeError: + except ValueError: pass return j, data -- cgit v1.2.3