Skip to content

Instantly share code, notes, and snippets.

@whitmo
Created December 2, 2011 21:01
Show Gist options
  • Select an option

  • Save whitmo/1424820 to your computer and use it in GitHub Desktop.

Select an option

Save whitmo/1424820 to your computer and use it in GitHub Desktop.
sshcm.py
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' %(exc))
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