summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2015-01-21 15:35:56 -0500
committerBarry Warsaw <barry@python.org>2015-01-21 15:35:56 -0500
commitcccc0ff012d2e7b5c238609b22cc064b519e54a5 (patch)
tree1ca463be706ede0f0b3f0d967f67de79d13e5793 /cloudinit
parent463d626ba53e54160f350d84831e1877b24f4024 (diff)
downloadvyos-cloud-init-cccc0ff012d2e7b5c238609b22cc064b519e54a5.tar.gz
vyos-cloud-init-cccc0ff012d2e7b5c238609b22cc064b519e54a5.zip
Fix file modes to be Python 2/3 compatible.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/distros/__init__.py2
-rw-r--r--cloudinit/util.py8
2 files changed, 5 insertions, 5 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index 5eab780b..a913e15a 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -272,7 +272,7 @@ class Distro(object):
if header:
contents.write("%s\n" % (header))
contents.write("%s\n" % (eh))
- util.write_file(self.hosts_fn, contents.getvalue(), mode=0644)
+ util.write_file(self.hosts_fn, contents.getvalue(), mode=0o644)
def _bring_up_interface(self, device_name):
cmd = ['ifup', device_name]
diff --git a/cloudinit/util.py b/cloudinit/util.py
index bf8e7d80..9efc704a 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -1250,7 +1250,7 @@ def rename(src, dest):
os.rename(src, dest)
-def ensure_dirs(dirlist, mode=0755):
+def ensure_dirs(dirlist, mode=0o755):
for d in dirlist:
ensure_dir(d, mode)
@@ -1264,7 +1264,7 @@ def read_write_cmdline_url(target_fn):
return
try:
if key and content:
- write_file(target_fn, content, mode=0600)
+ write_file(target_fn, content, mode=0o600)
LOG.debug(("Wrote to %s with contents of command line"
" url %s (len=%s)"), target_fn, url, len(content))
elif key and not content:
@@ -1489,7 +1489,7 @@ def append_file(path, content):
write_file(path, content, omode="ab", mode=None)
-def ensure_file(path, mode=0644):
+def ensure_file(path, mode=0o644):
write_file(path, content='', omode="ab", mode=mode)
@@ -1507,7 +1507,7 @@ def chmod(path, mode):
os.chmod(path, real_mode)
-def write_file(filename, content, mode=0644, omode="wb"):
+def write_file(filename, content, mode=0o644, omode="wb"):
"""
Writes a file with the given content and sets the file mode as specified.
Resotres the SELinux context if possible.