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


Python SCSI.inquiry方法代码示例

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


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

示例1: main

# 需要导入模块: from pyscsi.pyscsi.scsi import SCSI [as 别名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import inquiry [as 别名]
def main():
    i = 1
    page_code = 0
    evpd = 0
    while i < len(sys.argv):
        if sys.argv[i] == '--help':
            return usage()
        if sys.argv[i] == '-p':
            del sys.argv[i]
            page_code = int(sys.argv[i], 16)
            evpd = 1
            del sys.argv[i]
            continue
        i += 1

    if len(sys.argv) < 2:
        return usage()

    device = sys.argv[1]

    sd = SCSIDevice(device)
    s = SCSI(sd)

    i = s.testunitready()

    if not evpd:
        inquiry_standard(s)
        return

    if page_code == INQUIRY.VPD.SUPPORTED_VPD_PAGES:
        inquiry_supported_vpd_pages(s)
        return

    if page_code == INQUIRY.VPD.BLOCK_LIMITS:
        inquiry_block_limits(s)
        return

    if page_code == INQUIRY.VPD.BLOCK_DEVICE_CHARACTERISTICS:
        inquiry_block_dev_char(s)
        return

    if page_code == INQUIRY.VPD.LOGICAL_BLOCK_PROVISIONING:
        inquiry_logical_block_prov(s)
        return

    if page_code == INQUIRY.VPD.UNIT_SERIAL_NUMBER:
        inquiry_unit_serial_number(s)
        return

    if page_code == INQUIRY.VPD.DEVICE_IDENTIFICATION:
        inquiry_device_identification(s)
        return

    print 'No pretty print for this page, page_code=0x%02x' % page_code
    print '=============================================\n'
    i = s.inquiry(evpd=1, page_code=page_code).result
    for k, v in i.iteritems():
        print '%s - %s' % (k, v)
开发者ID:c-r-h,项目名称:python-scsi,代码行数:60,代码来源:inquiry.py

示例2: main

# 需要导入模块: from pyscsi.pyscsi.scsi import SCSI [as 别名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import inquiry [as 别名]
def main():
    device = ''
    for i in range(len(sys.argv)):
        if sys.argv[i] == '-f':
            del sys.argv[i]
            device = sys.argv[i]
            del sys.argv[i]
            break

    if not device:
        usage()
        exit(1)

    scsi = SCSI(SCSIDevice(device))
    i = scsi.inquiry().result
    if i['peripheral_device_type'] != INQUIRY.DEVICE_TYPE.MEDIA_CHANGER_DEVICE:
        print '%s is not a MediaChanger device' % device
        exit(1)

    eaa = scsi.modesense6(page_code=MODESENSE6.PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT).result['mode_pages'][0]

    # get the data transfer elements
    dte = scsi.readelementstatus(
        start=eaa['first_data_transfer_element_address'],
        num=eaa['num_data_transfer_elements'],
        element_type=READELEMENTSTATUS.ELEMENT_TYPE.DATA_TRANSFER,
        voltag=1, curdata=1, dvcid=1,
        alloclen=16384).result['element_status_pages'][0]['element_descriptors']

    # get all the storage elements
    se = scsi.readelementstatus(
        start=eaa['first_storage_element_address'],
        num=eaa['num_storage_elements'],
        element_type=READELEMENTSTATUS.ELEMENT_TYPE.STORAGE,
        voltag=1, curdata=1, dvcid=1,
        alloclen=16384).result['element_status_pages'][0]['element_descriptors']

    # get all the medium transport elements
    mte = scsi.readelementstatus(
        start=eaa['first_medium_transport_element_address'],
        num=eaa['num_medium_transport_elements'],
        element_type=READELEMENTSTATUS.ELEMENT_TYPE.MEDIUM_TRANSPORT,
        voltag=1, curdata=1, dvcid=1,
        alloclen=16384).result['element_status_pages'][0]['element_descriptors']

    if sys.argv[1] == 'status':
        return status(scsi, dte, se)

    if sys.argv[1] == 'load':
        return load(scsi, mte, dte, se, int(sys.argv[2]), int(sys.argv[3]))

    if sys.argv[1] == 'unload':
        return unload(scsi, mte, dte, se, int(sys.argv[2]), int(sys.argv[3]))

    usage()
    exit(1)
开发者ID:c-r-h,项目名称:python-scsi,代码行数:58,代码来源:mtx.py

示例3: main

# 需要导入模块: from pyscsi.pyscsi.scsi import SCSI [as 别名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import inquiry [as 别名]
def main():
    dev = MockInquiry()
    dev.opcodes = spc
    s = SCSI(dev)

    # cdb for standard page request
    i = s.inquiry(alloclen=128)
    cdb = i.cdb
    assert cdb[0] == s.device.opcodes.INQUIRY.value
    assert cdb[1:3] == bytearray(2)
    assert scsi_ba_to_int(cdb[3:5]) == 128
    assert cdb[5] == 0
    cdb = i.unmarshall_cdb(cdb)
    assert cdb['opcode'] == s.device.opcodes.INQUIRY.value
    assert cdb['evpd'] == 0
    assert cdb['page_code'] == 0
    assert cdb['alloc_len'] == 128

    d = Inquiry.unmarshall_cdb(Inquiry.marshall_cdb(cdb))
    assert d == cdb

    # supported vpd pages
    i = s.inquiry(evpd=1, page_code=0x88, alloclen=300)
    cdb = i.cdb
    assert cdb[0] == s.device.opcodes.INQUIRY.value
    assert cdb[1] == 0x01
    assert cdb[2] == 0x88
    assert scsi_ba_to_int(cdb[3:5]) == 300
    assert cdb[5] == 0
    cdb = i.unmarshall_cdb(cdb)
    assert cdb['opcode'] == s.device.opcodes.INQUIRY.value
    assert cdb['evpd'] == 1
    assert cdb['page_code'] == 0x88
    assert cdb['alloc_len'] == 300

    d = Inquiry.unmarshall_cdb(Inquiry.marshall_cdb(cdb))
    assert d == cdb
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:39,代码来源:test_cdb_inquiry.py

示例4: main

# 需要导入模块: from pyscsi.pyscsi.scsi import SCSI [as 别名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import inquiry [as 别名]
def main():
    dev = MockInquiryStandard()
    dev.opcodes = sbc
    s = SCSI(dev)
    i = s.inquiry().result
    assert i['peripheral_qualifier'] == 1
    assert i['peripheral_device_type'] == 5
    assert i['rmb'] == 1
    assert i['version'] == 7
    assert i['normaca'] == 1
    assert i['hisup'] == 0
    assert i['response_data_format'] == 3
    assert i['additional_length'] == 64
    assert i['sccs'] == 1
    assert i['acc'] == 0
    assert i['tpgs'] == 3
    assert i['3pc'] == 1
    assert i['protect'] == 1
    assert i['encserv'] == 1
    assert i['vs'] == 1
    assert i['multip'] == 1
    assert i['addr16'] == 1
    assert i['wbus16'] == 1
    assert i['sync'] == 1
    assert i['cmdque'] == 1
    assert i['vs2'] == 1
    assert i['clocking'] == 2
    assert i['qas'] == 0
    assert i['ius'] == 1
    assert i['t10_vendor_identification'].decode("utf-8") == 'abcdefgh'
    assert i['product_identification'].decode("utf-8") == 'iiiiiiiijjjjjjjj'
    assert i['product_revision_level'].decode("utf-8") == 'revn'

    d = Inquiry.unmarshall_datain(Inquiry.marshall_datain(i))
    assert d == i

    dev = MockLBP()
    dev.opcodes = sbc
    s = SCSI(dev)
    i = s.inquiry(evpd=1, page_code=INQUIRY.VPD.LOGICAL_BLOCK_PROVISIONING).result
    assert i['peripheral_qualifier'] == 0
    assert i['peripheral_qualifier'] == 0
    assert i['threshold_exponent'] == 0x12
    assert i['lbpu'] == 1
    assert i['lpbws'] == 1
    assert i['lbpws10'] == 1
    assert i['lbprz'] == 1
    assert i['anc_sup'] == 1
    assert i['dp'] == 1
    assert i['provisioning_type'] == INQUIRY.PROVISIONING_TYPE.THIN_PROVISIONED

    d = Inquiry.unmarshall_datain(Inquiry.marshall_datain(i), evpd=1)
    assert d == i

    dev = MockUSN()
    dev.opcodes = sbc
    s = SCSI(dev)
    i = s.inquiry(evpd=1, page_code=INQUIRY.VPD.UNIT_SERIAL_NUMBER).result
    assert i['peripheral_qualifier'] == 0
    assert i['peripheral_qualifier'] == 0
    assert i['unit_serial_number'].decode("utf-8") == "ABCD"

    d = Inquiry.unmarshall_datain(Inquiry.marshall_datain(i), evpd=1)
    assert d == i

    dev = MockReferrals()
    dev.opcodes = sbc
    s = SCSI(dev)
    i = s.inquiry(evpd=1, page_code=INQUIRY.VPD.REFERRALS).result
    assert i['peripheral_qualifier'] == 0
    assert i['peripheral_qualifier'] == 0
    assert i['user_data_segment_size'] == 23
    assert i['user_data_segment_multiplier'] == 37

    d = Inquiry.unmarshall_datain(Inquiry.marshall_datain(i), evpd=1)
    assert d == i

    dev = MockExtendedInquiry()
    dev.opcodes = sbc
    s = SCSI(dev)
    i = s.inquiry(evpd=1, page_code=INQUIRY.VPD.EXTENDED_INQUIRY_DATA).result
    assert i['peripheral_qualifier'] == 0
    assert i['peripheral_qualifier'] == 0
    assert i['activate_microcode'] == 1
    assert i['spt'] == 2
    assert i['grd_chk'] == 1
    assert i['app_chk'] == 1
    assert i['ref_chk'] == 1
    assert i['uask_sup'] == 1
    assert i['group_sup'] == 1
    assert i['prior_sup'] == 0
    assert i['headsup'] == 0
    assert i['ordsup'] == 1
    assert i['simpsup'] == 1
    assert i['wu_sup'] == 0
    assert i['crd_sup'] == 1
    assert i['nv_sup'] == 0
    assert i['v_sup'] == 1
    assert i['p_i_i_sup'] == 1
    assert i['luiclr'] == 1
#.........这里部分代码省略.........
开发者ID:Katana-Steel,项目名称:python-scsi,代码行数:103,代码来源:test_unmarshall_inquiry.py

示例5: __init__

# 需要导入模块: from pyscsi.pyscsi.scsi import SCSI [as 别名]
# 或者: from pyscsi.pyscsi.scsi.SCSI import inquiry [as 别名]
class Device:
    def __init__(self, device):
        if not device:
            raise exceptions.CommandLineError(
                '--device parameter is required, should point to the disk '
                'device representing the meter.')

        self.device_name_ = device
        self.scsi_device_ = SCSIDevice(device, readwrite=True)
        self.scsi_ = SCSI(self.scsi_device_)
        self.scsi_.blocksize = _REGISTER_SIZE

    def connect(self):
        inq = self.scsi_.inquiry()
        logging.debug('Device connected: %r', inq.result)
        vendor = inq.result['t10_vendor_identification'][:32]
        if vendor != b'LifeScan':
            raise exceptions.ConnectionFailed(
                'Device %s is not a LifeScan glucometer.' % self.device_name_)

    def disconnect(self):  # pylint: disable=no-self-use
        return

    def _send_request(self, lba, request_format, request_obj, response_format):
        """Send a request to the meter, and read its response.

        Args:
          lba: (int) the address of the block register to use, known
            valid addresses are 3, 4 and 5.
          request_format: a construct format identifier of the request to send
          request_obj: the object to format with the provided identifier
          response_format: a construct format identifier to parse the returned
            message with.

        Returns:
          The Container object parsed from the response received by the meter.

        Raises:
          lifescan.MalformedCommand if Construct fails to build the request or
            parse the response.

        """
        try:
            request = request_format.build(request_obj)
            request_raw = _PACKET.build({'data': {'value': {
                'message': request,
            }}})
            logging.debug(
                'Request sent: %s', binascii.hexlify(request_raw))
            self.scsi_.write10(lba, 1, request_raw)

            response_raw = self.scsi_.read10(lba, 1)
            logging.debug(
                'Response received: %s', binascii.hexlify(response_raw.datain))
            response_pkt = _PACKET.parse(response_raw.datain).data
            logging.debug('Response packet: %r', response_pkt)

            response = response_format.parse(response_pkt.value.message)
            logging.debug('Response parsed: %r', response)

            return response
        except construct.ConstructError as e:
            raise lifescan.MalformedCommand(str(e))

    def _query_string(self, selector):
        response = self._send_request(
            3, _QUERY_REQUEST, {'selector': selector}, _QUERY_RESPONSE)

        return response.value

    def get_meter_info(self):
        return common.MeterInfo(
            'OneTouch %s glucometer' % self._query_string('model'),
            serial_number=self.get_serial_number(),
            version_info=(
                'Software version: ' + self.get_version(),),
            native_unit=self.get_glucose_unit())

    def get_serial_number(self):
        return self._query_string('serial')

    def get_version(self):
        return self._query_string('software')

    def get_datetime(self):
        response = self._send_request(
            3, _READ_RTC_REQUEST, None, _READ_RTC_RESPONSE)
        return response.timestamp

    def set_datetime(self, date=datetime.datetime.now()):
        self._send_request(
            3, _WRITE_RTC_REQUEST, {'timestamp': date},
            _COMMAND_SUCCESS)

        # The device does not return the new datetime, so confirm by calling
        # READ RTC again.
        return self.get_datetime()

    def zero_log(self):
        self._send_request(
#.........这里部分代码省略.........
开发者ID:Flameeyes,项目名称:glucometerutils,代码行数:103,代码来源:otverio2015.py


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