Commit 284c189c authored by Antoine Durand-Gasselin's avatar Antoine Durand-Gasselin
Browse files

[impression] etat_imprimante.py est dans lib/

Ignore-this: 8b65908baa5ef8278e3376ec0362c838

darcs-hash:20090515112758-bd074-dc51ddcc8dc0088b51dc138e3475d8e62272d114.gz
parent 9dae9ed4
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
import sys
sys.path.append("/usr/scripts/gestion")
import hptools
from config import impression
def etat_laserjet():
""" Renvoie une liste des differents ecrans actuels du display de l'imprimante """
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"]
dico = {
u"Prt": u"Prt",
u"Pr menus, appuy \x1e": u"",
u"Powersave activ": u"En veille",
u"Verification": u"Vrification imprimante",
u"imprimante": u"",
u"Prchauffage": u"Prchauffage",
u"Traitement de la": u"Impression en cours",
u"tche du bac 4": u"",
u"tche du bac 3": u"",
u"COMMANDER CARTOUCHE": u"",
u"CYAN": u"",
u"MAGENTA": u"",
}
try:
comm = hptools.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")
msg = dico.get(msg, msg).encode("ISO-8859-1")
if msg: liste_msg.append(msg)
except Exception,err:
liste_msg.append("[%s]" % unicode(err))
return liste_msg
def etat_canon():
try:
liste_msg = []
comm = hptools.snmp(host="imprimante.adm.crans.org", version="1", community="public")
for i in [".hrPrinterStatus.1"; ".hrPrinterDetectedErrorState.1"]:
msg = comm.get_string(oid)
msg = dico.get(msg, msg)
if msg: liste_msg.append(msg)
except Exception,err:
liste_msg.append("[%s]" % unicode(err))
return liste_msg
def etat():
exec ("etat_%()" % impression.imprimante)
def enregistre(filename="/usr/script/impression/imprimante.etat"):
l = etat()
fichier = open(filename,'w')
for x in l:
fichier.write(x+"\n")
fichier.close()
......@@ -12,40 +12,56 @@
import sys
sys.path.append("/usr/scripts/gestion")
import hptools
_dico = {
u"READY": u"Prte",
u"Prt": u"Prt",
u"Pr menus, appuy \x1e": u"",
u"Powersave activ": u"En veille",
u"Verification": u"Vrification imprimante",
u"imprimante": u"",
u"Prchauffage": u"Prchauffage",
u"Traitement de la": u"Impression en cours",
u"tche 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"",
}
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():
exec ("etat_%()" % impression.imprimante)
def etat_canon():
try:
liste_msg = []
comm = hptools.snmp(host="imprimante.adm.crans.org", version="1", community="public")
for i in [".hrPrinterStatus.1"; ".hrPrinterDetectedErrorState.1"]:
msg = comm.get_string(oid)
msg = dico.get(msg, msg)
if msg: liste_msg.append(msg)
except Exception,err:
liste_msg.append("[%s]" % unicode(err))
return liste_msg
def etat_laserjet():
""" Renvoie une liste des differents ecrans actuels du display de l'imprimante """
_dico = {
u"READY": u"Prte",
u"Prt": u"Prt",
u"Pr menus, appuy \x1e": u"",
u"Powersave activ": u"En veille",
u"Verification": u"Vrification imprimante",
u"imprimante": u"",
u"Prchauffage": u"Prchauffage",
u"Traitement de la": u"Impression en cours",
u"tche 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 = hptools.snmp(host="laserjet.adm.crans.org",version="1",community="public")
......@@ -58,3 +74,11 @@ def etat():
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()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment