change image file location in interface.xml, and change python file to use relative file location for it.
203 lines
7.3 KiB
Python
203 lines
7.3 KiB
Python
#!/usr/bin/python
|
|
''' handle gui button related commands.'''
|
|
|
|
import ri_tk as display
|
|
import ri_widget
|
|
import ri_data
|
|
|
|
import re
|
|
import copy
|
|
import sys
|
|
|
|
def quit():
|
|
''' correspond to quit button '''
|
|
# maybe a quit in current widget, so call widget.hide()
|
|
# get current widget, call its quit()
|
|
q, t = ri_widget.Sequence.current()
|
|
ri_widget.Widget.dict[t].hide()
|
|
display.quit()
|
|
ri_data.to_xml()
|
|
|
|
def previous():
|
|
''' correspond to previous button '''
|
|
q, t = ri_widget.Sequence.current()
|
|
wid_name = ri_widget.Sequence.previous()
|
|
if wid_name is not None:
|
|
ri_widget.Widget.dict[t].hide()
|
|
|
|
ri_widget.Widget.dict[wid_name].show()
|
|
else:
|
|
ri_widget.MessageBox.dict["previous"].show()
|
|
|
|
def next():
|
|
''' correspond to next button '''
|
|
q, t = ri_widget.Sequence.current()
|
|
wid_name = ri_widget.Sequence.next()
|
|
if wid_name is not None:
|
|
ri_widget.Widget.dict[t].hide()
|
|
|
|
ri_widget.Widget.dict[wid_name].show()
|
|
else:
|
|
ri_widget.MessageBox.dict["next"].show()
|
|
|
|
def serial_no_init():
|
|
display.var_dict['serial_no.number'].set(value=ri_data.SerialNumber.value)
|
|
|
|
def serial_no_quit():
|
|
ri_data.SerialNumber.value = display.var_dict['serial_no.number'].get()
|
|
|
|
|
|
def mount_list_init():
|
|
''' initialize mount list '''
|
|
l = []
|
|
for m in ri_data.MountPoint.list:
|
|
# get size from Partition info
|
|
sz = ri_data.Partition.get_size(m.device)
|
|
if not sz:
|
|
sz = ri_data.Raid.get_size(m.device)
|
|
print m.device, m.directory, m.filesystem, m.format, sz
|
|
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]))
|
|
|
|
def mount_list_modify(*args):
|
|
''' modify an item in mount list '''
|
|
tw = ri_widget.TopWindow.dict['mount_list_modify']
|
|
tw.show()
|
|
|
|
def mp_top_init():
|
|
''' mount dir top window initialize '''
|
|
ml_win = ri_widget.Widget.dict['mount.list'].tk_widget
|
|
idxs = ml_win.curselection()
|
|
if len(idxs) == 1:
|
|
idx = int(idxs[0])
|
|
mp = ri_data.MountPoint.list[idx]
|
|
dev = mp.device
|
|
dir = mp.directory
|
|
fs = mp.filesystem
|
|
fm = mp.format
|
|
sz = mp.size
|
|
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)
|
|
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 = itm.split()[0]
|
|
dev2 = display.var_dict['mp_top_dev'].get()
|
|
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 = ''
|
|
|
|
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
|
|
ri_data.MountPoint.change(dev2, dir, fs, fm)
|
|
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 and ri_data.Network.configuration or 'static')].tk_widget.invoke()
|
|
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()
|
|
|
|
def ncm_dynamic():
|
|
''' when radio button ncm dynamic is checked, several data entry will be set 'disable' '''
|
|
|
|
for n in ('network_domain_name','network_ip','network_subnet_mask','network_gateway','network_primary_dns','network_secondary_dns'):
|
|
ri_widget.Widget.dict[n].tk_widget.configure(state='disable')
|
|
|
|
def ncm_static():
|
|
''' when radio button ncm static is checked, several data entry will be set 'normal' '''
|
|
for n in ('network_domain_name','network_ip','network_subnet_mask','network_gateway','network_primary_dns','network_secondary_dns'):
|
|
ri_widget.Widget.dict[n].tk_widget.configure(state='normal')
|
|
|
|
class GroupCheck(object):
|
|
''' A function class called whenever the group checkbox is clicked '''
|
|
dict={}
|
|
def __init__(self, n):
|
|
self.name = n
|
|
GroupCheck.dict[n] = self
|
|
|
|
def __call__(self):
|
|
print self.name
|
|
display.SoftwarePackageWindow.dict[self.name].show()
|
|
|
|
def software_group_construct(w):
|
|
''' draw group information on, based on actual data
|
|
w - Widget instance '''
|
|
for g in ri_data.Group.dict.values():
|
|
display.SoftwarePackageWindow(g)
|
|
|
|
mdt = [ m for m in ri_data.Group.dict.values() if m.install == 'mandatory' ]
|
|
opt = [ o for o in ri_data.Group.dict.values() if o.install != 'mandatory' ]
|
|
|
|
wit = w.widgets.pop()
|
|
for i in mdt:
|
|
wi = copy.deepcopy(wit)
|
|
wi.attr['text'] = i.name
|
|
vn = "software_group_%s" %(i.name)
|
|
wi.attr['variable'] = vn
|
|
wi.variables = [(vn, 'StringVar', ''),]
|
|
idx = mdt.index(i)
|
|
wi.grid_location.dict['column'] = idx % int(w.grid_management.columns)
|
|
wi.grid_location.dict['row'] = idx / int(w.grid_management.columns)
|
|
gc = GroupCheck(i.name)
|
|
setattr(sys.modules[__name__], vn, gc)
|
|
wi.attr['command'] = vn
|
|
w.add_sub_widget(wi)
|
|
|
|
def software_group_init():
|
|
pass
|
|
|
|
def software_group_quit():
|
|
pass
|
|
|
|
def software_group_item():
|
|
pass
|
|
|
|
|