add the "fp" command to dump fingerprints; minor fixes to the help doc
[stack/cam.git] / cam / openssl_wrap.py
1 import logging
2 import subprocess
3
4 log = logging.getLogger(__name__)
5
6
7 class CommandError(Exception):
8     pass
9
10
11 def run(*args):
12     cmd = ['openssl']
13     cmd.extend(args)
14     log.debug('executing "%s"' % ' '.join(cmd))
15     pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE)
16     stdout, _ = pipe.communicate()
17     if pipe.returncode != 0:
18         raise CommandError('openssl exited with status %d' % (
19                 pipe.returncode,))
20     return stdout
21
22
23 def run_with_config(config_file, *args):
24     cmd = args[0]
25     args = args[1:]
26     return run(cmd, '-config', config_file, '-batch', *args)