Asyncio支持的PythonDSL,用于在本地、Docker上或通过ssh运行命令。
pitcrew的Python项目详细描述
活塞杆
Asyncio支持的PythonDSL,用于在本地、Docker上或通过ssh运行命令。
pitcrew做什么?
Pitcrew can run commands | ^{ |
...or over ssh | ^{ |
on hundreds of hosts! | ^{ |
Crew can also run tasks | ^{ |
Tasks are either other shell commands, or other tasks, for example, this provisions Cloudfront, SSL and S3 and builds and deploys docs to pitcrew.io | ^{ |
You can list available tasks | ^{ |
...edit an existing task | ^{ |
or create a new task! | ^{ |
安装
从二进制
要在主目录中安装pitcrew,请运行以下命令:
curl -fsSL "https://github.com/joshbuddy/pitcrew/releases/latest/download/crew-$(uname)" > crew
chmod u+x crew
./crew run crew.install --dest="$HOME/crew"
来自Pypi
要从python包索引安装,请运行以下命令:
pip install pitcrew
crew run crew.install --dest="$HOME/crew"
来源
git clone https://github.com/joshbuddy/pitcrew
cd pitcrew
python3.6 -m venv env
source env/bin/activate
pip install -e .
概念
一个或一组命令称为task。context在本地、Docker上或通过ssh运行任务。 provider生成上下文。
任务
任务可以由其他任务组成,也可以在shell上调用命令。
task的一个例子可能是读取文件。fs.read(path)
以字节形式读取文件并返回:
pitcrew/tasks/fs/read.py
importbase64frompitcrewimporttask@task.arg("path",desc="The file to read",type=str)@task.returns("The bytes of the file")classFsRead(task.BaseTask):"""Read value of path into bytes"""asyncdefrun(self)->bytes:code,out,err=awaitself.sh_with_code(f"cat {self.params.esc_path}")assertcode==0,"exitcode was not zero"returnout
其他任务可能包括编写文件、安装xcode或克隆git存储库。所有当前可用的 任务列在docs/tasks.md。任务中可用的api位于docs/api.md#crewtask。
上下文
context的一个例子可能是通过ssh,甚至是本地的。在docs/api.md#crewcontext了解有关上下文的更多信息。
提供者
provider是具有特定返回类型的任务。返回类型是返回上下文的异步迭代器。
用法
有关详细用法,请参见docs/cli.md了解更多详细信息。
运行命令
pitcrew允许使用bin/crew sh -- [shell command]
运行命令。
例如,crew sh ls /
将在本地列出“/”目录。
您可以使用crew sh -p providers.ssh -P '{"hosts": ["192.168.0.1", "192.168.0.2", "192.168.0.3"]}' ls /
通过ssh在三台主机上运行此命令。
运行任务
pitcrew允许使用crew run [task name] <task args>
运行任务。除非使用-p
标志选择其他提供程序,否则这通常以本地计算机为目标。
查看可用任务
查看所有可用任务的运行crew list
。这将显示存储在crew/tasks
中的所有可用任务。
执行新任务
查看所有可用的任务运行crew new [task_name]
。这将创建新任务的模板。
运行测试
要运行特殊命令,请使用。对于任务,请使用crew run [task-name] <args>
。
获取cli帮助
要查看命令行中可用命令的完整列表,请运行crew help
。