Python __builtin__.ord() Examples
The following are 5
code examples of __builtin__.ord().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
__builtin__
, or try the search function
.
Example #1
Source File: test_linux.py From vnpy_crypto with MIT License | 6 votes |
def get_mac_address(ifname): import fcntl ifname = ifname[:15] if PY3: ifname = bytes(ifname, 'ascii') s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) with contextlib.closing(s): info = fcntl.ioctl( s.fileno(), SIOCGIFHWADDR, struct.pack('256s', ifname)) if PY3: def ord(x): return x else: import __builtin__ ord = __builtin__.ord return ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]
Example #2
Source File: test_linux.py From psutil with BSD 3-Clause "New" or "Revised" License | 6 votes |
def get_mac_address(ifname): import fcntl ifname = ifname[:15] if PY3: ifname = bytes(ifname, 'ascii') s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) with contextlib.closing(s): info = fcntl.ioctl( s.fileno(), SIOCGIFHWADDR, struct.pack('256s', ifname)) if PY3: def ord(x): return x else: import __builtin__ ord = __builtin__.ord return ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]
Example #3
Source File: test_linux.py From jarvis with GNU General Public License v2.0 | 6 votes |
def get_mac_address(ifname): import fcntl ifname = ifname[:15] if PY3: ifname = bytes(ifname, 'ascii') s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) with contextlib.closing(s): info = fcntl.ioctl( s.fileno(), SIOCGIFHWADDR, struct.pack('256s', ifname)) if PY3: def ord(x): return x else: import __builtin__ ord = __builtin__.ord return ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]
Example #4
Source File: BluetoothHCI.py From pybleno with MIT License | 5 votes |
def kernel_disconnect_workarounds(self, data): #print 'PRE KERNEL WORKAROUND %d' % len(data) def noop(value): return value if (sys.version_info > (3, 0)): ord = noop else: import __builtin__ ord = __builtin__.ord if len(data) == 22 and [ord(elem) for elem in data[0:5]] == [0x04, 0x3e, 0x13, 0x01, 0x00]: handle = ord(data[5]) # get address set = data[9:15] # get device info dev_info = self.get_device_info() raw_set = [ord(c) for c in set] raw_set.reverse() #addz = ''.join([hex(c) for c in set]) #set.reverse() addz = "%02x:%02x:%02x:%02x:%02x:%02x" % struct.unpack("BBBBBB", array.array('B', raw_set)) socket2 = BluetoothSocket(socket.AF_BLUETOOTH, socket.SOCK_SEQPACKET, socket.BTPROTO_L2CAP) socket2.bind_l2(0, dev_info['addr'], cid=ATT_CID, addr_type=0)#addr_type=dev_info['type']) self._l2sockets[handle] = socket2 try: result = socket2.connect_l2(0, addz, cid=ATT_CID, addr_type=ord(data[8]) + 1) except: pass elif len(data) == 7 and [ord(elem) for elem in data[0:4]] == [0x04, 0x05, 0x04, 0x00]: handle = ord(data[4]) socket2 = self._l2sockets[handle] if handle in self._l2sockets else None if socket2: # print 'GOT A SOCKET!' socket2.close() del self._l2sockets[handle]
Example #5
Source File: utf8.py From termite-visualizations with BSD 3-Clause "New" or "Revised" License | 5 votes |
def ord(char): """ returns unicode id for utf8 or unicode *char* character SUPPOSE that *char* is an utf-8 or unicode character only """ if isinstance(char, unicode): return __builtin__.ord(char) return __builtin__.ord(unicode(char, 'utf-8'))