From fb83d4b5100ed94435dd911fba82bc423bf17c35 Mon Sep 17 00:00:00 2001 From: fling Date: Thu, 14 Oct 2010 15:05:40 +0800 Subject: [PATCH] modified: ri_tk_cmd.py add two showwarning messagebox for active devices that must be more than two --- interface/ri_tk_cmd.py | 19 +++++++++++++------ xml/interface.xml | 26 +++++++++++++++++--------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/interface/ri_tk_cmd.py b/interface/ri_tk_cmd.py index e9ae652..9e25d0d 100644 --- a/interface/ri_tk_cmd.py +++ b/interface/ri_tk_cmd.py @@ -22,9 +22,9 @@ def mount_list_init(): devs=ri_data.Raid.dev_in_raid() ri_data.MountPoint.init_from_internal() for m in ri_data.MountPoint.list: - # get size from Partition info if m.device in devs: continue + # get size from Partition info sz = ri_data.Partition.get_size(m.device) if not sz: sz = ri_data.Raid.get_size(m.device) @@ -313,11 +313,11 @@ devs - raid component devices ''' # all devs shall have same size. unit=ri_data.Partition.unit - sz=99999999999 + sz=999999999 for p in ri_data.Partition.list: if p.device in devs: - if float(p.size[:-len(unit)])< float(sz): - sz = float(p.size[:-len(unit)]) + if float(p.size)< float(sz): + sz = float(p.size) if level == '0': sz=sz*len(devs) return str(sz) @@ -330,19 +330,26 @@ devs - raid component devices def raid_device_add(): ''' add a new raid device ''' if display.var_dict['raid_active_devs'].get()=='': - ri_widget.MessageBox.dict["raid_add_active_warning"].show() - return + active=[] else: active = list(eval(display.var_dict['raid_active_devs'].get())) + if display.var_dict['raid_spare_devs'].get()=='': spare=[] else: spare = list(eval(display.var_dict['raid_spare_devs'].get())) + level = display.var_dict['raid_level'].get() if not active or not level: ri_widget.MessageBox.dict["raid_add_warning"].show() return + elif int(level) < 2 and len(active) < 2: + ri_widget.MessageBox.dict["raid_add_active_numbers"].show() + return + elif str(level) == "5" and len(active)<3: + ri_widget.MessageBox.dict["raid_add_active_2numbers"].show() + return dev = ri_data.Raid.get_next_device() ri_data.Raid(dev, "no", level, raid_calc_size(level, active), active, spare) diff --git a/xml/interface.xml b/xml/interface.xml index dc03a81..33c6bfb 100644 --- a/xml/interface.xml +++ b/xml/interface.xml @@ -727,7 +727,8 @@ row 4 | | - + +