本文整理匯總了Python中builtins.hex方法的典型用法代碼示例。如果您正苦於以下問題:Python builtins.hex方法的具體用法?Python builtins.hex怎麽用?Python builtins.hex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類builtins
的用法示例。
在下文中一共展示了builtins.hex方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: release
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import hex [as 別名]
def release(self):
""" Release control to libusb of the AlienFX controller."""
if not self._control_taken:
return
try:
usb.util.release_interface(self._dev, 0)
except USBError as exc:
logging.error(
"Cant release interface. Error : {}".format(exc.strerror))
try:
self._dev.attach_kernel_driver(0)
except USBError as exc:
logging.error("Cant re-attach. Error : {}".format(exc.strerror))
self._control_taken = False
logging.debug("USB device released, VID={}, PID={}".format(
hex(self._controller.vendor_id), hex(self._controller.product_id)))
示例2: reported_access
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import hex [as 別名]
def reported_access(self, address):
"""Determines if the address should be reported.
This assesses the destination address for suspiciousness. For example if
the address resides in a VAD region which is not mapped by a dll then it
might be suspicious.
"""
destination_names = self.session.address_resolver.format_address(
address)
# For now very simple: If any of the destination_names start with vad_*
# it means that the address resolver cant determine which module they
# came from.
destination = hex(address)
for destination in destination_names:
if not destination.startswith("vad_"):
return False
return destination
示例3: _cert_crl_check
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import hex [as 別名]
def _cert_crl_check(self, cert):
if not cert:
raise ValueError(
"empty or no Server Certificate chain for CRL check")
if not self._crl_checklist:
return
try:
serial_number = cert.get_serial_number()
if serial_number is None:
raise Exception("Wrong Server Certificate: No Serial Number.")
except Exception:
raise Exception(
"Wrong Server Certificate: not able to extract Serial Number.")
try:
serial_number_int = int(serial_number)
except Exception:
raise Exception(
"Wrong Server Certificate: not able to extract Serial Number in integer format.")
if serial_number in self._crl_checklist:
raise Exception("Server Certificate is in revoked list: (Serial Number: %s)" % (
str(hex(serial_number_int))))
示例4: __str__
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import hex [as 別名]
def __str__(self):
s = '(' + str(self[0])
s += ', '
if isinstance(self[1], Tensor):
if self[1].name and self[1].name is not None:
s += self[1].name
else:
s += 'tensor-' + hex(id(self[1]))
else:
s += str(self[1])
s += ', '
if isinstance(self[2], Tensor):
if self[2].name and self[2].name is not None:
s += self[2].name
else:
s += 'tensor-' + hex(id(self[2]))
else:
s += str(self[2])
s += ')'
return s
示例5: _drawRow
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import hex [as 別名]
def _drawRow(self, qp, cemu, row, asm, offset=-1):
log.debug('DRAW AN INSTRUCTION %s %s %s %s %s', asm, row, asm.get_name(), len(asm.get_operands(offset)), hex(self.getPageOffset()))
qp.setPen(QtGui.QPen(QtGui.QColor(192, 192, 192), 1, QtCore.Qt.SolidLine))
hex_data = asm.get_hex()
# write hexdump
cemu.writeAt(0, row, hex_data)
# fill with spaces
cemu.write((MNEMONIC_COLUMN - len(hex_data)) * ' ')
# let's color some branch instr
# if asm.isBranch():
# qp.setPen(QtGui.QPen(QtGui.QColor(255, 80, 0)))
# else:
qp.setPen(QtGui.QPen(QtGui.QColor(192, 192, 192), 1, QtCore.Qt.SolidLine))
mnemonic = asm.get_name()
cemu.write(mnemonic)
# leave some spaces
cemu.write((MNEMONIC_WIDTH - len(mnemonic)) * ' ')
if asm.get_symbol():
qp.setPen(QtGui.QPen(QtGui.QColor(192, 192, 192), 1, QtCore.Qt.SolidLine))
cemu.write_c('[')
qp.setPen(QtGui.QPen(QtGui.QColor('yellow'), 1, QtCore.Qt.SolidLine))
cemu.write(asm.get_symbol())
qp.setPen(QtGui.QPen(QtGui.QColor(192, 192, 192), 1, QtCore.Qt.SolidLine))
cemu.write_c(']')
self._write_operands(asm, qp, cemu, offset)
self._write_comments(asm, qp, cemu, offset)
示例6: drawCursor
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import hex [as 別名]
def drawCursor(self, qp):
qp.setBrush(QtGui.QColor(255, 255, 0))
if self.isInEditMode():
qp.setBrush(QtGui.QColor(255, 102, 179))
cursorX, cursorY = self.cursor.getPosition()
columns = self.HexColumns[self.idxHexColumns]
if cursorX > columns:
self.cursor.moveAbsolute(columns - 1, cursorY)
# get cursor position again, maybe it was moved
cursorX, cursorY = self.cursor.getPosition()
qp.setOpacity(0.8)
if self.isInEditMode():
qp.setOpacity(0.5)
# cursor on text
qp.drawRect((self.COLUMNS * 3 + self.gap + cursorX) * self.fontWidth, cursorY * self.fontHeight + 2,
self.fontWidth, self.fontHeight)
# cursor on hex
if not self.isInEditMode():
qp.drawRect(cursorX * 3 * self.fontWidth, cursorY * self.fontHeight + 2, 2 * self.fontWidth,
self.fontHeight)
else:
if self.highpart:
qp.drawRect(cursorX * 3 * self.fontWidth, cursorY * self.fontHeight + 2, 1 * self.fontWidth,
self.fontHeight)
else:
qp.drawRect(cursorX * 3 * self.fontWidth + self.fontWidth, cursorY * self.fontHeight + 2,
1 * self.fontWidth, self.fontHeight)
qp.setOpacity(1)
示例7: setOffset
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import hex [as 別名]
def setOffset(self, offset):
self._offset = offset
self.setText(self.ID_OFFSET, hex(offset))
示例8: setSize
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import hex [as 別名]
def setSize(self, size):
self._size = size
self.setText(self.ID_SIZE, hex(size))
示例9: acquire
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import hex [as 別名]
def acquire(self):
""" Acquire control from libusb of the AlienFX controller."""
if self._control_taken:
return
self._dev = usb.core.find(
idVendor=self._controller.vendor_id,
idProduct=self._controller.product_id)
if (self._dev is None):
msg = "ERROR: No AlienFX USB controller found; tried "
msg += "VID {}".format(self._controller.vendor_id)
msg += ", PID {}".format(self._controller.product_id)
logging.error(msg)
try:
self._dev.detach_kernel_driver(0)
except USBError as exc:
logging.error(
"Cant detach kernel driver. Error : {}".format(exc.strerror))
try:
self._dev.set_configuration()
except USBError as exc:
logging.error(
"Cant set configuration. Error : {}".format(exc.strerror))
try:
usb.util.claim_interface(self._dev, 0)
except USBError as exc:
logging.error(
"Cant claim interface. Error : {}".format(exc.strerror))
self._control_taken = True
logging.debug("USB device acquired, VID={}, PID={}".format(
hex(self._controller.vendor_id), hex(self._controller.product_id)))
示例10: _unpack_colour_pair
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import hex [as 別名]
def _unpack_colour_pair(self, pkt):
""" Unpack two colour values from the given packet and return them as a
list of two tuples (each colour is a 3-member tuple)
TODO: This might need improvement for newer controllers...
"""
red1 = hex(pkt[0] >> 4)
green1 = hex(pkt[0] & 0xf)
blue1 = hex(pkt[1] >> 4)
red2 = hex(pkt[1] & 0xf)
green2 = hex(pkt[2] >> 4)
blue2 = hex(pkt[2] & 0xf)
return [(red1, green1, blue1), (red2, green2, blue2)]
示例11: _unpack_colour
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import hex [as 別名]
def _unpack_colour(self, pkt):
""" Unpack a colour value from the given packet and return it as a
3-member tuple
TODO: This too might need improvement for newer controllers
"""
red = hex(pkt[0] >> 4)
green = hex(pkt[0] & 0xf)
blue = hex(pkt[1] >> 4)
return (red, green, blue)
示例12: _parse_cmd_set_speed
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import hex [as 別名]
def _parse_cmd_set_speed(self, args):
""" Parse a packet containing the "set speed" command and
return it as a human readable string.
"""
pkt = args["pkt"]
return "SET_SPEED: {}".format(hex((pkt[2] << 8) + pkt[3]))
# @classmethod
示例13: collect
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import hex [as 別名]
def collect(self):
for session, wndsta, clip, handle in self.calculate():
# If no tagCLIP is provided, we do not know the format
if not clip:
fmt = obj.NoneObject("Format unknown")
else:
# Try to get the format name, but failing that, print
# the format number in hex instead.
if clip.fmt.v() in constants.CLIPBOARD_FORMAT_ENUM:
fmt = str(clip.fmt)
else:
fmt = hex(clip.fmt.v())
# Try to get the handle from tagCLIP first, but
# fall back to using _HANDLEENTRY.phead. Note: this can
# be a value like DUMMY_TEXT_HANDLE (1) etc.
handle_value = clip.hData or handle.phead.h
clip_data = ""
if handle and "TEXT" in fmt:
clip_data = handle.reference_object().as_string(fmt)
print(handle)
yield dict(session=session.SessionId,
window_station=wndsta.Name,
format=fmt,
handle=handle_value,
object=handle.phead.v(),
data=clip_data,
hexdump=handle.reference_object().as_hex())
示例14: render_row
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import hex [as 別名]
def render_row(self, item, **options):
return text.Cell(hex(item), align="r")
示例15: transform_dotted_decimal_to_mac
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import hex [as 別名]
def transform_dotted_decimal_to_mac(dotted_decimal_mac):
"""
Method to transform dotted decimals to Mac address
Args:
dotted_decimal_mac(string): dotted decimal string
Returns:
mac_address(string): Mac address separated by colon
"""
decimal_mac = dotted_decimal_mac.split(u'.')
hex_mac = u':'.join(str(hex(int(i)).lstrip(u'0x')).zfill(2) for i in decimal_mac).upper()
return hex_mac