1
0
Fork
You've already forked fox
0
🦊 is a mini automation framework; it runs commands on remote servers, kinda like Fabric.
  • Python 100%
Find a file
2021年12月14日 03:15:34 +00:00
.github/workflows drop python 3.6 and update deps 2021年12月14日 03:06:48 +00:00
docs return the correct value from run_concurrent 2019年03月09日 02:51:00 +00:00
fox trim comment 2019年03月23日 21:33:38 +00:00
tests switch to pytest-asyncio in tests 2021年12月14日 03:07:44 +00:00
.gitignore gitignore and remove travis badge 2021年12月14日 03:06:48 +00:00
LICENSE Create LICENSE 2019年03月02日 17:59:33 +00:00
mypy.ini add more type annotations 2019年03月03日 17:10:50 +00:00
poetry.lock update asyncssh, pytest and add pytest-asyncio 2021年12月14日 03:06:48 +00:00
pyproject.toml update asyncssh, pytest and add pytest-asyncio 2021年12月14日 03:06:48 +00:00
README.md add tests badge 2021年12月14日 03:13:15 +00:00
setup.py drop python 3.6 and update deps 2021年12月14日 03:06:48 +00:00
tox.ini drop python 3.6 and update deps 2021年12月14日 03:06:48 +00:00

🦊 (Fox)

tests Documentation Status

🦊 (Fox) is an experimental alternative implementation of some of the Fabric 1.14 APIs.

Check out the documentation on readthedocs.

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.

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:

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:

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)