setokinto/slack-shogi

View on GitHub
fabfile.py

Summary

Maintainability
A
0 mins
Test Coverage

# It's for me, sorry

from fabric.api import *
import slackbot_settings as settings
from urllib import request, parse

env.hosts = settings.DEPLOY_HOSTS


def deploy():
    slack("Deploy Started")
    try:
        with cd("/var/bot/slack-shogi"):
            run("git pull")
            run("supervisorctl reload")
        slack("Deploy Finished")
    except:
        slack("Deploy Failed")


def slack(text):
    if settings.WEBHOOK_URL:
        payload = ("payload={\"text\": \"" + parse.quote(text) +
                   "\", \"username\": \"Mr.deploy\"}").encode("utf-8")
        request.urlopen(url=settings.WEBHOOK_URL, data=payload)