Detect if specific Python.app instance is already running
Andrei
andrei.fokau at gmail.com
Sun Jun 7 10:31:28 EDT 2015
Hello,
I am experimenting with OS X apps written in Python and need to detect if there is already an instance of Python.app running with certain script. My script modifies CFBundleName on-the-fly from "Python" to "MyApp" to change the app title in the menubar. If I start another instance and check CFBundleName of the running apps, it will only tell me the original value, i.e. "Python":
for app in NSWorkspace.sharedWorkspace().runningApplications():
bundle = NSBundle.bundleWithURL_(app.bundleURL())
name = bundle.infoDictionary().get('CFBundleName')
if name in ('Python', 'MyApp'):
print name # => prints Python
So I need to find a way to mark a Python.app instance that runs MyApp script to be able to abort launching duplicate instances. Is there such way?
Thanks,
Andrei
More information about the Python-list
mailing list