Simplification des messages d'erreur pour les adhrents et ajout d'un test pour voir si le fichier est bien pdf
darcs-hash:20061116222504-f46e9-1a7343559bbf6b98e2d1a22ced1162413720f418.gz
This commit is contained in:
parent
dce073de67
commit
cb801d4734
2 changed files with 25 additions and 6 deletions
|
@ -121,7 +121,14 @@ LPR_OPTIONS = {
|
|||
#
|
||||
#
|
||||
class FichierInvalide(Exception):
|
||||
pass
|
||||
def __str__(self):
|
||||
return self.args[0]
|
||||
def file(self):
|
||||
try:
|
||||
return self.args[1]
|
||||
except:
|
||||
return "n/a"
|
||||
|
||||
class SoldeInsuffisant(Exception):
|
||||
pass
|
||||
class PrintError(Exception):
|
||||
|
@ -158,15 +165,21 @@ class impression:
|
|||
|
||||
def __init__(self, path_to_pdf, adh = None):
|
||||
self._fichier = path_to_pdf
|
||||
# on verifie que le fichier existe
|
||||
if not os.path.isfile(path_to_pdf):
|
||||
raise FichierInvalide, "Nom de fichier invalide (%s)" % path_to_pdf
|
||||
raise FichierInvalide, ("Fichier introuvable", path_to_pdf)
|
||||
if not open(path_to_pdf).read().startswith("%PDF"):
|
||||
raise FichierInvalide, ("Le fichier ne semble pas etre un PDF", path_to_pdf)
|
||||
os.system("/usr/scripts/impression/compatibilise %s" % escapeForShell( path_to_pdf ) )
|
||||
|
||||
|
||||
self._adh = adh
|
||||
# calcule le prix de l'encre tout de suite
|
||||
try:
|
||||
self._base_prix_couleurs, self._nb_pages = cout.base_prix_couleurs(path_to_pdf)
|
||||
self._base_prix_nb, self._nb_pages = cout.base_prix_nb(path_to_pdf)
|
||||
except:
|
||||
raise FichierInvalide, ("PDF bugge, Analyse impossible.", path_to_pdf)
|
||||
self._calcule_prix()
|
||||
|
||||
|
||||
|
|
|
@ -50,7 +50,13 @@ COUT_PASSAGE_TAMBOUR_COULEUR = config.impression.c_tambour_coul
|
|||
#
|
||||
#
|
||||
class FichierInvalide(Exception):
|
||||
pass
|
||||
def __str__(self):
|
||||
return self.args[0]
|
||||
def file(self):
|
||||
try:
|
||||
return self.args[1]
|
||||
except:
|
||||
return "n/a"
|
||||
# ########################################################### #
|
||||
# PRIX COULEURS #
|
||||
# ########################################################### #
|
||||
|
@ -67,7 +73,7 @@ def base_prix_couleurs(path_fichier_pdf):
|
|||
# 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, escapeForShell(path_fichier_pdf)))
|
||||
if status:
|
||||
raise FichierInvalide("ERREUR %s : Fichier invalide. Aucun png cree. (couleurs)" % status)
|
||||
raise FichierInvalide, "ERREUR %s : Fichier invalide. Aucun png cree. (couleurs)" % status
|
||||
|
||||
# Récupère la liste des fichiers
|
||||
list_filepng=os.listdir(nom_rep)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue