diff options
| author | Barry Warsaw | 2009-04-01 15:14:24 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2009-04-01 15:14:24 -0500 |
| commit | 9ff1079e0efc68fc64b91c6d0728f933df84abc7 (patch) | |
| tree | 0a603521d2a859854d6f0b41e9e0dcbcccccad35 | |
| parent | b4d87c122b372e7805d9bbc712ccffea46c18d75 (diff) | |
| download | mailman-9ff1079e0efc68fc64b91c6d0728f933df84abc7.tar.gz mailman-9ff1079e0efc68fc64b91c6d0728f933df84abc7.tar.zst mailman-9ff1079e0efc68fc64b91c6d0728f933df84abc7.zip | |
| -rw-r--r-- | buildout.cfg | 1 | ||||
| -rw-r--r-- | src/mailman/bin/version.py | 35 | ||||
| -rw-r--r-- | src/mailman/core/system.py | 48 | ||||
| -rw-r--r-- | src/mailman/docs/version.txt | 26 | ||||
| -rw-r--r-- | src/mailman/interfaces/domain.py | 2 | ||||
| -rw-r--r-- | src/mailman/interfaces/system.py | 39 | ||||
| -rw-r--r-- | src/mailman/version.py | 1 |
7 files changed, 133 insertions, 19 deletions
diff --git a/buildout.cfg b/buildout.cfg index 54774fada..e98e4a81d 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -13,6 +13,7 @@ eggs = argparse lazr.config lazr.delegates + /Users/barry/projects/lazr/lazr.restful locknix mailman munepy diff --git a/src/mailman/bin/version.py b/src/mailman/bin/version.py index 0fb2c5a5b..af888f0f6 100644 --- a/src/mailman/bin/version.py +++ b/src/mailman/bin/version.py @@ -15,32 +15,31 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see <http://www.gnu.org/licenses/>. -import optparse +"""Print the Mailman version.""" -from mailman import version +from __future__ import absolute_import, unicode_literals + +__metaclass__ = type +__all__ = [ + 'main', + ] + + +from mailman.core.system import system from mailman.i18n import _ +from mailman.options import Options -def parseargs(): - parser = optparse.OptionParser(version=version.MAILMAN_VERSION, - usage=_("""\ +class ScriptOptions(Options): + usage = _("""\ %prog -Print the Mailman version and exit.""")) - opts, args = parser.parse_args() - if args: - parser.error(_('Unexpected arguments')) - return parser, opts, args +Print the Mailman version and exit.""") def main(): - parser, opts, args = parseargs() - # Yes, this is kind of silly - print _('Using $version.MAILMAN_VERSION ($version.CODENAME)') - - - -if __name__ == '__main__': - main() + options = ScriptOptions() + options.initialize() + print _('Using $system.mailman_version') diff --git a/src/mailman/core/system.py b/src/mailman/core/system.py new file mode 100644 index 000000000..0f6d0834f --- /dev/null +++ b/src/mailman/core/system.py @@ -0,0 +1,48 @@ +# Copyright (C) 2009 by the Free Software Foundation, Inc. +# +# This file is part of GNU Mailman. +# +# GNU Mailman is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# GNU Mailman. If not, see <http://www.gnu.org/licenses/>. + +"""System information.""" + +from __future__ import absolute_import, unicode_literals + +__metaclass__ = type +__all__ = [ + 'system', + ] + + +import sys +from zope.interface import implements + +from mailman import version +from mailman.interfaces.system import ISystem + + + +class System: + implements(ISystem) + + @property + def mailman_version(self): + return version.MAILMAN_VERSION_FULL + + @property + def python_version(self): + return sys.version + + +system = System() diff --git a/src/mailman/docs/version.txt b/src/mailman/docs/version.txt new file mode 100644 index 000000000..3ed0ce28c --- /dev/null +++ b/src/mailman/docs/version.txt @@ -0,0 +1,26 @@ +System versions +=============== + +Mailman system information is available through the System object, which +implements the ISystem interface. + + >>> from mailman.interfaces.system import ISystem + >>> from mailman.core.system import system + >>> from zope.interface.verify import verifyObject + + >>> verifyObject(ISystem, system) + True + +The Mailman version is available via the system object. + + >>> print system.mailman_version + GNU Mailman ... + +The Python version running underneath is also available via the system +object. + + # The entire python_version string is variable, so this is the best test + # we can do. + >>> import sys + >>> system.python_version == sys.version + True diff --git a/src/mailman/interfaces/domain.py b/src/mailman/interfaces/domain.py index 8c2a27e79..773290bc5 100644 --- a/src/mailman/interfaces/domain.py +++ b/src/mailman/interfaces/domain.py @@ -61,7 +61,7 @@ class IDomain(Interface): contact_address = Attribute( """The contact address for the human at this domain. - E.g. postmaster@python.org. + E.g. postmaster@example.com :type: string """) diff --git a/src/mailman/interfaces/system.py b/src/mailman/interfaces/system.py new file mode 100644 index 000000000..da7d019e6 --- /dev/null +++ b/src/mailman/interfaces/system.py @@ -0,0 +1,39 @@ +# Copyright (C) 2009 by the Free Software Foundation, Inc. +# +# This file is part of GNU Mailman. +# +# GNU Mailman is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# GNU Mailman. If not, see <http://www.gnu.org/licenses/>. + +"""System information.""" + +from __future__ import absolute_import, unicode_literals + +__metaclass__ = type +__all__ = [ + 'ISystem', + ] + + +from zope.interface import Interface, Attribute + + + +class ISystem(Interface): + """Information about the Mailman system.""" + + mailman_version = Attribute( + """The GNU Mailman version, as a string.""") + + python_version = Attribute( + """The version of Python running Mailman, as a string.""") diff --git a/src/mailman/version.py b/src/mailman/version.py index c22fcc78d..68034239a 100644 --- a/src/mailman/version.py +++ b/src/mailman/version.py @@ -46,3 +46,4 @@ QFILE_SCHEMA_VERSION = 3 # Printable version string used by command line scripts MAILMAN_VERSION = 'GNU Mailman ' + VERSION +MAILMAN_VERSION_FULL = MAILMAN_VERSION + ' (' + CODENAME + ')' |
