emacs noise files make "blag serve" very noisy
When using blag serve with content I'm editing with emacs, it gets tripped up by the .foo# symlink-lock-tags. The try/except covers it but generates a lot of rapid fire noise in the log output:
2024-07-14 18:03:42,220 ERROR blag.devserver Error occurred during rebuild:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/blag/devserver.py", line 80, in autoreload
mtime = get_last_modified(dirs)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/blag/devserver.py", line 45, in get_last_modified
mtime = os.stat(os.path.join(root, f)).st_mtime
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'content/.#survey.md'
2024-07-14 18:03:42,221 INFO blag.devserver Devserver did not crash, you may continue editing.
(The link is of the form .#survey.md -> [email protected]:1720912332 which doesn't exist, it's just being used because symlink creation is sufficiently atomic.)
On the theory that
- it makes sense to obey the convention that dotfiles are hidden, and skip them
- emacs is common enough that ignoring backup files ending in
~makes sense too
diff --git a/blag/blag.py b/blag/blag.py
index ed6db15..c538a5c 100644
--- a/blag/blag.py
+++ b/blag/blag.py
@@ -217,6 +217,9 @@ def build(args: argparse.Namespace) -> None:
convertibles = []
for root, dirnames, filenames in os.walk(args.input_dir):
for filename in filenames:
+ if filename.startswith(".") or filename.endswith("~"):
+ logger.debug(f"Skipping {filename}...")
+ continue
rel_src = os.path.relpath(
f"{root}/{filename}", start=args.input_dir
)
diff --git a/blag/devserver.py b/blag/devserver.py
index 1945740..076b7f9 100644
--- a/blag/devserver.py
+++ b/blag/devserver.py
@@ -42,6 +42,9 @@ def get_last_modified(dirs: list[str]) -> float:
for dir in dirs:
for root, dirs, files in os.walk(dir):
for f in files:
+ if f.startswith(".") or f.endswith("~"):
+ logger.debug(f"Skipping {f} ...")
+ continue
mtime = os.stat(os.path.join(root, f)).st_mtime
if mtime > last_mtime:
last_mtime = mtime
worked for me.
Thanks for reporting. Do you think it would be sufficient to just lower the loglevel of the exception, effectively silencing it?
That would probably be fine (since it's not as general as I thought when I started chasing it.)
Issue has been fixed and will be uploaded soonish. Thanks again for the report.
Just uploaded the changes to pypi and debian. feel free to test. cheers!