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


Python dbus.String方法代码示例

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


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

示例1: translate_to_dbus_type

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import String [as 别名]
def translate_to_dbus_type(typeof, value):
    """
    Helper function to map values from their native Python types
    to Dbus types.

    :param type typeof: Target for type conversion e.g., 'dbus.Dictionary'
    :param value: Value to assign using type 'typeof'
    :return: 'value' converted to type 'typeof'
    :rtype: typeof
    """
    if ((isinstance(value, types.UnicodeType) or
         isinstance(value, str)) and typeof is not dbus.String):
        # FIXME: This is potentially dangerous since it evaluates
        # a string in-situ
        return typeof(eval(value))
    else:
        return typeof(value) 
开发者ID:liamw9534,项目名称:bt-manager,代码行数:19,代码来源:interface.py

示例2: test_all

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import String [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

示例3: dict_to_string

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import String [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

示例4: unwrap

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import String [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

示例5: unwrap

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import String [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

示例6: on_playing_uri_changed

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import String [as 别名]
def on_playing_uri_changed(self, Player, three, four):
        #log.debug("uri changed event")

        # Update Metadata
        self.update_metadata()

        # Update track & trackid

        self.trackid2 = self.metadata.get(dbus.String(u'mpris:trackid'))
        if self.trackid != self.trackid2:
            # Update trackid
            self.trackid = self.trackid2
            # Update track name
            self.track = self.get_track(self.metadata)
            # Trigger event method
            self.playing_song_changed()

        # Update playback status

        self.playbackstatus2 = self.iface.Get(Player, "PlaybackStatus")

        if self.playbackstatus != self.playbackstatus2:
            self.playbackstatus = self.playbackstatus2

            self.playbackstatus_changed() 
开发者ID:Bleuzen,项目名称:SpotRec,代码行数:27,代码来源:spotrec.py

示例7: dbus_to_python

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import String [as 别名]
def dbus_to_python(obj):
    if isinstance(obj, dbus.String):
        return str(obj)

    # Add support for other DBus types as we need them
    raise ValueError("Can't handle value: %r" % obj) 
开发者ID:ideascube,项目名称:ideascube,代码行数:8,代码来源:systemd.py

示例8: set_videopos

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import String [as 别名]
def set_videopos(self,new_coordinates):
        logger.debug('CameraStream: ' + self.name + ' Set new position for ' + self.name + ' with new coordinates: + ' + str(new_coordinates) + ' on dbus interface')
        if platform.system() == "Linux":
            if self.dbusconnection is not None:
                self.dbusconnection.VideoPosWrapper((ObjectPath('/not/used'), String(" ".join(map(str,new_coordinates)))))
            else:
                logger.error('CameraStream: ' + self.name + ' has no dbus connection, probably because omxplayer crashed because it can not connect to this stream. As a result we could not change its videopos dynamically for this stream at this time.') 
开发者ID:SvenVD,项目名称:rpisurv,代码行数:9,代码来源:CameraStream.py

示例9: _from_dbus_type

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import String [as 别名]
def _from_dbus_type(fn):
    def from_dbus_type(dbusVal):
        def from_dbus_dict(dbusDict):
            d = dict()
            for dbusKey, dbusVal in dbusDict.items():
                d[from_dbus_type(dbusKey)] = from_dbus_type(dbusVal)
            return d

        typeUnwrapper = {
            dbus.types.Dictionary: from_dbus_dict,
            dbus.types.Array: lambda x: list(map(from_dbus_type, x)),
            dbus.types.Double: float,
            dbus.types.Boolean: bool,
            dbus.types.Byte: int,
            dbus.types.Int16: int,
            dbus.types.Int32: int,
            dbus.types.Int64: int,
            dbus.types.UInt32: int,
            dbus.types.UInt64: int,
            dbus.types.ByteArray: str,
            dbus.types.ObjectPath: str,
            dbus.types.Signature: str,
            dbus.types.String: str
        }
        try:
            return typeUnwrapper[type(dbusVal)](dbusVal)
        except KeyError:
            return dbusVal

    def wrapped(fn, self, *args, **kwargs):
            return from_dbus_type(fn(self, *args, **kwargs))

    return decorator(wrapped, fn)


# CLASSES 
开发者ID:willprice,项目名称:python-omxplayer-wrapper,代码行数:38,代码来源:player.py

示例10: set_aspect_mode

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import String [as 别名]
def set_aspect_mode(self, mode):
        """
        Set the aspect mode of the video

        Args:
            mode (str): One of ("letterbox" | "fill" | "stretch")
        """
        self._player_interface.SetAspectMode(ObjectPath('/not/used'), String(mode)) 
开发者ID:willprice,项目名称:python-omxplayer-wrapper,代码行数:10,代码来源:player.py

示例11: set_video_pos

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import String [as 别名]
def set_video_pos(self, x1, y1, x2, y2):
        """
        Set the video position on the screen

        Args:
            x1 (int): Top left x coordinate (px)
            y1 (int): Top left y coordinate (px)
            x2 (int): Bottom right x coordinate (px)
            y2 (int): Bottom right y coordinate (px)
        """
        position = "%s %s %s %s" % (str(x1),str(y1),str(x2),str(y2))
        self._player_interface.VideoPos(ObjectPath('/not/used'), String(position)) 
开发者ID:willprice,项目名称:python-omxplayer-wrapper,代码行数:14,代码来源:player.py

示例12: set_video_crop

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import String [as 别名]
def set_video_crop(self, x1, y1, x2, y2):
        """
        Args:
            x1 (int): Top left x coordinate (px)
            y1 (int): Top left y coordinate (px)
            x2 (int): Bottom right x coordinate (px)
            y2 (int): Bottom right y coordinate (px)
        """
        crop = "%s %s %s %s" % (str(x1),str(y1),str(x2),str(y2))
        self._player_interface.SetVideoCropPos(ObjectPath('/not/used'), String(crop)) 
开发者ID:willprice,项目名称:python-omxplayer-wrapper,代码行数:12,代码来源:player.py

示例13: agent_event_request_pin_code

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import String [as 别名]
def agent_event_request_pin_code(event, device):
    print '\n========================================================='
    print 'Agent event:', event
    print 'Device:', device
    print 'Enter PIN 1234 on device'
    return dbus.String('1234') 
开发者ID:liamw9534,项目名称:bt-manager,代码行数:8,代码来源:demo.py

示例14: StartDiscovery

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import String [as 别名]
def StartDiscovery(self):
        self._props[dbus.String(u'Discovering')] = \
            dbus.Boolean(True, variant_level=1) 
开发者ID:liamw9534,项目名称:bt-manager,代码行数:5,代码来源:test_bt_bus.py

示例15: StopDiscovery

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import String [as 别名]
def StopDiscovery(self):
        self._props[dbus.String(u'Discovering')] = \
            dbus.Boolean(False, variant_level=1) 
开发者ID:liamw9534,项目名称:bt-manager,代码行数:5,代码来源:test_bt_bus.py


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