is ok everone
modified: di_dialog.py
This commit is contained in:
@@ -1,25 +1,27 @@
|
||||
import sys
|
||||
import re
|
||||
import commands
|
||||
import dialog
|
||||
|
||||
sys.path.append('../interface/')
|
||||
import ri_data
|
||||
|
||||
from xml.dom import minidom
|
||||
from xml.dom.ext import PrettyPrint
|
||||
#import ../interface/ri_data
|
||||
#d=dialog.Dialog()
|
||||
#d.setBackgroundTitle("Rocky 4.2 install")
|
||||
|
||||
|
||||
config_xml="../xml/config.xml"
|
||||
|
||||
class Dialog:
|
||||
dialog
|
||||
status=''
|
||||
dict={}
|
||||
def __init__(self,name='dialog',text='Rocky 4.2 install'):
|
||||
Dialog.dialog=dialog.Dialog()
|
||||
Dialog.dialog.setBackgroundTitle(text)
|
||||
Dialog.dict[name] = self
|
||||
|
||||
@staticmethod
|
||||
def message(string):
|
||||
Dialog.dialog.msgbox(text=string,height=10,width=30)
|
||||
|
||||
class Welcome(Dialog):
|
||||
def __init__(self,height=10,width=30,text='Welcome!\n\nThis script will guide you through the installation of RSS packages.\n\nIf you want to install the system, then please continue, else abort the installation and come back later.\n\nAre you really sure you want to continue?'):
|
||||
Dialog.__init__(self,name='welcome')
|
||||
@@ -28,7 +30,8 @@ class Welcome(Dialog):
|
||||
self.width=width
|
||||
|
||||
def get_welcome(self):
|
||||
Dialog.status=Dialog.dialog.yesno(self.text,self.height,self.width,title='welcome')
|
||||
s=Dialog.dialog.yesno(self.text,self.height,self.width,title='welcome')
|
||||
return s
|
||||
|
||||
class SerialNumber(Dialog):
|
||||
def __init__(self,height=10, width=30,text='plase input a serial number'):
|
||||
@@ -46,15 +49,14 @@ class SerialNumber(Dialog):
|
||||
class MountPoint(Dialog):
|
||||
fs=''
|
||||
dict={}
|
||||
def __init__(self,height=15,width=24,text='Please input the mounting point of your partition:'):
|
||||
def __init__(self,height=15,width=30,text='Please input the mounting point of your partition:'):
|
||||
Dialog.__init__(self,name='mountpoint')
|
||||
self.text=text
|
||||
self.height=height
|
||||
self.width=width
|
||||
|
||||
def set_fstype(self,device):
|
||||
#device is sdaX
|
||||
#mp is mount point
|
||||
|
||||
list=[('ext2','Ext2 is the traditional Linux file system.'),\
|
||||
('ext3','Ext3 is the journaling version of the Ext2 file system.'),\
|
||||
('reiserfs','ReiserFS is a journaling file system.'),\
|
||||
@@ -63,26 +65,31 @@ class MountPoint(Dialog):
|
||||
('swap','SWAP is a swap')]
|
||||
|
||||
# menu return "(status,choice)"
|
||||
s,fs= Dialog.dialog.menu(self.text,self.height,self.width,choices=list,title='mount point',default_item='ext3')
|
||||
if s == 0:
|
||||
ri_data.MountPoint.dict[device].filesystem=fs
|
||||
return s
|
||||
exit_info,string= Dialog.dialog.menu(self.text,self.height,self.width,choices=list,title='Mount Point',default_item='ext3')
|
||||
if exit_info == 0:
|
||||
ri_data.MountPoint.dict[device].filesystem=string
|
||||
|
||||
return exit_info
|
||||
|
||||
def set_mountpoint(self,device):
|
||||
s,mp=Dialog.dialog.inputbox(text='plase input mount point',height=10,width=30,init=ri_data.MountPoint.dict[device].directory)
|
||||
if s == 0:
|
||||
ri_data.MountPoint.dict[device].directory=mp
|
||||
return s
|
||||
code,string=Dialog.dialog.inputbox(text='Plase input mount point',height=10,width=30,init=ri_data.MountPoint.dict[device].directory,title='Mount point')
|
||||
if code == 0:
|
||||
ri_data.MountPoint.dict[device].directory=string
|
||||
else:
|
||||
ri_data.MountPoint.dict[device].directory=''
|
||||
|
||||
return code
|
||||
|
||||
def set_format(self,device):
|
||||
s = Dialog.dialog.yesno(text='format the device',title='Format')
|
||||
print s
|
||||
if s == 0 :
|
||||
n = Dialog.dialog.yesno(text='Format the devices',title='Format')
|
||||
|
||||
if n == 0 :
|
||||
ri_data.MountPoint.dict[device].format='yes'
|
||||
self.set_fstype(device)
|
||||
else:
|
||||
ri_data.MountPoint.dict[device].format='no'
|
||||
return s
|
||||
|
||||
return n
|
||||
|
||||
def set_data(self):
|
||||
while True:
|
||||
@@ -91,28 +98,30 @@ class MountPoint(Dialog):
|
||||
keys.sort()
|
||||
|
||||
for d in keys:
|
||||
list.append((ri_data.MountPoint.dict[d].device,ri_data.MountPoint.dict[d].directory.ljust(10)+ri_data.MountPoint.dict[d].filesystem.ljust(5)+ri_data.MountPoint.dict[d].format.ljust(5)+ri_data.Partition.dict[d].size+ri_data.Partition.unit))
|
||||
list.append((ri_data.MountPoint.dict[d].device,ri_data.MountPoint.dict[d].directory.ljust(10)+ri_data.MountPoint.dict[d].filesystem.ljust(10)+ri_data.MountPoint.dict[d].format.ljust(5)+ri_data.Partition.dict[d].size+ri_data.Partition.unit))
|
||||
|
||||
s,d=Dialog.dialog.menu(text='device map',height=self.height,width=self.width,menu_height=self.height/5*4,choices=list,title='MountPoint',ok_label='choice')
|
||||
exit_info,string=Dialog.dialog.menu(text="There are five columns in the mount point display frame.\n \
|
||||
Device Directory Filesystem Format Size",
|
||||
height=self.height,width=self.width,menu_height=len(list),
|
||||
choices=list,title='Mount',ok_label='choice')
|
||||
|
||||
if s == 0 :
|
||||
self.set_mountpoint(d)
|
||||
self.set_format(d)
|
||||
elif s == 1 :
|
||||
if exit_info == 0 :
|
||||
self.set_mountpoint(string)
|
||||
self.set_format(string)
|
||||
|
||||
if not ri_data.MountPoint.check_data(string, # device
|
||||
ri_data.MountPoint.dict[string].directory.rstrip('/'), # mountpoint
|
||||
ri_data.MountPoint.dict[string].filesystem): # filesystem
|
||||
ri_data.MountPoint.dict[string].directory = ''
|
||||
Dialog.message("The mount point couldn't be mounted on because it has been used or it's particular.")
|
||||
|
||||
elif exit_info == 1 :
|
||||
break
|
||||
else:
|
||||
print "error"
|
||||
return s
|
||||
return exit_info
|
||||
|
||||
class Network(Dialog):
|
||||
hostname='localhost'
|
||||
domain=''
|
||||
ip=''
|
||||
netmask=''
|
||||
gateway=''
|
||||
primary_dns=''
|
||||
secondary_dns=''
|
||||
configuration=''
|
||||
def __init__(self,height=10,width=30,text='Configure network'):
|
||||
Dialog.__init__(self,name='network')
|
||||
self.text=text
|
||||
@@ -120,44 +129,45 @@ class Network(Dialog):
|
||||
self.width=width
|
||||
|
||||
def set_hostname(self):
|
||||
s,hostname=Dialog.dialog.inputbox(text='input host name',height=self.height,width=self.width,init=ri_data.Network.hostname,title='hostname')
|
||||
if s == 0 :
|
||||
code,hostname=Dialog.dialog.inputbox(text='Plase input the hostname',height=self.height,width=self.width,
|
||||
init=ri_data.Network.hostname and ri_data.Network.hostname or 'localhost' ,title='Hostname')
|
||||
if code == 0 :
|
||||
ri_data.Network.hostname=hostname
|
||||
|
||||
return s
|
||||
return code
|
||||
|
||||
def set_domain(self):
|
||||
s,domain=Dialog.dialog.inputbox(text='input domain name',height=self.height,width=self.width,init=ri_data.Network.domain,title='doname name')
|
||||
if s == 0:
|
||||
code,domain=Dialog.dialog.inputbox(text='Plase input domain name',height=self.height,width=self.width,init=ri_data.Network.domain,title='doname name')
|
||||
if code == 0:
|
||||
ri_data.Network.domain=domain
|
||||
return s
|
||||
return code
|
||||
|
||||
def set_ip(self):
|
||||
s,ip=Dialog.dialog.inputbox(text='input ip',height=self.height,width=self.width,init=ri_data.Network.ip,title='ip')
|
||||
if s == 0:
|
||||
code,ip=Dialog.dialog.inputbox(text='Plase input ip address',height=self.height,width=self.width,init=ri_data.Network.ip,title='Ip')
|
||||
if code == 0:
|
||||
ri_data.Network.ip = ip
|
||||
return s
|
||||
return code
|
||||
|
||||
def set_netmask(self):
|
||||
s,mask=Dialog.dialog.inputbox(text='input net mask',height=self.height,width=self.width,init=ri_data.Network.mask,title='netmask')
|
||||
if s == 0:
|
||||
code,mask=Dialog.dialog.inputbox(text='Plase input net mask',height=self.height,width=self.width,init=ri_data.Network.mask,title='Netmask')
|
||||
if code == 0:
|
||||
ri_data.Network.mask = mask
|
||||
return s
|
||||
return code
|
||||
|
||||
def set_gateway(self):
|
||||
s,gateway=Dialog.dialog.inputbox(text='input gateway',height=self.height,width=self.width,init=ri_data.Network.gateway,title='gateway')
|
||||
if s == 0:
|
||||
code,gateway=Dialog.dialog.inputbox(text='Plase input gateway',height=self.height,width=self.width,init=ri_data.Network.gateway,title='Gateway')
|
||||
if code == 0:
|
||||
ri_data.Network.gateway = gateway
|
||||
return s
|
||||
return code
|
||||
|
||||
def set_primary_dns(self):
|
||||
s,primary_dns=Dialog.dialog.inputbox(text='input primary_dns',height=self.height,width=self.width,init=ri_data.Network.primary_dns,title='primary_dns')
|
||||
if s == 0:
|
||||
code,primary_dns=Dialog.dialog.inputbox(text='Plase input DNS',height=self.height,width=self.width,init=ri_data.Network.primary_dns,title='DNS')
|
||||
if code == 0:
|
||||
ri_data.Network.primary_dns = primary_dns
|
||||
return s
|
||||
return code
|
||||
|
||||
def set_data(self):
|
||||
s,ri_data.Network.configuration=Dialog.dialog.menu(text='choice a network',height=self.height,width=self.width,choices=[('static','static network'),('dynamic','d c cp ')],)
|
||||
s,ri_data.Network.configuration=Dialog.dialog.menu(text='choice a network',height=self.height,width=self.width,choices=[('static','static ip address'),('dynamic','Dynamic IP address')])
|
||||
if s == 0 and ri_data.Network.configuration == 'static':
|
||||
count=0
|
||||
list=[self.set_hostname,self.set_domain,self.set_ip,self.set_netmask,self.set_gateway,self.set_primary_dns]
|
||||
@@ -172,6 +182,7 @@ class Network(Dialog):
|
||||
break
|
||||
else:
|
||||
self.set_hostname()
|
||||
return s
|
||||
|
||||
class Group(Dialog):
|
||||
def __init__(self,height=10,width=50,text='install pkg'):
|
||||
@@ -186,7 +197,8 @@ class Group(Dialog):
|
||||
# l is ['pkg','no']
|
||||
list.append((l[0],'',l[1] == 'yes' and 'on' or 'off'))
|
||||
|
||||
s,check_list=Dialog.dialog.checklist(text='choice optional',height=self.height,width=self.width,list_height=self.height/5*4,choices=list,title='choices %s optional'%g)
|
||||
s,check_list=Dialog.dialog.checklist(text='Plase select the installation package',height=self.height,
|
||||
width=self.width,list_height=len(list),choices=list,title='choices %s optional'%g)
|
||||
|
||||
if s == 0 and check_list :
|
||||
if check_list[0] == 'check all':
|
||||
@@ -203,7 +215,8 @@ class Group(Dialog):
|
||||
for g in ri_data.Group.dict.keys():
|
||||
list.append((g,'',ri_data.Group.dict[g].install == 'mandatory' and 'on' or 'off'))
|
||||
|
||||
s,check_list=Dialog.dialog.checklist(text='choice group',height=self.height,width=self.width,list_height=self.height/5*4,default_item='check all',choices=list,title='choices gourp')
|
||||
s,check_list=Dialog.dialog.checklist(text='Plase select the installation Group',height=self.height,width=self.width,
|
||||
list_height=len(list),default_item='check all',choices=list,title='Package group')
|
||||
if s == 0 and check_list:
|
||||
if check_list[0] == 'check all':
|
||||
for g in ri_data.Group.dict.keys():
|
||||
@@ -240,15 +253,8 @@ class Service(Dialog):
|
||||
list=[('check all','','off')]
|
||||
for s in ri_data.Service.list:
|
||||
list.append((s.name,'','off'))
|
||||
# print '++++'
|
||||
# print 'name',s.name
|
||||
# print 'number',s.number
|
||||
# print 'script',s.script
|
||||
# print 'start',s.start
|
||||
# print 'package',s.package
|
||||
# print '++++++'
|
||||
|
||||
s,check_list=Dialog.dialog.checklist(text='running service',height=self.height,width=self.width,list_height=self.height/5*4,default_item='check all',choices=list,title='choices gourp')
|
||||
s,check_list=Dialog.dialog.checklist(text='running service',height=self.height,width=self.width,list_height=len(list),default_item='check all',choices=list,title='choices gourp')
|
||||
if s == 0 and check_list:
|
||||
if check_list[0] == 'check all':
|
||||
for s in ri_data.Service.list:
|
||||
@@ -268,42 +274,19 @@ class Service(Dialog):
|
||||
return s
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# check_list.append('vm')
|
||||
# for g in check_list:
|
||||
# print 'nmae:',ri_data.Group.dict[g].name
|
||||
# print 'install:',ri_data.Group.dict[g].install
|
||||
# print 'mandatory',ri_data.Group.dict[g].mandatory
|
||||
# print 'selection:',ri_data.Group.dict[g].selection
|
||||
# print 'optional:',ri_data.Group.dict[g].optional
|
||||
|
||||
|
||||
ri_data.init()
|
||||
|
||||
#ri_data.Partition.init_from_os()
|
||||
#ri_data.MountPoint.init_from_internal()
|
||||
#xmldoc_cfg = minidom.parse(config_xml)
|
||||
#root_cfg = xmldoc_cfg.firstChild
|
||||
#ri_data.Group.init_from_config_xml(root_cfg)
|
||||
|
||||
|
||||
#Welcome(15,50)
|
||||
Welcome(15,50)
|
||||
#Dialog.dict['welcome'].get_welcome()
|
||||
###
|
||||
#MountPoint(20,75)
|
||||
MountPoint(20,45)
|
||||
#Dialog.dict['mountpoint'].set_data()
|
||||
###
|
||||
#SerialNumber(10,50)
|
||||
SerialNumber(10,50)
|
||||
#Dialog.dict['serialnumber'].set_number()
|
||||
##
|
||||
#Network(10,50)
|
||||
Network(10,50)
|
||||
#Dialog.dict['network'].set_data()
|
||||
##
|
||||
#Group(20,50)
|
||||
Group(20,50)
|
||||
#Dialog.dict['group'].set_pkg()
|
||||
Service(15,50)
|
||||
Dialog.dict['service'].set_service()
|
||||
#Dialog.dict['service'].set_service()
|
||||
|
||||
ri_data.to_xml()
|
||||
|
||||
Reference in New Issue
Block a user