"96:69:2C:88:7A:C3",
],
}
+ self.weird_mac_at_cabin = False
self.location_ts_by_mac: Dict[
Location, Dict[str, datetime.datetime]
] = defaultdict(dict)
"ssh scott@meerkat.cabin 'cat /home/scott/cron/persisted_mac_addresses.txt'"
)
self.parse_raw_macs_file(raw, Location.CABIN)
- # os.remove(filename)
def read_persisted_macs_file(
self, filename: str, location: Location
lines = raw.split("\n")
# CC:F4:11:D7:FA:EE, 2240, 10.0.0.22 (side_deck_high_home), Google, 1611681990
+ cabin_count = 0
for line in lines:
line = line.strip()
if len(line) == 0:
continue
logger.debug(f'{location}> {line}')
+ if "cabin_" in line:
+ continue
+ if location == Location.CABIN:
+ cabin_count += 1
try:
(mac, count, ip_name, mfg, ts) = line.split(",")
except Exception as e:
if match is not None:
name = match.group(2)
self.names_by_mac[mac] = name
+ if cabin_count > 0:
+ self.weird_mac_at_cabin = True
def is_anyone_in_location_now(self, location: Location) -> bool:
for person in Person:
loc = self.where_is_person_now(person)
if location == loc:
return True
+ if location == location.CABIN and self.weird_mac_at_cabin:
+ return True
return False
def where_is_person_now(self, name: Person) -> Location:
if name is Person.UNKNOWN:
- return Location.UNKNOWN
+ if self.weird_mac_at_cabin:
+ return Location.CABIN
+ else:
+ return Location.UNKNOWN
votes: Dict[Location, int] = {}
tiebreaks: Dict[Location, datetime.datetime] = {}
credit = 10000
credit = int(
credit * 0.667
) # Note: list most important devices first
- if credit == 0:
+ if credit <= 0:
credit = 1
if len(votes) > 0:
item = dict_utils.item_with_max_value(votes)