From d6a225a6c9fb80a1a8b7a066e0044b384aa91faf Mon Sep 17 00:00:00 2001 From: mattfrazer Date: Fri, 8 Jul 2022 12:03:29 -0400 Subject: [PATCH 1/3] SB6190 Target Based on SB6183 --- scraper/targets/arris_modem_SB6190.py | 106 ++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 scraper/targets/arris_modem_SB6190.py diff --git a/scraper/targets/arris_modem_SB6190.py b/scraper/targets/arris_modem_SB6190.py new file mode 100644 index 0000000..c40bb74 --- /dev/null +++ b/scraper/targets/arris_modem_SB6190.py @@ -0,0 +1,106 @@ +""" +Arris modem module. +""" +from lxml import html + +from bs4 import BeautifulSoup +from .arris_modem import ArrisModem, UpstreamItem, DownstreamItem + +class ArrisModemSB6190(ArrisModem): + """ + ArrisModem subclass that represents an Arris modem model SB6190 + running software + """ + + def get_downstream_items(self,html_string): + """ + Function to convert an HTML string to a list of DownstreamItems. + + Args: + html_string (string): HTML + + Returns: + [DownstreamItem]: List of DownstreamItems + """ + + # Use BeautifulSoup with html5lib. lxml doesn't play well with the SB6190. + soup = BeautifulSoup(html_string, 'html5lib') + + # key order must match the table column layout + keys = [ + 'downstream_id', + 'lock_status', + 'modulation', + 'dcid', + 'freq', + 'power', + 'snr', + 'correcteds', + 'uncorrectables', + 'octets', + ] + items = [] + + for table_row in soup.find_all("table")[2].find_all("tr")[2:]: + if table_row.th: + continue + channel = table_row.find_all('td')[0].text.strip() + lock_status = table_row.find_all('td')[1].text.strip() + modulation = table_row.find_all('td')[2].text.strip() + channel_id = table_row.find_all('td')[3].text.strip() + frequency = table_row.find_all('td')[4].text.replace(" Hz", "").strip() + power = table_row.find_all('td')[5].text.replace(" dBmV", "").strip() + snr = table_row.find_all('td')[6].text.replace(" dB", "").strip() + corrected = table_row.find_all('td')[7].text.strip() + uncorrectables = table_row.find_all('td')[8].text.strip() + octets = "0" + + values = ( channel, lock_status, modulation, channel_id, frequency, power, snr, corrected, uncorrectables, octets) + zipped = dict(zip(keys, values)) + items.append(DownstreamItem(zipped.items())) + + return items + + def get_upstream_items(self,html_string): + """ + Function to convert an HTML string to a list of UpstreamItems. + + Args: + html_string (string): HTML + + Returns: + [UpstreamItem]: List of UpstreamItems + """ + # Use BeautifulSoup with html5lib. lxml doesn't play well with the SB6190. + soup = BeautifulSoup(html_string, 'html5lib') + + # key order must match the table column layout + keys = [ + 'upstream_id', + 'lock_status', + 'channel_type', + 'ucid', + 'symbol_rate', + 'freq', + 'power', + ] + + items = [] + + # upstream table + for table_row in soup.find_all("table")[3].find_all("tr")[2:]: + if table_row.th: + continue + upstream_id = table_row.find_all('td')[0].text.strip() + lock_status = table_row.find_all('td')[1].text.strip() + channel_type = table_row.find_all('td')[2].text.strip() + ucid = table_row.find_all('td')[3].text.strip() + symbol_rate = table_row.find_all('td')[4].text.replace(" kSym/sec", "").strip() + freq = table_row.find_all('td')[5].text.replace(" Hz", "").strip() + power = table_row.find_all('td')[6].text.replace(" dBmV", "").strip() + + values = (upstream_id, lock_status, channel_type, ucid, symbol_rate, freq, power ) + zipped = dict(zip(keys, values)) + items.append(UpstreamItem(zipped.items())) + + return items From f2992b26eda5a9f94e5c605cfad068847b459bb6 Mon Sep 17 00:00:00 2001 From: mattfrazer Date: Fri, 8 Jul 2022 12:04:25 -0400 Subject: [PATCH 2/3] Add SB6190 to scrape --- scrape.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scrape.py b/scrape.py index cd0db82..091b265 100644 --- a/scrape.py +++ b/scrape.py @@ -51,6 +51,9 @@ def get_target(model): if model == "CM802A": from scraper.targets.arris_modem_CM820A import ArrisModemCM820A return ArrisModemCM820A() + if model == "SB6190": + from scraper.targets.arris_modem_SB6190 import ArrisModemSB6190 + return ArrisModemSB6190() def get_outputter(output): if output == 'influxdb': From 604fe8f4665028dc8b7b7cb35d4b44da5e11d432 Mon Sep 17 00:00:00 2001 From: mattfrazer Date: Fri, 8 Jul 2022 12:05:04 -0400 Subject: [PATCH 3/3] Add SB6190 to debugger --- tools/debugger.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/debugger.py b/tools/debugger.py index 64cccc9..e34ce5a 100644 --- a/tools/debugger.py +++ b/tools/debugger.py @@ -45,6 +45,9 @@ def get_target(model): if model == "CM802A": from scraper.targets.arris_modem_CM820A import ArrisModemCM820A return ArrisModemCM820A() + if model == "SB6190": + from scraper.targets.arris_modem_SB6190 import ArrisModemSB6190 + return ArrisModemSB6190() def get_downloader(): if IS_REMOTE: