# HG changeset patch # User Pascal Volk # Date 1211686962 0 # Node ID 22cc616aef61d4ab3d516d306c763dee6ec7741a # Parent 6d74e20c5b3b52c0f9ad7b62848a2ae15a5fa361 * 'VirtualMailManager/VirtualMailManager.py' - renamed: * __idn2ascii() -> idn2ascii() * __ace2idna() -> ace2idna() - implemented domain_list() - some small code cleanups * 'VirtualMailManager/Domain.py' - implemented search() * 'vmm' - implemented domain_list() - some small code cleanups * 'po/vmm.pot' * 'po/de.po' - updated diff -r 6d74e20c5b3b -r 22cc616aef61 ChangeLog --- a/ChangeLog Sun May 18 04:51:12 2008 +0000 +++ b/ChangeLog Sun May 25 03:42:42 2008 +0000 @@ -1,4 +1,18 @@ === 0.0.0 === +2008-05-25 Pascal Volk + + * VirtualMailManager/VirtualMailManager.py (VirtualMailManager): + Renamed: + __idn2ascii() -> idn2ascii() + __ace2idna() -> ace2idna() + Implemented domain_list() + some small code cleanups + * vmm: + Implemented domain_list() + some small code cleanups + * VirtualMailManager/Domain.py: + Implemented search() + 2008-05-13 Pascal Volk * VirtualMailManager/Alias.py, VirtualMailManager/MailLocation.py, diff -r 6d74e20c5b3b -r 22cc616aef61 VirtualMailManager/Domain.py --- a/VirtualMailManager/Domain.py Sun May 18 04:51:12 2008 +0000 +++ b/VirtualMailManager/Domain.py Sun May 25 03:42:42 2008 +0000 @@ -244,3 +244,18 @@ for alias in addresses: aliases.append(alias[0]) return aliases + +def search(dbh, pattern=None, like=False): + sql = 'SELECT domainname FROM domains' + if pattern is None: + pass + elif like: + sql += " WHERE domainname LIKE '%s'" % pattern + else: + sql += " WHERE domainname = '%s'" % pattern + sql += ' ORDER BY domainname' + dbc = dbh.cursor() + dbc.execute(sql) + domains = dbc.fetchall() + dbc.close() + return domains diff -r 6d74e20c5b3b -r 22cc616aef61 VirtualMailManager/VirtualMailManager.py --- a/VirtualMailManager/VirtualMailManager.py Sun May 18 04:51:12 2008 +0000 +++ b/VirtualMailManager/VirtualMailManager.py Sun May 25 03:42:42 2008 +0000 @@ -33,10 +33,9 @@ SALTCHARS = './0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' RE_ASCII_CHARS = """^[\x20-\x7E]*$""" RE_DOMAIN = """^(?:[a-z0-9-]{1,63}\.){1,}[a-z]{2,6}$""" +RE_DOMAIN_SRCH = """^[a-z0-9-\.]+$""" RE_LOCALPART = """[^\w!#$%&'\*\+-\.\/=?^_`{\|}~]""" RE_MAILLOCATION = """^[\w]{1,20}$""" -re.compile(RE_ASCII_CHARS) -re.compile(RE_DOMAIN) ENCODING_IN = sys.getfilesystemencoding() ENCODING_OUT = sys.stdout.encoding or sys.getfilesystemencoding() @@ -117,7 +116,7 @@ def __dbConnect(self): """Creates a pyPgSQL.PgSQL.connection instance.""" try: - self.__dbh = PgSQL.connect( + self.__dbh = PgSQL.connect( database=self.__Cfg.get('database', 'name'), user=self.__Cfg.get('database', 'user'), host=self.__Cfg.get('database', 'host'), @@ -144,7 +143,7 @@ localpart, ERR.LOCALPART_INVALID)) return localpart - def __idn2ascii(self, domainname): + def idn2ascii(self, domainname): """Converts an idn domainname in punycode. Keyword arguments: @@ -157,7 +156,7 @@ tmp.append(ToASCII(unicode(label, ENCODING_IN))) return '.'.join(tmp) - def __ace2idna(self, domainname): + def ace2idna(self, domainname): """Convertis a domainname from ACE according to IDNA Keyword arguments: @@ -176,11 +175,13 @@ Keyword arguments: domainname -- the domain name that should be validated """ + re.compile(RE_ASCII_CHARS) if not re.match(RE_ASCII_CHARS, domainname): - domainname = self.__idn2ascii(domainname) + domainname = self.idn2ascii(domainname) if len(domainname) > 255: raise VMMException((_('The domain name is too long.'), ERR.DOMAIN_TOO_LONG)) + re.compile(RE_DOMAIN) if not re.match(RE_DOMAIN, domainname): raise VMMException((_('The domain name is invalid.'), ERR.DOMAIN_INVALID)) @@ -454,7 +455,7 @@ dominfo = dom.getInfo() if dominfo['domainname'].startswith('xn--'): dominfo['domainname'] += ' (%s)'\ - % self.__ace2idna(dominfo['domainname']) + % self.ace2idna(dominfo['domainname']) if dominfo['aliases'] is None: dominfo['aliases'] = 0 if detailed is None: @@ -465,6 +466,28 @@ raise VMMDomainException(('%s: »%s«' % (_('Invalid argument'), detailed), ERR.INVALID_OPTION)) + def domain_list(self, pattern=None): + from Domain import search + like = False + if pattern is not None: + if pattern.startswith('%') or pattern.endswith('%'): + like = True + if pattern.startswith('%') and pattern.endswith('%'): + domain = pattern[1:-1] + elif pattern.startswith('%'): + domain = pattern[1:] + elif pattern.endswith('%'): + domain = pattern[:-1] + re.compile(RE_DOMAIN_SRCH) + if not re.match(RE_DOMAIN_SRCH, domain): + raise VMMException(( + _(u'The pattern »%s« contains invalid characters.') % + pattern, ERR.DOMAIN_INVALID)) + else: + pattern = self.__chkDomainname(pattern) + self.__dbConnect() + return search(self.__dbh, pattern=pattern, like=like) + def user_add(self, emailaddress, password): acc = self.__getAccount(emailaddress, password) acc.save(self.__Cfg.get('maildir', 'folder'), diff -r 6d74e20c5b3b -r 22cc616aef61 VirtualMailManager/constants/VERSION.py --- a/VirtualMailManager/constants/VERSION.py Sun May 18 04:51:12 2008 +0000 +++ b/VirtualMailManager/constants/VERSION.py Sun May 25 03:42:42 2008 +0000 @@ -4,4 +4,4 @@ # See COPYING for distribution information. # $Id$ -VERSION = '0.4' +VERSION = '0.5' diff -r 6d74e20c5b3b -r 22cc616aef61 po/de.po --- a/po/de.po Sun May 18 04:51:12 2008 +0000 +++ b/po/de.po Sun May 25 03:42:42 2008 +0000 @@ -5,8 +5,8 @@ msgid "" msgstr "" "Project-Id-Version: vmm 0.4\n" -"POT-Creation-Date: 2008-05-18 06:21+CEST\n" -"PO-Revision-Date: 2008-05-18 05:53+0200\n" +"POT-Creation-Date: 2008-05-25 04:58+CEST\n" +"PO-Revision-Date: 2008-05-25 05:00+0200\n" "Last-Translator: Pascal Volk \n" "Language-Team: German\n" "MIME-Version: 1.0\n" @@ -31,7 +31,7 @@ #: VirtualMailManager/Account.py:180 VirtualMailManager/Account.py:208 #: VirtualMailManager/Account.py:227 msgid "Account doesn't exists" -msgstr "Der Account existiert nicht." +msgstr "Der Account existiert nicht" #: VirtualMailManager/Account.py:148 msgid "Account already exists." @@ -47,7 +47,7 @@ #: VirtualMailManager/Alias.py:31 msgid "Address and destination are identical." -msgstr "Alias- und Ziel-Adresse sind identisch.." +msgstr "Alias- und Ziel-Adresse sind identisch." #: VirtualMailManager/Alias.py:44 msgid "There is already an account with address »%s«" @@ -67,11 +67,11 @@ #: VirtualMailManager/Config.py:101 msgid "missing section: %s\n" -msgstr "Fehlende Sektion: %s\n" +msgstr "Fehlender Bereich: %s\n" #: VirtualMailManager/Config.py:103 msgid "missing options in section %s:\n" -msgstr "Fehlende Optionen in Sektion %s:\n" +msgstr "Fehlende Optionen im Bereich %s:\n" #: VirtualMailManager/Config.py:119 msgid "Argument 'sections' is not a list." @@ -79,7 +79,7 @@ #: VirtualMailManager/Config.py:132 msgid "* Config section: %s" -msgstr "* Konfigurations Sektion: »%s«" +msgstr "* Konfigurations Bereich: »%s«" #: VirtualMailManager/Config.py:134 msgid "Enter new value for %s [%s]: " @@ -130,7 +130,7 @@ msgid "Unknown tid specified." msgstr "Unbekannte tid angegeben." -#: VirtualMailManager/VirtualMailManager.py:55 +#: VirtualMailManager/VirtualMailManager.py:54 msgid "" "fix permissions for '%s'\n" "`chmod 0600 %s` would be great." @@ -138,7 +138,7 @@ "Bitte Zugriffsrechte für '%s' anpassen\n" "`chmod 0600 %s` wäre großartig" -#: VirtualMailManager/VirtualMailManager.py:62 +#: VirtualMailManager/VirtualMailManager.py:61 msgid "" "You are not root.\n" "\tGood bye!\n" @@ -146,27 +146,27 @@ "Sie sind nicht root\n" "\tAuf Wiedersehen\n" -#: VirtualMailManager/VirtualMailManager.py:76 +#: VirtualMailManager/VirtualMailManager.py:75 msgid "The file »%s« does not exists." msgstr "Die Datei »%s« existiert nicht." -#: VirtualMailManager/VirtualMailManager.py:98 +#: VirtualMailManager/VirtualMailManager.py:97 msgid "%s is not a directory" msgstr "%s ist kein Verzeichnis" -#: VirtualMailManager/VirtualMailManager.py:102 +#: VirtualMailManager/VirtualMailManager.py:101 msgid "%s doesn't exists." msgstr "%s existiert nicht." -#: VirtualMailManager/VirtualMailManager.py:105 +#: VirtualMailManager/VirtualMailManager.py:104 msgid "%s is not executable." msgstr "%s ist nicht ausführbar." -#: VirtualMailManager/VirtualMailManager.py:139 +#: VirtualMailManager/VirtualMailManager.py:138 msgid "The local part is too long" msgstr "Der local-part ist zu lang" -#: VirtualMailManager/VirtualMailManager.py:143 +#: VirtualMailManager/VirtualMailManager.py:142 msgid "The local part »%s« contains invalid characters." msgstr "Der local-part »%s« enthält ungültige Zeichen." @@ -174,57 +174,61 @@ msgid "The domain name is too long." msgstr "Der Domain-Name ist zu lang." -#: VirtualMailManager/VirtualMailManager.py:185 +#: VirtualMailManager/VirtualMailManager.py:186 msgid "The domain name is invalid." msgstr "Der Domain-Name ist ungültig." -#: VirtualMailManager/VirtualMailManager.py:193 +#: VirtualMailManager/VirtualMailManager.py:194 msgid "Missing '@' sign in e-mail address »%s«." msgstr "In der E-Mail-Adresse »%s« fehlt das '@'-Zeichen." -#: VirtualMailManager/VirtualMailManager.py:196 +#: VirtualMailManager/VirtualMailManager.py:197 msgid "»%s« looks not like an e-mail address." msgstr "»%s« sieht nicht wie eine E-Mail-Adresse aus." -#: VirtualMailManager/VirtualMailManager.py:291 +#: VirtualMailManager/VirtualMailManager.py:292 msgid "FATAL: \"..\" in maildir path detected." msgstr "FATAL: \"..\" im Pfad zum Maildir entdeckt." -#: VirtualMailManager/VirtualMailManager.py:299 +#: VirtualMailManager/VirtualMailManager.py:300 msgid "FATAL: owner/group mismatch in maildir detected" msgstr "FATAL: Maildir gehört dem/der falschen Benutzer/Gruppe." -#: VirtualMailManager/VirtualMailManager.py:309 +#: VirtualMailManager/VirtualMailManager.py:310 msgid "FATAL: \"..\" in domain directory path detected." msgstr "FATAL: \"..\" im Pfad zum Domain-Verzeichnis entdeckt." -#: VirtualMailManager/VirtualMailManager.py:315 +#: VirtualMailManager/VirtualMailManager.py:316 msgid "FATAL: group mismatch in domain directory detected" msgstr "FATAL: Domain-Verzeichnis gehört der falschen Gruppe" -#: VirtualMailManager/VirtualMailManager.py:393 +#: VirtualMailManager/VirtualMailManager.py:394 msgid "" "Configurtion error: \"%s\"\n" "(in section \"connfig\", option \"done\")'\n" "see also: vmm.cfg(5)\n" msgstr "" "Konfigurations Fehler: \"%s\"\n" -"(in Sektion \"connfig\", Option \"done\")'\n" +"(im Bereich \"connfig\", Option \"done\")'\n" "Siehe auch: vmm.cfg(5)\n" -#: VirtualMailManager/VirtualMailManager.py:412 +#: VirtualMailManager/VirtualMailManager.py:413 msgid "Invalid section: »%s«" -msgstr "Ungültiges Sektion: »%s«" +msgstr "Ungültiger Bereich: »%s«" -#: VirtualMailManager/VirtualMailManager.py:426 -#: VirtualMailManager/VirtualMailManager.py:436 +#: VirtualMailManager/VirtualMailManager.py:427 +#: VirtualMailManager/VirtualMailManager.py:437 msgid "Invalid argument: »%s«" msgstr "Ungültiges Argument: »%s«" -#: VirtualMailManager/VirtualMailManager.py:465 +#: VirtualMailManager/VirtualMailManager.py:466 msgid "Invalid argument" msgstr "Ungültiges Argument" +#: VirtualMailManager/VirtualMailManager.py:484 +msgid "The pattern »%s« contains invalid characters." +msgstr "Das Muster »%s« enthält ungültige Zeichen." + #: vmm:34 msgid "" "Usage: %s SUBCOMMAND OBJECT ARGS*\n" @@ -237,95 +241,103 @@ " Unterbefehl Objekt args (* = optional)\n" "\n" -#: vmm:61 vmm:70 vmm:315 vmm:363 +#: vmm:62 vmm:71 vmm:321 vmm:371 msgid "Error" msgstr "Fehler" -#: vmm:80 vmm:360 +#: vmm:81 vmm:368 msgid "Ouch" msgstr "Autsch" -#: vmm:92 +#: vmm:93 msgid "Enter new password: " msgstr "Neues Passwort eingeben: " -#: vmm:95 +#: vmm:96 msgid "Sorry, empty passwords are not permitted" msgstr "Entschuldigung, leere Passwörter sind nicht zulässig" -#: vmm:96 +#: vmm:97 msgid "Retype new password: " msgstr "Neues Passwort wiederholen: " -#: vmm:99 +#: vmm:100 msgid "Sorry, passwords do not match" msgstr "Entschuldigung, die Passwörter stimmen nicht überein" -#: vmm:123 +#: vmm:122 msgid "information" msgstr "Informationen" -#: vmm:133 +#: vmm:132 msgid "Available" msgstr "Verfügbare" -#: vmm:139 vmm:150 +#: vmm:138 vmm:149 vmm:159 msgid "\tNone" msgstr "\tKeine" -#: vmm:143 +#: vmm:142 msgid "Alias information" msgstr "Alias Informationen" -#: vmm:145 +#: vmm:144 msgid "\tMail for %s goes to:" msgstr "\tE-Mails für %s gehen an:" -#: vmm:156 vmm:165 vmm:174 +#: vmm:154 +msgid "Available domains" +msgstr "Verfügbare Domains" + +#: vmm:156 +msgid "Matching domains" +msgstr "Übereinstimmende Domains" + +#: vmm:171 vmm:179 vmm:187 msgid "Missing domain name." msgstr "Kein Domain-Name angegeben." -#: vmm:180 +#: vmm:193 msgid "accounts" msgstr "Accounts" -#: vmm:181 +#: vmm:194 msgid "aliases" msgstr "Aliase" -#: vmm:186 +#: vmm:198 msgid "Missing domain name and new transport." msgstr "Domain-Name und neuer Transport fehlen." -#: vmm:188 +#: vmm:200 msgid "Missing new transport." msgstr "Neuer Transport fehlt." -#: vmm:197 vmm:207 vmm:214 vmm:241 vmm:250 vmm:259 +#: vmm:208 vmm:217 vmm:223 vmm:247 vmm:255 vmm:263 msgid "Missing e-mail address." msgstr "E-Mail-Adresse fehlt." -#: vmm:223 +#: vmm:231 msgid "Missing e-mail address and users name." msgstr "E-Mail-Adresse und der Name des Benutzers fehlen." -#: vmm:225 +#: vmm:233 msgid "Missing users name." msgstr "Name des Benutzers fehlt." -#: vmm:232 +#: vmm:239 msgid "Missing e-mail address and transport." msgstr "E-Mail-Adresse und Transport fehlen." -#: vmm:234 +#: vmm:241 msgid "Missing transport." msgstr "Transport fehlt." -#: vmm:269 +#: vmm:272 msgid "Missing alias address and destination." msgstr "Alias- und Ziel-Adresse fehlen." -#: vmm:276 vmm:283 +#: vmm:278 vmm:284 msgid "Missing alias address" msgstr "Alias-Adresse fehlt." @@ -333,7 +345,7 @@ msgid "Missing userid" msgstr "Keine UID angegeben." -#: vmm:298 +#: vmm:304 msgid "" "\n" "Warnings:" @@ -341,6 +353,6 @@ "\n" "Warnungen:" -#: vmm:357 +#: vmm:365 msgid "Unknown subcommand" msgstr "Unbekannter Unterbefehl" diff -r 6d74e20c5b3b -r 22cc616aef61 po/vmm.pot --- a/po/vmm.pot Sun May 18 04:51:12 2008 +0000 +++ b/po/vmm.pot Sun May 25 03:42:42 2008 +0000 @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2008-05-18 06:21+CEST\n" +"POT-Creation-Date: 2008-05-25 04:58+CEST\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -132,39 +132,39 @@ msgid "Unknown tid specified." msgstr "" -#: VirtualMailManager/VirtualMailManager.py:55 +#: VirtualMailManager/VirtualMailManager.py:54 msgid "" "fix permissions for '%s'\n" "`chmod 0600 %s` would be great." msgstr "" -#: VirtualMailManager/VirtualMailManager.py:62 +#: VirtualMailManager/VirtualMailManager.py:61 msgid "" "You are not root.\n" "\tGood bye!\n" msgstr "" -#: VirtualMailManager/VirtualMailManager.py:76 +#: VirtualMailManager/VirtualMailManager.py:75 msgid "The file \302\273%s\302\253 does not exists." msgstr "" -#: VirtualMailManager/VirtualMailManager.py:98 +#: VirtualMailManager/VirtualMailManager.py:97 msgid "%s is not a directory" msgstr "" -#: VirtualMailManager/VirtualMailManager.py:102 +#: VirtualMailManager/VirtualMailManager.py:101 msgid "%s doesn't exists." msgstr "" -#: VirtualMailManager/VirtualMailManager.py:105 +#: VirtualMailManager/VirtualMailManager.py:104 msgid "%s is not executable." msgstr "" -#: VirtualMailManager/VirtualMailManager.py:139 +#: VirtualMailManager/VirtualMailManager.py:138 msgid "The local part is too long" msgstr "" -#: VirtualMailManager/VirtualMailManager.py:143 +#: VirtualMailManager/VirtualMailManager.py:142 msgid "The local part \302\273%s\302\253 contains invalid characters." msgstr "" @@ -172,54 +172,58 @@ msgid "The domain name is too long." msgstr "" -#: VirtualMailManager/VirtualMailManager.py:185 +#: VirtualMailManager/VirtualMailManager.py:186 msgid "The domain name is invalid." msgstr "" -#: VirtualMailManager/VirtualMailManager.py:193 +#: VirtualMailManager/VirtualMailManager.py:194 msgid "Missing '@' sign in e-mail address \302\273%s\302\253." msgstr "" -#: VirtualMailManager/VirtualMailManager.py:196 +#: VirtualMailManager/VirtualMailManager.py:197 msgid "\302\273%s\302\253 looks not like an e-mail address." msgstr "" -#: VirtualMailManager/VirtualMailManager.py:291 +#: VirtualMailManager/VirtualMailManager.py:292 msgid "FATAL: \"..\" in maildir path detected." msgstr "" -#: VirtualMailManager/VirtualMailManager.py:299 +#: VirtualMailManager/VirtualMailManager.py:300 msgid "FATAL: owner/group mismatch in maildir detected" msgstr "" -#: VirtualMailManager/VirtualMailManager.py:309 +#: VirtualMailManager/VirtualMailManager.py:310 msgid "FATAL: \"..\" in domain directory path detected." msgstr "" -#: VirtualMailManager/VirtualMailManager.py:315 +#: VirtualMailManager/VirtualMailManager.py:316 msgid "FATAL: group mismatch in domain directory detected" msgstr "" -#: VirtualMailManager/VirtualMailManager.py:393 +#: VirtualMailManager/VirtualMailManager.py:394 msgid "" "Configurtion error: \"%s\"\n" "(in section \"connfig\", option \"done\")'\n" "see also: vmm.cfg(5)\n" msgstr "" -#: VirtualMailManager/VirtualMailManager.py:412 +#: VirtualMailManager/VirtualMailManager.py:413 msgid "Invalid section: \302\273%s\302\253" msgstr "" -#: VirtualMailManager/VirtualMailManager.py:426 -#: VirtualMailManager/VirtualMailManager.py:436 +#: VirtualMailManager/VirtualMailManager.py:427 +#: VirtualMailManager/VirtualMailManager.py:437 msgid "Invalid argument: \302\273%s\302\253" msgstr "" -#: VirtualMailManager/VirtualMailManager.py:465 +#: VirtualMailManager/VirtualMailManager.py:466 msgid "Invalid argument" msgstr "" +#: VirtualMailManager/VirtualMailManager.py:484 +msgid "The pattern \302\273%s\302\253 contains invalid characters." +msgstr "" + #: vmm:34 msgid "" "Usage: %s SUBCOMMAND OBJECT ARGS*\n" @@ -228,95 +232,103 @@ "\n" msgstr "" -#: vmm:61 vmm:70 vmm:315 vmm:363 +#: vmm:62 vmm:71 vmm:321 vmm:371 msgid "Error" msgstr "" -#: vmm:80 vmm:360 +#: vmm:81 vmm:368 msgid "Ouch" msgstr "" -#: vmm:92 +#: vmm:93 msgid "Enter new password: " msgstr "" -#: vmm:95 +#: vmm:96 msgid "Sorry, empty passwords are not permitted" msgstr "" -#: vmm:96 +#: vmm:97 msgid "Retype new password: " msgstr "" -#: vmm:99 +#: vmm:100 msgid "Sorry, passwords do not match" msgstr "" -#: vmm:123 +#: vmm:122 msgid "information" msgstr "" -#: vmm:133 +#: vmm:132 msgid "Available" msgstr "" -#: vmm:139 vmm:150 +#: vmm:138 vmm:149 vmm:159 msgid "\tNone" msgstr "" -#: vmm:143 +#: vmm:142 msgid "Alias information" msgstr "" -#: vmm:145 +#: vmm:144 msgid "\tMail for %s goes to:" msgstr "" -#: vmm:156 vmm:165 vmm:174 +#: vmm:154 +msgid "Available domains" +msgstr "" + +#: vmm:156 +msgid "Matching domains" +msgstr "" + +#: vmm:171 vmm:179 vmm:187 msgid "Missing domain name." msgstr "" -#: vmm:180 +#: vmm:193 msgid "accounts" msgstr "" -#: vmm:181 +#: vmm:194 msgid "aliases" msgstr "" -#: vmm:186 +#: vmm:198 msgid "Missing domain name and new transport." msgstr "" -#: vmm:188 +#: vmm:200 msgid "Missing new transport." msgstr "" -#: vmm:197 vmm:207 vmm:214 vmm:241 vmm:250 vmm:259 +#: vmm:208 vmm:217 vmm:223 vmm:247 vmm:255 vmm:263 msgid "Missing e-mail address." msgstr "" -#: vmm:223 +#: vmm:231 msgid "Missing e-mail address and users name." msgstr "" -#: vmm:225 +#: vmm:233 msgid "Missing users name." msgstr "" -#: vmm:232 +#: vmm:239 msgid "Missing e-mail address and transport." msgstr "" -#: vmm:234 +#: vmm:241 msgid "Missing transport." msgstr "" -#: vmm:269 +#: vmm:272 msgid "Missing alias address and destination." msgstr "" -#: vmm:276 vmm:283 +#: vmm:278 vmm:284 msgid "Missing alias address" msgstr "" @@ -324,13 +336,13 @@ msgid "Missing userid" msgstr "" -#: vmm:298 +#: vmm:304 msgid "" "\n" "Warnings:" msgstr "" -#: vmm:357 +#: vmm:365 msgid "Unknown subcommand" msgstr "" diff -r 6d74e20c5b3b -r 22cc616aef61 vmm --- a/vmm Sun May 18 04:51:12 2008 +0000 +++ b/vmm Sun May 25 03:42:42 2008 +0000 @@ -52,6 +52,7 @@ ai aliasinfo alias@domain.tld ad aliasdelete alias@domain.tld user@domain.tld* gu getuser userid + ld listdomains pattern* cf configure section* h help v version @@ -100,7 +101,6 @@ return clear0 def _getOrder(): - global argc order = () if sys.argv[1] in ['di', 'domaininfo']: order = (('domainname', 0), ('gid', 1), ('transport', 0), @@ -118,7 +118,6 @@ order = (('uid', 1), ('gid', 1), ('address', 0)) return order - def _printInfo(info, title): msg = '%s %s' % (title, _('information')) print '%s\n%s' % (msg, '-'*len(msg)) @@ -150,8 +149,24 @@ print _('\tNone') print +def _printDomList(domains): + if argc < 3: + msg = _('Available domains') + else: + msg = _('Matching domains') + print '%s\n%s' % (msg, '-'*len(msg)) + if not len(domains): + print _('\tNone') + else: + for domain in domains: + d = domain[0] + if not d.startswith('xn--'): + print '\t%s' % d + else: + print "\t%s (%s)" % (d, vmm.ace2idna(d)) + print + def domain_add(): - global argc if argc < 3: usage(EXIT.MISSING_ARGS, _('Missing domain name.')) elif argc < 4: @@ -160,7 +175,6 @@ vmm.domain_add(sys.argv[2].lower(), sys.argv[3]) def domain_delete(): - global argc if argc < 3: usage(EXIT.MISSING_ARGS, _('Missing domain name.')) elif argc < 4: @@ -169,7 +183,6 @@ vmm.domain_delete(sys.argv[2].lower(), sys.argv[3]) def domain_info(): - global argc if argc < 3: usage(EXIT.MISSING_ARGS, _('Missing domain name.')) elif argc < 4: @@ -181,7 +194,6 @@ _printUsers(infos[2], _('aliases')) def domain_transport(): - global argc if argc < 3: usage(EXIT.MISSING_ARGS, _('Missing domain name and new transport.')) if argc < 4: @@ -192,7 +204,6 @@ vmm.domain_transport(sys.argv[2].lower(), sys.argv[3], sys.argv[4]) def user_add(): - global argc if argc < 3: usage(EXIT.MISSING_ARGS, _('Missing e-mail address.')) elif argc < 4: @@ -202,14 +213,12 @@ vmm.user_add(sys.argv[2].lower(), password) def user_delete(): - global argc if argc < 3: usage(EXIT.MISSING_ARGS, _('Missing e-mail address.')) else: vmm.user_delete(sys.argv[2].lower()) def user_info(): - global argc if argc < 3: usage(EXIT.MISSING_ARGS, _('Missing e-mail address.')) elif argc < 4: @@ -218,7 +227,6 @@ _printInfo(vmm.user_info(sys.argv[2].lower(), True), 'Account') def user_name(): - global argc if argc < 3: usage(EXIT.MISSING_ARGS, _('Missing e-mail address and users name.')) if argc < 4: @@ -227,7 +235,6 @@ vmm.user_name(sys.argv[2].lower(), sys.argv[3]) def user_transport(): - global argc if argc < 3: usage(EXIT.MISSING_ARGS, _('Missing e-mail address and transport.')) if argc <4: @@ -236,7 +243,6 @@ vmm.user_transport(sys.argv[2].lower(), sys.argv[3]) def user_enable(): - global argc if argc < 3: usage(EXIT.MISSING_ARGS, _('Missing e-mail address.')) elif argc < 4: @@ -245,7 +251,6 @@ vmm.user_enable(sys.argv[2].lower(), sys.argv[3].lower()) def user_disable(): - global argc if argc < 3: usage(EXIT.MISSING_ARGS, _('Missing e-mail address.')) elif argc < 4: @@ -254,7 +259,6 @@ vmm.user_disable(sys.argv[2].lower(), sys.argv[3].lower()) def user_password(): - global argc if argc < 3: usage(EXIT.MISSING_ARGS, _('Missing e-mail address.')) elif argc < 4: @@ -264,21 +268,18 @@ vmm.user_password(sys.argv[2].lower(), password) def alias_add(): - global argc if argc < 4: usage(EXIT.MISSING_ARGS, _('Missing alias address and destination.')) else: vmm.alias_add(sys.argv[2].lower(), sys.argv[3]) def alias_info(): - global argc if argc < 3: usage(EXIT.MISSING_ARGS, _('Missing alias address')) else: _printAliases(sys.argv[2], vmm.alias_info(sys.argv[2].lower())) def alias_delete(): - global argc if argc < 3: usage(EXIT.MISSING_ARGS, _('Missing alias address')) elif argc < 4: @@ -287,12 +288,17 @@ vmm.alias_delete(sys.argv[2].lower(), sys.argv[3].lower()) def user_byID(): - global argc if argc < 3: usage(EXIT.MISSING_ARGS, _('Missing userid')) else: _printInfo(vmm.user_byID(sys.argv[2]), 'Account') +def domain_list(): + if argc < 3: + _printDomList(vmm.domain_list()) + else: + _printDomList(vmm.domain_list(sys.argv[2].lower())) + def showWarnings(): if vmm.hasWarnings(): print _('\nWarnings:') @@ -347,6 +353,8 @@ alias_delete() elif sys.argv[1] in ['gu', 'getuser']: user_byID() + elif sys.argv[1] in ['ld', 'listdomains']: + domain_list() elif sys.argv[1] in ['h', 'help']: usage() elif sys.argv[1] in ['v', 'version']: