Newer
Older
#!/bin/env python
from mailmanclient import Client
import os
import sys
import argparse
try:
import json
except ImportError:
import simplejson as json
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Dump Mailing List based on alias.")
CORE_URI = os.environ.get('MAILMAN_CORE_URI','http://mailman-core:8001/3.1')
CORE_USER = os.environ.get('MAILMAN_REST_USER', 'restadmin')
CORE_PASS = os.environ.get('MAILMAN_REST_PASSWORD', 'restpass')
LIST_NAME= 'apachesvn@lists.med.stanford.edu' # just a tesing default
# user invoked variables
parser.add_argument('--dump', action='store_true', default=False)
parser.add_argument('--list', help="Shows the email lists. (i.e.,apachesvn@lists.med.stanford.edu )")
parser.add_argument('--core-uri', dest='core_uri',default=CORE_URI)
parser.add_argument('--rest-user', dest='core_user',default=CORE_USER)
parser.add_argument('--rest-password', dest='core_password',default=CORE_PASS)
client = Client(args.core_uri, args.core_user, args.core_password)
if args.dump:
#members_hash['user']=member.user
#members_hash['address']= member.address
#members_hash['list_id']= member.list_id
#members_hash['email']= member.email
members_hash['address'] = member.rest_data
#held_data[held.request_id] = held.rest_data
#members_hash['preferences']= member.preferences
print json.dumps(members_hash, indent=2)
elif args.list:
for mlists in client.lists:
print(mlist.fqdn_listname)
# elif args.set:
# (setting, value) = args.set.split('=', 1)
# set_value(ml, setting, value)
# elif args.update:
# if args.update == '-':
# f = sys.stdin
# else:
# f = open(args.update, 'r')
# updated_settings = json.loads(f.read())
# update_settings(ml, updated_settings)
# if args.update != '-':