From 27268d44cf8daecd5b32acb347a43b4c52ab2fa1 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Wed, 10 Sep 2014 22:33:49 -0400 Subject: [PATCH] WS and style cleanup Signed-off-by: Dan Scott --- tools/patron-load/ldap_osrf_sync | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tools/patron-load/ldap_osrf_sync b/tools/patron-load/ldap_osrf_sync index 9a1c13413d..95e143e466 100755 --- a/tools/patron-load/ldap_osrf_sync +++ b/tools/patron-load/ldap_osrf_sync @@ -3,19 +3,19 @@ # Copyright (C) 2011 Laurentian University # Dan Scott # -# +# # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. """ -Synchronize Evergreen user accounts with an LDAP directory via OpenSRF +Synchronize Evergreen user accounts with an LDAP directory via OpenSRF LDAP and OpenSRF authentication information is stored in a separate Python file (credentials.py) and imported to avoid storing credentials in the VCS. @@ -25,7 +25,7 @@ file (credentials.py) and imported to avoid storing credentials in the VCS. 2. For each new LDAP record, check to see if the record exists in Evergreen (matching on ident_value, usrname, email). - + If not, create a new account with barcode. 3. Push the new barcode back into the LDAP directory. @@ -238,13 +238,13 @@ def load_idl(): server. One could a HEAD request to do some smarter caching, perhaps. """ - + parser = oils.utils.idl.IDLParser() idlfile = tempfile.TemporaryFile() # Get the fm_IDL.xml file from the server try: - idl = urllib2.urlopen('%s://%s/%s' % + idl = urllib2.urlopen('%s://%s/%s' % (credentials.OSRF_HTTP, ARGS.eg_host, credentials.IDL_URL) ) idlfile.write(idl.read()) @@ -270,7 +270,7 @@ def osrf_login(username, password, workstation=None): try: seed = osrf_request( - 'open-ils.auth', + 'open-ils.auth', 'open-ils.auth.authenticate.init', username).send() except Exception, exc: print exc @@ -280,11 +280,11 @@ def osrf_login(username, password, workstation=None): result = osrf_request( 'open-ils.auth', - 'open-ils.auth.authenticate.complete', - { 'workstation' : workstation, + 'open-ils.auth.authenticate.complete', { + 'workstation' : workstation, 'username' : username, 'password' : password, - 'type' : 'staff' + 'type' : 'staff' }).send() evt = oils.event.Event.parse_event(result) @@ -362,7 +362,7 @@ def get_barcode(auth, uid): evt = oils.event.Event.parse_event(user) if evt and not evt.success: raise AuthException(evt.text_code) - + if not user: return None @@ -382,7 +382,7 @@ def find_evergreen_user(auth, user): search_depth = 1 include_inactive = True - print("Trying to find user: %s %s %s" % + print("Trying to find user: %s %s %s" % (user.ident_value, user.email, user.usrname) ) @@ -402,7 +402,7 @@ def find_evergreen_user(auth, user): ).send() if by_email and len(by_email): - return by_email[0] + return by_email[0] by_usrname = osrf_request( 'open-ils.actor', search_method, @@ -496,7 +496,7 @@ def create_evergreen_user(auth, user): # Generate a barcode for the user try: barcode = osrf_request( - 'open-ils.actor', 'open-ils.actor.generate_patron_barcode', + 'open-ils.actor', 'open-ils.actor.generate_patron_barcode', auth, usr.id(), '000070' ).send() except Exception, exc: @@ -508,13 +508,13 @@ def create_evergreen_user(auth, user): print >> sys.stderr, "Create barcode failed for %s: %s" % ( AuthException(evt.text_code), user.usrname) return None - + user.barcode = barcode['evergreen.actor_update_barcode'] create_stat_cats(egau, user) print("Created: %s with barcode %s" % (egau.usrname(), user.barcode)) - + return egau.usrname(), user.barcode def update_ldap_barcode(con, user): @@ -568,24 +568,24 @@ def ldap_query(con, auth): 'lulModifyTimestamp' ] - if (ARGS.query_date): + if ARGS.query_date: ldap_filter = '(&%s(lulPrimaryAffiliation=*)(createTimestamp>=%s))' % ( '(objectclass=lulEduPerson)', ARGS.query_date ) - elif (ARGS.query_cn): + elif ARGS.query_cn: ldap_filter = '(&%s(cn=%s))' % ( '', ARGS.query_cn ) - elif (ARGS.query_sn): + elif ARGS.query_sn: ldap_filter = '(&%s(sn=%s))' % ( '(objectclass=lulEduPerson)', ARGS.query_sn ) - elif (ARGS.query_id): + elif ARGS.query_id: ldap_filter = '(&%s(lulColleagueId=%s))' % ( '(objectclass=lulEduPerson)', ARGS.query_id ) if not ldap_filter: - return + return return find_ldap_users(con, ldap_filter, attributes, auth) def parse_args(): -- 2.11.0