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/__init__.py +79 -26
- bcpkgfox/clean.py +257 -0
- bcpkgfox/cli.py +465 -138
- bcpkgfox/find_elements.py +33 -8
- bcpkgfox/get_driver.py +33 -14
- bcpkgfox/invoke_api.py +386 -88
- bcpkgfox/system.py +42 -9
- {bcpkgfox-0.15.30.dist-info → bcpkgfox-0.17.7.dist-info}/METADATA +20 -4
- bcpkgfox-0.17.7.dist-info/RECORD +12 -0
- {bcpkgfox-0.15.30.dist-info → bcpkgfox-0.17.7.dist-info}/WHEEL +1 -1
- bcpkgfox-0.17.7.dist-info/entry_points.txt +22 -0
- bcpkgfox/cli 2.py +0 -536
- bcpkgfox/cli copy 2.py +0 -237
- bcpkgfox/cli copy.py +0 -306
- bcpkgfox/cli2.py +0 -303
- bcpkgfox/dasdad.py +0 -68
- bcpkgfox/exec_file copy 2.py +0 -100
- bcpkgfox/exec_file copy.py +0 -99
- bcpkgfox/exec_file.py +0 -100
- bcpkgfox-0.15.30.dist-info/RECORD +0 -19
- bcpkgfox-0.15.30.dist-info/entry_points.txt +0 -2
- {bcpkgfox-0.15.30.dist-info → bcpkgfox-0.17.7.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[console_scripts]
|
|
2
|
+
bc = bcpkgfox.cli:main
|
|
3
|
+
bc-clean = bcpkgfox.clean_main:main
|
|
4
|
+
bc_clean = bcpkgfox.clean_main:main
|
|
5
|
+
bcc = bcpkgfox.clean_main:main
|
|
6
|
+
bcclaen = bcpkgfox.clean_main:main
|
|
7
|
+
bcclean = bcpkgfox.clean_main:main
|
|
8
|
+
bccleanfox = bcpkgfox.clean_main:main
|
|
9
|
+
bcclen = bcpkgfox.clean_main:main
|
|
10
|
+
bcfox = bcpkgfox.cli:main
|
|
11
|
+
bcpkffox = bcpkgfox.cli:main
|
|
12
|
+
bcpkfox = bcpkgfox.cli:main
|
|
13
|
+
bcpkg = bcpkgfox.cli:main
|
|
14
|
+
bcpkgfox = bcpkgfox.cli:main
|
|
15
|
+
bcpkhfox = bcpkgfox.cli:main
|
|
16
|
+
bpckgofx = bcpkgfox.cli:main
|
|
17
|
+
bpkg = bcpkgfox.cli:main
|
|
18
|
+
cleanbc = bcpkgfox.clean_main:main
|
|
19
|
+
cleanfox = bcpkgfox.clean_main:main
|
|
20
|
+
fox = bcpkgfox.cli:main
|
|
21
|
+
pkg = bcpkgfox.cli:main
|
|
22
|
+
pkgfox = bcpkgfox.cli:main
|
bcpkgfox/cli 2.py
DELETED
|
@@ -1,536 +0,0 @@
|
|
|
1
|
-
import subprocess
|
|
2
|
-
import threading
|
|
3
|
-
import argparse
|
|
4
|
-
import shutil
|
|
5
|
-
import math
|
|
6
|
-
import time
|
|
7
|
-
import sys
|
|
8
|
-
import re
|
|
9
|
-
import os
|
|
10
|
-
|
|
11
|
-
class cli:
|
|
12
|
-
def __init__(self):
|
|
13
|
-
self.current_dir = os.getcwd()
|
|
14
|
-
|
|
15
|
-
self.visuals = self.visual(self)
|
|
16
|
-
self.exec_gen = self.exec_gen_(self)
|
|
17
|
-
self.find_imports = self.find_import(self)
|
|
18
|
-
self.venv_managment = self.venv_mangt(self)
|
|
19
|
-
self.file = None
|
|
20
|
-
|
|
21
|
-
self.parser = argparse.ArgumentParser(
|
|
22
|
-
add_help=False
|
|
23
|
-
)
|
|
24
|
-
self._setup_arguments()
|
|
25
|
-
|
|
26
|
-
def _setup_arguments(self):
|
|
27
|
-
"""Configure all CLI arguments"""
|
|
28
|
-
venv_group = self.parser.add_argument_group('virtual environment options')
|
|
29
|
-
venv_group.add_argument(
|
|
30
|
-
'-v', '--venv',
|
|
31
|
-
action='store_true',
|
|
32
|
-
help="Creates a virtual environment with all dependencies installed"
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
venv_group.add_argument(
|
|
36
|
-
'-vc', '--venv-clean',
|
|
37
|
-
action='store_true',
|
|
38
|
-
help="Creates a virtual environment without dependencies"
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
venv_group.add_argument(
|
|
42
|
-
'-rv', '--recreate-venv',
|
|
43
|
-
action='store_true',
|
|
44
|
-
help="Recreates venv (without dependencies)"
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
venv_group.add_argument(
|
|
48
|
-
'-dv', '--delete-venv',
|
|
49
|
-
action='store_true',
|
|
50
|
-
help="Deletes venv"
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
self.parser.add_argument(
|
|
54
|
-
'-fi', '--find-imports',
|
|
55
|
-
action='store_true',
|
|
56
|
-
help="Finds all imports necessary for the lib to work"
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
self.parser.add_argument(
|
|
60
|
-
'filename',
|
|
61
|
-
type=str,
|
|
62
|
-
nargs='?',
|
|
63
|
-
help="Input file to process"
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
self.parser.add_argument(
|
|
67
|
-
'-h', '--help',
|
|
68
|
-
action='help',
|
|
69
|
-
default=argparse.SUPPRESS,
|
|
70
|
-
help="Salveeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
def execute(self):
|
|
74
|
-
"""Main execution point"""
|
|
75
|
-
args = self.parser.parse_args()
|
|
76
|
-
|
|
77
|
-
if args.venv:
|
|
78
|
-
self.venv_manager.main()
|
|
79
|
-
elif args.venv_clean:
|
|
80
|
-
self.venv_manager.create_venv()
|
|
81
|
-
elif args.recreate_venv:
|
|
82
|
-
self.venv_manager.recreate_venv()
|
|
83
|
-
elif args.delete_venv:
|
|
84
|
-
self.venv_manager.delete_venv()
|
|
85
|
-
|
|
86
|
-
if args.find_imports:
|
|
87
|
-
self.imports_finder.main()
|
|
88
|
-
|
|
89
|
-
if args.filename:
|
|
90
|
-
self._process_file(args.filename)
|
|
91
|
-
|
|
92
|
-
def clean_terminal(self):
|
|
93
|
-
if self.exec_gen.error == 1 \
|
|
94
|
-
or self.find_imports.error == 1 \
|
|
95
|
-
or self.venv_managment.error == 1:
|
|
96
|
-
print("\033[J", end='', flush=True)
|
|
97
|
-
|
|
98
|
-
if self.exec_gen.descerror: print(f"\n {self.visuals.DK_ORANGE}>{self.visuals.RESET} {self.exec_gen.descerror}")
|
|
99
|
-
if self.find_imports.descerror: print(f"\n {self.visuals.DK_ORANGE}>{self.visuals.RESET} {self.find_imports.descerror}")
|
|
100
|
-
if self.venv_managment.descerror: print(f"\n {self.visuals.DK_ORANGE}>{self.visuals.RESET} {self.venv_managment.descerror}")
|
|
101
|
-
|
|
102
|
-
class visual:
|
|
103
|
-
def __init__(self, self_cli):
|
|
104
|
-
self.cli = self_cli
|
|
105
|
-
|
|
106
|
-
self.DK_ORANGE = "\033[38;5;130m"
|
|
107
|
-
self.ORANGE = "\033[38;5;214m"
|
|
108
|
-
self.RD = "\033[38;5;196m"
|
|
109
|
-
self.GR = "\033[38;5;34m"
|
|
110
|
-
self.RESET = "\033[0m"
|
|
111
|
-
self.bold = "\033[1m"
|
|
112
|
-
|
|
113
|
-
self.hue = 0
|
|
114
|
-
|
|
115
|
-
def hsl_to_rgb(self, h, s, l):
|
|
116
|
-
h = h % 360
|
|
117
|
-
c = (1 - abs(2 * l - 1)) * s
|
|
118
|
-
x = c * (1 - abs((h / 60) % 2 - 1))
|
|
119
|
-
m = l - c / 2
|
|
120
|
-
|
|
121
|
-
if 0 <= h < 60: r, g, b = c, x, 0
|
|
122
|
-
elif 60 <= h < 120: r, g, b = x, c, 0
|
|
123
|
-
elif 120 <= h < 180: r, g, b = 0, c, x
|
|
124
|
-
elif 180 <= h < 240: r, g, b = 0, x, c
|
|
125
|
-
elif 240 <= h < 300: r, g, b = x, 0, c
|
|
126
|
-
elif 300 <= h < 360: r, g, b = c, 0, x
|
|
127
|
-
|
|
128
|
-
r = int((r + m) * 255) ; g = int((g + m) * 255) ; b = int((b + m) * 255)
|
|
129
|
-
return r, g, b
|
|
130
|
-
|
|
131
|
-
def rgb_text(self, text, r, g, b): return f"\033[38;2;{r};{g};{b}m{text}\033[0m"
|
|
132
|
-
|
|
133
|
-
def animate_rgb_text(self, text, delay=0.01):
|
|
134
|
-
r, g, b = self.hsl_to_rgb(self.hue, s=1.0, l=0.5)
|
|
135
|
-
self.hue = (self.hue + 1) % 360
|
|
136
|
-
time.sleep(delay)
|
|
137
|
-
return f" \033[1m{self.rgb_text(text, r, g, b)}\033[0m"
|
|
138
|
-
|
|
139
|
-
class exec_gen_:
|
|
140
|
-
def __init__(self, self_cli):
|
|
141
|
-
self.cli = self_cli
|
|
142
|
-
self.current_dir = self.cli.current_dir
|
|
143
|
-
self.target_file = self.cli.file
|
|
144
|
-
self.error = 0
|
|
145
|
-
self.descerror = ""
|
|
146
|
-
self.visuals = self.cli.visuals
|
|
147
|
-
|
|
148
|
-
def preparations(self):
|
|
149
|
-
self.current_dir = os.getcwd()
|
|
150
|
-
|
|
151
|
-
parser = argparse.ArgumentParser(description="Script to generate .exe and preventing bugs")
|
|
152
|
-
parser.add_argument("file", type=str, help="Put the name of file after the command (with the extension '.py')")
|
|
153
|
-
|
|
154
|
-
# args = parser.parse_args() #TODO
|
|
155
|
-
# self.file_name = args.file #TODO
|
|
156
|
-
# self.target_file = os.path.join(self.current_dir, self.file_name) #TODO
|
|
157
|
-
self.target_file = self.cli.file #FIX
|
|
158
|
-
|
|
159
|
-
if not os.path.exists(self.target_file):
|
|
160
|
-
self.descerror = f"Error: File '{self.target_file}' does not exist."
|
|
161
|
-
self.error = 1
|
|
162
|
-
return
|
|
163
|
-
|
|
164
|
-
def run_pyinstaller(self):
|
|
165
|
-
global process_finished
|
|
166
|
-
|
|
167
|
-
braille_spinner = [
|
|
168
|
-
'\u280B', # ⠋
|
|
169
|
-
'\u2809', # ⠙
|
|
170
|
-
'\u2839', # ⠹
|
|
171
|
-
'\u2838', # ⠸
|
|
172
|
-
'\u283C', # ⠼
|
|
173
|
-
'\u2834', # ⠴
|
|
174
|
-
'\u2826', # ⠦
|
|
175
|
-
'\u2827', # ⠧
|
|
176
|
-
'\u2807', # ⠇
|
|
177
|
-
'\u280F' # ⠏
|
|
178
|
-
]
|
|
179
|
-
|
|
180
|
-
retro_computer_style = [
|
|
181
|
-
'\u23BA', # ⎺
|
|
182
|
-
'\u23BB', # ⎻
|
|
183
|
-
'\u23BC', # ⎼
|
|
184
|
-
'\u23BD', # ⎽
|
|
185
|
-
]
|
|
186
|
-
|
|
187
|
-
def print_footer():
|
|
188
|
-
s = 0
|
|
189
|
-
n = 0
|
|
190
|
-
while not process_finished:
|
|
191
|
-
if s % 10 == 0: n += 1
|
|
192
|
-
if n == len(braille_spinner): n = 0
|
|
193
|
-
|
|
194
|
-
sys.stdout.write(f"\r \033[F\r\033[K\033[E {self.visuals.animate_rgb_text(f" {self.visuals.bold} {braille_spinner[n]} Gerando executável do '{self.target_file}', aguarde finalização. {braille_spinner[n]} {self.visuals.RESET}")} \n\033[F")
|
|
195
|
-
sys.stdout.flush()
|
|
196
|
-
s += 1
|
|
197
|
-
|
|
198
|
-
process_finished = False
|
|
199
|
-
command = ["pyinstaller", self.target_file]
|
|
200
|
-
process = subprocess.Popen(
|
|
201
|
-
command,
|
|
202
|
-
stdout=subprocess.PIPE,
|
|
203
|
-
stderr=subprocess.STDOUT,
|
|
204
|
-
universal_newlines=True,
|
|
205
|
-
bufsize=1
|
|
206
|
-
)
|
|
207
|
-
footer_thread = threading.Thread(target=print_footer)
|
|
208
|
-
footer_thread.start()
|
|
209
|
-
|
|
210
|
-
while True:
|
|
211
|
-
output = process.stdout.readline()
|
|
212
|
-
if output == '' and process.poll() is not None:
|
|
213
|
-
break
|
|
214
|
-
if output:
|
|
215
|
-
sys.stdout.write(f"\033[F\r\033[K{output.strip()}\033[K\n\n")
|
|
216
|
-
sys.stdout.flush()
|
|
217
|
-
|
|
218
|
-
process_finished = True
|
|
219
|
-
footer_thread.join()
|
|
220
|
-
|
|
221
|
-
print(f"\r \033[F\r\033[K\033[f\r\033[K\033[2E{self.visuals.bold}{self.visuals.DK_ORANGE}>{self.visuals.RESET}{self.visuals.bold} Executável gerado com sucesso!\n{self.visuals.RESET}\033[3E")
|
|
222
|
-
|
|
223
|
-
def main(self):
|
|
224
|
-
script = self.cli.exec_gen
|
|
225
|
-
script.preparations()
|
|
226
|
-
script.run_pyinstaller()
|
|
227
|
-
|
|
228
|
-
class find_import:
|
|
229
|
-
def __init__(self, self_cli):
|
|
230
|
-
self.cli = self_cli
|
|
231
|
-
self.visuals = self.cli.visuals
|
|
232
|
-
|
|
233
|
-
self.error = 0
|
|
234
|
-
self.descerror = ""
|
|
235
|
-
|
|
236
|
-
self.imports = None
|
|
237
|
-
|
|
238
|
-
def hsl_to_rgb(self, h, s, l):
|
|
239
|
-
h = h % 360
|
|
240
|
-
c = (1 - abs(2 * l - 1)) * s
|
|
241
|
-
x = c * (1 - abs((h / 60) % 2 - 1))
|
|
242
|
-
m = l - c / 2
|
|
243
|
-
|
|
244
|
-
if 0 <= h < 60: r, g, b = c, x, 0
|
|
245
|
-
elif 60 <= h < 120: r, g, b = x, c, 0
|
|
246
|
-
elif 120 <= h < 180: r, g, b = 0, c, x
|
|
247
|
-
elif 180 <= h < 240: r, g, b = 0, x, c
|
|
248
|
-
elif 240 <= h < 300: r, g, b = x, 0, c
|
|
249
|
-
elif 300 <= h < 360: r, g, b = c, 0, x
|
|
250
|
-
|
|
251
|
-
r = int((r + m) * 255) ; g = int((g + m) * 255) ; b = int((b + m) * 255)
|
|
252
|
-
return r, g, b
|
|
253
|
-
|
|
254
|
-
def rgb_text(self, text, r, g, b): return f"\033[38;2;{r};{g};{b}m{text}\033[0m"
|
|
255
|
-
|
|
256
|
-
def animate_rgb_text(self, text, delay=0.01):
|
|
257
|
-
import time
|
|
258
|
-
from bcpkgfox import DK_ORANGE
|
|
259
|
-
hue = 0
|
|
260
|
-
print(f" {DK_ORANGE}>{self.visuals.RESET} Dependências do arquivo {self.visuals.DK_ORANGE}'{self.target_file}'{self.visuals.RESET} identificadas com sucesso")
|
|
261
|
-
time.sleep(2)
|
|
262
|
-
print(f"{DK_ORANGE} PIP:{self.visuals.RESET}\n\n\033[s")
|
|
263
|
-
while True:
|
|
264
|
-
r, g, b = self.hsl_to_rgb(hue, s=1.0, l=0.5)
|
|
265
|
-
terminal_width = shutil.get_terminal_size().columns
|
|
266
|
-
num_lines = math.floor(len(text) / terminal_width)
|
|
267
|
-
if num_lines == 0: print("\033[1B", end="\r")
|
|
268
|
-
print(f"\033[{num_lines}A\033[0J {DK_ORANGE}---> \033[1m{self.rgb_text(text, r, g, b)}\033[0m (CTRL + C)", end="\r")
|
|
269
|
-
hue = (hue + 1) % 360
|
|
270
|
-
time.sleep(delay)
|
|
271
|
-
|
|
272
|
-
def main(self, return_=False):
|
|
273
|
-
parser = argparse.ArgumentParser(description="A CLI tool to find imports.")
|
|
274
|
-
parser.add_argument("file", type=str, help="The target .py file to process")
|
|
275
|
-
|
|
276
|
-
# args = parser.parse_args() #TODO
|
|
277
|
-
# self.file_name = args.file #TODO
|
|
278
|
-
# self.target_file = os.path.join(self.current_dir, self.file_name) #TODO
|
|
279
|
-
self.target_file = self.cli.file #FIX
|
|
280
|
-
|
|
281
|
-
if not os.path.exists(self.target_file):
|
|
282
|
-
self.descerror = f"Error: File '{self.target_file}' does not exist."
|
|
283
|
-
self.error = 1
|
|
284
|
-
return
|
|
285
|
-
|
|
286
|
-
try:
|
|
287
|
-
with open(self.target_file, "r", encoding="utf-8", errors="replace") as file:
|
|
288
|
-
file_content = file.read()
|
|
289
|
-
except Exception as e:
|
|
290
|
-
print(f"Error reading file: {e}")
|
|
291
|
-
return
|
|
292
|
-
|
|
293
|
-
if not file_content:
|
|
294
|
-
print(f"Erro: Não foi possível ler o arquivo '{self.target_file}' com nenhuma codificação testada.")
|
|
295
|
-
return
|
|
296
|
-
|
|
297
|
-
self.imports = []
|
|
298
|
-
import_data = {
|
|
299
|
-
"extract_pdf": "PyMuPDF",
|
|
300
|
-
"import requests": "requests",
|
|
301
|
-
"import pyautogui": "pyautogui",
|
|
302
|
-
"import cv2": "opencv-python",
|
|
303
|
-
"from PIL": "Pillow",
|
|
304
|
-
"from reportlab.lib import utils": "reportlab",
|
|
305
|
-
"from PyPDF2 import PdfMerger": "PyPDF2",
|
|
306
|
-
"import PyPDF2": "PyPDF2",
|
|
307
|
-
"invoke_api_": "requests",
|
|
308
|
-
"wait_for": "pygetwindow",
|
|
309
|
-
"from selenium_stealth import stealth": "selenium-stealth",
|
|
310
|
-
"import undetected_chromedriver": "undetected-chromedriver",
|
|
311
|
-
"from webdriver_manager.chrome import ChromeDriverManager": "webdriver-manager",
|
|
312
|
-
"move_to_image": ["pyscreeze", "pyautogui", "Pillow", "opencv-python"],
|
|
313
|
-
"move_mouse_smoothly": ["pyscreeze", "pyautogui", "Pillow"],
|
|
314
|
-
"initialize_driver": ["webdriver-manager", "undetected-chromedriver", "pyautogui", "psutil"],
|
|
315
|
-
"stealth max": ["webdriver-manager", "undetected-chromedriver", "fake-useragent"]
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
for name, import_name in import_data.items():
|
|
319
|
-
if re.search(fr"\b{name}\b", file_content):
|
|
320
|
-
if isinstance(import_name, list):
|
|
321
|
-
self.imports.extend(import_name)
|
|
322
|
-
else: self.imports.append(import_name)
|
|
323
|
-
|
|
324
|
-
self.imports = list(set(self.imports))
|
|
325
|
-
import pyperclip
|
|
326
|
-
|
|
327
|
-
from bcpkgfox import DK_ORANGE, ORANGE, RESET
|
|
328
|
-
if self.imports:
|
|
329
|
-
if not return_:
|
|
330
|
-
pyperclip.copy(f"pip install {' '.join(self.imports)}")
|
|
331
|
-
|
|
332
|
-
# try: self.animate_rgb_text(f'pip install {" ".join(self.imports)}', delay=0.002)
|
|
333
|
-
text = f"pip install {' '.join(self.imports)}"
|
|
334
|
-
terminal_width = shutil.get_terminal_size().columns
|
|
335
|
-
num_lines = math.floor(len(text) / terminal_width)
|
|
336
|
-
|
|
337
|
-
try: self.animate_rgb_text(text, delay=0.002)
|
|
338
|
-
except KeyboardInterrupt: print(f"\033[{num_lines}A\033[0J {DK_ORANGE}--->{RESET} {ORANGE}pip install {' '.join(self.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")
|
|
339
|
-
else: return self.imports
|
|
340
|
-
else: print("No libraries from the list were found in the script.")
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
class venv_mangt:
|
|
345
|
-
def __init__(self, self_cli):
|
|
346
|
-
self.cli = self_cli
|
|
347
|
-
self.current_dir = self.cli.current_dir
|
|
348
|
-
self.target_file = self.cli.file
|
|
349
|
-
self.error = 0
|
|
350
|
-
self.descerror = ""
|
|
351
|
-
self.visuals = self.cli.visuals
|
|
352
|
-
|
|
353
|
-
def delete_venv(self):
|
|
354
|
-
|
|
355
|
-
braille_spinner = [
|
|
356
|
-
'\u280B',
|
|
357
|
-
'\u2809',
|
|
358
|
-
'\u2839',
|
|
359
|
-
'\u2838',
|
|
360
|
-
'\u283C',
|
|
361
|
-
'\u2834',
|
|
362
|
-
'\u2826',
|
|
363
|
-
'\u2827',
|
|
364
|
-
'\u2807',
|
|
365
|
-
'\u280F'
|
|
366
|
-
]
|
|
367
|
-
|
|
368
|
-
retro_computer_style = [
|
|
369
|
-
'\u23BA', # ⎺
|
|
370
|
-
'\u23BB', # ⎻
|
|
371
|
-
'\u23BC', # ⎼
|
|
372
|
-
'\u23BD', # ⎽
|
|
373
|
-
]
|
|
374
|
-
|
|
375
|
-
process_finished = False
|
|
376
|
-
def print_footer():
|
|
377
|
-
s = 0
|
|
378
|
-
n = 0
|
|
379
|
-
while not process_finished:
|
|
380
|
-
if s % 10 == 0: n += 1
|
|
381
|
-
if n == len(braille_spinner): n = 0
|
|
382
|
-
|
|
383
|
-
sys.stdout.write(f"\r \033[F\r\033[K\033[E {self.visuals.animate_rgb_text(f" {self.visuals.bold} {braille_spinner[n]} Deleting virtual environment {braille_spinner[n]} {self.visuals.RESET}")} \n\033[F")
|
|
384
|
-
sys.stdout.flush()
|
|
385
|
-
s += 1
|
|
386
|
-
|
|
387
|
-
footer_thread = threading.Thread(target=print_footer)
|
|
388
|
-
footer_thread.start()
|
|
389
|
-
|
|
390
|
-
if os.path.exists(os.path.join(self.current_dir, ".venv")):
|
|
391
|
-
try:
|
|
392
|
-
shutil.rmtree(".venv")
|
|
393
|
-
except Exception as e:
|
|
394
|
-
print(f"{self.visuals.RD} > Failed to remove venv: {e} {self.visuals.RESET}")
|
|
395
|
-
return False
|
|
396
|
-
process_finished = True
|
|
397
|
-
footer_thread.join()
|
|
398
|
-
|
|
399
|
-
print(f"{self.visuals.bold}{self.visuals.GR} > Oldest virtual environment deleted with sucessfuly {self.visuals.RESET}\n")
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
def create_venv(self):
|
|
403
|
-
|
|
404
|
-
braille_spinner = [
|
|
405
|
-
'\u280B',
|
|
406
|
-
'\u2809',
|
|
407
|
-
'\u2839',
|
|
408
|
-
'\u2838',
|
|
409
|
-
'\u283C',
|
|
410
|
-
'\u2834',
|
|
411
|
-
'\u2826',
|
|
412
|
-
'\u2827',
|
|
413
|
-
'\u2807',
|
|
414
|
-
'\u280F'
|
|
415
|
-
]
|
|
416
|
-
|
|
417
|
-
retro_computer_style = [
|
|
418
|
-
'\u23BA', # ⎺
|
|
419
|
-
'\u23BB', # ⎻
|
|
420
|
-
'\u23BC', # ⎼
|
|
421
|
-
'\u23BD', # ⎽
|
|
422
|
-
]
|
|
423
|
-
|
|
424
|
-
process_finished = False
|
|
425
|
-
def print_footer():
|
|
426
|
-
s = 0
|
|
427
|
-
n = 0
|
|
428
|
-
while not process_finished:
|
|
429
|
-
if s % 10 == 0: n += 1
|
|
430
|
-
if n == len(braille_spinner): n = 0
|
|
431
|
-
|
|
432
|
-
sys.stdout.write(f"\r \033[F\r\033[K\033[E {self.visuals.animate_rgb_text(f" {self.visuals.bold} {braille_spinner[n]} Generating virtual environment {braille_spinner[n]} {self.visuals.RESET}")} \n\033[F")
|
|
433
|
-
sys.stdout.flush()
|
|
434
|
-
s += 1
|
|
435
|
-
|
|
436
|
-
process_finished = False
|
|
437
|
-
command = [sys.executable, '-m', 'venv', ".venv"]
|
|
438
|
-
process = subprocess.Popen(
|
|
439
|
-
command,
|
|
440
|
-
stdout=subprocess.PIPE,
|
|
441
|
-
stderr=subprocess.STDOUT,
|
|
442
|
-
universal_newlines=True,
|
|
443
|
-
bufsize=1
|
|
444
|
-
)
|
|
445
|
-
footer_thread = threading.Thread(target=print_footer)
|
|
446
|
-
footer_thread.start()
|
|
447
|
-
|
|
448
|
-
while True:
|
|
449
|
-
output = process.stdout.readline()
|
|
450
|
-
if output == '' and process.poll() is not None:
|
|
451
|
-
break
|
|
452
|
-
if output:
|
|
453
|
-
sys.stdout.write(f"\033[F\r\033[K{output.strip()}\033[K\n\n")
|
|
454
|
-
sys.stdout.flush()
|
|
455
|
-
|
|
456
|
-
process_finished = True
|
|
457
|
-
footer_thread.join()
|
|
458
|
-
|
|
459
|
-
print(f"{self.visuals.bold}{self.visuals.GR} > Virtual environment created successfully {self.visuals.RESET}", end="\r")
|
|
460
|
-
|
|
461
|
-
def install_imports(self):
|
|
462
|
-
pip_path = os.path.join(".venv", 'Scripts' if os.name == 'nt' else 'bin', 'pip')
|
|
463
|
-
librarys = self.cli.find_imports.main(return_=True)
|
|
464
|
-
|
|
465
|
-
braille_spinner = [
|
|
466
|
-
'\u280B',
|
|
467
|
-
'\u2809',
|
|
468
|
-
'\u2839',
|
|
469
|
-
'\u2838',
|
|
470
|
-
'\u283C',
|
|
471
|
-
'\u2834',
|
|
472
|
-
'\u2826',
|
|
473
|
-
'\u2827',
|
|
474
|
-
'\u2807',
|
|
475
|
-
'\u280F'
|
|
476
|
-
]
|
|
477
|
-
|
|
478
|
-
retro_computer_style = [
|
|
479
|
-
'\u23BA', # ⎺
|
|
480
|
-
'\u23BB', # ⎻
|
|
481
|
-
'\u23BC', # ⎼
|
|
482
|
-
'\u23BD', # ⎽
|
|
483
|
-
]
|
|
484
|
-
|
|
485
|
-
process_finished = False
|
|
486
|
-
def print_footer():
|
|
487
|
-
s = 0
|
|
488
|
-
n = 0
|
|
489
|
-
while not process_finished:
|
|
490
|
-
if s % 10 == 0: n += 1
|
|
491
|
-
if n == len(braille_spinner): n = 0
|
|
492
|
-
|
|
493
|
-
sys.stdout.write(f"\r \033[F\r\033[K\033[E {self.visuals.animate_rgb_text(f" {self.visuals.bold} {braille_spinner[n]} Installing all dependencies {braille_spinner[n]} {self.visuals.RESET}")} \n\033[F")
|
|
494
|
-
sys.stdout.flush()
|
|
495
|
-
s += 1
|
|
496
|
-
|
|
497
|
-
log_animation = threading.Thread(target=print_footer)
|
|
498
|
-
log_animation.start()
|
|
499
|
-
|
|
500
|
-
process_finished = False
|
|
501
|
-
try:
|
|
502
|
-
for lib in librarys:
|
|
503
|
-
result = subprocess.run(
|
|
504
|
-
[pip_path, 'install', lib],
|
|
505
|
-
check=True,
|
|
506
|
-
stdout=subprocess.PIPE,
|
|
507
|
-
stderr=subprocess.PIPE,
|
|
508
|
-
text=True
|
|
509
|
-
)
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
if result.stdout:
|
|
513
|
-
print(f"\033[0J{result.stdout.strip()}\033[0J")
|
|
514
|
-
|
|
515
|
-
except subprocess.CalledProcessError as e:
|
|
516
|
-
print(f"{self.visuals.bold}{self.visuals.RD} Failed to install {lib}: {e.stderr.strip()}{self.visuals.RESET}", end="\r")
|
|
517
|
-
return False
|
|
518
|
-
finally:
|
|
519
|
-
process_finished = True
|
|
520
|
-
log_animation.join()
|
|
521
|
-
print(f" {self.visuals.bold}{self.visuals.GR} > All packges installed with sucessfully {self.visuals.RESET}", end="\r")
|
|
522
|
-
|
|
523
|
-
def recreate_venv(self):
|
|
524
|
-
self.delete_venv()
|
|
525
|
-
self.create_venv()
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
def main(self):
|
|
529
|
-
self.delete_venv()
|
|
530
|
-
self.create_venv()
|
|
531
|
-
self.install_imports()
|
|
532
|
-
|
|
533
|
-
code = cli("bcpkgfox//cli.py")
|
|
534
|
-
code.exec_gen.main()
|
|
535
|
-
code.clean_terminal()
|
|
536
|
-
print()
|