From b6279231daf203f15392f735cce1ba572b0dd3ef Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Mon, 15 Jun 2015 09:28:20 +0300 Subject: [PATCH] agent: handle invalid commands --- agent.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/agent.py b/agent.py index 4945171..35776fd 100755 --- a/agent.py +++ b/agent.py @@ -66,7 +66,10 @@ def run(command, environ): log.debug('running %r with %r', command, environ) env = dict(os.environ) env.update(environ) - p = subprocess.Popen(args=command, env=env) + try: + p = subprocess.Popen(args=command, env=env) + except OSError as e: + raise OSError('cannot run %r: %s' % (command, e)) log.debug('subprocess %d is running', p.pid) ret = p.wait() log.debug('subprocess %d exited: %d', p.pid, ret) @@ -121,6 +124,8 @@ def main(): serve(key_files=key_files, command=args.command, signer=signer) except KeyboardInterrupt: log.info('server stopped') + except Exception as e: + log.warning(e, exc_info=True) if __name__ == '__main__': main()