pushimage: fix up for python 3

Make sure the dict ordering is consistent, and use context managers
with open to avoid warnings about unclosed file handles.

BUG=chromium:997354
TEST=`./run_tests` passes

Change-Id: Ia3b8ed333afd326ba7f85140a572415063e42643
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1872656
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/pushimage.py b/scripts/pushimage.py
index fd25c24..c5c6122 100644
--- a/scripts/pushimage.py
+++ b/scripts/pushimage.py
@@ -88,7 +88,8 @@
     self.buildroot = buildroot or constants.SOURCE_ROOT
 
     config = configparser.ConfigParser()
-    config.readfp(open(self.GetInsnFile('DEFAULT')))
+    with open(self.GetInsnFile('DEFAULT')) as fp:
+      config.readfp(fp)
 
     # What pushimage internally refers to as 'recovery', are the basic signing
     # instructions in practice, and other types are stacked on top.
@@ -99,7 +100,8 @@
     if not os.path.exists(input_insns):
       # This board doesn't have any signing instructions.
       raise MissingBoardInstructions(self.board, image_type, input_insns)
-    config.readfp(open(input_insns))
+    with open(input_insns) as fp:
+      config.readfp(fp)
 
     if image_type is not None:
       input_insns = self.GetInsnFile(image_type)
@@ -108,7 +110,8 @@
         raise MissingBoardInstructions(self.board, image_type, input_insns)
 
       self.image_type = image_type
-      config.readfp(open(input_insns))
+      with open(input_insns) as fp:
+        config.readfp(fp)
 
     self.cfg = config