当前位置: 首页>>代码示例>>Python>>正文


Python dbus.SessionBus类代码示例

本文整理汇总了Python中dbus.SessionBus的典型用法代码示例。如果您正苦于以下问题:Python SessionBus类的具体用法?Python SessionBus怎么用?Python SessionBus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SessionBus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: nh_side_command_process

def nh_side_command_process():
    """
    Execute command (clear screen or exit) on NH.

    :return: [no return value]
    """

    bus = SessionBus()
    obj = bus.get_object("im.pidgin.purple.PurpleService",
                         "/im/pidgin/purple/PurpleObject")
    purple = Interface(obj, "im.pidgin.purple.PurpleInterface")
    account = purple.PurpleAccountsGetAllActive()[0]

    while True:
        if nh_side_command.empty():
            sleep(0.001)
            continue

        cmd = nh_side_command.get()

        if cmd.startswith("TFC|N|%s|U|CLEAR|" % int_version):
            contact = cmd.split('|')[5]
            new_conv = purple.PurpleConversationNew(1, account, contact)
            purple.PurpleConversationClearMessageHistory(new_conv)
            system("clear")
开发者ID:regina-book,项目名称:tfc-nacl,代码行数:25,代码来源:NH.py

示例2: dbus_receiver

def dbus_receiver():
    """
    Start Qt loop that loads messages from Pidgin.

    :return: [no return value]
    """

    DBusQtMainLoop(set_as_default=True)
    bus = SessionBus()
    bus.add_signal_receiver(pidgin_to_rxm_queue,
                            dbus_interface="im.pidgin.purple.PurpleInterface",
                            signal_name="ReceivedImMsg")
开发者ID:regina-book,项目名称:tfc-nacl,代码行数:12,代码来源:NH.py

示例3: Vibra_Plugin

class Vibra_Plugin(Plugin):
    def __init__(self):
        DBusGMainLoop(set_as_default=True)

        self.bus = SystemBus()
        self.sessionbus = SessionBus()
        try:
            self.mce = self.bus.get_object("com.nokia.mce", "/com/nokia/mce")
        except DBusException:
            warning("Nokia MCE not found. Vibra is disabled\n")
            return

        self.profiled = self.sessionbus.get_object("com.nokia.profiled", "/com/nokia/profiled")

        self.sessionbus.add_signal_receiver(
            self.profile_changed_handler,
            "profile_changed",
            "com.nokia.profiled",
            "com.nokia.profiled",
            "/com/nokia/profiled",
        )

        profile = self.profiled.get_profile(dbus_interface="com.nokia.profiled")
        self.get_vibra_enabled(profile)

        self.register_plugin(PLUGIN_TYPE_VIBRA)

    def ready(self):
        self.notification = get_plugin_by_type(PLUGIN_TYPE_NOTIFICATION)

        sendfile = get_plugin_by_type(PLUGIN_TYPE_SEND_FILE)
        sendfile.receive_cb.append(self.file_receive)

    def get_vibra_enabled(self, profile):
        self.enabled = (
            self.profiled.get_value(profile, "vibrating.alert.enabled", dbus_interface="com.nokia.profiled") == "On"
        )
        debug("Vibra enabled: %s\n" % self.enabled)

    def profile_changed_handler(self, foo, bar, profile, *args):
        self.get_vibra_enabled(profile)

    def vibrate(self):
        if self.enabled:
            self.mce.req_vibrator_pattern_activate("PatternChatAndEmail", dbus_interface="com.nokia.mce.request")

    def file_receive(self, cb, user, fname):
        self.vibrate()

    def user_appears(self, user):
        if user.get("friend"):
            self.vibrate()
开发者ID:proximate,项目名称:proximate,代码行数:52,代码来源:vibra.py

示例4: __init__

 def __init__(self):
     DBusGMainLoop(set_as_default=True)
     self.mem='ActiveChanged'
     self.dest='org.gnome.ScreenSaver'
     self.bus=SessionBus()
     self.loop=MainLoop()
     self.bus.add_signal_receiver(self.catch,self.mem,self.dest)
开发者ID:duleorlovic,项目名称:log_working_time,代码行数:7,代码来源:ssTriger.py

示例5: DBusMediaKeyListener

class DBusMediaKeyListener(object):
    '''Listen on DBus for media-key events.'''

    def __init__(self, callback=None):
        self._subscribers = []
        self.app = APP_NAME
        self.bus = SessionBus()
        self.bus_object = self.bus.get_object(
            'org.gnome.SettingsDaemon', '/org/gnome/SettingsDaemon/MediaKeys')
        self.bus_object.GrabMediaPlayerKeys(
            self.app, 0, dbus_interface='org.gnome.SettingsDaemon.MediaKeys')
        self.bus_object.connect_to_signal(
            'MediaPlayerKeyPressed', self._notify)
        if callback:
            self.subscribe(callback)

    def _notify(self, application, *mmkeys):
        for subscriber in self._subscribers:
            subscriber(mmkeys)

    def subscribe(self, callback):
        self._subscribers.append(callback)

    def unsubscribe(self, callback):
        self._subscribers.remove(callback)
开发者ID:adiroiban,项目名称:keysocket,代码行数:25,代码来源:websocket_keylogger_dbus.py

示例6: __init__

    def __init__(self):
        DBusGMainLoop(set_as_default=True)

        self.bus = SystemBus()
        self.sessionbus = SessionBus()
        try:
            self.mce = self.bus.get_object("com.nokia.mce", "/com/nokia/mce")
        except DBusException:
            warning("Nokia MCE not found. Vibra is disabled\n")
            return

        self.profiled = self.sessionbus.get_object("com.nokia.profiled", "/com/nokia/profiled")

        self.sessionbus.add_signal_receiver(
            self.profile_changed_handler,
            "profile_changed",
            "com.nokia.profiled",
            "com.nokia.profiled",
            "/com/nokia/profiled",
        )

        profile = self.profiled.get_profile(dbus_interface="com.nokia.profiled")
        self.get_vibra_enabled(profile)

        self.register_plugin(PLUGIN_TYPE_VIBRA)
开发者ID:proximate,项目名称:proximate,代码行数:25,代码来源:vibra.py

示例7: __init__

class VoltiSession:
    def __init__(self, app_name):
        log.Notice("running init")
        self.app_name = app_name
        self.bus = SessionBus(mainloop = DBusGMainLoop() )

    def check(self):
        log.Notice("running check")
        return self.bus.request_name(self.app_name) != bus.REQUEST_NAME_REPLY_PRIMARY_OWNER
开发者ID:zerkalica,项目名称:volti-lite,代码行数:9,代码来源:voltisession.py

示例8: __init__

    def __init__(self, registry, owner):
        """Initialize the ServerPlugin instance

        :Parameters:
            `registry` : telepathy.client.ManagerRegistry
                From the PresenceService, used to find the connection
                manager details
            `owner` : buddy.GenericOwner
                The Buddy representing the owner of this XO (normally a
                buddy.ShellOwner instance)
        """
        gobject.GObject.__init__(self)

        #: The connection, a `telepathy.client.Connection`
        self._conn = None

        #: List of dbus-python SignalMatch objects representing signal match
        #: rules associated with the connection, so we don't leak the match
        #: rules when disconnected.
        self._matches = []

        #: The manager registry, a `telepathy.client.ManagerRegistry`
        self._registry = registry

        #: set of contact handles: those for whom we've emitted contacts-online
        self._online_contacts = set()

        #: The owner, a `buddy.GenericOwner`
        self._owner = owner
        #: The owner's handle on this connection
        self.self_handle = None
        #: The owner's identifier (e.g. JID) on this connection
        self.self_identifier = None

        #: The connection's status
        self._conn_status = CONNECTION_STATUS_DISCONNECTED

        #: GLib source ID indicating when we may try to reconnect
        self._backoff_id = 0

        #: length of the next reconnect timeout
        self._reconnect_timeout = self._RECONNECT_INITIAL_TIMEOUT

        #: The ``subscribe`` channel: a `telepathy.client.Channel` or None
        self._subscribe_channel = None
        #: The members of the ``subscribe`` channel
        self._subscribe_members = set()
        #: The local-pending members of the ``subscribe`` channel
        self._subscribe_local_pending = set()
        #: The remote-pending members of the ``subscribe`` channel
        self._subscribe_remote_pending = set()

        #: The ``publish`` channel: a `telepathy.client.Channel` or None
        self._publish_channel = None

        self._session_bus = SessionBus()
        self._init_connection()
开发者ID:tchx84,项目名称:debian-pkg-sugar-presence,代码行数:57,代码来源:telepathy_plugin.py

示例9: __init__

    def __init__(self, args, read_pipe):
        QApplication.__init__(self, args)

        self.menu = None
        self.read_pipe = read_pipe
        self.fmt = "80s80sI32sI80sf"
        self.fmt_size = struct.calcsize(self.fmt)
        self.timer_active = False
        self.active_icon = False
        self.user_settings = UserSettings()
        self.user_settings.load()
        self.user_settings.debug()

        self.tray_icon = QSystemTrayIcon()

        pm = load_pixmap("hp_logo", "32x32")
        self.prop_icon = QIcon(pm)

        a = load_pixmap('active', '16x16')
        painter = QPainter(pm)
        painter.drawPixmap(32, 0, a)
        painter.end()

        self.prop_active_icon = QIcon(pm)

        self.tray_icon.setIcon(self.prop_icon)

        self.session_bus = SessionBus()
        self.service = None

        for d in device.getSupportedCUPSDevices(back_end_filter=['hp', 'hpfax']):
            self.addDevice(d)

        self.tray_icon.setToolTip(self.__tr("HPLIP Status Service"))
        QObject.connect(self.tray_icon, SIGNAL("messageClicked()"), self.messageClicked)
        notifier = QSocketNotifier(self.read_pipe, QSocketNotifier.Read)
        QObject.connect(notifier, SIGNAL("activated(int)"), self.notifierActivated)
        QObject.connect(self.tray_icon, SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self.trayActivated)
        signal.signal(signal.SIGINT, signal.SIG_DFL)
        self.tray_icon.show()

        if self.user_settings.systray_visible == SYSTRAY_VISIBLE_SHOW_ALWAYS:
            self.tray_icon.setVisible(True)
        else:
            QTimer.singleShot(HIDE_INACTIVE_DELAY, self.timeoutHideWhenInactive) # show icon for awhile @ startup

        self.tray_icon.setIcon(self.prop_active_icon)
        self.active_icon = True

        if "--ignore-update-firsttime" not in args:
            self.handle_hplip_updation()

        QTimer.singleShot(SET_MENU_DELAY, self.initDone)

        self.update_timer = QTimer()
        self.update_timer.connect(self.update_timer,SIGNAL("timeout()"),self.handle_hplip_updation)
        self.update_timer.start(UPGRADE_CHECK_DELAY)
开发者ID:incrazyboyy,项目名称:RPiTC-X,代码行数:57,代码来源:systemtray.py

示例10: __init__

 def __init__(self, callback=None):
     self._subscribers = []
     self.app = APP_NAME
     self.bus = SessionBus()
     self.bus_object = self.bus.get_object("org.gnome.SettingsDaemon", "/org/gnome/SettingsDaemon/MediaKeys")
     self.bus_object.GrabMediaPlayerKeys(self.app, 0, dbus_interface="org.gnome.SettingsDaemon.MediaKeys")
     self.bus_object.connect_to_signal("MediaPlayerKeyPressed", self._notify)
     if callback:
         self.subscribe(callback)
开发者ID:hobeone,项目名称:keysocket,代码行数:9,代码来源:keysocket.py

示例11: run_client

    def run_client(self):
        bus = SessionBus()
        obj = bus.get_object(CROSS_TEST_BUS_NAME, CROSS_TEST_PATH)
        self.obj = obj

        self.run_synchronous_tests(obj)

        # Signal tests
        logger.info("Binding signal handler for Triggered")
        # FIXME: doesn't seem to work when going via the Interface method
        # FIXME: should be possible to ask the proxy object for its
        # bus name
        bus.add_signal_receiver(self.triggered_cb, 'Triggered',
                                INTERFACE_SIGNAL_TESTS,
                                CROSS_TEST_BUS_NAME,
                                path_keyword='sender_path')
        logger.info("method/signal: Triggering signal")
        self.expected.add('%s.Trigger' % INTERFACE_TESTS)
        Interface(obj, INTERFACE_TESTS).Trigger(u'/Where/Ever', dbus.UInt64(42), reply_handler=self.trigger_returned_cb, error_handler=self.trigger_error_handler)
开发者ID:tizenorg,项目名称:external.dbus-python,代码行数:19,代码来源:cross-test-client.py

示例12: __init__

 def __init__(self):
     self.v=False
     self.o=False
     try:
         self.session = SessionBus.get_session()
         self.spotify = self.session.get_object("org.mpris.MediaPlayer2.spotify","/org/mpris/MediaPlayer2")
         self.p=Interface(self.spotify, 'org.freedesktop.DBus.Properties')
         self.v=True
         self.o=True
     except:
         pass   
开发者ID:frodo0321,项目名称:spotify_control_linux,代码行数:11,代码来源:spotify_control_linux.py

示例13: header_printer_process

def header_printer_process():
    """
    Print NH.py headers.

    :return: [no return value]
    """

    try:
        bus = SessionBus()
        obj = bus.get_object("im.pidgin.purple.PurpleService",
                             "/im/pidgin/purple/PurpleObject")
        purple = Interface(obj, "im.pidgin.purple.PurpleInterface")
        active = purple.PurpleAccountsGetAllActive()[0]
        acco_u = purple.PurpleAccountGetUsername(active)[:-1]

        print("TFC-NaCl %s | NH.py\n" % str_version)
        print("Active account: %s\n" % acco_u)

    except DBusException:
        raise CriticalError("header_printer_process", "DBusException. Ensure "
                                                      "Pidgin is running.")
开发者ID:regina-book,项目名称:tfc-nacl,代码行数:21,代码来源:NH.py

示例14: run

    def run(self):
        radiotray = SessionBus().get_object("net.sourceforge.radiotray",
                                            "/net/sourceforge/radiotray")

        radio_full_name = str(radiotray.getCurrentRadio())
        matches = search("~ ([^\(]*)", radio_full_name)
        radio_short_name = matches.group(1).rstrip() if matches else radio_full_name

        cdict = {
            "radio": radio_short_name,
            "song": str(radiotray.getCurrentMetaData()),
        }

        if "not playing" in cdict["radio"]:
            full_text = ""
        else:
            full_text = self.format.format(**cdict)

        self.output = {
            "full_text": full_text,
            "color": self.color,
        }
开发者ID:jmberros,项目名称:dotfiles,代码行数:22,代码来源:radiotray.py

示例15: Audiobox

class Audiobox():
    """Audiobox class"""
    def __init__(self):
        self.bus = SessionBus()
        self.init()

    def init(self):
        self.proxy_obj = self.bus.get_object(vim.eval('g:audiobox_dbus_dest'),
                                             vim.eval('g:audiobox_dbus_path'))
        self.player = Interface(self.proxy_obj, vim.eval('g:audiobox_dbus_interface'))
        self.properties = Interface(self.proxy_obj, vim.eval('g:audiobox_dbus_properties_interface'))

    def Play(self):
        """Play current song"""
        if self.player:
            self.player.Play()

    def Pause(self):
        """Pause current song"""
        if self.player:
            self.player.Pause()

    def Next(self):
        """Play the next song"""
        if self.player:
            self.player.Next()

    def Prev(self):
        """Play the previous song"""
        if self.player:
            self.player.Previous()

    def PlayPause(self):
        """Play / Pause the current song"""
        if self.player:
            self.player.PlayPause()

    def Stop(self):
        """Stop the current song"""
        if self.player:
            self.player.Stop()

    def GetCurrentSong(self):
        """Get the title of the current song"""
        if self.properties:
            metadata = self.properties.Get(vim.eval('g:audiobox_dbus_interface'), 'Metadata')
            if len(metadata) > 0:
                vim.command("echohl String | echom \"" + ("Song: %s, Artist: %s, Album: %s"
                    % (str(metadata['xesam:title']),
                        str(metadata['xesam:artist'][0]),
                        str(metadata['xesam:album']))) + "\" | echohl None")
开发者ID:dhruvasagar,项目名称:vim-audiobox,代码行数:51,代码来源:audiobox.py


注:本文中的dbus.SessionBus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。