Simple Slack interface for your Python application with Yasuf
Slack is now pretty ubiquitous and having the ability to control your Python services via Slack can be nice. With Yasuf you can do that with just a single decorator.
Motivation
I recently needed to add Slack control to a service that manages AWS EC2/GCE instances in response to changing load. I wanted something that could be quickly plugged into an existing code base and just work.
Nothing I found was quite as simple as I’d hoped, and that’s how Yasuf was born.
Usage
In my specific case I have a few functions that launch, terminate and list instances. For example the launch function looks like this:
To launch instances via Slack and get all the text output and the return value, I simply decorate the function with yasuf.handle
.
And run Yasuf when executing the service.
And that’s it! Typing ‘launch 5’ in the ‘ops’ channel will now launch 5 instances and give you back the logs.
Contributing
The github repo is at sYnfo/Yasuf and I very much welcome both new issues and pull requests. :)