various further fixes for python3
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 1 Jan 2019 15:17:10 +0000 (16:17 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 1 Jan 2019 15:17:10 +0000 (16:17 +0100)
conf_files.py
logger.py
plugins/privatebridge.py
sliver_lxc.py
tools.py

index 0759dba..72a0e00 100755 (executable)
@@ -108,7 +108,7 @@ def start():
 
 def GetSlivers(data, config=None, plc=None):
     logger.log("conf_files: Running.")
-    instance = conf_files()
+    instance = ConfFiles()
     instance.run_once(data)
     logger.log("conf_files: Done.")
 
index 6a5d0dd..8216cfb 100644 (file)
--- a/logger.py
+++ b/logger.py
@@ -130,8 +130,11 @@ def log_call(command, timeout=default_timeout_minutes*60, poll=1):
     trigger=time.time()+timeout
     result = False
     try:
-        child = subprocess.Popen(command, bufsize=1,
-                                 stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
+        child = subprocess.Popen(
+            command, bufsize=1,
+            stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+            close_fds=True,
+            universal_newlines=True)
         buffer = Buffer()
         while True:
             # see if anything can be read within the poll interval
index 748d392..8e77524 100644 (file)
@@ -31,8 +31,11 @@ def log_call_read(command, timeout=logger.default_timeout_minutes*60, poll=1):
     logger.verbose("log_call: poll=%r s" % poll)
     trigger=time.time()+timeout
     try:
-        child = subprocess.Popen(command, bufsize=1,
-                                 stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
+        child = subprocess.Popen(
+            command, bufsize=1,
+            stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+            close_fds=True,
+            universal_newlines=True)
 
         stdout = ""
         while True:
index a9988fe..19216d7 100644 (file)
@@ -151,7 +151,8 @@ class Sliver_LXC(Sliver_Libvirt, Initscript):
         # this assumes the reference image is in its own subvolume
         command = ['btrfs', 'subvolume', 'snapshot', refImgDir, containerDir]
         if not logger.log_call(command, timeout=BTRFS_TIMEOUT):
-            logger.log('sliver_lxc: ERROR Could not create BTRFS snapshot at', containerDir)
+            logger.log('sliver_lxc: ERROR Could not create BTRFS snapshot at {}'
+                       .format(containerDir))
             return
         command = ['chmod', '755', containerDir]
         logger.log_call(command)
index ffbf711..96df451 100644 (file)
--- a/tools.py
+++ b/tools.py
@@ -197,7 +197,7 @@ returns True if a change occurred, or the file is deleted
     # overwrite target file: create a temp in the same directory
     path = os.path.dirname(target) or '.'
     fd, name = tempfile.mkstemp('', 'repl', path)
-    os.write(fd, new_contents)
+    os.write(fd, new_contents.encode())
     os.close(fd)
     if os.path.exists(target):
         os.unlink(target)