Created
September 6, 2011 22:15
-
-
Save whitmo/1199164 to your computer and use it in GitHub Desktop.
ssh cm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from fabric import network as net | |
| @contextmanager | |
| def ssh2(notify, raise_error=False): | |
| try: | |
| yield | |
| except : | |
| exc_t, exc, tb = sys.exc_info() | |
| if isinstance(exc, exceptions.SystemExit): | |
| notify('Task aborted. Check fabworker logs.') | |
| else: | |
| notify('Task error: %s %s' %(exc, exc.message)) | |
| logger.error(traceback.format_exc()) | |
| if raise_error: | |
| raise | |
| finally: | |
| net.disconnect_all() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment