From 25fc43be81ec506792c7ab1496a132c5186b89f3 Mon Sep 17 00:00:00 2001 From: gitea Date: Wed, 31 Jul 2024 11:21:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20ssh=20=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E7=9A=84=E9=83=A8=E5=88=86=20create=5Fplot?= =?UTF-8?q?=20=E5=87=BD=E6=95=B0=E4=B8=AD=E5=A2=9E=E5=8A=A0=20close('all')?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=BE=AA=E7=8E=AF=E7=94=BB=E5=9B=BE?= =?UTF-8?q?=E4=B8=8D=E9=94=80=E6=AF=81=E5=8D=A0=E7=94=A8=E5=86=85=E5=AD=98?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aio/README.md | 5 ++++- aio/code/aio.py | 3 ++- aio/code/automatic_test/do_brake.py | 5 ++--- aio/code/automatic_test/do_current.py | 5 ++--- aio/code/commons/clibs.py | 10 ++++------ 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/aio/README.md b/aio/README.md index 4d1469d..cc40575 100644 --- a/aio/README.md +++ b/aio/README.md @@ -567,7 +567,7 @@ v0.2.0.5(2024/07/31) - 调整代码组织结构,新增模块,将公共函数以及类合并入此 - 将一些常量放入该模块 - 引入logging/concurrent_log_handler模块,并作初始化操作,供其他模块使用,按50M切割,最多保留10份 - - prj_to_xcore函数设置工程名部分重写,修复了多个prj工程可能不能执行的问题 + - prj_to_xcore函数设置工程名部分重写,修复了多个prj工程可能不能执行的问题,并优化输入密码的部分 2. [t_change_ui: openapi.py] - 完全重写了 get_from_id 函数,使更精准 - 在 msg_storage 函数中,增加 logger,保留所有响应消息 @@ -576,10 +576,13 @@ v0.2.0.5(2024/07/31) 3. [t_change_ui: aio.py] - 增加了日志初始化部分 - detect_network 函数中修改重新实例化HR间隔为 4s,对应心跳 + - create_plot 函数中增加 close('all'),解决循环画图不销毁占用内存的问题 4. [t_change_ui: do_brake.py] - 使用一直打开曲线的方法规避解决了 OOM 的问题,同时修改数据处理方式,只取最后 12s + - 优化 ssh 输入密码的部分 5. [t_change_ui: do_current.py] - 保持电流,只取最后 15s + - 优化 ssh 输入密码的部分 6. [t_change_ui: all the part]: 引入 commons 包,并定制了 logging 输出,后续持续优化 diff --git a/aio/code/aio.py b/aio/code/aio.py index 47c8f3e..cb69554 100644 --- a/aio/code/aio.py +++ b/aio/code/aio.py @@ -11,7 +11,7 @@ from data_process import brake, current, iso, wavelogger from automatic_test import do_current, do_brake, btn_functions from durable_action import factory_test from commons import openapi, clibs -from matplotlib.pyplot import rcParams, figure, subplots_adjust +from matplotlib.pyplot import rcParams, figure, subplots_adjust, close from matplotlib import use from pandas import DataFrame, read_excel import logging @@ -230,6 +230,7 @@ class App(customtkinter.CTk): self.flg = 1 self.df_copy = df.copy() self.old_curve = widgits_da['curvesel']['optionmenu'].get() + close('all') _figure = figure(frameon=True, facecolor='#E9E9E9') subplots_adjust(left=0.04, right=0.98, bottom=0.1, top=0.95) diff --git a/aio/code/automatic_test/do_brake.py b/aio/code/automatic_test/do_brake.py index 6a79748..477ff9a 100644 --- a/aio/code/automatic_test/do_brake.py +++ b/aio/code/automatic_test/do_brake.py @@ -161,9 +161,8 @@ def run_rl(path, loadsel, hr, md, config_file, result_dirs, w2t): cmd += f'sudo sed -i "/VelSet/i {_rl_tool}" projects/target/_build/brake/main.mod; ' stdin, stdout, stderr = ssh.exec_command(cmd, get_pty=True) stdin.write('luoshi2019' + '\n') - stdin.flush() - print(stdout.read().decode()) # 必须得输出一下stdout,才能正确执行sudo - print(stderr.read().decode()) # 顺便也执行以下stderr + stdout.read().decode() # 需要read一下才能正常执行 + stderr.read().decode() # 3. reload工程后,pp2main,并且自动模式和上电,最后运行程序 clibs.execution('overview.reload', hr, w2t, tab_name, prj_path=prj_path, tasks=['brake', 'stop0_related']) diff --git a/aio/code/automatic_test/do_current.py b/aio/code/automatic_test/do_current.py index ac528ba..e489a13 100644 --- a/aio/code/automatic_test/do_current.py +++ b/aio/code/automatic_test/do_current.py @@ -280,9 +280,8 @@ def run_rl(path, hr, md, loadsel, w2t): cmd += f'sudo sed -i "/DONOTDELETE/i {condition}" projects/target/_build/current/main.mod' stdin, stdout, stderr = ssh.exec_command(cmd, get_pty=True) stdin.write('luoshi2019' + '\n') - stdin.flush() - print(stdout.read().decode()) # 必须得输出一下stdout,才能正确执行sudo - print(stderr.read().decode()) # 顺便也执行以下stderr + stdout.read().decode() # 需要read一下才能正常执行 + stderr.read().decode() # 2. reload工程后,pp2main,并且自动模式和上电 prj_path = 'target/_build/target.prj' diff --git a/aio/code/commons/clibs.py b/aio/code/commons/clibs.py index 8876185..2fa9c7f 100644 --- a/aio/code/commons/clibs.py +++ b/aio/code/commons/clibs.py @@ -107,18 +107,16 @@ def prj_to_xcore(prj_file): cmd += 'sudo mv /tmp/target/ /home/luoshi/bin/controller/projects/' stdin, stdout, stderr = ssh.exec_command(cmd, get_pty=True) stdin.write('luoshi2019' + '\n') - stdin.flush() - print(stdout.read().decode()) # 必须得输出一下stdout,才能正确执行sudo - print(stderr.read().decode()) # 顺便也执行以下stderr + stdout.read().decode() # 需要read一下才能正常执行 + stderr.read().decode() cmd = 'cd /home/luoshi/bin/controller/; ' cmd += 'sudo chmod -R 755 projects; rm /tmp/*.prj; sudo mv projects/target/_build/*.prj /tmp; cd /tmp; ' cmd += 'prj=($(ls *.prj)); sudo mv ${prj[0]} /home/luoshi/bin/controller/projects/target/_build/target.prj; ' stdin, stdout, stderr = ssh.exec_command(cmd, get_pty=True) stdin.write('luoshi2019' + '\n') - stdin.flush() - print(stdout.read().decode()) # 必须得输出一下stdout,才能正确执行sudo - print(stderr.read().decode()) # 顺便也执行以下stderr + stdout.read().decode() # 需要read一下才能正常执行 + stderr.read().decode() ssh.close()