Skip to content

Commit

Permalink
grouper_delta_user: Add log keyword option #57
Browse files Browse the repository at this point in the history
Update user_update to pass log
  • Loading branch information
astrochun committed Sep 29, 2020
1 parent ab475aa commit d0283f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
9 changes: 6 additions & 3 deletions requiam/grouper_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .delta import Delta
from .manual_override import update_entries
from .commons import figshare_stem
from .logger import log_stdout


class GrouperQuery(object):
Expand Down Expand Up @@ -87,7 +88,7 @@ def figshare_group(group, root_stem, production=True):


def grouper_delta_user(group, stem, netid, uaid, action,
grouper_dict, delta_dict, log, production=True):
grouper_dict, delta_dict, log=None, production=True):
"""
Purpose:
Construct a Delta object for addition/deletion based for a specified
Expand All @@ -111,15 +112,17 @@ def grouper_delta_user(group, stem, netid, uaid, action,
For logging
:param production: Bool to use production stem. Otherwise a stage/test is used. Default: True
:return d: Delta object class
"""

if isinstance(log, type(None)):
log = log_stdout()

grouper_query = figshare_group(group, stem, production=production)
gq = GrouperQuery(**grouper_dict, grouper_group=grouper_query)

member_set = gq.members
member_set = update_entries(member_set, netid, uaid, action, log)
member_set = update_entries(member_set, netid, uaid, action, log=log)

d = Delta(ldap_members=member_set,
grouper_query_instance=gq,
Expand Down
12 changes: 6 additions & 6 deletions scripts/user_update
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ if __name__ == '__main__':
d = grouper_delta_user('active', '',
current_dict['not_active']['netid'],
set(current_dict['not_active']['uaid']),
'add', grouper_dict, delta_dict, log)
'add', grouper_dict, delta_dict, log=None)

if args.sync:
log.info('synchronizing ...')
Expand All @@ -278,7 +278,7 @@ if __name__ == '__main__':
d = grouper_delta_user('active', '',
current_dict['active']['netid'],
set(current_dict['active']['uaid']),
'remove', grouper_dict, delta_dict, log)
'remove', grouper_dict, delta_dict, log=None)

if args.sync:
log.info('synchronizing ...')
Expand Down Expand Up @@ -306,7 +306,7 @@ if __name__ == '__main__':

d = grouper_delta_user(current_portal, 'portal',
not_portal_netid[i], {not_portal_uaid[i]},
'remove', grouper_dict, delta_dict, log)
'remove', grouper_dict, delta_dict, log=None)

if args.sync:
log.info('synchronizing ...')
Expand All @@ -321,7 +321,7 @@ if __name__ == '__main__':
d = grouper_delta_user(vargs['portal'], 'portal',
current_dict['not_portal']['netid'],
current_dict['not_portal']['uaid'],
'add', grouper_dict, delta_dict, log)
'add', grouper_dict, delta_dict, log=None)

if args.sync:
log.info('synchronizing ...')
Expand Down Expand Up @@ -362,7 +362,7 @@ if __name__ == '__main__':

d = grouper_delta_user(current_quota, 'quota',
not_quota_netid[i], {not_quota_uaid[i]},
'remove', grouper_dict, delta_dict, log)
'remove', grouper_dict, delta_dict, log=None)

if args.sync:
log.info('synchronizing ...')
Expand All @@ -377,7 +377,7 @@ if __name__ == '__main__':
d = grouper_delta_user(vargs['quota'], 'quota',
current_dict['not_quota']['netid'],
current_dict['not_quota']['uaid'],
'add', grouper_dict, delta_dict, log)
'add', grouper_dict, delta_dict, log=None)

if args.sync:
log.info('synchronizing ...')
Expand Down

0 comments on commit d0283f9

Please sign in to comment.