<jupyter_start><jupyter_text>Jupyter + Slack Driven DevelopmentThis example shows how environment variables allow the python core to publish a message into Slack to notify the associated user with a message containing the line number and source code that threw the exception.<jupyter_code>import os, sys, json

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

from pycore import PyCore

print 'Initializing Python Core'
core = PyCore()

print 'These Slack Env variables are set by docker'
slackbotname   = str(os.getenv('ENV_SLACK_BOTNAME'))
slackchannel   = str(os.getenv('ENV_SLACK_CHANNEL'))
slacknotifyuser= str(os.getenv('ENV_SLACK_NOTIFY_USER'))
slacktoken     = str(os.getenv('ENV_SLACK_TOKEN'))
slackenvname   = str(os.getenv('ENV_SLACK_ENVNAME'))

core.lg('Slack Env - Bot(' + slackbotname + ') Channel(' + slackchannel + ') NotifyThisUser(' + slacknotifyuser + ') Token(' + slacktoken + ') Env(' + slackenvname + ')', 1)
try:
    core.lg('')
    core.lg('-----------------------------------------------------------------------------', 2)
    core.lg('This will throw an exception and should post a message into the Slack Channel')
    core.lg('')
    THIS_VARIABLE_DOES_NOT_EXIST
except Exception,e:
    core.handle_send_slack_internal_ex(e)
# end of try/ex<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1669195751138088, 'fraction_numerical': 0.002276176024279211, 'mean_word_length': 3.867158671586716, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '178080', 'license': 'Apache-2.0', 'n_tokens_mistral': 421, 'n_tokens_neox': 414, 'n_words': 112, 'path': 'examples/example-slack-debugging.ipynb', 'repo_name': 'jayvdb/sci-pype', 'size': '1318'}