fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fab-user] How to capture abort message


From: Ruoyan Wang
Subject: [Fab-user] How to capture abort message
Date: Wed, 31 Jul 2013 18:21:40 +0800

Hi~

    Currently I use fabric api to develop a server administrator management system.
    I hope
to capture the exception
or error message, but abory() and error() does not provide a method.

   
Is there any good way? More thanks.


def run_with_exceptions(command, **kwargs):

    try:
        output = run(command, **kwargs)

    except SystemExit:
        # capture abort message at here

    except CommandTimeout:
        raise CommandExecuteTimeout

    except SSHException, e:
        if 'Invalid key' in e:
            raise SshBadHostKeyException

    except IOError, e:
        if 'No such file or directory' in e:
            raise SshBadPrivateKeyPath

    except NetworkError, e:
        if 'Timed out trying to connect to' in e or 'Low level socket error connecting' in e:
            raise SshConnectionTimeout
        elif 'Name lookup failed for' in e:
            raise IncorrectNodeAddress
        else:
            raise

    except Exception:
        raise

    finally:
        return output if output else None


Nothing is Sound.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]