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 2020/07/11 15:19:32 UTC
[libcloud] 06/08: Bail early if pricing data hasn't changed.
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 75887e8b5c885dc5f1b9b8d9a90ac6ee56aa7a89
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sat Jul 11 17:12:04 2020 +0200
Bail early if pricing data hasn't changed.
---
contrib/scrape-ec2-prices.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/contrib/scrape-ec2-prices.py b/contrib/scrape-ec2-prices.py
index 51ca346..554f745 100755
--- a/contrib/scrape-ec2-prices.py
+++ b/contrib/scrape-ec2-prices.py
@@ -20,6 +20,7 @@
import os
import re
import json
+import copy
import time
from collections import defaultdict, OrderedDict
@@ -233,9 +234,17 @@ def update_pricing_file(pricing_file_path, pricing_data):
content = fp.read()
data = json.loads(content)
- data['updated'] = int(time.time())
+ original_data = copy.deepcopy(data)
+
data['compute'].update(pricing_data)
+ if data == original_data:
+ # Nothing has changed, bail out early and don't update "updated" attribute
+ print("Nothing has changed, skipping update.")
+ return
+
+ data['updated'] = int(time.time())
+
# Always sort the pricing info
data = sort_nested_dict(data)