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


Python github.GitHub方法代码示例

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


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

示例1: update

# 需要导入模块: import github [as 别名]
# 或者: from github import GitHub [as 别名]
def update(send_email=True):
    # Update the DB with the GitHub repo data
    for repo in config.github_repos:
        github.update_library_data(config.github_user, repo)

    # Update the DB with Package Manager data
    pm.update_package_manager_data(config.package_manager_urls)

    # Export tables as CSV if config file indicates to do so
    if config.export_github:
        db.export_table_to_csv(GitHubData)
    if config['export_tables']['PackageManagers']:
        db.export_table_to_csv(PackageManagerData)

    if not send_email:
        return

    # Send an email update
    sg.send_email(config.to_email,
                  config.from_email,
                  config.email_subject,
                  config.email_body) 
开发者ID:sendgrid,项目名称:open-source-library-data-collector,代码行数:24,代码来源:app.py

示例2: cron

# 需要导入模块: import github [as 别名]
# 或者: from github import GitHub [as 别名]
def cron(testing=False):
    """Script to run from cron for Sampleplatform."""
    from mod_ci.controllers import start_platforms, kvm_processor, TestPlatform
    from flask import current_app
    from run import config, log
    from database import create_session
    from github import GitHub

    log.info('Run the cron for kicking off CI platform(s).')
    # Create session
    db = create_session(config['DATABASE_URI'])
    gh = GitHub(access_token=config['GITHUB_TOKEN'])
    repository = gh.repos(config['GITHUB_OWNER'])(config['GITHUB_REPOSITORY'])

    if testing is True:
        kvm_processor(current_app._get_current_object(), db, config.get('KVM_LINUX_NAME', ''), TestPlatform.linux,
                      repository, None)
    else:
        start_platforms(db, repository) 
开发者ID:CCExtractor,项目名称:sample-platform,代码行数:21,代码来源:cron.py

示例3: inform_mailing_list

# 需要导入模块: import github [as 别名]
# 或者: from github import GitHub [as 别名]
def inform_mailing_list(mailer, id, title, author, body) -> None:
    """
    Send mail to subscribed users when a issue is opened via the Webhook.

    :param mailer: The mailer instance
    :type mailer: Mailer
    :param id: ID of the Issue Opened
    :type id: int
    :param title: Title of the Created Issue
    :type title: str
    :param author: The Authors Username of the Issue
    :type author: str
    :param body: The Content of the Issue
    :type body: str
    """
    from run import get_github_issue_link

    subject = f"GitHub Issue #{id}"
    url = get_github_issue_link(id)
    if not mailer.send_simple_message({
        "to": "ccextractor-dev@googlegroups.com",
        "subject": subject,
        "html": get_html_issue_body(title=title, author=author, body=body, issue_number=id, url=url)
    }):
        g.log.error('failed to send issue to mailing list') 
开发者ID:CCExtractor,项目名称:sample-platform,代码行数:27,代码来源:controllers.py

示例4: authenticate

# 需要导入模块: import github [as 别名]
# 或者: from github import GitHub [as 别名]
def authenticate(self):
        """
            (class) -> boolean

            Passing throught authentication and verifying if the right credentials were given.
        """

        if self.personal_access_token is not None:
            self.gh = github.GitHub(access_token = self.personal_access_token)
        else:
            self.gh = github.GitHub(
                        self.consumer_key,
                        self.consumer_secret,
                        self.access_token,
                        self.access_secret)
        try:
            
            some_get = self.gh.users(self.user_name).get()
            print json.dumps(some_get, sort_keys=True, indent=4, separators=(',', ': '))
            return True
        except Exception, ex:
            print '[e] exception {}'.format(str(ex))
            return False 
开发者ID:vdmitriyev,项目名称:services-to-wordcloud,代码行数:25,代码来源:github_commits.py

示例5: mergeCloneData

# 需要导入模块: import github [as 别名]
# 或者: from github import GitHub [as 别名]
def mergeCloneData(cloneStats, rid):
    # convert traffic data into SQL values
    data=""
    for cday in cloneStats['clones']:
        data+="("+str(rid)+",'"+cday['timestamp'][:10]+"',"+str(cday['count'])+","+str(cday['uniques'])+"),"
    mergeStatement=mergeClones1+data[:-1]+mergeClones2
    # execute MERGE statement
    res=ibm_db.exec_immediate(conn,mergeStatement)


# Overall flow:
# - loop over users
#   - log in to GitHub as that current user
#   - retrieve repos for that current user, loop the repos
#     - for each repo fetch stats
#     - merge traffic data into table
#  update last run info 
开发者ID:IBM-Cloud,项目名称:github-traffic-stats,代码行数:19,代码来源:__main__.py

示例6: get_contributors

# 需要导入模块: import github [as 别名]
# 或者: from github import GitHub [as 别名]
def get_contributors(full_name):
    print("Getting GitHub repository `{}`".format(full_name))
    response = yield from gh_async.get_contributors(*full_name.split("/"))
    json = yield from response.json()
    print("response for {}: {}".format(full_name, json))
    return json 
开发者ID:prkumar,项目名称:uplink,代码行数:8,代码来源:asyncio_example.py

示例7: get_contributors

# 需要导入模块: import github [as 别名]
# 或者: from github import GitHub [as 别名]
def get_contributors(full_name):
    print("Getting GitHub repository `{}`".format(full_name))
    response = yield gh_async.get_contributors(*full_name.split("/"))
    json = response.json()
    print("response for {}: {}".format(full_name, json)) 
开发者ID:prkumar,项目名称:uplink,代码行数:7,代码来源:twisted_example.py

示例8: setUp

# 需要导入模块: import github [as 别名]
# 或者: from github import GitHub [as 别名]
def setUp(self):
        if os.environ.get('TRAVIS') is None:
            self.github = GitHub()
            self.db = DBConnector()
            self.config = Config() 
开发者ID:sendgrid,项目名称:open-source-library-data-collector,代码行数:7,代码来源:test.py

示例9: get_commits

# 需要导入模块: import github [as 别名]
# 或者: from github import GitHub [as 别名]
def get_commits(self):
        """
            (class) -> None

            Getting commits of the particular repository of the GitHub.
        """

        counter = 0
        page = 1

        # one exta requrest to understand math pages commits per page
        commits = self.gh.repos(self.user_name)(self.repository_name).commits.get(author = self.user_name, page = page)
        max_commits_per_page = len(commits)

        while True:
            commits = self.gh.repos(self.user_name)(self.repository_name).commits.get(author = self.user_name, page = page)
            for index in range(len(commits)):
                 commit_message = self.__get_replaced(commits[index]['commit'])
                 commit_date = self.__get_date(commits[index]['commit'])
                 self.df.loc[counter,'githubCommitMessage'] = commit_message
                 self.df.loc[counter,'timestamp'] = commit_date
                 counter += 1

            if max_commits_per_page == len(commits):
                page+=1
            else:
                break 
开发者ID:vdmitriyev,项目名称:services-to-wordcloud,代码行数:29,代码来源:github_commits.py

示例10: queue_test

# 需要导入模块: import github [as 别名]
# 或者: from github import GitHub [as 别名]
def queue_test(db, gh_commit, commit, test_type, branch="master", pr_nr=0) -> None:
    """
    Store test details into Test model for each platform, and post the status to GitHub.

    :param db: Database connection.
    :type db: sqlalchemy.orm.scoped_session
    :param gh_commit: The GitHub API call for the commit. Can be None
    :type gh_commit: Any
    :param commit: The commit hash.
    :type commit: str
    :param test_type: The type of test
    :type test_type: TestType
    :param branch: Branch name
    :type branch: str
    :param pr_nr: Pull Request number, if applicable.
    :type pr_nr: int
    :return: Nothing
    :rtype: None
    """
    from run import log

    fork_url = f"%/{g.github['repository_owner']}/{g.github['repository']}.git"
    fork = Fork.query.filter(Fork.github.like(fork_url)).first()

    if test_type == TestType.pull_request:
        log.debug('pull request test type detected')
        branch = "pull_request"

    linux_test = Test(TestPlatform.linux, test_type, fork.id, branch, commit, pr_nr)
    db.add(linux_test)
    windows_test = Test(TestPlatform.windows, test_type, fork.id, branch, commit, pr_nr)
    db.add(windows_test)
    db.commit()
    add_customized_regression_tests(linux_test.id)
    add_customized_regression_tests(windows_test.id)

    if gh_commit is not None:
        status_entries = {
            linux_test.platform.value: linux_test.id,
            windows_test.platform.value: windows_test.id
        }
        for platform_name, test_id in status_entries.items():
            try:
                gh_commit.post(
                    state=Status.PENDING,
                    description="Tests queued",
                    context=f"CI - {platform_name}",
                    target_url=url_for('test.by_id', test_id=test_id, _external=True)
                )
            except ApiError as a:
                log.critical(f'Could not post to GitHub! Response: {a.response}')

    log.debug("Created tests, waiting for cron...") 
开发者ID:CCExtractor,项目名称:sample-platform,代码行数:55,代码来源:controllers.py

示例11: progress_reporter

# 需要导入模块: import github [as 别名]
# 或者: from github import GitHub [as 别名]
def progress_reporter(test_id, token):
    """
    Handle the progress of a certain test after validating the token. If necessary, update the status on GitHub.

    :param test_id: The id of the test to update.
    :type test_id: int
    :param token: The token to check the validity of the request.
    :type token: str
    :return: Nothing.
    :rtype: None
    """
    from run import config, log

    test = Test.query.filter(Test.id == test_id).first()
    if test is not None and test.token == token:
        repo_folder = config.get('SAMPLE_REPOSITORY', '')

        if 'type' in request.form:
            if request.form['type'] == 'progress':
                log.info('[PROGRESS_REPORTER] Progress reported')
                if not progress_type_request(log, test, test_id, request):
                    return "FAIL"

            elif request.form['type'] == 'equality':
                log.info('[PROGRESS_REPORTER] Equality reported')
                equality_type_request(log, test_id, test, request)

            elif request.form['type'] == 'logupload':
                log.info('[PROGRESS_REPORTER] Log upload')
                if not upload_log_type_request(log, test_id, repo_folder, test, request):
                    return "EMPTY"

            elif request.form['type'] == 'upload':
                log.info('[PROGRESS_REPORTER] File upload')
                if not upload_type_request(log, test_id, repo_folder, test, request):
                    return "EMPTY"

            elif request.form['type'] == 'finish':
                log.info('[PROGRESS_REPORTER] Test finished')
                finish_type_request(log, test_id, test, request)
            else:
                return "FAIL"

            return "OK"

    return "FAIL" 
开发者ID:CCExtractor,项目名称:sample-platform,代码行数:48,代码来源:controllers.py


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