Change cl_install_cmd object. Convert to common view.

master3.3
Mike Hiretsky 14 years ago
parent ee9a4b6902
commit b473eb7d6b

@ -585,20 +585,12 @@ class cl_install(color_print):
def __init__(self): def __init__(self):
self.clVars = None self.clVars = None
self.clTempl = None self.clTempl = None
self.color = True
self.listDisksOptions = [] self.listDisksOptions = []
self.listBindsOptions = [] self.listBindsOptions = []
self.listSwapsOptions = [] self.listSwapsOptions = []
self.startMessage = "" self.startMessage = ""
Spinner().setWriteFunc(self.defaultPrint) 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): def setNoColor(self):
self.color = False self.color = False

@ -93,7 +93,7 @@ CMD_OPTIONS = [{'shortOption':"d",
#'help':_("installation for assembling") #'help':_("installation for assembling")
#}] #}]
class install_cmd(cl_install,share_cmd): class install_cmd(share_cmd):
"""Class for work with cl_install by console""" """Class for work with cl_install by console"""
def __init__(self): def __init__(self):
self.optobj = opt(package=__app__, self.optobj = opt(package=__app__,
@ -102,7 +102,7 @@ class install_cmd(cl_install,share_cmd):
option_list= CMD_OPTIONS + opt.variable_control + option_list= CMD_OPTIONS + opt.variable_control +
opt.color_control, opt.color_control,
check_values=self.checkOpts) check_values=self.checkOpts)
cl_install.__init__(self) self.logicObj = cl_install()
# names incompatible options with --live # names incompatible options with --live
self.optionsLiveIncompatible = ["d", "b", "mbr", "w", "f", "s"] self.optionsLiveIncompatible = ["d", "b", "mbr", "w", "f", "s"]
@ -155,7 +155,8 @@ class install_cmd(cl_install,share_cmd):
return False return False
if not (values.install or values.uninstall or values.live): if not (values.install or values.uninstall or values.live):
if values.v is False and \ 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")) self.optobj.error(_("need specify disk by '-d' option"))
# check syntax DISK:DIR:FS:'Do I need to format the disk' # check syntax DISK:DIR:FS:'Do I need to format the disk'
if values.d: if values.d:
@ -204,7 +205,7 @@ class install_cmd(cl_install,share_cmd):
def setLang(self,lang): def setLang(self,lang):
"""Process set locales by lang""" """Process set locales by lang"""
if self.setAllLocaleByLang(lang): if self.logicObj.setAllLocaleByLang(lang):
return True return True
else: else:
self.printERROR(_("specified lang %s is unsupported")%lang) self.printERROR(_("specified lang %s is unsupported")%lang)
@ -213,11 +214,11 @@ class install_cmd(cl_install,share_cmd):
def setProxyNtp(self,proxy,ntp): def setProxyNtp(self,proxy,ntp):
"""Process set locales by lang""" """Process set locales by lang"""
if proxy: 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) self.printERROR(get_install_errors(),printBR=False)
return False return False
elif ntp: 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) self.printERROR(get_install_errors(),printBR=False)
return False return False
return True return True
@ -228,19 +229,17 @@ class install_cmd(cl_install,share_cmd):
for vals in options.set: for vals in options.set:
for val in vals.split(','): for val in vals.split(','):
k,o,v = val.partition('=') k,o,v = val.partition('=')
if self.clVars.exists(k): if self.logicObj.clVars.exists(k):
if not self.clVars.SetWriteVar(k,v): if not self.logicObj.clVars.SetWriteVar(k,v):
self.printERROR(get_install_errors(),printBR=False) self.printERROR(get_install_errors(),printBR=False)
return False return False
else: else:
self.printERROR(_('variable %s not found')%k) self.printERROR(_('variable %s not found')%k)
return False return False
if options.live: if options.live:
#self.clVars.Set('cl_image','',True) self.logicObj.clVars.Set('cl_action','merge',True)
self.clVars.Set('cl_action','merge',True)
else: else:
self.clVars.Set('cl_action','system',True) self.logicObj.clVars.Set('cl_action','system',True)
if options.s: if options.s:
self.setLinuxName(options.s.upper()) self.setLinuxName(options.s.upper())
return True return True
@ -262,7 +261,7 @@ class install_cmd(cl_install,share_cmd):
listSwapOptions = self._parseOptSwap(swapOptions) listSwapOptions = self._parseOptSwap(swapOptions)
if listSwapOptions is False: if listSwapOptions is False:
return False return False
if not self.setInstallOptions(listDiskOptions, listBindOptions, if not self.logicObj.setInstallOptions(listDiskOptions, listBindOptions,
listSwapOptions): listSwapOptions):
return False return False
return True return True
@ -330,14 +329,36 @@ class install_cmd(cl_install,share_cmd):
def templateSelect(self,template): def templateSelect(self,template):
"""Process template appling""" """Process template appling"""
if self.applyTemplatesForSystem(): if self.logicObj.applyTemplatesForSystem():
return True return True
else: else:
return False return False
def installSystem(self, force=False, bootDisk=None, users=[]): 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): users=users):
return True return True
else: else:
return False 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) varsNames.append(optCmd)
if "xml" in optObj.__dict__.keys() and optObj.xml: if "xml" in optObj.__dict__.keys() and optObj.xml:
format = "xml" format = "xml"
self.clVars.printVars(varsFilter, varsNames, outFormat=format) self.logicObj.clVars.printVars(varsFilter, varsNames,
outFormat=format)
def setVars(self, optObj): def setVars(self, optObj):
"""Установка переменных""" """Установка переменных"""
@ -50,8 +51,8 @@ class share_cmd(color_print, _error):
for vals in optObj.set: for vals in optObj.set:
for val in vals.split(','): for val in vals.split(','):
k,o,v = val.partition('=') k,o,v = val.partition('=')
if self.clVars.exists(k): if self.logicObj.clVars.exists(k):
if not self.clVars.SetWriteVar(k,v): if not self.logicObj.clVars.SetWriteVar(k,v):
return False return False
else: else:
self.printERROR(_('variable %s not found')%k) self.printERROR(_('variable %s not found')%k)
@ -60,7 +61,7 @@ class share_cmd(color_print, _error):
def writeVars(self, optObj): def writeVars(self, optObj):
"""Запись переменных""" """Запись переменных"""
if not self.clVars.WriteVars(header="install"): if not self.logicObj.clVars.WriteVars(header="install"):
errMsg = self.getError() errMsg = self.getError()
if errMsg: if errMsg:
self.printERROR(errMsg.strip()) self.printERROR(errMsg.strip())

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

Loading…
Cancel
Save