我尝试在父类被守护的方法中执行脚本。在
在自动伽马.sh需要安装ImageMagick(并使用convert)的脚本,可以在此处找到:http://www.fmwconcepts.com/imagemagick/autogamma/index.php
import os
import subprocess
import daemon
class MyClass():
def __init__(self):
self.myfunc()
def myfunc(self):
script = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'autogamma.sh')
cmd = ('/bin/sh %s -c average /tmp/c.jpg /tmp/d.jpg' % script).split(' ')
ret = subprocess.Popen(cmd).communicate()
with daemon.DaemonContext():
process = MyClass()
process.run()
脚本在启动类MyClass时正确执行。我认为env或类似的东西有问题,但无法得到它。在
Rsync,mediainfo,ffprobe也出现了问题。 使用python2.7.3和Python守护进程1.6,在macos、centos5.5、ubuntu12.04TLS上测试
这个脚本很短,如果不包括用于读取命令行参数、注释和其他颜色模式的代码,它将少于75行。我只需要把它转换成Python。在
如注释所示,最好的方法是为ImageMagick使用一个python包装器。在
您也可以直接调用
convert
,尽管这可能会很痛苦。下面是一个小片段,内容如下:我终于发现了问题。这实际上是一个路径问题。在查看了lib之后,我发现了这个有用的参数:
所以我把守护程序设置成这样:
^{pr2}$现在我有了正确的路径,我的脚本得到了正确的执行。在
当我怀疑环境问题时,我会做两件事之一:
这使得tty-less脚本的不透明性有所降低。在
相关问题 更多 >
编程相关推荐