CMS 3D CMS Logo

Classes | Functions
errors Namespace Reference

Classes

class  NoMoreRetriesException
 
class  ServerNotFoundException
 

Functions

def check_response (check="json")
 

Detailed Description

File that contains errors that can occur in CondDBFW.

Function Documentation

def errors.check_response (   check = "json")

Definition at line 27 of file errors.py.

References beamvalidation.exit(), and str.

Referenced by uploads.uploader.close_upload_session(), uploads.uploader.get_all_hashes(), uploads.uploader.get_upload_session_id(), uploads.uploader.send_blob(), and uploads.uploader.send_payloads().

27 def check_response(check="json"):
28 
29  def checker(function):
30 
31  def function_with_exception(self, *args, **kwargs):
32  return_value = None
33  try:
34  return_value = function(self, *args, **kwargs)
35  if check == "json":
36  dictionary = json.loads(return_value)
37  return dictionary
38  elif check == "base64":
39  return base64.b64decode(str(return_value))
40  else:
41  return return_value
42  except (ValueError, TypeError) as e:
43  # the server response couldn't be decoded, so write the log file data to file, and exit
44  self._outputter.write("Couldn't decode response in function '%s' - this is a fault on the server side. Response is:" % function.__name__)
45  self._outputter.write(return_value)
46  self.write_server_side_log(self._log_data)
47  exit()
48  # no need to catch any other exceptions, since this is left to the method that calls 'function'
49 
50  function_with_exception.__doc__ = function.__doc__
51 
52  return function_with_exception
53 
54  return checker
Definition: vlib.h:246
def check_response(check="json")
Definition: errors.py:27
#define str(s)
def exit(msg="")