1

サーバーを管理するために使用する 2 つのユーザー名と対応するパスワードがあります。fab スクリプト/モジュールを使用する方法はありますか?各ホストまたはそれらのグループ。

run() などの周りで try/except を実行する方法がドキュメントにありません...

4

1 に答える 1

1

runおよびその他のコマンドは SystemExit を発生させます

from fabric.api import run,cd,put,sudo,settings

def do_stuff():
    run('ls derp')

try:
    with(settings(host_string='%s@localhost' % first_user,password = first_password)):
        do_stuff()
except SystemExit:
    with(settings(host_string='%s@localhost' % second_user,password = second_password)):
        do_stuff()
于 2011-12-17T14:22:19.470 に答える