From aeb4aed29099ab92b1397e09c0b78c9b1cf53b99 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 28 Apr 2008 17:24:35 +1000 Subject: [PATCH] Add username, password options and host:port leftover args. --- bbc | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/bbc b/bbc index 11bf30b..682b53b 100755 --- a/bbc +++ b/bbc @@ -1,6 +1,6 @@ #!/usr/bin/python # -# Command line buildbot status client +# Command line buildbot status client. # import sys @@ -10,12 +10,25 @@ from twisted.internet import reactor OPT_LIST_BUILDERS = 'list-builders' +OPT_USER = 'user' +OPT_PASSWORD = 'password' + class Options(usage.Options): optFlags = [ [OPT_LIST_BUILDERS, 'b', 'List available builders'], ] + optParameters = [ + [OPT_USER, 'u', None, 'Username to connect as'], + [OPT_PASSWORD, 'p', None, 'Password to connect with'], + ] + + def parseArgs(self, server): + host, port = server.split(':') + self['host'] = host + self['port'] = int(port) + def list_builders(connect_result, client): """List builders by name.""" @@ -36,7 +49,19 @@ if __name__ == '__main__': options.parseOptions() except usage.UsageError, errortext: print '%s: %s' % (sys.argv[0], errortext) - print '%s: Try --help for usage details.' % (sys.argv[0]) + print '%s: Try --help for usage details.' % sys.argv[0] + sys.exit(1) + + # Validate options + + if options[OPT_USER] is None: + print '%s: Must specify username' % sys.argv[0] + print options + sys.exit(1) + + if options[OPT_PASSWORD] is None: + print '%s: Must specify password' % sys.argv[0] + print options sys.exit(1) # Make buildbot connection @@ -45,7 +70,9 @@ if __name__ == '__main__': client = BuildbotClient() - d = client.connect('ldl.fc.hp.com', 8019, 'statusClient', 'clientpw') + d = client.connect( + options['host'], options['port'], + options[OPT_USER], options[OPT_PASSWORD]) # Execute commands -- 2.34.1