[impression] etat_imprimante.py est dans lib/
Ignore-this: 8b65908baa5ef8278e3376ec0362c838 darcs-hash:20090515112758-bd074-dc51ddcc8dc0088b51dc138e3475d8e62272d114.gz
This commit is contained in:
parent
9dae9ed43b
commit
284c189c8e
2 changed files with 51 additions and 86 deletions
|
@ -1,59 +0,0 @@
|
||||||
#!/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"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"tÀche 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,9 +12,31 @@
|
||||||
import sys
|
import sys
|
||||||
sys.path.append("/usr/scripts/gestion")
|
sys.path.append("/usr/scripts/gestion")
|
||||||
|
|
||||||
import hptools
|
from hptools import snmp
|
||||||
|
from config import impression
|
||||||
|
|
||||||
_dico = {
|
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"Prête",
|
u"READY": u"Prête",
|
||||||
u"PrÁt": u"Prêt",
|
u"PrÁt": u"Prêt",
|
||||||
u"Pr menus, appuy \x1e": u"",
|
u"Pr menus, appuy \x1e": u"",
|
||||||
|
@ -38,14 +60,8 @@ _dico = {
|
||||||
u'DS TRAPPE SUP DROITE':u"",
|
u'DS TRAPPE SUP DROITE':u"",
|
||||||
u'COMM TAMB. NOIR':u"",
|
u'COMM TAMB. NOIR':u"",
|
||||||
u'PAGES REST.': u"",
|
u'PAGES REST.': u"",
|
||||||
}
|
}
|
||||||
|
|
||||||
class ErreurCommunication(Exception):
|
|
||||||
"""Si une erreur est survenue lors de la communication avec l'imprimante"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
def etat():
|
|
||||||
""" 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"]
|
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:
|
try:
|
||||||
comm = hptools.snmp(host="laserjet.adm.crans.org",version="1",community="public")
|
comm = hptools.snmp(host="laserjet.adm.crans.org",version="1",community="public")
|
||||||
|
@ -58,3 +74,11 @@ def etat():
|
||||||
except Exception,err:
|
except Exception,err:
|
||||||
raise ErreurCommunication, str(err)
|
raise ErreurCommunication, str(err)
|
||||||
return liste_msg
|
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()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue