https://github.com/piger/fox
🦊 is a mini automation framework; it runs commands on remote servers, kinda like Fabric.
https://github.com/piger/fox
fabric python remote-execution ssh
Last synced: 8 months ago
JSON representation
🦊 is a mini automation framework; it runs commands on remote servers, kinda like Fabric.
- Host: GitHub
- URL: https://github.com/piger/fox
- Owner: piger
- License: bsd-2-clause
- Created: 2019-03-02T17:53:46.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-12-14T03:15:37.000Z (about 4 years ago)
- Last Synced: 2025-07-26T13:52:36.798Z (8 months ago)
- Topics: fabric, python, remote-execution, ssh
- Language: Python
- Homepage:
- Size: 76.2 KB
- Stars: 4
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🦊 (Fox)

[](https://fox-py.readthedocs.io/en/latest/?badge=latest)
🦊 (Fox) is an _experimental_ alternative implementation of _some_ of the
[Fabric 1.14](http://docs.fabfile.org/en/1.14/) APIs.
Check out the documentation on [readthedocs](https://fox-py.readthedocs.io/en/latest/index.html).
**NOTE**: this project is under development.
## Why?
I want to keep using the old Fabric 1.14 APIs with Python3:
- Fabric 2 changed the APIs
- Fabric3 (a fork of Fabric 1.14 for Python3) has some issues with Python3
- Maybe it's better to start from scratch with smaller project scope and focusing on Python3 only
## Example usage
Adapting code that uses Fabric 1.x should be easy enough, but some features will be missing and some
will behave differently.
``` python
from fox.conf import env
from fox.api import run, sudo
env.host_string = "server.example.com"
env.sudo_password = "very secret"
run("./configure --with-prefix=/90s", cd="/code/project")
sudo("make install", cd="/code/project")
# escaping should be handled correctly, for example:
run(
"""tail -n 1 < /etc/passwd | awk 'BEGIN { FS=":" } { print $1 " and " $3 }'"""
)
```
You can also use an explicit API:
``` python
from fox.connection import Connection
from fox.conf import env
env.sudo_password = "much more secret"
conn = Connection("app1.example.com")
conn.put("nginx.conf", "/tmp/nginx.conf")
# NOTE there is no "put() with sudo"
conn.sudo("mv /tmp/nginx.conf /etc/nginx/")
conn.sudo("systemctl restart nginx")
conn.disconnect()
```
You can also use Cluster mode when you want to run the same command on several hosts in parallel:
``` python
from fox.cluster import Cluster
cluster = Cluster("app1.example.com", "app2.example.com", "app3.example.com")
cluster.run("sleep $((1 + RANDOM % 5)) && hostname", limit=2)
```