Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mailman-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
irt-public
mailman-tools
Commits
b88015b6
Commit
b88015b6
authored
6 years ago
by
Conrad Holmberg
Browse files
Options
Downloads
Patches
Plain Diff
Added more arguments to sort by members.
parent
ab72e390
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
manage_users.py
+27
-29
27 additions, 29 deletions
manage_users.py
with
27 additions
and
29 deletions
manage_users.py
+
27
−
29
View file @
b88015b6
...
...
@@ -8,6 +8,9 @@ try:
except
ImportError
:
import
simplejson
as
json
def
print_email_lists
(
email_lists
):
for
eamil_list
in
email_lists
:
print
email_list
if
__name__
==
'
__main__
'
:
parser
=
argparse
.
ArgumentParser
(
description
=
"
Dump Mailing List based on alias.
"
)
...
...
@@ -19,45 +22,40 @@ if __name__ == '__main__':
LIST_NAME
=
'
apachesvn@lists.med.stanford.edu
'
# just a tesing default
# user invoked variables
parser
.
add_argument
(
'
--
dump
'
,
action
=
'
store_true
'
,
default
=
False
,
help
=
'
Dumps a full member list
.
'
)
parser
.
add_argument
(
'
--list
'
,
help
=
'
Shows the email lists. (i.e.,apachesvn@lists.med.stanford.edu )
'
)
parser
.
add_argument
(
'
--
dump
'
,
action
=
'
store_true
'
,
default
=
False
,
help
=
'
Dumps a full member list
.
'
)
parser
.
add_argument
(
'
--
members
'
,
help
=
'
Dumps a full member
s
list
from an email list <setting_name>=<setting_value>
'
)
parser
.
add_argument
(
'
--list
'
,
action
=
'
store_true
'
,
default
=
False
,
help
=
'
Shows the email lists. (i.e.,apachesvn@lists.med.stanford.edu )
'
)
parser
.
add_argument
(
'
--
file
'
,
help
=
'
Places input into a file
.
'
)
# Add arguments for env variables
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
)
# Parse out the command line arguments
args
=
parser
.
parse_args
()
# Set the mailman client
client
=
Client
(
args
.
core_uri
,
args
.
core_user
,
args
.
core_password
)
ml
=
client
.
get_list
(
LIST_NAME
)
# append the mail lists to an array from client
email_lists
=
[]
for
mlist
in
client
.
lists
:
email_lists
.
append
(
mlist
.
fqdn_listname
)
if
args
.
dump
:
members_hash
=
{}
for
member
in
ml
.
members
:
#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
)
# lists members of a list
if
args
.
members
:
members_hash
=
{}
email_list
=
args
.
members
# get lists
if
email_list
in
email_lists
:
ml
=
client
.
get_list
(
LIST_NAME
)
elif
email_list
.
upper
()
==
'
ALL
'
:
print
"
Watch out thsi prints all lists.
"
else
:
sys
.
exit
(
'
Error: Email list
"'
+
email_list
+
'"
does not exist in domain
'
+
args
.
core_uri
+
"
\n
See List
\n
"
+
print_email_lists
(
email_lists
))
elif
args
.
list
:
for
mlist
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 != '-':
# option just to show lists
print_email_lists
(
email_lists
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment