Kami commented on code in PR #1715:
URL: https://github.com/apache/libcloud/pull/1715#discussion_r908895069


##########
contrib/scrape-ec2-prices.py:
##########
@@ -161,82 +48,155 @@
     "extra-large",
 ]
 
-RE_NUMERIC_OTHER = re.compile(r"(?:([0-9]+)|([-A-Z_a-z]+)|([^-0-9A-Z_a-z]+))")
-
-BASE_PATH = os.path.dirname(os.path.abspath(__file__))
-PRICING_FILE_PATH = os.path.join(BASE_PATH, "../libcloud/data/pricing.json")
-PRICING_FILE_PATH = os.path.abspath(PRICING_FILE_PATH)
-
 
+def download_json():
+    response = requests.get(URL, stream=True)
+    try:
+        return open(TEMPFILE, "r")
+    except IOError:
+        with open(TEMPFILE, "wb") as fo:
+            for chunk in response.iter_content(chunk_size=2**20):
+                if chunk:
+                    fo.write(chunk)
+    return open(TEMPFILE, "r")
+
+
+def get_json():
+    try:
+        return open(TEMPFILE, "r")

Review Comment:
   May be a good idea to use with context manager to ensure file is closed 
(then again, this script is short lived so any file handle leaks are not a big 
deal)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@libcloud.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to