def get_travis_data():
 import os
 jobid = os.environ.get('TRAVIS_JOB_ID')
 if (not jobid):
  return (None, None)
 with closing(urlopen('https://api.travis-ci.org/workers/')) as resp:
  workers = json.loads(resp.read())
 host = njobs = None
 for item in workers:
  host = item.get('host')
  id = ((item.get('payload') or {}).get('job') or {}).get('id')
  if (id and (str(id) == str(jobid))):
   break
  if host:
   njobs = len([x for x in workers if ((host in x['host']) and x['payload'])])
 return (host, njobs)

def get_travis_data ( ) : import os jobid = os . environ . get ( 'TRAVIS_JOB_ID' ) if ( not jobid ) : return ( None , None ) with closing ( urlopen ( 'https://api.travis-ci.org/workers/' ) ) as resp : workers = json . loads ( resp . read ( ) ) host = njobs = None for item in workers : host = item . get ( 'host' ) id = ( ( item . get ( 'payload' ) or { } ) . get ( 'job' ) or { } ) . get ( 'id' ) if ( id and ( str ( id ) == str ( jobid ) ) ) : break if host : njobs = len ( [ x for x in workers if ( ( host in x [ 'host' ] ) and x [ 'payload' ] ) ] ) return ( host , njobs )
figure out what worker were running on .