[mail_invalide] subprocess + template path
This commit is contained in:
parent
e1b2941e6b
commit
d218131733
2 changed files with 13 additions and 7 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue