Merge #7737: devtools: make github-merge.py use py3
f11c5a3
devtools: make github-merge.py use py3 (Wladimir J. van der Laan)
This commit is contained in:
commit
aa0d2b2631
1 changed files with 13 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# Copyright (c) 2016 Bitcoin Core Developers
|
# Copyright (c) 2016 Bitcoin Core Developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
@ -19,6 +19,11 @@ import os,sys
|
||||||
from sys import stdin,stdout,stderr
|
from sys import stdin,stdout,stderr
|
||||||
import argparse
|
import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import json,codecs
|
||||||
|
try:
|
||||||
|
from urllib.request import Request,urlopen
|
||||||
|
except:
|
||||||
|
from urllib2 import Request,urlopen
|
||||||
|
|
||||||
# External tools (can be overridden using environment)
|
# External tools (can be overridden using environment)
|
||||||
GIT = os.getenv('GIT','git')
|
GIT = os.getenv('GIT','git')
|
||||||
|
@ -38,7 +43,7 @@ def git_config_get(option, default=None):
|
||||||
Get named configuration option from git repository.
|
Get named configuration option from git repository.
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
return subprocess.check_output([GIT,'config','--get',option]).rstrip()
|
return subprocess.check_output([GIT,'config','--get',option]).rstrip().decode('utf-8')
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
@ -47,18 +52,19 @@ def retrieve_pr_title(repo,pull):
|
||||||
Retrieve pull request title from github.
|
Retrieve pull request title from github.
|
||||||
Return None if no title can be found, or an error happens.
|
Return None if no title can be found, or an error happens.
|
||||||
'''
|
'''
|
||||||
import urllib2,json
|
|
||||||
try:
|
try:
|
||||||
req = urllib2.Request("https://api.github.com/repos/"+repo+"/pulls/"+pull)
|
req = Request("https://api.github.com/repos/"+repo+"/pulls/"+pull)
|
||||||
result = urllib2.urlopen(req)
|
result = urlopen(req)
|
||||||
result = json.load(result)
|
reader = codecs.getreader('utf-8')
|
||||||
return result['title']
|
obj = json.load(reader(result))
|
||||||
|
return obj['title']
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('Warning: unable to retrieve pull title from github: %s' % e)
|
print('Warning: unable to retrieve pull title from github: %s' % e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def ask_prompt(text):
|
def ask_prompt(text):
|
||||||
print(text,end=" ",file=stderr)
|
print(text,end=" ",file=stderr)
|
||||||
|
stderr.flush()
|
||||||
reply = stdin.readline().rstrip()
|
reply = stdin.readline().rstrip()
|
||||||
print("",file=stderr)
|
print("",file=stderr)
|
||||||
return reply
|
return reply
|
||||||
|
|
Loading…
Reference in a new issue