1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
# -*- coding: iso-8859-1 -*-
"""
MoinMoin - MailImport script
@copyright: 2006 MoinMoin:AlexanderSchremmer
@license: GNU GPL, see COPYING for details.
"""
import sys
import xmlrpclib
from MoinMoin.script import MoinScript, fatal
input = sys.stdin
class PluginScript(MoinScript):
"""\
Purpose:
========
This tool allows you to import mail into the wiki.
Detailed Instructions:
======================
General syntax: moin [options] maint mailimport [mailimport-options]
[options] usually should be:
--config-dir=/path/to/my/cfg/ --wiki-url=http://wiki.example.org/
[mailimport-options] see below:
0. Verify that you have a mailimportconf.py configuration file.
1. To import mail from the file '/mymail'
moin ... xmlrpc mailimport << /mymail
OR
cat /mymail | moin ... xmlrpc mailimport
"""
def __init__(self, argv, def_values):
MoinScript.__init__(self, argv, def_values)
def mainloop(self):
try:
import mailimportconf
except ImportError:
fatal("Could not find the file mailimportconf.py. Maybe you want to use the --config-dir=... option?")
secret = mailimportconf.mail_import_secret
url = mailimportconf.mail_import_url
s = xmlrpclib.ServerProxy(url)
result = s.ProcessMail(secret, xmlrpclib.Binary(input.read()))
if result != "OK":
print >> sys.stderr, result
|