Sleds/buildvm/scat/sledssetup.py

51 lines
1.3 KiB
Python

#!/bin/python3
'''
Created on Apr 5, 2016
author: tpweis
file name: sledssetup.py
'''
import os
import subprocess
#import shutil
from pprint import pprint
import sys
from contextlib import redirect_stdout
#import urllib
import getopt
from sleds_utilities import *
def main():
"function main"
# Now that we are ready to go, redirect output to the log file
logfile = sllogget() + "recipe.log"
with open(logfile, 'a') as f:
with redirect_stdout(f):
print("sledssetup")
# Set up the environmental variables required
slsetvars()
# using the echo command at the other end of the pipe to send a string through stdin.
# use builtin input command to fetch a line
arglist = input()
cmd, temp, args = arglist.partition(" ")
cmd_str = slsetupget() + cmd + ".py"
# Pack in the arguments ONLY if they exist. Otherwise, its simply the command
if args and args.strip():
FULL_CMD = cmd_str + " " + args
else:
FULL_CMD = cmd_str
print("Run: " + FULL_CMD)
# execute the command
subprocess.call([FULL_CMD], shell=True)
exit()
if __name__ == "__main__":
# execute only if run as a script
main()