From 1dd103bc8c445a1fe4f5ab59a1e6a343a8984305 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Mon, 8 Oct 2012 07:54:47 -0400 Subject: 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 --- ipapython/ipautil.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'ipapython/ipautil.py') diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 11433b4b..0b519c29 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: -- cgit