Home | History | Annotate | Download | only in .travis
      1 import os
      2 import urllib2
      3 import json
      4 
      5 def request(url, data, token = None):
      6   req = urllib2.Request(url, data)
      7   req.add_header('User-Agent', 'MyClient/1.0.0')
      8   req.add_header('Accept', 'application/vnd.travis-ci.2+json')
      9   req.add_header('Content-Type', 'application/json; charset=UTF-8')
     10   if token:
     11     req.add_header('Travis-API-Version', '3')
     12     req.add_header('Authorization', 'token ' + travis_token)
     13   p = urllib2.urlopen(req)
     14   return json.loads(p.read())
     15 
     16 travis_token = request('https://api.travis-ci.org/auth/github', '{"github_token":"' + os.environ['GH_TOKEN'] + '"}')['access_token']
     17 print(request('https://api.travis-ci.org/repo/jacoco%2Fwww.eclemma.org/requests', '{ "request": { "branch": "master", "message": "New JaCoCo snapshot" } }', travis_token))
     18