def execute_installscript(options, files_to_archive, module_use):
current_perm = os.stat(options.install_script.name)
if not options.csgteam: # too often this fail for csgteam
os.chmod(options.install_script.name, current_perm.st_mode | stat.S_IEXEC)
print term.bold_green("Running ./" + options.install_script.name + "...")
stop_logging_current_session() # log the output of the script in a different dir
log = "hpci." + os.path.basename(options.install_script.name) + "-" + str(
datetime.datetime.now().isoformat().split(".")[0].replace("-", "").replace(":", "")) + ".log" # 20161116T114145
start_logging_current_session(files_to_archive, log=log)
p = subcall(module_use + "./" + options.install_script.name, use_popen=True, debug=options.debug)
process_output = " "
while process_output != "": # continue while the process is running, it'll be "" when EOF is reached
process_output = p.stdout.readline() # needs to do this instead of using subprocess.call to allow
print process_output, # 'tee' to log the process output
p.wait()
stop_logging_current_session()
files_to_archive.append(log)
start_logging_current_session(files_to_archive, continuation=True)
print term.bold_green("Done running ./" + options.install_script.name + " - exited with code " + str(p.returncode))
if p.returncode != 0:
ask_confirmation_for(True, "Running " + options.install_script.name + " failed. Archive logs anyway? ")
files_to_archive.append(options.install_script.name)
评论列表
文章目录