BBrother commited on
Commit
8932f35
1 Parent(s): a1b43ab

Update “sd_clsa_webui_colab_ipynb”_修复v2_3.py

Browse files
“sd_clsa_webui_colab_ipynb”_修复v2_3.py CHANGED
@@ -188,7 +188,6 @@ for repo_url, destination in extensions_to_clone:
188
  run_git_clone(repo_url, destination)
189
 
190
  # 使用subprocess运行sed命令
191
-
192
  # 定义要执行的sed命令
193
  sed_command_1 = '''/from modules import launch_utils/a\\import os'''
194
  sed_command_2 = '''/prepare_environment()/a\\ os.system(f"sed -i -e 's/stable/dict()))/dict())).cuda()/g' /content/ui/repositories/diffusion-stability-stable/ldm/util.py")'''
@@ -199,10 +198,16 @@ launch_py_path = "/content/ui/launch.py"
199
  util_py_path = "/content/ui/repositories/diffusion-stability-stable/ldm/util.py"
200
  shared_py_path = "/content/ui/modules/shared.py"
201
 
202
- # 执行sed命令
203
- subprocess.run(["sed", "-i", "-e", sed_command_1, launch_py_path])
204
- subprocess.run(["sed", "-i", "-e", sed_command_2, launch_py_path])
205
- subprocess.run(["sed", "-i", "-e", sed_command_3, shared_py_path])
 
 
 
 
 
 
206
 
207
 
208
  # 汉化
 
188
  run_git_clone(repo_url, destination)
189
 
190
  # 使用subprocess运行sed命令
 
191
  # 定义要执行的sed命令
192
  sed_command_1 = '''/from modules import launch_utils/a\\import os'''
193
  sed_command_2 = '''/prepare_environment()/a\\ os.system(f"sed -i -e 's/stable/dict()))/dict())).cuda()/g' /content/ui/repositories/diffusion-stability-stable/ldm/util.py")'''
 
198
  util_py_path = "/content/ui/repositories/diffusion-stability-stable/ldm/util.py"
199
  shared_py_path = "/content/ui/modules/shared.py"
200
 
201
+ # 执行sed命令并捕获异常
202
+ try:
203
+ subprocess.run(["sed", "-i", "-e", sed_command_1, launch_py_path], check=True)
204
+ subprocess.run(["sed", "-i", "-e", sed_command_2, launch_py_path], check=True)
205
+ subprocess.run(["sed", "-i", "-e", sed_command_3, shared_py_path], check=True)
206
+ except subprocess.CalledProcessError as e:
207
+ # 将异常信息写入日志文件
208
+ with open("/content/logs.txt", "a") as log_file:
209
+ log_file.write(f"Error: {e}\n")
210
+
211
 
212
 
213
  # 汉化