orionis 0.78.0__py3-none-any.whl → 0.82.0__py3-none-any.whl
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.
- orionis/contracts/container/i_container.py +7 -7
- orionis/contracts/facades/commands/i_commands_facade.py +40 -0
- orionis/contracts/services/commands/__init__.py +0 -0
- orionis/contracts/services/commands/i_reactor_commands_service.py +23 -0
- orionis/framework.py +1 -1
- orionis/luminate/app.py +234 -34
- orionis/luminate/bootstrap/command_bootstrapper.py +1 -1
- orionis/luminate/config/logging.py +6 -6
- orionis/luminate/container/container.py +6 -6
- orionis/luminate/facades/app.py +1 -3
- orionis/luminate/facades/commands/__init__.py +0 -0
- orionis/luminate/facades/commands/commands_facade.py +42 -0
- orionis/luminate/providers/commands/__init__.py +0 -0
- orionis/luminate/providers/commands/reactor_commands_service_provider.py +19 -0
- orionis/luminate/services/commands/__init__.py +0 -0
- orionis/luminate/services/commands/reactor_commands_service.py +127 -0
- orionis/luminate/services/log/log_service.py +19 -30
- {orionis-0.78.0.dist-info → orionis-0.82.0.dist-info}/METADATA +1 -1
- {orionis-0.78.0.dist-info → orionis-0.82.0.dist-info}/RECORD +24 -17
- orionis/luminate/console/runner.py +0 -127
- orionis/luminate/pipelines/cli_pipeline.py +0 -122
- /orionis/{luminate/pipelines → contracts/facades/commands}/__init__.py +0 -0
- {orionis-0.78.0.dist-info → orionis-0.82.0.dist-info}/LICENCE +0 -0
- {orionis-0.78.0.dist-info → orionis-0.82.0.dist-info}/WHEEL +0 -0
- {orionis-0.78.0.dist-info → orionis-0.82.0.dist-info}/entry_points.txt +0 -0
- {orionis-0.78.0.dist-info → orionis-0.82.0.dist-info}/top_level.txt +0 -0
@@ -3,13 +3,6 @@ from typing import Any, Callable
|
|
3
3
|
|
4
4
|
class IContainer(ABC):
|
5
5
|
|
6
|
-
@abstractmethod
|
7
|
-
def _newRequest(self) -> None:
|
8
|
-
"""
|
9
|
-
Reset scoped instances at the beginning of a new request.
|
10
|
-
"""
|
11
|
-
pass
|
12
|
-
|
13
6
|
@abstractmethod
|
14
7
|
def _ensureNotMain(self, concrete: Callable[..., Any]) -> str:
|
15
8
|
"""
|
@@ -83,6 +76,13 @@ class IContainer(ABC):
|
|
83
76
|
"""
|
84
77
|
pass
|
85
78
|
|
79
|
+
@abstractmethod
|
80
|
+
def forgetScopedInstances(self) -> None:
|
81
|
+
"""
|
82
|
+
Reset scoped instances at the beginning of a new request.
|
83
|
+
"""
|
84
|
+
self._scoped_instances = {}
|
85
|
+
|
86
86
|
@abstractmethod
|
87
87
|
def bind(self, concrete: Callable[..., Any]) -> str:
|
88
88
|
"""
|
@@ -0,0 +1,40 @@
|
|
1
|
+
from abc import ABC, abstractmethod
|
2
|
+
from typing import Any
|
3
|
+
|
4
|
+
class ICommand(ABC):
|
5
|
+
"""
|
6
|
+
Interface for defining a CLI command.
|
7
|
+
Command class for managing and executing registered CLI commands.
|
8
|
+
|
9
|
+
This class provides a static method to invoke commands registered in the
|
10
|
+
`CacheCommands` singleton, passing the required signature and any additional
|
11
|
+
parameters.
|
12
|
+
|
13
|
+
Methods
|
14
|
+
-------
|
15
|
+
call(signature: str, vars: dict[str, Any] = {}, *args: Any, **kwargs: Any) -> Any
|
16
|
+
Executes the specified command with the provided arguments.
|
17
|
+
"""
|
18
|
+
|
19
|
+
@abstractmethod
|
20
|
+
def call(signature: str, vars: dict[str, Any] = {}, *args: Any, **kwargs: Any) -> Any:
|
21
|
+
"""
|
22
|
+
Calls a registered command using the `CLIRunner`.
|
23
|
+
|
24
|
+
Parameters
|
25
|
+
----------
|
26
|
+
signature : str
|
27
|
+
The command signature (name) to execute.
|
28
|
+
vars : dict[str, Any], optional
|
29
|
+
A dictionary containing named arguments for the command (default is `{}`).
|
30
|
+
*args : Any
|
31
|
+
Additional positional arguments.
|
32
|
+
**kwargs : Any
|
33
|
+
Additional keyword arguments.
|
34
|
+
|
35
|
+
Returns
|
36
|
+
-------
|
37
|
+
Any
|
38
|
+
The output of the executed command.
|
39
|
+
"""
|
40
|
+
pass
|
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
from abc import ABC, abstractmethod
|
2
|
+
from typing import Optional
|
3
|
+
|
4
|
+
class IReactorCommandsService(ABC):
|
5
|
+
"""
|
6
|
+
Interface for the ReactorCommandsService class.
|
7
|
+
Service responsible for executing and managing CLI commands in Orionis.
|
8
|
+
|
9
|
+
This service handles:
|
10
|
+
- Parsing command arguments.
|
11
|
+
- Executing commands and logging their output.
|
12
|
+
- Managing execution timing and error handling.
|
13
|
+
"""
|
14
|
+
|
15
|
+
@abstractmethod
|
16
|
+
def execute(self, signature: Optional[str] = None, vars: dict = {}, *args, **kwargs):
|
17
|
+
"""
|
18
|
+
Processes and executes a CLI command.
|
19
|
+
|
20
|
+
Determines if the command originates from `sys.argv` or is explicitly called,
|
21
|
+
then executes the appropriate command pipeline, handling success and errors.
|
22
|
+
"""
|
23
|
+
pass
|
orionis/framework.py
CHANGED
orionis/luminate/app.py
CHANGED
@@ -1,71 +1,271 @@
|
|
1
|
+
from typing import Any, Callable
|
1
2
|
from orionis.luminate.container.container import Container
|
2
3
|
from orionis.luminate.bootstrap.config_bootstrapper import ConfigBootstrapper
|
3
4
|
from orionis.luminate.bootstrap.command_bootstrapper import CommandsBootstrapper
|
4
5
|
from orionis.luminate.bootstrap.environment_bootstrapper import EnvironmentBootstrapper
|
5
6
|
from orionis.luminate.patterns.singleton import SingletonMeta
|
7
|
+
from orionis.luminate.providers.commands.reactor_commands_service_provider import ReactorCommandsServiceProvider
|
6
8
|
from orionis.luminate.providers.environment.environment__service_provider import EnvironmentServiceProvider
|
7
9
|
from orionis.luminate.providers.config.config_service_provider import ConfigServiceProvider
|
8
|
-
from orionis.luminate.
|
10
|
+
from orionis.luminate.providers.log.log_service_provider import LogServiceProvider
|
9
11
|
|
10
12
|
class Application(metaclass=SingletonMeta):
|
13
|
+
"""
|
14
|
+
The core Application class responsible for bootstrapping and managing the application lifecycle.
|
15
|
+
|
16
|
+
This class follows the Singleton pattern to ensure a single instance throughout the application.
|
17
|
+
|
18
|
+
Attributes
|
19
|
+
----------
|
20
|
+
_config : dict
|
21
|
+
A dictionary to store application configuration.
|
22
|
+
_commands : dict
|
23
|
+
A dictionary to store application commands.
|
24
|
+
_environment_vars : dict
|
25
|
+
A dictionary to store environment variables.
|
26
|
+
container : Container
|
27
|
+
The dependency injection container for the application.
|
28
|
+
|
29
|
+
Methods
|
30
|
+
-------
|
31
|
+
boot()
|
32
|
+
Bootstraps the application by loading environment, configuration, and core providers.
|
33
|
+
_beforeBootstrapProviders()
|
34
|
+
Registers and boots essential providers required before bootstrapping.
|
35
|
+
_bootstraping()
|
36
|
+
Loads user-defined configuration, commands, and environment variables.
|
37
|
+
_afterBootstrapProviders()
|
38
|
+
Registers and boots additional providers after bootstrapping.
|
39
|
+
"""
|
11
40
|
|
12
41
|
def __init__(self, container: Container):
|
42
|
+
"""
|
43
|
+
Initializes the Application instance.
|
13
44
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
45
|
+
Parameters
|
46
|
+
----------
|
47
|
+
container : Container
|
48
|
+
The dependency injection container for the application.
|
49
|
+
"""
|
50
|
+
# Class attributes
|
51
|
+
self._config: dict = {}
|
52
|
+
self._commands: dict = {}
|
53
|
+
self._environment_vars: dict = {}
|
54
|
+
self._booted: bool = False
|
18
55
|
|
19
|
-
#
|
56
|
+
# Initialize the application container
|
20
57
|
self.container = container
|
21
58
|
self.container.instance(container)
|
22
59
|
|
23
|
-
|
24
|
-
|
60
|
+
def isBooted(self) -> bool:
|
61
|
+
"""
|
62
|
+
Check if the application has been booted.
|
63
|
+
|
64
|
+
Returns
|
65
|
+
-------
|
66
|
+
bool
|
67
|
+
True if the application has been booted, False otherwise.
|
68
|
+
"""
|
69
|
+
return self._booted
|
70
|
+
|
71
|
+
def bind(self, concrete: Callable[..., Any]) -> str:
|
72
|
+
"""
|
73
|
+
Bind a callable to the container.
|
74
|
+
This method ensures that the provided callable is not the main function,
|
75
|
+
is unique within the container, and is indeed callable. It then creates
|
76
|
+
a unique key for the callable based on its module and name, and stores
|
77
|
+
the callable in the container's bindings.
|
78
|
+
Args:
|
79
|
+
concrete (Callable[..., Any]): The callable to be bound to the container.
|
80
|
+
Returns:
|
81
|
+
str: The unique key generated for the callable.
|
82
|
+
"""
|
83
|
+
self.container.bind(concrete)
|
84
|
+
|
85
|
+
def transient(self, concrete: Callable[..., Any]) -> str:
|
86
|
+
"""
|
87
|
+
Registers a transient service in the container.
|
88
|
+
A transient service is created each time it is requested.
|
89
|
+
Args:
|
90
|
+
concrete (Callable[..., Any]): The callable that defines the service.
|
91
|
+
Returns:
|
92
|
+
str: The unique key generated for the callable.
|
93
|
+
"""
|
94
|
+
self.container.transient(concrete)
|
95
|
+
|
96
|
+
def singleton(self, concrete: Callable[..., Any]) -> str:
|
97
|
+
"""
|
98
|
+
Registers a callable as a singleton in the container.
|
99
|
+
This method ensures that the provided callable is not the main module,
|
100
|
+
is unique within the container, and is indeed callable. It then registers
|
101
|
+
the callable as a singleton, storing it in the container's singleton registry.
|
102
|
+
Args:
|
103
|
+
concrete (Callable[..., Any]): The callable to be registered as a singleton.
|
104
|
+
Returns:
|
105
|
+
str: The key under which the singleton is registered in the container.
|
106
|
+
"""
|
107
|
+
self.container.singleton(concrete)
|
108
|
+
|
109
|
+
def scoped(self, concrete: Callable[..., Any]) -> str:
|
110
|
+
"""
|
111
|
+
Registers a callable as a scoped service.
|
112
|
+
This method ensures that the provided callable is not the main service,
|
113
|
+
is unique, and is indeed callable. It then registers the callable in the
|
114
|
+
scoped services dictionary with relevant metadata.
|
115
|
+
Args:
|
116
|
+
concrete (Callable[..., Any]): The callable to be registered as a scoped service.
|
117
|
+
Returns:
|
118
|
+
str: The key under which the callable is registered in the scoped services dictionary.
|
119
|
+
"""
|
120
|
+
self.container.scoped(concrete)
|
121
|
+
|
122
|
+
def instance(self, instance: Any) -> str:
|
123
|
+
"""
|
124
|
+
Registers an instance as a singleton in the container.
|
125
|
+
Args:
|
126
|
+
instance (Any): The instance to be registered as a singleton.
|
127
|
+
Returns:
|
128
|
+
str: The key under which the instance is registered in the container.
|
129
|
+
"""
|
130
|
+
self.container.instance(instance)
|
131
|
+
|
132
|
+
def alias(self, alias: str, concrete: Any) -> None:
|
133
|
+
"""
|
134
|
+
Creates an alias for a registered service.
|
135
|
+
Args:
|
136
|
+
alias (str): The alias name to be used for the service.
|
137
|
+
concrete (Any): The actual service instance or callable to be aliased.
|
138
|
+
Raises:
|
139
|
+
OrionisContainerException: If the concrete instance is not a valid object or if the alias is a primitive type.
|
140
|
+
"""
|
141
|
+
self.container.alias(alias, concrete)
|
142
|
+
|
143
|
+
def has(self, obj: Any) -> bool:
|
144
|
+
"""
|
145
|
+
Checks if a service is registered in the container.
|
146
|
+
|
147
|
+
Parameters
|
148
|
+
----------
|
149
|
+
obj : Any
|
150
|
+
The service class, instance, or alias to check.
|
25
151
|
|
26
|
-
|
152
|
+
Returns
|
153
|
+
-------
|
154
|
+
bool
|
155
|
+
True if the service is registered, False otherwise.
|
156
|
+
"""
|
157
|
+
self.container.has(obj)
|
158
|
+
|
159
|
+
def make(self, abstract: Any) -> Any:
|
160
|
+
"""
|
161
|
+
Create and return an instance of a registered service.
|
162
|
+
|
163
|
+
Parameters
|
164
|
+
----------
|
165
|
+
abstract : Any
|
166
|
+
The service class or alias to instantiate.
|
167
|
+
|
168
|
+
Returns
|
169
|
+
-------
|
170
|
+
Any
|
171
|
+
An instance of the requested service.
|
172
|
+
|
173
|
+
Raises
|
174
|
+
------
|
175
|
+
OrionisContainerException
|
176
|
+
If the service is not found in the container.
|
177
|
+
"""
|
178
|
+
self.container.make(abstract)
|
179
|
+
|
180
|
+
def forgetScopedInstances(self) -> None:
|
181
|
+
"""
|
182
|
+
Reset scoped instances at the beginning of a new request.
|
183
|
+
"""
|
184
|
+
self.container.forgetScopedInstances()
|
185
|
+
|
186
|
+
def boot(self):
|
187
|
+
"""
|
188
|
+
Bootstraps the application.
|
189
|
+
|
190
|
+
This method is responsible for loading the environment, configuration, and core providers.
|
191
|
+
It ensures the application is ready to handle requests or commands.
|
192
|
+
"""
|
193
|
+
# Load environment server
|
194
|
+
self._beforeBootstrapProviders()
|
195
|
+
|
196
|
+
# Dynamically load application configuration
|
27
197
|
self._bootstraping()
|
28
198
|
|
29
|
-
#
|
30
|
-
self.
|
199
|
+
# Load core providers
|
200
|
+
self._afterBootstrapProviders()
|
31
201
|
|
32
|
-
#
|
33
|
-
self.
|
202
|
+
# Set the booted flag to True
|
203
|
+
self._booted = True
|
34
204
|
|
35
|
-
def
|
205
|
+
def _beforeBootstrapProviders(self):
|
206
|
+
"""
|
207
|
+
Registers and boots essential providers required before bootstrapping.
|
36
208
|
|
37
|
-
|
209
|
+
This method ensures that environment variables are loaded and available
|
210
|
+
for use during the bootstrapping process.
|
211
|
+
"""
|
212
|
+
# Load the environment provider, which is responsible for returning values from the .env file.
|
213
|
+
# This provider is essential as it must be loaded first to resolve environment variables.
|
214
|
+
# Developers can interact with it through the facade "orionis.luminate.facades.environment.environment_facade.Env".
|
38
215
|
_environment_provider = EnvironmentServiceProvider(app=self.container)
|
39
216
|
_environment_provider.register()
|
40
217
|
_environment_provider.boot()
|
41
218
|
|
42
219
|
def _bootstraping(self):
|
220
|
+
"""
|
221
|
+
Loads user-defined configuration, commands, and environment variables.
|
43
222
|
|
44
|
-
|
45
|
-
|
46
|
-
|
223
|
+
This method initializes the configuration, commands, and environment variables
|
224
|
+
required for the application to function.
|
225
|
+
"""
|
226
|
+
# This initializer loads the user-defined configuration from the "config" folder.
|
227
|
+
# It extracts configuration values and stores them as class properties for future use.
|
228
|
+
config_bootstrapper_key = self.singleton(ConfigBootstrapper)
|
229
|
+
config_bootstrapper: ConfigBootstrapper = self.make(config_bootstrapper_key)
|
47
230
|
self._config = config_bootstrapper.get()
|
48
231
|
|
49
|
-
#
|
50
|
-
|
51
|
-
|
232
|
+
# This initializer dynamically searches for all user-defined commands in the "commands" folder,
|
233
|
+
# both from the framework core and developer-defined commands.
|
234
|
+
# It stores them in a dictionary and registers them in the container.
|
235
|
+
commands_bootstrapper_key = self.singleton(CommandsBootstrapper)
|
236
|
+
commands_bootstrapper: CommandsBootstrapper = self.make(commands_bootstrapper_key)
|
52
237
|
self._commands = commands_bootstrapper.get()
|
238
|
+
for command in self._commands.keys():
|
239
|
+
_key_instance_container = self.bind(self._commands[command].get('concrete'))
|
240
|
+
self.alias(alias=command, concrete=_key_instance_container)
|
53
241
|
|
54
|
-
#
|
55
|
-
|
56
|
-
|
242
|
+
# Load environment variables and store them as class properties.
|
243
|
+
# This is useful for executing future tasks conditioned on environment values.
|
244
|
+
environment_bootstrapper_key = self.singleton(EnvironmentBootstrapper)
|
245
|
+
environment_bootstrapper: EnvironmentBootstrapper = self.make(environment_bootstrapper_key)
|
57
246
|
self._environment_vars = environment_bootstrapper.get()
|
58
247
|
|
59
|
-
def
|
248
|
+
def _afterBootstrapProviders(self):
|
249
|
+
"""
|
250
|
+
Registers and boots additional providers after bootstrapping.
|
60
251
|
|
61
|
-
|
62
|
-
for
|
63
|
-
|
64
|
-
|
252
|
+
This method ensures that configuration and logging providers are loaded
|
253
|
+
and available for use in the application.
|
254
|
+
"""
|
255
|
+
# Load the configuration provider, which is responsible for returning configuration values.
|
256
|
+
# Developers can interact with it through the facade "orionis.luminate.facades.config.config_facade.Config".
|
257
|
+
_environment_provider = ConfigServiceProvider(app=self.container)
|
258
|
+
_environment_provider.register()
|
259
|
+
_environment_provider.boot()
|
65
260
|
|
66
|
-
|
261
|
+
# Load the log provider based on the application configuration defined by the developer.
|
262
|
+
# Developers can interact with it through the facade "orionis.luminate.facades.log.log_facade.Log".
|
263
|
+
_log_provider = LogServiceProvider(app=self.container)
|
264
|
+
_log_provider.register()
|
265
|
+
_log_provider.boot()
|
67
266
|
|
68
|
-
#
|
69
|
-
|
70
|
-
|
71
|
-
|
267
|
+
# Load the commands provider, which is responsible for executing and managing CLI commands.
|
268
|
+
# Developers can interact with it through the facade "orionis.luminate.facades.commands.commands_facade.Commands".
|
269
|
+
_commands_provider = ReactorCommandsServiceProvider(app=self.container)
|
270
|
+
_commands_provider.register()
|
271
|
+
_commands_provider.boot()
|
@@ -139,12 +139,12 @@ class Channels:
|
|
139
139
|
chunked : Chunked
|
140
140
|
Configuration for chunked log file storage.
|
141
141
|
"""
|
142
|
-
stack
|
143
|
-
hourly
|
144
|
-
daily
|
145
|
-
weekly
|
146
|
-
monthly
|
147
|
-
chunked
|
142
|
+
stack : Stack
|
143
|
+
hourly : Hourly
|
144
|
+
daily : Daily
|
145
|
+
weekly : Weekly
|
146
|
+
monthly : Monthly
|
147
|
+
chunked : Chunked
|
148
148
|
|
149
149
|
|
150
150
|
@dataclass
|
@@ -38,12 +38,6 @@ class Container(IContainer):
|
|
38
38
|
cls._instance._validate_types = Types()
|
39
39
|
return cls._instance
|
40
40
|
|
41
|
-
def _newRequest(self) -> None:
|
42
|
-
"""
|
43
|
-
Reset scoped instances at the beginning of a new request.
|
44
|
-
"""
|
45
|
-
self._scoped_instances = {}
|
46
|
-
|
47
41
|
def _ensureNotMain(self, concrete: Callable[..., Any]) -> str:
|
48
42
|
"""
|
49
43
|
Ensure that a class is not defined in the main script.
|
@@ -117,6 +111,12 @@ class Container(IContainer):
|
|
117
111
|
if not isinstance(instance, object) or instance.__class__.__module__ in ['builtins', 'abc']:
|
118
112
|
raise OrionisContainerValueError(f"The instance '{str(instance)}' must be a valid object.")
|
119
113
|
|
114
|
+
def forgetScopedInstances(self) -> None:
|
115
|
+
"""
|
116
|
+
Reset scoped instances at the beginning of a new request.
|
117
|
+
"""
|
118
|
+
self._scoped_instances = {}
|
119
|
+
|
120
120
|
def bind(self, concrete: Callable[..., Any]) -> str:
|
121
121
|
"""
|
122
122
|
Bind a callable to the container.
|
orionis/luminate/facades/app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import Any
|
2
2
|
from orionis.luminate.container.container import Container
|
3
|
-
from orionis.luminate.container.exception import
|
3
|
+
from orionis.luminate.container.exception import OrionisContainerTypeError
|
4
4
|
|
5
5
|
def app(concrete: Any = None):
|
6
6
|
"""
|
@@ -33,8 +33,6 @@ def app(concrete: Any = None):
|
|
33
33
|
|
34
34
|
# If concrete is provided (not None), attempt to resolve it from the container
|
35
35
|
if concrete is not None:
|
36
|
-
if not isinstance(concrete, type):
|
37
|
-
raise OrionisContainerTypeError(f"The provided concrete must be a class or service, got {type(concrete)}.")
|
38
36
|
return container.make(concrete)
|
39
37
|
|
40
38
|
# If concrete is None, return the container instance
|
File without changes
|
@@ -0,0 +1,42 @@
|
|
1
|
+
from typing import Any
|
2
|
+
from orionis.contracts.facades.commands.i_commands_facade import ICommand
|
3
|
+
from orionis.luminate.facades.app import app
|
4
|
+
from orionis.luminate.services.commands.reactor_commands_service import ReactorCommandsService
|
5
|
+
|
6
|
+
class Command(ICommand):
|
7
|
+
"""
|
8
|
+
Command class for managing and executing registered CLI commands.
|
9
|
+
|
10
|
+
This class provides a static method to invoke commands registered in the
|
11
|
+
`CacheCommands` singleton, passing the required signature and any additional
|
12
|
+
parameters.
|
13
|
+
|
14
|
+
Methods
|
15
|
+
-------
|
16
|
+
call(signature: str, vars: dict[str, Any] = {}, *args: Any, **kwargs: Any) -> Any
|
17
|
+
Executes the specified command with the provided arguments.
|
18
|
+
"""
|
19
|
+
|
20
|
+
@staticmethod
|
21
|
+
def call(signature: str, vars: dict[str, Any] = {}, *args: Any, **kwargs: Any) -> Any:
|
22
|
+
"""
|
23
|
+
Calls a registered command using the `CLIRunner`.
|
24
|
+
|
25
|
+
Parameters
|
26
|
+
----------
|
27
|
+
signature : str
|
28
|
+
The command signature (name) to execute.
|
29
|
+
vars : dict[str, Any], optional
|
30
|
+
A dictionary containing named arguments for the command (default is `{}`).
|
31
|
+
*args : Any
|
32
|
+
Additional positional arguments.
|
33
|
+
**kwargs : Any
|
34
|
+
Additional keyword arguments.
|
35
|
+
|
36
|
+
Returns
|
37
|
+
-------
|
38
|
+
Any
|
39
|
+
The output of the executed command.
|
40
|
+
"""
|
41
|
+
_commands_provider : ReactorCommandsService = app(ReactorCommandsService)
|
42
|
+
return _commands_provider.execute(signature, vars, *args, **kwargs)
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
from orionis.luminate.providers.service_provider import ServiceProvider
|
2
|
+
from orionis.luminate.services.commands.reactor_commands_service import ReactorCommandsService
|
3
|
+
|
4
|
+
class ReactorCommandsServiceProvider(ServiceProvider):
|
5
|
+
|
6
|
+
def register(self) -> None:
|
7
|
+
"""
|
8
|
+
Registers services or bindings into the given container.
|
9
|
+
"""
|
10
|
+
self._container_id = self.app.singleton(ReactorCommandsService)
|
11
|
+
|
12
|
+
def boot(self,) -> None:
|
13
|
+
"""
|
14
|
+
Boot the service provider.
|
15
|
+
|
16
|
+
This method is intended to be overridden by subclasses to perform
|
17
|
+
any necessary bootstrapping or initialization tasks.
|
18
|
+
"""
|
19
|
+
self.app.make(self._container_id)
|
File without changes
|
@@ -0,0 +1,127 @@
|
|
1
|
+
import time
|
2
|
+
from typing import Any, Dict, Optional
|
3
|
+
from orionis.contracts.services.commands.i_reactor_commands_service import IReactorCommandsService
|
4
|
+
from orionis.luminate.bootstrap.command_bootstrapper import CommandsBootstrapper
|
5
|
+
from orionis.luminate.console.base.command import BaseCommand
|
6
|
+
from orionis.luminate.console.command_filter import CommandFilter
|
7
|
+
from orionis.luminate.console.exceptions.cli_exception import CLIOrionisException
|
8
|
+
from orionis.luminate.console.output.console import Console
|
9
|
+
from orionis.luminate.console.output.executor import Executor
|
10
|
+
from orionis.luminate.console.parser import Parser
|
11
|
+
from orionis.luminate.facades.app import app
|
12
|
+
from orionis.luminate.facades.log.log_facade import Log
|
13
|
+
|
14
|
+
class ReactorCommandsService(IReactorCommandsService):
|
15
|
+
"""
|
16
|
+
Service responsible for executing and managing CLI commands in Orionis.
|
17
|
+
|
18
|
+
This service handles:
|
19
|
+
- Parsing command arguments.
|
20
|
+
- Executing commands and logging their output.
|
21
|
+
- Managing execution timing and error handling.
|
22
|
+
"""
|
23
|
+
|
24
|
+
def __init__(
|
25
|
+
self,
|
26
|
+
commands_bootstrapper: CommandsBootstrapper,
|
27
|
+
command_filter: CommandFilter,
|
28
|
+
log: Log,
|
29
|
+
executor: Executor,
|
30
|
+
console: Console,
|
31
|
+
):
|
32
|
+
"""
|
33
|
+
Initializes the ReactorCommandsService instance.
|
34
|
+
|
35
|
+
Assigns provided services to internal attributes for later use in command
|
36
|
+
execution, filtering, and logging.
|
37
|
+
"""
|
38
|
+
self.commands_bootstrapper = commands_bootstrapper
|
39
|
+
self.command_filter = command_filter
|
40
|
+
self.log = log
|
41
|
+
self.console_executor = executor
|
42
|
+
self.console_output = console
|
43
|
+
|
44
|
+
def _parse_arguments(
|
45
|
+
self, arguments, vars: Optional[Dict[str, Any]] = None, *args, **kwargs
|
46
|
+
):
|
47
|
+
"""
|
48
|
+
Parses command-line arguments using the Orionis argument parser.
|
49
|
+
|
50
|
+
Utilizes an internal parser to convert raw arguments into structured data.
|
51
|
+
Handles exceptions to ensure errors are properly raised and managed.
|
52
|
+
"""
|
53
|
+
try:
|
54
|
+
arg_parser = Parser(vars=vars or {}, args=args, kwargs=kwargs)
|
55
|
+
arg_parser.setArguments(arguments=arguments)
|
56
|
+
arg_parser.recognize()
|
57
|
+
return arg_parser.get()
|
58
|
+
except Exception as e:
|
59
|
+
raise ValueError(f"Error parsing arguments: {e}")
|
60
|
+
|
61
|
+
def execute(self, signature: Optional[str] = None, vars: dict = {}, *args, **kwargs):
|
62
|
+
"""
|
63
|
+
Processes and executes a CLI command.
|
64
|
+
|
65
|
+
Determines if the command originates from `sys.argv` or is explicitly called,
|
66
|
+
then executes the appropriate command pipeline, handling success and errors.
|
67
|
+
"""
|
68
|
+
try:
|
69
|
+
|
70
|
+
# Determine if command is excluded from running
|
71
|
+
exclude_running = self.command_filter.isExcluded(signature)
|
72
|
+
sys_argv = signature is None
|
73
|
+
|
74
|
+
# Start timing execution
|
75
|
+
start_time = time.perf_counter()
|
76
|
+
|
77
|
+
# Extract signature and arguments from command-line input
|
78
|
+
if sys_argv:
|
79
|
+
if not args or len(args[0]) <= 1:
|
80
|
+
raise CLIOrionisException("No command signature specified. Please provide a valid command to execute.")
|
81
|
+
args_list = args[0]
|
82
|
+
signature, *args = args_list[1:]
|
83
|
+
|
84
|
+
# Log command execution
|
85
|
+
self.log.info(f"Running command: {signature}")
|
86
|
+
|
87
|
+
# Notify console
|
88
|
+
if not exclude_running:
|
89
|
+
self.console_executor.running(program=signature)
|
90
|
+
|
91
|
+
# Retrieve command from bootstrapper
|
92
|
+
command = self.commands_bootstrapper.get(signature)
|
93
|
+
|
94
|
+
# Parse command arguments dynamically based on execution context
|
95
|
+
args_dict = self._parse_arguments(command.get('arguments', []), vars, *args, **kwargs)
|
96
|
+
|
97
|
+
# Instantiate command and execute it
|
98
|
+
command_instance: BaseCommand = app(signature)
|
99
|
+
command_instance.setArgs(args_dict)
|
100
|
+
output = command_instance.handle(**vars(args_dict))
|
101
|
+
|
102
|
+
# Log successful command execution
|
103
|
+
self.log.success(f"Command executed successfully: {signature}")
|
104
|
+
|
105
|
+
# Finalize execution and report elapsed time
|
106
|
+
if not exclude_running:
|
107
|
+
elapsed_time = round(time.perf_counter() - start_time, 2)
|
108
|
+
self.console_executor.done(program=signature, time=f"{elapsed_time}s")
|
109
|
+
|
110
|
+
# Return command output
|
111
|
+
return output
|
112
|
+
|
113
|
+
except ValueError as e:
|
114
|
+
# Handle parsing errors
|
115
|
+
self.log.error(f"Command failed: {signature or 'Unknown'}, Value Error: {e}")
|
116
|
+
if not exclude_running:
|
117
|
+
self.console_output.error(message=f"Value Error: {e}")
|
118
|
+
elapsed_time = round(time.perf_counter() - start_time, 2)
|
119
|
+
self.console_executor.fail(program=signature or "Unknown", time=f"{elapsed_time}s")
|
120
|
+
|
121
|
+
except Exception as e:
|
122
|
+
# Handle unexpected execution errors
|
123
|
+
self.log.error(f"Command failed: {signature or 'Unknown'}, Execution Error: {e}")
|
124
|
+
if not exclude_running:
|
125
|
+
self.console_output.error(message=f"Execution Error: {e}")
|
126
|
+
elapsed_time = round(time.perf_counter() - start_time, 2)
|
127
|
+
self.console_executor.fail(program=signature or "Unknown", time=f"{elapsed_time}s")
|
@@ -49,19 +49,6 @@ class LogguerService(ILogguerService):
|
|
49
49
|
self.config_service = config_service
|
50
50
|
self._initialize_logger()
|
51
51
|
|
52
|
-
def _path_resolver(self, filename: str):
|
53
|
-
"""
|
54
|
-
Resolves the log file path based on the specified filename.
|
55
|
-
"""
|
56
|
-
base_path = Path(os.getcwd())
|
57
|
-
log_dir = base_path / "storage" / "logs"
|
58
|
-
|
59
|
-
# Create the log directory if it does not exist
|
60
|
-
if not log_dir.exists():
|
61
|
-
log_dir.mkdir(parents=True, exist_ok=True)
|
62
|
-
|
63
|
-
return log_dir / filename
|
64
|
-
|
65
52
|
def _initialize_logger(self):
|
66
53
|
"""
|
67
54
|
Configures the logger with the specified settings.
|
@@ -82,6 +69,8 @@ class LogguerService(ILogguerService):
|
|
82
69
|
"""
|
83
70
|
try:
|
84
71
|
|
72
|
+
handlers = []
|
73
|
+
|
85
74
|
channel : str = self.config_service.get("logging.default")
|
86
75
|
config : dict = self.config_service.get(f"logging.channels.{channel}", {})
|
87
76
|
path : str = config.get("path", 'logs/orionis.log')
|
@@ -91,7 +80,7 @@ class LogguerService(ILogguerService):
|
|
91
80
|
|
92
81
|
handlers = [
|
93
82
|
logging.FileHandler(
|
94
|
-
filename=
|
83
|
+
filename=path,
|
95
84
|
encoding="utf-8"
|
96
85
|
)
|
97
86
|
]
|
@@ -100,7 +89,7 @@ class LogguerService(ILogguerService):
|
|
100
89
|
|
101
90
|
handlers = [
|
102
91
|
TimedRotatingFileHandler(
|
103
|
-
filename=
|
92
|
+
filename=path,
|
104
93
|
when="h",
|
105
94
|
interval=1,
|
106
95
|
backupCount=config.get('retention_hours', 24),
|
@@ -111,16 +100,16 @@ class LogguerService(ILogguerService):
|
|
111
100
|
|
112
101
|
elif channel == "daily":
|
113
102
|
|
114
|
-
backup_count
|
115
|
-
hour_at
|
116
|
-
if backup_count < 1
|
103
|
+
backup_count = config.get('retention_days', 30)
|
104
|
+
hour_at:str = config.get('at', "00:00")
|
105
|
+
if backup_count < 1:
|
117
106
|
raise ValueError("The 'retention_days' value must be an integer greater than 0.")
|
118
107
|
if not bool(re.match(r"^(?:[01]?\d|2[0-3]):[0-5]?\d$", hour_at)):
|
119
108
|
raise ValueError("The 'at' value must be a valid time in the format HH:MM.")
|
120
109
|
|
121
110
|
handlers = [
|
122
111
|
TimedRotatingFileHandler(
|
123
|
-
filename=
|
112
|
+
filename=path,
|
124
113
|
when="d",
|
125
114
|
interval=1,
|
126
115
|
backupCount=backup_count,
|
@@ -132,12 +121,12 @@ class LogguerService(ILogguerService):
|
|
132
121
|
|
133
122
|
elif channel == "weekly":
|
134
123
|
|
135
|
-
backup_count
|
136
|
-
if backup_count < 1
|
124
|
+
backup_count = config.get('retention_weeks', 4)
|
125
|
+
if backup_count < 1:
|
137
126
|
raise ValueError("The 'retention_weeks' value must be an integer greater than 0.")
|
138
127
|
handlers = [
|
139
128
|
TimedRotatingFileHandler(
|
140
|
-
filename=
|
129
|
+
filename=path,
|
141
130
|
when="w0",
|
142
131
|
interval=1,
|
143
132
|
backupCount=backup_count,
|
@@ -148,12 +137,12 @@ class LogguerService(ILogguerService):
|
|
148
137
|
|
149
138
|
elif channel == "monthly":
|
150
139
|
|
151
|
-
backup_count
|
152
|
-
if backup_count < 1
|
140
|
+
backup_count = config.get('retention_months', 2)
|
141
|
+
if backup_count < 1:
|
153
142
|
raise ValueError("The 'retention_months' value must be an integer greater than 0.")
|
154
143
|
handlers = [
|
155
144
|
TimedRotatingFileHandler(
|
156
|
-
filename=
|
145
|
+
filename=path,
|
157
146
|
when="midnight",
|
158
147
|
interval=30,
|
159
148
|
backupCount=backup_count,
|
@@ -164,15 +153,15 @@ class LogguerService(ILogguerService):
|
|
164
153
|
|
165
154
|
elif channel == "chunked":
|
166
155
|
|
167
|
-
max_bytes
|
168
|
-
if max_bytes < 1
|
156
|
+
max_bytes = config.get('mb_size', 5)
|
157
|
+
if max_bytes < 1:
|
169
158
|
raise ValueError("The 'mb_size' value must be an integer greater than 0.")
|
170
|
-
backup_count
|
171
|
-
if backup_count < 1
|
159
|
+
backup_count = config.get('max_files', 5)
|
160
|
+
if backup_count < 1:
|
172
161
|
raise ValueError("The 'max_files' value must be an integer greater than 0.")
|
173
162
|
handlers = [
|
174
163
|
RotatingFileHandler(
|
175
|
-
filename=
|
164
|
+
filename=path,
|
176
165
|
maxBytes= max_bytes * 1024 * 1024,
|
177
166
|
backupCount=backup_count,
|
178
167
|
encoding="utf-8"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
orionis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
orionis/cli_manager.py,sha256=0bM-hABXJSoPGuvEgnqeaj9qcLP8VjTQ3z9Mb0TSEUI,1381
|
3
|
-
orionis/framework.py,sha256=
|
3
|
+
orionis/framework.py,sha256=czq_vQU4HeqXvnXqiNgD86PKF5N3Y6j1B2bj74FNMag,1386
|
4
4
|
orionis/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
orionis/contracts/bootstrap/i_command_bootstrapper.py,sha256=cfpYWSlNhOY1q_C9o0H7F381OoM0Oh0qaeqP-c85nzk,2457
|
6
6
|
orionis/contracts/bootstrap/i_config_bootstrapper.py,sha256=d2TXT74H2fCBbzWgrt9-ZG11S_H_YPQOEcJoIOrsgb0,4462
|
@@ -20,9 +20,11 @@ orionis/contracts/console/output/i_executor.py,sha256=MGMTTPSwF8dgCjHD3A4CKtYDaC
|
|
20
20
|
orionis/contracts/console/output/i_progress_bar.py,sha256=sOkQzQsliFemqZHMyzs4fWhNJfXDTk5KH3aExReetSE,1760
|
21
21
|
orionis/contracts/console/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
22
|
orionis/contracts/console/tasks/i_schedule.py,sha256=_dsR0gCvJ7_67lwPUAzBwQFHNvWM6jVjcg1EdPqDIIo,10117
|
23
|
-
orionis/contracts/container/i_container.py,sha256=
|
23
|
+
orionis/contracts/container/i_container.py,sha256=MSJkVNawcovxSUAG-nrEctMYLT8H0OJq15pL5UwJeqA,6932
|
24
24
|
orionis/contracts/container/i_types.py,sha256=GCH7x3PjpXKPET3l84GcXbcM8cpne8AGrmTw-uFaT24,526
|
25
25
|
orionis/contracts/facades/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
26
|
+
orionis/contracts/facades/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
|
+
orionis/contracts/facades/commands/i_commands_facade.py,sha256=LpSfZb3lTmhgMx0H42NmFbKLvcOqSDIbpQrkQpF9RPY,1274
|
26
28
|
orionis/contracts/facades/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
29
|
orionis/contracts/facades/config/i_config_facade.py,sha256=Yzc0mB4W9XF8cZTdTO78AKUiyGaiShl1k8nJiecvKTc,970
|
28
30
|
orionis/contracts/facades/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -40,6 +42,8 @@ orionis/contracts/installer/i_installer_setup.py,sha256=enXOusaAJVWamTpH9FjXpJf-
|
|
40
42
|
orionis/contracts/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
41
43
|
orionis/contracts/providers/i_service_provider.py,sha256=zoBAsGE-KrNfCsF3u876oxoa518zMuBD9npRK7BixUs,791
|
42
44
|
orionis/contracts/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
45
|
+
orionis/contracts/services/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
46
|
+
orionis/contracts/services/commands/i_reactor_commands_service.py,sha256=msIOfwOYASFNuS4shhwsnukPH5_XnuxNBHW9f6q-Lqo,795
|
43
47
|
orionis/contracts/services/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
44
48
|
orionis/contracts/services/config/i_config_service.py,sha256=TdlEEsd8jvzBGozwaZtQ9KYHisY4ACL-VUOtydidHeE,989
|
45
49
|
orionis/contracts/services/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -56,10 +60,10 @@ orionis/installer/installer_manager.py,sha256=Hb6T0bmSl39T30maY-nUWkrLhG77JdrKe4
|
|
56
60
|
orionis/installer/installer_output.py,sha256=LeKxzuXpnHOKbKpUtx3tMGkCi2bGcPV1VNnfBxwfxUU,7161
|
57
61
|
orionis/installer/installer_setup.py,sha256=c2HtVklSa-2_-YVonc7fwtoK-RTDqBS2Ybvbekgfqtc,6970
|
58
62
|
orionis/luminate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
59
|
-
orionis/luminate/app.py,sha256=
|
63
|
+
orionis/luminate/app.py,sha256=_kMCDsUX6A5XN0bCv847F3d6hDEGobHlinfi-38Donk,11545
|
60
64
|
orionis/luminate/app_context.py,sha256=XREVkOHU6aP8UB2daA2QbFcOCB8HRmcGXjVbrlW1AHQ,1827
|
61
65
|
orionis/luminate/bootstrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
62
|
-
orionis/luminate/bootstrap/command_bootstrapper.py,sha256=
|
66
|
+
orionis/luminate/bootstrap/command_bootstrapper.py,sha256=JJkWWOS2R2Zg7mC7-VMtZ0wAgxlegMkdnqudpbAjxwk,6925
|
63
67
|
orionis/luminate/bootstrap/config_bootstrapper.py,sha256=Gw83UtPAOggwzqmz062JfJcpIfmZvmIQyZJfgVFiIcQ,7474
|
64
68
|
orionis/luminate/bootstrap/environment_bootstrapper.py,sha256=GTZ-mBumoNlxYcqsQksw4XyH3TRfPkWAU62mB3wFKLk,2777
|
65
69
|
orionis/luminate/bootstrap/exception_bootstrapper.py,sha256=wDKfEW295c7-bavr7YUHK2CLYcTSZgjT9ZRSBne6GOE,1356
|
@@ -71,7 +75,7 @@ orionis/luminate/config/cache.py,sha256=nBKmDFDb91sbBriEsVLjMhrNb__j7YsRzZGQRDdA
|
|
71
75
|
orionis/luminate/config/cors.py,sha256=zWKUylPiaUzGXTJM3eLmwY0HcAD7iOLp9QiAoTyAL08,2275
|
72
76
|
orionis/luminate/config/database.py,sha256=oj-FQWtbwIYrJAQktSGBl96EZu78fr6IBcQxHbWDVBM,5619
|
73
77
|
orionis/luminate/config/filesystems.py,sha256=fAn4Wx6naIb8E4U2TXJhVnx0Ipxpxc_Ee2w_FWfwlHI,2444
|
74
|
-
orionis/luminate/config/logging.py,sha256=
|
78
|
+
orionis/luminate/config/logging.py,sha256=s3QTCZtshRuMdWWpEKuM2Z-gT9Lf29Or7o_mJKfU8Ig,4047
|
75
79
|
orionis/luminate/config/mail.py,sha256=3iYXG72bXiVns4sEPZ_A3-cGcFjGEGDXkuLKkk-hKtY,2102
|
76
80
|
orionis/luminate/config/queue.py,sha256=DYjP5zD09ISsIX117wtOfjiG_iQrcrPoQVeeftmuO3c,1739
|
77
81
|
orionis/luminate/config/session.py,sha256=7mOC_DfGIBDqAClSiewHoTA9Kht_zdHApvALcZc7cfY,1861
|
@@ -79,7 +83,6 @@ orionis/luminate/console/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
79
83
|
orionis/luminate/console/command_filter.py,sha256=os5BxR6Rcmihrv34pD-fFTkRms_nZzCIrV7vr4RNuIU,1322
|
80
84
|
orionis/luminate/console/kernel.py,sha256=uh3IeR3qI3X0esyw9dxE0LzQ6ueSd_2suMijtQn3HWM,939
|
81
85
|
orionis/luminate/console/parser.py,sha256=qif0eR54bwaVOiugVQh-NUks35XD2VofWbJlRpfR8lg,5579
|
82
|
-
orionis/luminate/console/runner.py,sha256=7oLEZpJ4lPf4YkP9bj7wvgT9GJ2gUJv81JKXEdD0gA0,4820
|
83
86
|
orionis/luminate/console/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
84
87
|
orionis/luminate/console/base/command.py,sha256=YGHd5xVYILcNhQumi74IRnzvagvjufEO2Bx1CwHRToY,12544
|
85
88
|
orionis/luminate/console/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -97,11 +100,13 @@ orionis/luminate/console/output/progress_bar.py,sha256=ssi8Drryr-shl7OxweTgGOhvR
|
|
97
100
|
orionis/luminate/console/output/styles.py,sha256=2e1_FJdNpKaVqmdlCx-udzTleH_6uEFE9_TjH7T1ZUk,3696
|
98
101
|
orionis/luminate/console/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
99
102
|
orionis/luminate/console/tasks/scheduler.py,sha256=zt4p2VGUYGGrG2-E-MxyheKjBqGDJB2c0irULDsBgIw,22678
|
100
|
-
orionis/luminate/container/container.py,sha256=
|
103
|
+
orionis/luminate/container/container.py,sha256=Ruyhs5OAiO6nMFhGDm7TNQD4qqFO0lh_phqUFDit_bE,16429
|
101
104
|
orionis/luminate/container/exception.py,sha256=ap1SqYEjQEEHXJJTNmL7V1jrmRjgT5_7geZ95MYkhMA,1691
|
102
105
|
orionis/luminate/container/types.py,sha256=BDcXN0__voRNHZ5Gr5dF0sWIYAQyNk4TxAwILBWyDAA,1735
|
103
106
|
orionis/luminate/facades/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
104
|
-
orionis/luminate/facades/app.py,sha256=
|
107
|
+
orionis/luminate/facades/app.py,sha256=DHwCdhfU-Mfj0gPX5nwXR_cgnkvg6agMP2WBa-L0JE8,1294
|
108
|
+
orionis/luminate/facades/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
109
|
+
orionis/luminate/facades/commands/commands_facade.py,sha256=xy-5sW5_fDXhS2y0c0CCbBOfrOR0mJQLVTwBe3J8WTk,1561
|
105
110
|
orionis/luminate/facades/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
106
111
|
orionis/luminate/facades/config/config_facade.py,sha256=xpyVdH_-CeOvtMuf-Pjl9SFZWOflXzx9lyDy_fYOmxU,1353
|
107
112
|
orionis/luminate/facades/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -114,10 +119,10 @@ orionis/luminate/facades/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
|
|
114
119
|
orionis/luminate/facades/tests/tests_facade.py,sha256=eH_fyXjzEVw8aqEwxAgSujFUItz2woau6hc2Mf4VlkE,1660
|
115
120
|
orionis/luminate/patterns/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
116
121
|
orionis/luminate/patterns/singleton.py,sha256=b3U0nubKSQWyal5wTXADVPtOztkaTk-M8Zwy-bje1L0,1425
|
117
|
-
orionis/luminate/pipelines/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
118
|
-
orionis/luminate/pipelines/cli_pipeline.py,sha256=xpdwxArZrYqaeo4h375RQwY329V14S8DJC9z1w_Ar1s,4218
|
119
122
|
orionis/luminate/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
120
123
|
orionis/luminate/providers/service_provider.py,sha256=Ave9V10KPVCI6bt3HwJ51322P-_RnQuHXkC-ltlAOOA,1537
|
124
|
+
orionis/luminate/providers/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
125
|
+
orionis/luminate/providers/commands/reactor_commands_service_provider.py,sha256=3HX3wwPCH_Y9OsoTyfC4_LrNlPW_-UaffDcz3Wehuvk,701
|
121
126
|
orionis/luminate/providers/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
122
127
|
orionis/luminate/providers/config/config_service_provider.py,sha256=NLKB3Vcu4kqZ0WyeImMG3CsclSu_P4aWs6yXitcv474,659
|
123
128
|
orionis/luminate/providers/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -125,6 +130,8 @@ orionis/luminate/providers/environment/environment__service_provider.py,sha256=L
|
|
125
130
|
orionis/luminate/providers/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
126
131
|
orionis/luminate/providers/log/log_service_provider.py,sha256=tcWDEI-fubi1mWSS-IKiRReuc0pRMHpxvbvuDgs2Uy0,654
|
127
132
|
orionis/luminate/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
133
|
+
orionis/luminate/services/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
134
|
+
orionis/luminate/services/commands/reactor_commands_service.py,sha256=913caIBsrbjfVh2oPXLKNMGnSRTFPAn4V9vwbGmV-is,5490
|
128
135
|
orionis/luminate/services/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
129
136
|
orionis/luminate/services/config/config_service.py,sha256=sVqX3UBxZA5whjiVFgfo5fzAb8QxD0NT0OYYlgZUK0g,2223
|
130
137
|
orionis/luminate/services/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -132,7 +139,7 @@ orionis/luminate/services/environment/environment_service.py,sha256=IgrfzLELNhnE
|
|
132
139
|
orionis/luminate/services/files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
133
140
|
orionis/luminate/services/files/path_resolver_service.py,sha256=E-G_E2H5QAZyxeMssARp7l1OBSxQurxkUPoKdSOCKEE,2041
|
134
141
|
orionis/luminate/services/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
135
|
-
orionis/luminate/services/log/log_service.py,sha256=
|
142
|
+
orionis/luminate/services/log/log_service.py,sha256=gYbjDV4Lh2f4qFbDItWtZ68pywTITyNkLyv2jyzbZz0,8130
|
136
143
|
orionis/luminate/support/dot_dict.py,sha256=FVHfBuAGTTVMjNG01Fix645fRNKKUMmNx61pYkxPL5c,1253
|
137
144
|
orionis/luminate/support/exception_to_dict.py,sha256=jpQ-c7ud1JLm8dTWbvMT1dI-rL3yTB2P8VxNscAX71k,2098
|
138
145
|
orionis/luminate/support/reflection.py,sha256=VYpluTQJ0W_m6jYQ9_L02sYFrk2wlLYtLY2yp9rZMKA,11944
|
@@ -153,9 +160,9 @@ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
153
160
|
tests/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
154
161
|
tests/tools/class_example.py,sha256=dIPD997Y15n6WmKhWoOFSwEldRm9MdOHTZZ49eF1p3c,1056
|
155
162
|
tests/tools/test_reflection.py,sha256=bhLQ7VGVod4B8sv-rW9AjnOumvaBVsoxieA3sdoM2yM,5244
|
156
|
-
orionis-0.
|
157
|
-
orionis-0.
|
158
|
-
orionis-0.
|
159
|
-
orionis-0.
|
160
|
-
orionis-0.
|
161
|
-
orionis-0.
|
163
|
+
orionis-0.82.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
|
164
|
+
orionis-0.82.0.dist-info/METADATA,sha256=9Xe_QyLbOju0fAyHCnNS1APyEiDBNx5uxCNoUHqNX5o,2978
|
165
|
+
orionis-0.82.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
166
|
+
orionis-0.82.0.dist-info/entry_points.txt,sha256=eef1_CVewfokKjrGBynXa06KabSJYo7LlDKKIKvs1cM,53
|
167
|
+
orionis-0.82.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
|
168
|
+
orionis-0.82.0.dist-info/RECORD,,
|
@@ -1,127 +0,0 @@
|
|
1
|
-
# import time
|
2
|
-
# from orionis.luminate.facades.log import Log
|
3
|
-
# from orionis.luminate.console.output.console import Console
|
4
|
-
# from orionis.luminate.console.output.executor import Executor
|
5
|
-
# from orionis.luminate.pipelines.cli_pipeline import CLIPipeline
|
6
|
-
# from orionis.luminate.console.command_filter import CommandFilter
|
7
|
-
# from orionis.luminate.contracts.console.runner_interface import ICLIRunner
|
8
|
-
|
9
|
-
class CLIRunner:
|
10
|
-
pass
|
11
|
-
# """
|
12
|
-
# CLIRunner manages the execution of CLI commands in Orionis.
|
13
|
-
|
14
|
-
# This class:
|
15
|
-
# - Parses command-line arguments or function parameters.
|
16
|
-
# - Executes commands through the `CLIPipeline`.
|
17
|
-
# - Logs execution status and errors.
|
18
|
-
|
19
|
-
# Methods
|
20
|
-
# -------
|
21
|
-
# handle(signature: str = None, vars: dict = {}, *args, **kwargs)
|
22
|
-
# Processes and executes a CLI command based on provided arguments.
|
23
|
-
# """
|
24
|
-
|
25
|
-
# @staticmethod
|
26
|
-
# def handle(signature: str = None, vars: dict = {}, *args, **kwargs):
|
27
|
-
# """
|
28
|
-
# Processes and executes a CLI command.
|
29
|
-
|
30
|
-
# This method:
|
31
|
-
# - Determines whether the command is invoked from `sys.argv` or as a function.
|
32
|
-
# - Extracts the command signature and arguments.
|
33
|
-
# - Executes the command pipeline.
|
34
|
-
# - Logs execution status and handles errors.
|
35
|
-
|
36
|
-
# Parameters
|
37
|
-
# ----------
|
38
|
-
# signature : str, optional
|
39
|
-
# The command signature (default is None, meaning it is extracted from `sys.argv`).
|
40
|
-
# vars : dict, optional
|
41
|
-
# Named arguments for the command (default is an empty dictionary).
|
42
|
-
# *args
|
43
|
-
# Additional arguments for the command.
|
44
|
-
# **kwargs
|
45
|
-
# Additional keyword arguments for the command.
|
46
|
-
|
47
|
-
# Returns
|
48
|
-
# -------
|
49
|
-
# Any
|
50
|
-
# The output of the executed command.
|
51
|
-
|
52
|
-
# Raises
|
53
|
-
# ------
|
54
|
-
# ValueError
|
55
|
-
# If no command signature is provided.
|
56
|
-
# Exception
|
57
|
-
# If an unexpected error occurs during execution.
|
58
|
-
# """
|
59
|
-
|
60
|
-
# try:
|
61
|
-
|
62
|
-
# # Exclude commands from Printing
|
63
|
-
# exclude_running = CommandFilter.isExcluded(signature)
|
64
|
-
|
65
|
-
# # Determine if command is being executed from sys.argv
|
66
|
-
# sys_argv = signature is None
|
67
|
-
|
68
|
-
# # Start execution timer
|
69
|
-
# start_time = time.perf_counter()
|
70
|
-
|
71
|
-
# # Handle command signature extraction from sys.argv
|
72
|
-
# if sys_argv:
|
73
|
-
|
74
|
-
# # Extract command signature and arguments from sys.argv
|
75
|
-
# if not args or len(args[0]) <= 1:
|
76
|
-
# raise ValueError("No command signature specified.")
|
77
|
-
|
78
|
-
# # Extract command signature and arguments
|
79
|
-
# args_list = args[0]
|
80
|
-
# signature, *args = args_list[1:]
|
81
|
-
|
82
|
-
# # Log command execution start
|
83
|
-
# Log.info(f"Running command: {signature}")
|
84
|
-
|
85
|
-
# if not exclude_running:
|
86
|
-
# Executor.running(program=signature)
|
87
|
-
|
88
|
-
# # Initialize command pipeline
|
89
|
-
# pipeline = CLIPipeline().getCommand(signature)
|
90
|
-
|
91
|
-
# # Parse arguments based on invocation type
|
92
|
-
# if sys_argv:
|
93
|
-
# pipeline.parseArguments(*args)
|
94
|
-
# else:
|
95
|
-
# pipeline.parseArguments(vars, *args, **kwargs)
|
96
|
-
|
97
|
-
# # Execute the command
|
98
|
-
# output = pipeline.execute()
|
99
|
-
|
100
|
-
# # Log successful execution
|
101
|
-
# Log.success(f"Command executed successfully: {signature}")
|
102
|
-
|
103
|
-
# # Calculate execution time
|
104
|
-
# if not exclude_running:
|
105
|
-
# elapsed_time = round(time.perf_counter() - start_time, 2)
|
106
|
-
# Executor.done(program=signature, time=f"{elapsed_time}s")
|
107
|
-
|
108
|
-
# # Return command output
|
109
|
-
# return output
|
110
|
-
|
111
|
-
# except ValueError as e:
|
112
|
-
|
113
|
-
# # Handle missing or invalid command signature
|
114
|
-
# Log.error(f"Command failed: {signature or 'Unknown'}, Value Error: {e}")
|
115
|
-
# if not exclude_running:
|
116
|
-
# Console.error(message=f"Value Error: {e}")
|
117
|
-
# elapsed_time = round(time.perf_counter() - start_time, 2)
|
118
|
-
# Executor.fail(program=signature or "Unknown", time=f"{elapsed_time}s")
|
119
|
-
|
120
|
-
# except Exception as e:
|
121
|
-
|
122
|
-
# # Handle unexpected errors
|
123
|
-
# Log.error(f"Command failed: {signature or 'Unknown'}, Execution Error: {e}")
|
124
|
-
# if not exclude_running:
|
125
|
-
# Console.error(message=f"Execution Error: {e}")
|
126
|
-
# elapsed_time = round(time.perf_counter() - start_time, 2)
|
127
|
-
# Executor.fail(program=signature or "Unknown", time=f"{elapsed_time}s")
|
@@ -1,122 +0,0 @@
|
|
1
|
-
# import argparse
|
2
|
-
# from typing import Dict, Any, Optional
|
3
|
-
# from orionis.luminate.app_context import AppContext
|
4
|
-
# from orionis.luminate.console.parser import Parser
|
5
|
-
# from orionis.luminate.console.cache import CLICache
|
6
|
-
# from orionis.luminate.console.base.command import BaseCommand
|
7
|
-
# from orionis.luminate.contracts.pipelines.cli_pipeline_interface import ICLIPipeline
|
8
|
-
|
9
|
-
class CLIPipeline:
|
10
|
-
pass
|
11
|
-
# """
|
12
|
-
# Handles the retrieval, parsing, and execution of CLI commands within the Orionis framework.
|
13
|
-
|
14
|
-
# This class is responsible for:
|
15
|
-
# - Retrieving command metadata from cache.
|
16
|
-
# - Parsing command-line arguments dynamically.
|
17
|
-
# - Executing the corresponding command with parsed arguments.
|
18
|
-
|
19
|
-
# Attributes
|
20
|
-
# ----------
|
21
|
-
# _command : dict
|
22
|
-
# Stores the command's metadata, including its instance and expected arguments.
|
23
|
-
# _parsed_arguments : argparse.Namespace
|
24
|
-
# Holds parsed arguments after processing user input.
|
25
|
-
# """
|
26
|
-
|
27
|
-
# def __init__(self):
|
28
|
-
# """
|
29
|
-
# Initializes the CLIPipeline instance with an empty command cache
|
30
|
-
# and a default argument namespace.
|
31
|
-
# """
|
32
|
-
# self._command: Dict[str, Any] = {}
|
33
|
-
# self._parsed_arguments: argparse.Namespace = argparse.Namespace()
|
34
|
-
|
35
|
-
# def getCommand(self, signature: str) -> "CLIPipeline":
|
36
|
-
# """
|
37
|
-
# Retrieves a command from the cache based on its signature.
|
38
|
-
|
39
|
-
# Parameters
|
40
|
-
# ----------
|
41
|
-
# signature : str
|
42
|
-
# The unique identifier of the command.
|
43
|
-
|
44
|
-
# Returns
|
45
|
-
# -------
|
46
|
-
# CLIPipeline
|
47
|
-
# The current instance of CLIPipeline for method chaining.
|
48
|
-
|
49
|
-
# Raises
|
50
|
-
# ------
|
51
|
-
# ValueError
|
52
|
-
# If the command signature is not found in the cache.
|
53
|
-
# """
|
54
|
-
# with AppContext() as app:
|
55
|
-
# config_service : BaseCommand = app.container.run_command("config")
|
56
|
-
# config_service.
|
57
|
-
|
58
|
-
# try:
|
59
|
-
# cache = CLICache().getCommands()
|
60
|
-
# self._command = cache.get(signature)
|
61
|
-
# return self
|
62
|
-
# except KeyError as e:
|
63
|
-
# raise ValueError(e)
|
64
|
-
|
65
|
-
# def parseArguments(self, vars: Optional[Dict[str, Any]] = None, *args, **kwargs) -> "CLIPipeline":
|
66
|
-
# """
|
67
|
-
# Parses command-line arguments using the Orionis argument parser.
|
68
|
-
|
69
|
-
# Parameters
|
70
|
-
# ----------
|
71
|
-
# vars : dict, optional
|
72
|
-
# A dictionary of predefined variables to be included in parsing.
|
73
|
-
# *args
|
74
|
-
# Positional arguments for the parser.
|
75
|
-
# **kwargs
|
76
|
-
# Keyword arguments for the parser.
|
77
|
-
|
78
|
-
# Returns
|
79
|
-
# -------
|
80
|
-
# CLIPipeline
|
81
|
-
# The current instance of CLIPipeline for method chaining.
|
82
|
-
|
83
|
-
# Raises
|
84
|
-
# ------
|
85
|
-
# ValueError
|
86
|
-
# If an error occurs during argument parsing.
|
87
|
-
# """
|
88
|
-
# try:
|
89
|
-
# arguments = self._command.get("arguments")
|
90
|
-
# if arguments:
|
91
|
-
# arg_parser = Parser(vars=vars or {}, args=args, kwargs=kwargs)
|
92
|
-
# arg_parser.setArguments(arguments=arguments)
|
93
|
-
# arg_parser.recognize()
|
94
|
-
# self._parsed_arguments = arg_parser.get()
|
95
|
-
|
96
|
-
# return self
|
97
|
-
|
98
|
-
# except Exception as e:
|
99
|
-
# raise ValueError(f"Error parsing arguments: {e}")
|
100
|
-
|
101
|
-
# def execute(self) -> Any:
|
102
|
-
# """
|
103
|
-
# Executes the retrieved command using parsed arguments.
|
104
|
-
|
105
|
-
# This method:
|
106
|
-
# - Instantiates the command class.
|
107
|
-
# - Calls the `handle()` method, passing the parsed arguments.
|
108
|
-
|
109
|
-
# Returns
|
110
|
-
# -------
|
111
|
-
# Any
|
112
|
-
# The output of the command execution.
|
113
|
-
|
114
|
-
# Raises
|
115
|
-
# ------
|
116
|
-
# ValueError
|
117
|
-
# If the command instance is invalid.
|
118
|
-
# """
|
119
|
-
# command_class = self._command.get("instance")
|
120
|
-
# command_instance: BaseCommand = command_class()
|
121
|
-
# command_instance.setArgs(self._parsed_arguments)
|
122
|
-
# return command_instance.handle(**vars(self._parsed_arguments))
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|