当前位置: 首页>>代码示例>>Python>>正文


Python TravisPy.github_auth方法代码示例

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


在下文中一共展示了TravisPy.github_auth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: checktravis

# 需要导入模块: from travispy import TravisPy [as 别名]
# 或者: from travispy.TravisPy import github_auth [as 别名]
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,代码行数:27,代码来源:app.py

示例2: __init__

# 需要导入模块: from travispy import TravisPy [as 别名]
# 或者: from travispy.TravisPy import github_auth [as 别名]
    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,代码行数:27,代码来源:gitenberg_utils.py

示例3: get_repo_slug

# 需要导入模块: from travispy import TravisPy [as 别名]
# 或者: from travispy.TravisPy import github_auth [as 别名]
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,代码行数:9,代码来源:pylint_server.py

示例4: __init__

# 需要导入模块: from travispy import TravisPy [as 别名]
# 或者: from travispy.TravisPy import github_auth [as 别名]
 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,代码行数:10,代码来源:release_utils.py

示例5: loadtravis

# 需要导入模块: from travispy import TravisPy [as 别名]
# 或者: from travispy.TravisPy import github_auth [as 别名]
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,代码行数:12,代码来源:app.py

示例6: loadapis

# 需要导入模块: from travispy import TravisPy [as 别名]
# 或者: from travispy.TravisPy import github_auth [as 别名]
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,代码行数:13,代码来源:app.py

示例7: travis

# 需要导入模块: from travispy import TravisPy [as 别名]
# 或者: from travispy.TravisPy import github_auth [as 别名]
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,代码行数:13,代码来源:test_authenticated.py

示例8: enable_travis

# 需要导入模块: from travispy import TravisPy [as 别名]
# 或者: from travispy.TravisPy import github_auth [as 别名]
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,代码行数:55,代码来源:love.py

示例9: before_request

# 需要导入模块: from travispy import TravisPy [as 别名]
# 或者: from travispy.TravisPy import github_auth [as 别名]
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,代码行数:14,代码来源:tronci.py

示例10: travis

# 需要导入模块: from travispy import TravisPy [as 别名]
# 或者: from travispy.TravisPy import github_auth [as 别名]
 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,代码行数:19,代码来源:plugin.py

示例11: checkAuthorization

# 需要导入模块: from travispy import TravisPy [as 别名]
# 或者: from travispy.TravisPy import github_auth [as 别名]
 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,代码行数:20,代码来源:plugin.py

示例12: setup_platform

# 需要导入模块: from travispy import TravisPy [as 别名]
# 或者: from travispy.TravisPy import github_auth [as 别名]
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,代码行数:42,代码来源:travisci.py

示例13: old_logic

# 需要导入模块: from travispy import TravisPy [as 别名]
# 或者: from travispy.TravisPy import github_auth [as 别名]
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,代码行数:24,代码来源:trigger_travis.py

示例14: main

# 需要导入模块: from travispy import TravisPy [as 别名]
# 或者: from travispy.TravisPy import github_auth [as 别名]
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,代码行数:24,代码来源:username_traviscidetails.py

示例15: len

# 需要导入模块: from travispy import TravisPy [as 别名]
# 或者: from travispy.TravisPy import github_auth [as 别名]
    parser.add_argument('--username', type=str, default='',
                        help='Set name of the repository for automatic push')
    parser.add_argument('--token', type=str, default='',
                        help='Set token of the repository for automatic push')
    args = parser.parse_args()

    github_credentials = ''
    if len(args.username) > 0:
        github_credentials = args.username + ':' + args.token + '@'

    # Fork and clone the repository YangModles/yang
    reponse = requests.post('https://' + github_credentials + 'api.github.com/repos/YangModels/yang/forks')
    repo = repoutil.RepoUtil('https://github.com/' + args.username + '/yang.git')

    repo.clone()
    travis = TravisPy.github_auth(args.token)
    # Download all the latest yang modules out of http://www.claise.be/IETFYANGDraft.json and store them in tmp folder
    ietf_draft_json = load_json_from_url('http://www.claise.be/IETFYANGDraft.json')
    try:
        os.makedirs(repo.localdir + '/experimental/ietf-extracted-YANG-modules/')
    except OSError as e:
        # be happy if someone already created the path
        if e.errno != errno.EEXIST:
            raise
    for key in ietf_draft_json:
        yang_file = open(repo.localdir + '/experimental/ietf-extracted-YANG-modules/' + key, 'w+')
        yang_download_link = ietf_draft_json[key][2].split('href="')[1].split('">Download')[0]
        try:
            yang_raw = urllib2.urlopen(yang_download_link).read()
            yang_file.write(yang_raw)
        except:
开发者ID:mjethanandani,项目名称:yang,代码行数:33,代码来源:draftPull.py


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