Option quiet pour le lock
darcs-hash:20041205123023-d1718-526a0448dff827f459a187594773375cf6224610.gz
This commit is contained in:
parent
e9cd4db258
commit
3311711bb5
1 changed files with 10 additions and 5 deletions
|
@ -13,7 +13,7 @@ from user_tests import getuser
|
||||||
from fcntl import lockf, LOCK_EX, LOCK_NB, LOCK_UN
|
from fcntl import lockf, LOCK_EX, LOCK_NB, LOCK_UN
|
||||||
import errno
|
import errno
|
||||||
|
|
||||||
def make_lock(lock_name, lock_comment='',nowait=1) :
|
def make_lock(lock_name, lock_comment='',nowait=1, quiet=False) :
|
||||||
""" Création d'un lock
|
""" Création d'un lock
|
||||||
si nowait=1 fait un sys.exit(254) quand un ancien lock actif est rencontré
|
si nowait=1 fait un sys.exit(254) quand un ancien lock actif est rencontré
|
||||||
"""
|
"""
|
||||||
|
@ -45,7 +45,8 @@ def make_lock(lock_name, lock_comment='',nowait=1) :
|
||||||
# Le script lockant ne tourne plus
|
# Le script lockant ne tourne plus
|
||||||
os.remove(lock_file)
|
os.remove(lock_file)
|
||||||
elif nowait :
|
elif nowait :
|
||||||
sys.stderr.write('Lock : %s\n' % lock_file)
|
if not quiet:
|
||||||
|
sys.stderr.write('Lock : %s\n' % lock_file)
|
||||||
l=getoutput('ps -o etime --no-headers %s' % pid)
|
l=getoutput('ps -o etime --no-headers %s' % pid)
|
||||||
data = [ user , pid , l.strip() ]
|
data = [ user , pid , l.strip() ]
|
||||||
|
|
||||||
|
@ -67,9 +68,13 @@ def make_lock(lock_name, lock_comment='',nowait=1) :
|
||||||
txt = '???'
|
txt = '???'
|
||||||
|
|
||||||
data[-1]=txt
|
data[-1]=txt
|
||||||
|
|
||||||
sys.stderr.write('\tpropriétaire : %s\n\tpid : %s\n\tdémarré depuis %s\n' % tuple(data) )
|
if not quiet:
|
||||||
sys.exit(254)
|
sys.stderr.write('\tpropriétaire : %s\n\tpid : %s\n\tdémarré depuis %s\n' % tuple(data) )
|
||||||
|
sys.exit(254)
|
||||||
|
else:
|
||||||
|
# On va plutot lever une exception
|
||||||
|
raise AssertionError(tuple(data))
|
||||||
else :
|
else :
|
||||||
# Il faut attendre
|
# Il faut attendre
|
||||||
a = affich_tools.anim('\tattente du lock')
|
a = affich_tools.anim('\tattente du lock')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue