impression: factorisation des exceptions
This commit is contained in:
parent
aa0c474e41
commit
bf6da9a335
3 changed files with 40 additions and 40 deletions
|
@ -36,7 +36,6 @@ c_face_couleur = 6.84 + amm
|
||||||
#: Coût d'impression d'une face en noir & blanc
|
#: Coût d'impression d'une face en noir & blanc
|
||||||
c_face_nb = 0.65 + amm
|
c_face_nb = 0.65 + amm
|
||||||
|
|
||||||
|
|
||||||
#: Prix d'une agrafe : 200 euros les 15 000
|
#: Prix d'une agrafe : 200 euros les 15 000
|
||||||
c_agrafe = 1.3333
|
c_agrafe = 1.3333
|
||||||
|
|
||||||
|
|
39
impression/base.py
Normal file
39
impression/base.py
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
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
|
||||||
|
# ######################################################## #
|
||||||
|
# ERREURS #
|
||||||
|
# ######################################################## #
|
||||||
|
#
|
|
@ -37,6 +37,7 @@ from commands import getstatusoutput
|
||||||
sys.path.append('/usr/scripts/')
|
sys.path.append('/usr/scripts/')
|
||||||
from cranslib.utils import logs
|
from cranslib.utils import logs
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
|
from base import FichierInvalide, SoldeInsuffisant, PrintError, SettingsError
|
||||||
|
|
||||||
# ######################################################## #
|
# ######################################################## #
|
||||||
# CONSTANTES #
|
# CONSTANTES #
|
||||||
|
@ -88,45 +89,6 @@ DICT_PAPIER = { 'A4' : "Papier A4 ordinaire",
|
||||||
#'A4tr' : "Transparent A4",
|
#'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():
|
def _uniq_jid():
|
||||||
""" Alloue un jid unique """
|
""" Alloue un jid unique """
|
||||||
fname = '/var/impression/jid'
|
fname = '/var/impression/jid'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue