當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。