예제 #1
0
파일: dbus_attr.py 프로젝트: pat1/autoradio
 def _get_set_dbus(self, obj, val=UNDEFINED_PARAM, *args, **kw):
     properties = DbusInterface.get_bus_properties(obj)
     iface = self.iface or DbusInterface.get_bus_iface(obj)
     #vals is UndefinedParam, try to get val from object
     if val is UNDEFINED_PARAM:
         mval = properties.Get(iface, self.attr.__name__)
         DbusInterface.store_result(obj, mval)
         if self.override_val:
             val = mval
     #else set val in property (meth.__name__)
     else:
         to_primitve = self.to_primitive
         properties.Set(iface, self.attr.__name__, val)
         DbusInterface.store_result(obj, to_primitve(val))
     result = self.attr(val, *args, **kw)
     if result is None and self.override_return:
         result = properties.Get(iface, self.attr.__name__)
     produces = self.produces
     return produces(result)
예제 #2
0
 def _get_set_dbus(self, obj, val=UNDEFINED_PARAM, *args, **kw):
     properties = DbusInterface.get_bus_properties(obj)
     iface = self.iface or DbusInterface.get_bus_iface(obj)
     #vals is UndefinedParam, try to get val from object
     if val is UNDEFINED_PARAM:
         mval = properties.Get(iface, self.attr.__name__)
         DbusInterface.store_result(obj, mval)
         if self.override_val:
             val = mval
     #else set val in property (meth.__name__)
     else:
         to_primitve = self.to_primitive
         properties.Set(iface, self.attr.__name__, val)
         DbusInterface.store_result(obj, to_primitve(val))
     result = self.attr(val, *args, **kw)
     if result is None and self.override_return:
         result = properties.Get(iface, self.attr.__name__)
     produces = self.produces
     return produces(result)
예제 #3
0
    def _call_dbus(self, obj, *args, **kw):
#        print self.meth.__name__, args, kw
        bus_obj = DbusInterface.get_bus_obj(obj)
        bus_interface = self.iface if self.iface else\
            DbusInterface.get_bus_iface(obj)           
        bus_meth = bus_obj.get_dbus_method(self.meth.__name__, bus_interface)
        args = self.convert_args_to_dbus_args(*args)
        kw = self.convert_kw_to_dbus_kw(**kw)
        dbus_result = bus_meth(*args, **kw)
        DbusInterface.store_result(obj, dbus_result)
        produces = self.produces
        if produces:
            return produces(dbus_result)
        meth = self.meth
        result = None
        if meth:
            result = meth(obj, *args, **kw)
        if result is None and self.override_return:
            result = dbus_result
        return result
예제 #4
0
 def _watch_dbus(self, obj, *args, **kw):
     '''
     set self._handler to be called when obj fire signal wrapped
     '''
     def handler(*args, **kw):
         if self.meth is not self._handler:
             DbusInterface.store_result(obj, self.meth(obj, *args, **kw))
         return self._handler(self._obj, *args, **kw)
     if self.iface:
         bus_iface = DbusInterface.iface(obj, self.iface)
         bus_iface.connect_to_signal(self.meth.__name__,
                                   handler,
                                   dbus_interface=self.iface,
                                   *args, **kw)
     else:
         bus_obj = DbusInterface.get_bus_obj(obj)
         bus_obj.connect_to_signal(self.meth.__name__,
                                   handler,
                                   dbus_interface=DbusInterface.get_bus_iface(obj),
                                   *args, **kw)