コード例 #1
0
ファイル: aemconnect.py プロジェクト: AdminCNP/appscript
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.psnforapplicationpath(path)
		return True
	except ae.MacOSError, err:
		if err.args[0] == -600: 
			return False
		else:
			raise
コード例 #2
0
ファイル: aemconnect.py プロジェクト: wdong0472/vtest
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.psnforapplicationpath(path)
        return True
    except ae.MacOSError, err:
        if err.args[0] == -600:
            return False
        else:
            raise
コード例 #3
0
ファイル: aemconnect.py プロジェクト: AdminCNP/appscript
def localapp(path, newinstance=False, hide=False):
	"""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'
		newinstance : bool -- launch a new application instance?
		hide : bool -- hide after launch?
		Result : AEAddressDesc
	"""
	# Always create AEAddressDesc by process serial number; that way there's no confusion if multiple versions of the same app are running
	if newinstance:
		desc = _launchapplication(path, _runevent, newinstance, hide)
	else:
		try:
			desc = ae.psnforapplicationpath(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)
				desc = _launchapplication(path, _runevent, newinstance, hide)
			else:
				raise
コード例 #4
0
ファイル: aemconnect.py プロジェクト: AdminCNP/appscript
def launchapp(path, newinstance=False, hide=False):
	"""Send a 'launch' event to an application. If application is not already running, it will be launched in background first.
		path : string -- full path to application, e.g. '/Applications/TextEdit.app'
		newinstance : bool -- launch a new application instance?
		hide : bool -- hide after launch?
		Result : AEAddressDesc
	"""
	if newinstance:
		desc = _launchapplication(path, _launchevent, newinstance, hide)
	else:
		try:
			# If app is already running, calling ae.launchapplication will send a 'reopen' event, so need to check for this first:
			desc = ae.psnforapplicationpath(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)
				desc = _launchapplication(path, _launchevent, newinstance, hide)
			else:
				raise
		else: # App is already running, so send it a 'launch' event:
コード例 #5
0
ファイル: aemconnect.py プロジェクト: wdong0472/vtest
def localapp(path, newinstance=False, hide=False):
    """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'
		newinstance : bool -- launch a new application instance?
		hide : bool -- hide after launch?
		Result : AEAddressDesc
	"""
    # Always create AEAddressDesc by process serial number; that way there's no confusion if multiple versions of the same app are running
    if newinstance:
        desc = _launchapplication(path, _runevent, newinstance, hide)
    else:
        try:
            desc = ae.psnforapplicationpath(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)
                desc = _launchapplication(path, _runevent, newinstance, hide)
            else:
                raise
コード例 #6
0
ファイル: aemconnect.py プロジェクト: wdong0472/vtest
def launchapp(path, newinstance=False, hide=False):
    """Send a 'launch' event to an application. If application is not already running, it will be launched in background first.
		path : string -- full path to application, e.g. '/Applications/TextEdit.app'
		newinstance : bool -- launch a new application instance?
		hide : bool -- hide after launch?
		Result : AEAddressDesc
	"""
    if newinstance:
        desc = _launchapplication(path, _launchevent, newinstance, hide)
    else:
        try:
            # If app is already running, calling ae.launchapplication will send a 'reopen' event, so need to check for this first:
            desc = ae.psnforapplicationpath(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)
                desc = _launchapplication(path, _launchevent, newinstance,
                                          hide)
            else:
                raise
        else:  # App is already running, so send it a 'launch' event: