modified: ri_oper.py

update error info
This commit is contained in:
fling
2010-10-15 14:39:01 +08:00
parent 212f213a09
commit ac34d88e6c

View File

@@ -50,7 +50,7 @@ class Operation:
total is 100, if this operations is completed, 5% work is done.
and the following methods:
get_arguments - prepare arguments for scipt
get_arguments - prepare arguments for script
get_stdin - prepare stdin for script
install - install progress '''
@@ -58,10 +58,10 @@ class Operation:
''' Operation(base class) init method
return_value is a dict, key is return code, value is a tuple, first
element is English, second element is Chinese.'''
self.return_value = {0:('success', u'成功'), \
1:('argument error',u'参数错误'), \
2:('deivce node do not exist',u'设备节点不存在'),\
3:('filesystem no implement',u'文件系统没有实现'),\
self.return_value = {0:('Success', u'成功'), \
1:('Argument error',u'参数错误'), \
2:("Deivce node doesn't exist",u"设备节点不存在"),\
3:("File system hasn't been implemented",u'文件系统没有实现'),\
}
self.english_name = e
self.chinese_name = c
@@ -103,8 +103,8 @@ class Operation:
class Format(Operation):
''' class for format partition '''
def __init__(self, scr):
Operation.__init__(self, 'format partition', u'格式化分区', 'format_partition.sh', scr)
self.return_value[127] = ('format partition utils not found', u'没有格式化硬盘功能')
Operation.__init__(self, 'Format partition', u'格式化分区', 'format_partition.sh', scr)
self.return_value[127] = ('No tool to format partitions', u'没有格式化硬盘分区的工具')
def get_stdin(self):
format=''
@@ -119,7 +119,7 @@ class Format(Operation):
class MakeRaid(Operation):
"""class for make raid"""
def __init__(self,scr):
Operation.__init__(self,"make RAID",u"正在制作RAID磁盘阵列","mkraid_wrapper.sh",scr)
Operation.__init__(self,"Making a RAID", u"正在制作RAID磁盘阵列", "mkraid_wrapper.sh", scr)
def get_stdin(self):
args = ''
n = 0
@@ -135,7 +135,7 @@ class MakeRaid(Operation):
class MakeRaidConfigure(Operation):
"""class for make raid configure"""
def __init__(self,scr):
Operation.__init__(self,"make raid configure file",u"配置raid配置文件","mkraidconf.sh",scr)
Operation.__init__(self,"Generate /etc/mdadm.conf",u"生成raid配置文件","mkraidconf.sh",scr)
def install(self):
if ri_data.Raid.list:
return Operation.install(self)
@@ -150,7 +150,7 @@ class MakeRaidConfigure(Operation):
class Mount(Operation):
"""class for mount partition"""
def __init__(self,scr):
Operation.__init__(self,'mount partition',u'挂载分区','mount_partition.sh',scr)
Operation.__init__(self, 'Mount partition', u'挂载分区', 'mount_partition.sh',scr)
def get_stdin(self):
mount=''
@@ -165,9 +165,9 @@ class Mount(Operation):
class InstallPkg(Operation):
"""class for install packages"""
def __init__(self,scr):
Operation.__init__(self,'install packages',u'安装软件包','install_pkg.sh',scr)
self.return_value[2]=("source directory pkg_source_dir doesn't exist",u"软件包所在目录不存在")
self.return_value[3]=("package in source doesn't exist",u"软件包不存在")
Operation.__init__(self,'Install packages',u'安装软件包','install_pkg.sh',scr)
self.return_value[2]=("Software source directory doesn't exist",u"软件包所在目录不存在")
self.return_value[3]=("Software package doesn't exist",u"软件包不存在")
def get_stdin(self):
pkgname=[]
@@ -190,13 +190,13 @@ class InstallPkg(Operation):
class ConfigureFstab(Mount):
"""class for configure /etc/fstab"""
def __init__(self,scr):
Operation.__init__(self,'configure fstab',u'配置/etc/fstab文件','configure_fstab.sh',scr)
self.return_value[2]=("fstab doesn't exist",u"/etc/fstab文件不存在")
Operation.__init__(self,'Configure /etc/fstab',u'配置/etc/fstab文件','configure_fstab.sh',scr)
self.return_value[2]=("/etc/fstab doesn't exist",u"/etc/fstab文件不存在")
class GenerateIssue(Operation):
"""class for generate /etc/issue"""
def __init__(self,scr):
Operation.__init__(self,'generate issue',u'生成/etc/issue文件','generate_issue.sh',scr)
Operation.__init__(self,'Generate /etc/issue',u'生成/etc/issue文件','generate_issue.sh',scr)
def get_arguments(self):
args=[]
@@ -212,9 +212,11 @@ class GenerateIssue(Operation):
class ConfigureNetwork(Operation):
"""class for configure network"""
def __init__(self,scr):
Operation.__init__(self,'configure network',u'配置网络','configure_network.sh',scr)
self.return_value[2]=("ip or netmask or geteway address incorrect",u"ip或子网掩码网关不正确")
self.return_value[3]=("hosts/resolv.conf/ifcfg-eth0/network doesn't exist",u"文件hosts、resolv.conf、ifcfg-eht0、network 不存在")
Operation.__init__(self,'Configure network',u'配置网络','configure_network.sh',scr)
self.return_value[2]=("Ip address, network, or geteway is incorrect",u"Ip地址、子网掩码网关不正确")
self.return_value[3]=("/etc/hosts, /etc/resolv.conf, /etc/sysconfig/network-devices/ifcfg.template, or /etc/sysconfig/network doesn't exist",\
u"文件/etc/hosts,/etc/resolv.conf,/etc/sysconfig/network-devices/ifcfg.template或/etc/sysconfig/network文件不存在")
def get_arguments(self):
network=''
@@ -244,8 +246,8 @@ class ConfigureNetwork(Operation):
class MakeServiceAutoBoot(Operation):
"""class for make service autoboot"""
def __init__(self,scr):
Operation.__init__(self,"make service autoboot",u"启动服务器","mk_serv_autoboot.sh",scr)
self.return_value[2]=("boot script doesn't exist",u"引导脚本不存在")
Operation.__init__(self,"Make service autoboot",u"启动服务器","mk_serv_autoboot.sh",scr)
self.return_value[2]=("Boot script doesn't exist",u"引导脚本不存在")
def get_stdin(self):
serv=''
@@ -260,23 +262,23 @@ class MakeServiceAutoBoot(Operation):
class CopyKernel(Operation):
"""class for copy kernel"""
def __init__(self,scr):
Operation.__init__(self,"copy kernle",u"拷贝内核","copy_kernels.sh",scr)
self.return_value[1]=("kernel directory/modules directory/initrd.gz/makeinitrd doesn't exist",u"内核目录、模块目录、initrd.gz、makeinitrd 不存在")
Operation.__init__(self,"Copy kernle",u"拷贝内核","copy_kernels.sh",scr)
self.return_value[1]=("kernel directory, modules directory, initrd.gz, or makeinitrd doesn't exist",u"内核目录、模块目录、initrd.gz文件、makeinitrd指令不存在")
class ExecFinishInstall(Operation):
"""class for exec finish install"""
def __init__(self,scr):
Operation.__init__(self,"exec finish install",u"安装完成执行的脚本","exec_finish_install.sh",scr)
Operation.__init__(self,"Exec finish_install script",u"安装完成执行的脚本","exec_finish_install.sh",scr)
def get_stdin(self):
return "99finish_install.sh\n"
class BootLoader(Operation):
"""class for bootloader"""
def __init__(self,scr):
Operation.__init__(self,"install bootloader",u"安装引导程序","install_bootloader.sh",scr)
self.return_value[2]=("bootloader type doesn't specify",u"没有指定引导程序的类型")
self.return_value[3]=("bootloader no implement",u"没有执行bootloader")
self.return_value[127]=("bootloader utils not found",u"没发现bootloader的utils")
Operation.__init__(self,"Install bootloader",u"安装引导程序","install_bootloader.sh",scr)
self.return_value[2]=("Bootloader type hasn't been specified",u"没有指定引导程序的类型")
self.return_value[3]=("Bootloader hasn't been implemented",u"没有执行bootloader")
self.return_value[127]=("Bootloader utils not found",u"没发现bootloader的utils")
def get_arguments(self):
# only grub?
@@ -285,10 +287,10 @@ class BootLoader(Operation):
class ConfigureBootloader(Operation):
"""class for configure bootloader file"""
def __init__(self,scr):
Operation.__init__(self,"configure bootloader",u"配置bootloader","configure_bootloader_cnf.sh",scr)
self.return_value[2]=("bootloader type doesn't specify",u"没有指定引导程序的类型")
self.return_value[3]=("bootloader configure file doesn't exist",u"引导程序配置文件不存在")
self.return_value[4]=("bootloader configuration file doesn't exist",u"引导程序配置文件不存在")
Operation.__init__(self,"Configure bootloader",u"配置bootloader","configure_bootloader_cnf.sh",scr)
self.return_value[2]=("Bootloader type hasn't specified",u"没有指定引导程序的类型")
self.return_value[3]=("Bootloader hasn't been implemented",u"")
self.return_value[4]=("Bootloader configuration file doesn't exist",u"引导程序配置文件不存在")
def get_arguments(self):
bootloader=[]