Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ Everything except `name` is optional.
| `user` | `name` | the account the daemons run as |
| `ops_group` | `<name>-ops` | the group that may start, stop and deploy without a password |
| `env_prefix` | `NAME` | instance files set `<PREFIX>_DAEMON`, `_CONFIG` and `_HOST`; operators override paths with `<PREFIX>_REPO_DIR`, `_VENV_DIR`, `_ETC_DIR` |
| `subsystem_prefix` | none | set it only where instance names share one, so `start fei` finds `hsfei_*` |
| `docs_url` | none | linked from `--help` |
| `secrets.key_suffix` | `_env` | a config key ending in this names the variable holding a credential |
| `help.example_instance` | `<instance>` | used in `--help`, where a real name beats a placeholder |
Expand Down
2 changes: 1 addition & 1 deletion src/instrumentctl/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _err(product: Product, message: str) -> None:
def _resolve(paths: Paths, targets: List[str], names: List[str]) -> Optional[List[str]]:
"""Expand targets, explaining a miss. None means an error was printed."""
try:
return inst.resolve(paths.product, targets, names)
return inst.resolve(targets, names)
except TargetError as exc:
target, prog = str(exc), paths.product.name
if target in inst.in_repo(paths):
Expand Down
15 changes: 6 additions & 9 deletions src/instrumentctl/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,15 @@ def secrets_set(paths: Paths) -> Optional[Dict[str, str]]:
return None


def resolve(product: Product, targets: Iterable[str], names: List[str]) -> List[str]:
def resolve(targets: Iterable[str], names: List[str]) -> List[str]:
"""Expand command-line targets against the instances in ``names``.

A target is an instance name (``hsfei_adc``), a subsystem prefix
(``hsfei``, or just ``fei`` where the product sets one), or ``all``.
Targets keep their command-line order, so ``start power fei`` powers up
before it starts the mechanisms. Duplicates are dropped, and a target
matching nothing is an error.
A target is an instance name (``hsfei_adc``), the prefix every instance in
a subsystem shares (``hsfei``), or ``all``. Targets keep their command-line
order, so ``start hspower hsfei`` powers up before it starts the
mechanisms. Duplicates are dropped, and a target matching nothing is an
error.
"""
shorthand = product.subsystem_prefix
selected: List[str] = []
for target in targets:
if target == "all":
Expand All @@ -209,8 +208,6 @@ def resolve(product: Product, targets: Iterable[str], names: List[str]) -> List[
else:
prefix = target.rstrip("_") + "_"
hits = [n for n in names if n.startswith(prefix)]
if not hits and shorthand and not target.startswith(shorthand):
hits = [n for n in names if n.startswith(shorthand + prefix)]
if not hits:
raise TargetError(target)
selected.extend(n for n in hits if n not in selected)
Expand Down
2 changes: 0 additions & 2 deletions src/instrumentctl/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class Product: # pylint: disable=too-many-instance-attributes
user: str
ops_group: str
env_prefix: str
subsystem_prefix: str
secret_key_suffix: str = "_env"
docs_url: str = ""
# Used only in --help, where a real name beats a placeholder
Expand Down Expand Up @@ -61,7 +60,6 @@ def load(cls, config: "ConfigSource") -> "Product":
user=instrument.get("user", instrument["name"]),
ops_group=instrument.get("ops_group", f"{instrument['name']}-ops"),
env_prefix=instrument.get("env_prefix", instrument["name"].upper()),
subsystem_prefix=instrument.get("subsystem_prefix", ""),
secret_key_suffix=secrets.get("key_suffix", "_env"),
docs_url=instrument.get("docs_url", ""),
example_instance=help_text.get("example_instance", "<instance>"),
Expand Down
Loading