2017-02-07 13 views
1

私はfabric3(https://pypi.python.org/pypi/Fabric3)、python 3ポートのファブリックで作業しています。'cd'コマンドがfabric3で動作しない

I持って次の関数:

@roles('production') 
def dir(): 
    run('pwd') 
    run('ls') 
    cd('/home/deploy/mydir') 
    run('pwd') 

出力:

$ fab dir 
[[email protected]] Executing task 'dir' 
[[email protected]] run: pwd 
[[email protected]] out: /home/deploy 
[[email protected]] out: 

[[email protected]] run: ls 
[[email protected]] out: Env mysite 
[[email protected]] out: 

[[email protected]] run: pwd 
[[email protected]] out: /home/deploy 
[[email protected]] out: 

なぜそれが無視されたCD?

+0

試し '行うことができます。run (...) ' - http://docs.fabfile.org/ja/1.13/tutorial.html#making-connections – furas

答えて

1

すべてのコマンドは、分離した「環境」で動作します。

cd()フォルダを変更しますが、次のコマンドは新しい「クリア」環境で開始します。

しかし、あなたはwithを使用することができます。

with cd("<path>"): 
    run("<command>") 

は、ファブリックドキュメントの詳細情報:Context Managers

それとも、手動でCD(...)と

run("cd <path> && <command>") 
関連する問題