按顺序运行一些python代码。
godo的Python项目详细描述
按照定义顺序执行python代码目录。
给定如下目录结构:
myscripts/ 1-init.gd 2-run/ 1-stuff-a.gd 2-stuff-b.gd 3-finish.gd
godo将遍历这个目录,运行每个文件中定义的任务。
任务定义为用@taskdecorator修饰的函数。任务 在文件中定义的文件将按照它们定义的顺序执行。
任务文件
任何以.gd结尾的文件都将作为python源文件进行读取和计算。任何 由@taskdecorator修饰的函数将被添加到 要执行的任务列表。
示例mytasks.gd:
import os @task def first_task(): print "Yay going and doing stuff!" @task def second_task(cfg): print "A config option: %s" % cfg["whee"]
任务从定义它们的文件所在的同一目录执行 位于。
完成任务文件API:
- ^{tt1}$ - Decorate a function so that it will be executed.
- ^{tt5}$ - Used in ^{tt6}$ statements to change the working directory.
- ^{tt7}$ - Run a shell command checking the return code.
- ^{tt8}$ - Prepends a command with sudo. Probably won’t work if you don’t use passwordless sudo. Obviously, that should be fixed.
配置文件
默认情况下,godo将在基本执行目录中查找godo.cfg.py 文件。(除非在命令中指定,否则基本执行目录是./。 行)。或者可以指定路径。如果找到配置文件 作为字典计算并传递给接受 争论。