Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hshetl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tools
hshetl
Commits
f0384baf
Commit
f0384baf
authored
10 years ago
by
schulmax
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Improves ldap loader update logging
parent
c6faa401
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
hshetl/loaders.py
+13
-2
13 additions, 2 deletions
hshetl/loaders.py
with
13 additions
and
2 deletions
hshetl/loaders.py
+
13
−
2
View file @
f0384baf
...
@@ -382,10 +382,10 @@ class LdapLoader(AbstractLoader):
...
@@ -382,10 +382,10 @@ class LdapLoader(AbstractLoader):
attributes
=
modlist
.
modifyModlist
(
old_entity_dict
,
entity_dict
)
attributes
=
modlist
.
modifyModlist
(
old_entity_dict
,
entity_dict
)
try
:
try
:
if
self
.
dry
:
if
self
.
dry
:
logging
.
info
(
'
Would modify dn {} with {}
'
.
format
(
dn
,
s
tr
(
attributes
)))
logging
.
info
(
'
Would modify dn {} with {}
'
.
format
(
dn
,
s
elf
.
_generate_modify_logging
(
attributes
,
old_entity_dict
,
entity_dict
)))
else
:
else
:
connection
.
modify_s
(
dn
,
attributes
)
connection
.
modify_s
(
dn
,
attributes
)
logging
.
info
(
'
Modified dn {} with {}
'
.
format
(
dn
,
s
tr
(
attributes
)))
logging
.
info
(
'
Modified dn {} with {}
'
.
format
(
dn
,
s
elf
.
_generate_modify_logging
(
attributes
,
old_entity_dict
,
entity_dict
)))
except
Exception
,
e
:
except
Exception
,
e
:
logging
.
warn
(
'
Update failed for dn
\'
'
+
dn
+
'
\'
:
'
+
str
(
e
))
logging
.
warn
(
'
Update failed for dn
\'
'
+
dn
+
'
\'
:
'
+
str
(
e
))
...
@@ -438,3 +438,14 @@ class LdapLoader(AbstractLoader):
...
@@ -438,3 +438,14 @@ class LdapLoader(AbstractLoader):
elif
element
==
None
:
elif
element
==
None
:
data
[
key
]
=
''
data
[
key
]
=
''
return
data
return
data
def
_generate_modify_logging
(
self
,
attributes
,
old
,
new
):
'''
Generates a nicer representation of the executed query than str(attributes) would
'''
changed_attributes
=
[]
output
=
''
for
operation
in
attributes
:
if
operation
[
1
]
not
in
changed_attributes
:
changed_attributes
.
append
(
operation
[
1
])
for
attribute
in
changed_attributes
:
output
+=
attribute
+
'
:
'
+
old
[
attribute
]
+
'
->
'
+
new
[
attribute
]
+
'
,
'
return
output
[:
-
2
]
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