vigigraph / vigigraph / controllers / error.py @ 5b44cbbd
History | View | Annotate | Download (3.68 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
"""Error controller"""
|
3 |
|
4 |
from tg import request, expose |
5 |
|
6 |
__all__ = ['ErrorController']
|
7 |
|
8 |
|
9 |
class ErrorController(object): |
10 |
"""
|
11 |
Generates error documents as and when they are required.
|
12 |
|
13 |
The ErrorDocuments middleware forwards to ErrorController when error
|
14 |
related status codes are returned from the application.
|
15 |
|
16 |
This behaviour can be altered by changing the parameters to the
|
17 |
ErrorDocuments middleware in your config/middleware.py file.
|
18 |
|
19 |
"""
|
20 |
|
21 |
@expose('error.html') |
22 |
def document(self, *args, **kwargs): |
23 |
"""Render the error document"""
|
24 |
resp = request.environ.get('pylons.original_response')
|
25 |
default_message = ("<p>We're sorry but we weren't able to process "
|
26 |
" this request.</p>")
|
27 |
values = dict(prefix=request.environ.get('SCRIPT_NAME', ''), |
28 |
code=request.params.get('code', resp.status_int),
|
29 |
message=request.params.get('message', default_message))
|
30 |
return values
|
31 |
|
32 |
@expose('') |
33 |
def rrd_txt_error(self, **kwargs): |
34 |
"""
|
35 |
Gestion erreur rrd
|
36 |
|
37 |
@param kwargs : arguments nommes
|
38 |
@type kwargs : dict
|
39 |
(pour la clé 'txt', contient le texte)
|
40 |
|
41 |
@return: texte de l erreur
|
42 |
@rtype : C{str}
|
43 |
"""
|
44 |
|
45 |
txt = None
|
46 |
if kwargs is not None: |
47 |
txt = kwargs.get('txt')
|
48 |
return txt
|
49 |
|
50 |
@expose('rrd_error.html') |
51 |
def rrd_error(self, **kwargs): |
52 |
"""
|
53 |
Gestion erreur rrd
|
54 |
|
55 |
@param kwargs : arguments nommes
|
56 |
@type kwargs : dict
|
57 |
(pour la clé 'host', contient l'hôte)
|
58 |
|
59 |
@return: page erreur
|
60 |
@rtype: page (-> dict sur template rrd_error.html)
|
61 |
"""
|
62 |
|
63 |
host = None
|
64 |
if kwargs is not None: |
65 |
host = kwargs.get('host')
|
66 |
return dict(host=host) |
67 |
else:
|
68 |
return None |
69 |
|
70 |
@expose('rrd_error.html') |
71 |
def rrd_exportCSV_error(self, **kwargs): |
72 |
"""
|
73 |
Gestion erreur rrd sur export CSV
|
74 |
|
75 |
@param kwargs : arguments nommes
|
76 |
@type kwargs : dict
|
77 |
(pour la clé 'host', contient l'hôte)
|
78 |
|
79 |
@return: page erreur
|
80 |
@rtype: page (-> dict sur template rrd_error.html)
|
81 |
"""
|
82 |
|
83 |
host = None
|
84 |
if kwargs is not None: |
85 |
host = kwargs.get('host')
|
86 |
return dict(host=host) |
87 |
else:
|
88 |
return None |
89 |
|
90 |
@expose('nagios_host_error.html') |
91 |
def nagios_host_error(self, **kwargs): |
92 |
"""
|
93 |
Gestion erreur nagios sur l hote
|
94 |
|
95 |
@param kwargs : arguments nommes
|
96 |
@type kwargs : dict
|
97 |
|
98 |
@return: page erreur
|
99 |
@rtype: page
|
100 |
|
101 |
(arguments nommes : pour la clé 'host', contient l'hôte)
|
102 |
"""
|
103 |
|
104 |
host = None
|
105 |
if kwargs is not None: |
106 |
host = kwargs.get('host')
|
107 |
return dict(host=host) |
108 |
else:
|
109 |
return None |
110 |
|
111 |
@expose('nagios_host_service_error.html') |
112 |
def nagios_host_service_error(self, **kwargs): |
113 |
"""
|
114 |
Gestion erreur nagios sur l'hote et le service
|
115 |
|
116 |
@param kwargs : arguments nommes
|
117 |
@type kwargs : dict
|
118 |
(pour la clé 'host', contient l'hôte)
|
119 |
(pour la clé 'service', contient le service)
|
120 |
|
121 |
@return: page erreur
|
122 |
@rtype: page (-> dict sur template nagios_host_service_error.html)
|
123 |
"""
|
124 |
|
125 |
host = None
|
126 |
service = None
|
127 |
if kwargs is not None: |
128 |
host = kwargs.get('host')
|
129 |
service = kwargs.get('service')
|
130 |
return dict(host=host, service=service) |
131 |
else:
|
132 |
return None |
133 |
|