1. 程式人生 > >PYTHON代碼:根據位圖間的關系,連接IBM V7000的8G BS位圖

PYTHON代碼:根據位圖間的關系,連接IBM V7000的8G BS位圖

v7000

import sqlite3
import struct
cx_m = sqlite3.connect("F:\\zy\\map\\map_v2.db")
cu_m = cx_m.cursor()
BS = 256 * 1024 * 1024
bs = 256 * 1024
sDisk = []
sDisk.append("")
sDisk.append("")
sDisk.append("")
sDisk.append("")
sDisk.append(["h:\mdisk4.img", 0])
sDisk.append(["g:\mdisk5.img", 0])
sDisk.append(["i:\mdisk6.img", 0])
sDisk.append(["d:\mdisk7.img", 0])
sDisk.append(["e:\mdisk8.img", 0])
sDisk.append(["f:\mdisk9.img", 0])
for disk in sDisk[4:10]:
    disk[1] = open(disk[0], ‘rb‘)
tlist = list()
curNo,curDid,curBS =0,4,800
tlist.append([curNo,curDid,curBS])
pEnd = 0
while True:
    pos = curBS * BS + 512 * 1024
    f = sDisk[curDid][1]
    f.seek(pos)
    d = f.read(bs)
    v = struct.unpack_from("Q",d,bs -8 - pEnd * 8)[0]
    if v == 0:
        break
    if curBS == 13333 or curBS == 21088 :
        vj = 160
    elif curBS == 22588 or (curBS == 3861 and curDid == 7):
        vj = 1600
    elif curBS == 26044:
        v = 39160914945
    elif curBS == 6834 and curDid == 8:
        v = 55357308929
    elif curBS == 6866 and curDid == 8:
        v = 55407631873
    elif curBS == 10472 and curDid == 9:
        v = 54081059329
    else:
        vj = 16
    v1 = v-vj*512
    v2 = v+vj*512
    #print("v1,v2:",v1,v2)
    cu_m.execute(r"select * from map_info where v_num > %d and v_num < %d and MAP_ITEM_POS < 5"%(v1,v2))
    rows = cu_m.fetchall()
    isbreak = False
    if len(rows) == 0:
        if pEnd < 7:
            pEnd += 1
            continue;
        else:
            print("len is 0:CurDid,CurBS is break", curDid, curBS)
            #print(tlist)
            pEnd = 0
            break;
    elif len(rows) > 1:
        t1,t2 = rows[0][0],rows[0][1]
        #print("t1,t2 is",t1,t2)
        for row1 in rows:
            if t1 != row1[0] or t2 != row1[1]:
                print("len >1,t1,t2,row[0],row[1] is",t1,t2,row1[0],row1[1])
                isbreak = True
                break;
    if isbreak:
        print("CurDid,CurBS is break", curDid, curBS)
#        print(tlist)
        break;
    else:
        pEnd = 0
    curNo += 1
    curDid = rows[0][0]
    curBS = rows[0][1]
    #if curDid== 9 and curBS== 7471:
    #    break
    tlist.append([curNo,curDid,curBS])
   # if curBS == 18511 and curDid == 8:
    #    break
print("the list num is",len(tlist))
print(tlist)
f1 = open("f:\\zy\\8gLIST.TXT",‘w+‘)
for i in tlist:
    f1.write("%d\t%d\t%d\n"%(i[0],i[1],i[2]))


PYTHON代碼:根據位圖間的關系,連接IBM V7000的8G BS位圖