A set of convenience utils for Python requiring no external libs. Some of the best tricks from django-htk
, without the bloat and Django dependency.
- Debug via Slack using
slack_debug
andslack_debug_json
. The best ofprintln
debugging, without the inconvenience of visually fishing for one message out of thousands of log lines.
- Install via PIP:
pip install htk-lite
- (Alternative install via clone) Installe via local clone: clone this repository into a directory named
htk
(preferred) orhtk_lite
SSH:git clone git@github.com:hacktoolkit/python-htk-lite.git htk
HTTPS:git clone https://github.com/hacktoolkit/python-htk-lite.git
- Create
local_settings.py
and add your Slack incoming webhook URL toSLACK_WEBHOOK_URL
.
- You can place it outside of your app directory tree, and then symlink it inside.
- To not be nagged by the presence of the
htk
directory whenever you dogit status
, addhtk
to your.git/info/exclude
file (like.gitignore
, but only in your local repository, not checked in).
- Example usage in Python Shell
In [1]: from htk import slack_debug In [2]: from htk import slack_debug_json In [3]: slack_debug('This is seriously awesome!') Out[3]: <Response [200]> In [4]: slack_debug('Yeah, no kidding.') Out[4]: <Response [200]> In [5]: slack_debug_json({'A':1,'B':2,'C':3,'X':['foo','bar','baz'],'Z':{'nested_key':'nested_val ...: ue'}}), Out[5]: (None,)
- Check your Slack to verify that the message was posted. If not, perhaps your token was wrong, or the Slack integration was disabled.
(Alternative link to screenshot above: https://cl.ly/436cfb4383a2) - Profit!
- (Recommended) Create a BASH alias or similar:
alias fdb='touch /tmp/fdebug.log; tail -f /tmp/fdebug.log'
- In a separate window used for debugging, run
fdb
to watch the logs roll in.
- In a separate window used for debugging, run
from htk import fdb
fdb('Not all heroes wear capes')
- C# - https://github.com/hacktoolkit/csharp-htk
- PHP - https://github.com/hacktoolkit/php-htk
- Python (full) - https://github.com/hacktoolkit/python-htk
- Python (lite) - https://github.com/hacktoolkit/python-htk-lite
- Ruby - https://github.com/hacktoolkit/htk-rb
MIT. See LICENSE.md