Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
dashboards
Commits
f81c7d527c3f
Commit
5df18e09
authored
Nov 19, 2020
by
Laurent Peuch
Browse files
feat(deprecated): include the full traceback of the warnings
parent
5b36dd6298c7
Changes
4
Hide whitespace changes
Inline
Side-by-side
deprecated-warnings.py
View file @
f81c7d52
...
...
@@ -112,6 +112,18 @@ def get_all_cubes():
yield
cnx
.
projects
.
get
(
id
=
project_id
)
def
render_traceback
(
traceback_id
,
traceback
,
warning_name
):
os
.
makedirs
(
"public/traceback"
,
exist_ok
=
True
)
rendered_template
=
jinja2
.
Template
(
open
(
"template/traceback.html"
,
"r"
).
read
()).
render
(
traceback
=
reversed
(
traceback
),
files_to_url
=
files_to_url_cache
,
highlight_code
=
highlight_code
,
warning_name
=
warning_name
,
pygment_css
=
HtmlFormatter
().
get_style_defs
())
open
(
f
"public/traceback/
{
traceback_id
}
.html"
,
"w"
).
write
(
rendered_template
)
download_files_to_url_cache
()
files_to_url_cache
=
json
.
load
(
open
(
"files_to_url_cache.json"
))
...
...
@@ -194,5 +206,7 @@ rendered_template = jinja2.Template(open("template/deprecated-warnings.html",
"r"
).
read
()).
render
(
warnings
=
result
,
files_to_url
=
files_to_url_cache
,
highlight_code
=
highlight_code
,
str
=
str
,
render_traceback
=
render_traceback
,
pygment_css
=
HtmlFormatter
().
get_style_defs
())
open
(
"public/deprecated-warnings.html"
,
"w"
).
write
(
rendered_template
)
public/css/style.css
View file @
f81c7d52
...
...
@@ -123,3 +123,7 @@ table.qa td.readthedocs a {
text-decoration
:
none
;
font-style
:
italic
;
}
.highlighttable
pre
{
margin-top
:
0
;
}
template/deprecated-warnings.html
View file @
f81c7d52
...
...
@@ -34,31 +34,37 @@
</ul>
{% endif %}
{% for project, project_data in warning_data["projects"].items() %}
<h4>
Project
<a
target=
"_blank"
href=
"{{ project.web_url }}"
>
{{ project.name }}
</a>
({{ project_data["count"] }} occurences)
</h4>
{% for project, project_data in warning_data["projects"].items() %}
<h4>
Project
<a
target=
"_blank"
href=
"{{ project.web_url }}"
>
{{ project.name }}
</a>
({{ project_data["count"] }} occurences)
</h4>
<p>
Dependencies (detected during tests execution):
</p>
<p>
Dependencies (detected during tests execution):
</p>
<ul>
{%- for i in ("Cubicweb", "Yams", "RQL", "logilab-common", "logilab-database") -%}
{%- if i.lower() in project_data["dependencies"] -%}
<li><i>
{{ i }}
</i>
{{ project_data["dependencies"][i.lower()] }}
</li>
{%- endif -%}
{%- endfor -%}
</ul>
<ul>
{%- for i in ("Cubicweb", "Yams", "RQL", "logilab-common", "logilab-database") -%}
{%- if i.lower() in project_data["dependencies"] -%}
<li><i>
{{ i }}
</i>
{{ project_data["dependencies"][i.lower()] }}
</li>
{%- endif -%}
{%- endfor -%}
</ul>
{% for (path, lineno), warning in project_data["warnings"].items() %}
<p>
In
<u>
{{ path }}
</u>
line {{ lineno }}
{% if path in files_to_url %}(
<a
href=
"{{ files_to_url[path] }}#L{{ lineno }}"
target=
"_blank"
>
file on branch/default
</a>
){% endif %}
</p>
{% with warning_id=loop.index %}
{% for (path, lineno), warning in project_data["warnings"].items() %}
<p>
{% if "file_content" in warning %}
{{ highlight_code(warning["file_content"], lineno) }}
{% endif %}
{% with traceback_id=str(warning_id) + "_" + str(project.id) + "_" + path.replace("/", "_") + "_" + str(lineno) %}
In
<u>
{{ path }}
</u>
line {{ lineno }} (
<a
href=
"traceback/{{ traceback_id }}.html"
>
full traceback
</a>
)
{{- render_traceback(traceback_id, warning["traceback"], warning_name) or "" -}}
{% endwith %}
{% endfor %}
{% if path in files_to_url %}(
<a
href=
"{{ files_to_url[path] }}#L{{ lineno }}"
target=
"_blank"
>
file on branch/default
</a>
){% endif %}
</p>
{% if "file_content" in warning %}
{{ highlight_code(warning["file_content"], lineno) }}
{% endif %}
{% endfor %}
{% endwith %}
{% endfor %}
...
...
template/traceback.html
0 → 100644
View file @
f81c7d52
<!doctype html>
<html>
<head>
<title>
Traceback
</title>
<link
href=
"../css/style.css"
rel=
"stylesheet"
type=
"text/css"
>
<style>
{
{
pygment_css
}
}
</style>
</head>
<body>
<h2>
{{ warning_name }}
</h2>
<p><i>
The stack frame is in reversed order for practical reason, the upper one first
</i></p>
{% for frame in traceback %}
<div
class=
"stack-frame"
>
<span><u>
{{ frame["filename"] }}
</u>
line {{ frame["lineno"] }}
<span>
{% if frame["file_content"] %}
{{ highlight_code(frame["file_content"], frame["lineno"]) }}
{% endif %}
</div>
{% endfor %}
</body>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment