modify based on code inspection comments. - continue work in weekend.
This commit is contained in:
@@ -22,9 +22,7 @@ def mount_list_init():
|
||||
ri_data.MountPoint.init_from_internal()
|
||||
for d in ri_data.MountPoint.dict.keys().sort():
|
||||
# get size from Partition info
|
||||
sz = ri_data.Partition.get_size(d)
|
||||
if not sz:
|
||||
sz = ri_data.Raid.get_size(d)
|
||||
sz = MountPoint.get_size(d)
|
||||
m = ri_data.MountPoint.dict[d]
|
||||
s = m.device.ljust(10) + m.directory.ljust(10) + m.filesystem.ljust(10) + m.format.ljust(4) + sz.ljust(6)
|
||||
l.append(s)
|
||||
@@ -41,15 +39,16 @@ def mp_top_init():
|
||||
idxs = ml_win.curselection()
|
||||
if len(idxs) == 1:
|
||||
idx = int(idxs[0])
|
||||
mp = ri_data.MountPoint.list[idx]
|
||||
dev = mp.device
|
||||
dir = mp.directory
|
||||
l = eval(display.var_dict['mount.list'].get())
|
||||
dev = l[idx].split()[0]
|
||||
mp = ri_data.MountPoint.dict[dev]
|
||||
dr = mp.directory
|
||||
fs = mp.filesystem
|
||||
fm = mp.format
|
||||
sz = mp.size
|
||||
sz = MountPoint.get_size(dev)
|
||||
display.var_dict['mp_top_dev'].set(value=dev)
|
||||
display.var_dict['mp_top_size'].set(value=sz)
|
||||
display.var_dict['mp_top_dir'].set(value=dir)
|
||||
display.var_dict['mp_top_dir'].set(value=dr)
|
||||
if fm == 'yes':
|
||||
ri_widget.Widget.dict['mp_top_format'].tk_widget.select()
|
||||
else:
|
||||
@@ -66,24 +65,22 @@ 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()
|
||||
dr = 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()
|
||||
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)
|
||||
# if format, use the filesystem just set
|
||||
idx2 = int(idxs2[0])
|
||||
fs = eval(display.var_dict['mp_top_fs'].get())[idx2]
|
||||
else:
|
||||
# else use the filesystem in Partition
|
||||
fs = dev in Partition.dict.keys() and Partition.dict[dev].filesystem
|
||||
s2 = dev.ljust(10) + dr.ljust(10) + fs.ljust(10) + fm.ljust(4) + sz.ljust(6)
|
||||
l.append(s2)
|
||||
# make change in internal data structure
|
||||
ri_data.MountPoint.change(dev2, dir, fs, fm)
|
||||
ri_data.MountPoint.change(dev, dir, fs, fm)
|
||||
else:
|
||||
l.append(itm)
|
||||
|
||||
@@ -133,12 +130,12 @@ class GroupButton(object):
|
||||
dict={}
|
||||
def __init__(self, g):
|
||||
self.name = g.name
|
||||
self.win = display.SoftwarePackageWindow(g)
|
||||
GroupButton.dict[g.name] = self
|
||||
display.SoftwarePackageWindow(g)
|
||||
|
||||
|
||||
def __call__(self):
|
||||
print self.name
|
||||
display.SoftwarePackageWindow.dict[self.name].show()
|
||||
self.win.show()
|
||||
|
||||
class GroupCheck(GroupButton):
|
||||
''' A function class called whenever the group check button is checked '''
|
||||
@@ -191,10 +188,8 @@ def software_group_optional_quit():
|
||||
''' software group window quit, record optional group state '''
|
||||
opt = [ o for o in ri_data.Group.dict.values() if o.install != 'mandatory' ]
|
||||
for i in opt:
|
||||
print i.name
|
||||
vn = "software_group_%s" %(i.name)
|
||||
i.install = display.var_dict[vn].get()
|
||||
print i.name, i.install
|
||||
|
||||
def dependency_list_init():
|
||||
''' init function for list in dependency step '''
|
||||
@@ -261,13 +256,10 @@ def raid_raw_init():
|
||||
if not raid_raw_initialized:
|
||||
raid_raw_initialized = True
|
||||
# get all component devices already in raid
|
||||
dev_in_raid = set()
|
||||
for r in ri_data.Raid.list:
|
||||
dev_in_raid.update(r.active_components)
|
||||
dev_in_raid.update(r.spare_components)
|
||||
dev_in_raid = ri_data.Raid.dev_in_raid()
|
||||
|
||||
raw_devs = [ p.device for p in ri_data.Partition.list
|
||||
if p.flags=='yes' and p.device not in dev_in_raid ]
|
||||
raw_devs = [ d for d in ri_data.Partition.dict.keys()
|
||||
if re.search('raid', ri_data.Partition.dict[d].flags) and d not in dev_in_raid ]
|
||||
display.var_dict['raid_raw_devs'].set(value=tuple(raw_devs))
|
||||
|
||||
def list_to_list(list_from, var_from, var_to):
|
||||
@@ -308,38 +300,18 @@ def raid_device_init():
|
||||
raid_devs = [ r.device for r in ri_data.Raid.list ]
|
||||
display.var_dict['raid_devs'].set(value=tuple(raid_devs))
|
||||
|
||||
def raid_calc_size(level, devs):
|
||||
''' calculate raid device size
|
||||
level - raid level (0/1/5)
|
||||
devs - raid component devices
|
||||
'''
|
||||
# all devs shall have same size.
|
||||
unit=ri_data.Partition.unit
|
||||
sz=99999999999
|
||||
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 level == '0':
|
||||
sz=sz*len(devs)
|
||||
return "%d%s"%(sz,unit)
|
||||
elif level == '1':
|
||||
return "%d%s"%(sz,unit)
|
||||
elif level == '5':
|
||||
sz=sz*(len(devs)-1)
|
||||
return "%d%s"%(sz,unit)
|
||||
|
||||
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
|
||||
else:
|
||||
try:
|
||||
active = list(eval(display.var_dict['raid_active_devs'].get()))
|
||||
if display.var_dict['raid_spare_devs'].get()=='':
|
||||
spare=[]
|
||||
else:
|
||||
except:
|
||||
active = []
|
||||
|
||||
try:
|
||||
spare = list(eval(display.var_dict['raid_spare_devs'].get()))
|
||||
except:
|
||||
spare = []
|
||||
|
||||
level = display.var_dict['raid_level'].get()
|
||||
|
||||
if not active or not level:
|
||||
@@ -347,7 +319,7 @@ def raid_device_add():
|
||||
return
|
||||
|
||||
dev = ri_data.Raid.get_next_device()
|
||||
ri_data.Raid(dev, "no", level, raid_calc_size(level, active), active, spare)
|
||||
ri_data.Raid(dev, "no", level, active, spare)
|
||||
raid_device_init()
|
||||
display.var_dict['raid_active_devs'].set(value='')
|
||||
display.var_dict['raid_spare_devs'].set(value='')
|
||||
@@ -361,25 +333,30 @@ def raid_device_delete():
|
||||
idxs = win_dev.curselection()
|
||||
if len(idxs) == 1:
|
||||
idx = int(idxs[0])
|
||||
r = ri_data.Raid.list[idx]
|
||||
try:
|
||||
l = eval(display.var_dict['raid_devs'].get())
|
||||
except:
|
||||
# a null string?
|
||||
return
|
||||
dev = l[idx].split()[0]
|
||||
r = ri_data.Raid.dict[dev]
|
||||
if r.from_os == 'yes':
|
||||
ri_widget.MessageBox.dict["raid_delete_warning"].show()
|
||||
return
|
||||
if display.var_dict['raid_active_devs'].get() == '':
|
||||
active=[]
|
||||
else:
|
||||
try:
|
||||
active = list(eval(display.var_dict['raid_active_devs'].get()))
|
||||
if display.var_dict['raid_spare_devs'].get()=='':
|
||||
spare=[]
|
||||
else:
|
||||
except:
|
||||
active=[]
|
||||
try:
|
||||
spare = list(eval(display.var_dict['raid_spare_devs'].get()))
|
||||
|
||||
except:
|
||||
spare=[]
|
||||
active.extend(r.active_components)
|
||||
spare.extend(r.spare_components)
|
||||
# do not touch level
|
||||
display.var_dict['raid_active_devs'].set(value=tuple(active))
|
||||
display.var_dict['raid_spare_devs'].set(value=tuple(spare))
|
||||
del ri_data.Raid.list[idx]
|
||||
del ri_data.Raid.dict[dev]
|
||||
raid_device_init()
|
||||
|
||||
def raid_device_list_detail(*args):
|
||||
@@ -388,7 +365,13 @@ def raid_device_list_detail(*args):
|
||||
idxs = win.curselection()
|
||||
if len(idxs) == 1:
|
||||
idx = int(idxs[0])
|
||||
r = ri_data.Raid.list[idx]
|
||||
try:
|
||||
l = eval(display.var_dict['raid_devs'].get())
|
||||
except:
|
||||
# a null string?
|
||||
return
|
||||
dev = l[idx].split()[0]
|
||||
r = ri_data.Raid.dict[dev]
|
||||
display.var_dict['raid_detail_active'].set(value='active: %s' %(str(r.active_components)))
|
||||
display.var_dict['raid_detail_spare'].set(value='spare: %s' %(str(r.spare_components)))
|
||||
display.var_dict['raid_detail_level'].set(value='level: %s' %(str(r.level)))
|
||||
|
||||
Reference in New Issue
Block a user