Skip to content

Commit

Permalink
pdf generation bugfix & bump up version
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandip Samal committed Jul 14, 2021
1 parent dbdc805 commit 9b49446
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 177 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
FROM python:3.9.1-slim-buster
LABEL maintainer="Sandip Samal <[email protected]>"
RUN apt-get update \
&& apt-get install -y libsm6 libxext6 libxrender-dev wkhtmltopdf xvfb \
&& apt-get install -y wkhtmltopdf xvfb \
&& rm -rf /var/lib/apt/lists/*

ENV XDG_RUNTIME_DIR=/bin/wkhtmltopdf
Expand Down
Binary file removed mgz2lut_report/assets/[email protected]
Binary file not shown.
Binary file removed mgz2lut_report/assets/[email protected]
Binary file not shown.
168 changes: 0 additions & 168 deletions mgz2lut_report/assets/pdfstyle.css

This file was deleted.

16 changes: 12 additions & 4 deletions mgz2lut_report/mgz2lut_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,25 @@ def run(self, options):
if report_type == 'pdf':
f = open("/tmp/report.html",'a')
f.write(result)

# Certain .html files fail to be saved by pdfkit,
# a hack is to open the file in read mode and then
# save it.
f = open("/tmp/report.html",'r')
opt = {
'quiet':''
}

# Ensure pdfkit config is available
try:
config = pdfkit.configuration()
print (config)
except OSError:
print ("missing wkhtmltopdf")
pdfkit.from_file("/tmp/report.html",report_path,options=opt,configuration=config)
try:
pdfkit.from_file("/tmp/report.html",report_path,options=opt,configuration=config)
except OSError:
print ("failed to save pdf")
continue;
for k in sorted(counter.keys()):
res_df=df_FSColorLUT.loc[df_FSColorLUT['#No'] == str(k),['LabelName']]
Expand All @@ -282,9 +292,7 @@ def run(self, options):
else:
f.write(rep.to_string(index=False))
f.close()

f = open(report_path,'r')
#print(f.read())

print("Report saved as %s/%s in %s format(s)" %(options.outputdir,options.report_name, options.report_types))

def show_man_page(self):
Expand Down
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name = 'mgz2lut_report',
version = '1.2.5',
version = '1.3.0',
description = 'An app to generate a report on volumes of various brain segments listed in a Look-up Table (Default = FreeSurferColorLUT.txt',
long_description = readme,
author = 'Sandip Samal',
Expand All @@ -19,9 +19,6 @@
license = 'MIT',
zip_safe = False,
python_requires = '>=3.8',
package_data = {
'mgz2lut_report': ['assets/*']
},
entry_points = {
'console_scripts': [
'mgz2lut_report = mgz2lut_report.__main__:main'
Expand Down

0 comments on commit 9b49446

Please sign in to comment.