Skip to content

Commit

Permalink
Warn for unexpected characters in daemon names
Browse files Browse the repository at this point in the history
  • Loading branch information
ksunden committed Jun 19, 2023
1 parent 0aa9612 commit 082337e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

### Changed
- Upgraded appdirs to platformdirs
- Warn for unexpected characters in daemon names

### [2022.4.0]

Expand Down
13 changes: 12 additions & 1 deletion yaqd_control/_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@


import pathlib
import platformdirs # type: ignore
import re
import warnings

import platformdirs
import toml
from ._daemon_data import DaemonData

Expand Down Expand Up @@ -61,9 +64,17 @@ def add_config(filepath):
kind = filepath.parent.name
if kind.startswith("yaqd-"):
kind = kind[5:]
ident = re.compile("^[a-zA-z_][a-zA-Z0-9_]*$")
for k, v in dic.items():
if k in ("enable", "shared-settings"):
continue
if ident.match(k) is None:
warnings.warn(
f"Daemon named {k!r} may have incompatibilities with external systems"
"such as happi. Using a name which consists of only alphanumeric ASCII"
"characters or '_' (and not starting with a number) is recommended."
)

dd = DaemonData(
kind=kind,
host="127.0.0.1",
Expand Down

0 comments on commit 082337e

Please sign in to comment.