【发布时间】:2014-08-25 07:29:28
【问题描述】:
我正在尝试将os.system 替换为子进程模块(引用自here),但是虽然它似乎可以工作(在脚本编辑器中显示结果)但实际上并没有工作。
def convert_text(inImg, outImg, texImg):
if not os.path.exists(texImg):
Image.open(inImg).save(outImg)
#os.system('/apps/Linux64/prman-18.0/bin/txmake ' + outImg + ' ' + texImg)
subprocess.Popen("/apps/Linux64/prman-18.0/bin/txmake" + outImg + " " + texImg, shell = True)
os.remove(outImg)
print "Done converting " + inImg
上面的代码应该查找任何图像文件,将其转换为 .tif,然后是 .tex。虽然结果可能会显示Done converting /user_data/texture/testTexture_01.tga,但实际上在目录中找不到任何 .tex 文件。 (应该有 .tex 文件位于 /user_data/texture,即图像文件所在的位置)
我也尝试将其写为subprocess.Popen('/apps/Linux64/prman-18.0/bin/txmake %s %s'% (outImg, texImg), shell = True),但它不起作用。
编辑:我在 Maya 中运行以下代码,因为我正在该软件中实现该代码
我在某些方面做错了吗?
【问题讨论】:
-
@suhail 我没有看到任何错误,即使我在 Maya 中使用
echo all commands时已打开它
标签: python subprocess maya