[Buildbot-commits] buildbot/buildbot/scripts runner.py,1.12,1.13
Brian Warner
warner at users.sourceforge.net
Tue Apr 26 09:14:12 UTC 2005
Update of /cvsroot/buildbot/buildbot/buildbot/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24822/buildbot/scripts
Modified Files:
runner.py
Log Message:
* buildbot/scripts/runner.py (loadOptions): add code to search for
~/.buildbot/, a directory with things like 'options', containing
defaults for various 'buildbot' subcommands. .buildbot/ can be in
the current directory, your $HOME directory, or anywhere
inbetween, as long as you're somewhere inside your home directory.
(debugclient): look in ~/.buildbot/options for master and passwd
(statuslog): look in ~/.buildbot/options for 'masterstatus'
* buildbot/test/test_runner.py (Options.testFindOptions): test it
Index: runner.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/scripts/runner.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- runner.py 23 Apr 2005 10:37:00 -0000 1.12
+++ runner.py 26 Apr 2005 09:14:10 -0000 1.13
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+# -*- test-case-name: buildbot.test.test_runner -*-
# N.B.: don't import anything that might pull in a reactor yet. Some of our
# subcommands want to load modules that need the gtk reactor.
@@ -141,6 +141,57 @@
# TODO: poll once per second until twistd.pid goes away
sys.exit(0)
+def loadOptions(here=None, filename="options"):
+ """Find the .buildbot/FILENAME file. If we're somewhere under the user's
+ home directory, look in all directories between here and $HOME. If we're
+ elsewhere, only look in $HOME. exec() the first 'options' file we find.
+
+ @rtype : dict
+ @return: a dictionary of names defined in the options file. If no options
+ file was found, return an empty dict."""
+
+ if here is None:
+ here = os.getcwd()
+ here = os.path.abspath(here)
+ home = os.path.expanduser("~")
+ searchpath = []
+ toomany = 20
+ while True:
+ searchpath.append(here)
+ if here == home:
+ break
+ next = os.path.dirname(here)
+ if next == here:
+ # we've hit the root, without seeing $HOME, so ignore everything
+ # except the user's home directory
+ searchpath = [home]
+ break # we've hit the root
+ here = next
+ toomany -= 1 # just in case
+ if toomany == 0:
+ raise ValueError("Hey, I seem to have wandered up into the "
+ "infinite glories of the heavens. Oops.")
+
+ localDict = {}
+
+ for d in searchpath:
+ if os.path.isdir(os.path.join(d, ".buildbot")):
+ optfile = os.path.join(d, ".buildbot", filename)
+ if os.path.exists(optfile):
+ try:
+ f = open(optfile, "r")
+ options = f.read()
+ exec options in localDict
+ except:
+ print "error while reading %s" % optfile
+ raise
+ break
+
+ for k in localDict.keys():
+ if k.startswith("__"):
+ del localDict[k]
+ return localDict
+
class Base(usage.Options):
optFlags = [
['help', 'h', "Display this message"],
@@ -192,9 +243,9 @@
['help', 'h', "Display this message"],
]
optParameters = [
- ["master", "m", "localhost:8007",
+ ["master", "m", None,
"Location of the buildmaster's slaveport (host:port)"],
- ["passwd", "p", "debugpw", "Debug password to use"],
+ ["passwd", "p", None, "Debug password to use"],
]
def parseArgs(self, *args):
@@ -207,8 +258,23 @@
def debugclient(config):
from buildbot.clients import debug
- print "config is", config
- d = debug.DebugWidget(config['master'], config['passwd'])
+ opts = loadOptions()
+
+ master = config.get('master')
+ if not master:
+ master = opts.get('master')
+ if master is None:
+ raise usage.UsageError("master must be specified: on the command "
+ "line or in ~/.buildbot/options")
+
+ passwd = config.get('passwd')
+ if not passwd:
+ passwd = opts.get('debugPassword')
+ if passwd is None:
+ raise usage.UsageError("passwd must be specified: on the command "
+ "line or in ~/.buildbot/options")
+
+ d = debug.DebugWidget(master, passwd)
d.run()
class StatusClientOptions(usage.Options):
@@ -216,7 +282,7 @@
['help', 'h', "Display this message"],
]
optParameters = [
- ["master", "m", "localhost:8007",
+ ["master", "m", None,
"Location of the buildmaster's status port (host:port)"],
]
@@ -228,12 +294,26 @@
def statuslog(config):
from buildbot.clients import base
- c = base.TextClient(config['master'])
+ opts = loadOptions()
+ master = config.get('master')
+ if not master:
+ master = opts.get('masterstatus')
+ if master is None:
+ raise usage.UsageError("master must be specified: on the command "
+ "line or in ~/.buildbot/options")
+ c = base.TextClient(master)
c.run()
def statusgui(config):
from buildbot.clients import gtkPanes
- c = gtkPanes.GtkClient(config['master'])
+ opts = loadOptions()
+ master = config.get('master')
+ if not master:
+ master = opts.get('masterstatus')
+ if master is None:
+ raise usage.UsageError("master must be specified: on the command "
+ "line or in ~/.buildbot/options")
+ c = gtkPanes.GtkClient(master)
c.run()
class Options(usage.Options):
More information about the Commits
mailing list