def retry_wrapper(func):
def try_and_retry(*args, **kwargs):
retry = False
try:
return func(*args, **kwargs)
except utils.SOSError as e:
# if we got an http error and
# the string contains 401 or if the string contains the word cookie
if (e.err_code == utils.SOSError.HTTP_ERR and
(e.err_text.find('401') != -1 or
e.err_text.lower().find('cookie') != -1)):
retry = True
CoprHDCLIDriver.AUTHENTICATED = False
else:
exception_message = "\nViPR Exception: %s\nStack Trace:\n%s" \
% (e.err_text, traceback.format_exc())
raise utils.SOSError(utils.SOSError.SOS_FAILURE_ERR,"Exception is : "+exception_message)
except Exception:
exception_message = "\nGeneral Exception: %s\nStack Trace:\n%s" \
% (sys.exc_info()[0], traceback.format_exc())
raise utils.SOSError(utils.SOSError.SOS_FAILURE_ERR,"Exception is : "+exception_message)
if retry:
return func(*args, **kwargs)
return try_and_retry
评论列表
文章目录