File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 3
3
4
4
"""Use the GitHub API to download built artifacts."""
5
5
6
+ import datetime
6
7
import os
7
8
import os .path
9
+ import time
8
10
import zipfile
9
11
10
12
import requests
@@ -25,6 +27,14 @@ def unpack_zipfile(filename):
25
27
print (f" extracting { name } " )
26
28
z .extract (name )
27
29
30
+ def utc2local (timestring ):
31
+ dt = datetime .datetime
32
+ utc = dt .fromisoformat (timestring .rstrip ("Z" ))
33
+ epoch = time .mktime (utc .timetuple ())
34
+ offset = dt .fromtimestamp (epoch ) - dt .utcfromtimestamp (epoch )
35
+ local = utc + offset
36
+ return local .strftime ("%Y-%m-%d %H:%M:%S" )
37
+
28
38
dest = "dist"
29
39
repo_owner = "nedbat/coveragepy"
30
40
temp_zip = "artifacts.zip"
@@ -35,6 +45,8 @@ def unpack_zipfile(filename):
35
45
36
46
r = requests .get (f"https://api.github.com/repos/{ repo_owner } /actions/artifacts" )
37
47
latest = max (r .json ()["artifacts" ], key = lambda a : a ["created_at" ])
48
+
49
+ print (f"Artifacts created at { utc2local (latest ['created_at' ])} " )
38
50
download_url (latest ["archive_download_url" ], temp_zip )
39
51
unpack_zipfile (temp_zip )
40
52
os .remove (temp_zip )
You can’t perform that action at this time.
0 commit comments