Update SW_run.py
Browse files
SW_run.py
CHANGED
@@ -5,6 +5,18 @@ import os
|
|
5 |
import binascii # 用于将文本转换为十六进制
|
6 |
import re # 用于正则表达式
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
# 检查是否存在 logs_run.txt 文件,如果存在则删除它
|
9 |
log_file = '/etc/logs_run.txt'
|
10 |
if os.path.exists(log_file):
|
@@ -30,12 +42,12 @@ sys.stdout = logging.getLogger().handlers[0].stream
|
|
30 |
sys.stderr = logging.getLogger().handlers[0].stream
|
31 |
|
32 |
# 更改当前工作目录为 /etc/main
|
33 |
-
os.chdir('/etc/main')
|
34 |
|
35 |
try:
|
36 |
-
# 在 try 块中运行 /etc/main/
|
37 |
with open(log_file, 'a') as log_file_handle, open(url_file, 'a') as url_file_handle:
|
38 |
-
process = subprocess.Popen(['python',
|
39 |
|
40 |
url_pattern = re.compile(r'https?://\S+')
|
41 |
|
|
|
5 |
import binascii # 用于将文本转换为十六进制
|
6 |
import re # 用于正则表达式
|
7 |
|
8 |
+
StartBL = ""
|
9 |
+
|
10 |
+
# 打开并执行txt文件
|
11 |
+
with open('/etc/main/StartBianLiang.txt', 'r') as file:
|
12 |
+
code = file.read()
|
13 |
+
|
14 |
+
# 去除每行开头和结尾的空格、空行等
|
15 |
+
cleaned_code = '\n'.join(line.strip() for line in code.splitlines() if line.strip())
|
16 |
+
|
17 |
+
# 执行干净的代码
|
18 |
+
exec(cleaned_code)
|
19 |
+
|
20 |
# 检查是否存在 logs_run.txt 文件,如果存在则删除它
|
21 |
log_file = '/etc/logs_run.txt'
|
22 |
if os.path.exists(log_file):
|
|
|
42 |
sys.stderr = logging.getLogger().handlers[0].stream
|
43 |
|
44 |
# 更改当前工作目录为 /etc/main
|
45 |
+
os.chdir('/etc/main/')
|
46 |
|
47 |
try:
|
48 |
+
# 在 try 块中运行 /etc/main/webui.py,并将输出重定向到日志文件
|
49 |
with open(log_file, 'a') as log_file_handle, open(url_file, 'a') as url_file_handle:
|
50 |
+
process = subprocess.Popen(['python', {StartBL} ], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
51 |
|
52 |
url_pattern = re.compile(r'https?://\S+')
|
53 |
|