Shows the current status of www.githubstatus.com. Find out if Github is having DDOS problems which will affect pushes/pulls.
#!/usr/bin/env python3
# <xbar.title>GitHub status</xbar.title>
# <xbar.version>v0.4</xbar.version>
# <xbar.author>Brett Jones</xbar.author>
# <xbar.author.github>blockloop</xbar.author.github>
# <xbar.image>https://cloud.githubusercontent.com/assets/3022496/12325555/a4b2bd9a-ba90-11e5-8254-9de54c2c6847.png</xbar.image>
# <xbar.desc>Shows the current status of www.githubstatus.com. Find out if Github is having DDOS problems which will affect pushes/pulls.</xbar.desc>
# <xbar.dependencies>python</xbar.dependencies>
import json
import time
from datetime import datetime
from urllib.request import urlopen
# See https://www.githubstatus.com/api
body = urlopen("https://kctbh9vrtdwd.statuspage.io/api/v2/status.json").read()
obj = json.loads(body.decode('utf-8'))
image = "PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pgo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMC8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9UUi8yMDAxL1JFQy1TVkctMjAwMTA5MDQvRFREL3N2ZzEwLmR0ZCI+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgaWQ9ImJvZHlfMSIgd2lkdGg9IjE4IiBoZWlnaHQ9IjE4Ij4KCjxnIHRyYW5zZm9ybT0ibWF0cml4KDAuMTgzNjczNDcgMCAwIDAuMTg3NSAwIDApIj4KICAgIDxwYXRoIGQ9Ik00OC44NTQgMEMgMjEuODM5IDAgMCAyMiAwIDQ5LjIxN0MgMCA3MC45NzMgMTMuOTkzIDg5LjM4OSAzMy40MDUgOTUuOTA3QyAzNS44MzIgOTYuMzk2OTk2IDM2LjcyMSA5NC44NDggMzYuNzIxIDkzLjU0NUMgMzYuNzIxIDkyLjQwNCAzNi42NDEgODguNDkzIDM2LjY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Dc5Ljk5NCA0MS4yMzEwMDMgNzkuOTk0IDQ2LjYwOTAwNUMgNzkuOTk0IDY1LjUxNDAxIDY4LjU5MDAwNCA2OS42NjkwMSA1Ny42NzAwMDYgNzAuODkyMDA2QyA1OS40NTAwMDUgNzIuNDQgNjAuOTg2MDA4IDc1LjM3MzAxIDYwLjk4NjAwOCA4MC4wMTgwMDVDIDYwLjk4NjAwOCA4Ni42MTgwMDQgNjAuOTA2MDA2IDkxLjkxNTAxIDYwLjkwNjAwNiA5My41NDQwMUMgNjAuOTA2MDA2IDk0Ljg0ODAxIDYxLjc5NjAwNSA5Ni4zOTcgNjQuMjIyMDEgOTUuOTA4MDA1QyA4My42MzQwMSA4OS4zODgwMSA5Ny42MjcwMSA3MC45NzMwMSA5Ny42MjcwMSA0OS4yMTcwMDNDIDk3LjcwNyAyMiA3NS43ODggMCA0OC44NTQgMHoiIHN0cm9rZT0ibm9uZSIgZmlsbD0iIzI0MjkyRiIgZmlsbC1ydWxlPSJub256ZXJvIiAvPgo8L2c+Cjwvc3ZnPg=="
if obj["status"]["indicator"] == "none":
print("✓ | templateImage=" + image)
else:
print("✕ | color=red templateImage=" + image)
print("---")
print((obj["status"]["description"] + " | href=" + obj["page"]["url"]))
# convert UTC to local
utc_date = datetime.strptime(obj["page"]["updated_at"], '%Y-%m-%dT%H:%M:%S.%fZ')
now = time.time()
offset = datetime.fromtimestamp(now) - datetime.utcfromtimestamp(now)
local_time = utc_date + offset
print(("Last Change: %s" % local_time.strftime("%D %r")))