将Makefile移植到dodo.py我想在路径上找到“nikola”,而不是直接调用它
在Makefile中我会做类似
的事情NIKOLA = $(which nikola)
然而我似乎无法找到doit / dodo / python equivelant我当前的文件看起来像这样
import subprocess
Nikola = subprocess.Popen("nikola", stdout=subprocess.PIPE, shell=True)
def task_build():
return {
'actions': ['{0} build'.format(Nikola)],
}
但是运行task_build会返回此
########################################
Execution aborted.
Task 'build': invalid 'actions' type. got:<subprocess.Popen object at 0x10111f810> <class 'subprocess.Popen'>
(env)
答案 0 :(得分:0)
试试这个:
>>> import subprocess
>>> subprocess.check_output(['which','nikola'])
'/Users/elyase/miniconda/bin/nikola\n'
在你的情况下:
def task_build():
return {
'actions': ['{0} build'.format(Nikola)],
}
>>> Nikola = subprocess.check_output(['which','nikola']).rstrip()
>>> task_build()
{'actions': ['/Users/elyase/miniconda/bin/nikola build']}