finish run of initial manifest, finish shell_run_or_debug_fail()

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-09-08 14:04:30 +02:00
parent ddff3e8b57
commit 9533e579b3

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
#
@ -96,11 +97,23 @@ class Cdist:
log.error(args)
sys.exit(1)
def run_or_fail(self,*args, **kargs):
def shell_run_or_debug_fail(self, script, *args, **kargs):
kargs['shell'] = True
log.debug("Shell exec: " + " ".join(*args))
try:
subprocess.check_call(*args, **kargs)
except subprocess.CalledProcessError:
# FIXME: print out shell script!
script_fd = open(script)
log.error("Code that raised the error:\n" + script_fd.read())
script_fd.close()
self.exit_error("Non-Zero exit code exit of " + " ".join(*args))
def run_or_fail(self, *args, **kargs):
# newargs = ["echo"]
newargs = []
newargs.extend(*args)
print(newargs)
try:
subprocess.check_call(newargs, **kargs)
@ -165,15 +178,18 @@ class Cdist:
# # Link configuraion source directory - consistent with remote
# run_or_fail(["ln -sf", "$__cdist_conf_dir", "$__cdist_local_base_dir/$__cdist_name_conf_dir"])
def initial_manifes(self):
def run_initial_manifest(self):
"""Run the initial manifest"""
log.info("Running the initial manifest")
self.shell_run_or_debug_fail(self.initial_manifest, [self.initial_manifest])
def deploy_to(self):
"""Mimic the old deploy to: Deploy to one host"""
log.info("Deploying to host " + self.hostname)
self.init_deploy()
self.global_explore()
self.initial_manifest()
self.run_initial_manifest()
if __name__ == "__main__":