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
d7217d03
Commit
d7217d03
authored
6 years ago
by
Conrad Holmberg
Browse files
Options
Downloads
Patches
Plain Diff
manage_members can now subscribe from a restore file.
parent
8682d0e7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
manage_members.py
+16
-13
16 additions, 13 deletions
manage_members.py
with
16 additions
and
13 deletions
manage_members.py
+
16
−
13
View file @
d7217d03
...
...
@@ -51,35 +51,38 @@ def dump_fqdn_members(client,ml_fqdn ):
print
json
.
dumps
(
members_hash
,
indent
=
2
)
# end dump_fqdn_memberss
def
restore_members
(
input
_file
):
def
restore_members
(
member
_file
):
"""
Creates Code to Restore Members of a source/target email list.
"""
tgt_list
=
None
tgt_list
=
None
#email list of target members
if
input
_file
==
'
-
'
:
if
member
_file
==
'
-
'
:
json_file
=
sys
.
stdin
else
:
user_file
=
input_file
with
open
(
user_file
)
as
json_file
:
with
open
(
member_file
)
as
json_file
:
data
=
json
.
load
(
json_file
)
#print json.dumps(datam, indent=2)
# subscribe members from source into target
for
src_member
in
data
[
'
members
'
]:
# get target the email list
if
(
tgt_list
is
None
):
tgt_list
=
client
.
get_list
(
member
[
'
list_fqdn
'
])
tgt_list
=
client
.
get_list
(
src_
member
[
'
list_fqdn
'
])
# Get members from the current email list
tgt_members
=
[
str
(
m
.
email
)
for
m
in
ml
.
members
]
# check on display_name is null or not
if
src_member
not
in
tgt_members
:
tgt_members
=
[
str
(
m
.
email
)
for
m
in
tgt_list
.
members
]
if
src_member
[
'
email
'
]
not
in
tgt_members
:
# check on display_name is null or not
if
(
src_member
[
'
display_name
'
]
is
not
None
):
display_name
=
src_member
[
'
display_name
'
]
else
:
display_name
=
'
display_name=None
'
# subscribe member to list
t
est_one
.
subscribe
(
src_member
[
'
email
'
],
t
gt_list
.
subscribe
(
src_member
[
'
email
'
],
display_name
,
pre_verified
=
True
)
pre_verified
=
True
,
pre_confirmed
=
True
,
pre_approved
=
True
)
# set the preferences
tgt_prefs
=
tgt_list
.
get_member
(
src_member
[
'
email
'
]).
preferences
...
...
@@ -118,7 +121,7 @@ if __name__ == '__main__':
# Parse out the command line arguments
#
args = parser.parse_args()
args
=
parser
.
parse_args
()
# Set the mailman client
client
=
Client
(
args
.
core_uri
,
args
.
core_user
,
args
.
core_password
)
...
...
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