|
5 | 5 | import json |
6 | 6 | import os |
7 | 7 | from time import time |
| 8 | +from typing import List |
8 | 9 |
|
9 | 10 |
|
10 | 11 | try: |
@@ -44,8 +45,8 @@ class CallTypeMonitor: |
44 | 45 | """Define Request/Response monitor""" |
45 | 46 |
|
46 | 47 | active: bool = False |
47 | | - range_start: int = "" |
48 | | - range_stop: int = "" |
| 48 | + range_start: int = -1 |
| 49 | + range_stop: int = -1 |
49 | 50 | function: int = -1 |
50 | 51 | hex: bool = False |
51 | 52 | decode: bool = False |
@@ -176,7 +177,7 @@ def __init__( |
176 | 177 | with open(file, encoding="utf-8") as handle: |
177 | 178 | self.generator_html[entry][0] = handle.read() |
178 | 179 | self.refresh_rate = 0 |
179 | | - self.register_filter = [] |
| 180 | + self.register_filter: List[int] = [] |
180 | 181 | self.call_list = [] |
181 | 182 | self.call_monitor = CallTypeMonitor() |
182 | 183 | self.call_response = CallTypeResponse() |
@@ -326,15 +327,11 @@ async def build_html_log(self, _params, html): |
326 | 327 |
|
327 | 328 | def helper_build_html_calls_submit_monitor(self, params): |
328 | 329 | """Build html calls submit.""" |
329 | | - if params["range_start"]: |
330 | | - self.call_monitor.range_start = int(params["range_start"]) |
331 | | - if params["range_stop"]: |
332 | | - self.call_monitor.range_stop = int(params["range_stop"]) |
333 | | - else: |
334 | | - self.call_monitor.range_stop = self.call_monitor.range_start |
| 330 | + self.call_monitor.range_start = params["range_start"] |
| 331 | + if params["range_stop"] != -1: |
| 332 | + self.call_monitor.range_stop = params["range_stop"] |
335 | 333 | else: |
336 | | - self.call_monitor.range_start = "" |
337 | | - self.call_monitor.range_stop = "" |
| 334 | + self.call_monitor.range_stop = self.call_monitor.range_start |
338 | 335 | if params["function"]: |
339 | 336 | self.call_monitor.function = int(params["function"]) |
340 | 337 | else: |
@@ -412,9 +409,19 @@ async def build_html_calls(self, params, html): |
412 | 409 | ): |
413 | 410 | selected = "selected" if i == self.call_response.error_response else "" |
414 | 411 | function_error += f"<option value={i} {selected}>{txt}</option>" |
| 412 | + range_start_html = ( |
| 413 | + str(self.call_monitor.range_start) |
| 414 | + if self.call_monitor.range_start != -1 |
| 415 | + else "" |
| 416 | + ) |
| 417 | + range_stop_html = ( |
| 418 | + str(self.call_monitor.range_stop) |
| 419 | + if self.call_monitor.range_stop != -1 |
| 420 | + else "" |
| 421 | + ) |
415 | 422 | html = ( |
416 | | - html.replace("FUNCTION_RANGE_START", str(self.call_monitor.range_start)) |
417 | | - .replace("FUNCTION_RANGE_STOP", str(self.call_monitor.range_stop)) |
| 423 | + html.replace("FUNCTION_RANGE_START", range_start_html) |
| 424 | + .replace("FUNCTION_RANGE_STOP", range_stop_html) |
418 | 425 | .replace("<!--FUNCTION_TYPES-->", function_error) |
419 | 426 | .replace( |
420 | 427 | "FUNCTION_SHOW_HEX_CHECKED", "checked" if self.call_monitor.hex else "" |
@@ -493,14 +500,8 @@ async def build_json_server(self, params, json_dict): |
493 | 500 |
|
494 | 501 | def helper_build_filter(self, params): |
495 | 502 | """Build list of registers matching filter.""" |
496 | | - if x := params.get("range_start"): |
497 | | - range_start = int(x) |
498 | | - else: |
499 | | - range_start = -1 |
500 | | - if x := params.get("range_stop"): |
501 | | - range_stop = int(x) |
502 | | - else: |
503 | | - range_stop = range_start |
| 503 | + range_start = params.get("range_start", -1) |
| 504 | + range_stop = params.get("range_stop", range_start) |
504 | 505 | reg_action = int(params["action"]) |
505 | 506 | reg_writeable = "writeable" in params |
506 | 507 | reg_type = int(params["type"]) |
|
0 commit comments