Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: tools/post_perf_builder_job.py

Issue 184293011: Make bisect script to post build request to try server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Post a try job to the Try server to produce build. It communicates
6 to server by directly connecting via HTTP.
qyearsley 2014/03/06 23:40:45 Any try server? I have a general question about o
prasadv 2014/03/07 01:07:44 The main purpose of this module is to post a reque
7 """
8
9 import getpass
10 import optparse
11 import os
12 import sys
13 import urllib
14 import urllib2
15
16
17 class ServerAccessError(Exception):
18 def __str__(self):
19 return '%s\nSorry, cannot connect to server.' % self.args[0]
20
21
22 def ParseArgs(options):
qyearsley 2014/03/06 23:40:45 This function could be marked as private (_ParseAr
prasadv 2014/03/07 01:07:44 Done.
23 """Parse common options passed to PostTryJob."""
qyearsley 2014/03/06 23:40:45 Style consistency note: In most places (including
prasadv 2014/03/07 01:07:44 Done.
24 values = {'host': options.host,
25 'port': options.port,
26 'user': options.user,
27 'name': options.name
28 }
29 if options.email:
30 values['email'] = options.email
31 if options.revision:
32 values['revision'] = options.revision
33 if options.root:
34 values['root'] = options.root
35 if options.bot:
36 values['bot'] = options.bot
37 if options.patch:
38 values['patch'] = options.patch
39 return values
40
41
42 def PostTryJob(url_params):
43 """Send a build request to the server using the HTTP protocol."""
qyearsley 2014/03/06 23:40:45 This docstring could be more detailed: - Which p
prasadv 2014/03/07 01:07:44 Done.
44 # Parse url parameters to be sent to Try server.
45 if not url_params.get('host'):
46 raise ServerAccessError('Hostname of server to connect is missing.')
47 if not url_params.get('port'):
48 raise ServerAccessError('Port of server to connect is missing.')
49 if not url_params.get('revision'):
50 raise ServerAccessError('Missing revision details. Please specify revision'
51 ' information.')
52 if not url_params.get('bot'):
53 raise ServerAccessError('Missing bot details. Please specify bot'
54 ' information.')
55
56 url = 'http://%s:%s/send_try_patch' % (url_params['host'], url_params['port'])
57
58 print 'Sending by HTTP'
59 query_params = '&'.join('%s=%s' % (k, v) for k, v in url_params.iteritems())
60 print 'url: %s?%s' % (url, query_params)
61
62 connection = None
63 try:
64 print 'Opening connection...'
65 connection = urllib2.urlopen(url, urllib.urlencode(url_params))
66 print 'Done, request sent to server to produce build.'
67 except IOError, e:
68 raise ServerAccessError('%s is unaccessible. Reason: %s' % (url, e))
69 if not connection:
70 raise ServerAccessError('%s is unaccessible.' % url)
71 response = connection.read()
72 print 'Received %s from server' % response
73 if response != 'OK':
74 raise ServerAccessError('%s is unaccessible. Got:\n%s' % (url, response))
75 return True
76
77
78 def gen_parser():
qyearsley 2014/03/06 23:40:45 Style: Should be GenParser (or _GenParser). Maybe
prasadv 2014/03/07 01:07:44 Done.
79 # Parse argv
qyearsley 2014/03/06 23:40:45 Should have a docstring with a sentence saying wha
prasadv 2014/03/07 01:07:44 Done.
80 usage = ('%prog [options]\n'
81 'Post a build request to the try server for the given revision.\n')
82 parser = optparse.OptionParser(usage=usage)
83 parser.add_option('-H', '--host',
84 help='Host address')
85 parser.add_option('-P', '--port', type='int',
86 help='HTTP port')
87 parser.add_option('-u', '--user', default=getpass.getuser(),
88 dest='user',
89 help='Owner user name [default: %default]')
90 parser.add_option('-e', '--email',
91 default=os.environ.get('TRYBOT_RESULTS_EMAIL_ADDRESS',
92 os.environ.get('EMAIL_ADDRESS')),
93 help='Email address where to send the results. Use either '
94 'the TRYBOT_RESULTS_EMAIL_ADDRESS environment '
95 'variable or EMAIL_ADDRESS to set the email address '
96 'the try bots report results to [default: %default]')
97 parser.add_option('-n', '--name',
98 default= 'try_job_http',
99 help='Descriptive name of the try job')
100 parser.add_option('-b', '--bot',
101 help=('IMPORTANT: specify ONE builder per run is supported.'
102 'Run script for each builders separately.'))
103 parser.add_option('-r', '--revision',
104 help='Revision to use for the try job; default: the '
105 'revision will be determined by the try server; see '
106 'its waterfall for more info')
107 parser.add_option('--root',
108 help='Root to use for the patch; base subdirectory for '
109 'patch created in a subdirectory')
110 parser.add_option('--patch',
111 help='Patch information.')
112 return parser
113
qyearsley 2014/03/06 23:40:45 Style: Should have two blank lines here.
prasadv 2014/03/07 01:07:44 Done.
114 def Main(argv):
115 parser = gen_parser()
116 options, args = parser.parse_args()
117 if not options.host:
118 raise ServerAccessError('Please use the --host option to specify the try '
119 'server host to connect to.')
120 if not options.port:
121 raise ServerAccessError('Please use the --port option to specify the try '
122 'server port to connect to.')
123 params = ParseArgs(options)
124 PostTryJob(params)
125
126
127 if __name__ == '__main__':
128 sys.exit(Main(sys.argv))
OLDNEW
« tools/bisect-perf-regression.py ('K') | « tools/bisect-perf-regression.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698