fix(py,sql): Fixed all Windows targets.

This commit is contained in:
mbruzon 2026-03-04 15:05:57 +01:00
parent a363133891
commit 9906a16562
2 changed files with 38 additions and 10 deletions

View File

@ -78,7 +78,7 @@ class NucelarMonitor:
RE_HTTP_REQUEST:REPattern = re_compile(r'^([^\s]+)\s([^\s\?\#]+)(?:\?([^#]+))?(?:\#[^\s]+)?\s([^\/]+)\/([0-9\.]+)$')
RE_HEADER_LINE:REPattern = re_compile(r'^([^\:]+)\:(.+)$')
RE_HTTP_BLOCKS:REPattern = re_compile(r'((?:(?!(?:(?:\r\n){2}|\n{2}|\r{2}))(?:.|[\r\n]+))+)(?:(?:(?:\r\n){2}|\n{2}|\r{2})((?:.+|[\r\n]+)*))?')
RE_LAST_DIRECTORY:REPattern = re_compile(r'^(.*)[\/][^\/]*\/?$')
RE_LAST_DIRECTORY:REPattern = re_compile(r'^(.*)[\/\\\\][^\/\\\\]*[\/\\\\]?$')
RE_SLASHES:REPattern = re_compile(r'[\\\/]+')
RE_TO_REGULAR_EXPRESSION:REPattern = re_compile(r'[\(\)\{\}\/\\\.\-\+\*\^\$\?\|\!\<\>\r\n\t]')
RE_ROUTE_KEY:REPattern = re_compile(r'\\\{([a-z_][a-z0-9_]*)\\\}', RE_IGNORE_CASE)
@ -234,6 +234,9 @@ class NucelarMonitor:
self.__started:bool = False
self.__working:bool = False
self.__root_paths:list[str] = ["", self.ROOT]
self.__commands:list[list[list[str], Callable[[dict[str, Any|None], list[Any|None]], None]]] = [
[["close", "exit", "quit", "bye"], self.__close_command]
]
for _ in range(2):
self.__root_paths.append(self.RE_LAST_DIRECTORY.sub(r'\1', self.__root_paths[-1]))
@ -251,6 +254,8 @@ class NucelarMonitor:
self.__http_server = Socket(ADDRESS_FAMILY_IPV4, SOCKET_STREAM)
self.__working = True
Thread(target = self.__command_listener).start()
try:
self.__http_server.setsockopt(SOCKET_LAYER, SOCKET_REUSE_ADDRESS, 1)
@ -281,6 +286,28 @@ class NucelarMonitor:
"port" : self.__http_port,
})
def __command_listener(self:Self) -> None:
while self.__working:
try:
parameters:dict[str, Any|None] = {}
arguments:list[Any|None] = []
command:str = input().strip().lower()
if command:
for commands, callback in self.__commands:
if command in commands:
callback(self.get_dictionary(self.__inputs), [parameters, *arguments])
break
except Exception as exception:
self.exception(exception, "command_listener_exception", {
"command" : command
})
def __close_command(self:Self, inputs:dict[str, Any|None], *arguments:list[Any|None]) -> None:
self.close()
def get_print_type(self:Self, _type:str) -> str:
group:list[str]
@ -356,17 +383,17 @@ class NucelarMonitor:
absolute:str
for root in self.__root_paths:
absolute = self.fix_path(root + '/' + path)
absolute = self.fix_path((root + '/' if root else "") + path)
if path_exists(absolute):
return absolute
return None
def load_file(self:Self, path:str, mode:str = "r") -> str|bytes|None:
path:str = self.get_absolute_path(path)
absolute_path:str = self.get_absolute_path(path)
if path:
with open(path, mode) as file:
if absolute_path:
with open(absolute_path, mode) as file:
return file.read()
return None
@ -463,6 +490,9 @@ class NucelarMonitor:
variables:list[str] = []
if path is not None:
variables.append("route")
def callback(matches:REMatch) -> str:
variables.append(matches.group(1))

View File

@ -907,12 +907,11 @@ as begin
select top 1 id from dbo.MachineInterfaces where
date_out is null and
machine = @machine_id and
[interface] = @interface_id and
[name] = @name
[interface] = @interface_id
)
if @machine_interface_id is null begin
insert into dbo.MachineInterfaces(machine, [interface], [name]) values (@machine_id, @interface_id, @name)
insert into dbo.MachineInterfaces(machine, [interface]) values (@machine_id, @interface_id)
set @machine_interface_id = scope_identity()
end
@ -946,8 +945,7 @@ as begin
mask = @mask
where
date_out is null and
machine_interface = @machine_interface_id and
candle_time = @candle_time_id
machine_interface = @machine_interface_id
end
insert into dbo.MachineInterfacesTraffic(machine_interface, candle_time, bytes, packages, errors) values