子进程没有调用我的命令(或者做错了)

发布于 2024-11-25 12:08:35 字数 1296 浏览 1 评论 0原文

概述:

我有一个应用程序,有时必须用芹菜制作一些东西 - 如果是简单的任务,例如计算一些东西 - 一切都可以。

我有一项任务必须使用 MS Windows 程序将现有文件转换为另一个文件。所以-我安装了WINE,然后安装了应用程序并将以下任务添加到我的tasks.py中:

def convert_file( fil, to_format = 'pdf', save_to = '/tmp', callback = None ):
    devnull = open( '/dev/null', 'w' )
    commands = "xvfb-run -a wine '[ABSOLUTE_PATH_TO_WINDOWS_APP]' /r /f 104 %s" % fil
    p = subprocess.Popen( commands, shell=True, cwd='/home/test', env=os.environ, stdout = devnull, stderr = subprocess.STDOUT )
    p.wait()
    devnull.close()
    if callback:
        subtask( callback ).delay( )
    else:
        return outfile

问题:

该命令未被调用或被调用但没有发生任何事情(在任何地方都没有新文件)文件系统) - 但如果我从 bash 或交互式 python shell 调用此命令,一切都会好的。

编辑: 当我从命令行调用命令时,我得到以下信息:

test@ubuntu:~$ xvfb-run -a /home/test/.wine/....exe /r /f 104 /home/test/fs/...
err:winediag:X11DRV_WineGL_InitOpenglInfo The Mesa OpenGL driver is using software rendering, most likely your OpenGL drivers haven't been installed correctly
test@ubuntu:~$ XIO:  fatal IO error 11 (Zasoby chwilowo niedostępne) on X server ":99"
      after 1262 requests (1226 known processed) with 0 events remaining.
[Here i must press enter]
test@ubuntu:~$ 

Overview:

I have an application that sometimes must make something with celery- and if it is simple task such as count something- everything is ok.

I' ve got one task which must convert existing file to another file using MS Windows program. So- I installed WINE, then installed application and added folowing task to my tasks.py:

def convert_file( fil, to_format = 'pdf', save_to = '/tmp', callback = None ):
    devnull = open( '/dev/null', 'w' )
    commands = "xvfb-run -a wine '[ABSOLUTE_PATH_TO_WINDOWS_APP]' /r /f 104 %s" % fil
    p = subprocess.Popen( commands, shell=True, cwd='/home/test', env=os.environ, stdout = devnull, stderr = subprocess.STDOUT )
    p.wait()
    devnull.close()
    if callback:
        subtask( callback ).delay( )
    else:
        return outfile

Problem:

The command isn't called or is called but nothing is happening(there isn't new file anywhere in filesystem)- but if I'll call this command from bash or from interactive python shell, everything is ok.

Edit:
When I'm calling the command from command line I get this:

test@ubuntu:~$ xvfb-run -a /home/test/.wine/....exe /r /f 104 /home/test/fs/...
err:winediag:X11DRV_WineGL_InitOpenglInfo The Mesa OpenGL driver is using software rendering, most likely your OpenGL drivers haven't been installed correctly
test@ubuntu:~$ XIO:  fatal IO error 11 (Zasoby chwilowo niedostępne) on X server ":99"
      after 1262 requests (1226 known processed) with 0 events remaining.
[Here i must press enter]
test@ubuntu:~$ 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

童话里做英雄 2024-12-02 12:08:35

用于

p = subprocess.Popen( commands, shell=True, cwd='/home/test', env=os.environ, stdout = subprocess.PIPE, stderr = subprocess.PIPE)

您的 Popen 命令,然后

print p.communicate()
p.wait()
print p.communicate()

查看它打印到 stdoutstderr 的内容,并找出您做错了什么。

编辑:Xvfb 是一个假帧缓冲区;它没有硬件加速。尝试更改您的 wine 设置,使其不需要硬件加速/不使用 OpenGL / 使用 winecfg 进行软件渲染。

Use

p = subprocess.Popen( commands, shell=True, cwd='/home/test', env=os.environ, stdout = subprocess.PIPE, stderr = subprocess.PIPE)

for your Popen command, then

print p.communicate()
p.wait()
print p.communicate()

To see what it prints to stdout and stderr and figure out what you're doing wrong.

Edit: Xvfb is a fake framebuffer; it doesn't have hardware acceleration. Try changing your wine settings not to require hardware acceleration / not to use OpenGL / to do software rendering with winecfg.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文