#!/usr/bin/env python2.7 # This script provides an interface for sandboxed code to trigger buildbot # using plain HTTP from bottle import post, request, run, HTTPResponse trigger_names = [ 'repo_update', 'definitions_update', 'build_complete'] def call_trigger(trigger_name,*args): global trigger_names assert trigger_name in trigger_names import subprocess trigger_cmd = ['sh','source/%s' % trigger_name] for arg in args: trigger_cmd.append(arg) trigger_ballback = subprocess.Popen(trigger_cmd) return trigger_callback.wait() @post('/repo_update') def repo_update(): repo_name = request.forms.get("repo_name") if not repo_name: return HTTPResponse( status=400, body="400: A repo_name is required") if call_trigger('repo_update',repo_name): return HTTPResponse(status=500) return 0 @post('/definitions_update') def definitions_update(): pass @post('/build_complete') def repo_update(): pass if __name__ == '__main__': run(host='localhost', port=8080, debug=True)