Ugh, a bunch of things. @overrides. --lmodule. Chromecasts. etc...
[python_utils.git] / presence.py
index 947ff08706851c9d5bfa6b743bd53633afcfe9d6..b310183b4da6c1fdf002bee0c559abd9a9fd0ca1 100755 (executable)
@@ -7,6 +7,7 @@ import logging
 import re
 from typing import Dict, List
 
+# Note: this module is fairly early loaded.  Be aware of dependencies.
 import argparse_utils
 import bootstrap
 import config
@@ -83,7 +84,10 @@ class PresenceDetection(object):
 
     def update(self) -> None:
         from exec_utils import cmd
-        persisted_macs = config.config['presence_macs_file']
+        try:
+            persisted_macs = config.config['presence_macs_file']
+        except KeyError:
+            persisted_macs = '/home/scott/cron/persisted_mac_addresses.txt'
         self.read_persisted_macs_file(persisted_macs, Location.HOUSE)
         raw = cmd(
             "ssh [email protected] 'cat /home/scott/cron/persisted_mac_addresses.txt'"
@@ -166,7 +170,7 @@ class PresenceDetection(object):
             location = dict_utils.key_with_min_value(tiebreaks)
             v = votes.get(location, 0)
             votes[location] = v + credit
-            logger.debug('{name}: {location} gets {credit} votes.')
+            logger.debug(f'{name}: {location} gets {credit} votes.')
             credit = int(
                 credit * 0.667
             )  # Note: list most important devices first