impression: deprecated stuff
This commit is contained in:
parent
bf6da9a335
commit
dd369ca635
4 changed files with 11 additions and 79 deletions
|
@ -39,6 +39,8 @@ import shutil
|
|||
import syslog
|
||||
import stat
|
||||
sys.path.append('/usr/scripts/')
|
||||
from cranslib.deprecated import module as deprecated_module
|
||||
deprecated_module()
|
||||
from cranslib.utils import QuoteForPOSIX as escapeForShell
|
||||
def __init__():
|
||||
pass
|
||||
|
@ -48,7 +50,8 @@ def __init__():
|
|||
# ########################################################### #
|
||||
#
|
||||
#
|
||||
from gestion import config.impression
|
||||
from gestion import config
|
||||
import gestion.config.impression
|
||||
COUT_UNITE_COULEUR = config.impression.c_coul
|
||||
COUT_UNITE_NOIRE = config.impression.c_noir
|
||||
COUT_PASSAGE_TAMBOUR_NOIR = config.impression.c_tambour_noir
|
||||
|
|
|
@ -10,90 +10,13 @@
|
|||
"""
|
||||
|
||||
import sys
|
||||
sys.path.append("/usr/scripts/gestion")
|
||||
|
||||
from hptools import snmp
|
||||
from config import impression
|
||||
|
||||
class ErreurCommunication(Exception):
|
||||
"""Si une erreur est survenue lors de la communication avec l'imprimante"""
|
||||
pass
|
||||
|
||||
def etat():
|
||||
return (globals()["etat_%s" % impression.imprimante])()
|
||||
return ["État inconnu. Les nounous y travaillent."]
|
||||
|
||||
def etat_canon():
|
||||
_dico = {
|
||||
'idle(3)\nrunning(2)' : u'Imprimante fonctionnelle',
|
||||
'printing(4)\nrunning(2)' : u'Impression en cours',
|
||||
'other(1)\ndown(5)' : u"Imprimante hors-service",
|
||||
'other(1)\nrunning(2)' : u'Imprimante en veille',
|
||||
'warmup(5)\nrunning(2)' : u'Préchauffage',
|
||||
'idle(3)\nwarning(3)' : u'Imprimante fonctionnelle',
|
||||
'printing(4)\nwarning(3)' : u'Impression en cours'
|
||||
}
|
||||
try:
|
||||
raw_msg = msg = []
|
||||
comm = snmp(host="imprimante.adm.crans.org", version="1", community="public")
|
||||
|
||||
for oid in [".hrPrinterStatus.1", ".hrDeviceStatus.1"]:
|
||||
#".hrPrinterDetectedErrorState.1"
|
||||
raw_msg.append(comm.get_string(oid))
|
||||
msg = _dico['\n'.join(msg)].split('\n')
|
||||
|
||||
msg += [v.replace('"', '') for v in comm.walk('mib-2.43.18.1.1.8', output='q').values()]
|
||||
|
||||
except Exception,err:
|
||||
msg.append("[%s]" % unicode(err))
|
||||
msg += impression.state_msg
|
||||
|
||||
return msg
|
||||
|
||||
def etat_laserjet():
|
||||
""" Renvoie une liste des differents ecrans actuels du display de l'imprimante """
|
||||
_dico = {
|
||||
u"READY": u"Prête",
|
||||
u"PrÁt": u"Prêt",
|
||||
u"Pr menus, appuy \x1e": u"",
|
||||
u"Powersave activÅ": u"En veille",
|
||||
u"Verification": u"Vérification imprimante",
|
||||
u"imprimante": u"",
|
||||
u"PrÅchauffage": u"Préchauffage",
|
||||
u"Traitement de la": u"Impression en cours",
|
||||
u"tÀche du bac 4": u"",
|
||||
u"COMMANDER CARTOUCHE": u"",
|
||||
u"COMMANDER KIT NETTOY": u"",
|
||||
u"COMMANDER FOURNIT.": u"",
|
||||
u"CYAN": u"",
|
||||
u"MAGENTA": u"",
|
||||
u"JAUNE": u"",
|
||||
u"NOIR": u"",
|
||||
u'Pr aide appuyer \x1f': u"",
|
||||
u'13.12.12 BOURRAGE DS':u"Bourrage papier",
|
||||
u'ACCESSOIRE GAUCHE':u"",
|
||||
u'13.03.00 BOURRAGE':u"Bourrage papier",
|
||||
u'DS TRAPPE SUP DROITE':u"",
|
||||
u'COMM TAMB. NOIR':u"",
|
||||
u'PAGES REST.': u"",
|
||||
}
|
||||
|
||||
liste_oid = ["mib-2.43.16.5.1.2.1.1","mib-2.43.16.5.1.2.1.2","mib-2.43.16.5.1.2.1.3","mib-2.43.16.5.1.2.1.4","mib-2.43.16.5.1.2.1.5"]
|
||||
try:
|
||||
comm = snmp(host="laserjet.adm.crans.org",version="1",community="public")
|
||||
liste_msg = []
|
||||
for oid in liste_oid:
|
||||
msg = comm.get_string(oid).decode("ISO-8859-1")
|
||||
for k in _dico.keys():
|
||||
if k in msg: msg = _dico[k]
|
||||
if msg: liste_msg.append(msg)
|
||||
except Exception,err:
|
||||
raise ErreurCommunication, str(err)
|
||||
return liste_msg
|
||||
|
||||
def enregistre(filename="/usr/script/impression/imprimante.etat"):
|
||||
l = etat()
|
||||
fichier = open(filename,'w')
|
||||
for x in l:
|
||||
fichier.write(x+"\n")
|
||||
fichier.close()
|
||||
|
||||
|
|
|
@ -8,5 +8,8 @@
|
|||
# Toutes les heures on appelle ce script qui tue toutes les occurances
|
||||
# de cnpkmodule avec un time supérieur à 60 minutes
|
||||
|
||||
echo "deprecated"
|
||||
exit 1
|
||||
|
||||
ps ax | grep cnpkmodule | \
|
||||
perl -nle '/\s*(\d*)\s+([^\s]*\s*){2}(\d*)/; if ($3 > 60) {kill 9, $1; print "cnpkmodule was killed"}'
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "deprecated"
|
||||
exit 1
|
||||
|
||||
exec /etc/init.d/intranet restart
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue