コード例 #1
0
ファイル: shutdown.py プロジェクト: zenny/Galicaster
def get_dbus_method(method_name):
    dbus_loop = DBusGMainLoop()
    connection = BusConnection(mainloop=dbus_loop)
    bus_name = "org.gnome.SessionManager"
    object_path = "/org/gnome/SessionManager"
    session_object = connection.get_object(bus_name, object_path)
    interface = dbus.Interface(session_object, bus_name)
    method = interface.get_dbus_method(method_name)
    return method
コード例 #2
0
def get_dbus_method(method_name):
    dbus_loop = DBusGMainLoop()
    connection = BusConnection(mainloop=dbus_loop)
    bus_name = "com.canonical.Unity"
    object_path = "/com/canonical/Unity/Session"
    session_object = connection.get_object(bus_name, object_path)
    interface = dbus.Interface(session_object, bus_name + ".Session")
    method = interface.get_dbus_method(method_name)
    return method
コード例 #3
0
ファイル: shutdown.py プロジェクト: MasterFox/Galicaster
def get_dbus_method(method_name):
    dbus_loop = DBusGMainLoop()
    connection = BusConnection(mainloop=dbus_loop)
    bus_name = "org.gnome.SessionManager"
    object_path = "/org/gnome/SessionManager"
    session_object = connection.get_object(bus_name, object_path)
    interface = dbus.Interface(session_object, bus_name)
    method = interface.get_dbus_method(method_name)
    return method
コード例 #4
0
def main():
    size = Size(800, 600)

    mainloop = GLib.MainLoop()
    DBusGMainLoop(set_as_default=True)

    sleep(10)

    bus = BusConnection(getenv("DBUS_ADDRESS") or DBUS_ADDRESS)
    remote_object = bus.get_object(BUS_NAME, OBJECT_PATH)

    process = Popen(ffplay_command(size), stdin=PIPE)
    remote_object.connect_to_signal("FrameEmitted", partial(handle_frame, process.stdin), dbus_interface=DBUS_INTERFACE)
    remote_object.EmitFrames()

    #print(remote_object.Capitalize("hello world"))
    
    print("Starting player... ", flush=True)
    mainloop.run()
コード例 #5
0
ファイル: commons.py プロジェクト: pobot-nros/nros-core
def get_bus(address_or_type=BusConnection.TYPE_SESSION):
    """ Returns a given bus, either from the local system or from a remote one, thanks to D-Bus TCP support.

    The parameter is used the same way as in D-Bus class :py:class:`BusConnection`. Refer to original
    documentation for details.

    :param address_or_type: request bus identification
    :return: the requested bus
    :rtype: BusConnection
    """
    os.environ.update(get_bus_config())
    return BusConnection(address_or_type)
コード例 #6
0
ファイル: commons.py プロジェクト: pobot-nros/nros-core
def get_remote_bus(host, port):
    """ Returns a bus exposed by a remote host.

    This is a convenience wrapper of the :py:class:`BusConnection` create, building the bus address
    for a TCP connection.

    :param str host: host name or IP
    :param int port: port on which the remote host is listening
    :return: the requested bus
    :rtype: BusConnection
    """
    return BusConnection("tcp:host=%s,port=%d" % (host, port))
コード例 #7
0
ファイル: _dbus.py プロジェクト: aminba90/PythonCourse
    def __new__(cls,
                bus_type=BusConnection.TYPE_SESSION,
                private=False,
                mainloop=None):
        """Constructor, returning an existing instance where appropriate.

        The returned instance is actually always an instance of `SessionBus`,
        `SystemBus` or `StarterBus`.

        :Parameters:
            `bus_type` : cls.TYPE_SESSION, cls.TYPE_SYSTEM or cls.TYPE_STARTER
                Connect to the appropriate bus
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.

                :Deprecated: since 0.82.3. Use dbus.bus.BusConnection for
                    private connections.

            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        :Changed: in dbus-python 0.80:
            converted from a wrapper around a Connection to a Connection
            subclass.
        """
        if (not private and bus_type in cls._shared_instances):
            return cls._shared_instances[bus_type]

        # this is a bit odd, but we create instances of the subtypes
        # so we can return the shared instances if someone tries to
        # construct one of them (otherwise we'd eg try and return an
        # instance of Bus from __new__ in SessionBus). why are there
        # three ways to construct this class? we just don't know.
        if bus_type == BUS_SESSION:
            subclass = SessionBus
        elif bus_type == BUS_SYSTEM:
            subclass = SystemBus
        elif bus_type == BUS_STARTER:
            subclass = StarterBus
        else:
            raise ValueError('invalid bus_type %s' % bus_type)

        bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)

        bus._bus_type = bus_type

        if not private:
            cls._shared_instances[bus_type] = bus

        return bus
コード例 #8
0
    def __new__(cls, bus_type=BusConnection.TYPE_SESSION, private=False,
                mainloop=None):
        """Constructor, returning an existing instance where appropriate.

        The returned instance is actually always an instance of `SessionBus`,
        `SystemBus` or `StarterBus`.

        :Parameters:
            `bus_type` : cls.TYPE_SESSION, cls.TYPE_SYSTEM or cls.TYPE_STARTER
                Connect to the appropriate bus
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        :ToDo:
            - There is currently no way to connect this class to a custom
              address.
            - Some of this functionality should be available on
              peer-to-peer D-Bus connections too.
        :Changed: in dbus-python 0.80:
            converted from a wrapper around a Connection to a Connection
            subclass.
        """
        if (not private and bus_type in cls._shared_instances):
            return cls._shared_instances[bus_type]

        # this is a bit odd, but we create instances of the subtypes
        # so we can return the shared instances if someone tries to
        # construct one of them (otherwise we'd eg try and return an
        # instance of Bus from __new__ in SessionBus). why are there
        # three ways to construct this class? we just don't know.
        if bus_type == BUS_SESSION:
            subclass = SessionBus
        elif bus_type == BUS_SYSTEM:
            subclass = SystemBus
        elif bus_type == BUS_STARTER:
            subclass = StarterBus
        else:
            raise ValueError('invalid bus_type %s' % bus_type)

        bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)

        bus._bus_type = bus_type

        if not private:
            cls._shared_instances[bus_type] = bus

        return bus
コード例 #9
0
def main():
    file_path = Path("./ocean3.mp4")
    size = Size(800, 600)

    print("Starting streamer... ", flush=True)

    mainloop = GLib.MainLoop()
    DBusGMainLoop(set_as_default=True)

    bus = BusConnection(getenv("DBUS_ADDRESS") or DBUS_ADDRESS)
    bus_name = BusName(BUS_NAME, bus)

    StreamerObject(bus, bus_name, file_path, size)

    mainloop.run()
コード例 #10
0
    def __init__(self, bus_address):
        """
        Register the org.freedesktop.Notifications service and an object implementing the corresponding interface
        on the given bus. Make sure that the org.freedesktop.Notifications service doesn't exist on the bus yet.

        :param bus_address:
            Address of the desired bus. D-BUS addresses are of the form 'unix:*=*'
        """
        # maximum notification ID is the biggest number that can be represented by 32 bits (uint32)
        self.__max_id = 4294967295
        # start notification IDs at 1 since 0 is not allowed
        self.__id_count = 1

        # get bus name of service on the defined bus connection and create service object
        self.__bus_name = dbus.service.BusName(self.service,
                                               bus=BusConnection(bus_address))
        self.__service_object = dbus.service.Object.__init__(
            self, self.__bus_name, self.object_path)
コード例 #11
0
 def __new__(cls, mainLoop=None):
     bus = BusConnection.__new__(cls,
                                 mbusConfig.DBUS_ADDRESS,
                                 mainloop=mainLoop)
     return bus