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

Method initialize_csv

shared.py:1485–1518  ·  view source on GitHub ↗

Initialize the network knowledge base CSV file with headers.

(self)

Source from the content-addressed store, hash-verified

1483 if ':' not in mac and len(mac) == 12:
1484 mac = ':'.join(mac[i:i + 2] for i in range(0, 12, 2))
1485
1486 if mac.count(':') == 5:
1487 if mac in {"00:00:00:00:00:00", "FF:FF:FF:FF:FF:FF"}:
1488 return ""
1489 return mac
1490
1491 return ""
1492
1493 def process_discovered_macs(self, mac_addresses):
1494 """Track newly discovered MAC addresses and award points once per device."""
1495 normalized = {self.normalize_mac(mac) for mac in mac_addresses}
1496 normalized.discard("")
1497
1498 if not normalized:
1499 return 0, 0
1500
1501 with self._stats_lock:
1502 mac_points = self.gamification_data.setdefault("mac_points", {})
1503 new_mac_count = 0
1504 points_awarded = 0
1505
1506 for mac in normalized:
1507 if mac in mac_points:
1508 continue
1509 mac_points[mac] = {
1510 "points": self.points_per_mac,
1511 "first_seen": datetime.utcnow().isoformat() + "Z"
1512 }
1513 new_mac_count += 1
1514 points_awarded += self.points_per_mac
1515
1516 if points_awarded:
1517 previous_points = self.gamification_data.get("total_points", 0)
1518 self.gamification_data["total_points"] = int(previous_points) + points_awarded
1519 prev_level = self.levelnbr
1520 self._update_gamification_state()
1521 self.save_gamification_data()

Callers 1

setup_environmentMethod · 0.95

Calls 2

infoMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected