kenenet 1.2.0__py3-none-any.whl → 1.2.2__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.
- kenenet/__init__.py +22 -28
- {kenenet-1.2.0.dist-info → kenenet-1.2.2.dist-info}/METADATA +1 -1
- kenenet-1.2.2.dist-info/RECORD +5 -0
- kenenet-1.2.0.dist-info/RECORD +0 -5
- {kenenet-1.2.0.dist-info → kenenet-1.2.2.dist-info}/WHEEL +0 -0
- {kenenet-1.2.0.dist-info → kenenet-1.2.2.dist-info}/top_level.txt +0 -0
kenenet/__init__.py
CHANGED
@@ -9,6 +9,10 @@ from zhmiscellany._processing_supportfuncs import _ray_init_thread
|
|
9
9
|
import zhmiscellany.processing
|
10
10
|
import math
|
11
11
|
import pygame
|
12
|
+
import win32gui
|
13
|
+
import win32process
|
14
|
+
import psutil
|
15
|
+
|
12
16
|
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
13
17
|
import io
|
14
18
|
global timings, ospid, debug_mode
|
@@ -183,7 +187,6 @@ def pp(msg='caca', subdir=None, pps=3):
|
|
183
187
|
|
184
188
|
def save_img(img, name=' ', reset=True, file='temp_screenshots', mute=False):
|
185
189
|
global ospid
|
186
|
-
# Ensure target directory exists or is cleaned once
|
187
190
|
if os.path.exists(file):
|
188
191
|
if reset and ospid is None:
|
189
192
|
zhmiscellany.fileio.empty_directory(file)
|
@@ -192,35 +195,13 @@ def save_img(img, name=' ', reset=True, file='temp_screenshots', mute=False):
|
|
192
195
|
quick_print(f'New folder created {file}')
|
193
196
|
zhmiscellany.fileio.create_folder(file)
|
194
197
|
ospid = True
|
195
|
-
|
196
|
-
# Determine caller line number for logging
|
197
198
|
frame = inspect.currentframe().f_back
|
198
199
|
lineno = frame.f_lineno
|
199
|
-
|
200
200
|
if isinstance(img, np.ndarray):
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
raw_name = str(name).strip()
|
206
|
-
safe_name = re.sub(r'[^A-Za-z0-9_-]+', '_', raw_name)
|
207
|
-
timestamp = f'{time.time():.6f}' # more compact timestamp
|
208
|
-
save_name = f"{safe_name}_{timestamp}"
|
209
|
-
|
210
|
-
# Prepare image for saving
|
211
|
-
if is_mask:
|
212
|
-
# Scale mask values [0.0,1.0] to [0,255] grayscale
|
213
|
-
mask_uint8 = (img.squeeze() * 255).clip(0, 255).astype(np.uint8)
|
214
|
-
img_to_save = Image.fromarray(mask_uint8)
|
215
|
-
else:
|
216
|
-
img_to_save = Image.fromarray(img)
|
217
|
-
|
218
|
-
# Save to disk
|
219
|
-
filepath = os.path.join(file, f"{save_name}.png")
|
220
|
-
img_to_save.save(filepath)
|
221
|
-
|
222
|
-
if not mute:
|
223
|
-
quick_print(f'Saved image as {save_name}', lineno)
|
201
|
+
save_name = name + f'{time.time()}'
|
202
|
+
img = Image.fromarray(img)
|
203
|
+
img.save(fr'{file}\{save_name}.png')
|
204
|
+
if not mute: quick_print(f'Saved image as {save_name}', lineno)
|
224
205
|
else:
|
225
206
|
quick_print(f"Your img is not a fucking numpy array you twat, couldn't save {name}", lineno)
|
226
207
|
|
@@ -539,7 +520,20 @@ def time_loop(iterable, cutoff_time=0.1):
|
|
539
520
|
yield item
|
540
521
|
if time.time() > end_time:
|
541
522
|
break
|
542
|
-
|
523
|
+
|
524
|
+
def get_focused_process_name(mute=False):
|
525
|
+
hwnd = win32gui.GetForegroundWindow()
|
526
|
+
if hwnd == 0:
|
527
|
+
return None
|
528
|
+
_, pid = win32process.GetWindowThreadProcessId(hwnd)
|
529
|
+
try:
|
530
|
+
pname = psutil.Process(pid).name()
|
531
|
+
if not mute:
|
532
|
+
quick_print(pname)
|
533
|
+
return pname
|
534
|
+
except psutil.NoSuchProcess:
|
535
|
+
return None
|
536
|
+
|
543
537
|
ct = time_loop
|
544
538
|
|
545
539
|
class k:
|
@@ -0,0 +1,5 @@
|
|
1
|
+
kenenet/__init__.py,sha256=2tr73Q3mzdlD2GR0uU8GZgLuXAEy7PmTvGqCJcSmMz8,21557
|
2
|
+
kenenet-1.2.2.dist-info/METADATA,sha256=UM_pLlbJwXmWQMmuudR9xu5fB-v5XOzLqCI-YhPkBZ8,1693
|
3
|
+
kenenet-1.2.2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
+
kenenet-1.2.2.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
+
kenenet-1.2.2.dist-info/RECORD,,
|
kenenet-1.2.0.dist-info/RECORD
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
kenenet/__init__.py,sha256=oy4f42bfvN-UX-T7r9zViybxIHsGXhGvcTIPqdnTFMo,22026
|
2
|
-
kenenet-1.2.0.dist-info/METADATA,sha256=CqZ5DO_3bxTDMSbtLuBv_11h_Bk_c_X3SZGp6kO0wk8,1693
|
3
|
-
kenenet-1.2.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
-
kenenet-1.2.0.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
-
kenenet-1.2.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|