BBrother commited on
Commit
0914440
1 Parent(s): 2891af0

Update launch.py

Browse files
Files changed (1) hide show
  1. launch.py +23 -0
launch.py CHANGED
@@ -40,6 +40,17 @@ start = launch_utils.start
40
 
41
  util_py_path = '/bushu/ui/repositories/diffusion-stability-stable/ldm/util.py'
42
 
 
 
 
 
 
 
 
 
 
 
 
43
  # 创建主程序函数
44
  def main():
45
  # 创建线程用于实时查找并打印链接
@@ -50,6 +61,18 @@ def main():
50
  # 主程序代码块
51
  # 这里包含了原来在 if __name__ == "__main__": 中的代码
52
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  # 设置标志变量来确定是否执行主程序
54
  run_main = True
55
 
 
40
 
41
  util_py_path = '/bushu/ui/repositories/diffusion-stability-stable/ldm/util.py'
42
 
43
+ # 创建一个将输出同时发送到控制台和日志文件的处理程序
44
+ console_handler = logging.StreamHandler(sys.stdout)
45
+ console_handler.setLevel(logging.INFO)
46
+ formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
47
+ console_handler.setFormatter(formatter)
48
+ logging.getLogger().addHandler(console_handler)
49
+
50
+ # 重定向标准输出和标准错误到日志文件和控制台
51
+ sys.stdout = logging.getLogger().handlers[0].stream
52
+ sys.stderr = logging.getLogger().handlers[0].stream
53
+
54
  # 创建主程序函数
55
  def main():
56
  # 创建线程用于实时查找并打印链接
 
61
  # 主程序代码块
62
  # 这里包含了原来在 if __name__ == "__main__": 中的代码
63
 
64
+ # 创建线程用于实时查找并打印链接
65
+ def find_and_print_links():
66
+ while True:
67
+ line = log_process.stdout.readline()
68
+ if "Public WebUI Colab URL" in line:
69
+ url = line.split("Public WebUI Colab URL: ")[1].strip()
70
+ print(url) # 在控制台中显示链接
71
+ else:
72
+ # 将其他消息记录到日志文件
73
+ log_file.write(line)
74
+ log_file.flush()
75
+
76
  # 设置标志变量来确定是否执行主程序
77
  run_main = True
78