Monday, 1 November 2021

How to ignore command failure when running it using Fabric 2

In Fabric 1 it looks like this:

with settings(warn_only=True):
    run_commands_that_may_fail()

It is unclear how to implement it in Fabric 2, pyinvoke via context manager. The upgrade docs recommend replacing warn_only with run.warn. I've come up with:

old_warn = c.config.run.warn
c.config.run.warn = True
try:
    run_commands_that_may_fail(c)
finally:
    c.config.run.warn = old_warn

Perhaps, there is a nicer way that is similar to Fabric's 1.



from How to ignore command failure when running it using Fabric 2

No comments:

Post a Comment