forked from github/pelican
ignore emacs lock files and exception handling for watchers
This commit is contained in:
parent
740bb46e6d
commit
be8837963a
4 changed files with 18 additions and 8 deletions
|
|
@ -81,9 +81,9 @@ Setting name (default value) What doe
|
||||||
`MARKUP` (``('rst', 'md')``) A list of available markup languages you want
|
`MARKUP` (``('rst', 'md')``) A list of available markup languages you want
|
||||||
to use. For the moment, the only available values
|
to use. For the moment, the only available values
|
||||||
are `rst`, `md`, `markdown`, `mkd`, `mdown`, `html`, and `htm`.
|
are `rst`, `md`, `markdown`, `mkd`, `mdown`, `html`, and `htm`.
|
||||||
`IGNORE_FILES` (``[]``) A list of file globbing patterns to match against the
|
`IGNORE_FILES` (``['.#*']``) A list of file globbing patterns to match against the
|
||||||
source files to be ignored by the processor. For example
|
source files to be ignored by the processor. For example,
|
||||||
``['.#*']`` will ignore emacs temporary files.
|
the default ``['.#*']`` will ignore emacs lock files.
|
||||||
`MD_EXTENSIONS` (``['codehilite(css_class=highlight)','extra']``) A list of the extensions that the Markdown processor
|
`MD_EXTENSIONS` (``['codehilite(css_class=highlight)','extra']``) A list of the extensions that the Markdown processor
|
||||||
will use. Refer to the Python Markdown documentation's
|
will use. Refer to the Python Markdown documentation's
|
||||||
`Extensions section <http://pythonhosted.org/Markdown/extensions/>`_
|
`Extensions section <http://pythonhosted.org/Markdown/extensions/>`_
|
||||||
|
|
|
||||||
|
|
@ -353,8 +353,6 @@ def main():
|
||||||
|
|
||||||
pelican.run()
|
pelican.run()
|
||||||
|
|
||||||
time.sleep(.5) # sleep to avoid cpu load
|
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
logger.warning("Keyboard interrupt, quitting.")
|
logger.warning("Keyboard interrupt, quitting.")
|
||||||
break
|
break
|
||||||
|
|
@ -366,6 +364,10 @@ def main():
|
||||||
logger.warning(
|
logger.warning(
|
||||||
'Caught exception "{0}". Reloading.'.format(e))
|
'Caught exception "{0}". Reloading.'.format(e))
|
||||||
|
|
||||||
|
finally:
|
||||||
|
time.sleep(.5) # sleep to avoid cpu load
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if next(watchers['content']) is None:
|
if next(watchers['content']) is None:
|
||||||
logger.warning('No valid files found in content.')
|
logger.warning('No valid files found in content.')
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ _DEFAULT_CONFIG = {'PATH': os.curdir,
|
||||||
'PLUGIN_PATH': '',
|
'PLUGIN_PATH': '',
|
||||||
'PLUGINS': [],
|
'PLUGINS': [],
|
||||||
'TEMPLATE_PAGES': {},
|
'TEMPLATE_PAGES': {},
|
||||||
'IGNORE_FILES': []
|
'IGNORE_FILES': ['.#*']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -444,7 +444,10 @@ def folder_watcher(path, extensions, ignores=[]):
|
||||||
for f in files:
|
for f in files:
|
||||||
if (f.endswith(tuple(extensions)) and
|
if (f.endswith(tuple(extensions)) and
|
||||||
not any(fnmatch.fnmatch(f, ignore) for ignore in ignores)):
|
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
|
LAST_MTIME = 0
|
||||||
while True:
|
while True:
|
||||||
|
|
@ -464,7 +467,12 @@ def file_watcher(path):
|
||||||
LAST_MTIME = 0
|
LAST_MTIME = 0
|
||||||
while True:
|
while True:
|
||||||
if path:
|
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:
|
if mtime > LAST_MTIME:
|
||||||
LAST_MTIME = mtime
|
LAST_MTIME = mtime
|
||||||
yield True
|
yield True
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue