2013-06-26 3 views
2

의 시리즈에 실패, 우리는파이썬 원단 : 표준 직물 예에서 명령

def test(): 
    with settings(warn_only=True): 
     result = local('./manage.py test my_app', capture=True) 
    if result.failed and not confirm("Tests failed. Continue anyway?"): 
     abort("Aborting at user request.") 

는 전체 방법의 상태를 확인할 수있는 방법이 있습니까 있나요? 예를 들어

,

def method1(): 
    run_this_as_sudo 
    run_this_as_sudo 

어떻게 각각의 메소드 호출을보고 반대로 전체 방법은 직물에 실패 있는지 확인합니까? 여러 쉘 명령으로 구성된 모든 메소드에서 일종의 try catch를 추가하기 위해이를 처리하는 유일한 방법은 무엇입니까? 조건부 함께 난 그냥 전화를 체인있어

╭─[email protected] ~ 
╰─$ fab -f tmp.py test 
Ok 
Something failed 

Done. 
╭─[email protected] ~ 
╰─$ cat tmp.py 
from fabric.api import local, task, quiet 

@task 
def test(): 
    with quiet(): 
     if local("whoami").succeeded and local("echo good").succeeded: 
      print "Ok" 
     else: 
      print "Something failed" 


     if local("exit 1").succeeded and local("echo good").succeeded: 
      print "Ok" 
     else: 
      print "Something failed" 

하고 조건부 전환을 위해 반환 bools을 사용

+0

이것에 대한'SystemExit' 예외를 잡을 수 있습니다. 참조 : http://stackoverflow.com/questions/5481742/how-to-catch-auth-errors-in-fabric-and-retry – Roshambo

답변

2

은 당신이 뭔가를 할 수 있습니다.