Fabric:意外令牌附近的语法错误'('

时间:2015-07-18 18:27:47

标签: python fabric

我有这样的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的新手。这里有什么问题?

1 个答案:

答案 0 :(得分:2)

默认情况下fabric.operations.local() function使用/bin/sh作为运行命令的shell。这个基本的shell不支持/bin/bash所有的语法。

如果您必须有权访问Bash shell语法,请设置shell='/bin/bash'

local('pex -r <(cat requirements.txt) . -o app.pex', shell='/bin/bash'))