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
|
||||
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)
|
||||
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()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue