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 2022/09/08 11:07:09 UTC

[libcloud] 05/07: Print file mtime when using existing cached pricing file.

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 23034670cd32fff78eb2114e2fc1a5164c252933
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Thu Sep 8 12:54:29 2022 +0200

    Print file mtime when using existing cached pricing file.
---
 contrib/scrape-ec2-prices.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/contrib/scrape-ec2-prices.py b/contrib/scrape-ec2-prices.py
index cb482c034..c1828ad57 100755
--- a/contrib/scrape-ec2-prices.py
+++ b/contrib/scrape-ec2-prices.py
@@ -57,7 +57,12 @@ INSTANCE_SIZES = [
 
 def download_json():
     if os.path.isfile(FILEPATH):
-        print("Using data from existing cached file %s" % (FILEPATH))
+        mtime_str = time.strftime(
+            "%Y-%m-%d %H:%I:%S UTC", time.gmtime(os.path.getmtime(FILEPATH))
+        )
+        print(
+            "Using data from existing cached file %s (mtime=%s)" % (FILEPATH, mtime_str)
+        )
         return open(FILEPATH, "r"), True
 
     def remove_partial_cached_file():
@@ -92,7 +97,10 @@ def get_json():
     if not os.path.isfile(FILEPATH):
         return download_json()[0], False
 
-    print("Using data from existing cached file %s" % (FILEPATH))
+    mtime_str = time.strftime(
+        "%Y-%m-%d %H:%I:%S UTC", time.gmtime(os.path.getmtime(FILEPATH))
+    )
+    print("Using data from existing cached file %s (mtime=%s)" % (FILEPATH, mtime_str))
     return FILEPATH, True