def processexistsforpath(path): """Does a local process launched from the specified application file exist? Note: if path is invalid, a MacOSError is raised. """ try: ae.pidforapplicationpath(path) return True except ae.MacOSError, err: if err.args[0] == -600: return False else: raise
def launchapp(path): """Send a 'launch' event to an application. If application is not already running, it will be launched in background first.""" try: # If app is already running, calling ae.launchapplication will send a 'reopen' event, so need to check for this first: pid = ae.pidforapplicationpath(path) except ae.MacOSError, err: if err.args[0] == -600: # Application isn't running, so launch it and send it a 'launch' event: sleep(1) _launchapplication(path, _launchevent) else: raise
def launchapp(path): """Send a 'launch' event to an application. If application is not already running, it will be launched in background first.""" try: # If app is already running, calling ae.launchapplication will send a 'reopen' event, so need to check for this first: pid = ae.pidforapplicationpath(path) except ae.MacOSError, err: if err.args[ 0] == -600: # Application isn't running, so launch it and send it a 'launch' event: sleep(1) _launchapplication(path, _launchevent) else: raise
def localapp(path): """Make an AEAddressDesc identifying a local application. (Application will be launched if not already running.) path : string -- full path to application, e.g. '/Applications/TextEdit.app' Result : AEAddressDesc """ # Always create AEAddressDesc by process serial number; that way there's no confusion if multiple versions of the same app are running try: pid = ae.pidforapplicationpath(path) except ae.MacOSError, err: if err.args[0] == -600: # Application isn't running, so launch it in background and send it a standard 'run' event. sleep(1) pid = _launchapplication(path, _runevent) else: raise
def localapp(path): """Make an AEAddressDesc identifying a local application. (Application will be launched if not already running.) path : string -- full path to application, e.g. '/Applications/TextEdit.app' Result : AEAddressDesc """ # Always create AEAddressDesc by process serial number; that way there's no confusion if multiple versions of the same app are running try: pid = ae.pidforapplicationpath(path) except ae.MacOSError, err: if err.args[ 0] == -600: # Application isn't running, so launch it in background and send it a standard 'run' event. sleep(1) pid = _launchapplication(path, _runevent) else: raise