diff --git a/lib/impression/cout.py b/lib/impression/cout.py index 56d735e5..697a7609 100755 --- a/lib/impression/cout.py +++ b/lib/impression/cout.py @@ -29,6 +29,7 @@ import sys, time, tempfile, os, commands, string, random, re sys.path.append('/usr/scripts/gestion') import config +from crans.utils import QuoteForPOSIX as escapeForShell def __init__(): pass @@ -60,13 +61,11 @@ def base_prix_couleurs(path_fichier_pdf): # nom_rep seras le dossier dans tmp ou tous les fichier créé par # convert seront entreposé - path_fichier_pdf = re.sub(r"(?<=[^\\]) ", "\\ ", path_fichier_pdf) - nom_rep = tempfile.mkdtemp(prefix='tmpimpr') nom_png = "%s/convert.png" % nom_rep # Nom prefixe et chemin des png créé par convert # Convertit les pdf en png couleur - (status, rep) = commands.getstatusoutput("nice -n 5 gs -sDEVICE=png16m -r30 -dBATCH -dNOPAUSE -dSAFER -dPARANOIDSAFER -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dMaxBitmap=50000000 -sOutputFile=%s%%d -q %s" % (nom_png, path_fichier_pdf)) + (status, rep) = commands.getstatusoutput("nice -n 5 gs -sDEVICE=png16m -r30 -dBATCH -dNOPAUSE -dSAFER -dPARANOIDSAFER -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dMaxBitmap=50000000 -sOutputFile=%s%%d -q %s" % (nom_png, escapeForShell(path_fichier_pdf))) if status: raise FichierInvalide("ERREUR %s : Fichier invalide. Aucun png cree. (couleurs)" % status) @@ -107,14 +106,11 @@ def base_prix_nb(path_fichier_pdf): # nom_rep seras le dossier dans tmp ou tous les fichier créé par # convert seront entreposé - # on tranforme les espaces en "\ " - path_fichier_pdf = re.sub(r"(?<=[^\\]) ", "\\ ", path_fichier_pdf) - nom_rep = tempfile.mkdtemp(prefix='tmpimpr') nom_png = "%s/convert.png" % nom_rep # Nom prefixe et chemin des png créé par convert # Convertit les pdf en png - (status, rep) = commands.getstatusoutput("nice -n 5 gs -sDEVICE=pnggray -r30 -dBATCH -dNOPAUSE -dSAFER -dPARANOIDSAFER -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dMaxBitmap=50000000 -sOutputFile=%s%%d -q %s" % (nom_png, path_fichier_pdf)) + (status, rep) = commands.getstatusoutput("nice -n 5 gs -sDEVICE=pnggray -r30 -dBATCH -dNOPAUSE -dSAFER -dPARANOIDSAFER -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dMaxBitmap=50000000 -sOutputFile=%s%%d -q %s" % (nom_png, escapeForShell( path_fichier_pdf ) )) if status: raise FichierInvalide("ERREUR : Fichier invalide. Aucun png n'a ete cree.\n")