Mercurial > mozilla > hg > MozillaTry
comparison mozillatry.py @ 7:51d1167cc684
something still wrong here but on the right track, i hope
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 04 Dec 2012 13:22:39 -0800 |
parents | 6f35d0d90c64 |
children | 7423fa8b4343 |
comparison
equal
deleted
inserted
replaced
6:6f35d0d90c64 | 7:51d1167cc684 |
---|---|
64 message += ['-t', (','.join(talos) if talos else 'none')] | 64 message += ['-t', (','.join(talos) if talos else 'none')] |
65 if bug: | 65 if bug: |
66 message += ['--post-to-bugzilla', 'Bug', str(bug)] | 66 message += ['--post-to-bugzilla', 'Bug', str(bug)] |
67 return ' '.join(message) | 67 return ' '.join(message) |
68 | 68 |
69 ### configuration parsing | |
70 | |
71 class ConfigurationError(Exception): | |
72 """error when checking configuration""" | |
73 | |
69 class MozillaTryConfiguration(configuration.Configuration): | 74 class MozillaTryConfiguration(configuration.Configuration): |
70 | 75 |
71 usage = '%prog [options] patch <patch2> <...>' | 76 usage = '%prog [options] patch <patch2> <...>' |
72 options = {'opt': {'default': True, | 77 options = {'opt': {'default': True, |
73 'help': "whether to try on opt builds"}, | 78 'help': "whether to try on opt builds"}, |
85 } | 90 } |
86 | 91 |
87 def __init__(self): | 92 def __init__(self): |
88 configuration.Configuration.__init__(self, usage=self.usage, load='--config') | 93 configuration.Configuration.__init__(self, usage=self.usage, load='--config') |
89 | 94 |
90 def check(self, parser, options, args): | 95 def check(self, config): |
91 """check configuration""" | 96 """check configuration""" |
92 | 97 |
93 if not args: | 98 if (not config.get('opt')) and (not config.get('debug')): |
94 parser.print_help() | 99 raise ConfigurationError("Must have opt or debug builds") |
95 parser.exit() | |
96 if (not options.opt) and (not options.debug): | |
97 parser.error("Must enable opt or debug builds") | |
98 | 100 |
99 | 101 |
100 def read_config(filename, options): | 102 def read_config(filename, options): |
101 """read .mozutils config file and substitute for options if None""" | 103 """read .mozutils config file and substitute for options if None""" |
102 | 104 |
121 def main(args=sys.argv[1:]): | 123 def main(args=sys.argv[1:]): |
122 | 124 |
123 # parse command line arguments | 125 # parse command line arguments |
124 parser = MozillaTryConfiguration() | 126 parser = MozillaTryConfiguration() |
125 options, args = parser.parse_args() | 127 options, args = parser.parse_args() |
128 if not args: | |
129 parser.print_usage() | |
130 parser.exit() | |
126 | 131 |
127 # get mozilla-central repository directory | 132 # get mozilla-central repository directory |
128 try_directory = options.mozilla_central | 133 try_directory = options.mozilla_central |
129 if (try_directory is None) or (not os.path.exists(try_directory)): | 134 if (try_directory is None) or (not os.path.exists(try_directory)): |
130 parser.error("mozilla-central directory does not exist: %s" % try_directory) | 135 parser.error("mozilla-central directory does not exist: %s" % try_directory) |