atomicshop 2.16.33__py3-none-any.whl → 2.16.34__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.
Potentially problematic release.
This version of atomicshop might be problematic. Click here for more details.
- atomicshop/__init__.py +1 -1
- atomicshop/print_api.py +1 -1
- atomicshop/wrappers/loggingw/loggingw.py +23 -31
- atomicshop/wrappers/socketw/get_process.py +1 -9
- {atomicshop-2.16.33.dist-info → atomicshop-2.16.34.dist-info}/METADATA +1 -1
- {atomicshop-2.16.33.dist-info → atomicshop-2.16.34.dist-info}/RECORD +9 -9
- {atomicshop-2.16.33.dist-info → atomicshop-2.16.34.dist-info}/LICENSE.txt +0 -0
- {atomicshop-2.16.33.dist-info → atomicshop-2.16.34.dist-info}/WHEEL +0 -0
- {atomicshop-2.16.33.dist-info → atomicshop-2.16.34.dist-info}/top_level.txt +0 -0
atomicshop/__init__.py
CHANGED
atomicshop/print_api.py
CHANGED
|
@@ -128,7 +128,7 @@ def print_api(
|
|
|
128
128
|
if print_end == '\n':
|
|
129
129
|
if stdcolor and color is not None:
|
|
130
130
|
# Use logger to output message.
|
|
131
|
-
with loggingw.
|
|
131
|
+
with loggingw.temporary_change_logger_stream_record_color(logger, color):
|
|
132
132
|
getattr(logger, logger_method)(message)
|
|
133
133
|
else:
|
|
134
134
|
# Use logger to output message.
|
|
@@ -5,7 +5,7 @@ import datetime
|
|
|
5
5
|
import contextlib
|
|
6
6
|
import threading
|
|
7
7
|
|
|
8
|
-
from . import loggers, handlers
|
|
8
|
+
from . import loggers, handlers, filters
|
|
9
9
|
from ...file_io import csvs
|
|
10
10
|
from ...basics import tracebacks, ansi_escape_codes
|
|
11
11
|
from ... import print_api
|
|
@@ -308,10 +308,10 @@ def find_the_parent_logger_with_stream_handler(logger: logging.Logger) -> loggin
|
|
|
308
308
|
@contextlib.contextmanager
|
|
309
309
|
def _temporary_change_logger_stream_handler_color(logger: logging.Logger, color: str):
|
|
310
310
|
"""
|
|
311
|
-
THIS IS ONLY FOR REFERENCE
|
|
311
|
+
THIS IS ONLY FOR REFERENCE.
|
|
312
|
+
Better use 'temporary_change_logger_stream_record_color', since it is thread safe.
|
|
312
313
|
If there are several threads that use this logger, there could be a problem, since unwanted messages
|
|
313
|
-
could be colored with the color of the other thread.
|
|
314
|
-
safe and will color only the messages from the current thread.
|
|
314
|
+
could be colored with the color of the other thread.
|
|
315
315
|
|
|
316
316
|
Context manager to temporarily change the color of the logger's StreamHandler formatter.
|
|
317
317
|
|
|
@@ -351,13 +351,16 @@ def _temporary_change_logger_stream_handler_color(logger: logging.Logger, color:
|
|
|
351
351
|
# found_stream_handler.removeFilter(color_filter)
|
|
352
352
|
|
|
353
353
|
|
|
354
|
-
# Thread-local storage to store color codes per thread
|
|
355
|
-
thread_local = threading.local()
|
|
356
|
-
|
|
357
|
-
|
|
358
354
|
@contextlib.contextmanager
|
|
359
|
-
def
|
|
360
|
-
"""
|
|
355
|
+
def temporary_change_logger_stream_record_color(logger: logging.Logger, color: str):
|
|
356
|
+
"""
|
|
357
|
+
This function will temporarily change the color of the logger's StreamHandler record message.
|
|
358
|
+
|
|
359
|
+
Example:
|
|
360
|
+
with temporary_change_logger_stream_record_color(logger, "red"):
|
|
361
|
+
# Do something with the temporary color.
|
|
362
|
+
logger.error("This message will be colored with the 'red'.")
|
|
363
|
+
"""
|
|
361
364
|
|
|
362
365
|
# Find the current or the topmost logger's StreamHandler.
|
|
363
366
|
# Could be that it is a child logger inherits its handlers from the parent.
|
|
@@ -369,32 +372,21 @@ def temporary_change_logger_stream_handler_emit_color(logger: logging.Logger, co
|
|
|
369
372
|
found_stream_handler = handler
|
|
370
373
|
break
|
|
371
374
|
|
|
372
|
-
# Save the original
|
|
373
|
-
|
|
375
|
+
# Save the original state of the handler
|
|
376
|
+
# original_filters = found_stream_handler.filters.copy() # To restore the original filters
|
|
374
377
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
if getattr(thread_local, 'color', None):
|
|
379
|
-
record.msg = (
|
|
380
|
-
ansi_escape_codes.get_colors_basic_dict(color) + original_msg +
|
|
381
|
-
ansi_escape_codes.ColorsBasic.END)
|
|
382
|
-
original_emit(record) # Call the original emit method
|
|
383
|
-
record.msg = original_msg # Restore the original message for other handlers
|
|
378
|
+
# Create a thread-specific color filter
|
|
379
|
+
thread_id = threading.get_ident()
|
|
380
|
+
color_filter = filters.ThreadColorLogFilter(color, thread_id)
|
|
384
381
|
|
|
385
|
-
#
|
|
386
|
-
found_stream_handler.
|
|
387
|
-
|
|
388
|
-
# Set the color code in thread-local storage for this thread
|
|
389
|
-
thread_local.color = color
|
|
382
|
+
# Add the filter to the handler
|
|
383
|
+
found_stream_handler.addFilter(color_filter)
|
|
390
384
|
|
|
391
385
|
try:
|
|
392
|
-
yield
|
|
386
|
+
yield # Do the logging within the context
|
|
393
387
|
finally:
|
|
394
|
-
# Restore the original
|
|
395
|
-
found_stream_handler.
|
|
396
|
-
# Clear the color code from thread-local storage
|
|
397
|
-
thread_local.color = None
|
|
388
|
+
# Restore the original filters, ensuring thread safety
|
|
389
|
+
found_stream_handler.removeFilter(color_filter)
|
|
398
390
|
|
|
399
391
|
|
|
400
392
|
class ExceptionCsvLogger:
|
|
@@ -73,20 +73,12 @@ class GetCommandLine:
|
|
|
73
73
|
print_api(
|
|
74
74
|
execution_error, error_type=True, logger_method="error", traceback_string=True,
|
|
75
75
|
**print_kwargs)
|
|
76
|
-
pass
|
|
77
76
|
except psutil.AccessDenied:
|
|
78
77
|
execution_error = f"Access Denied for 'psutil' to read system process command line. " \
|
|
79
78
|
f"Run script with Admin Rights."
|
|
80
79
|
print_api(
|
|
81
80
|
execution_error, error_type=True, logger_method="error", traceback_string=True,
|
|
82
81
|
**print_kwargs)
|
|
83
|
-
pass
|
|
84
|
-
except Exception:
|
|
85
|
-
execution_error = "There was undocumented exception in localhost script execution."
|
|
86
|
-
print_api(
|
|
87
|
-
execution_error, error_type=True, logger_method="error", traceback_string=True,
|
|
88
|
-
**print_kwargs)
|
|
89
|
-
pass
|
|
90
82
|
|
|
91
83
|
if not execution_error:
|
|
92
84
|
# Reading the buffer.
|
|
@@ -97,8 +89,8 @@ class GetCommandLine:
|
|
|
97
89
|
|
|
98
90
|
return process_name
|
|
99
91
|
|
|
92
|
+
@staticmethod
|
|
100
93
|
def get_commandline_and_error(
|
|
101
|
-
self,
|
|
102
94
|
execution_output,
|
|
103
95
|
execution_error,
|
|
104
96
|
print_kwargs: dict = None
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
atomicshop/__init__.py,sha256=
|
|
1
|
+
atomicshop/__init__.py,sha256=CBAptMUJXJVgtdUNjx4iw5nayaXCSZahEQHtGmfl1oM,124
|
|
2
2
|
atomicshop/_basics_temp.py,sha256=6cu2dd6r2dLrd1BRNcVDKTHlsHs_26Gpw8QS6v32lQ0,3699
|
|
3
3
|
atomicshop/_create_pdf_demo.py,sha256=Yi-PGZuMg0RKvQmLqVeLIZYadqEZwUm-4A9JxBl_vYA,3713
|
|
4
4
|
atomicshop/_patch_import.py,sha256=ENp55sKVJ0e6-4lBvZnpz9PQCt3Otbur7F6aXDlyje4,6334
|
|
@@ -25,7 +25,7 @@ atomicshop/ip_addresses.py,sha256=Hvi4TumEFoTEpKWaq5WNF-YzcRzt24IxmNgv-Mgax1s,11
|
|
|
25
25
|
atomicshop/keyboard_press.py,sha256=1W5kRtOB75fulVx-uF2yarBhW0_IzdI1k73AnvXstk0,452
|
|
26
26
|
atomicshop/on_exit.py,sha256=Rpg2SaF0aginuO7JYwA49YJYnS8F6K2jUqhjH65WzuU,6889
|
|
27
27
|
atomicshop/pbtkmultifile_argparse.py,sha256=aEk8nhvoQVu-xyfZosK3ma17CwIgOjzO1erXXdjwtS4,4574
|
|
28
|
-
atomicshop/print_api.py,sha256=
|
|
28
|
+
atomicshop/print_api.py,sha256=q9dAQCASk3pHp_PtYIpr6iZmRcW_lvrV_gPPNwTMRsw,11152
|
|
29
29
|
atomicshop/process.py,sha256=PeLvyixXaCfftdUF3oMbohI1L4MdLtvQVDx2V1Tz_Rk,16662
|
|
30
30
|
atomicshop/python_file_patcher.py,sha256=-uhbUX-um5k-If_XXuOfCr8wMzZ3QE6h9N8xGWw6W_o,5486
|
|
31
31
|
atomicshop/python_functions.py,sha256=zJg4ogUwECxrDD7xdDN5JikIUctITM5lsyabr_ZNsRw,4435
|
|
@@ -250,7 +250,7 @@ atomicshop/wrappers/loggingw/filters.py,sha256=48UVhJHemCS0agXmQP8dHvAHM8r9DFphJ
|
|
|
250
250
|
atomicshop/wrappers/loggingw/formatters.py,sha256=ZY12IokVY1G_Wzn2Zlv9qjK-e8CtIK6yUgUfPHvH2BU,5802
|
|
251
251
|
atomicshop/wrappers/loggingw/handlers.py,sha256=vxaSSnlJGs9NKJvYROKtNjaFTqePdHy0sz-GwN5aNPw,19035
|
|
252
252
|
atomicshop/wrappers/loggingw/loggers.py,sha256=mmM__XR3W4QC82wbsDRG_M4_0JYGGEP0Qn0WCOSp-go,2910
|
|
253
|
-
atomicshop/wrappers/loggingw/loggingw.py,sha256=
|
|
253
|
+
atomicshop/wrappers/loggingw/loggingw.py,sha256=uLY7DJS-3xIYQBRvI--9eFvdcnvsWSXmtJKS-gTRfjM,20863
|
|
254
254
|
atomicshop/wrappers/loggingw/reading.py,sha256=sCNlgqLNH5XdKqOOjjEox7CvViMHzs6h7-hwCnx4NKk,17566
|
|
255
255
|
atomicshop/wrappers/mongodbw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
256
256
|
atomicshop/wrappers/mongodbw/install_mongodb.py,sha256=3ZPqrXxj3lC-PnAKGXclylLuOqsbyXYeUpb5iGjdeUU,6626
|
|
@@ -299,7 +299,7 @@ atomicshop/wrappers/socketw/certificator.py,sha256=3CpQKtcW68FSbH6LVSEZTqWBS6Yg_
|
|
|
299
299
|
atomicshop/wrappers/socketw/creator.py,sha256=3_OraDkw2DAWZfoSdY3svCGMOIxpjLEEY7NxWd7M5P4,9873
|
|
300
300
|
atomicshop/wrappers/socketw/dns_server.py,sha256=VHV6s7vd0zqqW3dhE6li-260YRzmEB5ZUXqYJ9p0vVA,49069
|
|
301
301
|
atomicshop/wrappers/socketw/exception_wrapper.py,sha256=B-X5SHLSUIWToihH2MKnOB1F4A81_X0DpLLfnYKYbEc,7067
|
|
302
|
-
atomicshop/wrappers/socketw/get_process.py,sha256=
|
|
302
|
+
atomicshop/wrappers/socketw/get_process.py,sha256=aJC-_qFUv3NgWCSUzDI72E4z8_-VTZE9NVZ0CwUoNlM,5698
|
|
303
303
|
atomicshop/wrappers/socketw/receiver.py,sha256=XVvWOoeCo3vA0O5p19ryi-hcDIyx382WNG7WzMNVeYk,9322
|
|
304
304
|
atomicshop/wrappers/socketw/sender.py,sha256=5HPrgTS2pA1g-jbG1TUtR7drHT1Z_8UevlRCTwW7dgY,5007
|
|
305
305
|
atomicshop/wrappers/socketw/sni.py,sha256=J1kPnQ77XwKN1pO5aOI1c_VfhuivCm95OOaQxMpPuZ0,17627
|
|
@@ -310,8 +310,8 @@ atomicshop/wrappers/socketw/ssl_base.py,sha256=kmiif84kMhBr5yjQW17p935sfjR5JKG0L
|
|
|
310
310
|
atomicshop/wrappers/socketw/statistics_csv.py,sha256=w1AH-zf4mBuT4euf28UKij9ihM-b1BRU9Qfby0QDdqI,2957
|
|
311
311
|
atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
312
312
|
atomicshop/wrappers/winregw/winreg_network.py,sha256=bQ8Jql8bVGBJ0dt3VQ56lga_1LBOMLI3Km_otvvbU6c,7138
|
|
313
|
-
atomicshop-2.16.
|
|
314
|
-
atomicshop-2.16.
|
|
315
|
-
atomicshop-2.16.
|
|
316
|
-
atomicshop-2.16.
|
|
317
|
-
atomicshop-2.16.
|
|
313
|
+
atomicshop-2.16.34.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
|
|
314
|
+
atomicshop-2.16.34.dist-info/METADATA,sha256=BKW8IYDADJjg7d-7-exeW7BZT5mboP95IsNtRy7lom4,10473
|
|
315
|
+
atomicshop-2.16.34.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
316
|
+
atomicshop-2.16.34.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
|
|
317
|
+
atomicshop-2.16.34.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|