Run python-modernize fixers
authorBen Steffen <bds@mit.edu>
Mon, 25 Nov 2019 22:50:19 +0000 (17:50 -0500)
committerBen Steffen <bds@mit.edu>
Mon, 25 Nov 2019 22:50:19 +0000 (17:50 -0500)
python/invirt/authz.py
python/invirt/common.py
python/invirt/config.py
python/invirt/remctl.py

index f5f02a0..791dbf3 100644 (file)
@@ -9,6 +9,7 @@ a unique name. That name can then be configured in
 """
 
 
+from __future__ import absolute_import
 import pkg_resources
 
 from invirt.config import structs as cfg
index 57fea45..923d672 100644 (file)
@@ -1,5 +1,6 @@
 from __future__ import with_statement
 
+from __future__ import absolute_import
 import unittest
 from fcntl import flock, LOCK_EX, LOCK_SH, LOCK_UN
 import contextlib as clib
@@ -55,7 +56,7 @@ def dicts2struct(x, prefix = None, default = None):
 
 @clib.contextmanager
 def lock_file(path, exclusive = True):
-    with clib.closing(file(path, 'w')) as f:
+    with clib.closing(open(path, 'w')) as f:
         if exclusive:
             locktype = LOCK_EX
         else:
index 626b76a..1589889 100644 (file)
@@ -1,5 +1,6 @@
 from __future__ import with_statement
 
+from __future__ import absolute_import
 import json
 from invirt.common import *
 import os
@@ -63,7 +64,7 @@ def list_files():
 def load_master():
     config = dict()
     for filename in list_files():
-        with closing(file(filename)) as f:
+        with closing(open(filename)) as f:
             augment(config, yaml.load(f, loader))
     return config
 
@@ -116,7 +117,7 @@ def load(force_refresh = False):
         # lock with other concurrent reads).  This isolation is accomplished
         # using an atomic filesystem rename in the refreshing stage.
         try: 
-            with closing(file(cache_path)) as f:
+            with closing(open(cache_path)) as f:
                 ns.cfg = json.read(f.read())
         except: do_refresh = True
 
@@ -131,7 +132,7 @@ def load(force_refresh = False):
             with lock_file(lock_path):
                 ns.cfg = load_master()
                 try: 
-                    with closing(file(cache_path + '.tmp', 'w')) as f:
+                    with closing(open(cache_path + '.tmp', 'w')) as f:
                         f.write(json.write(ns.cfg))
                 except: pass # silent failure
                 else: rename(cache_path + '.tmp', cache_path)
index 956ca2d..5466375 100644 (file)
@@ -2,6 +2,8 @@
 Functions to perform remctls.
 """
 
+from __future__ import absolute_import
+from __future__ import print_function
 from invirt.common import CodeError
 import subprocess
 import sys
@@ -39,7 +41,7 @@ def remctl(host, *args, **kws):
     if kws.get('err'):
         return stdout, stderr
     if p.returncode:
-        print >> sys.stderr, 'Error', p.returncode, 'on remctl', args, ':'
-        print >> sys.stderr, stderr
+        print('Error', p.returncode, 'on remctl', args, ':', file=sys.stderr)
+        print(stderr, file=sys.stderr)
         raise CodeError('ERROR on remctl')
     return stdout