-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathset_proxy_args.py
More file actions
40 lines (23 loc) · 994 Bytes
/
set_proxy_args.py
File metadata and controls
40 lines (23 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import yaml
import json
import os
base_path = './docker_sdk_api/api/data'
proxy_file_path = os.path.join(base_path, "proxy.json")
proxy_settings = None
with open(proxy_file_path, "r") as proxy_file:
proxy_settings = json.loads(proxy_file.read())
compose_build_files = ["./build_cpu.yml", "./build_gpu.yml"]
for build_file in compose_build_files:
content = None
with open(build_file, "r") as f:
contents = yaml.load_all(f, Loader=yaml.FullLoader)
for content in contents:
services = content['services']
for service, service_params in services.items():
build = service_params['build']
build['args']['http_proxy'] = proxy_settings['HTTP_PROXY']
build['args']['https_proxy'] = proxy_settings['HTTPS_PROXY']
service_params['build'] = build
content['services'] = services
with open(build_file, "w") as f:
yaml.dump(content, f)