def callback_wrapper(self, _request, _reply):
        _parameters, _attributes = aetools.unpackevent(_request)
        _class = _attributes['evcl'].type
        _type = _attributes['evid'].type

        if (_class, _type) in self.ae_handlers:
            _function = self.ae_handlers[(_class, _type)]
        elif (_class, '****') in self.ae_handlers:
            _function = self.ae_handlers[(_class, '****')]
        elif ('****', '****') in self.ae_handlers:
            _function = self.ae_handlers[('****', '****')]
        else:
            raise 'Cannot happen: AE callback without handler', (_class, _type)

        # XXXX Do key-to-name mapping here

        _parameters['_attributes'] = _attributes
        _parameters['_class'] = _class
        _parameters['_type'] = _type
        if '----' in _parameters:
            _object = _parameters['----']
            del _parameters['----']
            # The try/except that used to be here can mask programmer errors.
            # Let the program crash, the programmer can always add a **args
            # to the formal parameter list.
            rv = _function(_object, **_parameters)
        else:
            #Same try/except comment as above
            rv = _function(**_parameters)

        if rv is None:
            aetools.packevent(_reply, {})
        else:
            aetools.packevent(_reply, {'----': rv})
示例#2
0
 def callback_wrapper(self, _request, _reply):
     _parameters, _attributes = aetools.unpackevent(_request)
     _class = _attributes["evcl"].type
     _type = _attributes["evid"].type
     if (_class, _type) in self.ae_handlers:
         _function = self.ae_handlers[_class, _type]
     elif (_class, "****") in self.ae_handlers:
         _function = self.ae_handlers[_class, "****"]
     elif ("****", "****") in self.ae_handlers:
         _function = self.ae_handlers[("****", "****")]
     else:
         raise "Cannot happen: AE callback without handler", (_class, _type)
     _parameters["_attributes"] = _attributes
     _parameters["_class"] = _class
     _parameters["_type"] = _type
     if "----" in _parameters:
         _object = _parameters["----"]
         del _parameters["----"]
         rv = _function(_object, **_parameters)
     else:
         rv = _function(**_parameters)
     if rv is None:
         aetools.packevent(_reply, {})
     else:
         aetools.packevent(_reply, {"----": rv})
     return
示例#3
0
    def callback_wrapper(self, _request, _reply):
        _parameters, _attributes = aetools.unpackevent(_request)
        _class = _attributes['evcl'].type
        _type = _attributes['evid'].type

        if self.ae_handlers.has_key((_class, _type)):
            _function = self.ae_handlers[(_class, _type)]
        elif self.ae_handlers.has_key((_class, '****')):
            _function = self.ae_handlers[(_class, '****')]
        elif self.ae_handlers.has_key(('****', '****')):
            _function = self.ae_handlers[('****', '****')]
        else:
            raise 'Cannot happen: AE callback without handler', (_class, _type)

        # XXXX Do key-to-name mapping here

        _parameters['_attributes'] = _attributes
        _parameters['_class'] = _class
        _parameters['_type'] = _type
        if _parameters.has_key('----'):
            _object = _parameters['----']
            del _parameters['----']
            # The try/except that used to be here can mask programmer errors.
            # Let the program crash, the programmer can always add a **args
            # to the formal parameter list.
            rv = _function(_object, **_parameters)
        else:
            #Same try/except comment as above
            rv = _function(**_parameters)

        if rv == None:
            aetools.packevent(_reply, {})
        else:
            aetools.packevent(_reply, {'----':rv})
示例#4
0
 def callback_wrapper(self, _request, _reply):
     _parameters, _attributes = aetools.unpackevent(_request)
     _class = _attributes['evcl'].type
     _type = _attributes['evid'].type
     if (_class, _type) in self.ae_handlers:
         _function = self.ae_handlers[_class, _type]
     elif (_class, '****') in self.ae_handlers:
         _function = self.ae_handlers[_class, '****']
     elif ('****', '****') in self.ae_handlers:
         _function = self.ae_handlers[('****', '****')]
     else:
         raise 'Cannot happen: AE callback without handler', (_class, _type)
     _parameters['_attributes'] = _attributes
     _parameters['_class'] = _class
     _parameters['_type'] = _type
     if '----' in _parameters:
         _object = _parameters['----']
         del _parameters['----']
         rv = _function(_object, **_parameters)
     else:
         rv = _function(**_parameters)
     if rv is None:
         aetools.packevent(_reply, {})
     else:
         aetools.packevent(_reply, {'----': rv})
     return
示例#5
0
    def callback_wrapper(self, _request, _reply):
        _parameters, _attributes = aetools.unpackevent(_request)
        _class = _attributes["evcl"].type
        _type = _attributes["evid"].type

        if (_class, _type) in self.ae_handlers:
            _function = self.ae_handlers[(_class, _type)]
        elif (_class, "****") in self.ae_handlers:
            _function = self.ae_handlers[(_class, "****")]
        elif ("****", "****") in self.ae_handlers:
            _function = self.ae_handlers[("****", "****")]
        else:
            raise "Cannot happen: AE callback without handler", (_class, _type)

        # XXXX Do key-to-name mapping here

        _parameters["_attributes"] = _attributes
        _parameters["_class"] = _class
        _parameters["_type"] = _type
        if "----" in _parameters:
            _object = _parameters["----"]
            del _parameters["----"]
            # The try/except that used to be here can mask programmer errors.
            # Let the program crash, the programmer can always add a **args
            # to the formal parameter list.
            rv = _function(_object, **_parameters)
        else:
            # Same try/except comment as above
            rv = _function(**_parameters)

        if rv is None:
            aetools.packevent(_reply, {})
        else:
            aetools.packevent(_reply, {"----": rv})
示例#6
0
 def callback_wrapper(self, _request, _reply):
     _parameters, _attributes = aetools.unpackevent(_request)
     _class = _attributes['evcl'].type
     _type = _attributes['evid'].type
     if (_class, _type) in self.ae_handlers:
         _function = self.ae_handlers[_class, _type]
     elif (_class, '****') in self.ae_handlers:
         _function = self.ae_handlers[_class, '****']
     elif ('****', '****') in self.ae_handlers:
         _function = self.ae_handlers[('****', '****')]
     else:
         raise 'Cannot happen: AE callback without handler', (_class, _type)
     _parameters['_attributes'] = _attributes
     _parameters['_class'] = _class
     _parameters['_type'] = _type
     if '----' in _parameters:
         _object = _parameters['----']
         del _parameters['----']
         rv = _function(_object, **_parameters)
     else:
         rv = _function(**_parameters)
     if rv is None:
         aetools.packevent(_reply, {})
     else:
         aetools.packevent(_reply, {'----': rv})
     return
示例#7
0
def corehandler(req, rep):
	print 'core event!'
	parameters, attributes = aetools.unpackevent(req)
	print "event class =", attributes['evcl']
	print "event id =", attributes['evid']
	print 'parameters:', parameters
	# echo the arguments, to see how Script Editor formats them
	aetools.packevent(rep, parameters)
 def opendocsevent(self, theAppleEvent, theReply):
     W.SetCursor('watch')
     import aetools
     parameters, args = aetools.unpackevent(theAppleEvent)
     docs = parameters['----']
     if type(docs) <> type([]):
         docs = [docs]
     for doc in docs:
         fsr, a = doc.FSResolveAlias(None)
         path = fsr.as_pathname()
         self.opendoc(path)
示例#9
0
 def opendocsevent(self, theAppleEvent, theReply):
     W.SetCursor('watch')
     import aetools
     parameters, args = aetools.unpackevent(theAppleEvent)
     docs = parameters['----']
     if type(docs) <> type([]):
         docs = [docs]
     for doc in docs:
         fsr, a = doc.FSResolveAlias(None)
         path = fsr.as_pathname()
         self.opendoc(path)
示例#10
0
	def aehandler(self, request, reply):
		print "Apple Event",
		parameters, attributes = aetools.unpackevent(request)
		print "class =", `attributes['evcl'].type`,
		print "id =", `attributes['evid'].type`
		print "Parameters:"
		keys = parameters.keys()
		keys.sort()
		for key in keys:
			print "%s: %.150s" % (`key`, `parameters[key]`)
			print "      :", str(parameters[key])
		print "Attributes:"
		keys = attributes.keys()
		keys.sort()
		for key in keys:
			print "%s: %.150s" % (`key`, `attributes[key]`)
		aetools.packevent(reply, parameters)
示例#11
0
def aehandler(request, reply):
	tosend = []
	print 'request:', aetools.unpackevent(request)
	param = request.AEGetParamDesc(keyDirectObject, typeWildCard)
	if param.type == typeAEList:
		n = param.AECountItems()
		print 'List has', n, 'items'
		for i in range(1, 1+n):
			type, item = param.AEGetNthDesc(i, typeFSS)
			data = item.data
			print 'item', i, ':', type, item.type, len(data), 'bytes'
			vol, dir, fnlen = struct.unpack('hlb', data[:7])
			filename = data[7:7+fnlen]
			print 'vol:', vol, '; dir:', dir, '; filename:', `filename`
			print 'full path:', macfs.FSSpec((vol,dir,filename)).as_pathname()
			tosend.append(item)
	else:
		pass
		print 'param:', (param.type, param.data[:20]), param.data[20:] and '...'
	if tosend:
		passtothink(tosend)
示例#12
0
文件: remote.py 项目: SayCV/tools-FDK
def _executePython(theAppleEvent, theReply):
	import aetools
	import cStringIO
	import traceback
	import sys
	parms, attrs = aetools.unpackevent(theAppleEvent)
	source = parms.get("----")
	if source is None:
		return
	stdout = cStringIO.StringIO()
	#print "<executing remote command>"
	save = sys.stdout, sys.stderr
	sys.stdout = sys.stderr = stdout
	namespace = {}
	try:
		try:
			exec source in namespace
		except:
			traceback.print_exc()
	finally:
		sys.stdout, sys.stderr = save
	output = stdout.getvalue()
	aetools.packevent(theReply, {"----": output})
示例#13
0
def _executePython(theAppleEvent, theReply):
    import aetools
    import cStringIO
    import traceback
    import sys
    parms, attrs = aetools.unpackevent(theAppleEvent)
    source = parms.get("----")
    if source is None:
        return
    stdout = cStringIO.StringIO()
    #print "<executing remote command>"
    save = sys.stdout, sys.stderr
    sys.stdout = sys.stderr = stdout
    namespace = {}
    try:
        try:
            exec source in namespace
        except:
            traceback.print_exc()
    finally:
        sys.stdout, sys.stderr = save
    output = stdout.getvalue()
    aetools.packevent(theReply, {"----": output})
示例#14
0
"""PythonSlave.py
示例#15
0
def wildhandler(req, rep):
	print 'wildcard event!'
	parameters, attributes = aetools.unpackevent(req)
	print "event class =", attributes['evcl']
	print "event id =", attributes['evid']
	print 'parameters:', parameters
示例#16
0
"""MiniAEFrame - A minimal AppleEvent Application framework.
示例#17
0
"""AEservertest - Test AppleEvent server interface
示例#18
0
文件: tell.py 项目: mcyril/ravel-ftn
# (Slightly less) primitive operations for sending Apple Events to applications.
示例#19
0
文件: echo.py 项目: mcyril/ravel-ftn
"""'echo' -- an AppleEvent handler which handles all events the same.
示例#20
0
文件: tell.py 项目: mcyril/ravel-ftn
# (Slightly less) primitive operations for sending Apple Events to applications.
示例#21
0
"""AEservertest - Test AppleEvent server interface
示例#22
0
	def sendevent(self, event):
		reply = event.AESend(self.send_flags, self.send_priority,
		                          self.send_timeout)
		parameters, attributes = aetools.unpackevent(reply)
		return reply, parameters, attributes
示例#23
0
"""PythonSlave.py
示例#24
0
文件: echo.py 项目: mcyril/ravel-ftn
"""'echo' -- an AppleEvent handler which handles all events the same.