예제 #1
0
 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
예제 #2
0
 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
예제 #3
0
 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)