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

env.hosts = settings.DEPLOY_HOSTS


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


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)


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)


Add fallback slack message for deploy script
Add fallback slack message for deploy script

  
  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"):
+         with cd("/var/bot/slack-shogi"):
-         run("git pull")
+             run("git pull")
-         run("supervisorctl reload")
+             run("supervisorctl reload")
-     slack("Deploy Finished")
+         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)
  
+ 
Add fallback slack message for deploy script
## Code Before:

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

env.hosts = settings.DEPLOY_HOSTS


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


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)

## Instruction:
Add fallback slack message for deploy script
## Code After:

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)

