Revision 5cbe43a5
b/lib/utils.py | ||
---|---|---|
1951 | 1951 |
return time.strftime("%F %T", time.localtime(val)) |
1952 | 1952 |
|
1953 | 1953 |
|
1954 |
def ReadWatcherPauseFile(filename, now=None): |
|
1954 |
def ReadWatcherPauseFile(filename, now=None, remove_after=3600):
|
|
1955 | 1955 |
"""Reads the watcher pause file. |
1956 | 1956 |
|
1957 |
@type filename: string |
|
1958 |
@param filename: Path to watcher pause file |
|
1959 |
@type now: None, float or int |
|
1960 |
@param now: Current time as Unix timestamp |
|
1961 |
@type remove_after: int |
|
1962 |
@param remove_after: Remove watcher pause file after specified amount of |
|
1963 |
seconds past the pause end time |
|
1964 |
|
|
1957 | 1965 |
""" |
1958 | 1966 |
if now is None: |
1959 | 1967 |
now = time.time() |
... | ... | |
1969 | 1977 |
try: |
1970 | 1978 |
value = int(value) |
1971 | 1979 |
except ValueError: |
1980 |
logging.warning(("Watcher pause file (%s) contains invalid value," |
|
1981 |
" removing it"), filename) |
|
1982 |
RemoveFile(filename) |
|
1972 | 1983 |
value = None |
1973 | 1984 |
|
1974 | 1985 |
if value is not None: |
1975 |
if now > value: |
|
1986 |
# Remove file if it's outdated |
|
1987 |
if now > (value + remove_after): |
|
1988 |
RemoveFile(filename) |
|
1989 |
value = None |
|
1990 |
|
|
1991 |
elif now > value: |
|
1976 | 1992 |
value = None |
1977 | 1993 |
|
1978 | 1994 |
return value |
Also available in: Unified diff