VirtualMailManager/cli/subcommands.py
branchv0.6.x
changeset 397 cf661a40266d
parent 376 2af61bc06215
child 398 3e5ed678d535
equal deleted inserted replaced
396:7f931c1ca059 397:cf661a40266d
    15 from time import strftime, strptime
    15 from time import strftime, strptime
    16 
    16 
    17 from VirtualMailManager import ENCODING
    17 from VirtualMailManager import ENCODING
    18 from VirtualMailManager.account import SERVICES
    18 from VirtualMailManager.account import SERVICES
    19 from VirtualMailManager.cli import get_winsize, prog, w_err, w_std
    19 from VirtualMailManager.cli import get_winsize, prog, w_err, w_std
    20 from VirtualMailManager.common import version_str
    20 from VirtualMailManager.common import human_size, version_str
    21 from VirtualMailManager.constants import __copyright__, __date__, \
    21 from VirtualMailManager.constants import __copyright__, __date__, \
    22      __version__, ACCOUNT_EXISTS, ALIAS_EXISTS, ALIASDOMAIN_ISDOMAIN, \
    22      __version__, ACCOUNT_EXISTS, ALIAS_EXISTS, ALIASDOMAIN_ISDOMAIN, \
    23      DOMAIN_ALIAS_EXISTS, INVALID_ARGUMENT, EX_MISSING_ARGS, RELOCATED_EXISTS
    23      DOMAIN_ALIAS_EXISTS, INVALID_ARGUMENT, EX_MISSING_ARGS, RELOCATED_EXISTS
    24 from VirtualMailManager.errors import VMMError
    24 from VirtualMailManager.errors import VMMError
    25 
    25 
   172 
   172 
   173 def config_get(ctx):
   173 def config_get(ctx):
   174     """show the actual value of the configuration option"""
   174     """show the actual value of the configuration option"""
   175     if ctx.argc < 3:
   175     if ctx.argc < 3:
   176         usage(EX_MISSING_ARGS, _(u"Missing option name."), ctx.scmd)
   176         usage(EX_MISSING_ARGS, _(u"Missing option name."), ctx.scmd)
       
   177 
       
   178     noop = lambda option: option
       
   179     opt_formater = {
       
   180         'misc.dovecot_version': version_str,
       
   181         'misc.quota_bytes': human_size,
       
   182     }
       
   183 
   177     option = ctx.args[2].lower()
   184     option = ctx.args[2].lower()
   178     if option != 'misc.dovecot_version':
   185     w_std('%s = %s' % (option, opt_formater.get(option,
   179         w_std('%s = %s' % (option, ctx.cget(option)))
   186                        noop)(ctx.cget(option))))
   180     else:
       
   181         w_std('%s = %s' % (option, version_str(ctx.cget(option))))
       
   182 
   187 
   183 
   188 
   184 def config_set(ctx):
   189 def config_set(ctx):
   185     """set a new value for the configuration option"""
   190     """set a new value for the configuration option"""
   186     if ctx.argc < 3:
   191     if ctx.argc < 3: