From notifications-return-17289-archive-asf-public=cust-asf.ponee.io@libcloud.apache.org Sat Jul 11 15:19:28 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id A6384180679 for ; Sat, 11 Jul 2020 17:19:27 +0200 (CEST) Received: (qmail 89874 invoked by uid 500); 11 Jul 2020 15:19:27 -0000 Mailing-List: contact notifications-help@libcloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@libcloud.apache.org Delivered-To: mailing list notifications@libcloud.apache.org Received: (qmail 89797 invoked by uid 500); 11 Jul 2020 15:19:26 -0000 Delivered-To: apmail-libcloud-commits@libcloud.apache.org Received: (qmail 89788 invoked by uid 99); 11 Jul 2020 15:19:26 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Jul 2020 15:19:26 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id C755D811D7; Sat, 11 Jul 2020 15:19:26 +0000 (UTC) Date: Sat, 11 Jul 2020 15:19:32 +0000 To: "commits@libcloud.apache.org" Subject: [libcloud] 06/08: Bail early if pricing data hasn't changed. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: tomaz@apache.org In-Reply-To: <159448076624.32575.4076433714300300194@gitbox.apache.org> References: <159448076624.32575.4076433714300300194@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: libcloud X-Git-Refname: refs/heads/trunk X-Git-Reftype: branch X-Git-Rev: 75887e8b5c885dc5f1b9b8d9a90ac6ee56aa7a89 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20200711151926.C755D811D7@gitbox.apache.org> 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 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)