Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Blanc
scripts
Commits
ac3b4e36
Commit
ac3b4e36
authored
Sep 19, 2014
by
Daniel STAN
Browse files
imprimante: petite info d'état
parent
09985e97
Changes
1
Hide whitespace changes
Inline
Side-by-side
impression/etat_imprimante.py
View file @
ac3b4e36
...
...
@@ -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
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment