Can I catch error codes when using Fabric to run() calls in a remote shell?

前端 未结 4 653
花落未央
花落未央 2020-12-23 13:17

Normally Fabric quits as soon as a run() call returns a non-zero exit code. For some calls, however, this is expected. For example, PNGOut returns an error code of 2 when it

4条回答
  •  没有蜡笔的小新
    2020-12-23 13:36

    Yes, you can. Just change the environment's abort_exception. For example:

    from fabric.api import settings
    
    class FabricException(Exception):
        pass
    
    with settings(abort_exception = FabricException):
        try:
            run()
        except FabricException:
            
    

    The documentation on abort_exception is here.

提交回复
热议问题