mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
25
build.py
25
build.py
@@ -43,6 +43,16 @@ if sys.version_info[0] != 2:
|
||||
|
||||
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.
|
||||
@@ -263,11 +273,16 @@ class Gen_compressed(threading.Thread):
|
||||
def do_compile(self, params, target_filename, filenames, remove):
|
||||
# Send the request to Google.
|
||||
headers = {"Content-type": "application/x-www-form-urlencoded"}
|
||||
conn = httplib.HTTPConnection("closure-compiler.appspot.com")
|
||||
conn.request("POST", "/compile", urllib.urlencode(params), headers)
|
||||
response = conn.getresponse()
|
||||
json_str = response.read()
|
||||
conn.close()
|
||||
|
||||
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()
|
||||
|
||||
# Parse the JSON response.
|
||||
json_data = json.loads(json_str)
|
||||
|
||||
Reference in New Issue
Block a user