楊立群*_*楊立群 9 python invoke python-2.7 python-3.x pyinvoke
我开始使用 Python Invoke
from invoke import task
@task
def build():
print("Building!")
Run Code Online (Sandbox Code Playgroud)
预期的产出是
$ invoke build
Building!
Run Code Online (Sandbox Code Playgroud)
但是,我的输出是
$ invoke build
Can't find any collection named 'tasks'!
Run Code Online (Sandbox Code Playgroud)
我不知道为什么.
令人惊奇的是,一旦我在virtualenv中调用,那么我可以在没有virtualenv的情况下构建.
> mkvirtualenv myenv
> invoke build
Building!
> deactivate myenv
> invoke build
Building!
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
您还可以重命名tasks.py为您选择的名称,并可以使用'-c'选项运行它。
假设下面是您的简单 py 文件,名为'invoke_testing.py'
from invoke import task
@task
def check_config_files(c):
print("Hey I am Checking configurations")
Run Code Online (Sandbox Code Playgroud)
您需要像这样通过命令行运行:例如列出可用任务
invoke -c invoke_testing --lists
Run Code Online (Sandbox Code Playgroud)
其输出:
Available tasks:
check-config-files
Run Code Online (Sandbox Code Playgroud)
函数名称中的ps'_'已替换为'-',如果您需要运行特定任务,则已使用列表中列出的名称运行该任务。
invoke -c invoke_testing check-config-files
Run Code Online (Sandbox Code Playgroud)
我从这个源Python Invoke得到了这个参考
如果有人获得有关此的更多信息,请告诉我。
| 归档时间: |
|
| 查看次数: |
3860 次 |
| 最近记录: |