BBrother commited on
Commit
7452a8e
1 Parent(s): cffe9cc

Update launch.py

Browse files
Files changed (1) hide show
  1. launch.py +10 -40
launch.py CHANGED
@@ -39,51 +39,21 @@ start = launch_utils.start
39
 
40
  util_py_path = '/bushu/ui/repositories/diffusion-stability-stable/ldm/util.py'
41
 
42
- # 打开日志文件以写入程序的所有输出
43
- log_file_path = '/bushu/logs_run.txt'
44
- log_file = open(log_file_path, 'w')
45
-
46
- # 创建一个线程,用于实时查找并打印链接
47
- def find_and_print_links():
48
- while True:
49
- line = log_process.stdout.readline()
50
- if "Public WebUI Colab URL" in line:
51
- url = line.split("Public WebUI Colab URL: ")[1].strip()
52
- print(url) # 在控制台中显示链接
53
- else:
54
- # 将其他消息记录到日志文件
55
- log_file.write(line)
56
- log_file.flush()
57
-
58
- # 使用tee命令将程序的输出同时写入日志文件和进程管道
59
- tee_command = f"{python} -u -m tee -a {log_file_path}"
60
- log_process = subprocess.Popen(tee_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, universal_newlines=True)
61
-
62
  def main():
63
- if not args.skip_prepare_environment:
64
- prepare_environment()
65
- os.system(f"sed -i -e 's/dict()))/dict())).cuda()/g' {util_py_path}")
66
- os.system(f"sed -i -e 's/stable/dict()))/dict())).cuda()/g' /content/ui/repositories/diffusion-stability-stable/ldm/util.py")
67
- os.system(f"sed -i -e 's/dict()))/dict())).cuda()/g' {util_py_path}")
68
- os.system(f"sed -i -e 's/stable/dict()))/dict())).cuda()/g' /content/ui/repositories/diffusion-stability-stable/ldm/util.py")
69
- os.system(f"sed -i -e 's/dict()))/dict())).cuda()/g' {util_py_path}")
70
- os.system(f"sed -i -e 's/stable/dict()))/dict())).cuda()/g' /content/ui/repositories/diffusion-stability-stable/ldm/util.py")
71
-
72
- if args.test_server:
73
- configure_for_tests()
74
-
75
- start()
76
-
77
- if __name__ == "__main__":
78
  # 创建线程用于实时查找并打印链接
79
  link_thread = threading.Thread(target=find_and_print_links)
80
  link_thread.daemon = True # 设置为守护线程,程序退出时自动结束
81
  link_thread.start()
82
 
83
- main()
 
 
 
 
84
 
85
- # 等待程序执行完毕
86
- log_process.wait()
 
87
 
88
- # 关闭日志文件
89
- log_file.close()
 
39
 
40
  util_py_path = '/bushu/ui/repositories/diffusion-stability-stable/ldm/util.py'
41
 
42
+ # 创建主程序函数
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  def main():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  # 创建线程用于实时查找并打印链接
45
  link_thread = threading.Thread(target=find_and_print_links)
46
  link_thread.daemon = True # 设置为守护线程,程序退出时自动结束
47
  link_thread.start()
48
 
49
+ # 主程序代码块
50
+ # 这里包含了原来在 if __name__ == "__main__": 中的代码
51
+
52
+ # 设置标志变量来确定是否执行主程序
53
+ run_main = True
54
 
55
+ if __name__ == "__main__":
56
+ run_main = True # 如果直接运行 launch.py,则设置为 True
57
+ main()
58
 
59
+ # 其他模块导入语句