Gateway (gw) is a lightweight dispatcher that turns every Python function
into a command line entry. It includes a recipe
runner so you can compose automations with only functions
and .gwr files.
Install from PyPI or from source and invoke gway on the command line.
Every module inside projects/ becomes a namespace on gw and a CLI
sub-command.
gway hello-world
gway awg find-awg --meters 30 --amps 60from gway import gw
gw.hello_world()
result = gw.awg.find_awg(meters=30, amps=60)
print(result["awg"])pip install gway pulls the latest released package from PyPI. Use this
when you simply want to depend on GWAY in your own projects. To work on the
framework itself clone the repository and install it in editable mode:
git clone https://github.com/arthexis/gway.git
cd gway
pip install -r requirements.txt
pip install -e .- Gateway Object
gw: entry point for all operations. Callinggw.project.func()is equivalent togway project func. - Projects: any
.pyfile or directory insideprojects/is loaded on demand. Nested modules use dotted notation. - Builtins: common utilities such as
resource,run_recipe,help,testandnotifyare always available. - Results & Context: return values are stored in
gw.resultsand are referenced by name. Use sigils like[result.key]to pull values into later calls. - Sigils:
[VAR]or[object.attr]placeholders resolve from previous results,gw.contextand environment variables. Automatic resolution only happens for sigils prefixed with%(e.g.%[VAR]); other sigils remain lazy until passed togw.resolveorgw["VAR"]. - Recipes
.gwr: text files listing commands. Indented lines reuse the previous command allowing very compact scripts. Run them viagway -r fileorgw.run_recipe('file.gwr'). - Unquoted Kwargs: values after
--keymay include spaces up to the next-or--token; quoting is optional. - Environment Loading:
envs/clients/<user>.envandenvs/servers/<host>.envare read automatically. A file can specify aBASE_ENVto inherit defaults from another file. - Async & Watchers: coroutines are executed in background threads. Use
gw.untilwith file or URL watchers (and even PyPI version checks) to keep services running until a condition changes. PyPI version checks poll every 30 minutes by default.
- Resources:
gw.resourceresolves a file path in the workspace and can create files or directories.gw.resource_listlists files matching filters. - Logging & Testing:
gw.setup_loggingconfigures rotating logs inlogs/.gway test --coverageorgw.test()run the suite.
Recipes are .gwr files listing commands to automate tasks. Run them with
gway -r file or gw.run_recipe('file.gwr').
awg awg-probe --target localhost
auth-db load sample.cdv
Folder Structure
Here's a quick reference of the main directories in a typical GWAY workspace:
| Directory | Description |
|---|---|
| envs/clients/ | Per-user environment files (e.g., username.env). |
| envs/servers/ | Per-host environment files (e.g., hostname.env). |
| projects/ | Included GWAY python projects. You may add your own. |
| logs/ | Runtime logs and log backups. |
| gway/ | Source code for core GWAY components. |
| tests/ | Hierarchical unit tests (e.g., tests/gway). |
| data/ | Static assets, resources, and other included data files. |
| work/ | Working directory for output files and products. |
| recipes/ | Included .gwr recipe files (-r mode). You may add more. |
| tools/ | Platform-specific scripts and files. |
The test suite verifies projects using the gw dispatcher. Install all
dependencies and run gway test to execute it.
Tests are discovered recursively so directories under tests may mirror the source tree. A suggested structure is:
tests/
gway/
projects/
Before executing the suite, ensure the package and all dependencies are installed. Follow the commands in TESTING.rst to install requirements.txt and the editable package, then invoke gway test.
MIT License