本文整理匯總了Python中travispy.TravisPy.repo方法的典型用法代碼示例。如果您正苦於以下問題:Python TravisPy.repo方法的具體用法?Python TravisPy.repo怎麽用?Python TravisPy.repo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類travispy.TravisPy
的用法示例。
在下文中一共展示了TravisPy.repo方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_travis_session
# 需要導入模塊: from travispy import TravisPy [as 別名]
# 或者: from travispy.TravisPy import repo [as 別名]
def get_travis_session(username, travis_ci_token, github_token):
travis_session = TravisPy(token=travis_ci_token)
try:
travis_session.repo('some_repo')
except TravisError:
logger.error("Travis session expired for {}. Please manually generate it by doing:\n{}"
.format(username, TOKEN_INSTRUCTION.format(github_token)))
exit(1)
else:
return travis_session
示例2: build_passed
# 需要導入模塊: from travispy import TravisPy [as 別名]
# 或者: from travispy.TravisPy import repo [as 別名]
def build_passed(repo='RPi-Distro/python-gpiozero', delay=3600):
t = TravisPy()
r = t.repo(repo)
while True:
yield r.last_build_state == 'passed'
sleep(delay) # Sleep an hour before hitting travis again
示例3: build_passed
# 需要導入模塊: from travispy import TravisPy [as 別名]
# 或者: from travispy.TravisPy import repo [as 別名]
def build_passed(repo):
t = TravisPy()
r = t.repo(repo)
while True:
yield r.last_build_state == 'passed'
示例4: test
# 需要導入模塊: from travispy import TravisPy [as 別名]
# 或者: from travispy.TravisPy import repo [as 別名]
def test(self):
with self.assertRaises(TravisError):
travis = TravisPy(token='invalid_token')
travis.repo('some_repo')
示例5: GitenbergTravisJob
# 需要導入模塊: from travispy import TravisPy [as 別名]
# 或者: from travispy.TravisPy import repo [as 別名]
class GitenbergTravisJob(GitenbergJob):
def __init__(self, username, password, repo_name, repo_owner,
update_travis_commit_msg,
tag_commit_message, github_token=None, access_token=None, repo_token=None):
super(GitenbergTravisJob, self).__init__(username, password, repo_name, repo_owner,
update_travis_commit_msg,
tag_commit_message)
self.username = username
self.password = password
self._github_token = github_token
self._access_token = access_token
# if access_token is given, use it
if access_token is not None:
self.travis = TravisPy(access_token)
else:
self.travis = TravisPy.github_auth(self.github_token())
self._repo_token = repo_token
self._travis_repo_public_key = None
if self.gh_repo is not None:
self.travis_repo = self.travis.repo(self.repo_slug)
def public_key_for_travis_repo(self):
if self._travis_repo_public_key is None:
self._travis_repo_public_key = requests.get("https://api.travis-ci.org/repos/{}/{}/key".format(self.repo_owner,
self.repo_name)).json()['key']
return self._travis_repo_public_key
def github_token(self):
if self._github_token is not None:
return self._github_token
token_note = "token for travis {}".format(datetime.datetime.utcnow().isoformat())
token = self.gh.authorize(self.username, self.password,
scopes=('read:org', 'user:email', 'repo_deployment',
'repo:status', 'write:repo_hook'), note=token_note)
self._github_token = token.token
return self._github_token
def repo_token(self, from_repo_owner='GITenberg', create_duplicate=False):
"""
"""
if self._repo_token is not None:
return self._repo_token
token_note = "automatic releases for {}/{}".format(self.repo_owner, self.repo_name)
try:
token = self.gh.authorize(self.username, self.password, scopes=('public_repo'), note=token_note)
except Exception as e:
raise e # for now
if self._authorization_description_already_exists(e):
# try again with a new description
if create_duplicate:
token_note += " " + datetime.datetime.utcnow().isoformat()
token = self.gh.authorize(self.username, self.password, scopes=('public_repo'), note=token_note)
else:
raise Exception('repo token already exists for {}'.format(self.repo_slug))
else:
raise e
self._repo_token = token.token
return self._repo_token
def delete_repo_token (self):
for auth in self.gh.iter_authorizations():
if auth.name == "automatic releases for {}/{}".format(self.repo_owner, self.repo_name):
auth.delete()
return True
return False
def travis_encrypt(self, token_to_encrypt):
"""
return encrypted version of token_to_encrypt
"""
# token_to_encrypt has to be string
# if's not, assume it's unicode and enconde in utf-8
if isinstance(token_to_encrypt, unicode):
token_string = token_to_encrypt.encode('utf-8')
else:
token_string = token_to_encrypt
repo_public_key_text = self.public_key_for_travis_repo()
pubkey = repo_public_key_text.encode('utf-8')
#.........這裏部分代碼省略.........