------------------------------------------------------------
revno: 6765
committer: Barry Warsaw <[email protected]>
branch nick: 3.0
timestamp: Wed 2009-08-12 00:31:37 -0400
message:
  'mailman info' command.
added:
  src/mailman/commands/cli_info.py
  src/mailman/commands/docs/info.txt
modified:
  src/mailman/app/finder.py
  src/mailman/database/__init__.py


--
lp:mailman
https://code.launchpad.net/~mailman-coders/mailman/3.0

Your team Mailman Checkins is subscribed to branch lp:mailman.
To unsubscribe from this branch go to 
https://code.launchpad.net/~mailman-coders/mailman/3.0/+edit-subscription.
=== modified file 'src/mailman/app/finder.py'
--- src/mailman/app/finder.py	2009-07-01 03:14:26 +0000
+++ src/mailman/app/finder.py	2009-08-12 04:31:37 +0000
@@ -54,6 +54,9 @@
         if not hasattr(module, '__all__'):
             continue
         for name in module.__all__:
-            component = getattr(module, name)
+            missing = object()
+            component = getattr(module, name, missing)
+            assert component is not missing, (
+                '%s has bad __all__: %s' % (module, name))
             if interface.implementedBy(component):
                 yield component

=== added file 'src/mailman/commands/cli_info.py'
--- src/mailman/commands/cli_info.py	1970-01-01 00:00:00 +0000
+++ src/mailman/commands/cli_info.py	2009-08-12 04:31:37 +0000
@@ -0,0 +1,68 @@
+# 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/>.
+
+"""Information about this Mailman instance."""
+
+from __future__ import absolute_import, unicode_literals
+
+__metaclass__ = type
+__all__ = [
+    'Info'
+    ]
+
+
+import sys
+
+from zope.interface import implements
+
+from mailman.config import config
+from mailman.i18n import _
+from mailman.interfaces.command import ICLISubCommand
+from mailman.version import MAILMAN_VERSION_FULL
+
+
+
+class Info:
+    """The `info` subcommand."""
+
+    implements(ICLISubCommand)
+
+    def add(self, parser, subparser):
+        """See `ICLISubCommand`."""
+        info_parser = subparser.add_parser(
+            'info', help=_('Information about this Mailman instance.'))
+        info_parser.set_defaults(func=self.process)
+        info_parser.add_argument(
+            '-o', '--output',
+            action='store', help=_("""\
+            File to send the output to.  If not given, standard output is
+            used."""))
+
+    def process(self, args):
+        """See `ICLISubCommand`."""
+
+        if args.output is None:
+            output = sys.stdout
+        else:
+            # We don't need to close output because that will happen
+            # automatically when the script exits.
+            output = open(args.output, 'w')
+
+        print >> output, MAILMAN_VERSION_FULL
+        print >> output, 'Python', sys.version
+        print >> output, 'config file:', config.filename
+        print >> output, 'db url:', config.db.url

=== added file 'src/mailman/commands/docs/info.txt'
--- src/mailman/commands/docs/info.txt	1970-01-01 00:00:00 +0000
+++ src/mailman/commands/docs/info.txt	2009-08-12 04:31:37 +0000
@@ -0,0 +1,35 @@
+===================
+Getting information
+===================
+
+You can get information about Mailman's environment by using the command line
+script 'mailman info'.  By default, the info is printed to standard output.
+
+    >>> from mailman.commands.cli_info import Info
+    >>> command = Info()
+
+    >>> class FakeArgs:
+    ...     output = None
+    >>> args = FakeArgs()
+
+    >>> command.process(args)
+    GNU Mailman 3...
+    Python ...
+    ...
+    config file: .../test.cfg
+    db url: sqlite:.../mailman.db
+
+By passing in the -o/--output option, you can print the info to a file.
+
+    >>> from mailman.config import config
+    >>> import os
+    >>> output_path = os.path.join(config.VAR_DIR, 'output.txt')
+    >>> args.output = output_path
+    >>> command.process(args)
+    >>> with open(output_path) as fp:
+    ...     print fp.read()
+    GNU Mailman 3...
+    Python ...
+    ...
+    config file: .../test.cfg
+    db url: sqlite:.../mailman.db

=== modified file 'src/mailman/database/__init__.py'
--- src/mailman/database/__init__.py	2009-08-08 04:45:21 +0000
+++ src/mailman/database/__init__.py	2009-08-12 04:31:37 +0000
@@ -55,6 +55,7 @@
     implements(IDatabase)
 
     def __init__(self):
+        self.url = None
         self.list_manager = None
         self.user_manager = None
         self.message_store = None
@@ -105,6 +106,7 @@
         # ensuring the right permissions.  We only try to do this for SQLite
         # engines, and yes, we could have chmod'd the file after the fact, but
         # half dozen and all...
+        self.url = url
         touch(url)
         database = create_database(url)
         store = Store(database, GenerationalCache())

_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to