changeset 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
files mozillatry.py
diffstat 1 files changed, 16 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/mozillatry.py	Mon Dec 03 21:49:55 2012 -0800
+++ b/mozillatry.py	Tue Dec 04 09:51:34 2012 -0800
@@ -4,6 +4,7 @@
 push patches to try
 """
 
+import configuration
 import optparse
 import os
 import sys
@@ -65,28 +66,21 @@
         message += ['--post-to-bugzilla', str(bug)]
     return ' '.join(message)
 
-def add_options(parser):
-    """add options for mozilla try to an OptionParser instance"""
-
-    parser.add_option('--no-opt', dest='opt',
-                      action='store_false', default=True,
-                      help='no opt builds')
-    parser.add_option('--no-debug', dest='debug',
-                      action='store_false', default=True,
-                      help='no debug builds')
-    parser.add_option('-u', dest='unittests', action='append',
-                      help='unittests')
-    parser.add_option('-t', dest='talostests',
-                      action='append',
-                      help='talos tests')
-    parser.add_option('--bug', dest='bug', type='int',
-                      help='post to bugzilla bug #')
-    parser.add_option('-c', '--config', dest='config',
-                      default=os.path.join(os.environ['HOME'], '.mozutils.ini'),
-                      help='location of config file')
-    parser.add_option('-m', '--m-c', '--mozilla-central',
-                      help="path to mozilla-central repository")
-
+class MozillaTryConfiguration(configuration.Configuration):
+    options = {'opt': {'default': True,
+                       'help': "whether to try on opt builds"},
+               'debug': {'default': True,
+                         'help': "whether to try on debug builds"},
+               'unittests': {'default': [],
+                             'help': "unit tests to run",
+                             'flags': ['-u', '--unittests']},
+               'talostests': {'default': [],
+                              'help': "talos tests to run",
+                              'flags': ['-t', '--talostests']},
+               'mozilla_central': {'help': "path to mozilla-central clone",
+                                   'required': True,
+                                   'flags': ["--m-c", "--mozilla-central"]}
+               }
 
 def read_config(filename, options):
     """read .mozutils config file and substitute for options if None"""
@@ -129,9 +123,6 @@
                 return description + '\n'
             else:
                 return ''
-    parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
-    add_options(parser)
-    options, args = parser.parse_args(args)
     config_file = options.config
     read_config(config_file)