From d64d4f2de392a709191301e5e53c8d4eeb42b133 Mon Sep 17 00:00:00 2001 From: fling Date: Wed, 29 Sep 2010 08:53:32 +0800 Subject: [PATCH 1/5] 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) From 19b32bca435075b92ea925aa4514fa0d79aa531c Mon Sep 17 00:00:00 2001 From: fling Date: Thu, 30 Sep 2010 08:44:29 +0800 Subject: [PATCH 2/5] modified: ri_tk_cmd.py bug : Not formatted, should not change filesystem of hard disk partition --- interface/ri_tk_cmd.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/interface/ri_tk_cmd.py b/interface/ri_tk_cmd.py index ea9d4ce..73c8097 100644 --- a/interface/ri_tk_cmd.py +++ b/interface/ri_tk_cmd.py @@ -64,17 +64,20 @@ def mp_top_ok(): for itm in eval(display.var_dict['mount.list'].get()): dev = itm.split()[0] dev2 = display.var_dict['mp_top_dev'].get() + base_fs='' if dev == dev2: sz = display.var_dict['mp_top_size'].get() dir = display.var_dict['mp_top_dir'].get() fm = display.var_dict['mp_top_format'].get() idxs2 = ri_widget.Widget.dict['mp_top_fs'].tk_widget.curselection() - if len(idxs2): - idx2 = int(idxs2[0]) - fs = eval(display.var_dict['mp_top_fs'].get())[idx2] - else: - fs = '' - + for m in ri_data.Partition.list: + if m.device == dev2: + base_fs = m.filesystem + if len(idxs2) and fm =='yes' : + idx2 = int(idxs2[0]) + fs = eval(display.var_dict['mp_top_fs'].get())[idx2] + elif fm=='no': + fs = base_fs s2 = dev.ljust(10) + dir.ljust(10) + fs.ljust(10) + fm.ljust(4) + sz.ljust(6) l.append(s2) # make change in internal data structure From ef4a024ab3bf198cbccf2b04c674549f739c5850 Mon Sep 17 00:00:00 2001 From: fling Date: Thu, 30 Sep 2010 09:45:34 +0800 Subject: [PATCH 3/5] modified: mkraid_wrapper.sh add success information --- operation/mkraid_wrapper.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/operation/mkraid_wrapper.sh b/operation/mkraid_wrapper.sh index 3c55faa..dd034fa 100755 --- a/operation/mkraid_wrapper.sh +++ b/operation/mkraid_wrapper.sh @@ -17,12 +17,13 @@ # # This file is a wrapper to mkraid.sh. - while read line do - $(dirname $0)/mkraid.sh "$line" - ret=$? - if [ $ret -ne 0 ];then - exit $ret - fi + $(dirname $0)/mkraid.sh "$line" + ret=$? + if [ $ret -ne 0 ];then + exit $ret + else + echo "@ make raid is success" + fi done From a90555da07eb3be1ba73ee424d8eaf482cfc1f38 Mon Sep 17 00:00:00 2001 From: fling Date: Thu, 30 Sep 2010 09:50:12 +0800 Subject: [PATCH 4/5] aend --- operation/mkraid_wrapper.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/operation/mkraid_wrapper.sh b/operation/mkraid_wrapper.sh index dd034fa..78aa353 100755 --- a/operation/mkraid_wrapper.sh +++ b/operation/mkraid_wrapper.sh @@ -19,11 +19,11 @@ # This file is a wrapper to mkraid.sh. while read line do - $(dirname $0)/mkraid.sh "$line" - ret=$? - if [ $ret -ne 0 ];then - exit $ret + $(dirname $0)/mkraid.sh "$line" + ret=$? + if [ $ret -ne 0 ];then + exit $ret else echo "@ make raid is success" - fi + fi done From c2903ad9a2548f503077423e6e94ef37732054bf Mon Sep 17 00:00:00 2001 From: fling Date: Thu, 30 Sep 2010 11:35:23 +0800 Subject: [PATCH 5/5] modified: ../xml/interface.xml add main.help Text --- xml/interface.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/interface.xml b/xml/interface.xml index 40dacf2..37cefb4 100644 --- a/xml/interface.xml +++ b/xml/interface.xml @@ -42,7 +42,7 @@ row 4 | quit previous next | - +