impression: factorisation des exceptions
This commit is contained in:
parent
aa0c474e41
commit
bf6da9a335
3 changed files with 40 additions and 40 deletions
|
@ -37,6 +37,7 @@ from commands import getstatusoutput
|
|||
sys.path.append('/usr/scripts/')
|
||||
from cranslib.utils import logs
|
||||
from subprocess import Popen, PIPE
|
||||
from base import FichierInvalide, SoldeInsuffisant, PrintError, SettingsError
|
||||
|
||||
# ######################################################## #
|
||||
# CONSTANTES #
|
||||
|
@ -88,45 +89,6 @@ DICT_PAPIER = { 'A4' : "Papier A4 ordinaire",
|
|||
#'A4tr' : "Transparent A4",
|
||||
}
|
||||
|
||||
# ######################################################## #
|
||||
# ERREURS #
|
||||
# ######################################################## #
|
||||
#
|
||||
|
||||
class FichierInvalide(Exception):
|
||||
"""
|
||||
Exception renvoyée lorsqu'un fichier ne passe pas.
|
||||
utilisée avec deux arguments : une chaîne décrivant l'erreur et une chaîne avec le nom du fichier
|
||||
"""
|
||||
def __str__(self):
|
||||
"""
|
||||
Description de l'erreur.
|
||||
"""
|
||||
return self.args[0]
|
||||
def file(self):
|
||||
"""
|
||||
Nom du fichier qui pose problème
|
||||
"""
|
||||
try:
|
||||
return self.args[1]
|
||||
except:
|
||||
return "n/a"
|
||||
|
||||
class SoldeInsuffisant(Exception):
|
||||
"""
|
||||
Solde insuffisant pour l'impression demandée
|
||||
"""
|
||||
pass
|
||||
class PrintError(Exception):
|
||||
"""
|
||||
Erreur lors de l'impression
|
||||
"""
|
||||
pass
|
||||
class SettingsError(Exception):
|
||||
"""
|
||||
Erreur de paramètres.
|
||||
"""
|
||||
pass
|
||||
def _uniq_jid():
|
||||
""" Alloue un jid unique """
|
||||
fname = '/var/impression/jid'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue