Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

updated for python3 #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from chalice import Chalice
from urllib import unquote

import json
import urllib
import requests
from chalice import Chalice
from urllib.parse import quote


app = Chalice(app_name='apple-system-status')

Expand All @@ -16,24 +17,24 @@

@app.route('/services')
def get_services():

result = []

for _, servicekeys in service_classes.iteritems():
for _, servicekeys in service_classes.items():
for service in servicekeys:
serviceName = service.get('serviceName')
result.append(serviceName)

return json.dumps(result)

@app.route('/service/{name}')
def get_service(name):

result = {}

for _, servicekeys in service_classes.iteritems():
for _, servicekeys in service_classes.items():
for service in servicekeys:
if unquote(name) in service['serviceName']:
if urllib.parse.unquote(name) in service['serviceName']:
result = service

return json.dumps(result)
Expand All @@ -45,9 +46,9 @@ def get_service_status(name, status):
down_status_list = ['']
up_status_list = ['resolved', 'completed']

for _, servicekeys in service_classes.iteritems():
for _, servicekeys in service_classes.items():
for service in servicekeys:
if unquote(name) in service['serviceName']:
if urllib.parse.unquote(name) in service['serviceName']:
eventStatus = service['events'][0]['eventStatus']
if 'up' in status:
if len(service['events']) == 0:
Expand All @@ -67,7 +68,7 @@ def get_service_status(name, status):
result = False
else:
result = 'Invalid status request'

return json.dumps(result)

@app.route('/devstatus')
Expand All @@ -82,7 +83,7 @@ def get_dev():

else:
result[serviceName] = service.get('events')

return json.dumps(result)

@app.route('/prodstatus')
Expand All @@ -97,7 +98,5 @@ def get_prod():

else:
result[serviceName] = service.get('events')

return json.dumps(result)


return json.dumps(result)