mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #862 from avaris/emacs-autoreload
ignore emacs lock files and exception handling for watchers
This commit is contained in:
commit
30c2490f88
4 changed files with 18 additions and 8 deletions
|
|
@ -464,7 +464,10 @@ def folder_watcher(path, extensions, ignores=[]):
|
|||
for f in files:
|
||||
if (f.endswith(tuple(extensions)) and
|
||||
not any(fnmatch.fnmatch(f, ignore) for ignore in ignores)):
|
||||
yield os.stat(os.path.join(root, f)).st_mtime
|
||||
try:
|
||||
yield os.stat(os.path.join(root, f)).st_mtime
|
||||
except OSError as e:
|
||||
logger.warning('Caught Exception: {}'.format(e))
|
||||
|
||||
LAST_MTIME = 0
|
||||
while True:
|
||||
|
|
@ -484,7 +487,12 @@ def file_watcher(path):
|
|||
LAST_MTIME = 0
|
||||
while True:
|
||||
if path:
|
||||
mtime = os.stat(path).st_mtime
|
||||
try:
|
||||
mtime = os.stat(path).st_mtime
|
||||
except OSError as e:
|
||||
logger.warning('Caught Exception: {}'.format(e))
|
||||
continue
|
||||
|
||||
if mtime > LAST_MTIME:
|
||||
LAST_MTIME = mtime
|
||||
yield True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue