Start of command line buildbot status client.
authorTim Potter <tpot@hp.com>
Thu, 10 Apr 2008 08:19:46 +0000 (18:19 +1000)
committerTim Potter <tpot@hp.com>
Thu, 10 Apr 2008 08:19:46 +0000 (18:19 +1000)
bbc [new file with mode: 0755]
bbclient.py

diff --git a/bbc b/bbc
new file mode 100755 (executable)
index 0000000..11bf30b
--- /dev/null
+++ b/bbc
@@ -0,0 +1,59 @@
+#!/usr/bin/python
+#
+# Command line buildbot status client
+#
+
+import sys
+
+from twisted.python import usage
+from twisted.internet import reactor
+
+OPT_LIST_BUILDERS = 'list-builders'
+
+class Options(usage.Options):
+
+    optFlags = [
+        [OPT_LIST_BUILDERS, 'b', 'List available builders'],
+    ]
+
+def list_builders(connect_result, client):
+    """List builders by name."""
+
+    d = client.getBuilderNames()
+
+    d.addCallback(
+        lambda names: [sys.stdout.write('%s\n' % name) for name in names])
+
+    d.addBoth(lambda arg: reactor.stop())
+
+if __name__ == '__main__':
+
+    # Command line options
+
+    options = Options()
+
+    try:
+        options.parseOptions()
+    except usage.UsageError, errortext:
+        print '%s: %s' % (sys.argv[0], errortext)
+        print '%s: Try --help for usage details.' % (sys.argv[0])
+        sys.exit(1)
+
+    # Make buildbot connection
+
+    from bbclient import BuildbotClient
+
+    client = BuildbotClient()
+    
+    d = client.connect('ldl.fc.hp.com', 8019, 'statusClient', 'clientpw')
+
+    # Execute commands
+
+    if options[OPT_LIST_BUILDERS] == 1:
+        d.addCallback(list_builders, client)
+    else:
+        print '%s: Must specify an operation to perform!' % sys.argv[0]
+        print options
+        sys.exit(1)
+
+    reactor.run()
index 7aeae67..ca40519 100644 (file)
@@ -46,6 +46,9 @@ class BuildbotClient:
     def subscribe(self, mode, interval, target):
         return self.remote.callRemote('subscribe', mode, interval, target)
 
+    def getBuilderNames(self):
+        return self.remote.callRemote('getBuilderNames')
+
 def CommandLineOptions():
     """Return hostname, port, user and password command line options."""