Chromium Code Reviews| Index: trigger_ct_lua |
| diff --git a/trigger_ct_lua b/trigger_ct_lua |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..6c61fd0bf65b9d9b0b9b6294677d4156383498f0 |
| --- /dev/null |
| +++ b/trigger_ct_lua |
| @@ -0,0 +1,71 @@ |
| +#!/usr/bin/env python |
| + |
| + |
| +""" Trigger a Cluster Telemetry job with the given Lua script. """ |
| + |
| + |
| +import argparse |
| +import getpass |
| +import httplib2 |
| +import subprocess |
| +import urllib |
| + |
| + |
| +CT_URL = 'https://skia-tree-status.appspot.com/skia-telemetry/add_lua_task' |
| +POST_DATA = ('username=%s' |
| + '&password=%s' |
| + '&description=%s' |
| + '&lua_script=%s' |
| + '&pagesets_type_and_chromium_build=' |
| + '10k-1f255cfb7df10bc635d2495f71e6d0e6975b9e3a-' |
| + 'c94a028ff836f8f0af41ec33ceb1f4bc140841bf') |
|
borenet
2015/06/26 19:58:45
I just hard-coded this for now. Ideally the defaul
rmistry
2015/06/26 20:16:01
Yes it should be simple to fix this on the fronten
|
| + |
| + |
| +def trigger_ct_run(user, password, description, script, aggregator=None): |
| + """Trigger a Cluster Telemetry run of the given script.""" |
| + with open(script) as f: |
| + script_contents = f.read() |
| + |
| + body = POST_DATA % (user, password, description, script_contents) |
| + |
| + if aggregator: |
| + with open(aggregator) as f: |
| + body += '&lua_aggregator=%s' % f.read() |
| + |
| + resp, content = httplib2.Http('.cache').request(CT_URL, 'POST', body=body) |
| + if resp['status'] != '200': |
| + raise Exception( |
| + 'Failed to trigger Cluster Telemetry job: (%s): %s' % ( |
| + resp['status'], content)) |
| + |
| + |
| +def parse_args(): |
| + """Parse command-line flags and obtain any additional information.""" |
| + parser = argparse.ArgumentParser( |
| + description='Trigger a Cluster Telemetry job with the given Lua script.') |
| + parser.add_argument('script', help='Lua script to run') |
| + parser.add_argument('--aggregator', help='Aggregator script') |
| + parser.add_argument('--description', help='Description of the job.') |
| + parser.add_argument('--email', help='Email address to send results') |
| + args = parser.parse_args() |
| + |
| + user = args.email |
| + if not user: |
| + user = subprocess.check_output(['git', 'config', 'user.email']).rstrip() |
| + |
| + password = getpass.getpass( |
| + 'Enter the skia_status_password ' |
| + '(on https://valentine.corp.google.com/): ') |
|
borenet
2015/06/26 19:58:45
This kills the automation. An alternative is to a
rmistry
2015/06/26 20:16:01
Yes all of this sounds good :)
|
| + |
| + return user, password, args.description, args.script, args.aggregator |
| + |
| + |
| +def main(): |
| + user, password, description, script, aggregator = parse_args() |
| + trigger_ct_run(user, password, description, script, aggregator) |
| + print ('Successfully triggered Cluster Telemetry job. View the queue at ' |
| + 'https://skia-tree-status.appspot.com/skia-telemetry/pending_tasks') |
| + |
| + |
| +if __name__ == '__main__': |
| + main() |