以下功能似乎很简单,但我不断得到:
NameError:未定义全局名称“this_submit”。
想法?
def sort_nodes():
host_list=Popen(hosts_cmd.split(),stdout=PIPE).communicate()[0].strip()
exec_list=Popen(exec_cmd.split(),stdout=PIPE).communicate()[0].strip()
if submit_cmd == '':
submit_list = [x for x in host_list if x not in exec_list]
else:
submit_list=Popen(submit_cmd.split(),stdout=PIPE).communicate()[0].strip()
for host in host_list:
if host in exec_list:
this_exec == 'Exec'
else:
this_exec == ''
if host in submit_list:
this_submit == 'Submit'
else:
this_submit == ''
output="%s,%s,%s\n" % (host,this_submit,this_exec)
ofile.write(output)