summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2012-10-08 07:54:47 -0400
committerMartin Kosek <mkosek@redhat.com>2012-10-10 17:34:19 +0200
commit1dd103bc8c445a1fe4f5ab59a1e6a343a8984305 (patch)
treebc397d9f1214478e921139eba16f50777af5caf3 /ipapython
parent7c0f1ea5018dd692666e8c758e81f9495d14b760 (diff)
downloadfreeipa-1dd103bc8c445a1fe4f5ab59a1e6a343a8984305.tar.gz
freeipa-1dd103bc8c445a1fe4f5ab59a1e6a343a8984305.tar.xz
freeipa-1dd103bc8c445a1fe4f5ab59a1e6a343a8984305.zip
Create Firefox extension on upgrade and replica-install
If the signing cert is not available, create an unsigned extension. Add a zip dependency to the specfile. https://fedorahosted.org/freeipa/ticket/3150
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/ipautil.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index 11433b4be..0b519c295 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -223,8 +223,17 @@ def template_str(txt, vars):
return val
def template_file(infilename, vars):
- txt = open(infilename).read()
- return template_str(txt, vars)
+ """Read a file and perform template substitutions"""
+ with open(infilename) as f:
+ return template_str(f.read(), vars)
+
+
+def copy_template_file(infilename, outfilename, vars):
+ """Copy a file, performing template substitutions"""
+ txt = template_file(infilename, vars)
+ with open(outfilename, 'w') as file:
+ file.write(txt)
+
def write_tmp_file(txt):
fd = tempfile.NamedTemporaryFile()
@@ -237,7 +246,7 @@ def shell_quote(string):
return "'" + string.replace("'", "'\\''") + "'"
def run(args, stdin=None, raiseonerr=True,
- nolog=(), env=None, capture_output=True):
+ nolog=(), env=None, capture_output=True, cwd=None):
"""
Execute a command and return stdin, stdout and the process return code.
@@ -285,7 +294,7 @@ def run(args, stdin=None, raiseonerr=True,
try:
p = subprocess.Popen(args, stdin=p_in, stdout=p_out, stderr=p_err,
- close_fds=True, env=env)
+ close_fds=True, env=env, cwd=cwd)
stdout,stderr = p.communicate(stdin)
stdout,stderr = str(stdout), str(stderr) # Make pylint happy
except KeyboardInterrupt: