Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
CondCore
Utilities
python
CondDBFW
errors.py
Go to the documentation of this file.
1
"""
2
3
File that contains errors that can occur in CondDBFW.
4
5
"""
6
7
import
traceback
8
import
json
9
import
base64
10
11
# not needed - since no more retries is the same as this
12
class
ServerNotFoundException
(
Exception
):
13
def
__init__
(self, server_name):
14
self.
server_name
= server_name
15
16
def
__str__
(self):
17
return
"The server '%s' was not found."
% self.
server_name
18
19
class
NoMoreRetriesException
(
Exception
):
20
def
__init__
(self, retry_limit):
21
self.
retry_limit
= retry_limit
22
23
def
__str__
(self):
24
return
"Ran out of retries for contacting the server, where the limit was %d"
% self.
retry_limit
25
26
# decorator to check response for error messages - if it contains an error message, throw the appropriate exception
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
errors.NoMoreRetriesException.__str__
def __str__
Definition:
errors.py:23
errors.NoMoreRetriesException.__init__
def __init__
Definition:
errors.py:20
errors.NoMoreRetriesException
Definition:
errors.py:19
errors.NoMoreRetriesException.retry_limit
retry_limit
Definition:
errors.py:21
callgraph.function
string function
Definition:
callgraph.py:50
errors.ServerNotFoundException.__init__
def __init__
Definition:
errors.py:13
errors.ServerNotFoundException.server_name
server_name
Definition:
errors.py:14
errors.ServerNotFoundException.__str__
def __str__
Definition:
errors.py:16
Exception
beamvalidation.exit
def exit
Definition:
beamvalidation.py:52
errors.ServerNotFoundException
Definition:
errors.py:12
str
#define str(s)
Definition:
TestProcessor.cc:54
errors.check_response
def check_response
Definition:
errors.py:27
Generated for CMSSW Reference Manual by
1.8.5