comparison mozillatry.py @ 3:7495c25d8476

WIP
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 03 Dec 2012 21:49:55 -0800
parents 3eaee0d10880
children 14275dcbff10
comparison
equal deleted inserted replaced
2:3eaee0d10880 3:7495c25d8476
74 parser.add_option('--no-debug', dest='debug', 74 parser.add_option('--no-debug', dest='debug',
75 action='store_false', default=True, 75 action='store_false', default=True,
76 help='no debug builds') 76 help='no debug builds')
77 parser.add_option('-u', dest='unittests', action='append', 77 parser.add_option('-u', dest='unittests', action='append',
78 help='unittests') 78 help='unittests')
79 parser.add_option('-t', dest='talos', action='append', 79 parser.add_option('-t', dest='talostests',
80 action='append',
80 help='talos tests') 81 help='talos tests')
81 parser.add_option('--bug', dest='bug', type='int', 82 parser.add_option('--bug', dest='bug', type='int',
82 help='post to bugzilla bug #') 83 help='post to bugzilla bug #')
83 parser.add_option('-c', '--config', dest='config', 84 parser.add_option('-c', '--config', dest='config',
84 default=os.path.join(os.environ['HOME'], '.mozutils.ini'), 85 default=os.path.join(os.environ['HOME'], '.mozutils.ini'),
92 93
93 # XXX stub; this should really use 94 # XXX stub; this should really use
94 # e.g. http://k0s.org/mozilla/hg/configuration/ 95 # e.g. http://k0s.org/mozilla/hg/configuration/
95 from ConfigParser import ConfigParser 96 from ConfigParser import ConfigParser
96 parser = ConfigParser() 97 parser = ConfigParser()
98 if not os.path.exists(filename):
99 return parser
97 parser.read(filename) 100 parser.read(filename)
98 if options.mozilla_central is None: 101 if options.mozilla_central is None:
99 try: 102 try:
100 path = parser.get('hg', 'mozilla-central') 103 path = parser.get('hg', 'mozilla-central')
101 os.path.expanduser(path) 104 if path:
105 options.mozilla_central = os.path.expanduser(path)
102 except Exception: # XXX temporary hack 106 except Exception: # XXX temporary hack
103 pass 107 pass
104 return parser 108 return parser
109
110 def check(parser, options, args):
111 """check configuration"""
112
113 if not args:
114 parser.print_help()
115 parser.exit()
116 if (not options.opt) and (not options.debug):
117 parser.error("Must enable opt or debug builds")
105 118
106 119
107 def main(args=sys.argv[1:]): 120 def main(args=sys.argv[1:]):
108 121
109 # parse command line arguments 122 # parse command line arguments
117 else: 130 else:
118 return '' 131 return ''
119 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter()) 132 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
120 add_options(parser) 133 add_options(parser)
121 options, args = parser.parse_args(args) 134 options, args = parser.parse_args(args)
122 if not args: 135 config_file = options.config
123 parser.print_help() 136 read_config(config_file)
124 parser.exit()
125 if (not options.opt) and (not options.debug):
126 parser.error("Must enable opt or debug builds")
127 137
128 # get mozilla-central repository directory 138 # get mozilla-central repository directory
129 config_file = options.__dict__.pop('config')
130 if os.path.exists(config_file): 139 if os.path.exists(config_file):
131 read_config(config_file)
132 try_directory = options.mozilla_central 140 try_directory = options.mozilla_central
133 if (try_directory is None) or (not os.path.exists(try_directory)): 141 if (try_directory is None) or (not os.path.exists(try_directory)):
134 parser.error("mozilla-central try directory does not exist: %s" % try_directory) 142 parser.error("mozilla-central directory does not exist: %s" % try_directory)
135 143
136 # build try syntax 144 # build try syntax
137 commit = try_syntax(**options.__dict__) 145 commit = try_syntax(**options.__dict__)
138 print commit 146 print commit
139 147