我有这样的fabfile.py:
from fabric.api import *
def deploy():
with prefix('source venv/bin/activate'):
local('pex -r <(cat requirements.txt) . -o app.pex')
当我运行
$ fab deploy
时,我得到:$ fab deploy
[localhost] local: pex -r <(cat requirements.txt) . -o app.pex
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `source venv/bin/activate && pex -r <(cat requirements.txt) . -o app.pex'
Fatal error: local() encountered an error (return code 1) while executing 'pex -r <(cat requirements.txt) . -o app.pex'
Aborting.
命令
source venv/bin/activate && pex -r <(cat requirements.txt) . -o app.pex
在shell中运行正常。我是Fabric的新手。怎么了 最佳答案
默认情况下,fabric.operations.local()
function使用/bin/sh
作为外壳程序来运行命令。这个基本的shell不支持/bin/bash
的所有语法。
如果必须访问Bash shell语法,则设置shell='/bin/bash'
:
local('pex -r <(cat requirements.txt) . -o app.pex', shell='/bin/bash'))
关于python - 结构:意外 token '('附近的语法错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31494224/