• R/O
  • SSH
  • HTTPS

pyhabu: Commit


Commit MetaInfo

Revision89 (tree)
Time2008-01-08 13:08:52
Authorliris

Log Message

Change Summary

Incremental Difference

--- trunk/habu/__init__.py (revision 88)
+++ trunk/habu/__init__.py (revision 89)
@@ -166,8 +166,10 @@
166166 self.scheduler = None
167167 self.servers = []
168168
169- def load(self, yamlStream):
169+ def load(self, yamlStream, includeStream = None):
170170 config = yaml.load(yamlStream)
171+ if includeStream:
172+ config.update(yaml.load(includeStream))
171173 self.environ = config.setdefault("global", None)
172174 self.lineConfigs = config.setdefault("pipeline", [])
173175 self._loadAfter(config)
--- trunk/runhabu.py (revision 88)
+++ trunk/runhabu.py (revision 89)
@@ -11,7 +11,8 @@
1111 print "Usage : %s [options] [config_file_path]" % name
1212 print "Valid Options:\n" \
1313 " -h, --help: Show this message.\n" \
14- " -v, --version: Show Version\n" \
14+ " -i, --include: include global configuration file\n" \
15+ " -V, --version: Show Version\n" \
1516 " -t, --target=TARGET_PIPELINE: Run specific pipeline.\n" \
1617 " -a, --plugin-path=PLUGIN_PATH: Append plugin paht.\n" \
1718 " --download-module=PLUGIN_NAME: download specified plugin.\n" \
@@ -34,8 +35,9 @@
3435 import os.path
3536
3637 try:
37- options, arguments = gnu_getopt(args[1:], "hVt:a:del:",
38+ options, arguments = gnu_getopt(args[1:], "hVi:t:a:del:",
3839 ["help", "version",
40+ "include",
3941 "enable-netinstall",
4042 "disable-server",
4143 "target=", "plugin-path=",
@@ -88,14 +90,23 @@
8890 bag["url"] = arg
8991 elif opt == "--pid-file":
9092 bag["pid-file"] = arg
93+ elif opt in ("-i", "--include"):
94+ bag["include"] = arg
9195
9296 return cfgFile, bag
9397
98+def readIncludeConfig(fname):
99+ if not fname:
100+ return fname
101+ return open(fname).read()
102+
94103 def prepare(cfgFile, bag):
95104 mgr = habu.Habu()
96- mgr.load(open(cfgFile).read())
105+ incCfg = readIncludeConfig(bag.get("include", None))
106+ mgr.load(open(cfgFile).read(), incCfg)
97107 mgr.addPluginPath(bag.get("plugin-path", None))
98- mgr.setProxy(bag.get("proxy-host", None), bag.get("proxy-port", 0))
108+ if bag.has_key("proxy-host") and bag.has_key("proxy-port"):
109+ mgr.setProxy(bag.get("proxy-host", None), bag.get("proxy-port", 0))
99110 if not mgr.getPipelines():
100111 print "No pipeline is defined"
101112 sys.exit(1)
Show on old repository browser