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


Python builtins.hex方法代码示例

本文整理汇总了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))) 
开发者ID:trackmastersteve,项目名称:alienfx,代码行数:18,代码来源:usbdriver.py

示例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 
开发者ID:google,项目名称:rekall,代码行数:21,代码来源:apihooks.py

示例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)))) 
开发者ID:aerospike,项目名称:aerospike-admin,代码行数:24,代码来源:ssl_context.py

示例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 
开发者ID:NervanaSystems,项目名称:neon,代码行数:22,代码来源:backend.py

示例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) 
开发者ID:amimo,项目名称:dcc,代码行数:39,代码来源:DisasmViewMode.py

示例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) 
开发者ID:amimo,项目名称:dcc,代码行数:36,代码来源:HexViewMode.py

示例7: setOffset

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import hex [as 别名]
def setOffset(self, offset):
        self._offset = offset
        self.setText(self.ID_OFFSET, hex(offset)) 
开发者ID:amimo,项目名称:dcc,代码行数:5,代码来源:HexViewMode.py

示例8: setSize

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import hex [as 别名]
def setSize(self, size):
        self._size = size
        self.setText(self.ID_SIZE, hex(size)) 
开发者ID:amimo,项目名称:dcc,代码行数:5,代码来源:HexViewMode.py

示例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))) 
开发者ID:trackmastersteve,项目名称:alienfx,代码行数:32,代码来源:usbdriver.py

示例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)] 
开发者ID:trackmastersteve,项目名称:alienfx,代码行数:15,代码来源:cmdpacket.py

示例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) 
开发者ID:trackmastersteve,项目名称:alienfx,代码行数:12,代码来源:cmdpacket.py

示例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 
开发者ID:trackmastersteve,项目名称:alienfx,代码行数:10,代码来源:cmdpacket.py

示例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()) 
开发者ID:google,项目名称:rekall,代码行数:33,代码来源:clipboard.py

示例14: render_row

# 需要导入模块: import builtins [as 别名]
# 或者: from builtins import hex [as 别名]
def render_row(self, item, **options):
        return text.Cell(hex(item), align="r") 
开发者ID:google,项目名称:rekall,代码行数:4,代码来源:base_objects.py

示例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 
开发者ID:yahoo,项目名称:panoptes,代码行数:14,代码来源:helpers.py


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