Skip to content

Commit

Permalink
Add KEEP_WORKSPACE_DIR and KEEP_WORKSPACE_DIR_ON_ERROR envs
Browse files Browse the repository at this point in the history
  • Loading branch information
MonsieurV committed Jun 28, 2024
1 parent 2eea276 commit bfab553
Show file tree
Hide file tree
Showing 10 changed files with 368 additions and 358 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ importlib-metadata = "*"
hyrule = "*"
sentry-sdk = {extras = ["flask"], version = "*"}
cerberus = "*"
envparse = "*"

[requires]
python_version = "3"
697 changes: 347 additions & 350 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cache.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# TODO Publish the final image?

FROM python:3.8-alpine
FROM python:3.12-alpine
LABEL maintainer="Yoan Tournade <[email protected]>"

# Set locales.
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ services:
- .:/app/latex-on-http
environment:
CACHE_HOST: cache
# KEEP_WORKSPACE_DIR: 1
KEEP_WORKSPACE_DIR_ON_ERROR: 1
cache:
build:
context: .
Expand Down
12 changes: 8 additions & 4 deletions latexonhttp/api/builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
:copyright: (c) 2017-2019 Yoan Tournade.
:license: AGPL, see LICENSE for more details.
"""
import envparse
import logging
import pprint
import json
Expand Down Expand Up @@ -42,6 +43,10 @@
logger = logging.getLogger(__name__)

builds_app = Blueprint("builds", __name__)
KEEP_WORKSPACE_DIR = envparse.env("KEEP_WORKSPACE_DIR", cast=bool, default=False)
KEEP_WORKSPACE_DIR_ON_ERROR = envparse.env(
"KEEP_WORKSPACE_DIR_ON_ERROR", cast=bool, default=False
)


# TODO Extract the filesystem/workspace management in a module:
Expand Down Expand Up @@ -341,9 +346,8 @@ def on_fetched(resource, data):

# TODO Option to let workspace on failure
# from env.
let_workspace_on_error = False

if let_workspace_on_error is False or (
error_in_try_block is None and error_compilation is None
if KEEP_WORKSPACE_DIR is False and (
KEEP_WORKSPACE_DIR_ON_ERROR is False
or (error_in_try_block is None and error_compilation is None)
):
remove_workspace(workspace_id)
1 change: 1 addition & 0 deletions latexonhttp/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def latexToPdf(compilerName, directory, main_resource, options={}):
"-W=all"
# TODO Add -halt-on-error --interaction=nonstopmode
# TODO Let user choose DVI (or other supported) output.
# TODO -shell-restricted / -shell-escape
'--latex-args="--output-format=pdf"',
"--bibtex-cmd={}".format(bibtexCommand),
input_path,
Expand Down
8 changes: 5 additions & 3 deletions latexonhttp/latexrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -1520,9 +1520,11 @@ def __errmessage(self):
stack_msg += (
"\n " + (" " * trace) + "^"
if isinstance(trace, int)
else "\n at " + trace.rstrip()
if i == 0
else "\n from " + trace.rstrip()
else (
"\n at " + trace.rstrip()
if i == 0
else "\n from " + trace.rstrip()
)
)

if is_fatal_error:
Expand Down
1 change: 1 addition & 0 deletions tests/test_fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:copyright: (c) 2018 Yoan Tournade.
:license: AGPL, see LICENSE for more details.
"""

import requests


Expand Down
1 change: 1 addition & 0 deletions tests/test_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:copyright: (c) 2019 Yoan Tournade.
:license: AGPL, see LICENSE for more details.
"""

import requests


Expand Down
1 change: 1 addition & 0 deletions tests/utils/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:copyright: (c) 2018 Yoan Tournade.
:license: AGPL, see LICENSE for more details.
"""

import os
import re
import difflib
Expand Down

0 comments on commit bfab553

Please sign in to comment.