Skip to content

Commit

Permalink
fix: Change from f-string to format() (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
elysia-best authored Sep 12, 2024
1 parent 05b0bb0 commit 96ae824
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions tools/tool_config_docker_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def config_docker_proxy(self):
if not url:
url = '127.0.0.1'
port = input('请输入代理所在端口:')
proxy_config_vpn = f"""[Service]
Environment="HTTP_PROXY=http://{url}:{port}/"
Environment="HTTPS_PROXY=http://{url}:{port}/"
Environment="NO_PROXY=localhost,127.0.0.1,{url},.example.com"""
proxy_config_vpn = """[Service]
Environment="HTTP_PROXY=http://{}:{}/"
Environment="HTTPS_PROXY=http://{}:{}/"
Environment="NO_PROXY=localhost,127.0.0.1,{},.example.com""".format(url, port, url, port, url)
FileUtils.new('/etc/systemd/system/docker.service.d/','proxy.conf',proxy_config_vpn)
PrintUtils.print_info(f"在{'/etc/systemd/system/docker.service.d'}/{'proxy.conf'}写入了{proxy_config_vpn},接下来为你重启Docker!")
PrintUtils.print_info("在{}/{}写入了{},接下来为你重启Docker!".format('/etc/systemd/system/docker.service.d', 'proxy.conf', proxy_config_vpn))
CmdTask("sudo systemctl daemon-reload").run()
CmdTask("sudo systemctl restart docker").run()
elif code==2:
Expand All @@ -39,9 +39,9 @@ def config_docker_proxy(self):
code,result = ChooseTask(dic, "请选择代理加速网址").run()
url = dic[code]
print(url)
proxy_config_vpn = f'{{"registry-mirrors": ["{url}"]}}'
proxy_config_vpn = '{{"registry-mirrors": ["{}"]}}'.format(url)
FileUtils.new('/etc/docker/','daemon.json',proxy_config_vpn)
PrintUtils.print_info(f"在{'/etc/docker/'}/{'daemon.json'}写入了{proxy_config_vpn},接下来为你重启Docker!")
PrintUtils.print_info("在{}/{}写入了{},接下来为你重启Docker!".format('/etc/docker/', 'daemon.json', proxy_config_vpn))
CmdTask("sudo systemctl daemon-reload").run()
CmdTask("sudo systemctl restart docker").run()
elif code==3:
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_config_system_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get_source_by_system(self,system,codename,arch,failed_sources=[]):
PrintUtils.print_warn('接下来为您排除已经失败的源')
for source in fast_source:
if source in failed_sources:
PrintUtils.print_info(f'{source} 已经测试失败,跳过!')
PrintUtils.print_info('{} 已经测试失败,跳过!'.format(source))
else:
return source,template
else:
Expand Down
4 changes: 2 additions & 2 deletions tools/tool_install_backup_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def install_nodejs(self):
disk_origin = '/dev/sda'
save_disk = input('请输入你要存放的文件磁盘(如:/dev/sdb2):')
file_name = input('请输入文件名guidebot_240802:')
CmdTask(f"mkdir -p /tmp/save_disk && mount {save_disk} /tmp/save_disk").run()
CmdTask("mkdir -p /tmp/save_disk && mount {} /tmp/save_disk".format(save_disk)).run()
PrintUtils.print_info("查看进度: watch -n 1 pkill -USR1 -x dd")
command = f'cd /tmp/save_disk && dd if={disk_origin} | gzip > {file_name}.gz'
command = 'cd /tmp/save_disk && dd if={} | gzip > {}.gz'.format(disk_origin, file_name)
CmdTask(command).run()

else:
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_install_ros_with_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def get_vesion_list():
"""获取可安装的ROS版本列表"""
names = []
for version in RosVersions.ros_version:
names.append(f'{version.name} ({version.version})')
names.append('{} ({})'.format(version.name, version.version))
return names


Expand Down

0 comments on commit 96ae824

Please sign in to comment.