Commit d2181317 authored by Daniel STAN's avatar Daniel STAN

[mail_invalide] subprocess + template path

parent e1b2941e
......@@ -10,7 +10,8 @@ Copyright (C) 2009 Michel Blockelet
Licence : GPL v2
"""
import commands, os, sys, time
import os, sys, time
import subprocess
sys.path.append('/usr/scripts/gestion')
from ldap_crans import crans_ldap
from config import upload
......@@ -57,7 +58,8 @@ def generate_ps(proprio, mail):
# Création du fichier tex
format_date = '%A %d %B %Y'
template = file('./mail_invalide.tex').read()
with open('%s/mail_invalide.tex' % os.path.dirname(__file__), 'r') as tempfile:
template = tempfile.read()
template = template.replace('~prenom~', proprio.prenom().encode('utf-8'))
template = template.replace('~nom~', proprio.nom().encode('utf-8'))
template = template.replace('~chambre~', proprio.chbre().encode('utf-8'))
......@@ -65,12 +67,15 @@ def generate_ps(proprio, mail):
template = template.replace('~fin~',
time.strftime(format_date, time.localtime(time.time()+14*86400)))
file('%s/%s.tex' % (dossier, fichier), 'w').write(template)
with open('%s/%s.tex' % (dossier, fichier), 'w') as outtex:
outtex.write(template)
# Compilation du fichier latex
#commands.getstatusoutput('PATH="/bin:/usr/bin" cd %(dossier)s && barcode -n -E -b %(adresse)s%(date)s -o %(barcode)s && latex --interaction=nonstopmode %(base)s.tex && dvips %(base)s.dvi && rm -f %(base)s.dvi %(base)s.aux %(base)s.log %(base)s.tex %(barcode)s'%{'dossier': dossier, 'adresse': adresse, 'date': time.strftime("%Y%m%d-%H%M"), 'base': fichier, 'barcode': barcode})
commands.getstatusoutput('cd %(dossier)s && pdflatex -interaction nonstopmode %(base)s.tex'%{'dossier': dossier, 'adresse': adresse, 'date': time.strftime("%Y%m%d-%H%M"), 'base': fichier, 'barcode': barcode})
subprocess.check_call(['/usr/bin/pdflatex',
'-output-directory='+ dossier,
'-interaction', 'nonstopmode',
fichier + '.tex',
])
return '%s/%s.pdf' % (dossier, fichier)
except Exception, e:
......
../admin/mail_invalide/mail_invalide.py
\ No newline at end of file
#!/bin/bash
/usr/scripts/admin/mail_invalide/mail_invalide.py "$@"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment