]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
script/build-integration-branch: python3 compatible and pep8 clean
authorKefu Chai <kchai@redhat.com>
Fri, 29 Sep 2017 04:03:15 +0000 (12:03 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 29 Sep 2017 04:05:49 +0000 (12:05 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/script/build-integration-branch

index 416d38e8b86f2b1b4a04cdd74a4a25ee8ad1f880..263506cb43c5a1c77bd62e54274c2baa5f2c86e5 100755 (executable)
@@ -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))