add top-window on mount list,
add network frame contents, init function, quit function.
This commit is contained in:
@@ -46,7 +46,9 @@ def mount_list_init():
|
||||
''' initialize mount list '''
|
||||
l = []
|
||||
for m in ri_data.MountPoint.list:
|
||||
s = m.device.ljust(10) + m.directory.ljust(20) + m.filesystem.ljust(10)
|
||||
# get size from Partition info
|
||||
sz = ri_data.Partition.get_size(m.device)
|
||||
s = m.device.ljust(10) + m.directory.ljust(10) + m.filesystem.ljust(10) + m.format.ljust(4) + sz.ljust(6)
|
||||
l.append(s)
|
||||
display.var_dict['mount.list'].set(value=tuple([str(i) for i in l]))
|
||||
|
||||
@@ -56,16 +58,17 @@ def mount_list_quit():
|
||||
if not s: return
|
||||
tpl = eval(s)
|
||||
for i in range(len(tpl)):
|
||||
dev, dir, fs = tpl[i].split()
|
||||
ri_data.MountPoint.list[i].directory = dir
|
||||
dev, dir, fs, fm, sz= tpl[i].split()
|
||||
ri_data.MountPoint.list[i].directory = dir
|
||||
ri_data.MountPoint.list[i].filesystem = fs
|
||||
ri_data.MountPoint.list[i].format = fm
|
||||
|
||||
def mount_list_modify(*args):
|
||||
''' modify an item in mount list '''
|
||||
tw = ri_widget.TopWindow.dict['mount_list_modify']
|
||||
tw.show()
|
||||
|
||||
def mp_top_fs_init():
|
||||
def mp_top_init():
|
||||
''' mount dir top window initialize '''
|
||||
ml_win = ri_widget.Widget.dict['mount.list'].tk_widget
|
||||
idxs = ml_win.curselection()
|
||||
@@ -74,6 +77,66 @@ def mp_top_fs_init():
|
||||
s = display.var_dict['mount.list'].get()
|
||||
if not s: return
|
||||
tpl = eval(s)
|
||||
dev, dir, fs = tpl[idx].split()
|
||||
print dev, dir, fs
|
||||
dev, dir, fs, fm, sz = tpl[idx].split()
|
||||
display.var_dict['mp_top_dev'].set(value=dev)
|
||||
display.var_dict['mp_top_dir'].set(value=dir)
|
||||
if fm == 'yes':
|
||||
ri_widget.Widget.dict['mp_top_format'].tk_widget.select()
|
||||
else:
|
||||
ri_widget.Widget.dict['mp_top_not_format'].tk_widget.select()
|
||||
|
||||
fs_values = eval(display.var_dict['mp_top_fs'].get())
|
||||
for i in range(len(fs_values)):
|
||||
if fs == fs_values[i]:
|
||||
ri_widget.Widget.dict['mp_top_fs'].tk_widget.selection_set(i)
|
||||
|
||||
def mp_top_ok():
|
||||
''' mount dir top window OK '''
|
||||
l = []
|
||||
for itm in eval(display.var_dict['mount.list'].get()):
|
||||
dev, dir, fs, fm, sz = itm.split()
|
||||
dev2 = display.var_dict['mp_top_dev'].get()
|
||||
if dev == dev2:
|
||||
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()
|
||||
idx2 = int(idxs2[0])
|
||||
fs = eval(display.var_dict['mp_top_fs'].get())[idx2]
|
||||
|
||||
s2 = dev.ljust(10) + dir.ljust(10) + fs.ljust(10) + fm.ljust(4) + sz.ljust(6)
|
||||
l.append(s2)
|
||||
else:
|
||||
l.append(itm)
|
||||
|
||||
display.var_dict['mount.list'].set(value=tuple(l))
|
||||
ri_widget.TopWindow.dict['mount_list_modify'].hide()
|
||||
|
||||
def mp_top_cancel():
|
||||
''' mount dir top window cancel '''
|
||||
ri_widget.TopWindow.dict['mount_list_modify'].hide()
|
||||
pass
|
||||
|
||||
def network_init():
|
||||
''' network initialize '''
|
||||
display.var_dict['network_host_name']. set(value=ri_data.Network.hostname)
|
||||
ri_widget.Widget.dict['network_config_%s' %(ri_data.Network.configuration,)].tk_widget.select()
|
||||
display.var_dict['network_domain_name']. set(value=ri_data.Network.domain)
|
||||
display.var_dict['network_ip']. set(value=ri_data.Network.ip)
|
||||
display.var_dict['network_subnet_mask']. set(value=ri_data.Network.mask)
|
||||
display.var_dict['network_gateway']. set(value=ri_data.Network.gateway)
|
||||
display.var_dict['network_primary_dns']. set(value=ri_data.Network.primary_dns)
|
||||
display.var_dict['network_secondary_dns'].set(value=ri_data.Network.secondary_dns)
|
||||
|
||||
def network_quit():
|
||||
''' network quit '''
|
||||
ri_data.Network.hostname = display.var_dict['network_host_name'].get()
|
||||
ri_data.Network.configuration = display.var_dict['network_config_method'].get()
|
||||
ri_data.Network.domain = display.var_dict['network_domain_name'].get()
|
||||
ri_data.Network.ip = display.var_dict['network_ip'].get()
|
||||
ri_data.Network.mask = display.var_dict['network_subnet_mask'].get()
|
||||
ri_data.Network.gateway = display.var_dict['network_gateway'].get()
|
||||
ri_data.Network.primary_dns = display.var_dict['network_primary_dns'].get()
|
||||
ri_data.Network.secondary_dns = display.var_dict['network_secondary_dns'].get()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ class Partition:
|
||||
def init_from_os():
|
||||
''' create a Partition instance from hardware info'''
|
||||
# cmd = 'sfdisk -d'
|
||||
# has problem on raid detection
|
||||
cmd = 'cat /home/zhi/work/new_install/python/mine/sfdisk.txt'
|
||||
st, o = commands.getstatusoutput(cmd)
|
||||
if st:
|
||||
@@ -109,6 +110,12 @@ p_node - xml node (parent node)'''
|
||||
pt.setAttributeNode(id_attr)
|
||||
pts.appendChild(pt)
|
||||
p_node.appendChild(pts)
|
||||
|
||||
@staticmethod
|
||||
def get_size(dev):
|
||||
for p in Partition.list:
|
||||
if p.device == dev:
|
||||
return p.size
|
||||
|
||||
class Raid:
|
||||
''' raid information '''
|
||||
@@ -187,10 +194,11 @@ p_node - xml node (parent node) '''
|
||||
class MountPoint:
|
||||
''' mount-points '''
|
||||
list=[]
|
||||
def __init__(self, dev, dir, fs):
|
||||
self.device = dev
|
||||
self.directory = dir
|
||||
def __init__(self, dev, dir='', fs='', fm='no'):
|
||||
self.device = dev
|
||||
self.directory = dir
|
||||
self.filesystem = fs
|
||||
self.format = fm
|
||||
MountPoint.list.append(self)
|
||||
|
||||
@staticmethod
|
||||
@@ -205,7 +213,7 @@ class MountPoint:
|
||||
devs.append(r.raid_device)
|
||||
|
||||
for dev in devs:
|
||||
MountPoint(dev, '', '')
|
||||
MountPoint(dev)
|
||||
|
||||
@staticmethod
|
||||
def init_from_xml(node):
|
||||
@@ -214,7 +222,8 @@ class MountPoint:
|
||||
if m.nodeType == node.ELEMENT_NODE and m.nodeName == 'mount-point':
|
||||
MountPoint(m.attributes['device'].value.encode('ascii'), \
|
||||
m.attributes['directory'].value.encode('ascii'), \
|
||||
m.attributes['file-system'].value.encode('ascii'))
|
||||
m.attributes['file-system'].value.encode('ascii'), \
|
||||
m.attributes['format'].value.encode('ascii') )
|
||||
|
||||
@staticmethod
|
||||
def to_xml(doc, p_node):
|
||||
@@ -227,12 +236,15 @@ p_node - xml node (parent node)'''
|
||||
dev_attr = doc.createAttribute('device')
|
||||
dir_attr = doc.createAttribute('directory')
|
||||
fs_attr = doc.createAttribute('file-system')
|
||||
fm_attr = doc.createAttribute('format')
|
||||
dev_attr.value = m.device
|
||||
dir_attr.value = m.directory
|
||||
fs_attr.value = m.filesystem
|
||||
fm_attr.value = m.format
|
||||
mp.setAttributeNode(dev_attr)
|
||||
mp.setAttributeNode(dir_attr)
|
||||
mp.setAttributeNode(fs_attr)
|
||||
mp.setAttributeNode(fm_attr)
|
||||
mps.appendChild(mp)
|
||||
p_node.appendChild(mps)
|
||||
|
||||
@@ -240,12 +252,12 @@ class Network:
|
||||
''' network '''
|
||||
hostname =''
|
||||
configuration =''
|
||||
domain = ''
|
||||
ip = ''
|
||||
mask = ''
|
||||
gateway = ''
|
||||
primary_dns = ''
|
||||
secondary_dns = ''
|
||||
domain = ''
|
||||
|
||||
@staticmethod
|
||||
def init_from_xml(node):
|
||||
|
||||
@@ -68,10 +68,6 @@ def create_widget_sub(w, p_win):
|
||||
# if not yet in dict, create it
|
||||
var_dict[v_n] = getattr(Tkinter, v_t)(value=v_v)
|
||||
|
||||
# process action init
|
||||
if 'action' in dir(w) and 'init' in w.action.dict:
|
||||
getattr(sys.modules['ri_cmd'], w.action.dict['init'])()
|
||||
|
||||
# change attr, if needed to suit tk
|
||||
tk_attr = dict(w.attr)
|
||||
modify_attributes(tk_attr)
|
||||
@@ -115,6 +111,11 @@ def create_widget_sub(w, p_win):
|
||||
|
||||
# save tk widget instance into w (widget instance)
|
||||
setattr(w, 'tk_widget', w_win)
|
||||
|
||||
# process action init
|
||||
if 'action' in dir(w) and 'init' in w.action.dict:
|
||||
getattr(sys.modules['ri_cmd'], w.action.dict['init'])()
|
||||
|
||||
return w_win
|
||||
|
||||
# When creating widget, I have to create each sub widget.
|
||||
@@ -176,3 +177,7 @@ w - TopWindow instance '''
|
||||
w_win.wait_window()
|
||||
|
||||
return w_win
|
||||
|
||||
def destroy_top_window(w):
|
||||
''' w - Toplevel instance '''
|
||||
w.tk_widget.destroy()
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
</raid>
|
||||
</raids>
|
||||
<mount-points>
|
||||
<mount-point device='/dev/hdb1' directory='/' file-system='ext3' format='yes'/>
|
||||
<mount-point device='/dev/hdb5' directory='/usr' file-system='ext2' format='no'/>
|
||||
<mount-point device='/dev/hda1' directory='/' file-system='ext3' format='yes'/>
|
||||
<mount-point device='/dev/hda5' directory='/usr' file-system='reiserfs' format='no'/>
|
||||
</mount-points>
|
||||
<network domain='in.linx' secondary_dns='' ip='192.168.1.25' hostname='localhost' mask='255.255.255.0' primary_dns='192.168.1.254' configuration='static' gateway='192.168.1.254'/>
|
||||
<groups>
|
||||
|
||||
@@ -274,6 +274,7 @@ row 4 | |
|
||||
<configure column='2' weight='1'/>
|
||||
</grid_management>
|
||||
<grid_location row='2' column='0' columnspan='3' sticky='NSWE'/>
|
||||
<action init='network_init'/>
|
||||
|
||||
<widget type='Text'>
|
||||
<widget_attribute width='40' height='15' state='disabled'/>
|
||||
@@ -286,29 +287,120 @@ row 4 | |
|
||||
<configure row='1' weight='1'/>
|
||||
<configure row='2' weight='1'/>
|
||||
</grid_management>
|
||||
<grid_location row='0' column='1' columnspan='2'/>
|
||||
<grid_location row='0' column='1' sticky='W'/>
|
||||
<variable name='network_config_method' type='StringVar'/>
|
||||
|
||||
<widget type='Label'>
|
||||
<widget_attribute text='host name'/>
|
||||
<grid_location row='0' column='0' sticky='W'/>
|
||||
</widget>
|
||||
|
||||
<widget type='Entry'>
|
||||
<widget_attribute width='12'/>
|
||||
<widget_attribute width='12' textvariable='network_host_name'/>
|
||||
<grid_location row='0' column='1' sticky='W'/>
|
||||
<variable name='network_host_name' type='StringVar'/>
|
||||
</widget>
|
||||
|
||||
<widget type='Label'>
|
||||
<widget_attribute text='#NCM'/>
|
||||
<grid_location row='1' column='0'/>
|
||||
<grid_location row='1' column='0' rowspan='2' sticky='W'/>
|
||||
</widget>
|
||||
|
||||
<widget type='Radiobutton' name='network_config_dynamic'>
|
||||
<widget_attribute text='dynamic' variable='network_config_method' value='dynamic'/>
|
||||
<grid_location row='1' column='1' sticky='W'/>
|
||||
</widget>
|
||||
|
||||
<widget type='Radiobutton' name='network_config_static'>
|
||||
<widget_attribute text='static' variable='network_config_method' value='static' />
|
||||
<grid_location row='2' column='1' sticky='W'/>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget type='Frame'>
|
||||
<grid_location row='0' column='2'/>
|
||||
|
||||
<widget type='Label'>
|
||||
<widget_attribute text='Domain name'/>
|
||||
<grid_location row='0' column='0'/>
|
||||
</widget>
|
||||
<widget type='Entry'>
|
||||
<widget_attribute width='16' textvariable='network_domain_name'/>
|
||||
<grid_location row='0' column='1' pady='2'/>
|
||||
<variable name='network_domain_name' type='StringVar'/>
|
||||
</widget>
|
||||
|
||||
<widget type='Label'>
|
||||
<widget_attribute text='IP'/>
|
||||
<grid_location row='1' column='0'/>
|
||||
</widget>
|
||||
<widget type='Entry'>
|
||||
<widget_attribute width='16' textvariable='network_ip'/>
|
||||
<grid_location row='1' column='1' pady='2'/>
|
||||
<variable name='network_ip' type='StringVar'/>
|
||||
</widget>
|
||||
|
||||
<widget type='Label'>
|
||||
<widget_attribute text='Subnet mask'/>
|
||||
<grid_location row='2' column='0'/>
|
||||
</widget>
|
||||
<widget type='Entry'>
|
||||
<widget_attribute width='16' textvariable='network_subnet_mask'/>
|
||||
<grid_location row='2' column='1' pady='2'/>
|
||||
<variable name='network_subnet_mask' type='StringVar'/>
|
||||
</widget>
|
||||
|
||||
<widget type='Label'>
|
||||
<widget_attribute text='Gateway'/>
|
||||
<grid_location row='3' column='0'/>
|
||||
</widget>
|
||||
<widget type='Entry'>
|
||||
<widget_attribute width='16' textvariable='network_gateway'/>
|
||||
<grid_location row='3' column='1' pady='2'/>
|
||||
<variable name='network_gateway' type='StringVar'/>
|
||||
</widget>
|
||||
|
||||
<widget type='Label'>
|
||||
<widget_attribute text='Primary DNS'/>
|
||||
<grid_location row='4' column='0'/>
|
||||
</widget>
|
||||
<widget type='Entry'>
|
||||
<widget_attribute width='16' textvariable='network_primary_dns'/>
|
||||
<grid_location row='4' column='1' pady='2'/>
|
||||
<variable name='network_primary_dns' type='StringVar'/>
|
||||
</widget>
|
||||
|
||||
<widget type='Label'>
|
||||
<widget_attribute text='Secondary DNS'/>
|
||||
<grid_location row='5' column='0'/>
|
||||
</widget>
|
||||
<widget type='Entry'>
|
||||
<widget_attribute width='16' textvariable='network_secondary_dns'/>
|
||||
<grid_location row='5' column='1' pady='2'/>
|
||||
<variable name='network_secondary_dns' type='StringVar'/>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<message_box name='previous' type='info' title='#install-sequence' message='#first-step'/>
|
||||
<message_box name='next' type='info' title='#install-sequence' message='#last-step'/>
|
||||
|
||||
<!--
|
||||
column 0 column 1
|
||||
________________________________________________
|
||||
row 0 | Device /dev/xxx |
|
||||
| _____________ |
|
||||
row 1 | Directory |_____________| |
|
||||
| _ _ |
|
||||
row 2 | |_| Format |_| Not-Format |
|
||||
| ___________________ |
|
||||
row 3 | | | |
|
||||
| filesystem | | |
|
||||
| | | |
|
||||
| |___________________| |
|
||||
| |
|
||||
row 4 | OK Cancel |
|
||||
|________________________________________________|
|
||||
-->
|
||||
<top_window name='mount_list_modify'>
|
||||
<grid_management rows='1' columns='1'>
|
||||
<configure row='0' weight='1'/>
|
||||
@@ -318,6 +410,7 @@ row 4 | |
|
||||
<widget type='Frame'>
|
||||
<grid_location row='0' column='0'/>
|
||||
<variable name='mp_top_format' type='StringVar'/>
|
||||
<action init='mp_top_init'/>
|
||||
<widget type='Label'>
|
||||
<widget_attribute text='Device'/>
|
||||
<grid_location row='0' column='0' padx='10' sticky='W'/>
|
||||
@@ -336,23 +429,30 @@ row 4 | |
|
||||
<grid_location row='1' column='1' sticky='W'/>
|
||||
<variable name='mp_top_dir' type='StringVar'/>
|
||||
</widget>
|
||||
<widget type='Radiobutton'>
|
||||
<widget_attribute text='Format' variable='mp_top_format' value='format'/>
|
||||
<widget type='Radiobutton' name='mp_top_format'>
|
||||
<widget_attribute text='Format' variable='mp_top_format' value='yes'/>
|
||||
<grid_location row='2' column='0'/>
|
||||
</widget>
|
||||
<widget type='Radiobutton'>
|
||||
<widget_attribute text='Not-Format' variable='mp_top_format' value='not-format'/>
|
||||
<widget type='Radiobutton' name='mp_top_not_format'>
|
||||
<widget_attribute text='Not-Format' variable='mp_top_format' value='no'/>
|
||||
<grid_location row='2' column='1'/>
|
||||
</widget>
|
||||
<widget type='Label'>
|
||||
<widget_attribute text='Filesystem'/>
|
||||
<grid_location row='3' column='0' sticky='W'/>
|
||||
</widget>
|
||||
<widget type='Listbox'>
|
||||
<widget type='Listbox' name='mp_top_fs'>
|
||||
<widget_attribute listvariable='mp_top_fs'/>
|
||||
<grid_location row='3' column='1' sticky='W'/>
|
||||
<variable name='mp_top_fs' type='StringVar' value='ext2 ext3 reiserfs xfs jfs'/>
|
||||
<action init='mp_top_fs_init' quit='mp_top_fs_quit'/>
|
||||
</widget>
|
||||
<widget type='Button'>
|
||||
<widget_attribute text='OK' command='mp_top_ok'/>
|
||||
<grid_location row='4' column='0'/>
|
||||
</widget>
|
||||
<widget type='Button'>
|
||||
<widget_attribute text='Cancel' command='mp_top_cancel'/>
|
||||
<grid_location row='4' column='1'/>
|
||||
</widget>
|
||||
</widget>
|
||||
</top_window>
|
||||
|
||||
Reference in New Issue
Block a user