VMM/VMM: allow configure subcommand also with missing settings.
Removed method VirtualMailManager.setupIsDone()
VMM/Config: Config.load() added 'finally' clause.
--- a/VirtualMailManager/Config.py Sun Jan 24 06:40:38 2010 +0000
+++ b/VirtualMailManager/Config.py Sun Jan 24 09:06:05 2010 +0000
@@ -332,9 +332,10 @@
self.__cfgFile = open(self.__cfgFileName, 'r')
self.readfp(self.__cfgFile)
except (MissingSectionHeaderError, ParsingError), e:
- self.__cfgFile.close()
raise VMMConfigException(str(e), ERR.CONF_ERROR)
- self.__cfgFile.close()
+ finally:
+ if not self.__cfgFile is None and not self.__cfgFile.closed:
+ self.__cfgFile.close()
def check(self):
"""Performs a configuration check.
--- a/VirtualMailManager/VirtualMailManager.py Sun Jan 24 06:40:38 2010 +0000
+++ b/VirtualMailManager/VirtualMailManager.py Sun Jan 24 09:06:05 2010 +0000
@@ -49,11 +49,11 @@
if self.__chkCfgFile():
self.__Cfg = Cfg(self.__cfgFileName)
self.__Cfg.load()
+ if not os.sys.argv[1] in ['cf', 'configure']:
self.__Cfg.check()
+ self.__chkenv()
self.__scheme = self.__Cfg.dget('misc.password_scheme')
self._postconf = Postconf(self.__Cfg.dget('bin.postconf'))
- if not os.sys.argv[1] in ['cf', 'configure']:
- self.__chkenv()
def __findCfgFile(self):
for path in ['/root', '/usr/local/etc', '/etc']:
@@ -436,15 +436,6 @@
def cfgSet(self, option, value):
return self.__Cfg.set(option, value)
- def setupIsDone(self):
- """Checks if vmm is configured, returns bool"""
- try:
- return self.__Cfg.dget('config.done')
- except ValueError, e:
- raise VMMConfigException(_(u"""Configuration error: "%s"
-(in section "config", option "done") see also: vmm.cfg(5)\n""") % str(e),
- ERR.CONF_ERROR)
-
def configure(self, section=None):
"""Starts interactive configuration.
@@ -462,7 +453,7 @@
self.__Cfg.configure([section])
else:
raise VMMException(_(u"Invalid section: ā%sā") % section,
- ERR.INVALID_SECTION)
+ ERR.INVALID_SECTION)
def domainAdd(self, domainname, transport=None):
dom = self.__getDomain(domainname, transport)
--- a/vmm Sun Jan 24 06:40:38 2010 +0000
+++ b/vmm Sun Jan 24 09:06:05 2010 +0000
@@ -476,7 +476,7 @@
vmm = get_vmm()
try:
- need_setup = not vmm.setupIsDone()
+ need_setup = not vmm.cfgDget('config.done')
if argv[1] in (u'cf', u'configure') or need_setup:
configure()
elif argv[1] in (u'da', u'domainadd'):