A watcher for running python code when after every modification
Project description
python-watcher
I've crated this project to watch over a repo dir and execute a file after modifying anything on that same dir. Its lightweight since it only has watchdog as a dependency.
Parameters for running
-d or --dir (required):
Folder you want the watcher to look for changes. Defaults to "."
-f or --file (required):
Script that you want to run after a file is changed (probably you main.py or something similar)
-t or --time (optional):
Time delay to run again (good when saving constantly). Defaults to 1.
--test (optional):
If the watcher should run a pytest command instead of python. Defaults to False.
To run
Watching and executing a python script:
watcher -d . -f watcher.py
Watching and executing pytest
watcher --test
For dependencies all you need to do is run
pip install -e .
Use cases
Although trivial, there are some uses cases that made me create this package:
- Run pytest when saving a file.
- Run pylint when making corrections.
- Run smaller scripts after every modification.
Mostly I was tired off having to tab out from vim just to run pytest/pylint/python on the terminal.
Todo
- create a proper setup
- make it executable from command line
- be able to pass parameters
- read parameters from yaml file
- only watch a single file changes
- run pytest
- run pylint
- to run pylint there has to be a folder to run pylint over
- fail with some threshold
- Spawn a new process to close if needed (more control over running process)
- Create documentation
- Create tests
- Publish
- Fix pytest not working on GitHub actions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
watcher-cli-0.0.1.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for watcher_cli-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56f5abf3820470597215a5e116ea9c2e35cbb7a43f032712dfb6ef7f0208da82 |
|
MD5 | 737fe8a139e32d5a97f863065ada9ad3 |
|
BLAKE2b-256 | 856aed6e0c6a2a22eec59e4c9d389979d4adec0c71218d6fe2d9ab381750da3e |