How to show an error detected during Fabric () localization

If Fabric encounters an error code when executing the local () command, it throws an exception, for example:

Fatal error: local() encountered an error (return code 127) while executing '...' 

However, it does not actually show any stdout or stderr from the command, even if you specify capture = True, which is very useless. There are explanations on how to do this , but since Fabric throws an exception, you cannot save the result from local () and inherit it.

How do you get Fabric to display useful error messages during errors that occur when running local ()?

+4
source share
1 answer

Otherwise, you can still use the tool from github to achieve this; Gusset

If you decide to follow this option, your code will look like this:

 from gusset.output import with_output from fabric.api import local, task @with_output(verbosity=2) @task def my_failing_task(): local("blahblah") In [4]: my_failing_task() [localhost] local: blahblah /bin/sh: 1: blahblah: not found Fatal error: local() encountered an error (return code 127) while executing 'blahakh' None Aborting. An exception has occurred, use %tb to see the full traceback. 

I also want you to be able to just take the code from Gusset and just paste it into your application

0
source

Source: https://habr.com/ru/post/1482434/


All Articles