projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make profanity filter catch foo/bar where foo and/or bar are bad
[python_utils.git]
/
base_presence.py
diff --git
a/base_presence.py
b/base_presence.py
index eff613b5edcfaea975ad5e7d37afe021fc14a03b..405b743f90e33a85394528403f06bce71d153cc8 100755
(executable)
--- a/
base_presence.py
+++ b/
base_presence.py
@@
-5,6
+5,7
@@
from collections import defaultdict
import logging
import re
from typing import Dict, List, Set
import logging
import re
from typing import Dict, List, Set
+import warnings
# Note: this module is fairly early loaded. Be aware of dependencies.
import argparse_utils
# Note: this module is fairly early loaded. Be aware of dependencies.
import argparse_utils
@@
-113,7
+114,9
@@
class PresenceDetection(object):
self.parse_raw_macs_file(raw, Location.CABIN)
except Exception as e:
logger.exception(e)
self.parse_raw_macs_file(raw, Location.CABIN)
except Exception as e:
logger.exception(e)
- logger.warning("Can't see the cabin right now; presence detection impared.")
+ msg = "Can't see the cabin right now; presence detection impared."
+ warnings.warn(msg)
+ logger.warning(msg, stacklevel=2)
self.dark_locations.add(Location.CABIN)
def update_from_cabin(self) -> None:
self.dark_locations.add(Location.CABIN)
def update_from_cabin(self) -> None:
@@
-131,7
+134,9
@@
class PresenceDetection(object):
self.parse_raw_macs_file(raw, Location.HOUSE)
except Exception as e:
logger.exception(e)
self.parse_raw_macs_file(raw, Location.HOUSE)
except Exception as e:
logger.exception(e)
- logger.warning("Can't see the house right now; presence detection impared.")
+ msg = "Can't see the house right now; presence detection impared."
+ logger.warning(msg)
+ warnings.warn(msg, stacklevel=2)
self.dark_locations.add(Location.HOUSE)
def read_persisted_macs_file(
self.dark_locations.add(Location.HOUSE)
def read_persisted_macs_file(
@@
-193,9
+198,9
@@
class PresenceDetection(object):
def where_is_person_now(self, name: Person) -> Location:
self.maybe_update()
if len(self.dark_locations) > 0:
def where_is_person_now(self, name: Person) -> Location:
self.maybe_update()
if len(self.dark_locations) > 0:
- logger.warning(
- f"Can't see {self.dark_locations} right now; answer confidence impacted"
- )
+ msg = f"Can't see {self.dark_locations} right now; answer confidence impacted"
+ logger.warning(msg)
+
warnings.warn(msg, stacklevel=2
)
logger.debug(f'Looking for {name}...')
if name is Person.UNKNOWN:
logger.debug(f'Looking for {name}...')
if name is Person.UNKNOWN: