[英]python subprocess: how to run an app on OS X?
I am porting a windows application to OS X 10.6.8. 我正在将Windows应用程序移植到OS X 10.6.8。 It is a new platform for me and I am facing some difficulties.
对我来说,这是一个新平台,我面临一些困难。
The application is a small webserver (bottle+waitress) which is starting a browser (based on chromium embedded framework) thanks to a subprocess call. 该应用程序是一个小型Web服务器(bottle + waitress),由于子进程调用,该服务器正在启动浏览器(基于Chrome嵌入式框架)。
The browser is an app file and runs ok when started from gui. 浏览器是一个应用程序文件,从gui启动时可以正常运行。
I am launching it this way: 我以这种方式启动它:
subprocess.Popen([os.getcwd()+"/cef/cefclient.app", '--url=http://127.0.0.1:8100'])
Unfortunately, this fails with OSError: permission denied
. 不幸的是,此操作失败,并显示
OSError: permission denied
I tried to run the script with a sudo
with similar result. 我试图用
sudo
运行脚本,结果类似。
I can launch the app from shell with the following command: 我可以使用以下命令从外壳启动应用程序:
open -a "cef/cefclient.app" --args --url-http://127.0.0.1:8100
But 但
subprocess.Popen(['open', '-a', os.getcwd()+'/cef/cefclient.app', '--args', '--url-http://127.0.0.1:8100'])
fails with the following error 失败并显示以下错误
FSPathMakeRef(/Users/.../cefclient.app) failed with error -43.
Any idea how to fix this issue? 任何想法如何解决此问题?
The file cefclient.app
is actually a directory (an application bundle , specifically), not the application executable. 文件
cefclient.app
实际上是目录(特别是应用程序捆绑包 ),而不是应用程序可执行文件。 The real executable is located inside the bundle, with a path like Contents/MacOS/executable_name
. 真正的可执行文件位于软件包内部,其路径类似于
Contents/MacOS/executable_name
。 So to launch it, you'd do this: 因此,要启动它,您可以这样做:
subprocess.Popen([os.getcwd()+"/cef/cefclient.app/Content/MacOS/executable_name",
"--url=http://127.0.0.1:8100"])
Alternatively, 或者,
os.system('open -a "cef/cefclient.app" --args --url-http://127.0.0.1:8100')
Just depends if you want to control stdin / stdout or if starting the app is enough. 仅取决于您是否要控制stdin / stdout或启动应用程序是否足够。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.