imprimante: petite info d'état
This commit is contained in:
parent
09985e97f0
commit
ac3b4e36e1
1 changed files with 19 additions and 1 deletions
|
@ -9,14 +9,32 @@
|
|||
|
||||
"""
|
||||
|
||||
import BeautifulSoup
|
||||
import requests
|
||||
import HTMLParser
|
||||
import sys
|
||||
from hptools import snmp
|
||||
|
||||
STATUS_URL = 'https://imprimante.adm.crans.org/hp/device/DeviceStatus/Index'
|
||||
CA = '/etc/ssl/certs/cacert.org.pem'
|
||||
|
||||
class ErreurCommunication(Exception):
|
||||
"""Si une erreur est survenue lors de la communication avec l'imprimante"""
|
||||
pass
|
||||
|
||||
def etat():
|
||||
return ["L'imprimante est en cours de test. L'interfaçage n'est pas encore terminé, mais l'impression fonctionne dans la plupart des cas."]
|
||||
return \
|
||||
["L'imprimante est test. L'interfaçage n'est pas encore terminé.",
|
||||
"Aucune notification de fin d'impression n'est envoyée pour le moment",
|
||||
_http_status()]
|
||||
|
||||
def _http_status():
|
||||
try:
|
||||
req = requests.get(STATUS_URL, verify=CA)
|
||||
doc = BeautifulSoup.BeautifulSoup(req.text)
|
||||
status_tag = doc.find(attrs={'id': 'MachineStatus'})
|
||||
h = HTMLParser.HTMLParser()
|
||||
return h.unescape(status_tag.text)
|
||||
except:
|
||||
raise ErreurCommunication()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue