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


Python github.GitHub类代码示例

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


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

示例1: get_gh_data

def get_gh_data():
    gh_access_token = request.cookies.get('gh_access_token')
    gh = GitHub(access_token=gh_access_token)

    user_id = gh.user().get()['login']
    page = 1
    events = gh.users(user_id).events().get(page=page)

    while True:
        page += 1        
        new_events = gh.users(user_id).events().get(page=page)
        if len(new_events) > 0:
            events.extend(new_events)
        else:
            break

    created_ats = [e['created_at'][:-1] for e in events]

    timestamps = []
    for ca in created_ats:
        ts = time.strptime(ca, "%Y-%m-%dT%H:%M:%S")
        timestamps.append((ts.tm_hour * 60 + ts.tm_min -300)%1440)

    print("GH: " + str(len(timestamps)))

    return json.dumps(timestamps)
开发者ID:acsalu,项目名称:social-traces,代码行数:26,代码来源:app.py

示例2: get

    def get(self):
        user = users.get_current_user()
        if not user:
            self.redirect(users.create_login_url(self.request.uri))
        else:
            if validAdmin(user):
                creds = get_githubcredentials()

                self.response.write("""
<form action='%s' method="POST">
                Github Repository Owner: <input name="github_owner" type="text" value="%s" /><br>
                Github Repository Name: <input name="github_repo" type="text" value="%s" /><br>
                Github Access Token (always hidden): <input name="github_token" type="text" placeholder="access token" /><br>
                <input type="submit" />
</form>
                """%(self.request.uri, creds.owner, creds.repo))

                hasAccess = False
                ghcreds = get_githubcredentials()
                gh = GitHub(creds.owner, creds.repo, creds.token)
                try:
                    hasAccess = gh.hasPushAccess()
                except:
                    pass
                
                if hasAccess:
                    self.response.write("<p>Push Access Granted by GitHub.com</p>")
                else:
                    self.response.write("<p>WARNING: No push access with the stored token and repo information. Please provide valid information</p>")
                

            else:
                self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
                self.response.write("No write access for user %s"%user.email())
开发者ID:elor,项目名称:tuvero-issue,代码行数:34,代码来源:main.py

示例3: _make_message

    def _make_message(self, message, user, repo):
        github = GitHub()
        try:
            git_user = github.user(user)
        except BadUser:
            logging.error("Uh oh! {} doesn't seem to be a valid GitHub user.".format(user))
            return False
        try:
            git_repo = github.repo(user, repo)
        except BadRepo:
            logging.error("Uh oh! Can't connect to {}'s repo {}.".format(user, repo))
            return False
        # TODO - this is ugly, setup Jinja or some other templating here instead.
        message = """
**[{title}]({url})** - *A {language} repository written by [{author}]({author_url})*

> {description}

{stars} stars, {forks} forks

Clone this repository: `{clone}`

---
[I'm a bot](https://github.com/naiyt/autogithubbot) that posts info about GitHub repositories. [Create your own bot](https://github.com/naiyt/reddit-replier)! (Just be nice about it.)
    """.format(title=git_repo.name, url=git_repo.url, language=git_repo.language,
                   description=git_repo.description, author=git_repo.author,
                   author_url=git_user.url,
                   stars=git_repo.stars, forks=git_repo.forks, clone=git_repo.clone_url)
        return message
开发者ID:naiyt,项目名称:autogithubbot,代码行数:29,代码来源:parser.py

示例4: upload_to_github

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)
开发者ID:greenheartgames,项目名称:greenworks,代码行数:9,代码来源:package.py

示例5: get_issues_api

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
开发者ID:IL2HorusTeam,项目名称:il2fb-mission-parser-demo,代码行数:9,代码来源:main.py

示例6: main

def main():
	parser = OptionParser(usage="usage: %prog [options] [pull number]")
	parser.add_option("-g", "--github-user", dest="gituser",
			type="string", help="github user, if not supplied no auth is used", metavar="USER")
	
	(options, args) = parser.parse_args()
	github = GitHub(options)

        for pullNumber in args:
		pull = github.pull("apache", "storm", pullNumber)
		print "git pull "+pull.fromRepo()+" "+pull.fromBranch()
开发者ID:10614931,项目名称:storm,代码行数:11,代码来源:storm-merge.py

示例7: main

def main():
	parser = OptionParser(usage="usage: %prog [options]")
	parser.add_option("-g", "--github-user", dest="gituser",
			type="string", help="github user, if not supplied no auth is used", metavar="USER")
	
	(options, args) = parser.parse_args()
	
	jrepo = JiraRepo("https://issues.apache.org/jira/rest/api/2")
	github = GitHub(options)
	
	openPullRequests = github.openPulls("apache","storm")
	stormJiraNumber = re.compile("STORM-[0-9]+")
	openJiras = jrepo.openJiras("STORM")
	
	jira2Pulls = {}
	pullWithoutJira = []
	pullWithBadJira = []
	
	for pull in openPullRequests:
		found = stormJiraNumber.search(pull.title())
		if found:
			jiraNum = found.group(0)
			if not (jiraNum in openJiras):
				pullWithBadJira.append(pull)
			else:
				if jira2Pulls.get(jiraNum) == None:
					jira2Pulls[jiraNum] = []
				jira2Pulls[jiraNum].append(pull)
		else:
			pullWithoutJira.append(pull);
	
	now = datetime.utcnow()
	print "Pull requests that need a JIRA:"
	print "Pull URL\tPull Title\tPull Age\tPull Update Age"
	for pull in pullWithoutJira:
		print ("%s\t%s\t%s\t%s"%(pull.html_url(), pull.title(), daydiff(now, pull.created_at()), daydiff(now, pull.updated_at()))).encode("UTF-8")
	
	print "\nPull with bad or closed JIRA:"
	print "Pull URL\tPull Title\tPull Age\tPull Update Age"
	for pull in pullWithBadJira:
		print ("%s\t%s\t%s\t%s"%(pull.html_url(), pull.title(), daydiff(now, pull.created_at()), daydiff(now, pull.updated_at()))).encode("UTF-8")
	
	print "\nOpen JIRA to Pull Requests and Possible Votes, vote detection is very approximate:"
	print "JIRA\tPull Requests\tJira Summary\tJIRA Age\tPull Age\tJIRA Update Age\tPull Update Age"
	print "\tComment Vote\tComment Author\tPull URL\tComment Age"
	for key, value in jira2Pulls.items():
		print ("%s\t%s\t%s\t%s\t%s\t%s\t%s"%(key, mstr(value), openJiras[key].getSummary(),
			 daydiff(now, openJiras[key].getCreated()), daydiff(now, value[0].created_at()),
			 daydiff(now, openJiras[key].getUpdated()), daydiff(now, value[0].updated_at()))).encode("UTF-8")
		for comment in openJiras[key].getComments():
			#print comment.raw()
			if comment.hasVote():
				print (("\t%s\t%s\t%s\t%s")%(comment.getVote(), comment.getAuthor(), comment.getPull(), daydiff(now, comment.getCreated()))).encode("UTF-8")
开发者ID:100Mbps,项目名称:storm,代码行数:53,代码来源:jira-github-join.py

示例8: get_token

def get_token(config):
    token = config.get('token')
    if token is None:
        github = GitHub()
        login, password = get_user_credentials()
        token = github.create_token(login, password)
        if token is None:
            otp = raw_input('Two-factor code: ')
            token = github.create_token(login, password, otp)
            config.put('token', token)
            config.save()

    return token
开发者ID:smaant,项目名称:cmdpr,代码行数:13,代码来源:pullrequest.py

示例9: cron

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)
开发者ID:canihavesomecoffee,项目名称:sample-platform,代码行数:13,代码来源:cron.py

示例10: lp_layout_list

 def lp_layout_list(self, upstream=None):
     """
     search_order : list layouts from upstream if mentioned
                    list layouts from core package
     """
     if upstream is None:
         l_files = list_files(self.base_path + "/inventory_layouts")
         return l_files
     else:
         g = GitHub(upstream)
         l_files = []
         files = g.list_files("inventory_layouts")
         return files
开发者ID:greg-hellings,项目名称:linch-pin,代码行数:13,代码来源:api.py

示例11: lp_topo_list

 def lp_topo_list(self, upstream=None):
     """
     search_order : list topologies from upstream if mentioned
                    list topologies from current folder
     """
     if upstream is None:
         t_files = list_files(self.base_path + "/ex_topo")
         return t_files
     else:
         print "getting from upstream"
         g = GitHub(upstream)
         t_files = []
         files = g.list_files("ex_topo")
         return files
开发者ID:greg-hellings,项目名称:linch-pin,代码行数:14,代码来源:api.py

示例12: lp_layout_get

 def lp_layout_get(self, layout, upstream=None):
     """
     search_order : get layouts from upstream if mentioned
                    get layouts from core package
     """
     if upstream is None:
         get_file(self.base_path + "/inventory_layouts/" + layout,
                  "./layouts/")
     else:
         g = GitHub(upstream)
         files = g.list_files("inventory_layouts")
         link = filter(lambda link: link['name'] == layout, files)
         link = link[0]["download_url"]
         get_file(link, "./layouts", True)
         return link
开发者ID:greg-hellings,项目名称:linch-pin,代码行数:15,代码来源:api.py

示例13: lp_topo_get

 def lp_topo_get(self, topo, upstream=None):
     """
     search_order : get topologies from upstream if mentioned
                    get topologies from core package
     # need to add checks for ./topologies
     """
     if upstream is None:
         get_file(self.base_path + "/ex_topo/" + topo, "./topologies/")
     else:
         g = GitHub(upstream)
         files = g.list_files("ex_topo")
         link = filter(lambda link: link['name'] == topo, files)
         link = link[0]["download_url"]
         get_file(link, "./topologies", True)
         return link
开发者ID:greg-hellings,项目名称:linch-pin,代码行数:15,代码来源:api.py

示例14: updatePullRequests

    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)
开发者ID:alalek,项目名称:buildbot-pullrequest-sample,代码行数:26,代码来源:pr_github.py

示例15: setup_repos

def setup_repos():
    """ Ensure we have a matching GitHub repo for every import project
    """

    github = GitHub(access_token=GITHUB_TOKEN, scope='user,repo')

    #current_repos = github.users(GITHUB_USERNAME).repos.get()
    current_repos = github.orgs(GITHUB_ORGANIZATION).repos.get()

    repo_names = [x['name'] for x in current_repos]

    for project in PROJECTS:
        target_repo_name = GITHUB_REPO_NAME_FORMAT % (project['github_name'])

        if target_repo_name not in repo_names:
            github.orgs(GITHUB_ORGANIZATION).repos.post(
                name=target_repo_name,
                description='Mirrored repository')  # FIXME
开发者ID:VersioningGoat,项目名称:versioning-goat,代码行数:18,代码来源:app.py


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