Beispiel #1
0
def do_test_unit_ready(sg_device):
    from infi.asi.cdb.tur import TestUnitReadyCommand
    try:
        cdb = TestUnitReadyCommand()
        return do_scsi_cdb(sg_device, cdb)
    except ScsiCheckConditionError as error:
        (key, code) = (error.sense_key, error.code_name)
        if key in ('NOT_READY', "ILLEGAL_REQUEST"):
            return False
        raise
    except AsiReservationConflictError:
        return True
Beispiel #2
0
import sys
from infi.asi import create_platform_command_executer
from infi.asi.cdb.tur import TestUnitReadyCommand
from infi.asi.coroutines.sync_adapter import sync_wait
from infi.asi import create_os_file
from infi.exceptools import print_exc

if len(sys.argv) != 2:
    sys.stderr.write("usage: %s device_name\n" % sys.argv[0])
    sys.exit(1)

path = sys.argv[1]

f = create_os_file(path)

try:

    executer = create_platform_command_executer(f)
    tur = TestUnitReadyCommand()
    data = sync_wait(tur.execute(executer))

    print(data)

    f.close()
except:
    print_exc()