Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fact_pdf_report
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
fact_pdf_report
Commits
697fc7db
Commit
697fc7db
authored
Jul 17, 2019
by
dorp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added docker support and fixed bug in template engine
parent
80a9e922
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
7 deletions
+89
-7
Dockerfile
Dockerfile
+13
-0
docker_entry.py
docker_entry.py
+48
-0
generator.py
pdf_generator/generator.py
+8
-4
template_engine.py
pdf_generator/tex_generation/template_engine.py
+2
-2
report.py
report.py
+18
-1
No files found.
Dockerfile
0 → 100644
View file @
697fc7db
FROM
phusion/baseimage:0.11
WORKDIR
/opt/app
COPY
. /opt/app
RUN
install_clean git python3 python3-pip python3-wheel python3-setuptools texlive-latex-base texlive-latex-extra lmodern
RUN
pip3 install
-r
requirements.txt
RUN
apt-get remove
-y
python3-pip
ENTRYPOINT
["./docker_entry.py"]
docker_entry.py
0 → 100755
View file @
697fc7db
#!/usr/bin/env python3
'''
fact_pdf_report
Copyright (C) 2015-2019 Fraunhofer FKIE
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
import
json
import
shutil
from
pathlib
import
Path
from
tempfile
import
TemporaryDirectory
from
pdf_generator.generator
import
compile_pdf
,
create_templates
def
get_data
():
return
json
.
loads
(
Path
(
'/tmp'
,
'interface'
,
'data'
,
'analysis.json'
)
.
read_text
()),
json
.
loads
(
Path
(
'/tmp'
,
'interface'
,
'data'
,
'meta.json'
)
.
read_text
())
def
move_pdf_report
(
pdf_path
):
shutil
.
move
(
str
(
pdf_path
.
absolute
()),
str
(
Path
(
'/tmp'
,
'interface'
,
'pdf'
,
pdf_path
.
name
)))
def
main
():
analysis
,
meta_data
=
get_data
()
with
TemporaryDirectory
()
as
tmp_dir
:
create_templates
(
analysis
,
meta_data
,
tmp_dir
)
target_path
=
compile_pdf
(
meta_data
,
tmp_dir
)
move_pdf_report
(
target_path
)
return
0
if
__name__
==
'__main__'
:
exit
(
main
())
pdf_generator/generator.py
View file @
697fc7db
...
...
@@ -4,7 +4,7 @@ import shutil
from
pathlib
import
Path
from
tempfile
import
TemporaryDirectory
from
common_helper_process
import
execute_shell_command
_get_return_code
from
common_helper_process
import
execute_shell_command
from
pdf_generator.pre_processing.rest
import
create_request_url
,
request_firmware_data
from
pdf_generator.tex_generation.template_engine
import
Engine
...
...
@@ -12,7 +12,7 @@ from pdf_generator.tex_generation.template_engine import Engine
def
execute_latex
(
tmp_dir
):
current_dir
=
os
.
getcwd
()
os
.
chdir
(
tmp_dir
)
execute_shell_command
_get_return_code
(
'env buf_size=1000000 pdflatex main.tex'
)
execute_shell_command
(
'env buf_size=1000000 pdflatex main.tex'
)
os
.
chdir
(
current_dir
)
...
...
@@ -27,13 +27,17 @@ def generate_analysis_templates(engine, analysis):
def
create_report_filename
(
meta_data
):
return
'{}_analysis_report.pdf'
.
format
(
meta_data
[
'device_name'
]
.
replace
(
' '
,
'_'
)
.
replace
(
'/'
,
'__'
))
unsafe_name
=
'{}_analysis_report.pdf'
.
format
(
meta_data
[
'device_name'
])
safer_name
=
unsafe_name
.
replace
(
' '
,
'_'
)
.
replace
(
'/'
,
'__'
)
return
safer_name
.
encode
(
'latin-1'
,
errors
=
'ignore'
)
.
decode
(
'latin-1'
)
def
compile_pdf
(
meta_data
,
tmp_dir
):
copy_fact_image
(
tmp_dir
)
execute_latex
(
tmp_dir
)
shutil
.
move
(
str
(
Path
(
tmp_dir
,
'main.pdf'
)),
str
(
Path
(
create_report_filename
(
meta_data
))))
target_path
=
Path
(
tmp_dir
,
create_report_filename
(
meta_data
))
shutil
.
move
(
str
(
Path
(
tmp_dir
,
'main.pdf'
)),
str
(
target_path
))
return
target_path
def
create_templates
(
analysis
,
meta_data
,
tmp_dir
):
...
...
pdf_generator/tex_generation/template_engine.py
View file @
697fc7db
...
...
@@ -49,8 +49,8 @@ def filter_latex_special_chars(data):
latex_character_escapes
[
'$'
]
=
'
\\
$'
latex_character_escapes
[
'('
]
=
'$($'
latex_character_escapes
[
')'
]
=
'$)$'
latex_character_escapes
[
'['
]
=
'$[$'
,
latex_character_escapes
[
']'
]
=
'$]$'
,
latex_character_escapes
[
'['
]
=
'$[$'
latex_character_escapes
[
']'
]
=
'$]$'
latex_character_escapes
[
'#'
]
=
'
\\
#'
latex_character_escapes
[
'
%
'
]
=
'
\\
%
'
latex_character_escapes
[
'&'
]
=
'
\\
&'
...
...
report.py
View file @
697fc7db
#! /usr/bin/env python3
#!/usr/bin/env python3
'''
fact_pdf_report
Copyright (C) 2015-2019 Fraunhofer FKIE
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
import
argparse
import
logging
...
...
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