bcpkgfox 0.15.30__py3-none-any.whl → 0.17.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
bcpkgfox/cli2.py DELETED
@@ -1,303 +0,0 @@
1
- import subprocess
2
- import threading
3
- import argparse
4
- import time
5
- import sys
6
- import re
7
- import os
8
-
9
- class cli:
10
- def __init__(self):
11
- self.current_dir = os.getcwd()
12
-
13
- self.visuals = self.visual(self)
14
- self.exec_gen = self.exec_gen_(self)
15
- self.find_imports = self.find_import(self)
16
-
17
- class visual:
18
- def __init__(self):
19
- self.RESET = "\033[0m"
20
- self.DK_ORANGE = "\033[38;5;130m"
21
- self.Neg = "\033[1m"
22
- self.hue = 0
23
-
24
- def hsl_to_rgb(self, h, s, l):
25
- h = h % 360
26
- c = (1 - abs(2 * l - 1)) * s
27
- x = c * (1 - abs((h / 60) % 2 - 1))
28
- m = l - c / 2
29
-
30
- if 0 <= h < 60: r, g, b = c, x, 0
31
- elif 60 <= h < 120: r, g, b = x, c, 0
32
- elif 120 <= h < 180: r, g, b = 0, c, x
33
- elif 180 <= h < 240: r, g, b = 0, x, c
34
- elif 240 <= h < 300: r, g, b = x, 0, c
35
- elif 300 <= h < 360: r, g, b = c, 0, x
36
-
37
- r = int((r + m) * 255) ; g = int((g + m) * 255) ; b = int((b + m) * 255)
38
- return r, g, b
39
-
40
- def rgb_text(self, text, r, g, b): return f"\033[38;2;{r};{g};{b}m{text}\033[0m"
41
-
42
- def animate_rgb_text(self, text, delay=0.01):
43
- r, g, b = self.hsl_to_rgb(self.hue, s=1.0, l=0.5)
44
- self.hue = (self.hue + 1) % 360
45
- time.sleep(delay)
46
- return f" \033[1m{self.rgb_text(text, r, g, b)}\033[0m"
47
-
48
- class exec_gen_:
49
- def __init__(self, self_cli):
50
- self.cli = self_cli
51
- self.current_dir = None
52
- self.self.target_file = None
53
- self.file_name = None
54
- self.visuals = self.cli.visuals
55
-
56
- def preparations(self):
57
- self.current_dir = os.getcwd()
58
-
59
- parser = argparse.ArgumentParser(description="Script to generate .exe and preventing bugs")
60
- parser.add_argument("file", type=str, help="Put the name of file after the command (with the extension '.py')")
61
-
62
- args = parser.parse_args()
63
- self.file_name = args.file
64
- self.self.target_file = os.path.join(self.current_dir, self.file_name)
65
-
66
- if not os.path.exists(self.self.target_file):
67
- print(f"Error: File '{self.self.target_file}' does not exist.")
68
- return
69
-
70
- def run_pyinstaller(self):
71
- global process_finished
72
-
73
- def print_footer():
74
- """Função que mantém a mensagem 'Aguarde download' na última linha."""
75
- while not process_finished:
76
- sys.stdout.write(f"\r \033[F\r\033[K\033[E {self.visuals.animate_rgb_text(f" {self.visuals.Neg}| Gerando executável do '{self.file_name}', aguarde finalização. |{self.visuals.RESET}")}\n\033[F")
77
- sys.stdout.flush()
78
-
79
- process_finished = False
80
- command = ["pyinstaller", self.self.target_file]
81
- process = subprocess.Popen(
82
- command,
83
- stdout=subprocess.PIPE,
84
- stderr=subprocess.STDOUT,
85
- universal_newlines=True,
86
- bufsize=1
87
- )
88
- footer_thread = threading.Thread(target=print_footer)
89
- footer_thread.start()
90
-
91
- # Lê a saída do PyInstaller em tempo real
92
- while True:
93
- output = process.stdout.readline()
94
- if output == '' and process.poll() is not None:
95
- break
96
- if output:
97
- sys.stdout.write(f"\033[F\r\033[K{output.strip()}\033[K\n\n")
98
- sys.stdout.flush()
99
-
100
- process_finished = True
101
- footer_thread.join()
102
-
103
- print(f"\r \033[F\r\033[K\033[f\r\033[K\033[2E{self.visuals.Neg}{self.visuals.DK_ORANGE}>{self.visuals.RESET}{self.visuals.Neg} Executável gerado com sucesso!\n{self.visuals.RESET}\033[3E")
104
-
105
- def main():
106
- script = exec_gen()
107
- visuals = visual()
108
- script.preparations()
109
- script.run_pyinstaller()
110
-
111
- class find_import:
112
- def __init__(self, self_cli):
113
- self.cli = self_cli
114
- self.visuals = self.cli.visuals
115
-
116
- self.imports = None
117
-
118
- def hsl_to_rgb(self, h, s, l):
119
- h = h % 360
120
- c = (1 - abs(2 * l - 1)) * s
121
- x = c * (1 - abs((h / 60) % 2 - 1))
122
- m = l - c / 2
123
-
124
- if 0 <= h < 60: r, g, b = c, x, 0
125
- elif 60 <= h < 120: r, g, b = x, c, 0
126
- elif 120 <= h < 180: r, g, b = 0, c, x
127
- elif 180 <= h < 240: r, g, b = 0, x, c
128
- elif 240 <= h < 300: r, g, b = x, 0, c
129
- elif 300 <= h < 360: r, g, b = c, 0, x
130
-
131
- r = int((r + m) * 255) ; g = int((g + m) * 255) ; b = int((b + m) * 255)
132
- return r, g, b
133
-
134
- def rgb_text(self, text, r, g, b): return f"\033[38;2;{r};{g};{b}m{text}\033[0m"
135
-
136
- def animate_rgb_text(self, text, delay=0.01):
137
- import time
138
- from bcpkgfox import DK_ORANGE
139
- hue = 0
140
- print(f" {DK_ORANGE}>{self.visuals.RESET} Dependências do arquivo {self.visuals.ORANGE}'{self.target_file}'{self.visuals.RESET} identificadas com sucesso")
141
- time.sleep(2)
142
- print(f"{DK_ORANGE} PIP:{self.visuals.RESET}")
143
- while True:
144
- r, g, b = self.hsl_to_rgb(hue, s=1.0, l=0.5)
145
- print(f" ---> \033[1m{self.rgb_text(text, r, g, b)}\033[0m (CTRL + C)", end="\r")
146
- hue = (hue + 1) % 360
147
- time.sleep(delay)
148
-
149
- def main(self):
150
- current_dir = os.getcwd()
151
-
152
- parser = argparse.ArgumentParser(description="A CLI tool to find imports.")
153
- parser.add_argument("file", type=str, help="The target .py file to process")
154
-
155
- args = parser.parse_args()
156
- self.self.target_file = os.path.join(current_dir, args.file)
157
-
158
- if not os.path.exists(self.target_file):
159
- print(f"Error: File '{self.target_file}' does not exist.")
160
- return
161
-
162
- try:
163
- with open(self.target_file, "r", encoding="utf-8", errors="replace") as file:
164
- file_content = file.read()
165
- except Exception as e:
166
- print(f"Error reading file: {e}")
167
- return
168
-
169
- if not file_content:
170
- print(f"Erro: Não foi possível ler o arquivo '{self.target_file}' com nenhuma codificação testada.")
171
- return
172
-
173
- libraries = [
174
- 'undetected-chromedriver',
175
- 'webdriver-manager',
176
- 'opencv-python',
177
- 'pygetwindow',
178
- 'setuptools',
179
- 'pyscreeze',
180
- 'pyautogui',
181
- 'selenium',
182
- 'requests',
183
- 'PyMuPDF',
184
- 'Pillow',
185
- 'psutil'
186
- ]
187
-
188
- self.imports = []
189
- for lib in libraries:
190
- pattern = rf"\b{re.escape(lib)}\b"
191
- if re.search(pattern, file_content):
192
- self.imports.append(lib)
193
-
194
- dict = {
195
- "extract_pdf": "PyMuPDF"
196
- "import requests": "requests"
197
- "import pyautogui": "pyautogui"
198
- "from PIL import Image": "Pillow"
199
- "from reportlab.lib import utils": "reportlab"
200
- "from PyPDF2 import PdfMerger": "PyPDF2"
201
- "import PyPDF2": "PyPDF2"
202
- "invoke_api_": "requests"
203
- "wait_for": "pygetwindow"
204
- "from selenium_stealth import stealth": "selenium-stealth"
205
- "import undetected_chromedriver": "undetected-chromedriver"
206
- "from webdriver_manager.chrome import ChromeDriverManager": "webdriver-manager"
207
- "move_to_image": ["pyscreeze", "pyautogui", "Pillow", "opencv-python"]
208
- "move_mouse_smoothly": ["pyscreeze", "pyautogui", "Pillow"]
209
- "initialize_driver": ["webdriver-manager", "undetected-chromedriver", "pyautogui", "psutil"]
210
- "stealth max": ["webdriver-manager", "undetected-chromedriver", "fake-useragent"]
211
- }
212
-
213
- for dic in dict.keys:
214
- if re.search(fr"\.{dic}\b", file_content):
215
- self.imports.append(dic.value)
216
-
217
- if re.search(r"\.import requests\b", file_content):
218
- self.imports.append("requests")
219
-
220
- if re.search(r"\.import pyautogui\b", file_content):
221
- self.imports.append("pyautogui")
222
-
223
- if re.search(r"\.from PIL import Image\b", file_content):
224
- self.imports.append("Pillow")
225
-
226
- if re.search(r"\.from reportlab.lib import utils\b", file_content):
227
- self.imports.append("reportlab")
228
-
229
- if re.search(r"\.from PyPDF2 import PdfMerger\b", file_content):
230
- self.imports.append("PyPDF2")
231
-
232
- if re.search(r"\.import PyPDF2\b", file_content):
233
- self.imports.append("PyPDF2")
234
-
235
- if re.search(r"\.invoke_api_\b", file_content):
236
- self.imports.append("requests")
237
-
238
- if re.search(r"\.wait_for\b", file_content):
239
- self.imports.append("pygetwindow")
240
-
241
- if re.search(r"\.from selenium_stealth import stealth\b", file_content):
242
- self.imports.append("selenium-stealth")
243
-
244
- if re.search(r"\.import undetected_chromedriver\b", file_content):
245
- self.imports.append("undetected-chromedriver")
246
-
247
- if re.search(r"\.from webdriver_manager.chrome import ChromeDriverManager\b", file_content):
248
- self.imports.append("webdriver-manager")
249
-
250
- if re.search(r"\.move_to_image\b", file_content):
251
- self.imports.extend(["pyscreeze", "pyautogui", "Pillow", "opencv-python"])
252
-
253
- if re.search(r"\.move_mouse_smoothly\b", file_content):
254
- self.imports.extend(["pyscreeze", "pyautogui", "Pillow"])
255
-
256
- if re.search(r"\.initialize_driver\b", file_content):
257
- self.imports.extend(["webdriver-manager", "undetected-chromedriver", "pyautogui", "psutil"])
258
-
259
- if re.search(r"\.stealth max\b", file_content):
260
- self.imports.extend(["webdriver-manager", "undetected-chromedriver", "fake-useragent"])
261
-
262
- imports = list(set(imports))
263
- import pyperclip
264
- pyperclip.copy(f"pip install {' '.join(imports)}")
265
-
266
- from bcpkgfox import DK_ORANGE, ORANGE, RESET
267
- if imports:
268
-
269
- def print_footer():
270
- """Função que mantém a mensagem 'Aguarde download' na última linha."""
271
- while not process_finished:
272
- sys.stdout.write(f"\r \033[F\r\033[K\033[E {self.visuals.animate_rgb_text(f" {self.visuals.Neg}| Gerando executável do '{self.file_name}', aguarde finalização. |{self.visuals.RESET}")}\n\033[F")
273
- sys.stdout.flush()
274
-
275
- process_finished = False
276
- command = ["pyinstaller", self.self.target_file]
277
- process = subprocess.Popen(
278
- command,
279
- stdout=subprocess.PIPE,
280
- stderr=subprocess.STDOUT,
281
- universal_newlines=True,
282
- bufsize=1
283
- )
284
- footer_thread = threading.Thread(target=print_footer)
285
- footer_thread.start()
286
-
287
- # Lê a saída do PyInstaller em tempo real
288
- while True:
289
- output = process.stdout.readline()
290
- if output == '' and process.poll() is not None:
291
- break
292
- if output:
293
- sys.stdout.write(f"\033[F\r\033[K{output.strip()}\033[K\n\n")
294
- sys.stdout.flush()
295
-
296
- process_finished = True
297
- footer_thread.join()
298
-
299
- print(f"\r \033[F\r\033[K\033[f\r\033[K\033[2E{self.visuals.Neg}{self.visuals.DK_ORANGE}>{self.visuals.RESET}{self.visuals.Neg} Executável gerado com sucesso!\n{self.visuals.RESET}\033[3E")
300
-
301
- try: self.animate_rgb_text(f'pip install {" ".join(imports)}', delay=0.002)
302
- except KeyboardInterrupt: print(f" {DK_ORANGE}--->{RESET} {ORANGE}pip install {' '.join(imports)}{RESET} \n\n {DK_ORANGE}>{RESET} Copiado para sua área de transferencia. \n(obs: só identifica as libs que são pertencentes da bibliotca bcfox) \n")
303
- else: print("No libraries from the list were found in the script.")
bcpkgfox/dasdad.py DELETED
@@ -1,68 +0,0 @@
1
- from selenium.webdriver.remote.webelement import WebElement
2
- from selenium.webdriver.chrome.options import Options
3
- from selenium_stealth import stealth
4
- from typing import Optional
5
-
6
- import undetected_chromedriver as uc
7
-
8
- import random
9
- import sys
10
- import os
11
-
12
- download_dir = "C:\\TMPIMGKIT\\LAST_IMG"
13
-
14
- # Configurações para o Chrome
15
- options = uc.ChromeOptions()
16
- extension_path = "capmonster"
17
- # extensao_caminho = os.path.abspath(extension_path)
18
-
19
- # options = Options()
20
- # options.add_argument(f'--load-extension={extensao_caminho}')
21
- # driver = uc.Chrome(options=options)
22
- print()
23
-
24
-
25
- def resource_path(relative_path):
26
- """ Get absolute path to resource, works for dev and for PyInstaller """
27
- base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
28
- return os.path.join(base_path, relative_path)
29
-
30
- def backcode__dont_use__set_user_agent():
31
- user_agents = [
32
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
33
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36",
34
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36"
35
- ]
36
- return random.choice(user_agents)
37
-
38
- # Alterar o User-Agent
39
- options.add_argument(f"user-agent={backcode__dont_use__set_user_agent()}")
40
-
41
- # Default's
42
- profile = {
43
- 'download.prompt_for_download': False,
44
- 'download.directory_upgrade': True,
45
- 'download.default_directory': download_dir,
46
- }
47
- options.add_experimental_option('prefs', profile)
48
-
49
- # extensao_caminho = resource_path(extension_path)
50
- extensao_caminho = os.path.abspath(extension_path)
51
- # print(extensao_caminho)
52
-
53
- # Configurações para reduzir detecção
54
- options.add_argument('--disable-blink-features=AutomationControlled')
55
- options.add_argument('--start-maximized')
56
- options.add_argument('--no-sandbox')
57
- options.add_argument('--disable-dev-shm-usage')
58
- options.add_argument('--disable-infobars')
59
-
60
- if extension_path:
61
- options.add_argument(f'--load-extension={extensao_caminho}')
62
-
63
- # options.add_argument('--disable-extensions') # Fix: Possibilita ter extensões ou não, nunca influenciou na detecção
64
-
65
- # Inicializar o navegador com undetected_chromedriver
66
- driver = uc.Chrome(options=options, use_subprocess=True)
67
-
68
- driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")
@@ -1,100 +0,0 @@
1
- import subprocess
2
- import threading
3
- import argparse
4
- import time
5
- import sys
6
- import os
7
-
8
- def main():
9
-
10
- class visual():
11
- def __init__(self):
12
- self.RESET = "\033[0m"
13
- self.DK_ORANGE = "\033[38;5;130m"
14
- self.Neg = "\033[1m"
15
- self.hue = 0
16
-
17
- def hsl_to_rgb(self, h, s, l):
18
- h = h % 360
19
- c = (1 - abs(2 * l - 1)) * s
20
- x = c * (1 - abs((h / 60) % 2 - 1))
21
- m = l - c / 2
22
-
23
- if 0 <= h < 60: r, g, b = c, x, 0
24
- elif 60 <= h < 120: r, g, b = x, c, 0
25
- elif 120 <= h < 180: r, g, b = 0, c, x
26
- elif 180 <= h < 240: r, g, b = 0, x, c
27
- elif 240 <= h < 300: r, g, b = x, 0, c
28
- elif 300 <= h < 360: r, g, b = c, 0, x
29
-
30
- r = int((r + m) * 255) ; g = int((g + m) * 255) ; b = int((b + m) * 255)
31
- return r, g, b
32
-
33
- def rgb_text(self, text, r, g, b): return f"\033[38;2;{r};{g};{b}m{text}\033[0m"
34
-
35
- def animate_rgb_text(self, text, delay=0.01):
36
- r, g, b = self.hsl_to_rgb(self.hue, s=1.0, l=0.5)
37
- self.hue = (self.hue + 1) % 360
38
- time.sleep(delay)
39
- return f" \033[1m{self.rgb_text(text, r, g, b)}\033[0m"
40
-
41
- class exec_gen():
42
- def __init__(self):
43
- self.current_dir = None
44
- self.target_file = None
45
- self.file_name = None
46
-
47
- def preparations(self):
48
- self.current_dir = os.getcwd()
49
-
50
- parser = argparse.ArgumentParser(description="Script to generate .exe and preventing bugs")
51
- parser.add_argument("file", type=str, help="Put the name of file after the command (with the extension '.py')")
52
-
53
- args = parser.parse_args()
54
- self.file_name = args.file
55
- self.target_file = os.path.join(self.current_dir, self.file_name)
56
-
57
- if not os.path.exists(self.target_file):
58
- print(f"Error: File '{self.target_file}' does not exist.")
59
- return
60
-
61
- def run_pyinstaller(self):
62
- global process_finished
63
-
64
- def print_footer():
65
- """Função que mantém a mensagem 'Aguarde download' na última linha."""
66
- while not process_finished:
67
- sys.stdout.write(f"\r \033[F\r\033[K\033[E {visuals.animate_rgb_text(f" {visuals.Neg}| Gerando executável do '{self.file_name}', aguarde finalização. |{visuals.RESET}")}\n\033[F")
68
- sys.stdout.flush()
69
-
70
- process_finished = False
71
-
72
- command = ["pyinstaller", self.target_file]
73
- process = subprocess.Popen(
74
- command,
75
- stdout=subprocess.PIPE,
76
- stderr=subprocess.STDOUT,
77
- universal_newlines=True,
78
- bufsize=1
79
- )
80
- footer_thread = threading.Thread(target=print_footer)
81
- footer_thread.start()
82
-
83
- # Lê a saída do PyInstaller em tempo real
84
- while True:
85
- output = process.stdout.readline()
86
- if output == '' and process.poll() is not None:
87
- break
88
- if output:
89
- sys.stdout.write(f"\033[F\r\033[K{output.strip()}\033[K\n\n")
90
- sys.stdout.flush()
91
-
92
- process_finished = True
93
- footer_thread.join()
94
-
95
- print(f"\r \033[F\r\033[K\033[f\r\033[K\033[2E{visuals.Neg}{visuals.DK_ORANGE}>{visuals.RESET}{visuals.Neg} Executável gerado com sucesso!\n{visuals.RESET}\033[3E")
96
-
97
- script = exec_gen()
98
- visuals = visual()
99
- script.preparations()
100
- script.run_pyinstaller()
@@ -1,99 +0,0 @@
1
- import subprocess
2
- import threading
3
- import argparse
4
- import time
5
- import sys
6
- import os
7
-
8
- def main():
9
-
10
- class visual():
11
- def __init__(self):
12
- self.RESET = "\033[0m"
13
- self.DK_ORANGE = "\033[38;5;130m"
14
- self.Neg = "\033[1m"
15
- self.hue = 0
16
-
17
- def hsl_to_rgb(self, h, s, l):
18
- h = h % 360
19
- c = (1 - abs(2 * l - 1)) * s
20
- x = c * (1 - abs((h / 60) % 2 - 1))
21
- m = l - c / 2
22
-
23
- if 0 <= h < 60: r, g, b = c, x, 0
24
- elif 60 <= h < 120: r, g, b = x, c, 0
25
- elif 120 <= h < 180: r, g, b = 0, c, x
26
- elif 180 <= h < 240: r, g, b = 0, x, c
27
- elif 240 <= h < 300: r, g, b = x, 0, c
28
- elif 300 <= h < 360: r, g, b = c, 0, x
29
-
30
- r = int((r + m) * 255) ; g = int((g + m) * 255) ; b = int((b + m) * 255)
31
- return r, g, b
32
-
33
- def rgb_text(self, text, r, g, b): return f"\033[38;2;{r};{g};{b}m{text}\033[0m"
34
-
35
- def animate_rgb_text(self, text, delay=0.01):
36
- r, g, b = self.hsl_to_rgb(self.hue, s=1.0, l=0.5)
37
- self.hue = (self.hue + 1) % 360
38
- time.sleep(delay)
39
- return f" \033[1m{self.rgb_text(text, r, g, b)}\033[0m"
40
-
41
- class exec_gen():
42
- def __init__(self):
43
- self.current_dir = None
44
-
45
- def preparations(self):
46
- self.current_dir = os.getcwd()
47
-
48
- parser = argparse.ArgumentParser(description="Script to generate .exe and preventing bugs")
49
- parser.add_argument("file", type=str, help="Put the name of file after the command (with the extension '.py')")
50
-
51
- args = parser.parse_args()
52
- target_file = os.path.join(self.current_dir, args.file)
53
-
54
- if not os.path.exists(target_file):
55
- print(f"Error: File '{target_file}' does not exist.")
56
- return
57
-
58
- def run_pyinstaller(self):
59
- global process_finished
60
-
61
- def print_footer():
62
- """Função que mantém a mensagem 'Aguarde download' na última linha."""
63
- while not process_finished:
64
- sys.stdout.write(f"\r \033[F\r\033[K\033[E {visuals.animate_rgb_text(' Gerando executável do "main.py", aguarde finalização.')}\n\033[F")
65
- sys.stdout.flush()
66
-
67
- process_finished = False
68
-
69
- command = ["pyinstaller", "teste.py"]
70
- process = subprocess.Popen(
71
- command,
72
- stdout=subprocess.PIPE,
73
- stderr=subprocess.STDOUT, # Mescla stdout e stderr
74
- universal_newlines=True,
75
- bufsize=1
76
- )
77
- footer_thread = threading.Thread(target=print_footer)
78
- footer_thread.start()
79
-
80
- # Lê a saída do PyInstaller em tempo real
81
- while True:
82
- output = process.stdout.readline()
83
- if output == '' and process.poll() is not None:
84
- break
85
- if output:
86
- sys.stdout.write(f"\033[F\r\033[K{output.strip()}\n\n")
87
- sys.stdout.flush()
88
-
89
- process_finished = True
90
- footer_thread.join()
91
-
92
- print(f"\r\033[K {visuals.Neg}{visuals.DK_ORANGE}>{visuals.RESET}{visuals.Neg} Executável gerado com sucesso!\n{visuals.RESET}")
93
-
94
- script = exec_gen()
95
- visuals = visual()
96
- # script.preparations()
97
- script.run_pyinstaller()
98
-
99
- main()
bcpkgfox/exec_file.py DELETED
@@ -1,100 +0,0 @@
1
- import subprocess
2
- import threading
3
- import argparse
4
- import time
5
- import sys
6
- import os
7
-
8
- def main():
9
-
10
- class visual():
11
- def __init__(self):
12
- self.RESET = "\033[0m"
13
- self.DK_ORANGE = "\033[38;5;130m"
14
- self.Neg = "\033[1m"
15
- self.hue = 0
16
-
17
- def hsl_to_rgb(self, h, s, l):
18
- h = h % 360
19
- c = (1 - abs(2 * l - 1)) * s
20
- x = c * (1 - abs((h / 60) % 2 - 1))
21
- m = l - c / 2
22
-
23
- if 0 <= h < 60: r, g, b = c, x, 0
24
- elif 60 <= h < 120: r, g, b = x, c, 0
25
- elif 120 <= h < 180: r, g, b = 0, c, x
26
- elif 180 <= h < 240: r, g, b = 0, x, c
27
- elif 240 <= h < 300: r, g, b = x, 0, c
28
- elif 300 <= h < 360: r, g, b = c, 0, x
29
-
30
- r = int((r + m) * 255) ; g = int((g + m) * 255) ; b = int((b + m) * 255)
31
- return r, g, b
32
-
33
- def rgb_text(self, text, r, g, b): return f"\033[38;2;{r};{g};{b}m{text}\033[0m"
34
-
35
- def animate_rgb_text(self, text, delay=0.01):
36
- r, g, b = self.hsl_to_rgb(self.hue, s=1.0, l=0.5)
37
- self.hue = (self.hue + 1) % 360
38
- time.sleep(delay)
39
- return f" \033[1m{self.rgb_text(text, r, g, b)}\033[0m"
40
-
41
- class exec_gen():
42
- def __init__(self):
43
- self.current_dir = None
44
- self.target_file = None
45
- self.file_name = None
46
-
47
- def preparations(self):
48
- self.current_dir = os.getcwd()
49
-
50
- parser = argparse.ArgumentParser(description="Script to generate .exe and preventing bugs")
51
- parser.add_argument("file", type=str, help="Put the name of file after the command (with the extension '.py')")
52
-
53
- args = parser.parse_args()
54
- self.file_name = args.file
55
- self.target_file = os.path.join(self.current_dir, self.file_name)
56
-
57
- if not os.path.exists(self.target_file):
58
- print(f"Error: File '{self.target_file}' does not exist.")
59
- return
60
-
61
- def run_pyinstaller(self):
62
- global process_finished
63
-
64
- def print_footer():
65
- """Função que mantém a mensagem 'Aguarde download' na última linha."""
66
- while not process_finished:
67
- sys.stdout.write(f"\r \033[F\r\033[K\033[E {visuals.animate_rgb_text(f" {visuals.Neg}| Gerando executável do '{self.file_name}', aguarde finalização. |{visuals.RESET}")}\n\033[F")
68
- sys.stdout.flush()
69
-
70
- process_finished = False
71
-
72
- command = ["pyinstaller", self.target_file]
73
- process = subprocess.Popen(
74
- command,
75
- stdout=subprocess.PIPE,
76
- stderr=subprocess.STDOUT,
77
- universal_newlines=True,
78
- bufsize=1
79
- )
80
- footer_thread = threading.Thread(target=print_footer)
81
- footer_thread.start()
82
-
83
- # Lê a saída do PyInstaller em tempo real
84
- while True:
85
- output = process.stdout.readline()
86
- if output == '' and process.poll() is not None:
87
- break
88
- if output:
89
- sys.stdout.write(f"\033[F\r\033[K{output.strip()}\033[K\n\n")
90
- sys.stdout.flush()
91
-
92
- process_finished = True
93
- footer_thread.join()
94
-
95
- print(f"\r \033[F\r\033[K\033[f\r\033[K\033[2E{visuals.Neg}{visuals.DK_ORANGE}>{visuals.RESET}{visuals.Neg} Executável gerado com sucesso!\n{visuals.RESET}\033[3E")
96
-
97
- script = exec_gen()
98
- visuals = visual()
99
- script.preparations()
100
- script.run_pyinstaller()