From d64d4f2de392a709191301e5e53c8d4eeb42b133 Mon Sep 17 00:00:00 2001 From: fling Date: Wed, 29 Sep 2010 08:53:32 +0800 Subject: [PATCH] modified: ri_data.py --- interface/ri_data.py | 48 ++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/interface/ri_data.py b/interface/ri_data.py index 296dd9e..ee64be3 100644 --- a/interface/ri_data.py +++ b/interface/ri_data.py @@ -58,18 +58,20 @@ class Partition: ''' create a Partition instance from hardware info''' device_list=[] Partition.unit='GB' + p = re.compile(r"\s*") cmd_cat = 'cat /proc/partitions' + fs_list=["ext2","ext3","fat32","fat16","ntfs","reiserfs","xfs","jfs","linux-swap"] + st,o = commands.getstatusoutput(cmd_cat) if st: print "Error cat : command not found or /proc/partitions dosen't exsit" return - p = re.compile(r"\s*") for s in o.splitlines(): - ret = re.search(r".+([sh][a-zA-Z]+)\s*",s) - if ret: - if ret.group(1) in device_list: - continue - device_list.append(ret.group(1)) + ret = re.search(r".+([sh][a-zA-Z]+)\s*",s) + if ret: + if ret.group(1) in device_list: + continue + device_list.append(ret.group(1)) for d in device_list: st,o=commands.getstatusoutput('parted /dev/%s unit %s print'%(d,Partition.unit)) @@ -80,16 +82,28 @@ class Partition: ret = p.split(s) if ret[0]=='Partition': Partition.label=ret[-1] - if len(ret)>=5 and ret[0] == '': - # Not enough to prevent of ret - tmp =[] - ret=ret+['','',''] - for l in ret[7].split(","): - tmp.append(l.strip()) - if "raid" in tmp: - ret[7]="yes" - else: - ret[7]="no" + if len(ret) > 1 and ret[1].isdigit(): + # ret[0] is [''] + #Number start end size type file_system flags + # 1 2.0B 33GB 1GB primary raid + # 2 32GB 33GB 1GB primary raid, boot ... + # 3 32GB 33GB 1GB primary boot, raid, lbx ... + # 4 32GB 33GB 1GB primary exit2 raid + # 5 32GB 33GB 1GB primary exit2 raid, boot ... + # 6 3.2kB 33GB 1GB primary + # 7 32GB 33GB 1GB primary linx-swap + # 8 32GB 33GB 1GB primary boot, lbx ... + # 9 32GB 33GB 1GB primary exit2 boot + #ret[1] ret[2] ret[3] ret[4] ret[5] ret[6] ret[7] + ret+=['','',''] + if "raid" in ret[6:] or "raid," in ret[6:]: + ret[7]='yes' + if ret[6][:3].lower()=='raid' or ret[6].lower() not in fs_list: + ret[6]='' + else: + ret[7]='no' + if ret[6].lower() not in fs_list: + ret[6]='' Partition(d+ret[1],ret[2],ret[4],ret[5],ret[6][:10] == "linux-swap" and "swap" or ret[6] ,ret[7],'yes') @@ -338,7 +352,7 @@ class MountPoint: for r in Raid.list: if r.device not in devs and r.from_os == 'yes': f_s = [p.filesystem for p in Partition.list if p.device == r.active_components[0]] - MountPoint(r.device, fs=f_s[0],sz=r.size) + MountPoint(r.device, fs=''.join(f_s),sz=r.size) elif r.device not in devs: MountPoint(r.device,sz=r.size)