Exemplo n.º 1
0
def write_to_dev(device, s_path):
    if not os.path.exists(s_path):
        raise Exception('source path %s does not found!' % s_path)

    block_dev = BlockDevice(device)
    block_dev.check_id_mbr()
    try:
        data = open(s_path, 'rb').read()
    except IOError:
        raise IOError('Can not read from "%s"' % s_path)
    block_dev.int_write(data)
Exemplo n.º 2
0
def write_to_dev(device, s_path):
    if not os.path.exists(s_path):
        raise Exception('source path %s does not found!'%s_path)

    block_dev = BlockDevice(device)
    block_dev.check_id_mbr()
    try:
        data = open(s_path, 'rb').read()
    except IOError:
        raise IOError('Can not read from "%s"'%s_path)
    block_dev.int_write(data)
Exemplo n.º 3
0
def read_from_dev(device, d_path):
    try:
        fd = open(d_path, 'wb')
    except IOError:
        raise Exception('permission denied to %s!' % d_path)
    try:
        block_dev = BlockDevice(device)
        block_dev.check_id_mbr()
        data = block_dev.int_read()
        fd.write(data)
    finally:
        fd.close()
Exemplo n.º 4
0
def read_from_dev(device, d_path):
    try:
        fd = open(d_path, 'wb')
    except IOError:
        raise Exception('permission denied to %s!'%d_path)
    try:
        block_dev = BlockDevice(device)
        block_dev.check_id_mbr()
        data = block_dev.int_read()
        fd.write(data)
    finally:
        fd.close()