MCPcopy Index your code
hub / github.com/Tencent/CodeAnalysis / get_proxy_args

Method get_proxy_args

client/util/jvmproxy.py:20–52  ·  view source on GitHub ↗

解析代理环境变量

()

Source from the content-addressed store, hash-verified

18class JVMProxy(object):
19 @staticmethod
20 def get_proxy_args():
21 """
22 解析代理环境变量
23 """
24 proxy_args = []
25 pattern = re.compile(r"https?://((.*):(.*)@)?(.*):(\d+)")
26
27 # 解析http_proxy
28 http_proxy = os.environ.get("HTTP_PROXY")
29 if http_proxy is None:
30 http_proxy = os.environ.get("http_proxy")
31 if http_proxy is not None:
32 match = pattern.match(http_proxy)
33 if match:
34 if match.group(1):
35 proxy_args.append(f"-Dhttp.proxyUser={match.group(2)}")
36 proxy_args.append(f"-Dhttp.proxyPassword={match.group(3)}")
37 proxy_args.append(f"-Dhttp.proxyHost={match.group(4)}")
38 proxy_args.append(f"-Dhttp.proxyPort={match.group(5)}")
39
40 https_proxy = os.environ.get("HTTPS_PROXY")
41 if https_proxy is None:
42 https_proxy = os.environ.get("https_proxy")
43 if https_proxy is not None:
44 match = pattern.match(https_proxy)
45 if match:
46 if match.group(1):
47 proxy_args.append(f"-Dhttps.proxyUser={match.group(2)}")
48 proxy_args.append(f"-Dhttps.proxyPassword={match.group(3)}")
49 proxy_args.append(f"-Dhttps.proxyHost={match.group(4)}")
50 proxy_args.append(f"-Dhttps.proxyPort={match.group(5)}")
51
52 return proxy_args
53
54
55if __name__ == "__main__":

Callers

nothing calls this directly

Calls 2

compileMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected