本文整理汇总了Python中github.GitHub.repos方法的典型用法代码示例。如果您正苦于以下问题:Python GitHub.repos方法的具体用法?Python GitHub.repos怎么用?Python GitHub.repos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.GitHub
的用法示例。
在下文中一共展示了GitHub.repos方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upload_to_github
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import repos [as 别名]
def upload_to_github(file_path, nwjs_version):
github = GitHub(auth_token())
releases = github.repos(GITHUB_REPO).releases.get()
release = create_or_get_release_draft(github, releases, nwjs_version)
params = {'name': os.path.basename(file_path) }
headers = {'Content-Type': 'application/zip'}
with open(file_path, 'rb') as f:
github.repos(GITHUB_REPO).releases(release['id']).assets.post(
params=params, headers=headers, data=f, verify=False)
示例2: get_issues_api
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import repos [as 别名]
def get_issues_api():
if app.config['REPORT_PARSING_ISSUES']:
access_token = app.config['GITHUB_ACCESS_TOKEN']
repo_owner = app.config['GITHUB_REPO_OWNER']
repo_name = app.config['GITHUB_REPO_NAME']
gh = GitHub(access_token=access_token)
return gh.repos(repo_owner)(repo_name).issues
else:
return None
示例3: cron
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import repos [as 别名]
def cron():
from mod_ci.controllers import start_platform
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'])
start_platform(db, repository)
示例4: get_comments
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import repos [as 别名]
def get_comments(owner, repo, user, csvfile):
gh = GitHub(access_token=GITHUB_ACCESS_TOKEN)
page = 1
writer = DictWriter(csvfile, fieldnames=CSV_FIELD_NAMES)
writer.writeheader()
while True:
print "Getting page {}".format(page)
new_comments = gh.repos(owner)(repo).pulls.comments.get(page=page)
if len(new_comments) == 0:
break
else:
page = page + 1
for comment in new_comments:
if comment['user']['login'] == user:
row = {
'message': comment['body'].encode('utf8'),
'url': comment['html_url'],
'username': comment['user']['login']
}
writer.writerow(row)
示例5: GitHub
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import repos [as 别名]
from github import GitHub
gh = GitHub()
user = gh.users('stevesun112').get()
#print( user )
commit = gh.repos('imsure', 'hello-antares').commits('083a8604a73dcb5eda83a5bdd6638a93cfa60045').get()
#print( commit[ 'html_url' ] )
search = gh.search.code.get(q="addClass in:file language:js repo:jquery/jquery")
#print( search )
search = gh.search.code.get(q="create_table in:file language:py repo:imsure/hello-antares")
#print( search[ 'items' ][0][ 'html_url' ] )
user = gh.users('AzNOAOTares').get()
print( user )
commit = gh.repos('AzNOAOTares', 'antares-docs').commits('ee22aff520fba4e69971c9ac86a383e0b2374bb6').get()
print( commit[ 'html_url' ] )
# search = gh.search.code.get(q="addClass in:file language:js repo:jquery/jquery")
#print( search )
search = gh.search.code.get(q="maketitle in:file language:tex repo:AzNOAOTares/antares-docs")
print( search[ 'items' ][0][ 'html_url' ] )
user = gh.users('AzNOAOTares').get()
print( user )
commit = gh.repos('AzNOAOTares', 'architecture').commits('93d4c7d2e6d6950dbeebff0de9c33941ecf3d109').get()
print( commit[ 'html_url' ] )
# search = gh.search.code.get(q="addClass in:file language:js repo:jquery/jquery")
#print( search )
#search = gh.search.code.get(q="maketitle in:file language:tex repo:AzNOAOTares/antares-docs")
#print( search[ 'items' ][0][ 'html_url' ] )
示例6: social_stats
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import repos [as 别名]
conn = sqlite3.connect(db_path)
# Connect to the database
c = conn.cursor()
# Create the SQLite3 table to store the info, if it's not already present
sql = ('CREATE TABLE IF NOT EXISTS social_stats (project TEXT, time_stamp TEXT, '
'watchers INTEGER, stars INTEGER, forks INTEGER, commits INTEGER, downloads INTEGER)')
c.execute(sql)
conn.commit()
# Loop through the projects in the config file
for project in config.sections():
# Extract the number of watchers, stars, and forks on GitHub
repo_data = gh.repos(project).get()
watchers = repo_data['subscribers_count']
stars = repo_data['stargazers_count']
forks = repo_data['forks_count']
# Count the # of commits in the last 24 hours
now = datetime.datetime.utcnow()
yesterday = now + datetime.timedelta(days=-1)
commits = gh.repos(project).commits.get(since=yesterday)
commits_count = len(commits)
# Count how many downloads have occurred (ever) for the project
# Note - For each project there is an outer loop of "releases" (eg v3.6.0), with an inner loop of "assets" inside
# each release (with each asset having it's own download counter). eg: an .exe and a .dmg might be two assets in
# the same v3.6.0 release. The .exe might have 10,000 downloads, and the .dmg might have 3,000.
download_counter = 0
示例7: GitHub
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import repos [as 别名]
from github import GitHub
gh = GitHub(username="bot-sunu", password="[email protected]#")
oh_issues = gh.repos(
"openhatch")("oh-mainline").issues.get(
state="all", labels="bugimporters", per_page=50)
total_issues = len(oh_issues)
for index, issue in enumerate(oh_issues):
print "Processing issue #%i of %i" % (index+1, total_issues)
title = issue.get("title")
body = issue.get("body")
assignee = issue["assignee"]["login"] if issue.get("assignee") else None
milestone = issue.get('milestone')
state = issue.get("state")
labels = [label['name'] for label in issue['labels']]
comment_count = issue.get("comments")
if comment_count > 0:
comments = gh.repos(
"openhatch")("oh-mainline").issues(issue["number"]).comments.get()
for comment in comments:
comment_body = comment.get("body")
creator = comment.get("user")["login"]
creation_time = comment.get("created_at")
text = "<hr/> **%s** commented at %s: <br/> %s" % (
creator, creation_time, comment_body)
示例8: ones
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import repos [as 别名]
class Processor:
"""
This class holds all the logic to process GitHub notifications and
comment on previous ones (to report a status, ...).
"""
_conn = None
def __init__(self, debug=False):
"""
Constructor for the Processor class.
:param debug: If set to True, the console will also log debug
messages.
:return:
"""
# Init GitHub with the configured access token
self.g = GitHub(access_token=Configuration.token)
self.debug = debug
loggers = LogConfiguration(self.debug)
self.logger = loggers.create_logger("Processor")
@staticmethod
def generate_random_string(
length=32, chars=string.ascii_uppercase + string.digits):
"""
Generates a random string with a given length and character set
:param length: The length of the random string. 32 by default.
:param chars: The characters that should be used. Uppercase + digits
by default.
:return: A randomly generated string of given length.
"""
return ''.join(
random.SystemRandom().choice(chars) for _ in range(length))
def run(self):
"""
Runs the script by fetching new notifications and running through
it, as well as reporting back for all the messages in the database
queue.
:return:
"""
self.logger.info("Start of bot")
# Create connection to the DB
self._conn = pymysql.connect(
host=Configuration.database_host,
user=Configuration.database_user,
passwd=Configuration.database_password,
db=Configuration.database_name,
charset='latin1',
cursorclass=pymysql.cursors.DictCursor)
self.logger.debug("Fetching notifications")
notifications = self.g.notifications.get()
if len(notifications) > 0:
self.logger.debug("We got {0} new notifications".format(
len(notifications)))
# Get valid forks
open_forks = self.get_forks()
# Run through notifications
for notification in notifications:
repo_name = notification.repository.full_name
self.logger.info("Got a notification in {0}".format(repo_name))
if repo_name in open_forks:
url = notification.subject.url
parts = url.split('/')
not_id = parts[-1]
not_type = notification.subject.type
repo_owner = notification.repository.owner.login
self.logger.info("Valid notification: {0} #{1}".format(
not_type, not_id))
self.logger.debug("Repository owned by: {0}".format(
repo_owner))
if not_type == "Issue":
self.logger.debug("Fetching issue")
issue = self.g.repos(repo_owner)(
Configuration.repo_name).issues(not_id).get()
comments = self.g.repos(repo_owner)(
Configuration.repo_name).issues(not_id).comments.get()
self.run_through_comments(
issue, comments, not_type, not_id, repo_owner,
open_forks[repo_name])
elif not_type == "PullRequest":
self.logger.debug("Fetching PR")
request = self.g.repos(repo_owner)(
Configuration.repo_name).pulls(not_id).get()
# For some reason, the comments for the PR are issues...
comments = self.g.repos(repo_owner)(
Configuration.repo_name).issues(not_id).comments.get()
self.run_through_comments(
request, comments, not_type, not_id, repo_owner,
open_forks[repo_name])
elif not_type == "Commit":
self.logger.debug("Fetching Commit")
commit = self.g.repos(repo_owner)(
Configuration.repo_name).commits(not_id).get()
comments = self.g.repos(repo_owner)(
Configuration.repo_name).commits(
#.........这里部分代码省略.........
示例9: print
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import repos [as 别名]
#import cgitb; cgitb.enable()
sys.path.insert(0, os.path.expanduser('~/site/python'))
import json
from pymongo import *
from github import GitHub
from secrets import github_username, github_password
print ("Content-Type: text/html; charset=utf-8")
print ("")
print("hello!!!")
gh = GitHub(username=github_username, password=github_password)
issuesdict = gh.repos("vgulaev")("trimet_it").issues.get(sort="created", filter="all")
#print(issuesdict[0].number)
def getnewissues(start_id):
client = MongoClient()
db = client['trimet_issues']
posts = db.issues
issues_in_db = posts.find().sort("number", direction = DESCENDING)
if db['issues'].count() > 0:
print(issues_in_db[0]["number"])
i_from = issues_in_db[0]["number"] + 1
else:
i_from = 1
示例10: index
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import repos [as 别名]
def index():
"""
Display a form to allow users to run tests.
User can enter commit or select the commit from their repo that are not more than 30 days old.
User can customized test based on selected regression tests and platforms.
Also Display list of customized tests started by user.
User will be redirected to the same page on submit.
"""
fork_test_form = TestForkForm(request.form)
username = fetch_username_from_token()
commit_options = False
if username is not None:
gh = GitHub(access_token=g.github['bot_token'])
repository = gh.repos(username)(g.github['repository'])
# Only commits since last month
last_month = datetime.now() - timedelta(days=30)
commit_since = last_month.isoformat() + 'Z'
commits = repository.commits().get(since=commit_since)
commit_arr = []
for commit in commits:
commit_url = commit['html_url']
commit_sha = commit['sha']
commit_option = (
'<a href="{url}">{sha}</a>').format(url=commit_url, sha=commit_sha)
commit_arr.append((commit_sha, commit_option))
# If there are commits present, display it on webpage
if len(commit_arr) > 0:
fork_test_form.commit_select.choices = commit_arr
commit_options = True
fork_test_form.regression_test.choices = [(regression_test.id, regression_test)
for regression_test in RegressionTest.query.all()]
if fork_test_form.add.data and fork_test_form.validate_on_submit():
import requests
regression_tests = fork_test_form.regression_test.data
commit_hash = fork_test_form.commit_hash.data
repo = g.github['repository']
platforms = fork_test_form.platform.data
api_url = ('https://api.github.com/repos/{user}/{repo}/commits/{hash}').format(
user=username, repo=repo, hash=commit_hash
)
# Show error if github fails to recognize commit
response = requests.get(api_url)
if response.status_code == 500:
fork_test_form.commit_hash.errors.append('Error contacting Github')
elif response.status_code != 200:
fork_test_form.commit_hash.errors.append('Wrong Commit Hash')
else:
add_test_to_kvm(username, commit_hash, platforms, regression_tests)
return redirect(url_for('custom.index'))
populated_categories = g.db.query(regressionTestLinkTable.c.category_id).subquery()
categories = Category.query.filter(Category.id.in_(populated_categories)).order_by(Category.name.asc()).all()
tests = Test.query.filter(and_(TestFork.user_id == g.user.id, TestFork.test_id == Test.id)).order_by(
Test.id.desc()).limit(50).all()
return {
'addTestFork': fork_test_form,
'commit_options': commit_options,
'tests': tests,
'TestType': TestType,
'GitUser': username,
'categories': categories,
'customize': True
}
示例11: raw_input
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import repos [as 别名]
import getpass
from github import GitHub
username = raw_input("Github username:")
password = getpass.getpass("Github password:")
gh = GitHub(username=username, password=password)
repo = gh.repos('rshorey')('create-github-issues')
title = "another sample issue"
body = "issue created through githubpy"
repo.issues.post(title=title, body=body)
示例12: GitHubContext
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import repos [as 别名]
class GitHubContext(pullrequest.context.Context):
updatePullRequestsDelay = 30 # seconds
name = 'GitHub Pull Requests'
dbname = 'pullrequests_github'
urlpath = 'pullrequests_gh'
builders = dict(
linux=dict(name='Linux x64', builders=['precommit_linux64'], order=100),
windows=dict(name='Win x64', builders=['precommit_windows64'], order=200),
win32=dict(name='Win 32', builders=['precommit_windows32'], order=250),
macosx=dict(name='Mac', builders=['precommit_macosx'], order=300),
android=dict(name='Android', builders=['precommit_android'], order=400),
)
username = 'alalek'
repo = 'test'
client = None
@defer.inlineCallbacks
def updatePullRequests(self):
print 'Updating pull requests from GitHub...'
if not self.client:
self.client = GitHub(userAgent=userAgent, async=True, reuseETag=True, access_token=githubAccessToken)
gh_pullrequests = yield self.client.repos(self.username)(self.repo).pulls.get(state='open', per_page=100)
if self.client.status == 304:
print "GitHub pull requests was not changed"
defer.returnValue(None)
elif self.client.status == 200:
prs = []
for gh_pullrequest in gh_pullrequests:
pr = {}
pr['id'] = gh_pullrequest['number']
pr['branch'] = gh_pullrequest['base']['ref']
pr['author'] = gh_pullrequest['user']['login']
pr['assignee'] = gh_pullrequest['assignee']['login'] if gh_pullrequest['assignee'] else None
pr['head_user'] = gh_pullrequest['head']['repo']['owner']['login']
pr['head_repo'] = gh_pullrequest['head']['repo']['name']
pr['head_branch'] = gh_pullrequest['head']['ref']
pr['head_sha'] = gh_pullrequest['head']['sha']
pr['title'] = gh_pullrequest['title']
pr['description'] = gh_pullrequest['body']
prs.append(pr)
defer.returnValue(prs)
raise Exception('invalid status', self.client.status)
def getListOfAutomaticBuilders(self, pr):
if pr.description is not None and '**WIP**' in pr.description:
return []
buildersList = [
'linux',
'windows',
'win32',
# 'macosx',
# 'android'
]
return buildersList
def getBuildProperties(self, pr, b, properties, sourcestamps):
prid = pr.prid
properties.setProperty('branch', pr.branch, 'Pull request')
properties.setProperty('head_sha', pr.head_sha, 'Pull request')
properties.setProperty('pullrequest', prid, 'Pull request')
if b.isPerf:
regressionTestFilter = self.extractRegressionTestFilter(pr.description)
if regressionTestFilter is not None:
properties.setProperty('regression_test_filter', regressionTestFilter, 'Pull request')
else:
print 'ERROR: Can\'t schedule perf precommit build without regression test filter. Use check_regression parameter'
defer.returnValue(False)
if pr.description is None or '**WIP**' in pr.description:
self.pushBuildProperty(properties, pr.description, 'test[s]?_filter[s]?', 'test_filter')
sourcestamps.append(dict(
codebase='code',
repository='https://github.com/%s/%s.git' % (self.username, self.repo),
branch=pr.branch))
sourcestamps.append(dict(
codebase='code_merge',
repository='https://github.com/%s/%s.git' % (pr.head_user, pr.head_repo),
branch=pr.head_branch,
revision=pr.head_sha))
return True
def getWebAddressPullRequest(self, pr):
return 'https://github.com/%s/%s/pull/%s' % (self.username, self.repo, pr.prid)
def getWebAddressPerfRegressionReport(self, pr):
return None
示例13: TrelloClient
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import repos [as 别名]
from github import GitHub
from pprint import pprint
from datetime import date, timedelta
from time import strptime, mktime
from os import getenv
trello_client = TrelloClient(
api_key=getenv("TRELLO_API_KEY"),
api_secret=getenv("TRELLO_API_SECRET"),
token=getenv("TRELLO_TOKEN")
)
github_client = GitHub(access_token=getenv("GITHUB_ACCESS_TOKEN"))
backlog = trello_client.get_list(list_id='5361b7091b0f3942310ab040')
backlog.client = trello_client
issues = github_client.repos('freedomofpress')('securedrop').issues.get(state='open')
pprint(issues[0])
pprint(backlog)
# a_month_ago = date.today() - timedelta(weeks=4)
#
# for issue in issues:
# time_struct = strptime(issue['updated_at'], u"%Y-%m-%dT%H:%M:%SZ")
# issue.date_time = mktime(time_struct)
#
# relevant_issues = [issue for issue in issues if date.fromtimestamp(issue.date_time) > a_month_ago]
#
# for issue in relevant_issues:
# pprint(issue['updated_at'])
# name = "%s - %s" % (issue['number'],issue['title'])
示例14: print
# 需要导入模块: from github import GitHub [as 别名]
# 或者: from github.GitHub import repos [as 别名]
if member["bioguide_id"] == "":
readme.write(row_template_no_bg.format(**member))
elif member["bioguide_id"] in websites:
member["website"] = websites[member["bioguide_id"]]
readme.write(row_template.format(**member))
else:
readme.write(row_template_no_web.format(**member))
if args.issues:
print("Only create github issues if you're sure you're ready")
print("The line actually creating issues is commented out to protect you from yourself")
print("So go uncomment it when you're really ready")
username = raw_input("Github username:")
password = getpass.getpass("Github password:")
gh = GitHub(username=username, password=password)
repo = gh.repos('unitedstates')('contact-congress')
for m in new_reps:
title = "[%s] Rep. %s" % (m, new_reps[m])
body = "Newly elected to 114th congress"
#repo.issues.post(title=title, body=body)
for m in new_senators:
title = "[%s] Sen. %s" % (m, new_reps[m])
body = "Newly elected to 114th congress"
#repo.issues.post(title=title, body=body)
#do we also want to create them for existing legislators in case they change anything?
##the decision seems to be no for existing legislators right now.