Skip to content

Commit

Permalink
Merge pull request #376 from google/revert-371-proxy
Browse files Browse the repository at this point in the history
Revert "proxy option for build.py"
  • Loading branch information
NeilFraser committed May 21, 2016
2 parents 78648b9 + f9d5bdc commit 493fa91
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@

import errno, glob, httplib, json, os, re, subprocess, threading, urllib

import getopt
import requests
opts , args = getopt.getopt(sys.argv[1:], "hp:")
proxy_url = False
for op, value in opts:
if op == '-h':
print('-p <proxy_url> Compile via <proxy_url>, example: python build.py -p 127.0.0.1:8787')
sys.exit()
elif op == '-p':
proxy_url = value

def import_path(fullpath):
"""Import a file with full path specification.
Expand Down Expand Up @@ -273,16 +263,11 @@ def gen_generator(self, language):
def do_compile(self, params, target_filename, filenames, remove):
# Send the request to Google.
headers = {"Content-type": "application/x-www-form-urlencoded"}

json_str=''
if proxy_url:
json_str=requests.post("http://closure-compiler.appspot.com/compile",data=params,headers=headers,proxies={"http":proxy_url,"https":proxy_url},timeout=100).content
else:
conn = httplib.HTTPConnection("closure-compiler.appspot.com")
conn.request("POST", "/compile", urllib.urlencode(params), headers)
response = conn.getresponse()
json_str = response.read()
conn.close()
conn = httplib.HTTPConnection("closure-compiler.appspot.com")
conn.request("POST", "/compile", urllib.urlencode(params), headers)
response = conn.getresponse()
json_str = response.read()
conn.close()

# Parse the JSON response.
json_data = json.loads(json_str)
Expand Down

0 comments on commit 493fa91

Please sign in to comment.