def download_latest_artifacts(account_project):
 build = get_project_build(account_project)
 jobs = build['build']['jobs']
 print 'Build {0[build][version]}, {1} jobs: {0[build][message]}'.format(build, len(jobs))
 for job in jobs:
  name = job['name'].partition(':')[2].split(',')[0].strip()
  print '  {0}: {1[status]}, {1[artifactsCount]} artifacts'.format(name, job)
  url = make_url('/buildjobs/{jobid}/artifacts', jobid=job['jobId'])
  response = requests.get(url, headers=make_auth_headers())
  artifacts = response.json()
  for artifact in artifacts:
   is_zip = (artifact['type'] == 'Zip')
   filename = artifact['fileName']
   print '    {0}, {1} bytes'.format(filename, artifact['size'])
   url = make_url('/buildjobs/{jobid}/artifacts/{filename}', jobid=job['jobId'], filename=filename)
   download_url(url, filename, make_auth_headers())
   if is_zip:
    unpack_zipfile(filename)
    os.remove(filename)

def download_latest_artifacts ( account_project ) : build = get_project_build ( account_project ) jobs = build [ 'build' ] [ 'jobs' ] print 'Build {0[build][version]}, {1} jobs: {0[build][message]}' . format ( build , len ( jobs ) ) for job in jobs : name = job [ 'name' ] . partition ( ':' ) [ 2 ] . split ( ',' ) [ 0 ] . strip ( ) print '  {0}: {1[status]}, {1[artifactsCount]} artifacts' . format ( name , job ) url = make_url ( '/buildjobs/{jobid}/artifacts' , jobid = job [ 'jobId' ] ) response = requests . get ( url , headers = make_auth_headers ( ) ) artifacts = response . json ( ) for artifact in artifacts : is_zip = ( artifact [ 'type' ] == 'Zip' ) filename = artifact [ 'fileName' ] print '    {0}, {1} bytes' . format ( filename , artifact [ 'size' ] ) url = make_url ( '/buildjobs/{jobid}/artifacts/{filename}' , jobid = job [ 'jobId' ] , filename = filename ) download_url ( url , filename , make_auth_headers ( ) ) if is_zip : unpack_zipfile ( filename ) os . remove ( filename )
download all the artifacts from the latest build .