VMM/domain: Extended/updated Domain.get_info() in order to: v0.6.x
authorPascal Volk <neverseen@users.sourceforge.net>
Fri, 04 Nov 2011 02:20:01 +0000
branchv0.6.x
changeset 447 c31d604e26d3
parent 446 18b75e6a39d5
child 448 45c917e6a386
VMM/domain: Extended/updated Domain.get_info() in order to: - include active service(s) || None - use more understandable English terms VMM/cli/subcommands: Updated (order of) keys of `domaininfo' output. .`userinfo' will always show `sieve', no longer `managesieve'.
VirtualMailManager/cli/subcommands.py
VirtualMailManager/domain.py
VirtualMailManager/handler.py
--- a/VirtualMailManager/cli/subcommands.py	Thu Nov 03 05:32:47 2011 +0000
+++ b/VirtualMailManager/cli/subcommands.py	Fri Nov 04 02:20:01 2011 +0000
@@ -742,25 +742,24 @@
     get a dict from the handler."""
     order = ()
     if ctx.scmd == 'domaininfo':
-        order = ((u'domainname', 0), (u'gid', 1), (u'transport', 0),
-                 (u'domaindir', 0), (u'quota limit', 0), (u'aliasdomains', 0),
-                 (u'accounts', 0), (u'aliases', 0), (u'relocated', 0))
+        order = ((u'domain name', 0), (u'gid', 1), (u'domain directory', 0),
+                 (u'quota limit', 0), (u'active services', 0),
+                 (u'transport', 0), (u'alias domains', 0), (u'accounts', 0),
+                 (u'aliases', 0), (u'relocated', 0))
     elif ctx.scmd == 'userinfo':
-        dc12 = ctx.cget('misc.dovecot_version') >= 0x10200b02
-        sieve = (u'managesieve', u'sieve')[dc12]
         if ctx.argc == 4 and ctx.args[3] != u'aliases' or \
            ctx.cget('account.disk_usage'):
             order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1),
                      (u'home', 0), (u'mail_location', 0),
                      (u'quota storage', 0), (u'quota messages', 0),
                      (u'disk usage', 0), (u'transport', 0), (u'smtp', 1),
-                     (u'pop3', 1), (u'imap', 1), (sieve, 1))
+                     (u'pop3', 1), (u'imap', 1), (u'sieve', 1))
         else:
             order = ((u'address', 0), (u'name', 0), (u'uid', 1), (u'gid', 1),
                      (u'home', 0), (u'mail_location', 0),
                      (u'quota storage', 0), (u'quota messages', 0),
                      (u'transport', 0), (u'smtp', 1), (u'pop3', 1),
-                     (u'imap', 1), (sieve, 1))
+                     (u'imap', 1), (u'sieve', 1))
     elif ctx.scmd == 'getuser':
         order = ((u'uid', 1), (u'gid', 1), (u'address', 0))
     return order
@@ -792,9 +791,9 @@
     w_std(msg, u'-' * len(msg))
     for key, upper in _get_order(ctx):
         if upper:
-            w_std(u'\t%s: %s' % (key.upper().ljust(15, u'.'), info[key]))
+            w_std(u'\t%s: %s' % (key.upper().ljust(17, u'.'), info[key]))
         else:
-            w_std(u'\t%s: %s' % (key.title().ljust(15, u'.'), info[key]))
+            w_std(u'\t%s: %s' % (key.title().ljust(17, u'.'), info[key]))
     print
 
 
--- a/VirtualMailManager/domain.py	Thu Nov 03 05:32:47 2011 +0000
+++ b/VirtualMailManager/domain.py	Fri Nov 04 02:20:01 2011 +0000
@@ -347,18 +347,26 @@
         """Returns a dictionary with information about the domain."""
         self._chk_state()
         dbc = self._dbh.cursor()
-        dbc.execute('SELECT aliasdomains, accounts, aliases, relocated '
-                    'FROM vmm_domain_info WHERE gid = %s', (self._gid,))
+        dbc.execute('SELECT aliasdomains "alias domains", accounts, aliases, '
+                    'relocated FROM vmm_domain_info WHERE gid = %s',
+                    (self._gid,))
         info = dbc.fetchone()
         dbc.close()
-        keys = ('aliasdomains', 'accounts', 'aliases', 'relocated')
+        keys = ('alias domains', 'accounts', 'aliases', 'relocated')
         info = dict(zip(keys, info))
         info['gid'] = self._gid
-        info['domainname'] = self._name
+        info['domain name'] = self._name
         info['transport'] = self._transport.transport
-        info['domaindir'] = self._directory
+        info['domain directory'] = self._directory
         info['bytes'] = self._qlimit.bytes
         info['messages'] = self._qlimit.messages
+        services = self._services.services
+        services = [s.upper() for s in services if services[s]]
+        if services:
+            services.sort()
+        else:
+            services.append('None')
+        info['active services'] = ' '.join(services)
         return info
 
     def get_accounts(self):
--- a/VirtualMailManager/handler.py	Thu Nov 03 05:32:47 2011 +0000
+++ b/VirtualMailManager/handler.py	Fri Nov 04 02:20:01 2011 +0000
@@ -511,9 +511,9 @@
                            INVALID_ARGUMENT)
         dom = self._get_domain(domainname)
         dominfo = dom.get_info()
-        if dominfo['domainname'].startswith('xn--'):
-            dominfo['domainname'] += ' (%s)' % \
-                                     dominfo['domainname'].decode('idna')
+        if dominfo['domain name'].startswith('xn--'):
+            dominfo['domain name'] += ' (%s)' % \
+                                      dominfo['domain name'].decode('idna')
         if details is None:
             return dominfo
         elif details == 'accounts':