Update nologs.py
Browse files
nologs.py
CHANGED
|
@@ -4,7 +4,7 @@ import logging
|
|
| 4 |
import os
|
| 5 |
|
| 6 |
# 检查是否存在 logs.txt 文件,如果存在则删除它
|
| 7 |
-
log_file = '/
|
| 8 |
if os.path.exists(log_file):
|
| 9 |
os.remove(log_file)
|
| 10 |
|
|
@@ -26,7 +26,7 @@ try:
|
|
| 26 |
# 在try块中运行v2_3.py,并将输出重定向到日志文件
|
| 27 |
print ("开始运行安装文件...")
|
| 28 |
with open(log_file, 'a') as log_file_handle:
|
| 29 |
-
subprocess.run(['python', '
|
| 30 |
except subprocess.CalledProcessError as e:
|
| 31 |
# 捕获异常并记录到日志文件
|
| 32 |
logging.exception(f"程序发生异常: {e}")
|
|
|
|
| 4 |
import os
|
| 5 |
|
| 6 |
# 检查是否存在 logs.txt 文件,如果存在则删除它
|
| 7 |
+
log_file = '/content/logs.txt'
|
| 8 |
if os.path.exists(log_file):
|
| 9 |
os.remove(log_file)
|
| 10 |
|
|
|
|
| 26 |
# 在try块中运行v2_3.py,并将输出重定向到日志文件
|
| 27 |
print ("开始运行安装文件...")
|
| 28 |
with open(log_file, 'a') as log_file_handle:
|
| 29 |
+
subprocess.run(['python', 'BuShu.py'], check=True, stdout=log_file_handle, stderr=subprocess.STDOUT)
|
| 30 |
except subprocess.CalledProcessError as e:
|
| 31 |
# 捕获异常并记录到日志文件
|
| 32 |
logging.exception(f"程序发生异常: {e}")
|