diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-11-29 20:53:59 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-11-29 21:47:06 +0100 |
commit | 4dbd616221490d7e11cddff561941057bd1e1273 (patch) | |
tree | ef3588ab7f026bab833dd3852f2272afbfec4fbf /worker_manager | |
parent | 5d311716861dbfede64d884621ca787b96e574f9 (diff) | |
download | ick2-4dbd616221490d7e11cddff561941057bd1e1273.tar.gz |
Add: support for python steps in worker-manager
Diffstat (limited to 'worker_manager')
-rwxr-xr-x | worker_manager | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/worker_manager b/worker_manager index a480558..15a6ef8 100755 --- a/worker_manager +++ b/worker_manager @@ -207,24 +207,37 @@ class WorkerManager(cliapp.Application): s[stream_name] = data self.post_snippet(snippet_url, s) - def run_shell(shell_cmd): + def run_with_interp(argv_prefix, cmd): exit_code, _, _ = cliapp.runcmd_unchecked( - ['bash', '-xeuc', shell_cmd], + argv_prefix + [cmd], stdout_callback=lambda data: post('stdout', data), stderr_callback=lambda data: post('stderr', data), cwd=workspace, ) - end_snippet = dict(snippet) - end_snippet['exit_code'] = exit_code - self.post_snippet(snippet_url, end_snippet) return exit_code + def run_shell(shell_cmd): + return run_with_interp(['bash', '-xeuc'], shell_cmd) + + def run_python(python_cmd): + return run_with_interp(['python3', '-c'], python_cmd) + + def run_cmd(step): + logging.info('Running step: %r', step) + if 'shell' in step: + run_shell(step['shell']) + elif 'python' in step: + run_python(step['python']) + exit_code = 0 if work.get('fresh_workspace'): + logging.info('Make an empty workspace') exit_code = run_shell('find . -delete') if exit_code == 0: - shell_cmd = work['step']['shell'] - run_shell(shell_cmd) + run_cmd(work['step']) + end_snippet = dict(snippet) + end_snippet['exit_code'] = exit_code + self.post_snippet(snippet_url, end_snippet) def now(self): return time.strftime('%Y-%m-%dT%H:%M:%S') |