Skip to content

Commit

Permalink
Less strict abort on error
Browse files Browse the repository at this point in the history
This should lead to less crashes when using the package. Not sure how false positives are affected (detecting a random device as a BLNET device, however this should not be the main issue)
  • Loading branch information
nielstron committed Jan 11, 2021
1 parent 11c0503 commit 2d0efc1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pyblnet/blnet_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_blnet(ip, timeout=5, id=0):
# Parse DOM object from HTMLCode
dom = htmldom.HtmlDom().createDom(r.text)
# either a 'Zugriff verweigert' message is shown
if 'BL-Net Zugang verweigert' in dom.find('title').text():
if 'BL-Net'.lower() in dom.find('title').text().lower():
return True
# or (more often) the BL-NET Menü
if 'BL-NET' in dom.find('div#head').text():
Expand Down Expand Up @@ -186,10 +186,13 @@ def read_analog_values(self):
# Parse DOM object from HTMLCode
dom = htmldom.HtmlDom().createDom(r.text)
# Check if we didn't fail in access
if 'BL-Net Zugang verweigert' in dom.find('title').text():
return None
#if 'BL-Net Zugang verweigert' in dom.find('title').text():
# return None
# get the element containing the interesting information
dom = dom.find("div.c")[1]
# in case of access denied or other errors, return None
if dom is None:
return dom
# filter out the text
data_raw = dom.text()

Expand Down

0 comments on commit 2d0efc1

Please sign in to comment.