dong625 commited on
Commit
fed8133
1 Parent(s): bb3df33

Update sd_launch.py

Browse files
Files changed (1) hide show
  1. sd_launch.py +81 -7
sd_launch.py CHANGED
@@ -1,9 +1,83 @@
1
  import os
 
2
 
3
- file_name = "0620.txt"
4
- file_path = "/mnt/workspace/stable-diffusion-webui/" + file_name
5
- if os.path.exists(file_path):
6
- os.remove(file_path)
7
- print("Error")
8
- else:
9
- print("Error")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
+ from modules import launch_utils
3
 
4
+ args = launch_utils.args
5
+ python = launch_utils.python
6
+ git = launch_utils.git
7
+ index_url = launch_utils.index_url
8
+ dir_repos = launch_utils.dir_repos
9
+
10
+ commit_hash = launch_utils.commit_hash
11
+ git_tag = launch_utils.git_tag
12
+
13
+ run = launch_utils.run
14
+ is_installed = launch_utils.is_installed
15
+ repo_dir = launch_utils.repo_dir
16
+
17
+ run_pip = launch_utils.run_pip
18
+ check_run_python = launch_utils.check_run_python
19
+ git_clone = launch_utils.git_clone
20
+ git_pull_recursive = launch_utils.git_pull_recursive
21
+ list_extensions = launch_utils.list_extensions
22
+ run_extension_installer = launch_utils.run_extension_installer
23
+ prepare_environment = launch_utils.prepare_environment
24
+ configure_for_tests = launch_utils.configure_for_tests
25
+ start = launch_utils.start
26
+
27
+
28
+ def main():
29
+ if args.dump_sysinfo:
30
+ filename = launch_utils.dump_sysinfo()
31
+
32
+ print(f"Sysinfo saved as {filename}. Exiting...")
33
+
34
+ exit(0)
35
+
36
+ import requests
37
+ def get_daily_sentence(types=['a']):
38
+ params = {
39
+ 'c': types
40
+ }
41
+ response = requests.get("https://v1.hitokoto.cn/", params=params)
42
+ if response.status_code == 200:
43
+ data = response.json()
44
+ return "\033[36m\033[4m" + data["hitokoto"] + "\033[0m"
45
+ else:
46
+ return " \033[36m\033[4m静待花开会有时,守得云开见月明\033[0m"
47
+ daily_sentence = get_daily_sentence(['i',])
48
+
49
+ def count_execution():
50
+ if not os.path.exists("/mnt/workspace/stable-diffusion-webui/count.txt"):
51
+ with open("/mnt/workspace/stable-diffusion-webui/count.txt", "w") as f:
52
+ f.write("0")
53
+ with open("/mnt/workspace/stable-diffusion-webui/count.txt", "r") as f:
54
+ count = int(f.read())
55
+ count += 1
56
+ with open("/mnt/workspace/stable-diffusion-webui/count.txt", "w") as f:
57
+ f.write(str(count))
58
+ return count
59
+ count=count_execution()
60
+ if(count<6):
61
+ print(f"这是您在本实例中第{count}次启动SD")
62
+ print("👇请往下滑点击蓝色的\033[34m http:\\\\0.0.0.0:6666\033[0m 打开SD界面👇")
63
+ if(count>5):
64
+ print(daily_sentence)
65
+ print(f"这是您在本实例中第{count}次启动SD")
66
+ print("SD服务启动中,如在使用过程中有任何问题,请联系VX:H917724495")
67
+ if os.path.exists("/mnt/workspace/Untitled.ipynb"):
68
+ os.remove("/mnt/workspace/Untitled.ipynb")
69
+ if os.path.exists("/mnt/workspace/不会用点我.jpg"):
70
+ os.remove("/mnt/workspace/不会用点我.jpg")
71
+ launch_utils.startup_timer.record("initial startup")
72
+
73
+ with launch_utils.startup_timer.subcategory("prepare environment"):
74
+ if not args.skip_prepare_environment:
75
+ prepare_environment()
76
+
77
+ if args.test_server:
78
+ configure_for_tests()
79
+
80
+ start()
81
+
82
+ if __name__ == "__main__":
83
+ main()