From b4bb0bc33e6ad1f80c3ebe475ff6acd52bb58547 Mon Sep 17 00:00:00 2001 From: gdetrez Date: Fri, 10 Nov 2006 15:24:39 +0100 Subject: [PATCH] etat imprimante, pour l'intranet (en fait, c'est le mme que l'autre avec un encode en moins par ce que a n'allait pas avec l'utf-8 de l'intranet) darcs-hash:20061110142439-f46e9-8cc1e1026c4856d78f83054838d7ed1fdedbde57.gz --- lib/impression/etat_imprimante.py | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 lib/impression/etat_imprimante.py diff --git a/lib/impression/etat_imprimante.py b/lib/impression/etat_imprimante.py new file mode 100755 index 00000000..6a6793c0 --- /dev/null +++ b/lib/impression/etat_imprimante.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# -*- coding: iso-8859-15 -*- + +import sys +sys.path.append("/usr/scripts/gestion") + +import hptools + +dico = { + u"PrÁt": u"Prêtb", + 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"CYAN": u"", + u"MAGENTA": u"", +} + +class ErreurCommunication(Exception): + 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"] + 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) + if msg: liste_msg.append(msg) + except Exception,err: + raise ErreurCommunication, str(err) + return liste_msg