From c144022e7971b23b87dccdf749cf679ec50fc936 Mon Sep 17 00:00:00 2001 From: Flavio Torres Date: Tue, 2 Feb 2021 23:06:17 -0800 Subject: [PATCH 1/3] code update for python3 updated unquote to urllib.parse.unquote updated iteritems to items --- app.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app.py b/app.py index c4a0d66..15a708d 100644 --- a/app.py +++ b/app.py @@ -1,10 +1,11 @@ -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') + +app = Chalice(app_name='fs_status') service_classes = {} @@ -13,17 +14,18 @@ prodjson = requests.get("https://www.apple.com/support/systemstatus/data/system_status_en_US.js").text service_classes['prod'] = json.loads(prodjson)['services'] +print (service_classes['prod']) @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}') @@ -31,9 +33,9 @@ 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) @@ -45,9 +47,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: @@ -67,7 +69,7 @@ def get_service_status(name, status): result = False else: result = 'Invalid status request' - + return json.dumps(result) @app.route('/devstatus') @@ -82,7 +84,7 @@ def get_dev(): else: result[serviceName] = service.get('events') - + return json.dumps(result) @app.route('/prodstatus') @@ -97,7 +99,5 @@ def get_prod(): else: result[serviceName] = service.get('events') - - return json.dumps(result) - + return json.dumps(result) From fa6d643f723976c18932b2d3f4869506cb372c6f Mon Sep 17 00:00:00 2001 From: Flavio Torres Date: Tue, 2 Feb 2021 23:07:35 -0800 Subject: [PATCH 2/3] Update app.py --- app.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app.py b/app.py index 15a708d..54b0247 100644 --- a/app.py +++ b/app.py @@ -14,7 +14,6 @@ prodjson = requests.get("https://www.apple.com/support/systemstatus/data/system_status_en_US.js").text service_classes['prod'] = json.loads(prodjson)['services'] -print (service_classes['prod']) @app.route('/services') def get_services(): From b8609559e0a1a05eb67c4405cbce88591c5dc398 Mon Sep 17 00:00:00 2001 From: Flavio Torres Date: Tue, 2 Feb 2021 23:09:23 -0800 Subject: [PATCH 3/3] Update app.py --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index 54b0247..818eb09 100644 --- a/app.py +++ b/app.py @@ -5,7 +5,7 @@ from urllib.parse import quote -app = Chalice(app_name='fs_status') +app = Chalice(app_name='apple-system-status') service_classes = {}