comparison mozillatry.py @ 4:14275dcbff10

begin switching to configuration package
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 04 Dec 2012 09:51:34 -0800
parents 7495c25d8476
children 416f4562005c
comparison
equal deleted inserted replaced
3:7495c25d8476 4:14275dcbff10
2 2
3 """ 3 """
4 push patches to try 4 push patches to try
5 """ 5 """
6 6
7 import configuration
7 import optparse 8 import optparse
8 import os 9 import os
9 import sys 10 import sys
10 11
11 from subprocess import check_call as call 12 from subprocess import check_call as call
63 message += ['-t', (','.join(talos) if talos else 'none')] 64 message += ['-t', (','.join(talos) if talos else 'none')]
64 if bug: 65 if bug:
65 message += ['--post-to-bugzilla', str(bug)] 66 message += ['--post-to-bugzilla', str(bug)]
66 return ' '.join(message) 67 return ' '.join(message)
67 68
68 def add_options(parser): 69 class MozillaTryConfiguration(configuration.Configuration):
69 """add options for mozilla try to an OptionParser instance""" 70 options = {'opt': {'default': True,
70 71 'help': "whether to try on opt builds"},
71 parser.add_option('--no-opt', dest='opt', 72 'debug': {'default': True,
72 action='store_false', default=True, 73 'help': "whether to try on debug builds"},
73 help='no opt builds') 74 'unittests': {'default': [],
74 parser.add_option('--no-debug', dest='debug', 75 'help': "unit tests to run",
75 action='store_false', default=True, 76 'flags': ['-u', '--unittests']},
76 help='no debug builds') 77 'talostests': {'default': [],
77 parser.add_option('-u', dest='unittests', action='append', 78 'help': "talos tests to run",
78 help='unittests') 79 'flags': ['-t', '--talostests']},
79 parser.add_option('-t', dest='talostests', 80 'mozilla_central': {'help': "path to mozilla-central clone",
80 action='append', 81 'required': True,
81 help='talos tests') 82 'flags': ["--m-c", "--mozilla-central"]}
82 parser.add_option('--bug', dest='bug', type='int', 83 }
83 help='post to bugzilla bug #')
84 parser.add_option('-c', '--config', dest='config',
85 default=os.path.join(os.environ['HOME'], '.mozutils.ini'),
86 help='location of config file')
87 parser.add_option('-m', '--m-c', '--mozilla-central',
88 help="path to mozilla-central repository")
89
90 84
91 def read_config(filename, options): 85 def read_config(filename, options):
92 """read .mozutils config file and substitute for options if None""" 86 """read .mozutils config file and substitute for options if None"""
93 87
94 # XXX stub; this should really use 88 # XXX stub; this should really use
127 description = description.strip() 121 description = description.strip()
128 if description: 122 if description:
129 return description + '\n' 123 return description + '\n'
130 else: 124 else:
131 return '' 125 return ''
132 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
133 add_options(parser)
134 options, args = parser.parse_args(args)
135 config_file = options.config 126 config_file = options.config
136 read_config(config_file) 127 read_config(config_file)
137 128
138 # get mozilla-central repository directory 129 # get mozilla-central repository directory
139 if os.path.exists(config_file): 130 if os.path.exists(config_file):