code: def enable_travis(token, slug, log):
      
  
      # Done with github directly. Login to travis
  
      travis = TravisPy.github_auth(token, uri='https://api.travis-ci.org')
      user = travis.user()
      log.info('Travis user: %s', user.name)
  
      # Ask travis to sync with github, try to fetch created repo with exponentially decaying time.
  
      last_sync = user.synced_at
      log.info('syncing Travis with Github, this can take a while...')
      repo = travis._session.post(travis._session.uri+'/users/sync')
      for i in range(10):
          try:
              sleep((1.5)**i)
              repo = travis.repo(slug)
              if travis.user().synced_at == last_sync:
                  raise ValueError('synced not really done, travis.repo() can be a duplicate')
              log.info('\nsyncing done')
              break
          # TODO: find the right exception here
          except Exception:
              pass
      ## todo , warn if not found
  
  
      #  Enable travis hook for this repository
  
      log.info('Enabling Travis-CI hook for this repository')
      resp = travis._session.put(travis._session.uri+"/hooks/",
                          json={
                              "hook": {
                                  "id": repo.id ,
                                  "active": True
                              }
                          },
                        )
      if resp.json()['result'] is True:
          log.info('Travis hook for this repository is now enabled.')
          log.info('Continuous integration test should be triggered every time you push code to github')
      else:
          log.info("I was not able to set up Travis hooks... something went wrong.")
  
      return user
docs: Enable Travis automatically for the given repo.
  
      this need to have access to the GitHub token.