我得到了这个片段,我用图片文件转换为TIFF。我想在文件无法转换时收到通知。 Imagemagick成功运行时退出0,所以我想下面的代码片段会报告问题。然而,根本没有报道任何错误。Python OSError不报告错误
def image(filePath,dirPath,fileUUID,shortFile):
try:
os.system("convert " + filePath + " +compress " + dirPath + "/" + shortFile + ".tif")
except OSError, e:
print >>sys.stderr, "image conversion failed: %s" % (e.errno, e.strerror)
sys.exit(-1)
这将有超过使用'os.system'-几个优点调用者想要的Pythonic API,避免使用shell,并以更常规的方式处理信号。 – 2010-03-26 01:25:44