Change write variables

master3.3
Mike Hiretsky 14 years ago
parent bf55747ca5
commit 261b2f595e

@ -1021,6 +1021,7 @@ class cl_install(color_print):
def configureSystem(self):
"""configure current system"""
self.printSUCCESS("Configurating system")
return True
def installSystem(self, force=False, bootDisk=None, users=[]):
"""install System by current variable enviroment"""

@ -83,30 +83,23 @@ CMD_OPTIONS = [{'shortOption':"d",
#'help':_("installation for assembling")
#}]
class install_cmd(cl_install,opt,share_cmd):
class install_cmd(cl_install,share_cmd):
"""Class for work with cl_install by console"""
def __init__(self):
opt.__init__(self,
package=__app__,
version=__version__,
description=DESCRIPTION,
option_list= CMD_OPTIONS + opt.variable_control +
opt.color_control,
check_values=self.checkOpts)
self.optobj = opt(package=__app__,
version=__version__,
description=DESCRIPTION,
option_list= CMD_OPTIONS + opt.variable_control +
opt.color_control,
check_values=self.checkOpts)
cl_install.__init__(self)
# names incompatible options with --live
self.optionsLiveIncompatible = ["d", "b", "mbr", "w", "f", "s"]
def error(self, msg):
self.print_usage(sys.stderr)
self.exit(2, "%s: error: %s\n%s\n" % (self.get_prog_name(), msg,
_("Try `%s' for more information")%
"%s --help"%self.get_prog_name()))
def _getNamesAllSetOptions(self):
"""Выдает словарь измененных опций"""
setOptDict = self.values.__dict__.items()
defaultOptDict = self.get_default_values().__dict__.items()
setOptDict = self.optobj.values.__dict__.items()
defaultOptDict = self.optobj.get_default_values().__dict__.items()
return reduce(lambda x,y: x+[y[0][0]],
filter(lambda x:x[0][1] != x[1][1],
zip(setOptDict,defaultOptDict)),
@ -117,37 +110,37 @@ class install_cmd(cl_install,opt,share_cmd):
return ", ".join(map(lambda x: len(x) == 1 and "'-%s'"%x or "'--%s'"%x,
listOpt))
def checkIncompatibeLive(self,values):
def checkIncompatibeLive(self):
incompatible = list(set(self._getNamesAllSetOptions()) &
set(self.optionsLiveIncompatible))
if incompatible:
self.error(_("incompatible options")+":"+" %s"\
self.optobj.error(_("incompatible options")+":"+" %s"\
%self.getStringIncompatibleOptions(incompatible+["live"]))
def checkOpts(self, values, args):
"""Check values all specified options."""
if len(args) > 0:
self.error(_("unrecognized option") + ": %s"% "".join(args))
self.optobj.error(_("unrecognized option") + ": %s"% "".join(args))
if values.live:
self.checkIncompatibeLive(values)
self.checkIncompatibeLive()
if values.d == None:
values.d = self.detectPreviousSystem()
if values.vars is None and \
values.d is None:
self.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'
if values.d:
reTrueDisk = re.compile("^[^:]+(:[^:]+){0,3}$")
wrongValue = filter(lambda x: not reTrueDisk.match(x),values.d)
if wrongValue:
self.error(_("option %s:") %"d" +\
self.optobj.error(_("option %s:") %"d" +\
" " + _("disk specifing error: '%s'")\
%", ".join(wrongValue))
if values.s:
choices = ['cld','cds','cls','css','cldg','cldx']
if not values.s.lower() in choices:
choices = ", ".join(map(repr, choices))
self.error(_("option %s:")%"s"+ " " +\
self.optobj.error(_("option %s:")%"s"+ " " +\
_("invalid choice: %r")%values.s+ " " +\
_("(choose from %s)")%choices)
# check syntax SRC_DIR:DEST_DIR
@ -155,7 +148,7 @@ class install_cmd(cl_install,opt,share_cmd):
reTrueBind = re.compile("^[^:]+:[^:]+$")
wrongValue = filter(lambda x: not reTrueBind.match(x),values.b)
if wrongValue:
self.error(_("option %s:") %"b" +\
self.optobj.error(_("option %s:") %"b" +\
" " + _("mount bind specifing error: '%s'")\
%", ".join(wrongValue))
@ -164,7 +157,7 @@ class install_cmd(cl_install,opt,share_cmd):
reTrueBind = re.compile("^[^:]+$")
wrongValue = filter(lambda x: not reTrueBind.match(x),values.w)
if wrongValue:
self.error(_("option %s:") %"w" +\
self.optobj.error(_("option %s:") %"w" +\
" " + _("mount bind specifing error: '%s'")\
%", ".join(wrongValue))
@ -173,11 +166,11 @@ class install_cmd(cl_install,opt,share_cmd):
bootDisk = values.mbr
reBootDisk = re.compile("^/dev/.+[^\d]$")
if not reBootDisk.match(bootDisk):
self.error(_("option %s:") %"mbr" + " " +\
self.optobj.error(_("option %s:") %"mbr" + " " +\
_("disk specifing error: '%s'")%bootDisk)
# check syntax --set
self.checkVarSyntax(values)
self.optobj.checkVarSyntax(values)
return (values, args)
def setLang(self,lang):

@ -48,7 +48,7 @@ class share_cmd(color_print, _error):
def writeVars(self, optObj):
"""Запись переменных"""
if optObj.set:
if not self.clVars.WriteVars():
if not self.clVars.WriteVars(header="calculate-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()
ret = install.parse_args()
ret = install.optobj.parse_args()
if ret is False:
sys.exit(1)
options, args = ret
@ -62,7 +62,6 @@ if __name__ == "__main__":
users=options.u):
sys.exit(1)
else:
if not install.configureSystem():
sys.exit(1)
if not install.writeVars(options):

Loading…
Cancel
Save