Example #1
0
 def invoke_special(self, message, connection):
     args = message["arguments"]
     args = [decode_object(arg) for arg in args]
     try:
         return_value = self.special_target(*args)
     except Exception as e:
         print_exc()
         return_value = e
     result = encode_object(return_value)
     response = create_message(CallFunctionResponse,
             message, return_value=result)
     connection.send(response)
Example #2
0
def process_get_object_value_command(message, sender, connection):
    interface_name = message["interface_name"]
    object_name = message["object_name"]
    try:
        interface = autobus.lookup_interface(interface_name)
        object = interface.object_map[object_name]
        object_value = object.get()
    except (autobus.NoSuchInterfaceException, KeyError): # Object doesn't exist yet
        object_value = encode_object(None)
    response = create_message(GetObjectValueResponse,
            message, interface_name=interface_name, object_name=object_name,
            value=object_value)
    connection.send(response)
Example #3
0
 def deregister(self):
     """
     The opposite of register(): deregisters this interface.
     """
     print "Deregistering interface with name " + self.name
     del interface_map[self.name]
     self.connection.interfaces.remove(self)
     for object_name in self.object_map:
         self.object_map[object_name].set_and_notify(encode_object(None))
     # Notifications
     if self is not autobus_interface:
         autobus_interface.notify_object("interface_count")
         autobus_interface.notify_object("interfaces")
         autobus_interface.notify_object("interface_items")
Example #4
0
def process_watch_object_command(message, sender, connection):
    interface_name = message["interface_name"]
    object_name = message["object_name"]
    autobus.register_object_watch(interface_name, object_name, sender)
    connection.watches.append((interface_name, object_name))
    try:
        interface = autobus.lookup_interface(interface_name)
        object = interface.object_map[object_name]
        object_value = object.get()
    except (autobus.NoSuchInterfaceException, KeyError): # Object doesn't exist yet
        object_value = encode_object(None)
    response = create_message(WatchObjectResponse,
            message, interface_name=interface_name, object_name=object_name,
            value=object_value)
    connection.send(response)
Example #5
0
 def get(self):
     value = self.accessor()
     return encode_object(value)