From: Alfredo Deza Date: Wed, 20 Nov 2013 17:35:52 +0000 (-0500) Subject: create a remote error utility to capture traceback info X-Git-Tag: 0.0.12~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0002ba0fbbc848683f55b5ca9a88c3aef2d52d24;p=remoto.git create a remote error utility to capture traceback info --- diff --git a/remoto/util.py b/remoto/util.py index 6098ac7..3dad572 100644 --- a/remoto/util.py +++ b/remoto/util.py @@ -14,3 +14,17 @@ def admin_command(sudo, command): command = [command] return ['sudo'] + [cmd for cmd in command] return command + + +class RemoteError(object): + + def __init__(self, traceback): + self.orig_traceback = traceback + self.exception_name = self.get_exception_name() + + def get_exception_name(self): + for tb_line in reversed(self.orig_traceback.split('\n')): + if tb_line: + for word in tb_line.split(): + if word.endswith(':'): # exception! + return word.strip().strip(':')