diff options
| author | Barry Warsaw | 2009-09-19 16:51:15 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2009-09-19 16:51:15 -0400 |
| commit | a5456442682ff20c4b0d3a9d166d5fa9bf06a7de (patch) | |
| tree | 7ad2aec53b1acc53d879e063ef7339c2302284c7 /src/mailman/bin/inject.py | |
| parent | ca84b1a8852a86464184586441c3d0fd66c879b1 (diff) | |
| download | mailman-a5456442682ff20c4b0d3a9d166d5fa9bf06a7de.tar.gz mailman-a5456442682ff20c4b0d3a9d166d5fa9bf06a7de.tar.zst mailman-a5456442682ff20c4b0d3a9d166d5fa9bf06a7de.zip | |
Diffstat (limited to 'src/mailman/bin/inject.py')
| -rw-r--r-- | src/mailman/bin/inject.py | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/src/mailman/bin/inject.py b/src/mailman/bin/inject.py deleted file mode 100644 index ebe7584e5..000000000 --- a/src/mailman/bin/inject.py +++ /dev/null @@ -1,91 +0,0 @@ -# Copyright (C) 2002-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/>. - -import os -import sys - -from email import message_from_string -from zope.component import getUtility - -from mailman import Utils -from mailman.configuration import config -from mailman.i18n import _ -from mailman.inject import inject_text -from mailman.interfaces.listmanager import IListManager -from mailman.message import Message -from mailman.options import SingleMailingListOptions - - - -class ScriptOptions(SingleMailingListOptions): - usage=_("""\ -%prog [options] [filename] - -Inject a message from a file into Mailman's incoming queue. 'filename' is the -name of the plaintext message file to inject. If omitted, or the string '-', -standard input is used. -""") - - def add_options(self): - super(ScriptOptions, self).add_options() - self.parser.add_option( - '-q', '--queue', - type='string', help=_("""\ -The name of the queue to inject the message to. The queuename must be one of -the directories inside the qfiles directory. If omitted, the incoming queue -is used.""")) - - def sanity_check(self): - if not self.options.listname: - self.parser.error(_('Missing listname')) - if len(self.arguments) == 0: - self.filename = '-' - elif len(self.arguments) > 1: - self.parser.print_error(_('Unexpected arguments')) - else: - self.filename = self.arguments[0] - - - -def main(): - options = ScriptOptions() - options.initialize() - - if options.options.queue is None: - qdir = config.INQUEUE_DIR - else: - qdir = os.path.join(config.QUEUE_DIR, options.options.queue) - if not os.path.isdir(qdir): - options.parser.error(_('Bad queue directory: $qdir')) - - fqdn_listname = options.options.listname - mlist = getUtility(IListManager).get(fqdn_listname) - if mlist is None: - options.parser.error(_('No such list: $fqdn_listname')) - - if options.filename == '-': - message_text = sys.stdin.read() - else: - with open(options.filename) as fp: - message_text = fp.read() - - inject_text(mlist, message_text, qdir=qdir) - - - -if __name__ == '__main__': - main() |
