import os from modules import launch_utils import subprocess import sys import shutil workspace_dir = "/mnt/workspace/stable-diffusion-webui" os.chdir(workspace_dir) def check_blacklist(): def download_blacklist(): def aria2(url, filename, d): subprocess.run( ["aria2c", "-c", "-x", "16", "-s", "16", url, "-o", filename, "-d", d], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL ) url = "https://hf-mirror.com/dong625/su/resolve/main/blacklist.txt" file_path = '/mnt/blacklist.txt' if os.path.exists(file_path): os.remove(file_path) aria2(url, "blacklist.txt", "/mnt") download_blacklist() try: with open("/mnt/userinfo.txt", "r") as user_file: user_content = user_file.read().strip() except FileNotFoundError: return False try: with open("/mnt/blacklist.txt", "r") as blacklist_file: blacklist_content = blacklist_file.readlines() except FileNotFoundError: return True for line in blacklist_content: if user_content == line.strip(): return False return True def delete_files_and_folders(): paths = [ "/mnt/Controlnet.py", "/mnt/DefourmDownload.py", "/mnt/AnimatediffDownload.py", "/mnt/Yolo.py", "/mnt/prompt.py", "/mnt/InpaintAnythingDownload.py", "/mnt/prompt_all_in_one.py", "/mnt/PromptLanguage.py", "/mnt/CheckpointDownload.py", "/mnt/LoraDownload.py", "/mnt/ModelDownload.py", "/mnt/workspace/stable-diffusion-webui/models", "/mnt/workspace/stable-diffusion-webui/handrefinerportable-2024.2.12.0-py2.py3-none-any.whl", ] for path in paths: if os.path.exists(path): if os.path.isfile(path): os.remove(path) elif os.path.isdir(path): shutil.rmtree(path) if not check_blacklist(): delete_files_and_folders() print("You have been blocked\n") print("Please contact QQ917724495") sys.exit() args = launch_utils.args python = launch_utils.python git = launch_utils.git index_url = launch_utils.index_url dir_repos = launch_utils.dir_repos commit_hash = launch_utils.commit_hash git_tag = launch_utils.git_tag run = launch_utils.run is_installed = launch_utils.is_installed repo_dir = launch_utils.repo_dir run_pip = launch_utils.run_pip check_run_python = launch_utils.check_run_python git_clone = launch_utils.git_clone git_pull_recursive = launch_utils.git_pull_recursive list_extensions = launch_utils.list_extensions run_extension_installer = launch_utils.run_extension_installer prepare_environment = launch_utils.prepare_environment configure_for_tests = launch_utils.configure_for_tests start = launch_utils.start def main(): if args.dump_sysinfo: filename = launch_utils.dump_sysinfo() print(f"Sysinfo saved as {filename}. Exiting...") exit(0) import requests def get_daily_sentence(types=['a']): params = { 'c': types } response = requests.get("https://v1.hitokoto.cn/", params=params) if response.status_code == 200: data = response.json() return "\033[36m\033[4m" + data["hitokoto"] + "\033[0m" else: return " \033[36m\033[4m静待花开会有时,守得云开见月明\033[0m" daily_sentence = get_daily_sentence(['i',]) print(daily_sentence) def count_execution(): if not os.path.exists("/mnt/count.txt"): with open("/mnt/count.txt", "w") as f: f.write("0") with open("/mnt/count.txt", "r") as f: count = int(f.read()) count += 1 with open("/mnt/count.txt", "w") as f: f.write(str(count)) return count count=count_execution() print(f"这是您在本实例中第{count}次启动SD") launch_utils.startup_timer.record("initial startup") with launch_utils.startup_timer.subcategory("prepare environment"): if not args.skip_prepare_environment: prepare_environment() if args.test_server: configure_for_tests() start() if __name__ == "__main__": main()