Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Hamza Dely
lc_ldap
Commits
294773ba
Commit
294773ba
authored
Nov 09, 2014
by
Valentin Samir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ldap_locks, lc_ldap] Ooups, erreur d'index / d'iteration
parent
1b76ba54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
lc_ldap.py
lc_ldap.py
+2
-2
ldap_locks.py
ldap_locks.py
+9
-5
No files found.
lc_ldap.py
View file @
294773ba
...
...
@@ -508,8 +508,8 @@ class lc_ldap(ldap.ldapobject.LDAPObject, object):
except
ldap_locks
.
LockError
:
continue
else
:
raise
EnvironmentError
(
'Aucun %s libre dans la plage
[%d, %d]
'
%
(
attr
,
plage
[
0
],
i
))
raise
EnvironmentError
(
'Aucun %s libre dans la plage
%s
'
%
(
attr
,
realm
))
else
:
# On extrait seulement les valeurs des id qui nous intêressent dans une liste
nonfree
=
[
int
(
r
[
1
].
get
(
attr
)[
0
])
for
r
in
res
if
r
[
1
].
get
(
attr
)
]
...
...
ldap_locks.py
View file @
294773ba
...
...
@@ -172,11 +172,12 @@ class LdapLockHolder:
def
check
(
self
,
Id
=
'default'
,
delai
=
0
):
"""Vérifie que l'on a toujours tous nos locks"""
for
item
,
value
in
self
.
locks
[
Id
]:
host
,
pid
,
begin
=
self
.
getlock
(
item
,
value
)
time_left
=
self
.
timeout
-
(
time
.
time
()
-
begin
)
if
time_left
<=
delai
:
raise
LockExpired
(
"Le lock sur la donnée %r=%r à expiré"
%
(
item
,
value
,
time_left
))
for
item
,
values
in
self
.
locks
[
Id
].
items
():
for
value
in
values
:
host
,
pid
,
begin
=
self
.
getlock
(
item
,
value
)
time_left
=
self
.
timeout
-
(
time
.
time
()
-
begin
)
if
time_left
<=
delai
:
raise
LockExpired
(
"Le lock sur la donnée %r=%r à expiré"
%
(
item
,
value
,
time_left
))
def
removelock
(
self
,
item
,
value
,
Id
=
'default'
,
force
=
False
):
"""
...
...
@@ -207,6 +208,9 @@ class LdapLockHolder:
return
host
,
int
(
pid
),
float
(
begin
)
except
ldap
.
NO_SUCH_OBJECT
:
raise
LockNotFound
()
except
ldap
.
INVALID_DN_SYNTAX
:
print
'%s=%s,%s'
%
(
item
,
value
,
LOCKS_DN
)
raise
except
ValueError
as
e
:
self
.
removelock
(
item
,
value
,
Id
,
force
=
True
)
raise
LockNotFound
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment