def status(self, opts): """\nDisplay current and historical GitHub service status""" api = github3.GitHubStatus() messages = api.messages() if not messages: messages = [api.last_message()] status = api.status() status.update({ 'body': 'Current status: %s' % status['status'], 'created_on': status['last_updated'], }) messages.insert(0, status) for message in reversed(messages): ts = time.strptime(message['created_on'], '%Y-%m-%dT%H:%M:%SZ') offset = time.timezone if time.daylight: offset = time.altzone color = { 'good': fgcolor.green, 'minor': fgcolor.yellow, 'major': fgcolor.red }[message['status']] ts = datetime.datetime(ts.tm_year, ts.tm_mon, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec) - datetime.timedelta(0, offset) print('%s %s %s' % (wrap(ts.strftime('%Y-%m-%d %H:%M'), attr.faint), wrap("%-5s" % message['status'], color), message['body']))
def get_client(self): return github3.GitHubStatus()
def setUp(self): super(TestGitHubStatus, self).setUp() self.g = github3.GitHubStatus() self.api = 'https://status.github.com/'