VirtualMailManager/cli/subcommands.py
branchv0.7.x
changeset 653 cf07e4468934
parent 643 df1e3b67882a
child 656 4bbca60e0ba4
equal deleted inserted replaced
652:68d715ce6e1c 653:cf07e4468934
   108     plan_a_b = _('Plan A failed ... trying Plan B: %(subcommand)s %(object)s')
   108     plan_a_b = _('Plan A failed ... trying Plan B: %(subcommand)s %(object)s')
   109 
   109 
   110     def __init__(self, argv, handler, command):
   110     def __init__(self, argv, handler, command):
   111         """Create a new RunContext"""
   111         """Create a new RunContext"""
   112         self.argc = len(argv)
   112         self.argc = len(argv)
   113         self.args = [str(arg, ENCODING) for arg in argv]
   113         self.args = argv[:]  # will be moved to argparse
   114         self.cget = handler.cfg_dget
   114         self.cget = handler.cfg_dget
   115         self.hdlr = handler
   115         self.hdlr = handler
   116         self.scmd = command
   116         self.scmd = command
   117 
   117 
   118 
   118 
   318             raise
   318             raise
   319     else:
   319     else:
   320         q_limit = 'Storage: %(bytes)s; Messages: %(messages)s'
   320         q_limit = 'Storage: %(bytes)s; Messages: %(messages)s'
   321         if not details:
   321         if not details:
   322             info['bytes'] = human_size(info['bytes'])
   322             info['bytes'] = human_size(info['bytes'])
   323             info['messages'] = locale.format('%d', info['messages'],
   323             info['messages'] = locale.format('%d', info['messages'], True)
   324                                              True).decode(ENCODING, 'replace')
       
   325             info['quota limit/user'] = q_limit % info
   324             info['quota limit/user'] = q_limit % info
   326             _print_info(ctx, info, _('Domain'))
   325             _print_info(ctx, info, _('Domain'))
   327         else:
   326         else:
   328             info[0]['bytes'] = human_size(info[0]['bytes'])
   327             info[0]['bytes'] = human_size(info[0]['bytes'])
   329             info[0]['messages'] = locale.format('%d', info[0]['messages'],
   328             info[0]['messages'] = locale.format('%d', info[0]['messages'],
   776     # the version information, e.g.:
   775     # the version information, e.g.:
   777     # vmm, version 0.5.2 (from 09/09/09)
   776     # vmm, version 0.5.2 (from 09/09/09)
   778     # Python 2.5.4 on FreeBSD
   777     # Python 2.5.4 on FreeBSD
   779         _('version'), __version__, _('from'),
   778         _('version'), __version__, _('from'),
   780         strftime(locale.nl_langinfo(locale.D_FMT),
   779         strftime(locale.nl_langinfo(locale.D_FMT),
   781             strptime(__date__, '%Y-%m-%d')).decode(ENCODING, 'replace'),
   780             strptime(__date__, '%Y-%m-%d')),
   782         os.sys.version.split()[0], _('on'), os.uname()[0],
   781         os.sys.version.split()[0], _('on'), os.uname()[0],
   783         __copyright__, prog,
   782         __copyright__, prog,
   784         _('is free software and comes with ABSOLUTELY NO WARRANTY.')))
   783         _('is free software and comes with ABSOLUTELY NO WARRANTY.')))
   785 
   784 
   786 
   785 
   941             'used': human_size(used),
   940             'used': human_size(used),
   942             'limit': human_size(limit),
   941             'limit': human_size(limit),
   943         }
   942         }
   944     else:
   943     else:
   945         q_usage = {
   944         q_usage = {
   946             'used': locale.format('%d', used, True).decode(ENCODING,
   945             'used': locale.format('%d', used, True),
   947                                                            'replace'),
   946             'limit': locale.format('%d', limit, True),
   948             'limit': locale.format('%d', limit, True).decode(ENCODING,
       
   949                                                              'replace'),
       
   950         }
   947         }
   951     if limit:
   948     if limit:
   952         q_usage['percent'] = locale.format('%6.2f', 100. / limit * used, True)
   949         q_usage['percent'] = locale.format('%6.2f', 100. / limit * used, True)
   953     else:
   950     else:
   954         q_usage['percent'] = locale.format('%6.2f', 0, True)
   951         q_usage['percent'] = locale.format('%6.2f', 0, True)