Revision 05e50653 lib/utils.py
b/lib/utils.py | ||
---|---|---|
1951 | 1951 |
return time.strftime("%F %T", time.localtime(val)) |
1952 | 1952 |
|
1953 | 1953 |
|
1954 |
def ReadWatcherPauseFile(filename, now=None): |
|
1955 |
"""Reads the watcher pause file. |
|
1956 |
|
|
1957 |
""" |
|
1958 |
if now is None: |
|
1959 |
now = time.time() |
|
1960 |
|
|
1961 |
try: |
|
1962 |
value = ReadFile(filename) |
|
1963 |
except IOError, err: |
|
1964 |
if err.errno != errno.ENOENT: |
|
1965 |
raise |
|
1966 |
value = None |
|
1967 |
|
|
1968 |
if value is not None: |
|
1969 |
try: |
|
1970 |
value = int(value) |
|
1971 |
except ValueError: |
|
1972 |
value = None |
|
1973 |
|
|
1974 |
if value is not None: |
|
1975 |
if now > value: |
|
1976 |
value = None |
|
1977 |
|
|
1978 |
return value |
|
1979 |
|
|
1980 |
|
|
1954 | 1981 |
class FileLock(object): |
1955 | 1982 |
"""Utility class for file locks. |
1956 | 1983 |
|
Also available in: Unified diff