You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2021/10/24 18:11:17 UTC
[libcloud] 04/04: Try using jsonnet which should work under Python
3.
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit 6eef7a5fc68662abb380ddc82a68dbb9b09b3462
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Oct 24 20:06:06 2021 +0200
Try using jsonnet which should work under Python 3.
---
contrib/scrape-ec2-prices.py | 6 ++++--
tox.ini | 9 +++------
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/contrib/scrape-ec2-prices.py b/contrib/scrape-ec2-prices.py
index e552fff..33638eb 100755
--- a/contrib/scrape-ec2-prices.py
+++ b/contrib/scrape-ec2-prices.py
@@ -25,7 +25,7 @@ import time
from collections import defaultdict, OrderedDict
import requests
-import demjson # pylint: disable=import-error
+import _jsonnet # pylint: disable=import-error
LINUX_PRICING_URLS = [
# Deprecated instances (JSON format)
@@ -179,8 +179,10 @@ def scrape_ec2_pricing():
match = re.match(r'^.*callback\((.*?)\);?$', data,
re.MULTILINE | re.DOTALL)
data = match.group(1)
+ # NOTE: We used to use demjson, but it's not working under Python 3 and new version of
+ # setuptools anymore so we use jsonnet
# demjson supports non-strict mode and can parse unquoted objects
- data = demjson.decode(data)
+ data = json.loads(_jsonnet.evaluate_snippet('snippet', data))
regions = data['config']['regions']
for region_data in regions:
diff --git a/tox.ini b/tox.ini
index ceebc59..b1d3215 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,9 +1,6 @@
[tox]
envlist = py{pypy3.5,3.5,3.6,3.7,3.8,3.9,3.10},checks,lint,pylint,mypy,docs,coverage,integration-storage
skipsdist = true
-requires =
- # Need to old old version for demjson which relies on 2to3
- setuptools==57.5.0
[testenv]
passenv = TERM CI GITHUB_* DOCKER_*
@@ -122,7 +119,7 @@ commands = python ./contrib/generate_provider_feature_matrix_table.py
[testenv:scrape-and-publish-provider-prices]
basepython: python3.7
deps = requests
- demjson==2.2.4
+ jsonnet
setenv =
PYTHONPATH={toxinidir}
passenv = TERM GCE_API_KEY PRICING_DATA_BUCKET_NAME AWS_REGION AWS_ACCESS_KEY_ID AWS_ACCESS_KEY_SECRET
@@ -145,7 +142,7 @@ commands =
[testenv:scrape-provider-prices]
basepython: python3.7
deps = requests
- demjson==2.2.4
+ jsonnet
passenv = TERM GCE_API_KEY
whitelist_externals = sha512sum
bash
@@ -162,7 +159,7 @@ commands =
[testenv:scrape-ec2-prices]
basepython: python3.7
deps = requests
- demjson==2.2.4
+ jsonnet
tqdm
commands = python contrib/scrape-ec2-prices.py