我正在运行此python包装程序,但是在提取tar文件后,它没有执行此命令-“ cd FVSDD_Automation”,因为pwd命令显示它仍在根目录中。因此,其余代码未正确执行,其余代码崩溃了。
#!/usr/bin/python
import sys, os
import shlex, subprocess
import time
sut = sys.argv[1]
pp = sys.argv[2]
sut_adapter = sys.argv[3]
pp_adapter = sys.argv[4]
switch_ip = sys.argv[5]
switch = sys.argv[6]
node_type = sys.argv[7]
hmc_name = sys.argv[8]
gsa_id = sys.argv[9]
gsa_pass = sys.argv[10]
f_name = sys.argv[1] + "_" + sys.argv[2] + ".p.config"
args_str="config_gen.pl {} {} {} {} {} {} {} {}".format(sut, pp, sut_adapter, pp_adapter, switch_ip, switch, node_type, hmc_name)
args_str2="/framework/scripts/ts//ts /testrepo/DD/NDD/fvndd_dedicated.p -t standard_frames_dedicated -c 4 -g /Jenkins/config/{}".format(f_name)
def test_install():
os.system("tar xvf FVSDD_Automation.tar")
time.sleep(10)
os.system("cd FVSDD_Automation")
arg_str = "AUTO_INSTALL.pl -i all {} {}".format(gsa_id, gsa_pass)
arg = shlex.split(arg_str)
pipe = subprocess.Popen(arg,bufsize=-1,stdin=subprocess.PIPE,stderr=subprocess.PIPE)
pipe.communicate()
print pipe.returncode
def test_run():
args2 = shlex.split(args_str2)
pipe = subprocess.Popen(args2,bufsize=-1,stdin=subprocess.PIPE,stderr=subprocess.PIPE)
print pipe.communicate()
print pipe.returncode
sys.stdin.close()
sys.exit(os.EX_OK)
def main():
args = "ls -d framework"
arg = shlex.split(args)
p = subprocess.Popen(arg,bufsize=-1,stdin=subprocess.PIPE,stderr=subprocess.PIPE)
p.communicate()
output = p.returncode
if output != 0:
test_install()
else:
print ("The installation is already done")
args = shlex.split(args_str)
pipe = subprocess.Popen(args,bufsize=-1,stdin=subprocess.PIPE,stderr=subprocess.PIPE)
print pipe.communicate()
print pipe.returncode
test_run()
if __name__== "__main__":
main()