aboutsummaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorPaul Sokolovsky <paul.sokolovsky@linaro.org>2012-04-23 17:45:03 +0300
committerPaul Sokolovsky <paul.sokolovsky@linaro.org>2012-04-23 17:45:03 +0300
commit9b14838b95943454611884a55219bf538239bba9 (patch)
treee58467058e86711eb0efad372c7594d89c34bbb4 /node
parent5d54f9d2f5bc4053e58dc58941ccd2e3d580318d (diff)
prepare_build_config.py: Fix mistakes and add more tests.
Diffstat (limited to 'node')
-rwxr-xr-xnode/prepare_build_config.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/node/prepare_build_config.py b/node/prepare_build_config.py
index 3086453..6949305 100755
--- a/node/prepare_build_config.py
+++ b/node/prepare_build_config.py
@@ -65,11 +65,11 @@ def validate_config(config, slave_type):
raise BuildConfigMismatchException("Incompatible slave type, job owner and build type")
-def convert_config_to_shell(config_text):
+def convert_config_to_shell(config_text, out_filename):
config = {}
- out = open(BUILD_CONFIG_FILE, "w")
+ out = open(out_filename, "w")
- for l in cfg.split("\n"):
+ for l in config_text.split("\n"):
l = l.strip()
if not l or l[0] == "#":
continue
@@ -79,15 +79,25 @@ def convert_config_to_shell(config_text):
var, val = l.split("=", 1)
val = shell_unquote(val)
config[var] = val
- print "%s=%s" % (var, pipes.quote(val))
+ out.write("%s=%s\n" % (var, pipes.quote(val)))
out.close()
+ return config
-
-if __name__ == "__main__":
- config_text = base64.b64decode(sys.argv[1])
- config = convert_config_to_shell(config_text, get_slave_type())
+def main(config_in, is_base64):
+ if is_base64:
+ config_in = base64.b64decode(config_in)
+ config = convert_config_to_shell(config_in, BUILD_CONFIG_FILE)
try:
- validate_config(config)
+ validate_config(config, get_slave_type())
except BuildConfigMismatchException, e:
print str(e)
sys.exit(1)
+
+if __name__ == "__main__":
+ optparser = optparse.OptionParser(usage="%prog")
+ optparser.add_option("--base64", action="store_true", help="Process only jobs matching regex pattern")
+ options, args = optparser.parse_args(sys.argv[1:])
+ if len(args) != 1:
+ optparser.error("Wrong number of arguments")
+ main(args[0], opts.base64)
+