当前位置: 首页>>代码示例>>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;未经允许,请勿转载。