2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
16 parser
= optparse
.OptionParser(usage
='%prog [options] <URL to load>')
17 parser
.add_option('--post', help='POST to URL.', dest
='post',
19 parser
.add_option('--get', help='GET to URL.', dest
='get',
21 parser
.add_option('--sleep',
22 help='Number of seconds to sleep after reading URL',
23 dest
='sleep', default
=0)
24 parser
.add_option('--expect-to-be-killed', help='If set, the script will warn'
25 ' if it isn\'t killed before it finishes sleeping.',
26 dest
='expect_to_be_killed', action
='store_true')
27 options
, args
= parser
.parse_args(args
)
29 parser
.error('Expected URL to load.')
31 PrintAndFlush('Starting %s.' % sys
.argv
[0])
34 urllib2
.urlopen(args
[0], data
='').read()
36 urllib2
.urlopen(args
[0]).read()
38 # Do nothing but wait to be killed.
41 time
.sleep(float(options
.sleep
))
43 if options
.expect_to_be_killed
:
44 PrintAndFlush('Done sleeping. Expected to be killed.')
47 if __name__
== '__main__':
48 sys
.exit(main(sys
.argv
[1:]))