summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index be84bfdc..c1b4fd2d 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -76,15 +76,16 @@ def mergedict(src,cand):
src[k] = mergedict(src[k],v)
return src
-def write_file(file,content,mode=0644):
+def write_file(file,content,mode=0644,omode="wb"):
try:
os.makedirs(os.path.dirname(file))
except OSError as e:
if e.errno != errno.EEXIST:
raise e
- f=open(file,"wb")
- os.chmod(file,mode)
+ f=open(file,omode)
+ if mode != None:
+ os.chmod(file,mode)
f.write(content)
f.close()