projects
/
python_utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
65e6f78
)
Have bootstrap log the site_config at program initialization.
author
Scott Gasch
<
[email protected]
>
Fri, 4 Feb 2022 20:13:37 +0000
(12:13 -0800)
committer
Scott Gasch
<
[email protected]
>
Fri, 4 Feb 2022 20:13:37 +0000
(12:13 -0800)
bootstrap.py
patch
|
blob
|
history
site_config.py
patch
|
blob
|
history
diff --git
a/bootstrap.py
b/bootstrap.py
index c89952a838dfb345acbc5cc2f2567d5c028a3287..2df95884957624f28ddec9cf36d46d9486234d1d 100644
(file)
--- a/
bootstrap.py
+++ b/
bootstrap.py
@@
-252,6
+252,11
@@
def initialize(entry_point):
logger.debug(f'Python C API version: {sys.api_version}')
logger.debug(f'Python path: {sys.path}')
logger.debug(f'Python C API version: {sys.api_version}')
logger.debug(f'Python path: {sys.path}')
+ # Log something about the site_config, many things use it.
+ import site_config
+
+ logger.debug(f'Global site_config: {site_config.get_config()}')
+
# Allow programs that don't bother to override the random seed
# to be replayed via the commandline.
import random
# Allow programs that don't bother to override the random seed
# to be replayed via the commandline.
import random
diff --git
a/site_config.py
b/site_config.py
index 3bf049e3787f66a38f42b5be0330642f4f39e645..d98c6bc36b8e5671ea581f14dd21f31356debc99 100644
(file)
--- a/
site_config.py
+++ b/
site_config.py
@@
-92,16
+92,7
@@
def this_location() -> str:
return location
return location
-def get_config(location_override: Optional[str] = None):
- """
- Get a configuration dataclass with information that is
- site-specific including the current running location.
-
- >>> cfg = get_config()
- >>> cfg.location_name == 'HOUSE' or cfg.location_name == 'CABIN'
- True
-
- """
+def effective_location(location_override: Optional[str] = None) -> str:
if location_override is None:
try:
location_override = config.config['site_config_override_location']
if location_override is None:
try:
location_override = config.config['site_config_override_location']
@@
-111,8
+102,22
@@
def get_config(location_override: Optional[str] = None):
if location_override is None or location_override == 'NONE':
location = this_location()
else:
if location_override is None or location_override == 'NONE':
location = this_location()
else:
+ logger.debug(f'site_config\'s location_override was set to: {location_override}')
location = location_override
location = location_override
+ return location
+
+def get_config(location_override: Optional[str] = None):
+ """
+ Get a configuration dataclass with information that is
+ site-specific including the current running location.
+
+ >>> cfg = get_config()
+ >>> cfg.location_name == 'HOUSE' or cfg.location_name == 'CABIN'
+ True
+
+ """
+ location = effective_location(location_override)
if location == 'HOUSE':
return SiteConfig(
location_name='HOUSE',
if location == 'HOUSE':
return SiteConfig(
location_name='HOUSE',