我需要在某些数据文件上运行此程序。当我在命令行中输入它时,通常会这样:
logic ./ case
我尝试从如下的python脚本中调用它:
def runLogic(pProtocol):
p = 2
base = os.path.basename(pProtocol[0])
path = pProtocol[0].rstrip(base)
for i in range (1,int(pProtocol[1])+1):
pAlpha = float(pProtocol[p])
pl = float(pProtocol[p+1])
case = 'Einlauf_Lippe_alpha%sdeg_l%smm'%(pAlpha, pl)
# Write mini Python scriptfile
pyPath = str(pProtocol[0])+'/Einlauf_Lippe_alpha%sdeg_l%smm/'%(pAlpha, pl)
PyScript = "import os\n\ndef executeLogic():\n case = '%s'\n os.system('logic ./ %%s'%%case)\n\nexecuteLogic()"%case
pyfile=open(pyPath + 'executeLogic.py', 'w')
pyfile.write(PyScript)
pyfile.close()
# Run local PyScript
os.system('python %sexecuteLogic.py'%pyPath)
# Remove local PyScript
os.system('rm %sexecuteLogic.py'%pyPath)
p = p + 2
i = i + 1
为了在要处理的文件所在的目录中创建本地python脚本,然后尝试执行它。迷你脚本看起来像这样:
import os
def executeLogic():
case = 'Einlauf_Lippe_alpha7.5deg_l9.0mm'
#print 'logic ./ %s'%case
os.system('logic ./ %s'%case)
executeLogic()
当我只在我的终端输入行logic ./ case
时,它工作得很好。当我尝试从python启动时,我得到以下内容:
sh: logic: command not found