File size: 2,701 Bytes
e18b047
9aa83d4
 
 
 
f21b6ec
0a3dbed
9aa83d4
e18b047
9aa83d4
e18b047
 
 
 
 
 
 
 
147f081
e18b047
9aa83d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6fe475d
9aa83d4
410c529
 
 
 
 
 
 
 
 
 
 
7452a8e
9aa83d4
 
 
 
 
 
7452a8e
 
 
410c529
 
 
 
 
 
 
 
 
 
 
 
7452a8e
 
9aa83d4
7452a8e
 
 
9aa83d4
7452a8e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# 导入所需的模块
from modules import launch_utils
import os
import subprocess
import threading
import logging
import sys

# 设置启动参数
args = launch_utils.args
args.listen = True
args.xformers = True
args.enable_insecure_extension_access = True
args.theme = "dark"
args.gradio_queue = True
args.multiple = True
args.no_download_sd_model = True
args.share = True
args.share = "/bushu/out_url.txt"

python = launch_utils.python
git = launch_utils.git
index_url = launch_utils.index_url
dir_repos = launch_utils.dir_repos

commit_hash = launch_utils.commit_hash
git_tag = launch_utils.git_tag

run = launch_utils.run
is_installed = launch_utils.is_installed
repo_dir = launch_utils.repo_dir

run_pip = launch_utils.run_pip
check_run_python = launch_utils.check_run_python
git_clone = launch_utils.git_clone
git_pull_recursive = launch_utils.git_pull_recursive
list_extensions = launch_utils.list_extensions
run_extension_installer = launch_utils.run_extension_installer
prepare_environment = launch_utils.prepare_environment
configure_for_tests = launch_utils.configure_for_tests
start = launch_utils.start

util_py_path = '/bushu/ui/repositories/diffusion-stability-stable/ldm/util.py'

# 创建一个将输出同时发送到控制台和日志文件的处理程序
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
console_handler.setFormatter(formatter)
logging.getLogger().addHandler(console_handler)

# 重定向标准输出和标准错误到日志文件和控制台
sys.stdout = logging.getLogger().handlers[0].stream
sys.stderr = logging.getLogger().handlers[0].stream

# 创建主程序函数
def main():
    # 创建线程用于实时查找并打印链接
    link_thread = threading.Thread(target=find_and_print_links)
    link_thread.daemon = True  # 设置为守护线程,程序退出时自动结束
    link_thread.start()

    # 主程序代码块
    # 这里包含了原来在 if __name__ == "__main__": 中的代码

# 创建线程用于实时查找并打印链接
def find_and_print_links():
    while True:
        line = log_process.stdout.readline()
        if "Public WebUI Colab URL" in line:
            url = line.split("Public WebUI Colab URL: ")[1].strip()
            print(url)  # 在控制台中显示链接
        else:
            # 将其他消息记录到日志文件
            log_file.write(line)
            log_file.flush()

# 设置标志变量来确定是否执行主程序
run_main = True

if __name__ == "__main__":
    run_main = True  # 如果直接运行 launch.py,则设置为 True
    main()

# 其他模块导入语句