Terarea  2
The automation project
Loading...
Searching...
No Matches
runtime_data.py
Go to the documentation of this file.
1"""_summary_
2 This file is the one in charge of containing data that will change during the server runtime.
3"""
4from typing import Dict, Any, TYPE_CHECKING
5from fastapi import FastAPI
6import uvicorn
7from . import constants as CONST
8from ..sql.sql_manager import SQL
9from ..bucket import Bucket
10if TYPE_CHECKING:
11 from .crons import Crons
12 from .paths import ServerPaths
13 from .endpoints_routes import Endpoints
14 from .background_tasks import BackgroundTasks
15 from .server_management import ServerManagement
16 from .oauth_authentication import OAuthAuthentication
17 from .mail_management import MailManagement
18 from ..boilerplates import BoilerplateIncoming, BoilerplateNonHTTP, BoilerplateResponses
19 from ..actions import ActionsMain
20
21
23 """_summary_
24 This class is the one in charge of containing data that will change during the server runtime.
25 """
26
27 def __init__(self, host: str = "0.0.0.0", port: int = 5000, app_name: str = "Area", error: int = 84, success: int = 0) -> None:
28 self.const: CONST = CONST
29 self.host: str = host
30 self.port: int = port
31 self.error: int = error
32 self.success: int = success
33 self.app_name: str = app_name
34 # --------------------- The rest api boiling class ---------------------
35 self.app: FastAPI = None
36 # ------------------------ The active database ------------------------
37 self.database_link: SQL = None
38 # --------------------------- Active bucket ---------------------------
39 self.bucket_link: Bucket = None
40 # ----------------------- Http response building -----------------------
41 if isinstance(app_name, str) is False:
42 app_name = f"{app_name}"
43 if isinstance(host, str) is False:
44 host = f"{host}"
45 if isinstance(port, str) is False:
46 port = f"{port}"
47 self.json_header: Dict[str, Any] = {
48 CONST.JSON_HEADER_APP_NAME: app_name,
49 CONST.JSON_HEADER_HOST: host,
50 CONST.JSON_HEADER_PORT: port
51 }
52 # --------------------- The server classes ---------------------
53 self.config: uvicorn.Config = None
54 self.server: uvicorn.Server = None
55 self.server_running: bool = True
56 self.continue_running: bool = True
57 # ------------------------- Classes reference -------------------------
58 self.crons_initialised: 'Crons' = None
59 self.paths_initialised: 'ServerPaths' = None
60 self.endpoints_initialised: 'Endpoints' = None
61 self.background_tasks_initialised: 'BackgroundTasks' = None
62 self.server_management_initialised: 'ServerManagement' = None
63 self.boilerplate_responses_initialised: 'BoilerplateResponses' = None
64 self.boilerplate_incoming_initialised: 'BoilerplateIncoming' = None
65 self.boilerplate_non_http_initialised: 'BoilerplateNonHTTP' = None
66 self.oauth_authentication_initialised: 'OAuthAuthentication' = None
67 self.actions_main_initialised: 'ActionsMain' = None
68 self.mail_management_initialised: 'MailManagement' = None
None __init__(self, str host="0.0.0.0", int port=5000, str app_name="Area", int error=84, int success=0)