Ejemplo n.º 1
0
#
# The common definitions
#
from dasbus.connection import SessionMessageBus
from dasbus.identifier import DBusServiceIdentifier

# Define the message bus.
SESSION_BUS = SessionMessageBus()

# Define services and objects.
HELLO_WORLD = DBusServiceIdentifier(namespace=("org", "example", "HelloWorld"),
                                    message_bus=SESSION_BUS)
Ejemplo n.º 2
0
def SessionBus() -> MessageBus:
    return cast(MessageBus, SessionMessageBus(error_mapper=error_mapper))
Ejemplo n.º 3
0
#
# The common definitions
#
from dasbus.connection import SessionMessageBus
from dasbus.error import DBusError, ErrorMapper, get_error_decorator
from dasbus.identifier import DBusServiceIdentifier
from dasbus.structure import DBusData
from dasbus.typing import Str, Int

# Define the error mapper.
ERROR_MAPPER = ErrorMapper()

# Define the message bus.
SESSION_BUS = SessionMessageBus(error_mapper=ERROR_MAPPER)

# Define namespaces.
REGISTER_NAMESPACE = ("org", "example", "Register")

# Define services and objects.
REGISTER = DBusServiceIdentifier(namespace=REGISTER_NAMESPACE,
                                 message_bus=SESSION_BUS)

# The decorator for DBus errors.
dbus_error = get_error_decorator(ERROR_MAPPER)


# Define errors.
@dbus_error("InvalidUserError", namespace=REGISTER_NAMESPACE)
class InvalidUser(DBusError):
    """The user is invalid."""
    pass
Ejemplo n.º 4
0
 def test_session_bus(self, getter):
     """Test the session bus."""
     message_bus = SessionMessageBus()
     self.assertIsNotNone(message_bus.connection)
     getter.assert_called_once_with(Gio.BusType.SESSION, None)
Ejemplo n.º 5
0
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to
#    the Free Software Foundation, Inc.,
#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

from dasbus.connection import SessionMessageBus
from dasbus.identifier import DBusServiceIdentifier

# Constants
XFCONF = DBusServiceIdentifier(
    namespace=("org", "xfce", "Xfconf"),
    message_bus=SessionMessageBus()
)

# Classes


class Xfconf:
    """Wrapper class for the org.xfce.Xfconf Dbus object"""

    def __init__(self):
        self.proxy = XFCONF.get_proxy()

    def get_property(self, channel: str, property: str):
        """ Read a Xfconf property"""
        return self.proxy.GetProperty(channel, property)
Ejemplo n.º 6
0
    if SESSION_BUS:
        logging.debug("disconnecting session bus")
        SESSION_BUS.disconnect()
        logging.debug("session bus disconnected")
    if LOOP:
        logging.debug("quitting loop")
        LOOP.quit()
        logging.debug("loop quitted")
    else:
        print("no loop to quit")


signal.signal(signal.SIGTERM, term_handler)
signal.signal(signal.SIGINT, term_handler)

SESSION_BUS = SessionMessageBus()

SYSEVENTD = DBusServiceIdentifier(namespace=("net", "cephalopo", "Syseventd"),
                                  message_bus=SESSION_BUS)

NOTIFICATION_PROXY = SESSION_BUS.get_proxy("org.freedesktop.Notifications",
                                           "/org/freedesktop/Notifications")


def _pulse_session():
    pulseses = pulsectl.Pulse(__name__, connect=False, threading_lock=False)
    pulseses.connect(autospawn=False)
    return pulseses


# icon names without URI path should be according to
Ejemplo n.º 7
0
        if os.path.exists(ANACONDA_BUS_ADDR_FILE):
            with open(ANACONDA_BUS_ADDR_FILE, 'rt') as f:
                return f.read().strip()

        raise ConnectionError("Can't find Anaconda bus address!")


class DefaultMessageBus(AnacondaMessageBus):
    """Representation of a default bus connection."""
    def _find_bus_address(self):
        """Get the address of the default bus.

        Connect to the bus specified by the environmental variable
        DBUS_STARTER_ADDRESS. If it is not specified, connect to
        the Anaconda bus.
        """
        if DBUS_STARTER_ADDRESS in os.environ:
            return os.environ.get(DBUS_STARTER_ADDRESS)

        return super()._find_bus_address()


# Default bus. Anaconda uses this connection.
DBus = DefaultMessageBus()

# System bus.
SystemBus = SystemMessageBus()

# Session bus.
SessionBus = SessionMessageBus()
Ejemplo n.º 8
0
    def _find_bus_address(self):
        """Get the address of the default bus.

        Connect to the bus specified by the environmental variable
        DBUS_STARTER_ADDRESS. If it is not specified, connect to
        the Anaconda bus.
        """
        if DBUS_STARTER_ADDRESS in os.environ:
            return os.environ.get(DBUS_STARTER_ADDRESS)

        return super()._find_bus_address()


# The mapper of DBus errors.
error_mapper = ErrorMapper()

# Default bus. Anaconda uses this connection.
DBus = DefaultMessageBus(error_mapper=error_mapper)

# System bus.
SystemBus = SystemMessageBus(error_mapper=error_mapper)

# Session bus.
SessionBus = SessionMessageBus(error_mapper=error_mapper)

# The decorator for DBus errors.
dbus_error = get_error_decorator(error_mapper)

# Register all DBus errors.
register_errors()