3
from storm.locals import *
4
from email import message_from_file, message_from_string
5
from HyperArch import Article,T
6
from i18n import initialize
9
from core.i18n import _
10
#command: /bin/echo "/usr/bin/mhonarc -add -dbfile $PRIVATE_ARCHIVE_FILE_DIR/${listname}.mbox/mhonarc.db
11
#-outdir $VAR_DIR/mhonarc/${listname} -stderr $LOG_DIR/mhonarc -stdout $LOG_DIR/mhonarc -spammode -umask 022"
13
#$prefix/archives/private/yourmaillist.mbox/yourmaillist.mbox
15
#add a message into archives
16
def add(args, archiver):
17
#take msg as string from stdin
18
# msg = message_from_string("""\
19
#From: "Dushyant" <db1@lists.example.org>
20
#To: test14@lists.example.com
21
#Subject: Re: new2 archived message
24
#Hi. this is the fist message
26
msg = sys.stdin.read()
28
msg = message_from_string(msg)
30
archiver.archiveMsg(msg)
32
#convert a mbox file into sqlite db
33
def convert(args, archiver):
34
archiver.mboxToDB(args.mbox)
38
# Create the basic parser and add all globally common options.
39
parser = argparse.ArgumentParser(
40
description="""ArchiverUI: Archives and manages messages from mailman mlists""",
41
formatter_class=argparse.RawDescriptionHelpFormatter)
45
action='version', version='1.0',
46
help=_('Print this version string and exit'))
51
Configuration file to use. If not given, the environment variable
52
MAILMAN_CONFIG_FILE is consulted and used if set. If neither are
53
given, a default configuration file is loaded."""))
56
'-basedir', help=_('Specify the base directory which contains archives'))
59
'-listname', help=_('Specify the listname to which this message belongs'))
61
subparsers = parser.add_subparsers(title='Commands',
62
description='valid subcommands',
63
help='additional help')
65
add_parser = subparsers.add_parser('add', help='add a message to the archives')
66
add_parser.set_defaults(func=add)
68
convert_parser = subparsers.add_parser('convert', help='convert a mbox file containing messages into archives db')
69
convert_parser.set_defaults(func=convert)
70
convert_parser.add_argument(
71
'-mbox', help=_('Specify the mbox file to be updated'))
73
args = parser.parse_args()
75
if len(args.__dict__) == 0:
76
# No arguments or subcommands were given.
79
# # Before actually performing the subcommand, we need to initialize the
80
# # Mailman system, and in particular, we must read the configuration file.
81
# config_file = os.getenv('MAILMAN_CONFIG_FILE')
82
# if config_file is None:
83
# config_file = args.config
84
# initialize(config_file)
85
# # Perform the subcommand option.
88
archiver = T(basedir = args.basedir, mlist = args.listname)
90
# args['msg'] = sys.stdin.read()
91
args.func(args, archiver)
93
if __name__ == "__main__":
b'\\ No newline at end of file'