Update app20.py
Browse files
app20.py
CHANGED
@@ -22,6 +22,34 @@ from concurrent.futures import ProcessPoolExecutor
|
|
22 |
import base64
|
23 |
import subprocess
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
def notbook():
|
27 |
os.system("pip install jupyterlab")
|
@@ -45,7 +73,7 @@ _ngrok_token = "2CXyNlT9xGfFoL5ruI6hQV20FNq_7tbmuzS9RtyNTkyEe1J6C"
|
|
45 |
os.system("pip install nvidia-ml-py3")
|
46 |
os.chdir(f"/root/xlab-app-center")
|
47 |
os.system(f"git clone https://openi.pcl.ac.cn/2575044704/stable-diffusion-webui-v1.8.0 /root/xlab-app-center/stable-diffusion-webui")
|
48 |
-
|
49 |
os.system(f"cp /root/xlab-app-center/styles.csv /root/xlab-app-center/stable-diffusion-webui/styles.csv")
|
50 |
os.chdir(f"/root/xlab-app-center/stable-diffusion-webui")
|
51 |
os.system(f"git lfs install")
|
|
|
22 |
import base64
|
23 |
import subprocess
|
24 |
|
25 |
+
import os
|
26 |
+
|
27 |
+
def replace_in_file(file_path, old_str, new_str):
|
28 |
+
with open(file_path, 'r', encoding='utf-8', errors='ignore') as file:
|
29 |
+
content = file.read()
|
30 |
+
|
31 |
+
content = content.replace(old_str, new_str)
|
32 |
+
|
33 |
+
with open(file_path, 'w', encoding='utf-8') as file:
|
34 |
+
file.write(content)
|
35 |
+
|
36 |
+
def traverse_directory(directory_path, old_str1, new_str1, old_str2, new_str2):
|
37 |
+
for root, _, files in os.walk(directory_path):
|
38 |
+
for file_name in files:
|
39 |
+
file_path = os.path.join(root, file_name)
|
40 |
+
replace_in_file(file_path, old_str1, new_str1)
|
41 |
+
replace_in_file(file_path, old_str2, new_str2)
|
42 |
+
|
43 |
+
def git_replace():
|
44 |
+
directory_path = '/root/xlab-app-center/stable-diffusion-webui/modules' # 修改为你要遍历的目录路径
|
45 |
+
old_str1 = 'https://github.com/'
|
46 |
+
new_str1 = 'https://mirror.ghproxy.com/https://github.com/'
|
47 |
+
old_str2 = 'https://raw.githubusercontent.com/'
|
48 |
+
new_str2 = 'https://mirror.ghproxy.com/https://raw.githubusercontent.com/'
|
49 |
+
|
50 |
+
traverse_directory(directory_path, old_str1, new_str1, old_str2, new_str2)
|
51 |
+
print("Replacement completed.")
|
52 |
+
|
53 |
|
54 |
def notbook():
|
55 |
os.system("pip install jupyterlab")
|
|
|
73 |
os.system("pip install nvidia-ml-py3")
|
74 |
os.chdir(f"/root/xlab-app-center")
|
75 |
os.system(f"git clone https://openi.pcl.ac.cn/2575044704/stable-diffusion-webui-v1.8.0 /root/xlab-app-center/stable-diffusion-webui")
|
76 |
+
git_replace()
|
77 |
os.system(f"cp /root/xlab-app-center/styles.csv /root/xlab-app-center/stable-diffusion-webui/styles.csv")
|
78 |
os.chdir(f"/root/xlab-app-center/stable-diffusion-webui")
|
79 |
os.system(f"git lfs install")
|