From c015a9a641d7a6bf57a6b56a03b724f0be68c53f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B1=BC=E9=A6=99ROS?= Date: Sun, 6 Feb 2022 19:54:20 +0800 Subject: [PATCH] =?UTF-8?q?[fix]:=E4=BF=AE=E5=A4=8Dnodejs=E6=9D=83?= =?UTF-8?q?=E9=99=90=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ install.py | 10 +++++++++- test_tools.py | 0 tools/base.py | 10 ++++++++++ tools/tool_install_nodejs.py | 3 ++- 5 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 test_tools.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd20fdd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +*.pyc diff --git a/install.py b/install.py index bc89476..626dec0 100644 --- a/install.py +++ b/install.py @@ -12,6 +12,7 @@ 4: {'tip':'一键配置:ROS环境(快速更新ROS环境设置,自动生成环境选择)', 'type':2, 'tool':url_prefix+'tools/tool_config_rosenv.py' ,'dep':[] }, 5: {'tip':'一键配置:系统源(更换系统源,支持全版本Ubuntu系统)', 'type':2, 'tool':url_prefix+'tools/tool_config_system_source.py' ,'dep':[] }, 6: {'tip':'一键安装:nodejs开发环境(通过nodejs可以预览小鱼官网噢)', 'type':0, 'tool':url_prefix+'tools/tool_install_nodejs.py' ,'dep':[] }, + 77: {'tip':'测试模式:运行自定义工具测试'}, } @@ -61,8 +62,15 @@ def main(): for tool_id in tools.keys(): choose_dic[tool_id] = tools[tool_id]["tip"] code,result = ChooseTask(choose_dic, "---众多工具,等君来用---").run() if code==0: PrintUtils().print_success("是觉得没有合胃口的菜吗?那快联系的小鱼增加菜单吧~") + elif code==77: + code,result = ChooseTask(choose_dic, "请选择你要测试的程序:").run() + if code<0 and code>=77: return False + # CmdTask("cp tools/* /tmp/fishinstall/tools/").run + run_tool_file(tools[code]['tool'].replace(url_prefix,'').replace("/",".")) + else: download_tools(code,tools) run_tool_file(tools[code]['tool'].replace(url_prefix,'').replace("/",".")) -main() \ No newline at end of file +if __name__=='__main__': + main() \ No newline at end of file diff --git a/test_tools.py b/test_tools.py new file mode 100644 index 0000000..e69de29 diff --git a/tools/base.py b/tools/base.py index 18b1353..ba9bff6 100644 --- a/tools/base.py +++ b/tools/base.py @@ -902,6 +902,16 @@ def getbashrc(): if bashrc_result[0]!=0: bashrc_result = CmdTask("ls /root/.bashrc", 0).run() return bashrc_result[1] + @staticmethod + def getusers(): + """ + 优先home,没有home提供root + """ + users = CmdTask("users", 0).run() + if users[0]!=0: return ['root'] + return users[1] + + @staticmethod def new(path,name=None,data=''): if not os.path.exists(path): diff --git a/tools/tool_install_nodejs.py b/tools/tool_install_nodejs.py index e4a2b54..28e84d3 100644 --- a/tools/tool_install_nodejs.py +++ b/tools/tool_install_nodejs.py @@ -23,10 +23,11 @@ def install_nodejs(self): CmdTask("rm -rf /opt/nodejs/").run() CmdTask("mkdir -p /opt/nodejs/").run() CmdTask("sudo tar -xvf /tmp/nodejs.tar.xz -C /opt/nodejs/").run() + CmdTask("sudo chmod -R 777 /opt/nodejs/").run() CmdTask("rm -rf /tmp/nodejs.tar.xz").run() PrintUtils.print_info("解压完成,接下来为你配置nodejs环境~") # 配置环境 - for bashrc in FileUtils.getbashrc()+['/root/.bashrc']: + for bashrc in FileUtils.getbashrc(): FileUtils.find_replace_sub(bashrc,"# >>> nodejs initialize >>>","# <<< nodejs initialize <<<", "") FileUtils.append(bashrc,"# >>> nodejs initialize >>>\n"+"export PATH=$PATH:/opt/nodejs/node-v16.13.2-linux-x64/bin/"+"\n# <<< nodejs initialize <<<") PrintUtils.print_info("配置完成,接下来你可以尝试使用node和npm指令运行了~")