easy-utils-dev 2.146__tar.gz → 2.153__tar.gz
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.
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/PKG-INFO +1 -2
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/debugger.py +63 -55
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/uiserver.py +0 -2
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/utils.py +6 -3
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/wsnoclib.py +5 -4
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev.egg-info/PKG-INFO +1 -2
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev.egg-info/requires.txt +0 -1
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/setup.py +1 -2
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/MANIFEST.in +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/EasySsh.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/Events.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/FastQueue.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/NameObject.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/__init__.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/abortable.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/brevosmtp.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/check_license.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/cplib.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/custom_env.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/debugger-C-PF4PAMMP.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/easy_oracle.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/encryptor.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/ept.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/ept_sql/create_dirs.sql +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/ept_sql/create_ept_tables.sql +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/exceptions.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/filescompressor.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/generate_license.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/keycloakapi.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/lralib.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/ne1830PSS.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/nsp_kafka.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/openid_server.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/optics_utils.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/require_auth.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/simple_sqlite.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/temp_memory.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/winserviceapi.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev/wsselib.py +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev.egg-info/SOURCES.txt +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev.egg-info/dependency_links.txt +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/easy_utils_dev.egg-info/top_level.txt +0 -0
- {easy_utils_dev-2.146 → easy_utils_dev-2.153}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: easy_utils_dev
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.153
|
|
4
4
|
Keywords: python3
|
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
|
6
6
|
Requires-Dist: psutil
|
|
@@ -16,7 +16,6 @@ Requires-Dist: flask_socketio
|
|
|
16
16
|
Requires-Dist: python-dotenv
|
|
17
17
|
Requires-Dist: gevent
|
|
18
18
|
Requires-Dist: pyzipper
|
|
19
|
-
Requires-Dist: shutil
|
|
20
19
|
Requires-Dist: pyjwt
|
|
21
20
|
Requires-Dist: authlib
|
|
22
21
|
Requires-Dist: kafka-python
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import os
|
|
3
|
+
import shutil
|
|
3
4
|
import sys
|
|
4
5
|
from datetime import datetime
|
|
5
6
|
from logging.handlers import RotatingFileHandler
|
|
6
|
-
from .utils import getRandomKey , convert_mb_to_bytes , getTimestamp , start_thread
|
|
7
|
+
from .utils import getRandomKey , convert_mb_to_bytes , getTimestamp, mkdirs , start_thread
|
|
7
8
|
from .custom_env import custom_env , setupEnvironment
|
|
8
9
|
from .Events import EventEmitter
|
|
9
10
|
from threading import Thread
|
|
@@ -58,12 +59,11 @@ class DEBUGGER:
|
|
|
58
59
|
self.file_handler_class=None
|
|
59
60
|
self.LOG_SIZE_THRESHOLD_IN_BYTES = 10 * 1024 * 1024
|
|
60
61
|
self.BACKUP_COUNT = log_rotation
|
|
61
|
-
self.
|
|
62
|
-
self.
|
|
62
|
+
self.name = name
|
|
63
|
+
self.create_log_path(homePath, file_name)
|
|
63
64
|
self.fullSyntax=fullSyntax
|
|
64
65
|
self.onScreen= onscreen
|
|
65
66
|
self.id = id
|
|
66
|
-
self.how_many_times_write= 0
|
|
67
67
|
self.stream_service = None
|
|
68
68
|
if not env['debugger'].get(name) :
|
|
69
69
|
self.console = console_handler = logging.StreamHandler()
|
|
@@ -71,7 +71,6 @@ class DEBUGGER:
|
|
|
71
71
|
self.console = console_handler = env['debugger'].get(name).console
|
|
72
72
|
if not self.logger.hasHandlers() :
|
|
73
73
|
self.logger.addHandler(self.console)
|
|
74
|
-
self.name = name
|
|
75
74
|
self.rotate_disabled=False
|
|
76
75
|
self.isInPyinstaller = False
|
|
77
76
|
self.log_iterations=0
|
|
@@ -86,13 +85,11 @@ class DEBUGGER:
|
|
|
86
85
|
f = f"[{self.name}]-[%(levelname)s]: %(message)s"
|
|
87
86
|
self.syntax = f
|
|
88
87
|
self.formatter = logging.Formatter(f , datefmt='%Y-%m-%d %H:%M:%S' )
|
|
89
|
-
self.filename = file_name
|
|
90
|
-
path = self.homepath(homePath)
|
|
91
88
|
if not env['debugger'].get(name) :
|
|
92
89
|
console_handler.setFormatter(self.formatter)
|
|
93
90
|
if not disable_log_write :
|
|
94
91
|
if not env['debugger'].get(name) :
|
|
95
|
-
self.file_handler_class = self.createRotateFileHandler(
|
|
92
|
+
self.file_handler_class = self.createRotateFileHandler(self.log_path_with_filename)
|
|
96
93
|
if onscreen :
|
|
97
94
|
self.enable_print()
|
|
98
95
|
elif not onscreen :
|
|
@@ -118,6 +115,35 @@ class DEBUGGER:
|
|
|
118
115
|
self.set_level(EASY_UTILS_DEBUG_LEVEL)
|
|
119
116
|
if os.environ.get("EASY_UTILS_ENABLE_PRINT" , '' ).lower() == 'true' :
|
|
120
117
|
self.enable_print()
|
|
118
|
+
start_thread(target=self.checks_in_bg)
|
|
119
|
+
|
|
120
|
+
def create_log_path(self , base_path , logname ) :
|
|
121
|
+
if not base_path :
|
|
122
|
+
base_path = os.path.join(os.getcwd() , 'debug')
|
|
123
|
+
if not logname :
|
|
124
|
+
logname = self.name
|
|
125
|
+
mkdirs(base_path)
|
|
126
|
+
self.baseHomePath = base_path
|
|
127
|
+
self.filename = logname
|
|
128
|
+
self.lastAbsoluteHomePath = base_path
|
|
129
|
+
self.log_path_with_filename = os.path.join(base_path, f'{logname}.log')
|
|
130
|
+
# print(f"Filename : {self.filename}")
|
|
131
|
+
# print(f"Base Home Path : {self.baseHomePath}")
|
|
132
|
+
# print(f"Log path With Filename : {self.log_path_with_filename}")
|
|
133
|
+
# print(f"Last Absolute Home Path : {self.lastAbsoluteHomePath}")
|
|
134
|
+
|
|
135
|
+
def fix_file_not_found_file_rotation(self) :
|
|
136
|
+
for i in range(self.BACKUP_COUNT) :
|
|
137
|
+
try :
|
|
138
|
+
file_path = self.homePath + f'.{i}'
|
|
139
|
+
# print(f"Checking log file path : {file_path}")
|
|
140
|
+
if not os.path.exists(file_path) :
|
|
141
|
+
with open(file_path, 'a+') as f :
|
|
142
|
+
# print(f"Creating log file path : {file_path}")
|
|
143
|
+
f.write('')
|
|
144
|
+
except :
|
|
145
|
+
pass
|
|
146
|
+
|
|
121
147
|
|
|
122
148
|
def switch_full_syntax(self , toggle) :
|
|
123
149
|
if toggle :
|
|
@@ -140,9 +166,10 @@ class DEBUGGER:
|
|
|
140
166
|
def updateGlobalHomePath(self ) :
|
|
141
167
|
if not self.isLogWriteDisabled :
|
|
142
168
|
getFromEnv = self.env.get('debugger_homepath' , None )
|
|
143
|
-
|
|
169
|
+
# print(f"getFromEnv : {getFromEnv}")
|
|
170
|
+
self.create_log_path(getFromEnv, self.filename)
|
|
144
171
|
if getFromEnv :
|
|
145
|
-
self.file_handler_class = self.createRotateFileHandler(self.
|
|
172
|
+
self.file_handler_class = self.createRotateFileHandler(self.log_path_with_filename)
|
|
146
173
|
|
|
147
174
|
def updateGlobalSetLevel( self ) :
|
|
148
175
|
self.set_level(self.env['debugger_global_level'])
|
|
@@ -211,13 +238,7 @@ class DEBUGGER:
|
|
|
211
238
|
self.logger.removeHandler(self.file_handler_class)
|
|
212
239
|
|
|
213
240
|
def enable_log_write(self) :
|
|
214
|
-
self.createRotateFileHandler(self.
|
|
215
|
-
|
|
216
|
-
def manage_file_rotation(self, record ) :
|
|
217
|
-
handler = self.get_rotate_handler()
|
|
218
|
-
if handler.shouldRollover(record) :
|
|
219
|
-
handler.doRollover()
|
|
220
|
-
self.log_iterations = 0
|
|
241
|
+
self.createRotateFileHandler(self.log_path_with_filename)
|
|
221
242
|
|
|
222
243
|
def get_rotate_handler(self) :
|
|
223
244
|
return self.file_handler_class
|
|
@@ -233,10 +254,10 @@ class DEBUGGER:
|
|
|
233
254
|
handler = self.get_rotate_handler()
|
|
234
255
|
handler.maxBytes = size
|
|
235
256
|
return True
|
|
236
|
-
|
|
237
257
|
|
|
238
258
|
def checks_in_bg(self) :
|
|
239
259
|
while True :
|
|
260
|
+
#self.fix_file_not_found_file_rotation()
|
|
240
261
|
if self.env.get('GLOBAL_DEBUGGER_STREAM_SERVICE') :
|
|
241
262
|
self.addStreamService(socketio=self.env.get('GLOBAL_DEBUGGER_STREAM_SERVICE'))
|
|
242
263
|
if self.env.get('debugger_global_level' , None) :
|
|
@@ -254,7 +275,7 @@ class DEBUGGER:
|
|
|
254
275
|
self.updateGlobalHomePath()
|
|
255
276
|
if os.environ.get("EASY_UTILS_ENABLE_PRINT" , '' ).lower() == 'true' :
|
|
256
277
|
self.enable_print()
|
|
257
|
-
sleep(
|
|
278
|
+
sleep(10)
|
|
258
279
|
|
|
259
280
|
def close(self) :
|
|
260
281
|
try :
|
|
@@ -262,28 +283,6 @@ class DEBUGGER:
|
|
|
262
283
|
except :
|
|
263
284
|
pass
|
|
264
285
|
|
|
265
|
-
def homepath(self , path=None ) :
|
|
266
|
-
env = custom_env()
|
|
267
|
-
getFromEnv = env.get('debugger_homepath' , None )
|
|
268
|
-
if getFromEnv is not None :
|
|
269
|
-
self.homePath = getFromEnv
|
|
270
|
-
else :
|
|
271
|
-
if path is not None :
|
|
272
|
-
if self.homePath and '.log' in str(self.homePath):
|
|
273
|
-
self.lastAbsoluteHomePath= self.homePath
|
|
274
|
-
self.homePath = path
|
|
275
|
-
else :
|
|
276
|
-
self.homePath = os.path.join(os.getcwd() , 'debug')
|
|
277
|
-
if not os.path.exists( self.homePath ) :
|
|
278
|
-
try :
|
|
279
|
-
os.makedirs( self.homePath )
|
|
280
|
-
except :
|
|
281
|
-
pass
|
|
282
|
-
if self.filename :
|
|
283
|
-
self.homePath = os.path.join( self.homePath, f'{self.filename}.log' )
|
|
284
|
-
else :
|
|
285
|
-
self.homePath = os.path.join( self.homePath, f'{self.name}.log' )
|
|
286
|
-
return self.homePath
|
|
287
286
|
|
|
288
287
|
def get_current_levels(self):
|
|
289
288
|
"""
|
|
@@ -312,10 +311,16 @@ class DEBUGGER:
|
|
|
312
311
|
self.logger.removeHandler(self.console)
|
|
313
312
|
|
|
314
313
|
def changeHomePath( self , path ) :
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
314
|
+
def delet_later(lastAbsoluteHomePath) :
|
|
315
|
+
if lastAbsoluteHomePath :
|
|
316
|
+
sleep(3)
|
|
317
|
+
try :
|
|
318
|
+
shutil.rmtree(lastAbsoluteHomePath)
|
|
319
|
+
except :
|
|
320
|
+
pass
|
|
321
|
+
start_thread(target=delet_later, args=[self.lastAbsoluteHomePath])
|
|
322
|
+
self.create_log_path( path , self.filename)
|
|
323
|
+
self.file_handler_class = self.createRotateFileHandler(self.log_path_with_filename)
|
|
319
324
|
|
|
320
325
|
def isGlobalDebuggerDefined(self) :
|
|
321
326
|
if self.global_debugger :
|
|
@@ -349,16 +354,19 @@ class DEBUGGER:
|
|
|
349
354
|
if self.isStreamServiceAvailable() :
|
|
350
355
|
d = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
|
351
356
|
streamUrl = self.getStreamServiceUrlPath()
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
357
|
+
try :
|
|
358
|
+
self.stream_service.emit( streamUrl , {
|
|
359
|
+
'message' : message ,
|
|
360
|
+
'level' : level ,
|
|
361
|
+
'msg' : message,
|
|
362
|
+
'date' : d ,
|
|
363
|
+
'id' : self.id,
|
|
364
|
+
'formate' : 'json' ,
|
|
365
|
+
'source' : self.name ,
|
|
366
|
+
'getTimestamp' : getTimestamp()
|
|
367
|
+
})
|
|
368
|
+
except :
|
|
369
|
+
pass
|
|
362
370
|
try :
|
|
363
371
|
t= Thread(target=__call_thread__)
|
|
364
372
|
# t.daemon=True
|
|
@@ -49,14 +49,14 @@ def timenow() :
|
|
|
49
49
|
return str(now().strftime("%d/%m/%Y %H:%M:%S"))
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def timenowForLabels() :
|
|
52
|
+
def timenowForLabels(format='%d-%m-%Y_%H-%M-%S') :
|
|
53
53
|
"""
|
|
54
54
|
Get current date and time formatted for use in file labels.
|
|
55
55
|
|
|
56
56
|
Returns:
|
|
57
57
|
str: Current date and time in format "DD-MM-YYYY_HH-MM-SS".
|
|
58
58
|
"""
|
|
59
|
-
return now().strftime(
|
|
59
|
+
return now().strftime(format)
|
|
60
60
|
|
|
61
61
|
def fixTupleForSql(list):
|
|
62
62
|
"""
|
|
@@ -399,7 +399,10 @@ def mkdirs(path) :
|
|
|
399
399
|
path (str): Path of directory to create.
|
|
400
400
|
"""
|
|
401
401
|
if not os.path.exists(path) :
|
|
402
|
-
|
|
402
|
+
try :
|
|
403
|
+
os.makedirs(path)
|
|
404
|
+
except :
|
|
405
|
+
pass
|
|
403
406
|
|
|
404
407
|
def releasify(release : float ) -> tuple :
|
|
405
408
|
"""
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
from tkinter import NO
|
|
2
1
|
from easy_utils_dev.debugger import DEBUGGER
|
|
3
2
|
import requests , json , subprocess
|
|
4
3
|
from requests.auth import HTTPBasicAuth as BAuth
|
|
@@ -87,6 +86,7 @@ class WSNOCLIB :
|
|
|
87
86
|
self.current_requests = 0
|
|
88
87
|
self.connected = False
|
|
89
88
|
self.pm_hadoop = PmHadoopClient(self)
|
|
89
|
+
self.verify_connection_by_ping = True
|
|
90
90
|
if register_atexit :
|
|
91
91
|
atexit.register(self.goodbye)
|
|
92
92
|
|
|
@@ -130,8 +130,9 @@ class WSNOCLIB :
|
|
|
130
130
|
self.logger.debug(f"loggedOut flag is {self.loggedOut}")
|
|
131
131
|
if self.loggedOut :
|
|
132
132
|
return
|
|
133
|
-
if
|
|
134
|
-
|
|
133
|
+
if self.verify_connection_by_ping :
|
|
134
|
+
if not pingAddress(self.address) :
|
|
135
|
+
raise Exception(f'Address {self.address} is not pingable.')
|
|
135
136
|
# self.logger.info(f'Connecting to {self.address} using username: {self.username}')
|
|
136
137
|
self.logger.debug(f'Connecting to {self.address} using username: {self.username}')
|
|
137
138
|
URL = f"https://{self.address}/rest-gateway/rest/api/v1/auth/token"
|
|
@@ -379,7 +380,7 @@ class WSNOCLIB :
|
|
|
379
380
|
return self.kafka
|
|
380
381
|
|
|
381
382
|
def change_kafka_refresh_period(self , period : int =3000) :
|
|
382
|
-
self.logger.warning('Deprecated, Kafka refresh period is now managed by WSNOC API SLEEP PERIOD. Nothing is applied
|
|
383
|
+
self.logger.warning('Deprecated, Kafka refresh period is now managed by WSNOC API SLEEP PERIOD. Nothing is applied from this function.')
|
|
383
384
|
|
|
384
385
|
def renewSubscription(self) :
|
|
385
386
|
self.logger.info('Renewing subscription ...')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: easy_utils_dev
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.153
|
|
4
4
|
Keywords: python3
|
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
|
6
6
|
Requires-Dist: psutil
|
|
@@ -16,7 +16,6 @@ Requires-Dist: flask_socketio
|
|
|
16
16
|
Requires-Dist: python-dotenv
|
|
17
17
|
Requires-Dist: gevent
|
|
18
18
|
Requires-Dist: pyzipper
|
|
19
|
-
Requires-Dist: shutil
|
|
20
19
|
Requires-Dist: pyjwt
|
|
21
20
|
Requires-Dist: authlib
|
|
22
21
|
Requires-Dist: kafka-python
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|