Python Core Demo

How to use the python core from a Jupyter notebook. It also shows how to debug the JSON application configs which are used to connect to external database(s) and redis server(s).


In [ ]:
import os, sys, json

sys.path.insert(0, os.getenv('ENV_PYTHON_SRC_DIR', '/opt/work/src'))

from pycore import PyCore

# default config: /opt/work/configs/jupyter.json 
config  = os.getenv('ENV_PYTHON_CORE_CONFIG', '/opt/work/configs/jupyter.json')

print 'Initializing Python Core with Redis and Database Applications - Disabled'
core = PyCore(config)

core.lg('')
core.lg('--------------------------------------------------------')
core.lg('Logging Demos')
core.lg('')
core.lg('  This is RED', 0)
core.lg('  This is BLUE', 1)
core.lg('  This is YELLOW', 2)
core.lg('  This is PURPLE', 3)
core.lg('  This is GRAY', 4)
core.lg('  This is GREEN', 5)
core.lg('  This is BLACK', 6)
core.lg('  Default is BLACK')
core.lg('')

core.lg('--------------------------------------------------------')
core.lg('Here is the Central Resource JSON Configuration', 2)
print core.ppj(core.m_core_json)
core.lg('')

core.lg('--------------------------------------------------------')
core.lg('Here are the Database Resources stored in JSON', 2)
print core.ppj(core.m_db_apps_json)
core.lg('')

core.lg('--------------------------------------------------------')
core.lg('Here are the Redis Resources stored in JSON', 2)
print core.ppj(core.m_rd_apps_json)
core.lg('')