From a220ca75495d6d69c5e1f4f72d66c45954e37916 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 21 Mar 2020 17:54:08 +0100 Subject: [PATCH] We need the french latex package --- Dockerfile | 2 +- README.md | 2 +- apps/treasury/views.py | 30 ++++++++++-------------------- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index bfc2a23e..dfc49d04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN apt update && \ # Install LaTeX requirements RUN apt update && \ - apt install -y texlive-latex-extra texlive-fonts-extra && \ + apt install -y texlive-latex-extra texlive-fonts-extra texlive-lang-french && \ rm -rf /var/lib/apt/lists/* COPY . /code/ diff --git a/README.md b/README.md index c87af71e..8f7caa61 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ On supposera pour la suite que vous utilisez Debian/Ubuntu sur un serveur tout n La génération des factures de l'application trésorerie nécessite une installation de LaTeX suffisante : - $ sudo apt install texlive-latex-extra texlive-fonts-extra + $ sudo apt install texlive-latex-extra texlive-fonts-extra texlive-lang-french 2. Clonage du dépot diff --git a/apps/treasury/views.py b/apps/treasury/views.py index ed0065c7..170a837d 100644 --- a/apps/treasury/views.py +++ b/apps/treasury/views.py @@ -134,27 +134,17 @@ class BillingRenderView(LoginRequiredMixin, View): f.write(tex.encode("UTF-8")) del tex - error = subprocess.Popen( - ["pdflatex", "billing-{}.tex".format(pk)], - cwd=tmp_dir, - stdin=open(os.devnull, "r"), - stderr=open(os.devnull, "wb"), - stdout=open(os.devnull, "wb") - ).wait() + for _ in range(2): + error = subprocess.Popen( + ["pdflatex", "billing-{}.tex".format(pk)], + cwd=tmp_dir, + stdin=open(os.devnull, "r"), + stderr=open(os.devnull, "wb"), + stdout=open(os.devnull, "wb") + ).wait() - if error: - raise IOError("An error attempted while generating a billing:", error) - - error = subprocess.Popen( - ["pdflatex", "billing-{}.tex".format(pk)], - cwd=tmp_dir, - stdin=open(os.devnull, "r"), - stderr=open(os.devnull, "wb"), - stdout=open(os.devnull, "wb") - ).wait() - - if error: - raise IOError("An error attempted while generating a billing:", error) + if error: + raise IOError("An error attempted while generating a billing (code=" + str(error) + ")") pdf = open("{}/billing-{}.pdf".format(tmp_dir, pk), 'rb').read() response = HttpResponse(pdf, content_type="application/pdf")