Skip to content

Commit

Permalink
fix: author拼接错误&Python配置国内源错误
Browse files Browse the repository at this point in the history
  • Loading branch information
fishros committed Sep 6, 2024
1 parent bf8e6d8 commit 2fc92d6
Show file tree
Hide file tree
Showing 22 changed files with 54 additions and 44 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ class Tool(BaseTool):
def __init__(self):
self.type = BaseTool.TYPE_INSTALL
self.name = "模板工程"
self.autor = '小鱼'
self.author = '小鱼'
def run(self):
#正式的运行
pass
```

接着修改type、name、autor
接着修改type、name、author

在run函数中编写逻辑,可以提供给你的工具有:
1. PrintUtils 打印文字
Expand Down
10 changes: 5 additions & 5 deletions tools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1422,12 +1422,12 @@ def __init__(self,name,tool_type):

self.name = name
self.type = tool_type
self.autor = '小鱼'
self.autor_email = '[email protected]'
self.author = '小鱼'
self.author_email = '[email protected]'

def init(self):
# 初始化部分
PrintUtils.print_delay(tr.tr("欢迎使用{},本工具由作者{}提供").format(self.name,self.autor))
PrintUtils.print_delay(tr.tr("欢迎使用{},本工具由作者{}提供").format(self.name,self.author))

def run(self):
# 运行该任务
Expand All @@ -1438,11 +1438,11 @@ def uninit(self):
pass
# PrintUtils.print_delay("一键安装已开源,欢迎给个star/提出问题/帮助完善:https://github.com/fishros/install/ ")

def run_tool_file(file,autorun=True):
def run_tool_file(file,authorun=True):
"""运行工具文件,可以获取其他工具的对象"""
import importlib
tool = importlib.import_module(file.replace(".py","")).Tool()
if not autorun: return tool
if not authorun: return tool
if tool.init()==False: return False
if tool.run()==False: return False
if tool.uninit()==False: return False
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_config_docker_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Tool(BaseTool):
def __init__(self):
self.name = "一键配置Docker代理(支持VPN+代理服务两种模式)"
self.type = BaseTool.TYPE_INSTALL
self.autor = '小鱼'
self.author = '小鱼'


def config_docker_proxy(self):
Expand Down
40 changes: 25 additions & 15 deletions tools/tool_config_python_source.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from .base import BaseTool
from .base import PrintUtils,CmdTask,FileUtils,AptUtils,ChooseTask
from .base import PrintUtils, CmdTask, FileUtils, AptUtils, ChooseTask
from .base import osversion
from .base import run_tool_file
from .base import os
Expand All @@ -9,23 +9,33 @@ class Tool(BaseTool):
def __init__(self):
self.type = BaseTool.TYPE_CONFIG
self.name = "python change source"
self.autor = 'songHat'
self.author = 'songHat'

def run(self):
#正式的运行
PrintUtils.print_delay('runing python_source')
# 正式的运行
port = "https://pypi.mirrors.ustc.edu.cn/simple/"

path = '~/.pip/pip.conf'
# delete
if FileUtils.exists(path):
FileUtils.delete(path)

data = "[global]\nindex-url = {}".format(port)
CmdTask(f"sudo touch {path}").run()
CmdTask(f"sudo chmod 777 {path}").run()
CmdTask(f'sudo echo "{data}" > {path}').run()
CmdTask(f'pip config list').run()
PrintUtils.print_delay('配置成功(如果使用国内源下载包,记得关闭代理)')
homes = FileUtils.getusershome()
for home in homes:
pip_dir = os.path.join(home, '.pip')
pip_conf = os.path.join(pip_dir, 'pip.conf')

# Delete .pip directory if it exists
if FileUtils.exists(pip_dir):
FileUtils.delete(pip_dir)

# Create the .pip directory
os.mkdir(pip_dir)

# Write the configuration to pip.conf
data = "[global]\nindex-url = {}".format(port)
with open(pip_conf, 'w') as f:
f.write(data)

# Set the appropriate permissions
CmdTask(f"sudo chmod 777 {pip_conf}").run()

# Verify pip configuration
CmdTask('pip config list').run()

PrintUtils.print_delay('配置成功(如果使用国内源下载包,记得关闭代理)')
2 changes: 1 addition & 1 deletion tools/tool_config_rosdep.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Tool(BaseTool):
def __init__(self):
self.type = BaseTool.TYPE_CONFIG
self.name = "模板工程"
self.autor = '小鱼'
self.author = '小鱼'

def install_rosdepc(self):
CmdTask("sudo apt install python3-pip -y", 0).run()
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_config_rosenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Tool(BaseTool):
def __init__(self):
self.type = BaseTool.TYPE_CONFIG
self.name = "一键配置ROS开发环境"
self.autor = '小鱼'
self.author = '小鱼'
def config_rosenv(self):
shell = FileUtils.get_shell()

Expand Down
4 changes: 2 additions & 2 deletions tools/tool_config_system_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ class Tool(BaseTool):
def __init__(self):
self.type = BaseTool.TYPE_CONFIG
self.name = "一键更换系统源"
self.autor = '小鱼'
self.author = '小鱼'


def add_ros_source(self):
"""快速添加ROS源"""
dic = {1:"添加ROS/ROS2源",2:"不添加ROS/ROS2源"}
code,result = ChooseTask(dic, "请问是否添加ROS和ROS2源?").run()
if code==2: return
tool = run_tool_file('tools.tool_install_ros',autorun=False)
tool = run_tool_file('tools.tool_install_ros',authorun=False)
if not tool.support_install(): return False
tool.add_key()
tool.add_source()
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_install_backup_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Tool(BaseTool):
def __init__(self):
self.name = "快速备份还原系统工具"
self.type = BaseTool.TYPE_INSTALL
self.autor = '小鱼'
self.author = '小鱼'

def install_nodejs(self):
wechat_version_dic = {1:"备份磁盘",2:"还原磁盘"}
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_install_cartographer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Tool(BaseTool):
def __init__(self):
self.name = "一键安装Cartographer"
self.type = BaseTool.TYPE_INSTALL
self.autor = 'catalpa'
self.author = 'catalpa'

def get_sys_default_ros_version(self):
if osversion.get_version().find('18')>=0:
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_install_code_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Tool(BaseTool):
def __init__(self):
self.name = "一键安装Code-Server"
self.type = BaseTool.TYPE_INSTALL
self.autor = '小鱼'
self.author = '小鱼'

def install_code_server(self):
PrintUtils.print_info("开始根据系统架构,为你下载对应版本的Code-Server~")
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_install_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Tool(BaseTool):
def __init__(self):
self.name = "一键安装Docker,支持amd64和arm64架构系统"
self.type = BaseTool.TYPE_INSTALL
self.autor = 'alyssa'
self.author = 'alyssa'

def install_docker(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_install_github_desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Tool(BaseTool):
def __init__(self):
self.type = BaseTool.TYPE_INSTALL
self.name = "安装Github桌面版"
self.autor = '小鱼'
self.author = '小鱼'

def install_github(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_install_micros_fishbot_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Tool(BaseTool):
def __init__(self):
self.name = "安装PlateformIO MicroROS开发环境(支持Fishbot)"
self.type = BaseTool.TYPE_INSTALL
self.autor = '小鱼'
self.author = '小鱼'

def install_nodejs(self):
CmdTask('sudo apt update && sudo apt install git python3-venv -y', os_command=True).run()
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_install_nodejs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Tool(BaseTool):
def __init__(self):
self.name = "一键安装nodejs并配置环境"
self.type = BaseTool.TYPE_INSTALL
self.autor = '小鱼'
self.author = '小鱼'

def install_nodejs(self):
PrintUtils.print_info("开始根据系统架构,为你下载对应版本的nodejs~")
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_install_proxy_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Tool(BaseTool):
def __init__(self):
self.name = "一键安装 Linux 代理科学上网工具"
self.type = BaseTool.TYPE_INSTALL
self.autor = '小鱼'
self.author = '小鱼'

# def install_docker(self):
# """安装Docker"""
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_install_qq.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Tool(BaseTool):
def __init__(self):
self.type = BaseTool.TYPE_INSTALL
self.name = "一键安装QQ"
self.autor = '五柳小生'
self.author = '五柳小生'

def install_qq(self):
PrintUtils.print_info("开始根据系统架构,为你下载对应版本的QQ~")
Expand Down
4 changes: 2 additions & 2 deletions tools/tool_install_ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class Tool(BaseTool):
def __init__(self):
self.name = "一键安装ROS和ROS2,支持树莓派Jetson"
self.type = BaseTool.TYPE_INSTALL
self.autor = '小鱼'
self.author = '小鱼'


def get_mirror_by_code(self,code,arch='amd64',first_choose="tsinghua"):
Expand Down Expand Up @@ -214,7 +214,7 @@ def check_sys_source(self):
PrintUtils.print_warn("=========接下来这一步很很很很重要,如果不知道怎么选请选择1========")
code,result = ChooseTask(dic, "新手或首次安装一定要一定要一定要换源并清理三方源,换源!!!系统默认国外源容易失败!!").run()
if code==1:
tool = run_tool_file('tools.tool_config_system_source',autorun=False)
tool = run_tool_file('tools.tool_config_system_source',authorun=False)
tool.change_sys_source()

def get_all_instsll_ros_pkgs(self):
Expand Down
4 changes: 2 additions & 2 deletions tools/tool_install_ros1_systemdefault.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Tool(BaseTool):
def __init__(self):
self.type = BaseTool.TYPE_INSTALL
self.name = "一键安装系统自带ROS,仅在Ubuntu 22.04 及以上版本系统中使用。"
self.autor = 'Elysia'
self.author = 'Elysia'
PrintUtils.print_warn("警告!!此工具安装的ROS与从ROS官方软件源安装的ROS冲突!")

def run(self):
Expand All @@ -23,7 +23,7 @@ def check_sys_source(self):
PrintUtils.print_warn("=========接下来这一步很很很很重要,如果不知道怎么选请选择1========")
code,result = ChooseTask(dic, "新手或首次安装一定要一定要一定要换源并清理三方源,换源!!!系统默认国外源容易失败!!").run()
if code==1:
tool = run_tool_file('tools.tool_config_system_source',autorun=False)
tool = run_tool_file('tools.tool_config_system_source',authorun=False)
tool.change_sys_source()

def install_system_ros(self):
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 @@ -92,7 +92,7 @@ class Tool(BaseTool):
def __init__(self):
self.name = "一键安装ROS-Docker版,支持所有版本ROS"
self.type = BaseTool.TYPE_INSTALL
self.autor = '小鱼'
self.author = '小鱼'

def get_container_scripts(self, name, rosversion, delete_file):
delete_command = "sudo rm -rf {}".format(delete_file)
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_install_vscode.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Tool(BaseTool):
def __init__(self):
self.name = "一键安装Vscode"
self.type = BaseTool.TYPE_INSTALL
self.autor = '小鱼'
self.author = '小鱼'

def install_vscode(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_install_wechat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Tool(BaseTool):
def __init__(self):
self.name = "一键安装微信"
self.type = BaseTool.TYPE_INSTALL
self.autor = '小鱼'
self.author = '小鱼'

def get_wechat_scripts(self,name,build):
return """xhost +local: >> /dev/null
Expand Down
2 changes: 1 addition & 1 deletion tools/tool_test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Tool(BaseTool):
def __init__(self):
self.name = "模板工程-以安装nodejs为栗子"
self.type = BaseTool.TYPE_INSTALL
self.autor = '小鱼'
self.author = '小鱼'

def install_nodejs(self):
PrintUtils.print_info("开始根据系统架构,为你下载对应版本的nodejs~")
Expand Down

0 comments on commit 2fc92d6

Please sign in to comment.