Fabric methods exceptions
- by baobee
I try to make Fabric func, which checks if Apache installed:
from fabric.api import *
def check_apache():
try:
result = local('httpd -v', capture=True)
except:
print "check_apache exception"
But if httpd not installed I get:
[root@server-local ~]$ fab check_apache
Fatal error: local() encountered an error (return code 127) while executing 'ahttpd -v'
Aborting.
check_apache exception
Done.
How can I get correct exception for Fabric local() method ? So I need to get exception and continue executing without any Fabric error messages:
[root@server-local ~]$ fab check_apache
check_apache exception
Done.