From ed61de0b108c6b830d38a12ce14903de499f7241 Mon Sep 17 00:00:00 2001 From: xyj <10908227994@qq.com> Date: Thu, 7 Dec 2023 16:07:53 +0800 Subject: [PATCH] update --- conf/common/record.conf | 2 +- bash/git_update.sh => git_update.sh | 4 ++-- src/ceshi.py | 4 ++-- src/tool.py | 14 +++++++++----- 4 files changed, 14 insertions(+), 10 deletions(-) rename bash/git_update.sh => git_update.sh (58%) diff --git a/conf/common/record.conf b/conf/common/record.conf index a616a0f..b817d7f 100644 --- a/conf/common/record.conf +++ b/conf/common/record.conf @@ -1,5 +1,5 @@ [program:record] -directory=/home/pi/lot_manager/src +directory=/home/pi/lot_manager/bash command=/usr/bin/bash record.sh user=pi ;是否随开机自启 或者reload自启动 diff --git a/bash/git_update.sh b/git_update.sh similarity index 58% rename from bash/git_update.sh rename to git_update.sh index 4dcef03..2102445 100644 --- a/bash/git_update.sh +++ b/git_update.sh @@ -3,8 +3,8 @@ set -e # git更新 git pull origin master --force # 配置文件复制到supervisor管理 -cp -r ../conf/common/*.conf /etc/supervisor/conf.d/ -cp -r ../conf/var/$device_name/*.conf /etc/supervisor/conf.d/ +cp -r conf/common/*.conf /etc/supervisor/conf.d/ +cp -r conf/var/$device_name/*.conf /etc/supervisor/conf.d/ # 更新配置文件 supervisorctl reread supervisorctl update diff --git a/src/ceshi.py b/src/ceshi.py index 8fd7255..d746f95 100644 --- a/src/ceshi.py +++ b/src/ceshi.py @@ -7,13 +7,13 @@ def on_connect(client, userdata, flags, rc): global times if rc == 0: # print("连接成功,执行数据推送和本地存储") - subprocess.Popen(['/usr/bin/bash start_data_upload.sh'], shell=True) + subprocess.Popen(['/usr/bin/bash /home/pi/lot_manager/bash/start_data_upload.sh'], shell=True) times = 3 def on_connect_fail(client, userdata): # print("失败,执行本地存储") - subprocess.Popen(['/usr/bin/bash stop_data_upload.sh'], shell=True) + subprocess.Popen(['/usr/bin/bash /home/pi/lot_manager/bash/stop_data_upload.sh'], shell=True) times = 3 diff --git a/src/tool.py b/src/tool.py index 7510830..7b5b031 100644 --- a/src/tool.py +++ b/src/tool.py @@ -8,14 +8,15 @@ mp4_path = '/home/pi/mp4' def push_stream(client): - p = subprocess.Popen(['/bin/bash start_push.sh'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen(['/bin/bash /home/pi/lot_manager/bash/start_push_stream.sh'], shell=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) out, err = p.communicate() output = out.decode('utf-8') client.publish('success', payload=json.dumps(output, ensure_ascii=False), qos=0) def close_stream(client): - p = subprocess.Popen(['/bin/bash stop_push.sh'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen(['/bin/bash /home/pi/lot_manager/bash/stop_push_stream.sh'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() output = out.decode('utf-8') client.publish('success', payload=json.dumps(output, ensure_ascii=False), qos=0) @@ -43,7 +44,10 @@ def get_status(client): def update(client): - p = subprocess.Popen(['/bin/bash update.sh'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.Popen(['/bin/bash /home/pi/lot_manager/git_update.sh'], + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) out, err = p.communicate() output = out.decode('utf-8') client.publish('success', payload=json.dumps(output, ensure_ascii=False), qos=0) @@ -60,7 +64,7 @@ def get_list_record(): def get_record(msg, client): filename = json.loads(msg.payload.decode('utf-8'))["data"] if filename is None or filename == '': - client.publish('error', payload='没有该文件', qos=1) + client.publish('error', payload='没有该文件', qos=0) return files = {filename: open(os.path.join(mp4_path, filename), 'rb'), "Content-Type": "application/octet-stream"} - requests.post("https://shop.lihaink.cn/api/index/upload", files=files) \ No newline at end of file + requests.post("https://shop.lihaink.cn/api/index/upload", files=files)