From 69c220cda3d8c0a95327630f5752dad36cb82261 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Tue, 17 Jul 2018 12:34:04 +0200 Subject: Squashed commit --- jobs/hplq1300n.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 jobs/hplq1300n.py (limited to 'jobs/hplq1300n.py') diff --git a/jobs/hplq1300n.py b/jobs/hplq1300n.py new file mode 100755 index 0000000..b77a323 --- /dev/null +++ b/jobs/hplq1300n.py @@ -0,0 +1,26 @@ +import codecs +import re +import urllib.request +from collections import namedtuple + +Data = namedtuple('Data', ['hostname', 'value']) + +URL = "http://{}/hp/device/info_suppliesStatus.html" + + +def job(host: str) -> Data: + url = URL.format(host) + name = host.replace(".", "_") + request = urllib.request.Request(url) + with urllib.request.urlopen(request) as f: + f2 = codecs.getreader('utf-8')(f) + for line in f2.readlines(): + m = re.match(".*>([0-9]*)%