Revision 91a61890
Réintroduction modif de la r5128.
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@5148 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigigraph/controllers/rpc.py | ||
---|---|---|
192 | 192 |
@return: url de graphes |
193 | 193 |
@rtype: document html |
194 | 194 |
""" |
195 |
# @TODO: le must serait de hot-patcher mootools pour que son serializer |
|
196 |
# d'URL utilise directement le format attendu par TurboGears |
|
197 |
# (notation pointée plutôt qu'avec des crochets) |
|
198 |
|
|
195 | 199 |
if not kwargs: |
196 | 200 |
return dict(graphslist=[]) |
197 | 201 |
|
... | ... | |
199 | 203 |
# n'accepte pas les chaînes Unicode en entrée. |
200 | 204 |
# TRANSLATORS: Format Python de date/heure, lisible par un humain. |
201 | 205 |
format = _("%a, %d %b %Y %H:%M:%S").encode('utf8') |
206 |
i = 0 |
|
202 | 207 |
graphslist = [] |
203 |
for url in kwargs.itervalues(): |
|
204 |
parts = urlparse.urlparse(url) |
|
205 |
params = dict(parse_qsl(parts.query)) |
|
206 |
|
|
207 |
graph = {} |
|
208 |
start = int(params.get('start', time.time() - 86400)) |
|
209 |
duration = int(params.get('duration', 86400)) |
|
210 |
|
|
211 |
graph['graph'] = params.get('graphtemplate') |
|
212 |
graph['start_date'] = time.strftime(format, |
|
213 |
time.localtime(start)).decode('utf8') |
|
214 |
graph['end_date'] = time.strftime(format, |
|
215 |
time.localtime(start + duration)).decode('utf8') |
|
216 |
graph['img_src'] = url |
|
217 |
graph['host'] = params['host'] |
|
218 |
graphslist.append(graph) |
|
208 |
|
|
209 |
while True: |
|
210 |
try: |
|
211 |
host = kwargs['graphs[%d][host]' % i] |
|
212 |
graph = kwargs['graphs[%d][graph]' % i] |
|
213 |
start = int(kwargs.get('graphs[%d][start]' % i, time.time() - 86400)) |
|
214 |
duration = int(kwargs.get('graphs[%d][duration]' % i)) |
|
215 |
nocache = kwargs['graphs[%d][nocache]' % i] |
|
216 |
except KeyError: |
|
217 |
break |
|
218 |
|
|
219 |
if not (host and graph and duration and nocache): |
|
220 |
break |
|
221 |
|
|
222 |
graphslist.append({ |
|
223 |
'host': host, |
|
224 |
'graph': graph, |
|
225 |
'start': start, |
|
226 |
'duration': duration, |
|
227 |
'nocache': nocache, |
|
228 |
'start_date': time.strftime(format, |
|
229 |
time.localtime(start)).decode('utf8'), |
|
230 |
'end_date': time.strftime(format, |
|
231 |
time.localtime(start + duration)).decode('utf8') |
|
232 |
}) |
|
233 |
i += 1 |
|
219 | 234 |
return dict(graphslist=graphslist) |
220 | 235 |
|
221 | 236 |
@expose('json') |
Also available in: Unified diff