luc
luc

Reputation: 43096

python subprocess: how to run an app on OS X?

I am porting a windows application to 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.

The browser is an app file and runs ok when started from 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.

I tried to run the script with a sudo with similar result.

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?

Upvotes: 0

Views: 12762

Answers (2)

user349511
user349511

Reputation:

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.

Upvotes: 1

Adam Rosenfield
Adam Rosenfield

Reputation: 400204

The file cefclient.app is actually a directory (an application bundle, specifically), not the application executable. The real executable is located inside the bundle, with a path like 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"])

Upvotes: 5

Related Questions