#NEWLINE# def _swift_call( self , region , action , * args , **kwargs ) : #NEWLINE# #INDENT# 'Wrap calls to swiftclient to allow retry.' #NEWLINE# try : #NEWLINE# #INDENT# region_name = region . name #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# region_name = region #NEWLINE# #UNINDENT# retries = 0 #NEWLINE# while ( retries < 3 ) : #NEWLINE# #INDENT# if ( region_name not in self . swifts ) : #NEWLINE# #INDENT# self . swifts [ region_name ] = self . _get_swift_client ( region_name ) #NEWLINE# #UNINDENT# swift = self . swifts [ region_name ] [ 'client' ] #NEWLINE# call = getattr ( swift , action . lower ( ) ) #NEWLINE# try : #NEWLINE# #INDENT# return call ( * args , ** kwargs ) #NEWLINE# #UNINDENT# except swiftclient . exceptions . ClientException as e : #NEWLINE# #INDENT# if ( e . http_status == 401 ) : #NEWLINE# #INDENT# del self . swifts [ region_name ] #NEWLINE# #UNINDENT# if ( e . http_status == 404 ) : #NEWLINE# #INDENT# raise ResourceNotFoundError ( msg = e . msg ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise retries #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# raise APIError ( msg = 'Impossible to get a valid token' )