added exclusion, fixed time display

This commit is contained in:
2026-06-01 14:24:48 -04:00
parent 74d8a8565e
commit 6fb1650cb9
11 changed files with 331 additions and 46 deletions
+126 -8
View File
@@ -5,6 +5,7 @@ import smbclient
from db_py import (
clear_tests,
get_config,
mark_completed,
update_all_p2p_coe_pairs_sql,
update_all_p3p_pairs_sql,
@@ -23,6 +24,125 @@ _SMB_SESSIONS = set()
_WIN_DRIVE_PATH_RE = re.compile(r"^[A-Za-z]:[\\/]")
_SCAN_STATE_LOCK = threading.Lock()
_ACTIVE_SCAN_COUNT = 0
_DEFAULT_SCAN_EXCLUSIONS = ""
def _parse_scan_exclusions(value):
raw = value if value not in (None, "") else _DEFAULT_SCAN_EXCLUSIONS
if raw == "" or raw is None:
return None
parts = re.split(r"[,\n;]", str(raw))
return {token.strip().upper() for token in parts if token.strip()}
def _build_match_tokens(parsed):
tokens = set()
def _add(value):
if value in (None, ""):
return
tokens.add(str(value).upper())
_add(parsed.get("interference"))
_add(parsed.get("device"))
_add(parsed.get("rotation"))
_add(parsed.get("test_point"))
_add(parsed.get("rssi"))
_add(parsed.get("station"))
_add(parsed.get("band"))
_add(parsed.get("channel"))
_add(parsed.get("bandwidth"))
_add(parsed.get("direction"))
_add(parsed.get("throttled"))
_add(parsed.get("test_id"))
for bw in parsed.get("extra_bandwidths") or []:
_add(bw)
# Add numeric alias for devices, e.g. CGW453 -> 453.
device = (parsed.get("device") or "").upper()
device_digits = re.sub(r"\D", "", device)
if device_digits:
tokens.add(device_digits)
# SP can appear as flag or specific token variant (e.g., SP40).
if parsed.get("sp"):
tokens.add("SP")
tokens.add(str(parsed.get("sp")).upper())
return tokens
def _normalize_bandwidth_value(value):
if value in (None, ""):
return set()
raw = str(value).strip().upper()
if not raw:
return set()
normalized = {raw}
digits = re.sub(r"\D", "", raw)
if digits:
normalized.add(digits)
normalized.add(f"BW{digits}")
return normalized
def _extract_coe_bandwidth_tokens(ini_path):
keys = {"Bandwidth_fh2", "Bandwidth_fh5", "Bandwidth_fh6"}
line_re = re.compile(r"^\s*([A-Za-z0-9_]+)\s*=\s*([^\r\n#;]+)")
tokens = set()
try:
for line in _read_text_lines(ini_path):
match = line_re.match(line)
if not match:
continue
key = match.group(1).strip()
if key not in keys:
continue
raw_value = match.group(2).strip()
for part in re.split(r"[,/\s]+", raw_value):
part = part.strip()
if not part:
continue
tokens.update(_normalize_bandwidth_value(part))
except OSError as exc:
print(f"[scanner] Cannot read ini file {ini_path}: {exc}")
return tokens
def _rule_matches_target(rule, parsed_tokens):
# Rule parts are AND-ed: CGW453_P3P_ROT2 => device AND interference AND rotation.
# Support _, -, or spaces as condition separators.
parts = [p for p in re.split(r"[_\-\s]+", rule) if p]
if not parts:
return False
def _part_matches(part):
if part in parsed_tokens:
return True
# Support tag variants (e.g., BW80 should match BW80M/BW80+80 in source names).
# Keep this conservative for very short parts to avoid overmatching.
if len(part) >= 3:
for token in parsed_tokens:
if token.startswith(part) or part in token:
return True
return False
return all(_part_matches(part) for part in parts)
def _should_exclude_target(parsed, exclusions):
parsed_tokens = _build_match_tokens(parsed)
# Any matching rule excludes the testcase.
return any(_rule_matches_target(rule, parsed_tokens) for rule in exclusions)
def _scan_started():
@@ -210,6 +330,7 @@ def full_scan(target_dir, results_dir, results_dir_ref):
def scan_targets(target_dir):
target_dir = _normalize_input_path(target_dir)
exclusions = _parse_scan_exclusions(get_config("scan_exclusions"))
try:
parent_entries = [
@@ -245,14 +366,11 @@ def scan_targets(target_dir):
#print(f"[scanner] skip (no test_id): {parent_name}/{filename}")
continue
# Remove all SP testcases and BW320 testcases
if parsed["sp"] or parsed["bandwidth"] == "BW320":
#print(f"[scanner] skip (SP test or BW320): {parent_name}/{filename}")
continue
#Remove P3P and COE testcases for CGW452
if parsed["interference"] in ["P3P", "COE"] and parsed["device"] == "CGW452":
#print(f"[scanner] skip ({parsed['interference']} CGW452): {parent_name}/{filename}")
if (parsed.get("interference") or "").upper() == "COE":
ini_path = _join_path(parent_path, filename)
parsed["extra_bandwidths"] = sorted(_extract_coe_bandwidth_tokens(ini_path))
if exclusions and _should_exclude_target(parsed, exclusions):
continue
#print( f"[scanner] found: {parent_name}/{filename} -> test_id={parsed['test_id']}")