changeset 1:f915c612df49

fill out/fix other details for the package
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 13 Oct 2010 09:53:31 -0700
parents f1dd1069f53d
children 972f1496cff0
files sendchanges/__init__.py sendchanges/sendchanges.py setup.py
diffstat 3 files changed, 64 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/sendchanges/__init__.py	Wed Oct 13 09:21:30 2010 -0700
+++ b/sendchanges/__init__.py	Wed Oct 13 09:53:31 2010 -0700
@@ -1,1 +1,3 @@
 #
+
+from sendchanges import *
--- a/sendchanges/sendchanges.py	Wed Oct 13 09:21:30 2010 -0700
+++ b/sendchanges/sendchanges.py	Wed Oct 13 09:53:31 2010 -0700
@@ -21,7 +21,8 @@
 # the Initial Developer. All Rights Reserved.
 # 
 # Contributor(s):
-#     Jeff Hammel <jhammel@mozilla.com>     (Original author)
+#     Alice Nodelman <anodelman@mozilla.com> (Original author)
+#     Jeff Hammel <jhammel@mozilla.com>     
 # 
 # Alternatively, the contents of this file may be used under the terms of
 # either of the GNU General Public License Version 2 or later (the "GPL"),
@@ -39,65 +40,71 @@
 
 """
 forces sendchanges to test mozilla-central builds for all platforms
-usage
-sendchange master_port_number
-author: Alice Nodelman <anodelman@mozilla.com>
+usage:
+sendchanges [options]
 """
 
+# imports
+import sys
+from getlatesttinderbox import GetLatestTinderbox
+from optparse import OptionParser
+from subprocess import check_call
+
 # globals
 platforms = ['win32', 'linux', 'linux64', 'macosx64']
 branches = ['talos', 'opt-unittest', 'debug-unittest']
 ports = ['9010', '9012']
 
-# parse options
-from optparse import OptionParser
-parser = OptionParser(description=__doc__)
-parser.add_option('-p', '--port', dest='port',
-                  choices=ports, type='choice',
-                  help='buildbot masteir port number to push sendchanges to (choices: %s)' % ports)
-parser.add_option('--branch', dest='branch',
-                  choices=branches, type='choice',
-                  help='which branch to push (choices: %s)' % branches)
-parser.add_option('-u', '--url', dest='url',
-                  default=None,
-                  help='base url where the builds live')
-parser.add_option('--platform', dest='platforms', action='append',
-                  help='which platforms to run on, all by default (choices: %s)' % platforms)
+
+def main(args=sys.argv[1:]):
 
-options, args = parser.parse_args()
-
-if not options.platforms:
-  options.platforms = platforms
-
-if not options.port:
-  parser.error("Error - please specify a buildbot master port number to push sendchanges to (9010 or 9012)")
-
-if not options.branch:
-  parser.error("Error - please specify your branch")
+  # parse options
+  parser = OptionParser(description=__doc__)
+  parser.add_option('-p', '--port', dest='port',
+                    choices=ports, type='choice',
+                    help='buildbot masteir port number to push sendchanges to (choices: %s)' % ports)
+  parser.add_option('--branch', dest='branch',
+                    choices=branches, type='choice',
+                    help='which branch to push (choices: %s)' % branches)
+  parser.add_option('-u', '--url', dest='url',
+                    default=None,
+                    help='base url where the builds live')
+  parser.add_option('--platform', dest='platforms', action='append',
+                    help='which platforms to run on, all by default (choices: %s)' % platforms)
+  parser.add_option('--username', dest='username', default='sendchange_script',
+                    help="user name to send changes as")
+  options, args = parser.parse_args(args)
 
-# get the changes
-from getlatesttinderbox import GetLatestTinderbox
-changes = {}
-for platform in options.platforms:
-  if args:
-    changes[platform] = args
-    continue
-  latest = GetLatestTinderbox(platform=platform)
-  _changes = [ latest.latest_build_url(options.url) ]
-  if options.branch != 'talos':
-    _changes.append(latest.latest_tests_url(options.url))
-    _changes.append(latest.latest_symbols_url(options.url))
-  if None in _changes:
-     raise AssertionError("You mess something up! %s %s %s" % (platform, options.url, _changes))
-  changes[platform] = _changes
+  # check options
+  if not options.platforms:
+    options.platforms = platforms
+  if not options.port:
+    parser.error("Error - please specify a buildbot master port number to push sendchanges to (9010 or 9012)")
+  if not options.branch:
+    parser.error("Error - please specify your branch")
 
-# send the changes
-from subprocess import check_call
-USERNAME="sendchange_script"
-for platform in options.platforms:
-  check_call(['buildbot', 'sendchange',
-              '--user', USERNAME,
-              '--master', 'localhost:%d' % int(options.port),
-              '--branch', 'mozilla-central-%s-%s' % (platform, options.branch)]
-              + changes[platform])
+  # get the changes
+  changes = {}
+  for platform in options.platforms:
+    if args:
+      changes[platform] = args
+      continue
+    latest = GetLatestTinderbox(platform=platform)
+    _changes = [ latest.latest_build_url(options.url) ]
+    if options.branch != 'talos':
+      _changes.append(latest.latest_tests_url(options.url))
+      _changes.append(latest.latest_symbols_url(options.url))
+    if None in _changes:
+      raise AssertionError("You mess something up! %s %s %s" % (platform, options.url, _changes))
+    changes[platform] = _changes
 
+    # send the changes
+    for platform in options.platforms:
+      check_call(['buildbot', 'sendchange',
+                  '--user', options.username,
+                  '--master', 'localhost:%d' % int(options.port),
+                  '--branch', 'mozilla-central-%s-%s' % (platform, options.branch)]
+                 + changes[platform])
+
+if __name__ == '__main__':
+  main()
--- a/setup.py	Wed Oct 13 09:21:30 2010 -0700
+++ b/setup.py	Wed Oct 13 09:53:31 2010 -0700
@@ -35,7 +35,6 @@
 # 
 # ***** END LICENSE BLOCK *****
 from setuptools import setup, find_packages
-import sys, os
 
 version = '0.0'
 
@@ -55,8 +54,11 @@
       zip_safe=False,
       install_requires=[
           # -*- Extra requirements: -*-
+        'GetLatestTinderbox'
       ],
       entry_points="""
       # -*- Entry points: -*-
+      [console_scripts]
+      sendchanges = sendchanges.sendchanges:main
       """,
       )