In the eventuality that Fabric exits cleanly or not, I need to execute a bunch of clean-up tasks (mostly delete temp files and folders).
How can I achieve this with Fabric?
Put something like this in your fabfile:
from fabric.context_managers import settings
def task_name():
# commands that are not expected to fail
...
with settings(warn_only=True):
# commands that might fail
...
clean_up()
You may even want to give the entire task the warn_only=True
treatment, if you don't care:
@with_settings(warn_only=True)
def task_name():
...
(more info)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With