HADOOP-12237. releasedocmaker.py doesn't work behind a proxy (Tsuyoshi Ozawa via aw)

(cherry picked from commit b41fe3111ae37478cbace2a07e6ac35a676ef978)
This commit is contained in:
Allen Wittenauer 2015-07-20 09:47:46 -07:00 committed by Andrew Wang
parent d7697831e3
commit adcf5dd940

View File

@ -24,6 +24,7 @@
import re import re
import sys import sys
import urllib import urllib
import urllib2
try: try:
import json import json
except ImportError: except ImportError:
@ -125,7 +126,7 @@ def __init__(self,versions, projects):
versions.sort() versions.sort()
print "Looking for %s through %s"%(versions[0],versions[-1]) print "Looking for %s through %s"%(versions[0],versions[-1])
for p in projects: for p in projects:
resp = urllib.urlopen("https://issues.apache.org/jira/rest/api/2/project/%s/versions"%p) resp = urllib2.urlopen("https://issues.apache.org/jira/rest/api/2/project/%s/versions"%p)
data = json.loads(resp.read()) data = json.loads(resp.read())
for d in data: for d in data:
if d['name'][0].isdigit and versions[0] <= d['name'] and d['name'] <= versions[-1]: if d['name'][0].isdigit and versions[0] <= d['name'] and d['name'] <= versions[-1]:
@ -288,7 +289,7 @@ def __init__(self, version, projects):
self.projects = projects self.projects = projects
v=str(version).replace("-SNAPSHOT","") v=str(version).replace("-SNAPSHOT","")
resp = urllib.urlopen("https://issues.apache.org/jira/rest/api/2/field") resp = urllib2.urlopen("https://issues.apache.org/jira/rest/api/2/field")
data = json.loads(resp.read()) data = json.loads(resp.read())
self.fieldIdMap = {} self.fieldIdMap = {}
@ -301,7 +302,7 @@ def __init__(self, version, projects):
count=100 count=100
while (at < end): while (at < end):
params = urllib.urlencode({'jql': "project in ('"+"' , '".join(projects)+"') and fixVersion in ('"+v+"') and resolution = Fixed", 'startAt':at, 'maxResults':count}) params = urllib.urlencode({'jql': "project in ('"+"' , '".join(projects)+"') and fixVersion in ('"+v+"') and resolution = Fixed", 'startAt':at, 'maxResults':count})
resp = urllib.urlopen("https://issues.apache.org/jira/rest/api/2/search?%s"%params) resp = urllib2.urlopen("https://issues.apache.org/jira/rest/api/2/search?%s"%params)
data = json.loads(resp.read()) data = json.loads(resp.read())
if (data.has_key('errorMessages')): if (data.has_key('errorMessages')):
raise Exception(data['errorMessages']) raise Exception(data['errorMessages'])
@ -407,6 +408,10 @@ def main():
if (len(options.versions) <= 0): if (len(options.versions) <= 0):
parser.error("At least one version needs to be supplied") parser.error("At least one version needs to be supplied")
proxy = urllib2.ProxyHandler()
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
projects = options.projects projects = options.projects
if (options.range is True): if (options.range is True):