|
43 | 43 |
|
44 | 44 | import errno, glob, httplib, json, os, re, subprocess, threading, urllib
|
45 | 45 |
|
46 |
| -import getopt |
47 |
| -import requests |
48 |
| -opts , args = getopt.getopt(sys.argv[1:], "hp:") |
49 |
| -proxy_url = False |
50 |
| -for op, value in opts: |
51 |
| - if op == '-h': |
52 |
| - print('-p <proxy_url> Compile via <proxy_url>, example: python build.py -p 127.0.0.1:8787') |
53 |
| - sys.exit() |
54 |
| - elif op == '-p': |
55 |
| - proxy_url = value |
56 | 46 |
|
57 | 47 | def import_path(fullpath):
|
58 | 48 | """Import a file with full path specification.
|
@@ -273,16 +263,11 @@ def gen_generator(self, language):
|
273 | 263 | def do_compile(self, params, target_filename, filenames, remove):
|
274 | 264 | # Send the request to Google.
|
275 | 265 | headers = {"Content-type": "application/x-www-form-urlencoded"}
|
276 |
| - |
277 |
| - json_str='' |
278 |
| - if proxy_url: |
279 |
| - json_str=requests.post("http://closure-compiler.appspot.com/compile",data=params,headers=headers,proxies={"http":proxy_url,"https":proxy_url},timeout=100).content |
280 |
| - else: |
281 |
| - conn = httplib.HTTPConnection("closure-compiler.appspot.com") |
282 |
| - conn.request("POST", "/compile", urllib.urlencode(params), headers) |
283 |
| - response = conn.getresponse() |
284 |
| - json_str = response.read() |
285 |
| - conn.close() |
| 266 | + conn = httplib.HTTPConnection("closure-compiler.appspot.com") |
| 267 | + conn.request("POST", "/compile", urllib.urlencode(params), headers) |
| 268 | + response = conn.getresponse() |
| 269 | + json_str = response.read() |
| 270 | + conn.close() |
286 | 271 |
|
287 | 272 | # Parse the JSON response.
|
288 | 273 | json_data = json.loads(json_str)
|
|
0 commit comments