本文整理匯總了Python中github.GitHub.hasPushAccess方法的典型用法代碼示例。如果您正苦於以下問題:Python GitHub.hasPushAccess方法的具體用法?Python GitHub.hasPushAccess怎麽用?Python GitHub.hasPushAccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.GitHub
的用法示例。
在下文中一共展示了GitHub.hasPushAccess方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from github import GitHub [as 別名]
# 或者: from github.GitHub import hasPushAccess [as 別名]
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())