Revision 7c4d6c7b lib/utils.py
b/lib/utils.py | ||
---|---|---|
27 | 27 |
""" |
28 | 28 |
|
29 | 29 |
|
30 |
import sys |
|
31 | 30 |
import os |
32 | 31 |
import time |
33 | 32 |
import subprocess |
... | ... | |
59 | 58 |
_locksheld = [] |
60 | 59 |
_re_shell_unquoted = re.compile('^[-.,=:/_+@A-Za-z0-9]+$') |
61 | 60 |
|
62 |
debug = False |
|
63 | 61 |
debug_locks = False |
64 | 62 |
|
65 | 63 |
#: when set to True, L{RunCmd} is disabled |
... | ... | |
687 | 685 |
""" |
688 | 686 |
try: |
689 | 687 |
nv = fn(val) |
690 |
except (ValueError, TypeError), err:
|
|
688 |
except (ValueError, TypeError): |
|
691 | 689 |
nv = val |
692 | 690 |
return nv |
693 | 691 |
|
... | ... | |
1097 | 1095 |
if source is not None: |
1098 | 1096 |
try: |
1099 | 1097 |
sock.bind((source, 0)) |
1100 |
except socket.error, (errcode, errstring):
|
|
1098 |
except socket.error, (errcode, _):
|
|
1101 | 1099 |
if errcode == errno.EADDRNOTAVAIL: |
1102 | 1100 |
success = False |
1103 | 1101 |
|
... | ... | |
1360 | 1358 |
|
1361 | 1359 |
def all(seq, pred=bool): |
1362 | 1360 |
"Returns True if pred(x) is True for every element in the iterable" |
1363 |
for elem in itertools.ifilterfalse(pred, seq):
|
|
1361 |
for _ in itertools.ifilterfalse(pred, seq):
|
|
1364 | 1362 |
return False |
1365 | 1363 |
return True |
1366 | 1364 |
|
1367 | 1365 |
|
1368 | 1366 |
def any(seq, pred=bool): |
1369 | 1367 |
"Returns True if pred(x) is True for at least one element in the iterable" |
1370 |
for elem in itertools.ifilter(pred, seq):
|
|
1368 |
for _ in itertools.ifilter(pred, seq):
|
|
1371 | 1369 |
return True |
1372 | 1370 |
return False |
1373 | 1371 |
|
... | ... | |
1552 | 1550 |
@param name: the daemon name used to derive the pidfile name |
1553 | 1551 |
|
1554 | 1552 |
""" |
1555 |
pid = os.getpid() |
|
1556 | 1553 |
pidfilename = DaemonPidFileName(name) |
1557 | 1554 |
# TODO: we could check here that the file contains our pid |
1558 | 1555 |
try: |
Also available in: Unified diff