當前位置: 首頁>>代碼示例>>Python>>正文


Python travispy.TravisPy類代碼示例

本文整理匯總了Python中travispy.TravisPy的典型用法代碼示例。如果您正苦於以下問題:Python TravisPy類的具體用法?Python TravisPy怎麽用?Python TravisPy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TravisPy類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

    def __init__(self, username, password, repo_name, repo_owner,
               update_travis_commit_msg,
               tag_commit_message, github_token=None, access_token=None, repo_token=None):
        
        super(GitenbergTravisJob, self).__init__(username, password, repo_name, repo_owner,
               update_travis_commit_msg,
               tag_commit_message)
        
        self.username = username
        self.password = password
        
        self._github_token = github_token
        self._access_token = access_token

        # if access_token is given, use it
        if access_token is not None:
            self.travis = TravisPy(access_token)
        else:
            self.travis = TravisPy.github_auth(self.github_token())

        self._repo_token = repo_token    
        self._travis_repo_public_key = None

        if self.gh_repo is not None:
            self.travis_repo = self.travis.repo(self.repo_slug)
開發者ID:rdhyee,項目名稱:nypl50,代碼行數:25,代碼來源:gitenberg_utils.py

示例2: get_travis_session

def get_travis_session(username, travis_ci_token, github_token):
  travis_session = TravisPy(token=travis_ci_token)
  try:
    travis_session.repo('some_repo')
  except TravisError:
    logger.error("Travis session expired for {}. Please manually generate it by doing:\n{}"
                 .format(username, TOKEN_INSTRUCTION.format(github_token)))
    exit(1)
  else:
    return travis_session
開發者ID:wisechengyi,項目名稱:TPlumber,代碼行數:10,代碼來源:exploit_travis.py

示例3: stop_all_builds

def stop_all_builds():
  for username, repo_name, github_token, travis_ci_token in CREDS:
    travis_session = TravisPy(token=travis_ci_token)
    builds = travis_session.builds(slug="{}/{}".format(username, repo_name))
    for build in builds:
      if not build.finished:
        success = build.cancel()
        url = calculate_build_url(username, repo_name, build)
        if success:
          logger.info("Build {} aborted".format(url))
        else:
          logger.error("Build {} fails to abort".format(url))
開發者ID:wisechengyi,項目名稱:TPlumber,代碼行數:12,代碼來源:exploit_travis.py

示例4: checktravis

def checktravis():
    try:
        if not session.get('fork') or not session.get('username'):
            return redirect(url_for('.github'))
        token = session['oauth_token']['access_token']
        travis = TravisPy.github_auth(token)
        username = session['username']
        user = travis.user()
        session['useremail'] = user.email
        repos = travis.repos(member=username)
        verified = False
        for repo in repos:
            if session['fork'].lower() == repo.slug.lower():
                verified = True
                break
        if verified:
            return redirect(url_for('.dashboard'))
        else:
            return redirect(url_for('.asktravis'))
    except:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        if 'Forbidden' in str(exc_value):
            session['username'] = None
            return redirect(url_for('.asktravis'))
        return 'checktravis: %s\n%s\n%s' % (exc_type, exc_value, exc_traceback)
開發者ID:btxlzh,項目名稱:peergrader,代碼行數:25,代碼來源:app.py

示例5: get_repo_slug

def get_repo_slug(travis_job_id):
    current_app.logger.info('getting repo slug, contacting travis...')
    travis = TravisPy.github_auth(os.environ["GITHUB_TOKEN"])
    job = travis.job(travis_job_id)
    repo = travis.repo(job.repository_id)
    current_app.logger.info('returning slug: '+repo.slug)
    return repo.slug
開發者ID:drivet,項目名稱:pylint-server,代碼行數:7,代碼來源:pylint_server.py

示例6: main

def main():
    travis = TravisPy()
    revision = check_output(["git", "rev-parse", "HEAD"]).strip()
    build_passed = False
    for build in travis.builds(slug="datawire/mdk"):
        if build.commit.sha == revision:
            if build.passed:
                build_passed = True
                break
            else:
                error("Found the build but it has not passed.\n    Build state: "
                      + build.state +
                      "\n    Build URL: https://travis-ci.org/datawire/mdk/builds/"
                      + str(build.id))

    if not build_passed:
        error("No matching build found on Travis CI.")
開發者ID:datawire,項目名稱:mdk,代碼行數:17,代碼來源:check-travis.py

示例7: __init__

 def __init__(self):
     token = os.environ.get('GITHUB_TOKEN', None)
     if token is None:
         raise SystemExit(
             'Please export your GitHub PAT as the "GITHUB_TOKEN" env var'
         )
     logger.debug('Connecting to TravisCI API...')
     self._travis = TravisPy.github_auth(token)
開發者ID:jantman,項目名稱:awslimitchecker,代碼行數:8,代碼來源:release_utils.py

示例8: loadtravis

def loadtravis():
    if not session.get('username') or not session.get('fork'):
        return None
    travis = None
    try:
        token = session['oauth_token']['access_token']
        travis = TravisPy.github_auth(token)
    except:
        return None
    return travis
開發者ID:peertest2,項目名稱:peergrader,代碼行數:10,代碼來源:app.py

示例9: travis

def travis(test_settings):
    token = test_settings.get('github_token', '')
    if not token.strip():
        pytest.skip('TRAVISPY_TEST_SETTINGS has no "github_token" value')

    try:
        result = TravisPy.github_auth(token)
    except TravisError:
        pytest.skip('Provided "github_token" value is invalid')

    return result
開發者ID:Usui22750,項目名稱:travispy,代碼行數:11,代碼來源:test_authenticated.py

示例10: loadapis

def loadapis():
    if not session.get('username') or not session.get('fork'):
        return None, None
    token = session['oauth_token']['access_token']
    github, travis = None, None
    try:
        github = Github(token)
        travis = TravisPy.github_auth(token)
    except:
        return None, None
    return github, travis
開發者ID:btxlzh,項目名稱:peergrader,代碼行數:11,代碼來源:app.py

示例11: enable_travis

def enable_travis(token, slug, log):
    """
    Enable Travis automatically for the given repo.

    this need to have access to the GitHub token.
    """

    # Done with github directly. Login to travis

    travis = TravisPy.github_auth(token, uri='https://api.travis-ci.org')
    user = travis.user()
    log.info('============= Configuring Travis.... ===========')
    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')
    import time
    for i in range(10):
        try:
            time.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.")

    log.info('========== Done configuring Travis.... =========')
    return repo, user
開發者ID:takluyver,項目名稱:Love,代碼行數:53,代碼來源:love.py

示例12: before_request

def before_request():
    from travispy import TravisPy
    from database import users

    g.user = None
    g.travispy = None

    if 'user_id' in session:
        g.user = users.find_one({'_id': ObjectId(session['user_id'])})

    if g.user is not None:
        g.travispy = TravisPy.github_auth(g.user['github_access_token'])
開發者ID:runt18,項目名稱:tron-ci,代碼行數:12,代碼來源:tronci.py

示例13: travis

 def travis(self, irc, msg, args, optrepo):
     """<repo>
     
     Run test on repo.
     """
     
     ght = self.registryValue('GitHubToken')
     t = TravisPy.github_auth(ght)
     user = t.user()
     irc.reply("user.login {0}".format(user.login))
     repos = t.repos(member=user.login)
     irc.reply("Member Repos: {0}".format(" | ".join([i.slug for i in repos])))
     repo = t.repo(optrepo)
     build = t.build(repo.last_build_id)
     irc.reply("BUILD: {0}".format(build))
     build.restart()
     irc.reply("BUILD RESTART: {0}".format(build))
開發者ID:reticulatingspline,項目名稱:Travis,代碼行數:17,代碼來源:plugin.py

示例14: checkAuthorization

 def checkAuthorization(self):
     """Check Travis Auth."""
     
     if self.travisAuth:
         pass
     else:
         GitHubToken = self.registryValue('GitHubToken')
         if not GitHubToken:
             self.log.info("ERROR :: You need to set GitHubToken in the config values for Travis.")
             self.travisAuth = False
         else:  # we have key.
             try:  # we're good. authed.
                 t = TravisPy.github_auth(GitHubToken)
                 self.travisAuth = t
                 self.log.info("I have successfully logged into Travis using your credentials.")
             except Exception as e:
                 self.log.info("ERROR :: I could not auth with Travis :: {0}".format(e))
                 self.travisAuth = False
開發者ID:reticulatingspline,項目名稱:Travis,代碼行數:18,代碼來源:plugin.py

示例15: setup_platform

def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the Travis CI sensor."""
    from travispy import TravisPy
    from travispy.errors import TravisError

    token = config.get(CONF_API_KEY)
    repositories = config.get(CONF_REPOSITORY)
    branch = config.get(CONF_BRANCH)

    try:
        travis = TravisPy.github_auth(token)
        user = travis.user()

    except TravisError as ex:
        _LOGGER.error("Unable to connect to Travis CI service: %s", str(ex))
        hass.components.persistent_notification.create(
            'Error: {}<br />'
            'You will need to restart hass after fixing.'
            ''.format(ex),
            title=NOTIFICATION_TITLE,
            notification_id=NOTIFICATION_ID)
        return False

    sensors = []

    # non specific repository selected, then show all associated
    if not repositories:
        all_repos = travis.repos(member=user.login)
        repositories = [repo.slug for repo in all_repos]

    for repo in repositories:
        if '/' not in repo:
            repo = "{0}/{1}".format(user.login, repo)

        for sensor_type in config.get(CONF_MONITORED_CONDITIONS):
            sensors.append(
                TravisCISensor(travis, repo, user, branch, sensor_type))

    add_devices(sensors, True)
    return True
開發者ID:BaptisteSim,項目名稱:home-assistant,代碼行數:40,代碼來源:travisci.py


注:本文中的travispy.TravisPy類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。