• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python travispy.TravisPy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中travispy.TravisPy的典型用法代码示例。如果您正苦于以下问题:Python TravisPy类的具体用法?Python TravisPy怎么用?Python TravisPy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TravisPy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: old_logic

def old_logic(gh_token):
	t = TravisPy.github_auth(gh_token)
	user = t.user()
	repos = t.repos(member=user.login)
	print "found", len(repos), "repositories:"
	for r in repos:
		print r.slug
	repo = t.repo('FITeagle/integration-test')

	branch_bin = t.branch(repo_id_or_slug=repo.slug,name='binary-only')
	branch_master = t.branch(repo_id_or_slug=repo.slug,name='master')

	print "bin:", branch_bin.repository_id, branch_bin.number
	print "master:", branch_master.repository_id, branch_master.number

	builds_master = t.builds(repository_id=branch_master.repository_id,number=branch_master.number)
	builds_bin = t.builds(repository_id=branch_bin.repository_id,number=branch_bin.number)

	print "Branch >>binary-only<< has", len(builds_bin), "Builds"
	print "Branch >>master<< has", len(builds_master), "Builds"
	build_master=builds_master[0]
	build_bin=builds_bin[0]
开发者ID:FITeagle,项目名称:integration-test,代码行数:22,代码来源:trigger_travis.py


示例17: main

def main(username):
    github_access_token = vault.get_key('github_access_token')
    if github_access_token != None:
        # Use the username variable to do some stuff and return the data
        token = TravisPy.github_auth(github_access_token)
        q=urllib2.urlopen("https://api.travis-ci.org/repos/%s" % username)
        jsondata=json.loads(q.read())
        details=[]

        if jsondata:
            for data in jsondata:
                builds=token.builds(slug=data["slug"])
                for bd in builds:
                    bid=token.build(bd.id)
                    details.append((bid.commit.author_name,bid.commit.author_email))
                    details.append((bid.commit.committer_name,bid.commit.committer_email))
        details=list(set(details))
        return details
    else:
        return [ colored(style.BOLD +
                         '[!] Error: No github token for Travis CI found. Skipping' +
                         style.END, 'red') ]
开发者ID:Chan9390,项目名称:datasploit,代码行数:22,代码来源:username_traviscidetails.py


示例18: TravisPy

	'grosser/parallel',
	'wvanbergen/request-log-analyzer',
	'troessner/reek',
	'ruboto/ruboto',
	'markevans/dragonfly',
	'grails/grails-core',
	'grosser/parallel_tests',
	'mongodb/mongo-python-driver',
	'scambra/devise_invitable',
	'dennisreimann/ioctocat',
	'cython/cython',
	'mongomapper/mongomapper',
	'publify/publify'	
]

t = TravisPy()

builds_result = []

for project in projects:

	builds = t.builds(slug=project, event_type='pull_request')

	labels = ['project', 'pull_number', 'started_at', 'finished_at', 'branch', 'build_status']
	count = 1

	print ' {:_<6} {:_<26} {:_^12} {:_^8} {:_^8} '.format('','','','','')
	print '|{:^6}|{:^26}|{:^12}|{:^8}|{:^8}|'.format('#','project','pull_number', 'branch', 'status')

	while builds:
		for build in builds:
开发者ID:joaohelis,项目名称:pulls_analysis,代码行数:31,代码来源:travis_miner.py


示例19: test_github_auth

 def test_github_auth(self):
     with pytest.raises(TravisError) as exception_info:
         TravisPy.github_auth('invalid')
     assert str(exception_info.value) == '[403] not a Travis user'
开发者ID:jayvdb,项目名称:travispy,代码行数:4,代码来源:test_travispy.py


示例20: setup_method

 def setup_method(self, method):
     self._travis = TravisPy.github_auth(os.environ['TRAVISPY_GITHUB_ACCESS_TOKEN'])
开发者ID:jayvdb,项目名称:travispy,代码行数:2,代码来源:test_travispy.py



注:本文中的travispy.TravisPy类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tree.loadTrees函数代码示例发布时间:2022-05-27
下一篇:
Python grammar.Parser类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap