From: Thierry Parmentelat Date: Tue, 1 Jan 2019 15:17:10 +0000 (+0100) Subject: various further fixes for python3 X-Git-Tag: nodemanager-7.0-0~7 X-Git-Url: http://git.onelab.eu/?p=nodemanager.git;a=commitdiff_plain;h=6f1c653e7f3712cd67d5db796eeae5c35fdddf5f various further fixes for python3 --- diff --git a/conf_files.py b/conf_files.py index 0759dba..72a0e00 100755 --- a/conf_files.py +++ b/conf_files.py @@ -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.") diff --git a/logger.py b/logger.py index 6a5d0dd..8216cfb 100644 --- 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 diff --git a/plugins/privatebridge.py b/plugins/privatebridge.py index 748d392..8e77524 100644 --- a/plugins/privatebridge.py +++ b/plugins/privatebridge.py @@ -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: diff --git a/sliver_lxc.py b/sliver_lxc.py index a9988fe..19216d7 100644 --- a/sliver_lxc.py +++ b/sliver_lxc.py @@ -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) diff --git a/tools.py b/tools.py index ffbf711..96df451 100644 --- 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)