← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~ajorgens/cloud-init:py27-analyze into cloud-init:master

 

Andrew Jorgensen has proposed merging ~ajorgens/cloud-init:py27-analyze into cloud-init:master.

Requested reviews:
  cloud-init commiters (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~ajorgens/cloud-init/+git/cloud-init/+merge/329653

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.
-- 
Your team cloud-init commiters is requested to review the proposed merge of ~ajorgens/cloud-init:py27-analyze into cloud-init:master.
diff --git a/cloudinit/analyze/__main__.py b/cloudinit/analyze/__main__.py
index 71cba4f..69b9e43 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 3b356bb..3e778b8 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

Follow ups