script/build-integration-branch: python3 compatible and pep8 clean

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2017-09-29 12:03:15 +08:00
parent 1aef50a1ed
commit 4e8e311694

View File

@ -1,11 +1,17 @@
#!/usr/bin/env python
from __future__ import print_function
import json
import os
import requests
from subprocess import call
import sys
import time
try:
from urllib.parse import urljoin
except:
from urlparse import urljoin
label = sys.argv[1]
repo = "ceph/ceph"
@ -14,7 +20,8 @@ with open(os.environ['HOME'] + '/.github_token', 'r') as myfile:
token = myfile.readline().strip()
# get prs
baseurl = 'https://api.github.com/repos/{repo}/issues?labels={label}&access_token={token}'
baseurl = urljoin('https://api.github.com',
'repos/{repo}/issues?labels={label}&access_token={token}')
url = baseurl.format(
label=label,
repo=repo,
@ -38,7 +45,7 @@ print("--- queried %s prs" % len(prs))
# name branch
TIME_FORMAT = '%Y-%m-%d-%H%M'
branch = label + "-" + time.strftime(TIME_FORMAT, time.localtime())
print "branch %s" % branch
print("branch %s" % branch)
# assemble
print('--- creating branch %s' % branch)
@ -50,9 +57,8 @@ for pr in prs:
pr['head']['repo']['clone_url'],
pr['head']['ref']))
r = call(['git', 'pull', '--no-edit',
pr['head']['repo']['clone_url'],
pr['head']['ref']
])
pr['head']['repo']['clone_url'],
pr['head']['ref']])
assert not r
print('--- done. these PRs were included:')
print('\n'.join(prtext))