Adde some more logging information to INFO and some more code comments.

This commit is contained in:
Johannes Findeisen 2022-09-10 01:39:49 +02:00
commit 5f975f90d6
2 changed files with 14 additions and 9 deletions

View file

@ -49,7 +49,7 @@ MINOR changes are "just-in-time" changes or small enhancements which should not
documentation. documentation.
FIXES should never affect anything else then stability or security. FIXES should never affect anything else then stability or security.
""" """
__version__ = '0.9.0.0' __version__ = '0.9.0.1'
__author__ = 'Johannes Findeisen <you@hanez.org>' __author__ = 'Johannes Findeisen <you@hanez.org>'
logger = logging.getLogger('uplink') logger = logging.getLogger('uplink')

View file

@ -26,7 +26,12 @@ from logging import getLogger
logger = getLogger('uplink') logger = getLogger('uplink')
""" """
This is experimental because you can set what you want but if a env key you set already exists it this is for environment vars which can be set dynamically at runtime. these vars are shared across
all objects and are readable and writable by all of them. environment variables are set at runtime
and currently not stored in the database. the goal is to minimize all of these vars but for now it
is nice feature to save states without saving them for runtime execution at another place.
this is experimental because you can set what you want but if a env key you set already exists it
will be overwritten. But it is an easy and maybe secure way to to set runtime variables which should will be overwritten. But it is an easy and maybe secure way to to set runtime variables which should
not affect the execution of uplink but may be required variables to execute to your wanted not affect the execution of uplink but may be required variables to execute to your wanted
configuration. Core functionality must not be affected when using this class! configuration. Core functionality must not be affected when using this class!
@ -36,19 +41,19 @@ configuration. Core functionality must not be affected when using this class!
class Environment: class Environment:
def __init__(self): def __init__(self):
# environment vars which can be set dynamically at runtime. these vars are shared across all
# objects and readable and writable by all of them.
self.__env = {} self.__env = {}
def get_env_var(self, key): def get_env_var(self, key):
if key in self.__env: if key in self.__env:
return self.__env[key] return self.__env[key]
else: else:
logger.info('environment var "' + key + '" not found! could be that is set late at ' logger.info('environment var "' + key + '" not found! could be that it is set later at '
'runtime. if you encounter errors executing ' 'runtime. if you encounter any errors '
'uplink, something is wrong in the code. ' 'executing uplink, something is wrong in the '
'please consider to report this as a bug! btw. ' 'logic of the code. please consider reporting '
'INFO is not an ERROR!') 'this as a bug! btw. INFO is not an ERROR! '
'uplink should work even with missing '
'environment variables.')
return False return False
def set_env_var(self, key, value): def set_env_var(self, key, value):