Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: third_party/boto/scripts/rebuild_endpoints.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/boto/boto/vpc/__init__.py ('k') | third_party/boto/setup.cfg » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/boto/scripts/rebuild_endpoints.py
===================================================================
--- third_party/boto/scripts/rebuild_endpoints.py (revision 0)
+++ third_party/boto/scripts/rebuild_endpoints.py (revision 0)
@@ -0,0 +1,54 @@
+from __future__ import print_function
+
+import json
+from pyquery import PyQuery as pq
+import requests
+
+
+class FetchError(Exception):
+ pass
+
+
+def fetch_endpoints():
+ # We utilize what the Java SDK publishes as a baseline.
+ resp = requests.get('https://raw2.github.com/aws/aws-sdk-java/master/src/main/resources/etc/regions.xml')
+
+ if int(resp.status_code) != 200:
+ raise FetchError("Failed to fetch the endpoints. Got {0}: {1}".format(
+ resp.status,
+ resp.body
+ ))
+
+ return resp.text
+
+def parse_xml(raw_xml):
+ return pq(raw_xml, parser='xml')
+
+
+def build_data(doc):
+ data = {}
+
+ # Run through all the regions. These have all the data we need.
+ for region_elem in doc('Regions').find('Region'):
+ region = pq(region_elem, parser='xml')
+ region_name = region.find('Name').text()
+
+ for endp in region.find('Endpoint'):
+ service_name = endp.find('ServiceName').text
+ endpoint = endp.find('Hostname').text
+
+ data.setdefault(service_name, {})
+ data[service_name][region_name] = endpoint
+
+ return data
+
+
+def main():
+ raw_xml = fetch_endpoints()
+ doc = parse_xml(raw_xml)
+ data = build_data(doc)
+ print(json.dumps(data, indent=4, sort_keys=True))
+
+
+if __name__ == '__main__':
+ main()
Property changes on: third_party/boto/scripts/rebuild_endpoints.py
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « third_party/boto/boto/vpc/__init__.py ('k') | third_party/boto/setup.cfg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698