diff options
author | Barry Warsaw <barry@python.org> | 2015-01-22 21:21:04 -0500 |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2015-01-22 21:21:04 -0500 |
commit | 3b798b5d5c3caa5d0e8e534855e29010ca932aaa (patch) | |
tree | c517762e79e4421d9b5a1be74cfe5776a7b9427a /cloudinit/util.py | |
parent | 6f2a62c2fde85839ed437549597498a707f5da68 (diff) | |
download | vyos-cloud-init-3b798b5d5c3caa5d0e8e534855e29010ca932aaa.tar.gz vyos-cloud-init-3b798b5d5c3caa5d0e8e534855e29010ca932aaa.zip |
Low hanging Python 3 fruit.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index 434ba7fb..94fd5c70 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -142,6 +142,9 @@ class ProcessExecutionError(IOError): 'reason': self.reason, } IOError.__init__(self, message) + # For backward compatibility with Python 2. + if not hasattr(self, 'message'): + self.message = message class SeLinuxGuard(object): @@ -260,7 +263,7 @@ def translate_bool(val, addons=None): def rand_str(strlen=32, select_from=None): if not select_from: - select_from = string.letters + string.digits + select_from = string.ascii_letters + string.digits return "".join([random.choice(select_from) for _x in range(0, strlen)]) @@ -1127,7 +1130,7 @@ def pipe_in_out(in_fh, out_fh, chunk_size=1024, chunk_cb=None): bytes_piped = 0 while True: data = in_fh.read(chunk_size) - if data == '': + if len(data) == 0: break else: out_fh.write(data) |