📣 An issue occured with the embedded container registry on October 25 2021, between 10:30 and 12:10 (UTC+2). Any persisting issues should be reported to CC-IN2P3 Support. 🐛

Commit dddff7b4 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch '31-python37' into 'master'

Resolve "migrate to python3.7"

Closes #31

See merge request !37
parents e3256b57 ea1db58b
# -*- coding: utf-8 -*-
"""Configure the build process for the plugin_event
"""
# ............................................................................
#
# JAVASCRIPT LIBRARY
# JavaScript source code and compile version
# paths are relative to the static directory
#
SENCHA_CLS = [
"plugin_event/src",
"plugin_dbui/src",
"plugin_extjs/packages/core/src",
"plugin_extjs/classic/classic/src",
"plugin_extjs/classic/classic/overrides"]
SENCHA_NS = "Ext,Dbui"
JSLIBDEBUG = "plugin_event/event-debug.js"
JSLIBMIN = "plugin_event/event-min.js"
# ...........................................................................
#
# DOCUMENTATION
# output directories for documentation
# paths are relative to the static directory
#
DOCS_DIR = "plugin_event/docs"
JSDOC = "plugin_event/docs/jsduck"
LATEXDOC = "plugin_event/docs/latex"
PDFDOC = "plugin_event/docs/pdf"
# ...........................................................................
#
# PLUGINS
# event
# paths are relative to the application directory
#
PLUGINS_FILES = {}
PLUGINS_FILES["default"] = [
"controllers/plugin_%s.py",
"models/plugin_%s.py",
"modules/plugin_%s",
"private/plugin_%s",
"static/plugin_%s",
"views/plugin_%s"]
PLUGINS_FILES["event"] = [
"controllers/plugin_event.py",
"modules/plugin_event",
"static/plugin_event",
"views/plugin_event"]
# ............................................................................
#
# REFERENCE FILES
#
CHANGELOG = "static/plugin_event/CHANGELOG"
VERSION = "static/plugin_event/VERSION"
# -*- coding: utf-8 -*-
""" Controllers
"""
......@@ -12,7 +11,7 @@ def index():
"""
# login procedure is active
if session.auth:
roles = session.auth.user_groups.values()
roles = list(session.auth.user_groups.values())
if roles:
session.role = roles[0]
......
# -*- coding: utf-8 -*-
"""plugin_event controllers
"""
import json
import traceback
import urllib
from datetime import datetime
from matplotlib.figure import Figure
from plugin_dbui import get_id
from plugin_event import (Graph,
List,
Metric2D,
ReportException,
Source)
from plugin_event import ReportException
MSG = T("%s entry(ies) modified in the history table. "
"DO NOT FORGET TO MODIFIED CONFIGURATION OF REPORT(s).")
......@@ -32,6 +28,8 @@ def grid():
the data displayed in the grid.
"""
from plugin_event import List
try:
report = List(request.vars.id_list)
store = report.get_store_configuration()
......@@ -41,7 +39,6 @@ def grid():
except (IndexError, ReportException, TypeError, ValueError):
return CODE(traceback.format_exc()).xml()
response.view = "plugin_event/grid.html"
return dict(cfg_store=store, grid=grid, title=title)
......@@ -58,38 +55,42 @@ def metric2d():
the graph.
"""
extension = request.extension
import base64
import io
import os
from uuid import uuid4
from plugin_event import Graph, Metric2D, mplstyle
try:
report = Metric2D(request.vars.id_metric2d)
graph = Graph(report)
title = report.get_title()
mplstyle()
fig = Figure()
Graph(report, fig)
extension = request.extension
if extension == "html":
store = report.get_store_configuration()
grid = report.get_grid_configuration()
if graph.ax is not None:
img = graph.to_svg()
img = urllib.quote(img)
buf = io.BytesIO()
fig.savefig(buf, format="svg")
data = base64.b64encode(buf.getbuffer()).decode("ascii")
response.view = "plugin_event/grid_and_graph.html"
return dict(cfg_store=store, grid=grid, img=img, title=title)
title = report.get_title()
else:
response.view = "plugin_event/grid.html"
return dict(cfg_store=store, grid=grid, title=title)
return dict(cfg_store=store, grid=grid, img=data, title=title)
elif extension == "pdf":
data = graph.to_pdf()
response.view = "plugin_event/graph.pdf"
return dict(data=data, title=title)
else:
fn = str(uuid4())
pfn = os.path.join("/tmp", f"{fn}.{extension}")
elif extension == "png":
data = graph.to_png()
response.view = "plugin_event/graph.png"
return dict(data=data, title=title)
with open(pfn, "wb") as fi:
fig.savefig(fi, format=extension)
return response.stream(pfn)
except (IndexError, ReportException, TypeError, ValueError):
return CODE(traceback.format_exc()).xml()
......@@ -100,6 +101,8 @@ def source():
Values send by the selector are used to filter the content of the source.
"""
from plugin_event import Source
try:
report = Source(request.vars.source)
store = report.get_store_configuration()
......@@ -145,7 +148,7 @@ def userModelConsistency():
if update_keys:
ok = False
for k, v in update_keys.iteritems():
for k, v in update_keys.items():
if oldkey == v:
update_keys[k] = newkey
ok = True
......@@ -212,7 +215,7 @@ def userModelConsistency():
data[key] = (rd[key] if key in rd else model[key]["value"])
# modify key name
for oldkey, newkey in update_keys.iteritems():
for oldkey, newkey in update_keys.items():
if oldkey in rd:
data[newkey] = rd[oldkey]
......
plugin_event.Graph.to_pdf
=========================
.. currentmodule:: plugin_event
.. automethod:: Graph.to_pdf
\ No newline at end of file
plugin_event.Graph.to_png
=========================
.. currentmodule:: plugin_event
.. automethod:: Graph.to_png
\ No newline at end of file
plugin_event.Graph.to_svg
=========================
.. currentmodule:: plugin_event
.. automethod:: Graph.to_svg
\ No newline at end of file
......@@ -24,7 +24,7 @@ def get_version():
str: the version number
"""
with open('../../VERSION') as fi:
with open('../../../VERSION') as fi:
return fi.read()
# If extensions (or modules to document with autodoc) are in another directory,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment