{
"info": {
"author": "4teamwork AG",
"author_email": "mailto:info@4teamwork.ch",
"bugtrack_url": null,
"classifiers": [
"Framework :: Plone",
"Framework :: Plone :: 4.3",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules"
],
"description": "ftw.slacker\n===========\n\n.. contents:: Table of Contents\n\n\nIntroduction\n------------\n\nThe ``ftw.slacker`` is a Plone addon that provides an easy to use api to post messages into a Slack channel through Slack's webhooks api.\n\nFor more information about slack webhooks see Slack's documentation about `Incoming Webhooks`_\n\nInstallation\n------------\n\nAdd the package as dependency to your setup.py:\n\n.. code:: python\n\n setup(\n # ...\n install_requires=[\n 'ftw.slacker',\n ])\n\nor to your buildout configuration:\n\n.. code:: ini\n\n [instance]\n eggs += ftw.slacker\n\nand run buildout\n\n.. code:: bash\n\n bin/buildout\n\nUsage\n-----\n\nSetup Slack webhook\n~~~~~~~~~~~~~~~~~~~\n\nFirst of all, you need to setup a Slack webhook.\n\nRead the Slack documentation about `Incoming Webhooks`_ and start\nsetting up your own webhock by follow the `incoming webhook integration `_.\n\nPost message to Slack\n~~~~~~~~~~~~~~~~~~~~~\n\nJust import the `notify_slack` api function and call it.\n\n.. code:: python\n\n from ftw.slacker import notify_slack\n\n notify_slack('https://hooks.slack.com/services/xxx',\n text=\"my first post\")\n\nDone!\n\nConfigure the requests module\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nFollowing properties are passed to the requests module:\n\n- `webhook_url `_\n- `timeout `_\n- `verify `_\n\nThat means, you can call the api-function with this parameteres to configure the request:\n\n.. code:: python\n\n from ftw.slacker import notify_slack\n\n notify_slack(webhook_url='https://hooks.slack.com/services/xxx',\n timemout=10,\n verify=False,\n text=\"my first post\")\n\nSlack payload\n~~~~~~~~~~~~~\n\nJust add additional keyword arguments to the api-function. All parameters will be passed\nas payload to the Slack webhook.\n\n.. code:: python\n\n from ftw.slacker import notify_slack\n\n notify_slack('https://hooks.slack.com/services/xxx',\n text=\"my first post\",\n attachments=[\n {\n \"title\": \"Slack API Documentation\",\n \"title_link\": \"https://api.slack.com/\",\n \"text\": \"Optional text that appears within the attachment\"\n }\n ])\n\nWebhook URL by environment variables\n------------------------------------\n\nNormally you don't want to store your webhook-url in your application code.\n\n``ftw.slacker`` supports configuration through environment-variables:\n\nSet your environment variable:\n\n.. code:: bash\n\n export STANDARD_SLACK_WEBHOOK='https://hooks.slack.com/services/xxx'\n\nor through buildout:\n\n.. code:: ini\n\n [instance]\n environment-vars +=\n STANDARD_SLACK_WEBHOOK https://hooks.slack.com/services/xxx\n\nand call the api-function without webhook_url parameter:\n\n.. code:: python\n\n from ftw.slacker import notify_slack\n\n notify_slack(text=\"my first post\")\n\nOverride the environment variable\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIf you set the STANDARD_SLACK_WEBHOOK environment variable, you can still use a different\nslack webhook.\n\n.. code:: bash\n\n export STANDARD_SLACK_WEBHOOK='https://hooks.slack.com/services/default-channel-id'\n\n.. code:: python\n\n from ftw.slacker import notify_slack\n\n # Post message to service default-channel-id\n notify_slack(text=\"my first post\")\n\n # Post message to service specific-channel-id\n notify_slack('https://hooks.slack.com/services/specific-channel-id',\n text=\"my first post\")\n\nDeactivate Slack notification\n-----------------------------\n\nLet's imagine, you have a server with multiple deployments and all deployments should\npush to the same Slack webhook.\n\nYou can either configure the standard slack webhook envoronment variable through buildout\nfor each deployment, or you just define the default webhook url once in your server environment:\n\n.. code:: bash\n\n export STANDARD_SLACK_WEBHOOK='https://hooks.slack.com/services/xxx'\n\nEach application will post messages to this slack webhook.\n\nBlacklist\n~~~~~~~~~\n\nNow you install a test-deployment on the same server where you want to deactivate the notifications.\n\nFor this purpose, you can set another environment variable in this specific deployment's ``builodut.cfg`` to\nthe value: ``deactivate``. (see the static variable ``NOTIFICATION_DEACTIVATION_VALUE``):\n\n.. code:: ini\n\n [instance]\n environment-vars +=\n DEACTIVATE_SLACK_NOTIFICATION deactivate\n\nAll notifications performed by this deployment will be skipped.\n\nWhitelist\n~~~~~~~~~\n\nYou could even do a whitelist for your deployments.\n\n.. code:: bash\n\n export STANDARD_SLACK_WEBHOOK='https://hooks.slack.com/services/xxx'\n export DEACTIVATE_SLACK_NOTIFICATION deactivate\n\nAnd for all whitelisted deployments, use the following buildout configuration:\n\n.. code:: ini\n\n [instance]\n environment-vars +=\n DEACTIVATE_SLACK_NOTIFICATION\n\nThis will reset the DEACTIVATE_SLACK_NOTIFICATION variable to ``''``\n\nDeactivate through webhook_url\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIt's also possible to deactivate just a specific notification.\n\nLet's say, you have set your STANDARD_SLACK_WEBHOOK. We've learned, that\nyou can call ``notify_slack`` without any webhook_url to push notification\nto the standard webhook url or you can call it with a more specific webhook url\n``notify_slack(webhook_url=\"xxx\")`` to override the standard slack webhook.\n\nUsing the NOTIFICATION_DEACTIVATION_VALUE as the webhook_url will just deactivate\nthe current notification and will not bubble up to the standard slack webhook.\n\nThis feature is expecially useful for handling notification comming from multiple\nexternal modules using the slacker-integration.\n\nSee the next chapter for more information about advanced usage.\n\nAdvance usage\n-------------\n\nPerhaps you've got different external modules using the ``ftw.slacker`` implementation and\nall of this modules providing a different default slack webhook url.\n\nLet's imagine, we have a module calling ``ftw.logger`` which logs all userlogins within your\nplonesite to a slack-channel.\n\nIt provides an additional environment variable called ``FTW_LOGGER_SLACK_WEBHOOK`` to post the\nlogging-activities to a separate channel. So the implementation of this module may\nlook like this:\n\n.. code:: python\n\n from ftw.slacker import notify_slack\n import os\n\n def notify_user_login(user):\n notify_slack(os.environ.get('FTW_LOGGER_SLACK_WEBHOOK'),\n text='User {} logged in'.format(user.username))\n\nIf you don't set the ``FTW_LOGGER_SLACK_WEBHOOK`` variable, ``ftw.slacker`` will post the user\nlogin to the default channel. If you set `FTW_LOGGER_SLACK_WEBHOOK`, ``ftw.slacker`` will\nuse this more specific channel for notifications.\n\nDeactivating the whole notification system through the DEACTIVATE_SLACK_NOTIFICATION\nenvironment variable is not desired, because you still want to post other notifications,\ni.e. from your application which uses the standard slack webhook url.\n\nFor this puropose, you can just deactivate this specific notification branch by setting\nthe environment variable ``FTW_LOGGER_SLACK_WEBHOOK`` to ``deactivate`` (see the static\nvariable ``NOTIFICATION_DEACTIVATION_VALUE``).\n\n.. code:: ini\n\n [instance]\n environment-vars +=\n STANDARD_SLACK_WEBHOOK https://hooks.slack.com/services/xxx\n FTW_LOGGER_SLACK_WEBHOOK deactivate\n\nThreading\n---------\n\nAll requests to the Slack-API will be handled within its own threads.\nAll messages are sent in a separate thread so that it is non-blocking and does not\ncrash the application on an error.\n\nThe function ``notify_slack`` returns the thread-object for further thread handlings (i.e. in testing) or none.\n\nLinks\n-----\n\n- Main project repository: https://github.com/4teamwork/ftw.slacker\n- Issue tracker: https://github.com/4teamwork/ftw.slacker/issues\n\nCopyright\n---------\n\nThis package is copyright by `4teamwork `_.\n\n``ftw.slacker`` is licensed under GNU General Public License, version 2.\n\n.. _Incoming Webhooks: https://api.slack.com/incoming-webhooks\n\nChangelog\n=========\n\n1.0.2 (2017-07-31)\n------------------\n\n- Use unittest instead unittest2 in tests.\n [elioschmutz]\n\n\n1.0.1 (2017-07-27)\n------------------\n\n- Fix README.rst errors.\n [elioschmutz]\n\n\n1.0.0 (2017-07-27)\n------------------\n\n- Initial release.",
"description_content_type": null,
"docs_url": null,
"download_url": "",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://git.4teamwork.ch/ftw/ftw.slacker",
"keywords": "ftw slacker slack webhoock api",
"license": "GPL2",
"maintainer": "",
"maintainer_email": "",
"name": "ftw.slacker",
"package_url": "https://pypi.org/project/ftw.slacker/",
"platform": "",
"project_url": "https://pypi.org/project/ftw.slacker/",
"project_urls": {
"Homepage": "https://git.4teamwork.ch/ftw/ftw.slacker"
},
"release_url": "https://pypi.org/project/ftw.slacker/1.0.2/",
"requires_dist": null,
"requires_python": "",
"summary": "Uses webhooks to post messages into a slack channel.",
"version": "1.0.2"
},
"last_serial": 5823513,
"releases": {
"1.0.0": [
{
"comment_text": "",
"digests": {
"md5": "8c667507e27793096e8ec9340dd7f5f4",
"sha256": "5bba92a8ea4a0a4533db7ac7feaa35feec485605a9fd143eea1b10fe1c6b5705"
},
"downloads": -1,
"filename": "ftw.slacker-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "8c667507e27793096e8ec9340dd7f5f4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7678,
"upload_time": "2017-07-27T15:24:35",
"url": "https://files.pythonhosted.org/packages/f8/af/4f33e3ef896068d7665328a5e5e7db66e5c3a4412047a8525034cc99377d/ftw.slacker-1.0.0.tar.gz"
}
],
"1.0.1": [
{
"comment_text": "",
"digests": {
"md5": "94cdd0e039e93d719ac384e40c40d5f8",
"sha256": "2509f7b681b1597e072ab5e4a5f02c63f2ab52182b2499e5d0e77240161ddeb5"
},
"downloads": -1,
"filename": "ftw.slacker-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "94cdd0e039e93d719ac384e40c40d5f8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7767,
"upload_time": "2017-07-27T16:21:03",
"url": "https://files.pythonhosted.org/packages/1f/a1/da6caf687ae6bbe0a6e4b6b6815a8c8f8ed8437706fc73e25b008fda76b6/ftw.slacker-1.0.1.tar.gz"
}
],
"1.0.2": [
{
"comment_text": "",
"digests": {
"md5": "c6ebf72125f402bfffd1a0f0dd8afea2",
"sha256": "3791d4bf365d814367d766ac30018676fa518fc3ad62e05f5d238333ae9ff992"
},
"downloads": -1,
"filename": "ftw.slacker-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "c6ebf72125f402bfffd1a0f0dd8afea2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7793,
"upload_time": "2017-07-31T08:48:55",
"url": "https://files.pythonhosted.org/packages/3a/34/1b378d2092db8e4cde1293b494194f1963203f5cd943709898e73ceec6ce/ftw.slacker-1.0.2.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "c6ebf72125f402bfffd1a0f0dd8afea2",
"sha256": "3791d4bf365d814367d766ac30018676fa518fc3ad62e05f5d238333ae9ff992"
},
"downloads": -1,
"filename": "ftw.slacker-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "c6ebf72125f402bfffd1a0f0dd8afea2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7793,
"upload_time": "2017-07-31T08:48:55",
"url": "https://files.pythonhosted.org/packages/3a/34/1b378d2092db8e4cde1293b494194f1963203f5cd943709898e73ceec6ce/ftw.slacker-1.0.2.tar.gz"
}
]
}