impression_hp: état d'un bac
Et utilise le bac 4 en prio, par rapport au 3, lorsqu'il n'est pas low.
This commit is contained in:
parent
7fbd3ad275
commit
0e1178bd1a
1 changed files with 33 additions and 7 deletions
|
@ -10,14 +10,12 @@ License: GPLv3
|
||||||
"""
|
"""
|
||||||
# impression_hp.py
|
# impression_hp.py
|
||||||
#
|
#
|
||||||
# Classe impression pour HP MFP 880
|
|
||||||
#
|
|
||||||
# Copyright (c) 2006, 2007, 2008, 2009 by Cr@ns (http://www.crans.org)
|
|
||||||
# #############################################################
|
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
|
import BeautifulSoup
|
||||||
|
import requests
|
||||||
|
|
||||||
if '/usr/scripts' not in sys.path:
|
if '/usr/scripts' not in sys.path:
|
||||||
sys.path.append('/usr/scripts')
|
sys.path.append('/usr/scripts')
|
||||||
|
@ -28,6 +26,12 @@ from gestion.config import impression as config_impression
|
||||||
from subprocess import Popen, PIPE, check_output
|
from subprocess import Popen, PIPE, check_output
|
||||||
import livret
|
import livret
|
||||||
|
|
||||||
|
## Pour les codes qui se connectent direct à l'imprimante en http
|
||||||
|
BASE_URL = 'https://imprimante.adm.crans.org'
|
||||||
|
URL_JOBLIST = BASE_URL + '/hp/device/JobLogReport/Index'
|
||||||
|
URL_STATE = BASE_URL + '/'
|
||||||
|
CA = '/etc/ssl/certs/cacert.org.pem'
|
||||||
|
|
||||||
##
|
##
|
||||||
logger = logging.getLogger('impression_hp')
|
logger = logging.getLogger('impression_hp')
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
@ -165,7 +169,7 @@ class Perforation(SelectOption):
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
class impression(object):
|
class impression(object):
|
||||||
"""impression
|
"""impression d'un fichier avec l'imprimante HP MFP M880
|
||||||
|
|
||||||
Un objet impression correspond à un fichier pdf et un adhérent.
|
Un objet impression correspond à un fichier pdf et un adhérent.
|
||||||
"""
|
"""
|
||||||
|
@ -366,6 +370,24 @@ class impression(object):
|
||||||
# imprime le document
|
# imprime le document
|
||||||
self._exec_imprime()
|
self._exec_imprime()
|
||||||
|
|
||||||
|
_doc = None
|
||||||
|
def low_tray(self, num):
|
||||||
|
"""Indique si un bac est vide ou presque vide"""
|
||||||
|
if self._doc is None:
|
||||||
|
req = requests.get(URL_STATE, verify=CA)
|
||||||
|
self._doc = BeautifulSoup.BeautifulSoup(req.text)
|
||||||
|
try:
|
||||||
|
tray = self._doc.findAll(attrs={'id': 'TrayBinStatus_%d' % num})[0]
|
||||||
|
except IndexError:
|
||||||
|
return False
|
||||||
|
state = tray.attrMap['class']
|
||||||
|
if 'morethan40' in state or 'between20and40':
|
||||||
|
return False
|
||||||
|
if 'empty' in state:
|
||||||
|
return True
|
||||||
|
logger.info('Unknown Tray State: %s' % state)
|
||||||
|
return False
|
||||||
|
|
||||||
def _calcule_prix(self):
|
def _calcule_prix(self):
|
||||||
|
|
||||||
faces = self._pages
|
faces = self._pages
|
||||||
|
@ -455,6 +477,10 @@ class impression(object):
|
||||||
options.append('InputSlot=Tray1')
|
options.append('InputSlot=Tray1')
|
||||||
elif self._settings['livret'].value:
|
elif self._settings['livret'].value:
|
||||||
options.append('InputSlot=Tray2')
|
options.append('InputSlot=Tray2')
|
||||||
|
else: # A4, dans Tray3 et Tray4
|
||||||
|
## On utilise en priorité le Tray 4 (plus gros)
|
||||||
|
if not self.low_tray(4) or self.low_tray(3):
|
||||||
|
options.append('InputSlot=Tray4')
|
||||||
else:
|
else:
|
||||||
options.append('InputSlot=Tray3')
|
options.append('InputSlot=Tray3')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue