8from socket
import socket, AF_INET, SOCK_STREAM
10from logistics
import Logistics
11from convert_data
import ConvertData
12from global_variables
import GlobalVariables
13from custom_functions
import pinfo, psuccess, perror, pdebug, pwarning
18 This is the class in charge of creating a tcp server and connecting to the server binary
20 Thread (_type_): _description_
23 def __init__(self, global_variables: GlobalVariables) ->
None:
30 Process incoming data from the server binary
32 tcp_socket (socket): _description_: The tcp connection
38 if data.decode().lower()
in (
"exit\n",
"dead\n"):
53 Send any data that could of been generated by the program
55 tcp_socket (socket): _description_: The tcp connection
58 bool: _description_: if ab error occurred: False, else True
65 if (isinstance(data, (str, dict))
is not True)
or (isinstance(data, str)
and data ==
""):
68 f
"Invalid response type: '{data}'"
71 if isinstance(data, dict):
77 tcp_socket.sendall((response.to_external()).encode())
81 tcp_socket.sendall(data.encode())
86 This is the function in charge fo
96 The server loop that is in charge of managing the packets
112 This is the function that will lay the foundation for the tcp server.
118 s = socket(AF_INET, SOCK_STREAM)
138 This is the function in charge of starting any function that contains the code we wish to run inside the thread we started.
146 f
"The listener exited with status: {status}"
151 "The listener exited without any errors"
156if __name__ ==
"__main__":
157 print(
"This script is not meant to be run as main.")
180 GI.current_buffer.append(
ConvertData(
"WELCOME").to_internal())
183 GI.colourise_output.init_pallet()
184 GI.colourise_error.init_pallet()
185 GI.colourise_output.unload_ressources()
186 sys.exit(GI.current_status)
None _process_incoming(self, socket tcp_socket)
None __init__(self, GlobalVariables global_variables)
int _mainloop(self, socket tcp_socket)
int _start_tcp_socket(self)
None _initialise_logistics(self)
bool _send_output_data(self, socket tcp_socket)