summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 2f5ed275..f95a5d07 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -487,6 +487,16 @@ def mergedict(src, cand):
@contextlib.contextmanager
+def chdir(ndir):
+ curr = os.getcwd()
+ try:
+ os.chdir(ndir)
+ yield ndir
+ finally:
+ os.chdir(curr)
+
+
+@contextlib.contextmanager
def umask(n_msk):
old = os.umask(n_msk)
try:
@@ -1285,6 +1295,10 @@ def subp(args, data=None, rcs=None, env=None, capture=True, shell=False):
return (out, err)
+def abs_join(*paths):
+ return os.path.abspath(os.path.join(*paths))
+
+
# shellify, takes a list of commands
# for each entry in the list
# if it is an array, shell protect it (with single ticks)