NeuroDonu commited on
Commit
c3f79dc
·
verified ·
1 Parent(s): 562b7ac

Delete updater_facefusion.py

Browse files
Files changed (1) hide show
  1. updater_facefusion.py +0 -135
updater_facefusion.py DELETED
@@ -1,135 +0,0 @@
1
- import os
2
- import subprocess
3
- import sys
4
- import locale
5
- import winreg
6
-
7
- def get_available_drives():
8
- drives = []
9
- for drive in range(65, 91): # ASCII коды от A (65) до Z (90)
10
- drive_letter = f"{chr(drive)}:\\"
11
- if os.path.exists(drive_letter):
12
- drives.append(drive_letter)
13
- return drives
14
-
15
- def get_path_for_install():
16
- language = get_system_language()
17
- if not language:
18
- language = input(get_localized_text("en", "choose_language")).strip().lower()
19
- if language not in ["en", "ru"]:
20
- language = "en"
21
-
22
- default_path = "C:\\"
23
- user_input = input(get_localized_text(language, "which_path") + f" ({default_path}): ").strip()
24
-
25
- install_path = user_input if user_input else default_path
26
-
27
- full_path = os.path.join(install_path, 'portablesource')
28
- if not os.path.exists(full_path):
29
- try:
30
- os.makedirs(full_path)
31
- except OSError:
32
- print(get_localized_text(language, "error_creating_directory"))
33
- return get_path_for_install()
34
-
35
- with open(os.path.join(full_path, 'installed.txt'), 'w') as f:
36
- f.write('installed')
37
-
38
- return full_path
39
-
40
- def get_install_path():
41
- drives = get_available_drives()
42
- install_path = None
43
- for drive in drives:
44
- possible_path = os.path.join(drive, 'portablesource', 'installed.txt')
45
- if os.path.exists(possible_path):
46
- install_path = os.path.dirname(possible_path)
47
- return install_path
48
- else:
49
- install_path = get_path_for_install()
50
- return install_path
51
- return install_path
52
-
53
- abs_path = get_install_path()
54
- git = os.path.join(abs_path, "system", "git", "cmd", "git.exe")
55
- ff_obs = os.path.join(abs_path, "sources", "facefusion")
56
- master_path = os.path.join(ff_obs, "master")
57
- python = os.path.join(abs_path, "sources", "facefusion", "venv", "Scripts", "python.exe")
58
-
59
- def run_git_command(args):
60
- subprocess.run([git] + args, check=True)
61
-
62
- def update_branch(branch):
63
- os.chdir(master_path)
64
- run_git_command(['reset', '--hard'])
65
- run_git_command(['checkout', 'master'])
66
- run_git_command(['pull', 'origin', 'master', '--rebase'])
67
-
68
- def start_ff(branch, webcam_mode=False):
69
- path_to_branch = master_path
70
- second_file = os.path.join(path_to_branch, "facefusion.py")
71
-
72
- if webcam_mode:
73
- args = ["run", "--open-browser", "--ui-layouts", "webcam"]
74
- else:
75
- args = ["run"]
76
-
77
- cmd = f'"{python}" "{second_file}" {" ".join(args)}'
78
-
79
- subprocess.run(cmd, shell=True, check=True)
80
-
81
-
82
- def get_localized_text(language, key):
83
- texts = {
84
- "en": {
85
- "choose_action": "Choose an action:",
86
- "update_master": "1. Update to the master branch and start it",
87
- "enter_choice": "Enter the number of the action: ",
88
- "invalid_choice": "Invalid choice, please try again.",
89
- "enable_webcam": "Enable webcam mode? (Y/N): ",
90
- },
91
- "ru": {
92
- "choose_action": "Выберите действие:",
93
- "update_master": "1. Обновить до обычной ветки и запустить ее (master)",
94
- "enter_choice": "Введите номер действия: ",
95
- "invalid_choice": "Неверный выбор, попробуйте снова.",
96
- "enable_webcam": "Включить режим вебкамеры? (Y/N): ",
97
- }
98
- }
99
- return texts[language].get(key, "")
100
-
101
- def get_system_language():
102
- try:
103
- key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Control Panel\International")
104
- language = winreg.QueryValueEx(key, "LocaleName")[0]
105
- winreg.CloseKey(key)
106
- lang_code = language.split('-')[0].lower()
107
- return "ru" if lang_code == "ru" else "en"
108
- except WindowsError:
109
- lang_code = locale.getdefaultlocale()[0].split('_')[0].lower()
110
- return "ru" if lang_code == "ru" else "en"
111
-
112
- def ask_webcam_mode(language):
113
- webcam_choice = input(get_localized_text(language, "enable_webcam")).strip().lower()
114
- return webcam_choice == 'y'
115
-
116
- def facefusion():
117
- language = get_system_language()
118
- if not language:
119
- language = input(get_localized_text("en", "choose_language")).strip().lower()
120
- if language not in ["en", "ru"]:
121
- language = "en"
122
- while True:
123
- print(get_localized_text(language, "choose_action"))
124
- print(get_localized_text(language, "update_master"))
125
- choice = input(get_localized_text(language, "enter_choice")).strip()
126
-
127
- if choice == '1':
128
- update_branch('master')
129
- webcam_mode = ask_webcam_mode(language)
130
- start_ff("master", webcam_mode)
131
- else:
132
- print(get_localized_text(language, "invalid_choice"))
133
-
134
- if __name__ == "__main__":
135
- facefusion()