Skip to content

Commit 1611839

Browse files
author
Zhao Wang
committed
Revert commits for auto country checking and mirror changing
This will revert commit 5e5906b and 3fb78f1
1 parent 5e5906b commit 1611839

7 files changed

Lines changed: 16 additions & 84 deletions

File tree

brainframe/cli/commands/install.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from argparse import ArgumentParser
22
from pathlib import Path
3-
import json
4-
from urllib.request import urlopen
53

64
import i18n
75

@@ -105,13 +103,6 @@ def install():
105103
docker_compose.download(
106104
install_path / "docker-compose.yml", version=args.version
107105
)
108-
location = check_location()
109-
try:
110-
docker_config = get_docker_config()
111-
except Exception:
112-
print_utils.warning_translate("install.fail-to-load-docker-config")
113-
else:
114-
update_docker_mirror(location=location, docker_config=docker_config)
115106

116107
print_utils.translate("install.downloading-images")
117108
docker_compose.run(install_path, ["pull"])
@@ -197,45 +188,3 @@ def _parse_args():
197188
)
198189

199190
return subcommand_parse_args(parser)
200-
201-
202-
def check_location() -> str:
203-
url = "http://ipinfo.io/json"
204-
try:
205-
response = urlopen(url, timeout=5)
206-
except Exception:
207-
return "US"
208-
data = json.load(response)
209-
return data["country"]
210-
211-
212-
def get_docker_config() -> dict:
213-
with open("/etc/docker/daemon.json") as docker_config_file:
214-
docker_config = json.load(docker_config_file)
215-
return docker_config
216-
217-
218-
def update_docker_mirror(docker_config: dict, location: str):
219-
docker_mirror_host = {"CN": "USTC", "US": "Docker Hub"}
220-
if location == "CN" and (
221-
"registry-mirrors" not in docker_config.keys()
222-
or docker_config["registry-mirrors"]
223-
!= ["https://docker.mirrors.ustc.edu.cn/"]
224-
):
225-
docker_config["registry-mirrors"] = [
226-
"https://docker.mirrors.ustc.edu.cn/"
227-
]
228-
elif location != "CN" and "registry-mirrors" in docker_config.keys():
229-
del docker_config["registry-mirrors"]
230-
else:
231-
return
232-
if print_utils.ask_yes_no(
233-
"install.change-docker-mirror",
234-
location=location,
235-
mirror_host=docker_mirror_host[location],
236-
):
237-
with open("/etc/docker/daemon.json", "w") as docker_config_file:
238-
json.dump(
239-
docker_config, docker_config_file, indent=4, sort_keys=True
240-
)
241-
os_utils.restart_docker()

brainframe/cli/dependencies.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ def _install_docker():
6161
os_utils.run(["sh", "/tmp/get-docker.sh"])
6262

6363

64-
docker = Dependency(
65-
"docker",
66-
"install.ask-install-docker",
67-
_install_docker,
68-
)
64+
docker = Dependency("docker", "install.ask-install-docker", _install_docker,)
6965

7066
docker_compose = Dependency(
7167
"docker-compose",

brainframe/cli/os_utils.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ def give_brainframe_group_rw_access(paths: List[Path]):
7777
run(["chmod", "-R", "g+rw"] + paths_str)
7878

7979

80-
def restart_docker():
81-
print_utils.translate("general.restarting_docker")
82-
run(["systemctl", "restart", "docker"])
83-
84-
8580
def _current_user():
8681
# If the SUDO_USER environment variable allows us to get the username of
8782
# the user running sudo instead of root. If they're not using sudo, we can

brainframe/cli/translations/general.en.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ en:
1616
staging-missing-credentials: "The %{username_env_var} and %{password_env_var}
1717
variables must be set to access staging."
1818
user-not-root: "This command must be run as root!"
19-
restarting_docker: "Restarting Docker..."

brainframe/cli/translations/install.en.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,3 @@ en:
8181
group? Doing so will allow the BrainFrame CLI to interact with Docker without
8282
root permissions."
8383
install-version: "BrainFrame:%{version} will be installed."
84-
change-docker-mirror: "We have detected you are located in %{location}, do
85-
you want to change docker mirror hosted by %{mirror_host} to speed up the
86-
download process? Please be aware that this will overwrite you docker
87-
daemon configuration and restart Docker service."
88-
fail-to-load-docker-config: "Fail to load the Docker configuration file,
89-
it's may caused by improper installation of Docker. Will keep using the
90-
original docker mirror."

poetry.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "brainframe-cli"
3-
version = "0.1.6.dev1"
3+
version = "0.1.5"
44
license = "BSD-3-Clause"
55
authors = ["Aotu <info@aotu.ai>"]
66

0 commit comments

Comments
 (0)