background = pygame.image.load("dashboard.png") backgroundRect = background.get_rect() size = (width, height) = background.get_size() screen = pygame.display.set_mode(size) pygame.display.set_caption('Simulation dashboard') screen.blit(background, backgroundRect) font = pygame.font.SysFont('Calibri', 25, True, False) initDisplay() # Initialize DBus loop as the main loop DBusGMainLoop(set_as_default=True) # Connect on the bus dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) if host == LOCAL_HOST: dbusConnectionBus = dbus.SessionBus() else: dbusConnectionBus = dbus.bus.BusConnection("tcp:host=" + host + ",port=4000") # Automotive message broker try: ambObject = dbusConnectionBus.get_object("org.automotive.message.broker", "/") except dbus.DBusException: print("connection to Automotive message broker failed") print_exc() sys.exit(1) ambInterface = dbus.Interface(ambObject, "org.automotive.Manager") # Get the object path to retrieve Engine Speed
def _get_vlc(self): mpris = 'org.mpris.MediaPlayer2' mpris_slash = '/' + mpris.replace('.', '/') bus = dbus.SessionBus() proxy = bus.get_object(mpris + '.vlc', mpris_slash) return dbus.Interface(proxy, dbus_interface=mpris + '.Player')
play_pause = fix_string(u'\u25B6,\u23F8') # first character is play, second is paused label_with_font = '%{{T{font}}}{label}%{{T-}}' font = args.font play_pause_font = args.play_pause_font # parameters can be overwritten by args if args.trunclen is not None: trunclen = args.trunclen if args.custom_format is not None: output = args.custom_format if args.play_pause is not None: play_pause = args.play_pause try: session_bus = dbus.SessionBus() spotify_bus = session_bus.get_object( 'org.mpris.MediaPlayer2.spotify', '/org/mpris/MediaPlayer2' ) spotify_properties = dbus.Interface( spotify_bus, 'org.freedesktop.DBus.Properties' ) metadata = spotify_properties.Get('org.mpris.MediaPlayer2.Player', 'Metadata') status = spotify_properties.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus') # Handle play/pause label
class MainLoop(gobject.MainLoop): def __init__(self, service): super(MainLoop, self).__init__() self.__service = service def __stdin_cb(self, fd, condition): if condition & gobject.IO_IN: line = sys.stdin.readline().decode(coding, 'ignore').rstrip('\n\r') if len(line) > 0: args = line.split('|') self.__service.Message(args[0], args[1:]) if condition & gobject.IO_HUP: exit() return True def run(self): gobject.io_add_watch(0, gobject.IO_IN | gobject.IO_HUP, self.__stdin_cb) super(MainLoop, self).run() if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) service = Object(dbus.SessionBus()) mainloop = MainLoop(service) mainloop.run()
def __init__(self): bus_name = dbus.service.BusName('org.chromium.flimflam', bus=dbus.SessionBus()) dbus.service.Object.__init__(self, bus_name, '/')
dumpfile(skypedir + "user256.dbb", cls=SkypeContactDBB) dumpfile(skypedir + "user1024.dbb", cls=SkypeContactDBB) dumpfile(skypedir + "voicemail256.dbb") ########NEW FILE######## __FILENAME__ = dbusapi #!/usr/bin/env python import dbus import sys try: skype = dbus.SystemBus().get_object('com.Skype.API', '/com/Skype') except: try: skype = dbus.SessionBus().get_object('com.Skype.API', '/com/Skype') except: print "Can't find Skype API" sys.exit() print skype.Invoke("NAME python") print skype.Invoke("PROTOCOL 9999") print skype.Invoke("SEARCH CHATS") ########NEW FILE######## __FILENAME__ = skypelog #!/usr/bin/env python # Copyright 2011 Valery Yundin # # This file is free software # project page https://github.com/Vayu/skypelog
def __init__(self, app): bus_name = dbus.service.BusName(HOTOT_DBUS_NAME, bus=dbus.SessionBus()) dbus.service.Object.__init__(self, bus_name, HOTOT_DBUS_PATH) self.app = app s = []
def __init__(self): DBusGMainLoop(set_as_default=True) self.bus = dbus.SessionBus() self.bus.watch_name_owner('org.gnome.FontManager', FontViewer.set_state)
def install_pkgs(self): # get list of packages to be installed from cfg, using pop to delete dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) dbus.mainloop.glib.threads_init() # # for ppa in cfg['tobeinstalled']: # for pkgid in cfg['tobeinstalled'][ppa]: # if ppa not in cfg['installing']: # cfg['downloading'][ppa] = {} # pkg = cfg['tobeinstalled'][ppa].pop(pkgid) # cfg['downloading'][ppa][pkgid] = pkg # debs_dir = cfg['debs_dir'] # rpms_dir = cfg['rpms_dir'] # self._thread_pool.apply_async(self._get_deb_links_and_download, # (ppa, # pkg, # debs_dir, # rpms_dir,)) try: # bus = dbus.SystemBus() # proxy = bus.get_object('org.freedesktop.PolicyKit1', '/org/freedesktop/PolicyKit1/Authority') # authority = dbus.Interface(proxy, dbus_interface='org.freedesktop.PolicyKit1.Authority') # # system_bus_name = bus.get_unique_name() # # subject = ('system-bus-name', {'name': system_bus_name}) # action_id = 'org.freedesktop.policykit.exec' # details = {} # flags = 1 # AllowUserInteraction flag # cancellation_id = '' # No cancellation id # # result = authority.CheckAuthorization(subject, action_id, details, flags, cancellation_id) system_bus = dbus.SystemBus() proxy = system_bus.get_object("org.freedesktop.PolicyKit1", "/org/freedesktop/PolicyKit1/Authority") authority = dbus.Interface(proxy, dbus_interface='org.freedesktop.PolicyKit1.Authority') system_bus_name = system_bus.get_unique_name() proc = Polkit.UnixProcess.new(os.getpid()) subject = ('unix-process', {'pid': dbus.UInt32(proc.get_pid()), 'start-time': dbus.UInt64(proc.get_start_time())}) action_id = 'uk.co.jerlesey.kxfed.InstallPkgs' details = {} #dbus.Dictionary({'year': 1964}, signature='sv') flags = 1 cancellation_id = '' result = authority.CheckAuthorization(subject, action_id, details, flags, cancellation_id) if result[0] == True: session_bus = dbus.SessionBus() proxy_object = session_bus.get_object("uk.co.jerlesey.kxfed.InstallPkgs", "/InstallPkgs") proxy_object.connect_to_signal("progress_adjusted", self.install_pkgs_signal_handler, dbus_interface="uk.co.jerlesey.kxfed.InstallPkgs") proxy_object.install(self.lp_team.web_link, dbus_interface="uk.co.jerlesey.kxfed.InstallPkgs") loop = GLib.MainLoop() loop.run() else: pass except dbus.DBusException: traceback.print_exc() sys.exit(1) # lets make a catchall session_bus.add_signal_receiver(self.install_pkgs_signal_handler, dbus_interface="uk.co.jerlesey.kxfed.InstallPkgs", signal_name="progress_adjusted")
def __init__(self): bus_name = dbus.service.BusName('org.frankhale.helloservice', bus=dbus.SessionBus()) dbus.service.Object.__init__(self, bus_name, '/org/frankhale/helloservice')
def __init__(self): dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) self.bus = dbus.SessionBus() self.secretsProxy = DbusProxyIface(self.bus.get_object("org.freedesktop.secrets", "/org/freedesktop/secrets"), "org.freedesktop.Secret.Service") self.loop = GObject.MainLoop() self.session = None
def __init__(self): super().__init__() self.bus = dbus.SessionBus() self.__cookie = None
def logout_current_desktop_session(): logger = get_logger() logger.info("Logging out the current desktop session") try: session_bus = dbus.SessionBus() except dbus.exceptions.DBusException: pass else: # KDE Plasma try: kde = session_bus.get_object("org.kde.ksmserver", "/KSMServer") kde.logout(0, 3, 3, dbus_interface="org.kde.KSMServerInterface") except dbus.exceptions.DBusException: pass # GNOME try: gnome = session_bus.get_object("org.gnome.SessionManager", "/org/gnome/SessionManager") gnome.Logout(1, dbus_interface="org.gnome.SessionManager") except dbus.exceptions.DBusException: pass # XFCE try: xfce = session_bus.get_object("org.xfce.SessionManager", "/org/xfce/SessionManager") xfce.Logout(False, True, dbus_interface="org.xfce.Session.Manager") except dbus.exceptions.DBusException: pass # Deepin try: deepin = session_bus.get_object('com.deepin.SessionManager', '/com/deepin/SessionManager') deepin.RequestLogout() except dbus.exceptions.DBusException: pass # i3 try: exec_bash("i3-msg exit") except BashError: pass # openbox try: exec_bash("openbox --exit") except BashError: pass # AwesomeWM try: exec_bash("awesome-client \"awesome.quit()\"") except BashError: pass # bspwm try: exec_bash("bspc quit") except BashError: pass # dwm try: exec_bash("pkill -SIGTERM -f dwm") except BashError: pass # lxde try: exec_bash("pkill -SIGTERM -f lxsession") except BashError: pass # qtile try: exec_bash("qtile-cmd -o cmd -f shutdown") except BashError: pass
def __init__(self): proxy = dbus.SessionBus().get_object(self.BUS_NAME, self.OBJECT_PATH) self.iface = dbus.Interface(proxy, dbus_interface=self.INTERFACE_NAME) self.cookie = None self.inhibit()
def test_name_owner(self): bus = dbus.SessionBus() self.failUnless( bus.name_has_owner("org.gnome.UPnP.MediaServer2.QuodLibet"))
win.class_name, win.name, win.desktop, win.type, win.state, (geometry.x, geometry.y), (geometry.width, geometry.height), )] # TODO: GetDesktops # TODO: GetDesktopInfo dbus_loop = DBusGMainLoop(set_as_default=True) #dbus_loop = DBusQtMainLoop(set_as_default=True) session_bus = dbus.SessionBus(mainloop=dbus_loop) name = dbus.service.BusName("net.kosciak.PyWO", session_bus) service = DBusService(session_bus, "/net/kosciak/PyWO") import gobject gobject.threads_init() loop = gobject.MainLoop() # NOTE: not sure how to start Qt event loop in separate thread... #from PyQt4 import QtCore #loop = QtCore.QEventLoop() def setup(config): service.CONFIG = config
def build_process_bar(self, now_playing, total_length, playing_flag, pause_flag, playing_mode): if (self.storage.database['player_info']['idx'] >= len( self.storage.database['player_info']['player_list'])): return curses.noecho() self.screen.move(3, 1) self.screen.clrtoeol() self.screen.move(4, 1) self.screen.clrtoeol() if not playing_flag: return if total_length <= 0: total_length = 1 if now_playing > total_length or now_playing <= 0: now_playing = 0 process = '[' for i in range(0, 33): if i < now_playing / total_length * 33: if (i + 1) > now_playing / total_length * 33: if not pause_flag: process += '>' continue process += '=' else: process += ' ' process += '] ' now_minute = int(now_playing / 60) if now_minute > 9: now_minute = str(now_minute) else: now_minute = '0' + str(now_minute) now_second = int(now_playing - int(now_playing / 60) * 60) if now_second > 9: now_second = str(now_second) else: now_second = '0' + str(now_second) total_minute = int(total_length / 60) if total_minute > 9: total_minute = str(total_minute) else: total_minute = '0' + str(total_minute) total_second = int(total_length - int(total_length / 60) * 60) if total_second > 9: total_second = str(total_second) else: total_second = '0' + str(total_second) process += '(' + now_minute + ':' + now_second + '/' + total_minute + ':' + total_second + ')' # NOQA if playing_mode == 0: process = '顺序播放 ' + process elif playing_mode == 1: process = '顺序循环 ' + process elif playing_mode == 2: process = '单曲循环 ' + process elif playing_mode == 3: process = '随机播放 ' + process elif playing_mode == 4: process = '随机循环 ' + process else: pass self.addstr(3, self.startcol - 2, process, curses.color_pair(1)) song = self.storage.database['songs'][ self.storage.database['player_info']['player_list'][ self.storage.database['player_info']['idx']]] if 'lyric' not in song.keys() or len(song['lyric']) <= 0: self.now_lyric = '暂无歌词 ~>_<~ \n' if dbus_activity and self.config.get_item('osdlyrics'): self.now_playing = song['song_name'] + ' - ' + song[ 'artist'] + '\n' else: key = now_minute + ':' + now_second for line in song['lyric']: if key in line: if 'tlyric' not in song.keys() or len(song['tlyric']) <= 0: self.now_lyric = line else: self.now_lyric = line for tline in song['tlyric']: if key in tline and self.config.get_item( 'translation'): self.now_lyric = tline + ' || ' + self.now_lyric # NOQA self.now_lyric = re.sub('\[.*?\]', '', self.now_lyric) if dbus_activity and self.config.get_item('osdlyrics'): try: bus = dbus.SessionBus().get_object('org.musicbox.Bus', '/') if self.now_lyric == '暂无歌词 ~>_<~ \n': bus.refresh_lyrics(self.now_playing, dbus_interface='local.musicbox.Lyrics') else: bus.refresh_lyrics(self.now_lyric, dbus_interface='local.musicbox.Lyrics') except Exception as e: log.error(e) pass self.addstr(4, self.startcol - 2, str(self.now_lyric), curses.color_pair(3)) self.screen.refresh()
def waitForDbusService(): bus = dbus.SessionBus() while not (dbus.UTF8String('ch.bbv.brightness') in bus.list_names()): time.sleep(0.01)
#!/usr/bin/env python3 import dbus from dbus.mainloop.glib import DBusGMainLoop from gi.repository import GLib DBusGMainLoop(set_as_default=True) loop = GLib.MainLoop() systembus = dbus.SystemBus() sessionbus = dbus.SessionBus() def prop_handler(interface, changed_properties, invalidated_properties): notification_proxy = dbus.Interface( sessionbus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications'), 'org.freedesktop.Notifications') for p in changed_properties: notification_proxy.Notify( "prop_changed", 0, "", "Props %s changed!" % interface, "%s = %s" % (str(p), bool(changed_properties[p])), "", {}, 4000) print("%s : %s" % (p, changed_properties[p])) print() properties_proxy = dbus.Interface( systembus.get_object('org.bluez', '/org/bluez/hci0'), 'org.freedesktop.DBus.Properties') properties_proxy.connect_to_signal("PropertiesChanged", prop_handler)
def bus(self): try: return self._bus except AttributeError: self._bus = dbus.SessionBus() return self._bus
def __init__(self, guakeinstance): self.guake = guakeinstance self.bus = dbus.SessionBus() bus_name = dbus.service.BusName(DBUS_NAME, bus=self.bus) super(DbusManager, self).__init__(bus_name, DBUS_PATH)
def exec_test_deferred (funs, params, protocol=None, timeout=None): colourer = None if sys.stdout.isatty(): colourer = install_colourer() queue = servicetest.IteratingEventQueue(timeout) queue.verbose = ( os.environ.get('CHECK_TWISTED_VERBOSE', '') != '' or '-v' in sys.argv) bus = dbus.SessionBus() # conn = make_connection(bus, queue.append, params) (server, port) = start_server(queue.append, protocol=protocol) bus.add_signal_receiver( lambda *args, **kw: queue.append( Event('dbus-signal', path=unwrap(kw['path']), signal=kw['member'], args=list(map(unwrap, args)), interface=kw['interface'])), None, # signal name None, # interface None, path_keyword='path', member_keyword='member', interface_keyword='interface', byte_arrays=True ) error = None try: for f in funs: conn = make_connection(bus, queue.append, params) f(queue, bus, conn, server) except Exception as e: import traceback traceback.print_exc() error = e try: if colourer: sys.stdout = colourer.fh d = port.stopListening() if error is None: d.addBoth((lambda *args: reactor.crash())) else: # please ignore the POSIX behind the curtain d.addBoth((lambda *args: os._exit(1))) # force Disconnect in case the test crashed and didn't disconnect # properly. We need to call this async because the BaseIRCServer # class must do something in response to the Disconnect call and if we # call it synchronously, we're blocking ourself from responding to the # quit method. servicetest.call_async(queue, conn, 'Disconnect') if 'IDLE_TEST_REFDBG' in os.environ: # we have to wait for the timeout so the process is properly # exited and refdbg can generate its report time.sleep(5.5) except dbus.DBusException as e: pass
def __init__(self, servername, basepath): self.basepath = basepath self.servername = servername self.bus = dbus.SessionBus()
def __init__(self): BaseInhibitor.__init__(self) self.bus = dbus.SessionBus() self.__cookie = None
def __init__(self, serial, vid_pid=None, daemon_dbus=None): # Load up the DBus if daemon_dbus is None: session_bus = _dbus.SessionBus() daemon_dbus = session_bus.get_object( "org.razer", "/org/razer/device/{0}".format(serial)) self._dbus = daemon_dbus self._available_features = self._get_available_features() self._dbus_interfaces = { 'device': _dbus.Interface(self._dbus, "razer.device.misc"), 'brightness': _dbus.Interface(self._dbus, "razer.device.lighting.brightness") } self._name = str(self._dbus_interfaces['device'].getDeviceName()) self._type = str(self._dbus_interfaces['device'].getDeviceType()) self._fw = str(self._dbus_interfaces['device'].getFirmware()) self._drv_version = str( self._dbus_interfaces['device'].getDriverVersion()) self._has_dedicated_macro = None self._urls = None if vid_pid is None: self._vid, self._pid = self._dbus_interfaces['device'].getVidPid() else: self._vid, self._pid = vid_pid self._serial = serial self._capabilities = { 'name': True, 'type': True, 'firmware_version': True, 'serial': True, 'brightness': self._has_feature('razer.device.lighting.brightness'), 'macro_logic': self._has_feature('razer.device.macro'), # Default device is a chroma so lighting capabilities 'lighting': self._has_feature('razer.device.lighting.chroma'), 'lighting_breath_single': self._has_feature('razer.device.lighting.chroma', 'setBreathSingle'), 'lighting_breath_dual': self._has_feature('razer.device.lighting.chroma', 'setBreathDual'), 'lighting_breath_triple': self._has_feature('razer.device.lighting.chroma', 'setBreathTriple'), 'lighting_breath_random': self._has_feature('razer.device.lighting.chroma', 'setBreathRandom'), 'lighting_wave': self._has_feature('razer.device.lighting.chroma', 'setWave'), 'lighting_reactive': self._has_feature('razer.device.lighting.chroma', 'setReactive'), 'lighting_none': self._has_feature('razer.device.lighting.chroma', 'setNone'), 'lighting_spectrum': self._has_feature('razer.device.lighting.chroma', 'setSpectrum'), 'lighting_static': self._has_feature('razer.device.lighting.chroma', 'setStatic'), 'lighting_ripple': self._has_feature( 'razer.device.lighting.custom', 'setRipple' ), # Thinking of extending custom to do more hence the key check 'lighting_ripple_random': self._has_feature('razer.device.lighting.custom', 'setRippleRandomColour'), 'lighting_pulsate': self._has_feature('razer.device.lighting.bw2013', 'setPulsate'), # Get if the device has an LED Matrix, == True as its a DBus boolean otherwise, so for consistency sake we coerce it into a native bool 'lighting_led_matrix': self._dbus_interfaces['device'].hasMatrix() == True, 'lighting_led_single': self._has_feature('razer.device.lighting.chroma', 'setKey'), # Mouse lighting attrs 'lighting_logo': self._has_feature('razer.device.lighting.logo'), 'lighting_logo_active': self._has_feature('razer.device.lighting.logo', 'setLogoActive'), 'lighting_logo_blinking': self._has_feature('razer.device.lighting.logo', 'setLogoBlinking'), 'lighting_logo_brightness': self._has_feature('razer.device.lighting.logo', 'setLogoBrightness'), 'lighting_logo_pulsate': self._has_feature('razer.device.lighting.logo', 'setLogoPulsate'), 'lighting_logo_spectrum': self._has_feature('razer.device.lighting.logo', 'setLogoSpectrum'), 'lighting_logo_static': self._has_feature('razer.device.lighting.logo', 'setLogoStatic'), 'lighting_logo_none': self._has_feature('razer.device.lighting.logo', 'setLogoNone'), 'lighting_logo_reactive': self._has_feature('razer.device.lighting.logo', 'setLogoReactive'), 'lighting_logo_breath_single': self._has_feature('razer.device.lighting.logo', 'setLogoBreathSingle'), 'lighting_logo_breath_dual': self._has_feature('razer.device.lighting.logo', 'setLogoBreathDual'), 'lighting_logo_breath_random': self._has_feature('razer.device.lighting.logo', 'setLogoBreathRandom'), 'lighting_scroll': self._has_feature('razer.device.lighting.scroll'), 'lighting_scroll_active': self._has_feature('razer.device.lighting.scroll', 'setScrollActive'), 'lighting_scroll_blinking': self._has_feature('razer.device.lighting.scroll', 'setScrollBlinking'), 'lighting_scroll_brightness': self._has_feature('razer.device.lighting.scroll', 'setScrollBrightness'), 'lighting_scroll_pulsate': self._has_feature('razer.device.lighting.scroll', 'setScrollPulsate'), 'lighting_scroll_spectrum': self._has_feature('razer.device.lighting.scroll', 'setScrollSpectrum'), 'lighting_scroll_static': self._has_feature('razer.device.lighting.scroll', 'setScrollStatic'), 'lighting_scroll_none': self._has_feature('razer.device.lighting.scroll', 'setScrollNone'), 'lighting_scroll_reactive': self._has_feature('razer.device.lighting.scroll', 'setScrollReactive'), 'lighting_scroll_breath_single': self._has_feature('razer.device.lighting.scroll', 'setScrollBreathSingle'), 'lighting_scroll_breath_dual': self._has_feature('razer.device.lighting.scroll', 'setScrollBreathDual'), 'lighting_scroll_breath_random': self._has_feature('razer.device.lighting.scroll', 'setScrollBreathRandom'), 'lighting_backlight': self._has_feature('razer.device.lighting.backlight'), 'lighting_backlight_active': self._has_feature('razer.device.lighting.backlight', 'setBacklightActive'), } # Nasty hack to convert dbus.Int32 into native self._matrix_dimensions = tuple([ int(dim) for dim in self._dbus_interfaces['device'].getMatrixDimensions() ]) # Setup FX if self._FX is None: self.fx = None else: self.fx = self._FX(serial, capabilities=self._capabilities, daemon_dbus=daemon_dbus, matrix_dims=self._matrix_dimensions) # Setup Macro if self.has('macro_logic'): if self._MACRO_CLASS is not None: self.macro = self._MACRO_CLASS(serial, daemon_dbus=daemon_dbus, capabilities=self._capabilities) else: self._capabilities['macro_logic'] = False self.macro = None else: self.macro = None
def register(self): if self.registered: return try: # register the main loop for d-bus events DBusGMainLoop(set_as_default=True) bus = dbus.SessionBus() except dbus.DBusException as e: raise DRingCtrlDBusError("Unable to connect DBUS session bus") if not bus.name_has_owner(DBUS_DEAMON_OBJECT): raise DRingCtrlDBusError(("Unable to find %s in DBUS." % DBUS_DEAMON_OBJECT) + " Check if dring is running") try: proxy_instance = bus.get_object(DBUS_DEAMON_OBJECT, DBUS_DEAMON_PATH + '/Instance', introspect=False) proxy_callmgr = bus.get_object(DBUS_DEAMON_OBJECT, DBUS_DEAMON_PATH + '/CallManager', introspect=False) proxy_confmgr = bus.get_object(DBUS_DEAMON_OBJECT, DBUS_DEAMON_PATH + '/ConfigurationManager', introspect=False) proxy_videomgr = bus.get_object(DBUS_DEAMON_OBJECT, DBUS_DEAMON_PATH + '/VideoManager', introspect=False) self.instance = dbus.Interface(proxy_instance, DBUS_DEAMON_OBJECT + '.Instance') self.callmanager = dbus.Interface( proxy_callmgr, DBUS_DEAMON_OBJECT + '.CallManager') self.configurationmanager = dbus.Interface( proxy_confmgr, DBUS_DEAMON_OBJECT + '.ConfigurationManager') if proxy_videomgr: self.videomanager = dbus.Interface( proxy_videomgr, DBUS_DEAMON_OBJECT + '.VideoManager') except dbus.DBusException as e: raise DRingCtrlDBusError("Unable to bind to dring DBus API") try: self.instance.Register(os.getpid(), self.name) self.registered = True except: raise DRingCtrlDeamonError("Client registration failed") try: proxy_callmgr.connect_to_signal('incomingCall', self.onIncomingCall) proxy_callmgr.connect_to_signal('callStateChanged', self.onCallStateChanged) proxy_callmgr.connect_to_signal('conferenceCreated', self.onConferenceCreated) except dbus.DBusException as e: raise DRingCtrlDBusError("Unable to connect to dring DBus signals")
def initialize(self): bus = dbus.SessionBus() dbus_signal_connect_weakly(bus, "NameOwnerChanged", self._name_owner_changed, dbus_interface="org.freedesktop.DBus")
def _entry_props_iface(self): bus = dbus.SessionBus() obj = bus.get_object("org.gnome.UPnP.MediaServer2.QuodLibet", "/org/gnome/UPnP/MediaServer2/QuodLibet") return dbus.Interface(obj, dbus_interface="org.freedesktop.DBus.Properties")
class Player: _name = None _service = None _player = None _interface = None _bus = dbus.SessionBus() _info = {} _pause_icon = "\uf04c" _play_icon = "\uf04b" _trackMap = { 'trackid': 'mpris:trackid', 'length': 'mpris:length', 'artUrl': 'mpris:artUrl', 'album': 'xesam:album', 'artist': 'xesam:artist', 'title': 'xesam:title', 'url': 'xesam:url', 'rating': 'xesam:autoRating', 'status': 'PlaybackStatus', } def __init__(self, service): self._service = service self._name = service.split('.')[-1] self._player = self._bus.get_object(self._service, '/org/mpris/MediaPlayer2') self._interface = dbus.Interface( self._player, dbus_interface='org.freedesktop.DBus.Properties') self.get_metadata() # Get all availables information from DBus for a player object def get_metadata(self): self._info = {} metadata = self._interface.GetAll('org.mpris.MediaPlayer2.Player') for key, val in metadata.items(): if isinstance(val, dict): for subk, subv in val.items(): self._info[subk] = subv self._info[key] = val def is_playing(self): return self._info['PlaybackStatus'] == 'Playing' # Print information for a player def print_metadata(self): for k, v in self._trackMap.items(): if v not in self._info: continue val = self._info[v] print(f"{k}: {', '.join(val) if isinstance(val, list) else val}") def retrieve_metadata(self): metadata = {} for k, v in self._trackMap.items(): if v not in self._info: continue val = self._info[v] metadata[k] = str(', '.join(val) if isinstance(val, list) else val) return metadata def next(self): dbus.Interface(self._player, dbus_interface='org.mpris.MediaPlayer2.Player').Next() def prev(self): dbus.Interface( self._player, dbus_interface='org.mpris.MediaPlayer2.Player').Previous() def play_pause(self): dbus.Interface( self._player, dbus_interface='org.mpris.MediaPlayer2.Player').PlayPause() def stop(self): dbus.Interface(self._player, dbus_interface='org.mpris.MediaPlayer2.Player').Stop()
def __init__(self, app): ServiceBase.__init__(self, dbus.SessionBus(), self.NAME, self.PATH) self._keyboard = app.keyboard self._keyboard_widget = app.keyboard_widget