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


Python dbus.Dictionary方法代码示例

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


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

示例1: test_all

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Dictionary [as 别名]
def test_all(self):

        val = [1, 2, 3, 4, 5]
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.Array, val),  # noqa
                         dbus.Array(val))
        val = -1
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.Int32, val),  # noqa
                         dbus.Int32(val))
        val = 1
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.UInt32, val),  # noqa
                         dbus.UInt32(val))
        val = 'Test'
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.String, val),  # noqa
                         dbus.String(val))
        val = {'Hello': 1}
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.Dictionary,  # noqa
                                                           val),
                         dbus.Dictionary(val))
        val = 'True'
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.Boolean, val),  # noqa
                         dbus.Boolean(True))
        val = 'False'
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.Boolean, val),  # noqa
                         dbus.Boolean(False)) 
开发者ID:liamw9534,项目名称:bt-manager,代码行数:26,代码来源:test_bt_bus.py

示例2: create_interface

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Dictionary [as 别名]
def create_interface(self, interface, bridge_interface=None,
                         driver=None, config_file=None):
        try:
            wpa_interface = self.__get_interface()
        except dbus.exceptions.DBusException as error:
            raise ServiceError(error)
        else:
            args = {"Ifname": interface}
            if bridge_interface is not None:
                args["BridgeIfname"] = bridge_interface
            if driver is not None:
                args["Driver"] = driver
            if config_file is not None:
                args["ConfigFile"] = config_file
            try:
                return wpa_interface.CreateInterface(dbus.Dictionary(args, 'sv'))
            except dbus.exceptions.DBusException as error:
                raise InterfaceError(error) 
开发者ID:emlid,项目名称:pywificontrol,代码行数:20,代码来源:dbuswpasupplicant.py

示例3: get_player_properties

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Dictionary [as 别名]
def get_player_properties(self):
        return dbus.Dictionary({
            'Metadata': self._metadata,
            'Rate': 1.0,
            'MinimumRate': 1.0,
            'MaximumRate': 1.0,
            'CanGoNext': True,
            'CanGoPrevious': True,
            'CanControl': True,
            'CanSeek': True,
            'CanPause': True,
            'CanPlay': True,
            'Position': self._old_position,
            # 'LoopStatus': 'Playlist',
            'PlaybackStatus': to_dbus_playback_status(self._app.player.state),
            'Volume': to_dbus_volume(self._app.player.volume),
        }, signature='sv', variant_level=2)

    # ##########################
    # implement mpris2 interface
    # ########################## 
开发者ID:feeluown,项目名称:FeelUOwn,代码行数:23,代码来源:mpris2.py

示例4: dict_to_string

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Dictionary [as 别名]
def dict_to_string(self, d):
        # Try to trivially translate a dictionary's elements into nice string
        # formatting.
        dstr = ""
        for key in d:
            val = d[key]
            str_val = ""
            add_string = True
            if isinstance(val, dbus.Array):
                for elt in val:
                    if isinstance(elt, dbus.Byte):
                        str_val += "%s " % int(elt)
                    elif isinstance(elt, dbus.String):
                        str_val += "%s" % elt
            elif isinstance(val, dbus.Dictionary):
                dstr += self.dict_to_string(val)
                add_string = False
            else:
                str_val = val
            if add_string:
                dstr += "%s: %s\n" % (key, str_val)
        return dstr 
开发者ID:openshift-kni,项目名称:baremetal-deploy,代码行数:24,代码来源:nmcli.py

示例5: unwrap

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Dictionary [as 别名]
def unwrap(val):
    if isinstance(val, dbus.ByteArray):
        return "".join([str(x) for x in val])
    if isinstance(val, (dbus.Array, list, tuple)):
        return [unwrap(x) for x in val]
    if isinstance(val, (dbus.Dictionary, dict)):
        return dict([(unwrap(x), unwrap(y)) for x, y in val.items()])
    if isinstance(val, (dbus.Signature, dbus.String)):
        return str(val)
    if isinstance(val, dbus.Boolean):
        return bool(val)
    if isinstance(val, (dbus.Int16, dbus.UInt16, dbus.Int32, dbus.UInt32, dbus.Int64, dbus.UInt64)):
        return int(val)
    if isinstance(val, dbus.Byte):
        return bytes([int(val)])
    return val 
开发者ID:dietervanhoof,项目名称:polybar-spotify-controls,代码行数:18,代码来源:py_spotify_listener.py

示例6: Set

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Dictionary [as 别名]
def Set(self, interface_name, property_name, value, *args, **kwargs):
        """Standard D-Bus API for setting a property value"""

        try:
            iface_props = self.props[interface_name]
        except KeyError:
            raise dbus.exceptions.DBusException(
                'no such interface ' + interface_name,
                name=self.interface + '.UnknownInterface')

        if property_name not in iface_props:
            raise dbus.exceptions.DBusException(
                'no such property ' + property_name,
                name=self.interface + '.UnknownProperty')

        iface_props[property_name] = value

        self.PropertiesChanged(interface_name,
                               dbus.Dictionary({property_name: value},
                                               signature='sv'),
                               dbus.Array([], signature='s')) 
开发者ID:ukBaz,项目名称:python-bluezero,代码行数:23,代码来源:localGATT.py

示例7: unwrap

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Dictionary [as 别名]
def unwrap(self, val):
        if isinstance(val, dbus.ByteArray):
            return "".join([str(x) for x in val])
        if isinstance(val, (dbus.Array, list, tuple)):
            return [self.unwrap(x) for x in val]
        if isinstance(val, (dbus.Dictionary, dict)):
            return dict([(self.unwrap(x), self.unwrap(y)) for x, y in val.items()])
        if isinstance(val, dbus.ObjectPath):
            if val.startswith('/org/freedesktop/NetworkManager/'):
                classname = val.split('/')[4]
                classname = {
                    'Settings': 'Connection',
                    'Devices': 'Device',
                }.get(classname, classname)
                return globals()[classname](val)
        if isinstance(val, (dbus.Signature, dbus.String)):
            return unicode(val)
        if isinstance(val, dbus.Boolean):
            return bool(val)
        if isinstance(val, (dbus.Int16, dbus.UInt16, dbus.Int32, dbus.UInt32, dbus.Int64, dbus.UInt64)):
            return int(val)
        if isinstance(val, dbus.Byte):
            return bytes([int(val)])
        return val 
开发者ID:atareao,项目名称:my-weather-indicator,代码行数:26,代码来源:networkmanayer.py

示例8: doCommand

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Dictionary [as 别名]
def doCommand(self,comm):
        self.com = comm 
        #Quit daemon and systray
        if self.com == "quit":
            #close systray when closing the daemon as well
            self.interface.do_quit(True)
            print("pomodoro daemon halted")
        # Show the change task gui
        elif self.com == "systray":
            # use busConnection better than bus = dbus.SessionBus() to work with systemd for example
            self.bus = dbus.bus.BusConnection(self.dbus_path)
            self.session_bus = self.bus.get_object('org.liloman.pomodoro.systray', "/systray")
            systray = dbus.Interface(self.session_bus, "org.liloman.pomodoro.systrayInterface")
            systray.show_change_task()
        # Start a uuid task
        elif self.com == "do_start":
            if len(sys.argv) != 3:
                print("must pass a valid uuid")
                sys.exit(1)
            dic = dbus.Dictionary({'uuid': sys.argv[2] , 'resume': 'No'  } , signature = 'ss' )
            try:
                print ("reply:"+self.interface.do_start(dic)[0])
            except:
                print("Incorrect uuid:"+sys.argv[2]+" .The task couldn't be started")
        # Do any other command
        else:
            print(u''.join(self.interface.do_fsm(self.com)[0]).encode('utf-8').strip()) 
开发者ID:liloman,项目名称:pomodoroTasks2,代码行数:29,代码来源:client.py

示例9: start

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Dictionary [as 别名]
def start(self):
        self.assertEquals(interface.do_start(dbus.Dictionary({'uuid':  self.uuid , 'resume': 'No'}))[0],"started:"+self.uuid) 
开发者ID:liloman,项目名称:pomodoroTasks2,代码行数:4,代码来源:basic.py

示例10: test_done_current

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Dictionary [as 别名]
def test_done_current(self):
        other_task = Task(self.tw, description="task to be done")
        other_task.save()
        uuid2 = other_task['uuid']
        self.assertEquals(interface.do_start(dbus.Dictionary({'uuid':  uuid2 , 'resume': 'No'}))[0],"started:"+uuid2)
        prog = re.compile('started .* left.*')
        self.assertTrue(prog.match(interface.do_fsm("status")[0]))
        self.assertEquals(interface.done_current()[0],"ok")
        self.assertTrue(prog.match(interface.do_fsm("status")[0]))
        self.assertEquals(interface.done_current()[0],"no active task") 
开发者ID:liloman,项目名称:pomodoroTasks2,代码行数:12,代码来源:basic.py

示例11: test_resume

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Dictionary [as 别名]
def test_resume(self):
        self.start()
        self.assertEquals(interface.do_fsm("stop")[0],"ok")
        self.assertEquals(interface.do_fsm("start")[0],"ok")
        prog = re.compile('started .* left.*')
        self.assertTrue(prog.match(interface.do_fsm("status")[0]))
        self.assertEquals(interface.do_fsm("pause")[0],"ok")
        prog = re.compile('paused .* left.*')
        self.assertTrue(prog.match(interface.do_fsm("status")[0]))
        self.assertEquals(interface.do_fsm("start")[0],"ok")
        self.assertEquals(interface.do_fsm("start")[0],"Already started")
        # test done and resume
        other_task = Task(self.tw, description="task 2 for the test")
        other_task.save()
        uuid2 = other_task['uuid']
        self.assertEquals(interface.do_start(dbus.Dictionary({'uuid':  uuid2 , 'resume': 'No'}))[0],"started:"+uuid2)
        prog = re.compile('started .* left.*')
        self.assertTrue(prog.match(interface.do_fsm("status")[0]))
        self.assertEquals(interface.do_fsm("stop")[0],"ok")
        other_task.done()
        self.assertEquals(interface.do_fsm("start")[0],"ok")
        self.assertTrue(prog.match(interface.do_fsm("status")[0]))
        # test delete and resume
        other_task = Task(self.tw, description="task 3 for the test")
        other_task.save()
        uuid2 = other_task['uuid']
        self.assertEquals(interface.do_start(dbus.Dictionary({'uuid':  uuid2 , 'resume': 'No'}))[0],"started:"+uuid2)
        prog = re.compile('started .* left.*')
        self.assertTrue(prog.match(interface.do_fsm("status")[0]))
        self.assertEquals(interface.do_fsm("stop")[0],"ok")
        other_task.delete()
        self.assertEquals(interface.do_fsm("start")[0],"ok")
        self.assertTrue(prog.match(interface.do_fsm("status")[0])) 
开发者ID:liloman,项目名称:pomodoroTasks2,代码行数:35,代码来源:basic.py

示例12: mediaEndpointRegisterSBC

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Dictionary [as 别名]
def mediaEndpointRegisterSBC(self):
        media = dbus.Interface(self.bus.get_object("org.bluez", self.path), "org.bluez.Media1")
        media_path = '/test/endpoint_sbc_' + self.path.split('/')[3]
        self.mediaEndpointSBC = MediaEndpoint(self.bus, media_path)
        properties = dbus.Dictionary({ "UUID" : A2DP_SINK_UUID, "Codec" : SBC_CODEC, "DelayReporting" : True, "Capabilities" : SBC_CAPABILITIES })
        media.RegisterEndpoint(media_path, properties)
        print("MediaEndpoint SBC registered for " + self.path) 
开发者ID:gmsoft-tuxicoman,项目名称:bt-audio,代码行数:9,代码来源:bt-audio.py

示例13: mediaEndpointRegisterAAC

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Dictionary [as 别名]
def mediaEndpointRegisterAAC(self):
        media = dbus.Interface(self.bus.get_object("org.bluez", self.path), "org.bluez.Media1")
        media_path = '/test/endpoint_aac_' + self.path.split('/')[3]
        self.mediaEndpointAAC = MediaEndpoint(self.bus, media_path)
        properties = dbus.Dictionary({ "UUID" : A2DP_SINK_UUID, "Codec" : AAC_CODEC, "DelayReporting" : True, "Capabilities" : AAC_CAPABILITIES })
        media.RegisterEndpoint(media_path, properties)
        print("MediaEndpoint AAC registered for " + self.path) 
开发者ID:gmsoft-tuxicoman,项目名称:bt-audio,代码行数:9,代码来源:bt-audio.py

示例14: song_changed

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Dictionary [as 别名]
def song_changed(self, artists=None, album=None, title=None,
                     album_art=None):
        """song_changed - sets the info for the current song.

        This method is not typically overriden. It should be called
        by implementations of this class when the player has changed
        songs.

        named arguments:
            artists - a list of strings representing the artists"
            album - a string for the name of the album
            title - a string for the title of the song

        """

        if artists is None:
            artists = ["Artist Unknown"]
        if album is None:
            album = "Album Uknown"
        if title is None:
            title = "Title Uknown"
        if album_art is None:
            album_art = ""

        self.__meta_data = dbus.Dictionary({"xesam:album": album,
                                            "xesam:title": title,
                                            "xesam:artist": artists,
                                            "mpris:artUrl": album_art,
                                            }, "sv", variant_level=1) 
开发者ID:atareao,项目名称:lplayer,代码行数:31,代码来源:sound_menu.py

示例15: signal_playing

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Dictionary [as 别名]
def signal_playing(self):
        """signal_playing - Tell the Sound Menu that the player has
        started playing. Implementations many need to call this function in
        order to keep the Sound Menu in synch.

        arguments:
            none

        """
        self.__playback_status = "Playing"
        d = dbus.Dictionary({"PlaybackStatus": self.__playback_status,
                            "Metadata": self.__meta_data}, "sv",
                            variant_level=1)
        self.PropertiesChanged("org.mpris.MediaPlayer2.Player", d, []) 
开发者ID:atareao,项目名称:lplayer,代码行数:16,代码来源:sound_menu.py


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