Update SW_run.py
Browse files
SW_run.py
CHANGED
@@ -2,7 +2,7 @@ import subprocess
|
|
2 |
import sys
|
3 |
import logging
|
4 |
import os
|
5 |
-
import binascii
|
6 |
|
7 |
# 检查是否存在 logs_run.txt 文件,如果存在则删除它
|
8 |
log_file = '/bushu/logs_run.txt'
|
@@ -34,17 +34,17 @@ os.chdir('/bushu/ui')
|
|
34 |
try:
|
35 |
# 在 try 块中运行 /bushu/ui/launch.py,并将输出重定向到日志文件
|
36 |
with open(log_file, 'a') as log_file_handle, open(url_file, 'a') as url_file_handle:
|
37 |
-
process = subprocess.Popen(['python', '/bushu/ui/launch.py', '--skip-torch-cuda-test', '--share', '--listen', '--xformers', '--enable-insecure-extension-access',
|
38 |
|
39 |
for line in process.stdout:
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
|
49 |
process.wait()
|
50 |
|
@@ -54,7 +54,7 @@ except subprocess.CalledProcessError as e:
|
|
54 |
except Exception as e:
|
55 |
# 捕获其他异常并记录到日志文件
|
56 |
logging.exception(f"程序发生异常: {e}")
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
2 |
import sys
|
3 |
import logging
|
4 |
import os
|
5 |
+
import binascii # 用于将文本转换为十六进制
|
6 |
|
7 |
# 检查是否存在 logs_run.txt 文件,如果存在则删除它
|
8 |
log_file = '/bushu/logs_run.txt'
|
|
|
34 |
try:
|
35 |
# 在 try 块中运行 /bushu/ui/launch.py,并将输出重定向到日志文件
|
36 |
with open(log_file, 'a') as log_file_handle, open(url_file, 'a') as url_file_handle:
|
37 |
+
process = subprocess.Popen(['python', '/bushu/ui/launch.py', '--skip-torch-cuda-test', '--share', '--listen', '--xformers', '--enable-insecure-extension-access', '--gradio-queue', '--multiple', '--disable-nan-check', '--no-hashing', '--lowram', '--no-half-vae', '--enable-console-prompts', '--opt-split-attention'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
38 |
|
39 |
for line in process.stdout:
|
40 |
+
# 将所有行转换为十六进制并写入 url.txt
|
41 |
+
hex_line = binascii.hexlify(line.encode()).decode()
|
42 |
+
url_file_handle.write(hex_line + '\n')
|
43 |
+
|
44 |
+
# 将同样的十六进制行写入 logs_run.txt
|
45 |
+
log_file_handle.write(hex_line + '\n')
|
46 |
+
|
47 |
+
log_file_handle.flush()
|
48 |
|
49 |
process.wait()
|
50 |
|
|
|
54 |
except Exception as e:
|
55 |
# 捕获其他异常并记录到日志文件
|
56 |
logging.exception(f"程序发生异常: {e}")
|
57 |
+
|
58 |
+
# 最后,关闭日志处理程序,以确保所有日志都被写入到日志文件
|
59 |
+
logging.getLogger().removeHandler(console_handler)
|
60 |
+
console_handler.close()
|