Change cl_install_cmd object. Convert to common view.

netsetup
Mike Hiretsky 14 years ago
parent ee9a4b6902
commit b473eb7d6b

@ -585,20 +585,12 @@ class cl_install(color_print):
def __init__(self):
self.clVars = None
self.clTempl = None
self.color = True
self.listDisksOptions = []
self.listBindsOptions = []
self.listSwapsOptions = []
self.startMessage = ""
Spinner().setWriteFunc(self.defaultPrint)
def colorPrint(self,*argv,**kwarg):
if self.color:
color_print.colorPrint(self,*argv,**kwarg)
else:
sys.stdout.write(argv[-1])
sys.stdout.flush()
def setNoColor(self):
self.color = False

@ -93,7 +93,7 @@ CMD_OPTIONS = [{'shortOption':"d",
#'help':_("installation for assembling")
#}]
class install_cmd(cl_install,share_cmd):
class install_cmd(share_cmd):
"""Class for work with cl_install by console"""
def __init__(self):
self.optobj = opt(package=__app__,
@ -102,7 +102,7 @@ class install_cmd(cl_install,share_cmd):
option_list= CMD_OPTIONS + opt.variable_control +
opt.color_control,
check_values=self.checkOpts)
cl_install.__init__(self)
self.logicObj = cl_install()
# names incompatible options with --live
self.optionsLiveIncompatible = ["d", "b", "mbr", "w", "f", "s"]
@ -155,7 +155,8 @@ class install_cmd(cl_install,share_cmd):
return False
if not (values.install or values.uninstall or values.live):
if values.v is False and \
values.d is None and not self.clVars.Get('os_install_dev_from'):
values.d is None and \
not self.logicObj.clVars.Get('os_install_dev_from'):
self.optobj.error(_("need specify disk by '-d' option"))
# check syntax DISK:DIR:FS:'Do I need to format the disk'
if values.d:
@ -204,7 +205,7 @@ class install_cmd(cl_install,share_cmd):
def setLang(self,lang):
"""Process set locales by lang"""
if self.setAllLocaleByLang(lang):
if self.logicObj.setAllLocaleByLang(lang):
return True
else:
self.printERROR(_("specified lang %s is unsupported")%lang)
@ -213,11 +214,11 @@ class install_cmd(cl_install,share_cmd):
def setProxyNtp(self,proxy,ntp):
"""Process set locales by lang"""
if proxy:
if not self.clVars.SetWriteVar('os_install_proxy',proxy):
if not self.logicObj.clVars.SetWriteVar('os_install_proxy',proxy):
self.printERROR(get_install_errors(),printBR=False)
return False
elif ntp:
if not self.clVars.SetWriteVar('os_install_ntp',ntp):
if not self.logicObj.clVars.SetWriteVar('os_install_ntp',ntp):
self.printERROR(get_install_errors(),printBR=False)
return False
return True
@ -228,19 +229,17 @@ class install_cmd(cl_install,share_cmd):
for vals in options.set:
for val in vals.split(','):
k,o,v = val.partition('=')
if self.clVars.exists(k):
if not self.clVars.SetWriteVar(k,v):
if self.logicObj.clVars.exists(k):
if not self.logicObj.clVars.SetWriteVar(k,v):
self.printERROR(get_install_errors(),printBR=False)
return False
else:
self.printERROR(_('variable %s not found')%k)
return False
if options.live:
#self.clVars.Set('cl_image','',True)
self.clVars.Set('cl_action','merge',True)
self.logicObj.clVars.Set('cl_action','merge',True)
else:
self.clVars.Set('cl_action','system',True)
self.logicObj.clVars.Set('cl_action','system',True)
if options.s:
self.setLinuxName(options.s.upper())
return True
@ -262,7 +261,7 @@ class install_cmd(cl_install,share_cmd):
listSwapOptions = self._parseOptSwap(swapOptions)
if listSwapOptions is False:
return False
if not self.setInstallOptions(listDiskOptions, listBindOptions,
if not self.logicObj.setInstallOptions(listDiskOptions, listBindOptions,
listSwapOptions):
return False
return True
@ -330,14 +329,36 @@ class install_cmd(cl_install,share_cmd):
def templateSelect(self,template):
"""Process template appling"""
if self.applyTemplatesForSystem():
if self.logicObj.applyTemplatesForSystem():
return True
else:
return False
def installSystem(self, force=False, bootDisk=None, users=[]):
if cl_install.installSystem(self, force=force, bootDisk=bootDisk,
"""Run install system"""
if self.logicObj.installSystem(force=force, bootDisk=bootDisk,
users=users):
return True
else:
return False
def configureSystem(self):
"""Run configure system"""
if self.logicObj.configureSystem():
return True
else:
return False
def installPackage(self):
"""Run package installation"""
if self.logicObj.installPackage():
return True
else:
return False
def uninstallPackage(self):
"""Run package uninstallation"""
if self.logicObj.uninstallPackage():
return True
else:
return False

@ -42,7 +42,8 @@ class share_cmd(color_print, _error):
varsNames.append(optCmd)
if "xml" in optObj.__dict__.keys() and optObj.xml:
format = "xml"
self.clVars.printVars(varsFilter, varsNames, outFormat=format)
self.logicObj.clVars.printVars(varsFilter, varsNames,
outFormat=format)
def setVars(self, optObj):
"""Установка переменных"""
@ -50,8 +51,8 @@ class share_cmd(color_print, _error):
for vals in optObj.set:
for val in vals.split(','):
k,o,v = val.partition('=')
if self.clVars.exists(k):
if not self.clVars.SetWriteVar(k,v):
if self.logicObj.clVars.exists(k):
if not self.logicObj.clVars.SetWriteVar(k,v):
return False
else:
self.printERROR(_('variable %s not found')%k)
@ -60,7 +61,7 @@ class share_cmd(color_print, _error):
def writeVars(self, optObj):
"""Запись переменных"""
if not self.clVars.WriteVars(header="install"):
if not self.logicObj.clVars.WriteVars(header="install"):
errMsg = self.getError()
if errMsg:
self.printERROR(errMsg.strip())

@ -30,7 +30,7 @@ tr.setLanguage(sys.modules[__name__])
if __name__ == "__main__":
install = install_cmd()
install.initVars()
install.logicObj.initVars()
# set lang
ret = install.optobj.parse_args()
if ret is False:
@ -54,11 +54,7 @@ if __name__ == "__main__":
if options.v or options.filter or options.xml:
install.printVars(options)
sys.exit(0)
# apply template to current system
#elif options.T:
#if not install.applyTemplatesForSystem():
#sys.exit(1)
#else:
# configurate current system
if options.live:
if not install.configureSystem():
sys.exit(1)

Loading…
Cancel
Save