Fabric methods exceptions

Posted by baobee on Stack Overflow See other posts from Stack Overflow or by baobee
Published on 2011-02-17T15:21:48Z Indexed on 2011/02/17 15:25 UTC
Read the original article Hit count: 237

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about python

Related posts about exception