Skip to content

Commit 01cb2ac

Browse files
author
Marcin Kardas
committed
Better error message when conversion fails
1 parent 6991550 commit 01cb2ac

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

latex2html.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ do
2424
done
2525

2626
MAINTEX=$(python3 /files/guess_main.py "$SOURCE_DIR")
27+
[ ! -f "$MAINTEX" ] && exit 1
28+
2729
timeout -s KILL 300 engrafo "$MAINTEX" /files/output
2830

31+
[ ! -f /files/output/index.html ] && exit 117
2932
cp /files/output/index.html "$OUTPUT_DIR/$OUTNAME"

sota_extractor2/helpers/latex_converter.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ def ro_bind(path): return dict(bind=path, mode='ro')
1212
def rw_bind(path): return dict(bind=path, mode='rw')
1313

1414

15+
# magic constant used in latex2html.sh to signal that
16+
# conversion failed on LaTeXML step
17+
MAGIC_EXIT_ERROR = 117
18+
19+
1520
class LatexConverter:
1621
def __init__(self, base_path):
1722
# pull arxivvanity/engrafo image
@@ -48,7 +53,13 @@ def latex2html(self, source_dir, output_dir, use_named_volumes=False):
4853
command = [scriptname, filename]
4954

5055
output_dir.mkdir(parents=True, exist_ok=True)
51-
self.client.containers.run("arxivvanity/engrafo:b3db888fefa118eacf4f13566204b68ce100b3a6", command, remove=True, volumes=volumes)
56+
57+
try:
58+
self.client.containers.run("arxivvanity/engrafo:b3db888fefa118eacf4f13566204b68ce100b3a6", command, remove=True, volumes=volumes)
59+
except ContainerError as err:
60+
if err.exit_status == MAGIC_EXIT_ERROR:
61+
raise LatexConversionError("LaTeXML was unable to convert source code of this paper")
62+
raise
5263

5364
# todo: check for errors
5465

0 commit comments

Comments
 (0)