Exemple #1
0
 def matches(cls, dbus_tuple, params):
     try:
         bus, connection_name = dbus_tuple
         bus_pid = _get_bus_connections_pid(bus, connection_name)
         return bus_pid != os.getpid()
     except dbus.DBusException:
         return False
Exemple #2
0
def _map_connection_to_pid(connection, dbus_bus):
    try:
        return _get_bus_connections_pid(dbus_bus, connection)
    except dbus.DBusException as e:
        logger.info(
            "dbus.DBusException while attempting to get PID for %s: %r" %
            (connection, e))
Exemple #3
0
def _dedupe_connections_on_pid(valid_connections, bus):
    seen_pids = []
    deduped_connections = []

    for connection in valid_connections:
        pid = _get_bus_connections_pid(bus, connection)
        if pid not in seen_pids:
            seen_pids.append(pid)
            deduped_connections.append(connection)
    return deduped_connections
Exemple #4
0
 def _check_pid_running(self):
     try:
         process_pid = _get_bus_connections_pid(self._addr_tuple.bus,
                                                self._addr_tuple.connection)
         return _pid_is_running(process_pid)
     except dbus.DBusException as e:
         if e.get_dbus_name() == \
                 'org.freedesktop.DBus.Error.NameHasNoOwner':
             return False
         else:
             raise
Exemple #5
0
    def matches(cls, dbus_tuple, params):
        """Match a connection based on the connections pid.

        :raises KeyError: if the pid parameter isn't passed in params.

        """

        pid = params['pid']
        bus, connection_name = dbus_tuple

        try:
            bus_pid = _get_bus_connections_pid(bus, connection_name)
        except dbus.DBusException as e:
            logger.info(
                "dbus.DBusException while attempting to get PID for %s: %r" %
                (connection_name, e))
            return False

        eligible_pids = [pid] + _get_child_pids(pid)
        return bus_pid in eligible_pids