本文整理汇总了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)
示例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)
示例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')
示例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
示例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
示例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
示例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))
示例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()
示例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
示例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...")
示例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"