5 log = logging.getLogger(__name__)
8 class CommandError(Exception):
12 def run(*args, **env_vars):
15 env = dict(os.environ)
17 log.debug('executing "%s"' % ' '.join(cmd))
18 pipe = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE)
19 stdout, _ = pipe.communicate()
20 if pipe.returncode != 0:
21 raise CommandError('openssl exited with status %d' % (
26 def run_with_config(caroot, config_file, *args):
29 caroot = os.path.abspath(caroot)
30 return run(cmd, '-config', config_file, '-batch', *args, CAROOT=caroot)