Skip to main content

Jupyterpost: Jupyterhub service for posting to Mattermost.

Project description

Jupyterpost: post from Jupyterhub to a Mattermost server

Installing

pip install jupyterpost

Enabling jupyterpost

  1. Create a bot user on your Mattermost server and get its token.
  2. Add the following at the end of your Jupyterhub config file.
from jupyterpost import configure_jupyterhub

configure_jupyterhub(
    c,
    mattermost_token="your mattermost token",
    mattermost_url="https://your.mattermost.server/api/v4/",
    mattermost_team="your mattermost team name",
    jupyterpost_url="https://services.your.jupyterhub/services/jupyterpost",
)

This will:

  • add a new service jupyterpost to your Jupyterhub
  • give all users and their servers access to this service
  • provide the service URL to the user's server as an environment variable JUPYTERPOST_URL

The function is somewhat fragile, but should work for standard Jupyterhub installations.

Using jupyterpost

from jupyterpost import post
from matplotlib import pyplot

pyplot.plot([0, 1])
post(
    message="Check out my plot",
    channel="my-channel",  # Or "@username"
    attachment=pyplot.gcf(),  # Or png bytes
)

Posting from outside of your Jupyterhub

  1. Get the variables JUPYTERPOST_URL and JPY_API_TOKEN from your Jupyterhub server.
  2. Provide them to jupyterpost.post as additional arguments and connect from anywhere!

Contributing

Contributions are welcome! Please open an issue or a pull request.

Specifically I would like to support more chat services, and more ways to post messages.

Tests would also be great huehuehue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterpost-0.0.1.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

jupyterpost-0.0.1-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page