summaryrefslogtreecommitdiff
path: root/ci
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2020-12-06 19:11:21 -0500
committerNed Batchelder <ned@nedbatchelder.com>2020-12-07 21:09:39 -0500
commit29e3241b79283148ace02fdfa310a99c837ffbf0 (patch)
tree6d3248b9935b32162f9a52d2addb58976b748c3e /ci
parent215996bfada5e2ceef04260236ce1de2f280d73f (diff)
downloadpython-coveragepy-git-29e3241b79283148ace02fdfa310a99c837ffbf0.tar.gz
Add time-created info to download_gha_artifacts.py
Diffstat (limited to 'ci')
-rw-r--r--ci/download_gha_artifacts.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/ci/download_gha_artifacts.py b/ci/download_gha_artifacts.py
index 9580dced..27da289b 100644
--- a/ci/download_gha_artifacts.py
+++ b/ci/download_gha_artifacts.py
@@ -3,8 +3,10 @@
"""Use the GitHub API to download built artifacts."""
+import datetime
import os
import os.path
+import time
import zipfile
import requests
@@ -25,6 +27,14 @@ def unpack_zipfile(filename):
print(f" extracting {name}")
z.extract(name)
+def utc2local(timestring):
+ dt = datetime.datetime
+ utc = dt.fromisoformat(timestring.rstrip("Z"))
+ epoch = time.mktime(utc.timetuple())
+ offset = dt.fromtimestamp(epoch) - dt.utcfromtimestamp(epoch)
+ local = utc + offset
+ return local.strftime("%Y-%m-%d %H:%M:%S")
+
dest = "dist"
repo_owner = "nedbat/coveragepy"
temp_zip = "artifacts.zip"
@@ -35,6 +45,8 @@ os.chdir(dest)
r = requests.get(f"https://api.github.com/repos/{repo_owner}/actions/artifacts")
latest = max(r.json()["artifacts"], key=lambda a: a["created_at"])
+
+print(f"Artifacts created at {utc2local(latest['created_at'])}")
download_url(latest["archive_download_url"], temp_zip)
unpack_zipfile(temp_zip)
os.remove(temp_zip)