Skip to content

Instantly share code, notes, and snippets.

@yeukhon
Created September 28, 2012 20:09
Show Gist options
  • Save yeukhon/3801860 to your computer and use it in GitHub Desktop.
Save yeukhon/3801860 to your computer and use it in GitHub Desktop.
runner.py
#!/usr/bin/env python
import yaml, json
from subprocess import Popen, PIPE
CONFIG_FILE = "config.yaml"
def read_config(filename):
with open(filename, "r") as f:
return yaml.load(f)
def run():
config=read_config(CONFIG_FILE)
output_report = {}
#if config['RUN_STUDENT_FILE']:
# cmd = ['python',config['STUDENT_RUNFILE']]
# pid = Popen(cmd, stdout=PIPE, stderr=PIPE)
# stdout, stderr = pid.communicate()
# output_report['stdout']=stdout
# output_report['stderr']=stderr
if config['run_nosetests']:
cmd = ['nosetests',
'--with-xunit',
'--xunit-file='+config['nose_report_file'] ]
pid = Popen(cmd,stdout=PIPE,stderr=PIPE)
stdout, stderr = pid.communicate()
output_report['test_stdout']=stdout
output_report['test_stderr']=stderr
return json.dumps(output_report)
if __name__ == "__main__":
print run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment