@@ -26,9 +26,7 @@ def make_auth_headers():
2626 with open (path ) as f :
2727 token = f .read ().strip ()
2828
29- headers = {
30- "Authorization" : "Bearer {}" .format (token ),
31- }
29+ headers = {"Authorization" : "Bearer {}" .format (token )}
3230 return headers
3331
3432
@@ -37,14 +35,20 @@ def download_latest_artifacts(account_project, build_id):
3735 if build_id is None :
3836 url = "https://ci.appveyor.com/api/projects/{}" .format (account_project )
3937 else :
40- url = "https://ci.appveyor.com/api/projects/{}/build/{}" .format (account_project , build_id )
38+ url = "https://ci.appveyor.com/api/projects/{}/build/{}" .format (
39+ account_project , build_id
40+ )
4141 build = requests .get (url , headers = make_auth_headers ()).json ()
4242 jobs = build ["build" ]["jobs" ]
43- print (u"Build {0[build][version]}, {1} jobs: {0[build][message]}" .format (build , len (jobs )))
43+ print (
44+ "Build {0[build][version]}, {1} jobs: {0[build][message]}" .format (
45+ build , len (jobs )
46+ )
47+ )
4448
4549 for job in jobs :
4650 name = job ["name" ]
47- print (u " {0}: {1[status]}, {1[artifactsCount]} artifacts" .format (name , job ))
51+ print (" {0}: {1[status]}, {1[artifactsCount]} artifacts" .format (name , job ))
4852
4953 url = "https://ci.appveyor.com/api/buildjobs/{}/artifacts" .format (job ["jobId" ])
5054 response = requests .get (url , headers = make_auth_headers ())
@@ -53,9 +57,11 @@ def download_latest_artifacts(account_project, build_id):
5357 for artifact in artifacts :
5458 is_zip = artifact ["type" ] == "Zip"
5559 filename = artifact ["fileName" ]
56- print (u " {0}, {1} bytes" .format (filename , artifact ["size" ]))
60+ print (" {0}, {1} bytes" .format (filename , artifact ["size" ]))
5761
58- url = "https://ci.appveyor.com/api/buildjobs/{}/artifacts/{}" .format (job ["jobId" ], filename )
62+ url = "https://ci.appveyor.com/api/buildjobs/{}/artifacts/{}" .format (
63+ job ["jobId" ], filename
64+ )
5965 download_url (url , filename , make_auth_headers ())
6066
6167 if is_zip :
@@ -79,28 +85,29 @@ def download_url(url, filename, headers):
7985 for chunk in response .iter_content (16 * 1024 ):
8086 f .write (chunk )
8187 else :
82- print (u " Error downloading {}: {}" .format (url , response ))
88+ print (" Error downloading {}: {}" .format (url , response ))
8389
8490
8591def unpack_zipfile (filename ):
8692 """Unpack a zipfile, using the names in the zip."""
8793 with open (filename , "rb" ) as fzip :
8894 z = zipfile .ZipFile (fzip )
8995 for name in z .namelist ():
90- print (u " extracting {}" .format (name ))
96+ print (" extracting {}" .format (name ))
9197 ensure_dirs (name )
9298 z .extract (name )
9399
94100
95101parser = argparse .ArgumentParser (description = "Download artifacts from AppVeyor." )
96- parser .add_argument ("--id" ,
97- metavar = "PROJECT_ID" ,
98- default = "python-mario/python-mario" ,
99- help = "Project ID in AppVeyor." )
100- parser .add_argument ("build" ,
101- nargs = "?" ,
102- metavar = "BUILD_ID" ,
103- help = "Build ID in AppVeyor. Eg: master-123" )
102+ parser .add_argument (
103+ "--id" ,
104+ metavar = "PROJECT_ID" ,
105+ default = "python-mario/python-mario" ,
106+ help = "Project ID in AppVeyor." ,
107+ )
108+ parser .add_argument (
109+ "build" , nargs = "?" , metavar = "BUILD_ID" , help = "Build ID in AppVeyor. Eg: master-123"
110+ )
104111
105112if __name__ == "__main__" :
106113 # import logging
0 commit comments