diff --git a/impression/etat_imprimante.py b/impression/etat_imprimante.py index 302114f1..5109f999 100644 --- a/impression/etat_imprimante.py +++ b/impression/etat_imprimante.py @@ -25,7 +25,7 @@ def etat(): def etat_canon(): _dico = { - 'idle(3)\nrunning(2)' : u'Pas configuré comme une imprimante', + 'idle(3)\nrunning(2)' : u'En marche', 'printing(4)\nrunning(2)' : u'Impression en cours', 'other(1)\ndown(5)' : u"Erreur [grave] de l'imprimante", 'other(1)\nrunning(2)' : u'Imprimante en veille', diff --git a/impression/impression_canon.py b/impression/impression_canon.py index 5f8bcad5..b44ec62c 100755 --- a/impression/impression_canon.py +++ b/impression/impression_canon.py @@ -18,11 +18,11 @@ # ................................ # # ############################################################# -# __init__.py +# impression_canon.py # -# Classe impression +# Classe impression pour l'imprimante canon iR C3580i # -# Copyright (c) 2006 by www.crans.org +# Copyright (c) 2006, 2007, 2008, 2009 by Cr@ns (http://www.crans.org) # ############################################################# """ Classe pour gérer l'envoie de pdf à l'imprimante. @@ -34,7 +34,6 @@ import sys, syslog, os.path, time sys.path.append('/usr/scripts/gestion') from config import impression as config_impression from commands import getstatusoutput -from hptools import snmp from crans.utils import QuoteForPOSIX as escapeForShell import crans.utils.logs @@ -42,8 +41,6 @@ import crans.utils.logs # CONSTANTES # # ######################################################## # -LOG = crans.utils.logs.getFileLogger('impression') -COMM = snmp(host="imprimante.adm.crans.org",version="1",community="public") FICHIER_LOG="/var/log/log_couts/impressions" SNMP_CAPA_B = "mib-2.43.11.1.1.8.1.1" @@ -120,6 +117,7 @@ class SettingsError(Exception): Erreur de paramètres. """ pass + # ######################################################## # # CLASSE IMPRESSION # # ######################################################## # @@ -152,7 +150,6 @@ class impression: _base_prix_nb = 0.0 _base_prix_couleurs = 0.0 - def __init__(self, path_to_pdf, adh = None): """impression(path_to_pdf [, adh]) @@ -162,6 +159,10 @@ class impression: l'adhérent. Lève l'exception FichierInvalide si le fichier n'existe pas ou si ce n'est pas un pdf. """ + + # On ouvre les logs + self.log = crans.utils.logs.getFileLogger('impression') + self._fichier = path_to_pdf self._adh = adh @@ -186,10 +187,10 @@ class impression: newfile = self._fichier[:-4] + '-book.pdf' pdfbook = "pdfbook %%s --outfile %s" % newfile (status, rep) = getstatusoutput(pdfbook % self._fichier) - LOG.info("%s | rep: %s" % ((pdfbook % self._fichier), rep)) + self.log.info("%s | rep: %s" % ((pdfbook % self._fichier), rep)) self._fichier = newfile if status != 0: - LOG.error("pdfbook status:%d | rep: %s" % (status, rep)) + self.log.error("pdfbook status:%d | rep: %s" % (status, rep)) raise FichierInvalide, ("pdfbook: Impossible de convertir le fichier", self._fichier) @@ -386,9 +387,9 @@ class impression: self._pdfbook() if (self._adh != None): - LOG.info('Impression [%s] : %s' % (self._adh, self._fichier)) + self.log.info('Impression [%s] : %s' % (self._adh, self._fichier)) else: - LOG.info("Impression : %s" % self._fichier) + self.log.info("Impression : %s" % self._fichier) # Envoi du fichier à CUPS options = '' @@ -449,10 +450,10 @@ class impression: cmd = "lpr %s -# %d %s" % (options, self._settings['copies'], self._fichier) (status, rep) = getstatusoutput(cmd) - LOG.info("printing: %s" % cmd) + self.log.info("printing: %s" % cmd) if status != 0: - LOG.error("erreur impression") - LOG.error("lpr status:%d | rep: %s" % (status, rep)) + self.log.error("erreur impression") + self.log.error("lpr status:%d | rep: %s" % (status, rep)) raise PrintError, "%s \n status:%d rep: %s" % (cmp, status, rep)