From 4e8e3116949d11f62ac027e300c09dc5f929cfc5 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 29 Sep 2017 12:03:15 +0800 Subject: [PATCH] script/build-integration-branch: python3 compatible and pep8 clean Signed-off-by: Kefu Chai --- src/script/build-integration-branch | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/script/build-integration-branch b/src/script/build-integration-branch index 416d38e8b86f2..263506cb43c5a 100755 --- a/src/script/build-integration-branch +++ b/src/script/build-integration-branch @@ -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)) -- 2.39.5