[impression_canon] fix + proprete

darcs-hash:20091102143816-bd074-e37ecdb9ef922b7adefa034db3ab1e9c356f45cb.gz
This commit is contained in:
Antoine Durand-Gasselin 2009-11-02 15:38:16 +01:00
parent d1c0935c1b
commit b639d90a11

View file

@ -28,13 +28,12 @@
Classe pour gérer l'envoie de pdf à l'imprimante. Classe pour gérer l'envoie de pdf à l'imprimante.
Calcule le coût des options d'impression. Calcule le coût des options d'impression.
""" """
__version__ = '1' __version__ = '9.11'
import sys, syslog, os.path, time import sys, os.path
sys.path.append('/usr/scripts/gestion') sys.path.append('/usr/scripts/gestion')
from config import impression as config_impression from config import impression as config_impression
from commands import getstatusoutput from commands import getstatusoutput
from crans.utils import QuoteForPOSIX as escapeForShell
import crans.utils.logs import crans.utils.logs
# ######################################################## # # ######################################################## #
@ -375,7 +374,6 @@ class impression:
def _get_adh(self, adh): def _get_adh(self, adh):
if type(adh) == str: if type(adh) == str:
import sys
sys.path.append("/usr/scripts/gestion/") sys.path.append("/usr/scripts/gestion/")
#from ldap_crans_test import crans_ldap #from ldap_crans_test import crans_ldap
from ldap_crans import CransLdap from ldap_crans import CransLdap
@ -457,15 +455,21 @@ class impression:
if not self._settings['livret'] and self._settings['agrafage'] in ['None', None]: if not self._settings['livret'] and self._settings['agrafage'] in ['None', None]:
left = self._settings['copies'] left = self._settings['copies']
while left >= 100: while left >= 100:
"lpr %s -# %d %s" % (options, 99, self._fichier) cmd = "lpr %s -# %d %s" % (options, 99, self._fichier)
left -= 99 left -= 99
(status, rep) = getstatusoutput(cmd)
self.log.info("printing: %s" % cmd)
if status != 0:
self.log.error("erreur impression")
self.log.error("lpr status:%d | rep: %s" % (status, rep))
raise PrintError, "%s \n status:%d rep: %s" % (cmd, status, rep)
cmd = "lpr %s -# %d %s" % (options, left, self._fichier) cmd = "lpr %s -# %d %s" % (options, left, self._fichier)
(status, rep) = getstatusoutput(cmd) (status, rep) = getstatusoutput(cmd)
self.log.info("printing: %s" % cmd) self.log.info("printing: %s" % cmd)
if status != 0: if status != 0:
self.log.error("erreur impression") self.log.error("erreur impression")
self.log.error("lpr status:%d | rep: %s" % (status, rep)) self.log.error("lpr status:%d | rep: %s" % (status, rep))
raise PrintError, "%s \n status:%d rep: %s" % (cmp, status, rep) raise PrintError, "%s \n status:%d rep: %s" % (cmd, status, rep)
else: else:
cmd = "lpr %s %s" % (options, self._fichier) cmd = "lpr %s %s" % (options, self._fichier)
@ -475,4 +479,4 @@ class impression:
if status != 0: if status != 0:
self.log.error("erreur impression") self.log.error("erreur impression")
self.log.error("lpr status:%d | rep: %s" % (status, rep)) self.log.error("lpr status:%d | rep: %s" % (status, rep))
raise PrintError, "%s \n status:%d rep: %s" % (cmp, status, rep) raise PrintError, "%s \n status:%d rep: %s" % (cmd, status, rep)