Source

pida-hacks / pida / core / pdbus.py

Full commit
# -*- coding: utf-8 -*-
"""
    Dbus integration
    ~~~~~~~~~~~~~~~~

    Base classes for integrating services/plugins with DBUS.

    :copyright: 2005-2008 by The PIDA Project
    :license: GPL 2 or later (see README/COPYING/LICENSE)
"""


import os

import dbus

from dbus.mainloop.glib import DBusGMainLoop
DBusMainloop = DBusGMainLoop(set_as_default=True)

from dbus.service import Object

from pida.utils.pdbus import UUID, DBUS_PATH, DBUS_NS
DBusMainloop = DBusGMainLoop(set_as_default=True)
BUS_NAME = dbus.service.BusName(
        'uk.co.pida.pida.p%s' % os.getpid(),
        bus=dbus.SessionBus())

class DbusConfig(Object):

    def __init__(self, service):
        self.svc = service
        path = DBUS_PATH(service.get_name())
        ns = DBUS_NS(service.get_name())
        self.dbus_ns = ns
        Object.__init__(self, BUS_NAME, path)

# export the PIDA UUID to the environment for
os.environ['PIDA_DBUS_UUID'] = UUID