def __exit__(self, prev_exc_type, prev_exc_val, prev_exc_trace): try: self.Close() except: # pylint: disable=bare-except exceptions.RaiseWithContext(prev_exc_type, prev_exc_val, prev_exc_trace, *sys.exc_info()) # Always return False so any previous exception will be re-raised. return False
def __exit__(self, prev_exc_type, prev_exc_val, prev_exc_trace): try: self._run('compute sole-tenancy hosts delete {} --zone {} --quiet'. format(self._name, self._zone)) except: # pylint: disable=bare-except exceptions.RaiseWithContext(prev_exc_type, prev_exc_val, prev_exc_trace, *sys.exc_info()) # Always return False so any previous exception will be re-raised. return False
def _RaiseWithContext(self, msg1, msg2): try: raise ValueError(msg1) except ValueError as e1: tb1 = sys.exc_info()[2] try: raise RuntimeError(msg2) except RuntimeError as e2: tb2 = sys.exc_info()[2] exceptions.RaiseWithContext(type(e1), e1, tb1, type(e2), e2, tb2)