X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=site_config.py;h=5604de676c0ded41ce5edcc051809ac7968c6286;hb=532df2c5b57c7517dfb3dddd8c1358fbadf8baf3;hp=7f6410d39356c1d0d8f910cfcece67eaf4cff29e;hpb=e8fbbb7306430478dec55d2c963eed116d8330cc;p=python_utils.git diff --git a/site_config.py b/site_config.py index 7f6410d..5604de6 100644 --- a/site_config.py +++ b/site_config.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 +# © Copyright 2021-2022, Scott Gasch + """Location/site dependent data.""" import logging @@ -82,15 +84,18 @@ def other_location() -> str: >>> x in set(['HOUSE', 'CABIN']) True + >>> y = this_location() + >>> x == y + False + """ - hostname = platform.node() - if '.house' in hostname: - location = 'CABIN' - elif '.cabin' in hostname: - location = 'HOUSE' + this = this_location() + if this == 'HOUSE': + return 'CABIN' + elif this == 'CABIN': + return 'HOUSE' else: - raise Exception(f"{hostname} doesn't help me know where I'm running?!") - return location + raise Exception(f"{this} doesn't tell me where I'm running?!") def this_location() -> str: @@ -107,6 +112,8 @@ def this_location() -> str: location = 'HOUSE' elif '.cabin' in hostname: location = 'CABIN' + elif '.local' in hostname: + location = 'HOUSE' else: raise Exception(f"{hostname} doesn't help me know where I'm running?!") return location