fix(py,sql): Fixed all Windows targets.
This commit is contained in:
parent
a363133891
commit
9906a16562
@ -78,7 +78,7 @@ class NucelarMonitor:
|
|||||||
RE_HTTP_REQUEST:REPattern = re_compile(r'^([^\s]+)\s([^\s\?\#]+)(?:\?([^#]+))?(?:\#[^\s]+)?\s([^\/]+)\/([0-9\.]+)$')
|
RE_HTTP_REQUEST:REPattern = re_compile(r'^([^\s]+)\s([^\s\?\#]+)(?:\?([^#]+))?(?:\#[^\s]+)?\s([^\/]+)\/([0-9\.]+)$')
|
||||||
RE_HEADER_LINE:REPattern = re_compile(r'^([^\:]+)\:(.+)$')
|
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_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_SLASHES:REPattern = re_compile(r'[\\\/]+')
|
||||||
RE_TO_REGULAR_EXPRESSION:REPattern = re_compile(r'[\(\)\{\}\/\\\.\-\+\*\^\$\?\|\!\<\>\r\n\t]')
|
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)
|
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.__started:bool = False
|
||||||
self.__working:bool = False
|
self.__working:bool = False
|
||||||
self.__root_paths:list[str] = ["", self.ROOT]
|
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):
|
for _ in range(2):
|
||||||
self.__root_paths.append(self.RE_LAST_DIRECTORY.sub(r'\1', self.__root_paths[-1]))
|
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.__http_server = Socket(ADDRESS_FAMILY_IPV4, SOCKET_STREAM)
|
||||||
self.__working = True
|
self.__working = True
|
||||||
|
|
||||||
|
Thread(target = self.__command_listener).start()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
self.__http_server.setsockopt(SOCKET_LAYER, SOCKET_REUSE_ADDRESS, 1)
|
self.__http_server.setsockopt(SOCKET_LAYER, SOCKET_REUSE_ADDRESS, 1)
|
||||||
@ -281,6 +286,28 @@ class NucelarMonitor:
|
|||||||
"port" : self.__http_port,
|
"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:
|
def get_print_type(self:Self, _type:str) -> str:
|
||||||
|
|
||||||
group:list[str]
|
group:list[str]
|
||||||
@ -356,17 +383,17 @@ class NucelarMonitor:
|
|||||||
absolute:str
|
absolute:str
|
||||||
|
|
||||||
for root in self.__root_paths:
|
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):
|
if path_exists(absolute):
|
||||||
return absolute
|
return absolute
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def load_file(self:Self, path:str, mode:str = "r") -> str|bytes|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:
|
if absolute_path:
|
||||||
with open(path, mode) as file:
|
with open(absolute_path, mode) as file:
|
||||||
return file.read()
|
return file.read()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -463,6 +490,9 @@ class NucelarMonitor:
|
|||||||
|
|
||||||
variables:list[str] = []
|
variables:list[str] = []
|
||||||
|
|
||||||
|
if path is not None:
|
||||||
|
variables.append("route")
|
||||||
|
|
||||||
def callback(matches:REMatch) -> str:
|
def callback(matches:REMatch) -> str:
|
||||||
|
|
||||||
variables.append(matches.group(1))
|
variables.append(matches.group(1))
|
||||||
|
|||||||
@ -907,12 +907,11 @@ as begin
|
|||||||
select top 1 id from dbo.MachineInterfaces where
|
select top 1 id from dbo.MachineInterfaces where
|
||||||
date_out is null and
|
date_out is null and
|
||||||
machine = @machine_id and
|
machine = @machine_id and
|
||||||
[interface] = @interface_id and
|
[interface] = @interface_id
|
||||||
[name] = @name
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if @machine_interface_id is null begin
|
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()
|
set @machine_interface_id = scope_identity()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -946,8 +945,7 @@ as begin
|
|||||||
mask = @mask
|
mask = @mask
|
||||||
where
|
where
|
||||||
date_out is null and
|
date_out is null and
|
||||||
machine_interface = @machine_interface_id and
|
machine_interface = @machine_interface_id
|
||||||
candle_time = @candle_time_id
|
|
||||||
end
|
end
|
||||||
|
|
||||||
insert into dbo.MachineInterfacesTraffic(machine_interface, candle_time, bytes, packages, errors) values
|
insert into dbo.MachineInterfacesTraffic(machine_interface, candle_time, bytes, packages, errors) values
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user