當前位置: 首頁>>代碼示例>>Python>>正文


Python dbus.ByteArray方法代碼示例

本文整理匯總了Python中dbus.ByteArray方法的典型用法代碼示例。如果您正苦於以下問題:Python dbus.ByteArray方法的具體用法?Python dbus.ByteArray怎麽用?Python dbus.ByteArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dbus的用法示例。


在下文中一共展示了dbus.ByteArray方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: unwrap

# 需要導入模塊: import dbus [as 別名]
# 或者: from dbus import ByteArray [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

示例2: unwrap

# 需要導入模塊: import dbus [as 別名]
# 或者: from dbus import ByteArray [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

示例3: set_icon_from_pixbuf

# 需要導入模塊: import dbus [as 別名]
# 或者: from dbus import ByteArray [as 別名]
def set_icon_from_pixbuf(self, icon):
        """Set a custom icon from a GdkPixbuf.
        """
        struct = (
            icon.get_width(),
            icon.get_height(),
            icon.get_rowstride(),
            icon.get_has_alpha(),
            icon.get_bits_per_sample(),
            icon.get_n_channels(),
            dbus.ByteArray(icon.get_pixels())
            )
        self.hints['icon_data'] = struct 
開發者ID:raelgc,項目名稱:scudcloud,代碼行數:15,代碼來源:notify2.py

示例4: base_to_python

# 需要導入模塊: import dbus [as 別名]
# 或者: from dbus import ByteArray [as 別名]
def base_to_python(val):
				if isinstance(val, dbus.ByteArray):
						return "".join([str(x) for x in val])
				if isinstance(val, (dbus.Array, list, tuple)):
						return [fixups.base_to_python(x) for x in val]
				if isinstance(val, (dbus.Dictionary, dict)):
						return dict([(fixups.base_to_python(x), fixups.base_to_python(y)) for x,y in val.items()])
				if isinstance(val, dbus.ObjectPath):
						for obj in (NetworkManager, Settings, AgentManager):
								if val == obj.object_path:
										return obj
						if val.startswith('/org/freedesktop/NetworkManager/'):
								classname = val.split('/')[4]
								classname = {
									 'Settings': 'Connection',
									 'Devices': 'Device',
								}.get(classname, classname)
								return globals()[classname](val)
						if val == '/':
								return None
				if isinstance(val, (dbus.Signature, dbus.String)):
						return six.text_type(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 six.int2byte(int(val))
				return val 
開發者ID:AstroPrint,項目名稱:AstroBox,代碼行數:31,代碼來源:NetworkManager.py

示例5: addr_to_dbus

# 需要導入模塊: import dbus [as 別名]
# 或者: from dbus import ByteArray [as 別名]
def addr_to_dbus(addr,family):
				if (family == socket.AF_INET):
						return dbus.UInt32(struct.unpack('I', socket.inet_pton(family,addr))[0])
				else:
						return dbus.ByteArray(socket.inet_pton(family,addr)) 
開發者ID:AstroPrint,項目名稱:AstroBox,代碼行數:7,代碼來源:NetworkManager.py

示例6: wrap

# 需要導入模塊: import dbus [as 別名]
# 或者: from dbus import ByteArray [as 別名]
def wrap(self, val):
        if isinstance(val, NMDbusInterface):
            return val.object_path
        if hasattr(val, 'mro'):
            for klass in val.mro():
                if klass.__module__ == '_dbus_bindings':
                    return val
        if hasattr(val, '__iter__') and not isinstance(val, basestring):
            if hasattr(val, 'items'):
                return dict([(x, self.wrap(y)) for x, y in val.items()])
            else:
                if (isinstance(val, dbus.Struct) or isinstance(val, dbus.ByteArray)):
                    return val
                return [self.wrap(x) for x in val]
        return val 
開發者ID:atareao,項目名稱:my-weather-indicator,代碼行數:17,代碼來源:networkmanayer.py

示例7: addr_to_dbus

# 需要導入模塊: import dbus [as 別名]
# 或者: from dbus import ByteArray [as 別名]
def addr_to_dbus(addr, family):
        if (family == socket.AF_INET):
            return dbus.UInt32(struct.unpack('I', socket.inet_pton(family, addr))[0])
        else:
            return dbus.ByteArray(socket.inet_pton(family, addr)) 
開發者ID:atareao,項目名稱:my-weather-indicator,代碼行數:7,代碼來源:networkmanayer.py

示例8: base_to_python

# 需要導入模塊: import dbus [as 別名]
# 或者: from dbus import ByteArray [as 別名]
def base_to_python(val):
        if isinstance(val, dbus.ByteArray):
            return "".join([str(x) for x in val])
        if isinstance(val, (dbus.Array, list, tuple)):
            return [fixups.base_to_python(x) for x in val]
        if isinstance(val, (dbus.Dictionary, dict)):
            return dict([(fixups.base_to_python(x), fixups.base_to_python(y)) for x, y in val.items()])
        if isinstance(val, dbus.ObjectPath):
            for obj in (NetworkManager, Settings, AgentManager):
                if val == obj.object_path:
                    return obj
            if val.startswith('/org/freedesktop/NetworkManager/'):
                classname = val.split('/')[4]
                classname = {
                    'Settings': 'Connection',
                    'Devices': 'Device',
                }.get(classname, classname)
                try:
                    return globals()[classname](val)
                except ObjectVanished:
                    return None
            if val == '/':
                return None
        if isinstance(val, (dbus.Signature, dbus.String)):
            return six.text_type(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 six.int2byte(int(val))
        return val 
開發者ID:eduvpn,項目名稱:python-eduvpn-client,代碼行數:34,代碼來源:other_nm.py

示例9: addr_to_dbus

# 需要導入模塊: import dbus [as 別名]
# 或者: from dbus import ByteArray [as 別名]
def addr_to_dbus(addr, family):
        if family == socket.AF_INET:
            return dbus.UInt32(struct.unpack('I', socket.inet_pton(family, addr))[0])
        else:
            return dbus.ByteArray(socket.inet_pton(family, addr)) 
開發者ID:eduvpn,項目名稱:python-eduvpn-client,代碼行數:7,代碼來源:other_nm.py


注:本文中的dbus.ByteArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。