hook: React to commands failures
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 2.1k
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 31
Description
I noticed that `hook.py` uses `subprocess.Popen(command_pieces).wait()` (BTW, why not `subprocess.call`), and does not check the return code (you ignore the `wait` result). It also might be you thought this code does what `check_call` does (namely, throw on non-OK exit). Right now, your exception handler is only triggered when the command cannot be found.
An improvement would be to log a warning on non-OK exit code, and allow failing commands to exit the beets process. Example:
```yaml
hook:
hooks:
- event: import
command: chmod -R go+rX "{lib.directory}"
on_error: abort
```
Choices for `on_error` would be `abort`, `ignore` (the default), `log`, `skip_album`, and `skip_item`.
`skip_*` would depend on the event, e.g. skip an album import if the command fails.
Contributor guide
Assessment
This issue has not been assessed yet.