Bug 945577 - mach rbt command to run ReviewBoard Tools; r=ahal
authorGregory Szorc <gps@mozilla.com>
Fri, 06 Dec 2013 11:35:52 +0800
changeset 168344 6a4ad5ae7eb74b5385451f2d99dcb29499994871
parent 168343 40718eca5ea7dcd89b3c01826310fbcf04c27e0a
child 168345 9ff7f259d9bc1f37fd43a3c40b1368ea22b71f61
push idunknown
push userunknown
push dateunknown
reviewersahal
bugs945577
milestone28.0a1
Bug 945577 - mach rbt command to run ReviewBoard Tools; r=ahal DONTBUILD (NPOTB)
tools/mach_commands.py
--- a/tools/mach_commands.py
+++ b/tools/mach_commands.py
@@ -1,20 +1,24 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import unicode_literals
 
+import sys
+
 from mach.decorators import (
     CommandArgument,
     CommandProvider,
     Command,
 )
 
+from mozbuild.base import MachCommandBase
+
 
 @CommandProvider
 class SearchProvider(object):
     @Command('mxr', category='misc',
         description='Search for something in MXR.')
     @CommandArgument('term', nargs='+', help='Term(s) to search for.')
     def mxr(self, term):
         import webbrowser
@@ -277,8 +281,28 @@ class PastebinProvider(object):
                 print(response.geturl())
             else:
                 print('Could not upload the file, '
                       'HTTP Response Code %s' %(http_response_code))
         except urllib2.URLError:
             print('ERROR. Could not connect to pastebin.mozilla.org.')
             return 1
         return 0
+
+
+@CommandProvider
+class ReviewboardToolsProvider(MachCommandBase):
+    @Command('rbt', category='devenv',
+        description='Run Reviewboard Tools')
+    @CommandArgument('args', nargs='*', help='Arguments to rbt tool')
+    def rbt(self, args):
+        if not args:
+            args = ['help']
+
+        self._activate_virtualenv()
+        self.virtualenv_manager.install_pip_package('RBTools')
+
+        from rbtools.commands.main import main
+
+        # main() doesn't accept arguments and instead reads from sys.argv. So,
+        # we fake it out.
+        sys.argv = ['rbt'] + args
+        return main()