MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / load_config

Method load_config

shared.py:1521–1550  ·  view source on GitHub ↗

Load the configuration from the shared configuration JSON file.

(self)

Source from the content-addressed store, hash-verified

1519 self.levelnbr = self.calculate_level(total_points)
1520 self.gamification_data["level"] = self.levelnbr
1521
1522 def normalize_mac(self, mac_address: str) -> str:
1523 """Return a normalized MAC address suitable for persistence."""
1524 if not mac_address:
1525 return ""
1526
1527 mac = mac_address.strip().upper()
1528 if mac in {"UNKNOWN", "N/A", "NONE"}:
1529 return ""
1530
1531 mac = mac.replace('-', ':')
1532 if '.' in mac:
1533 mac = mac.replace('.', '')
1534 mac = mac.replace(' ', '')
1535
1536 if ':' not in mac and len(mac) == 12:
1537 mac = ':'.join(mac[i:i + 2] for i in range(0, 12, 2))
1538
1539 if mac.count(':') == 5:
1540 if mac in {"00:00:00:00:00:00", "FF:FF:FF:FF:FF:FF"}:
1541 return ""
1542 return mac
1543
1544 return ""
1545
1546 def process_discovered_macs(self, mac_addresses):
1547 """Track newly discovered MAC addresses and award points once per device."""
1548 normalized = {self.normalize_mac(mac) for mac in mac_addresses}
1549 normalized.discard("")
1550
1551 if not normalized:
1552 return 0, 0
1553

Callers 4

__init__Method · 0.95
headlessRagnar.pyFile · 0.80
save_configurationMethod · 0.80
Ragnar.pyFile · 0.80

Calls 9

save_configMethod · 0.95
infoMethod · 0.80
warningMethod · 0.80
errorMethod · 0.80
updateMethod · 0.45
itemsMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected