orionis 0.531.0__py3-none-any.whl → 0.533.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.
@@ -0,0 +1,57 @@
1
+ from orionis.console.base.command import BaseCommand
2
+ from orionis.console.contracts.reactor import IReactor
3
+ from orionis.console.exceptions import CLIOrionisRuntimeError
4
+ from rich.console import Console
5
+ from rich.panel import Panel
6
+
7
+ class MakeListenerCommand(BaseCommand):
8
+ """
9
+ Este comando se encarga de crear los listener tando para CLI como para otro tipo de Eventos.
10
+ """
11
+
12
+ # Indicates whether timestamps will be shown in the command output
13
+ timestamps: bool = False
14
+
15
+ # Command signature and description
16
+ signature: str = "make:listener"
17
+
18
+ # Command description
19
+ description: str = "Displays usage information, examples, and a list of available commands in the Orionis CLI."
20
+
21
+ def handle(self) -> dict:
22
+ """
23
+ Displays usage information and a list of available commands for the Orionis CLI.
24
+
25
+ Parameters
26
+ ----------
27
+ reactor : IReactor
28
+ The reactor instance providing command metadata via the `info()` method.
29
+
30
+ Returns
31
+ -------
32
+ dict
33
+ A dictionary containing the list of available commands, each with its signature and description.
34
+
35
+ Raises
36
+ ------
37
+ CLIOrionisRuntimeError
38
+ If an unexpected error occurs during help information generation or display.
39
+ """
40
+ try:
41
+
42
+ # Solicitar el nombre del listener al usuario
43
+ ans = self.choice(
44
+ question="Tipo de Listener",
45
+ choices=[
46
+ "Listener para eventos CLI",
47
+ "Listener para eventos de Schedule",
48
+ ],
49
+ default_index=0
50
+ )
51
+
52
+ print(ans)
53
+
54
+ except Exception as e:
55
+
56
+ # Raise a custom runtime error if any exception occurs
57
+ raise CLIOrionisRuntimeError(f"An unexpected error occurred: {e}") from e
@@ -114,6 +114,7 @@ class Reactor(IReactor):
114
114
  from orionis.console.commands.cache import CacheClearCommand
115
115
  from orionis.console.commands.scheduler_work import ScheduleWorkCommand
116
116
  from orionis.console.commands.scheduler_list import ScheduleListCommand
117
+ from orionis.console.commands.make_listener import MakeListenerCommand
117
118
 
118
119
  # List of core command classes to load (extend this list as more core commands are added)
119
120
  core_commands = [
@@ -124,7 +125,8 @@ class Reactor(IReactor):
124
125
  WorkFlowGithubCommand,
125
126
  CacheClearCommand,
126
127
  ScheduleWorkCommand,
127
- ScheduleListCommand
128
+ ScheduleListCommand,
129
+ MakeListenerCommand
128
130
  ]
129
131
 
130
132
  # Iterate through the core command classes and register them
@@ -8,12 +8,12 @@ from orionis.services.log.contracts.log_service import ILogger
8
8
  class BaseExceptionHandler(IBaseExceptionHandler):
9
9
 
10
10
  # Exceptions that should not be caught by the handler
11
- dont_cathc: List[type[BaseException]] = [
11
+ dont_catch: List[type[BaseException]] = [
12
12
  # Add specific exceptions that should not be caught
13
13
  # Example: OrionisContainerException
14
14
  ]
15
15
 
16
- def destructureException(self, e: BaseException) -> Throwable:
16
+ async def destructureException(self, e: BaseException) -> Throwable:
17
17
  """
18
18
  Converts an exception into a structured `Throwable` object containing detailed information.
19
19
 
@@ -41,7 +41,7 @@ class BaseExceptionHandler(IBaseExceptionHandler):
41
41
  traceback=getattr(e, '__traceback__', None) # The traceback object, if available
42
42
  )
43
43
 
44
- def shouldIgnoreException(self, e: BaseException) -> bool:
44
+ async def shouldIgnoreException(self, e: BaseException) -> bool:
45
45
  """
46
46
  Determines if the exception should be ignored (not handled) by the handler.
47
47
 
@@ -61,12 +61,12 @@ class BaseExceptionHandler(IBaseExceptionHandler):
61
61
  raise TypeError(f"Expected BaseException, got {type(e).__name__}")
62
62
 
63
63
  # Convert the exception into a structured Throwable object
64
- throwable = self.destructureException(e)
64
+ throwable = await self.destructureException(e)
65
65
 
66
66
  # Check if the exception type is in the list of exceptions to ignore
67
- return hasattr(self, 'dont_cathc') and throwable.classtype in self.dont_cathc
67
+ return hasattr(self, 'dont_catch') and throwable.classtype in self.dont_catch
68
68
 
69
- def report(self, exception: BaseException, log: ILogger) -> Any:
69
+ async def report(self, exception: BaseException, log: ILogger) -> Any:
70
70
  """
71
71
  Report or log an exception.
72
72
 
@@ -84,7 +84,7 @@ class BaseExceptionHandler(IBaseExceptionHandler):
84
84
  raise TypeError(f"Expected BaseException, got {type(exception).__name__}")
85
85
 
86
86
  # Convert the exception into a structured Throwable object
87
- throwable = self.destructureException(exception)
87
+ throwable = await self.destructureException(exception)
88
88
 
89
89
  # Log the exception details
90
90
  log.error(f"[{throwable.classtype.__name__}] {throwable.message}")
@@ -92,7 +92,7 @@ class BaseExceptionHandler(IBaseExceptionHandler):
92
92
  # Return the structured exception
93
93
  return throwable
94
94
 
95
- def renderCLI(self, request: CLIRequest, exception: BaseException, log: ILogger, console: IConsole) -> Any:
95
+ async def renderCLI(self, request: CLIRequest, exception: BaseException, log: ILogger, console: IConsole) -> Any:
96
96
  """
97
97
  Render the exception message for CLI output.
98
98
 
@@ -109,11 +109,15 @@ class BaseExceptionHandler(IBaseExceptionHandler):
109
109
  if not isinstance(exception, BaseException):
110
110
  raise TypeError(f"Expected BaseException, got {type(exception).__name__}")
111
111
 
112
+ # Ensure the request is a CLIRequest
113
+ if not isinstance(request, CLIRequest):
114
+ raise TypeError(f"Expected CLIRequest, got {type(request).__name__}")
115
+
112
116
  # Convert the exception into a structured Throwable object
113
- throwable = self.destructureException(exception)
117
+ throwable = await self.destructureException(exception)
114
118
 
115
- args = request.args if isinstance(request, CLIRequest) and request.args else []
116
- string_args = ' '.join(args)
119
+ # Convert the request arguments to a string for logging
120
+ string_args = ' '.join(request.args)
117
121
 
118
122
  # Log the CLI error message with arguments
119
123
  log.error(f"CLI Error: {throwable.message} (Args: {string_args})")
orionis/failure/catch.py CHANGED
@@ -1,11 +1,11 @@
1
1
  from typing import Any
2
2
  from orionis.console.kernel import KernelCLI
3
3
  from orionis.console.output.contracts.console import IConsole
4
- from orionis.console.tasks.schedule import Schedule
5
4
  from orionis.failure.contracts.catch import ICatch
6
5
  from orionis.failure.contracts.handler import IBaseExceptionHandler
7
6
  from orionis.foundation.contracts.application import IApplication
8
7
  from orionis.services.log.contracts.log_service import ILogger
8
+ import asyncio
9
9
 
10
10
  class Catch(ICatch):
11
11
 
@@ -74,21 +74,89 @@ class Catch(ICatch):
74
74
  If a valid kernel is provided, the exception details are rendered to the CLI.
75
75
  """
76
76
 
77
- # Check if the exception should be ignored by the handler
78
- if self.__exception_handler.shouldIgnoreException(e):
79
- return
80
-
81
- # Report the exception using the application's exception handler and logger
82
- self.__exception_handler.report(
83
- exception=e,
84
- log=self.__logger
85
- )
86
-
87
- # If a kernel is provided, render the exception details to the CLI
88
- if isinstance(kernel, KernelCLI) or isinstance(kernel, Schedule):
89
- return self.__exception_handler.renderCLI(
90
- request=request,
91
- exception=e,
92
- log=self.__logger,
93
- console=self.__console
94
- )
77
+ async def handle():
78
+ """
79
+ Handles exceptions asynchronously using the provided exception handler.
80
+
81
+ This method performs the following steps:
82
+ 1. Determines if the exception should be ignored by invoking the `shouldIgnoreException` method
83
+ of the exception handler. This method supports both coroutine and regular functions.
84
+ 2. Reports the exception using the `report` method of the exception handler. This method
85
+ also supports both coroutine and regular functions.
86
+ 3. If the kernel is of type `KernelCLI` or `Any`, it attempts to render the exception
87
+ for the CLI using the `renderCLI` method of the exception handler. This method supports
88
+ both coroutine and regular functions.
89
+
90
+ Parameters
91
+ ----------
92
+ None
93
+
94
+ Returns
95
+ -------
96
+ Any or None
97
+ The result of the `renderCLI` method if applicable, otherwise `None`.
98
+
99
+ Notes
100
+ -----
101
+ - The `self.__exception_handler` is expected to have the methods `shouldIgnoreException`,
102
+ `report`, and `renderCLI`.
103
+ - The `self.__logger` is passed to the `report` and `renderCLI` methods for logging purposes.
104
+ - The `self.__console` is passed to the `renderCLI` method for CLI rendering.
105
+ """
106
+
107
+ # Check if the `shouldIgnoreException` method is a coroutine function
108
+ if asyncio.iscoroutinefunction(self.__exception_handler.shouldIgnoreException):
109
+
110
+ # If it is, await its result to determine if the exception should be ignored
111
+ if await self.__exception_handler.shouldIgnoreException(e):
112
+ return
113
+
114
+ else:
115
+
116
+ # If it is not a coroutine, call it directly
117
+ if self.__exception_handler.shouldIgnoreException(e):
118
+ return
119
+
120
+ # Check if the `report` method is a coroutine function
121
+ if asyncio.iscoroutinefunction(self.__exception_handler.report):
122
+
123
+ # If it is, await its execution to report the exception
124
+ await self.__exception_handler.report(
125
+ exception=e,
126
+ log=self.__logger
127
+ )
128
+
129
+ else:
130
+
131
+ # If it is not a coroutine, call it directly
132
+ self.__exception_handler.report(
133
+ exception=e,
134
+ log=self.__logger
135
+ )
136
+
137
+ # Check if the kernel is of type `KernelCLI` or `Any`
138
+ if isinstance(kernel, KernelCLI) or isinstance(kernel, Any):
139
+
140
+ # Check if the `renderCLI` method is a coroutine function
141
+ if asyncio.iscoroutinefunction(self.__exception_handler.renderCLI):
142
+
143
+ # If it is, await its execution to render the exception for the CLI
144
+ return await self.__exception_handler.renderCLI(
145
+ request=request,
146
+ exception=e,
147
+ log=self.__logger,
148
+ console=self.__console
149
+ )
150
+
151
+ else:
152
+
153
+ # If it is not a coroutine, call it directly
154
+ return self.__exception_handler.renderCLI(
155
+ request=request,
156
+ exception=e,
157
+ log=self.__logger,
158
+ console=self.__console
159
+ )
160
+
161
+ # Run the handler
162
+ asyncio.run(handle())
@@ -7,7 +7,7 @@ from orionis.services.log.contracts.log_service import ILogger
7
7
  class IBaseExceptionHandler:
8
8
 
9
9
  @abstractmethod
10
- def destructureException(self, e: BaseException):
10
+ async def destructureException(self, e: BaseException):
11
11
  """
12
12
  Converts an exception into a structured `Throwable` object containing detailed information.
13
13
 
@@ -29,7 +29,7 @@ class IBaseExceptionHandler:
29
29
  pass
30
30
 
31
31
  @abstractmethod
32
- def shouldIgnoreException(self, e: BaseException) -> bool:
32
+ async def shouldIgnoreException(self, e: BaseException) -> bool:
33
33
  """
34
34
  Determines if the exception should be ignored (not handled) by the handler.
35
35
 
@@ -46,7 +46,7 @@ class IBaseExceptionHandler:
46
46
  pass
47
47
 
48
48
  @abstractmethod
49
- def report (self, exception: BaseException, log: ILogger) -> Any:
49
+ async def report (self, exception: BaseException, log: ILogger) -> Any:
50
50
  """
51
51
  Report or log an exception.
52
52
 
@@ -62,7 +62,7 @@ class IBaseExceptionHandler:
62
62
  pass
63
63
 
64
64
  @abstractmethod
65
- def renderCLI(self, request: CLIRequest, exception: BaseException, log: ILogger, console: IConsole) -> Any:
65
+ async def renderCLI(self, request: CLIRequest, exception: BaseException, log: ILogger, console: IConsole) -> Any:
66
66
  """
67
67
  Render the exception message for CLI output.
68
68
 
@@ -5,7 +5,7 @@
5
5
  NAME = "orionis"
6
6
 
7
7
  # Current version of the framework
8
- VERSION = "0.531.0"
8
+ VERSION = "0.533.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orionis
3
- Version: 0.531.0
3
+ Version: 0.533.0
4
4
  Summary: Orionis Framework – Elegant, Fast, and Powerful.
5
5
  Home-page: https://github.com/orionis-framework/framework
6
6
  Author: Raul Mauricio Uñate Castro
@@ -13,6 +13,7 @@ orionis/console/base/scheduler_event_listener.py,sha256=tmdAMPzTmT8z0BcpyoIZwyTR
13
13
  orionis/console/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  orionis/console/commands/cache.py,sha256=8DsYoRzSBLn0P9qkGVItRbo0R6snWBDBg0_Xa7tmVhs,2322
15
15
  orionis/console/commands/help.py,sha256=zfSw0pYaOnFN-_Ozdn4veBQDYMgSSDY10nPDCi-7tTY,3199
16
+ orionis/console/commands/make_listener.py,sha256=iPOMCc41njwUKurxSwatZUTjpp-bBLdO9nN-w2FJ4mI,1921
16
17
  orionis/console/commands/publisher.py,sha256=FUg-EUzK7LLXsla10ZUZro8V0Z5S-KjmsaSdRHSSGbA,21381
17
18
  orionis/console/commands/scheduler_list.py,sha256=A2N_mEXEJDHO8DX2TDrL1ROeeRhFSkWD3rCw64Hrf0o,4763
18
19
  orionis/console/commands/scheduler_work.py,sha256=mzSFes8Wl1gCf253tNYClij0abT5HlpW1QZVFrU5EXo,6445
@@ -28,7 +29,7 @@ orionis/console/contracts/schedule.py,sha256=17cfPYtLo-jqF8FxYOhh4epJZnxw5mMPuLG
28
29
  orionis/console/contracts/schedule_event_listener.py,sha256=7fQdPh6X_npfGpQW_2x81D7-5Pe40jIog9uDeEU0kro,4390
29
30
  orionis/console/contracts/scheduler.py,sha256=OW-a_YDDNPrenYT9z8Tv71VjyZ1aSzqzqhTBhTCZhGM,7698
30
31
  orionis/console/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
- orionis/console/core/reactor.py,sha256=AG2i38YRTHSRG-eO2lNCy9P-Qfll297EvxYHCT_wvV0,30512
32
+ orionis/console/core/reactor.py,sha256=cUYZwOyWjKai885peSaRRu3vM0IpWxskCNyl9IangHs,30626
32
33
  orionis/console/dumper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
34
  orionis/console/dumper/dump.py,sha256=CATERiQ6XuIrKQsDaWcVxzTtlAJI9qLJX44fQxEX8ws,22443
34
35
  orionis/console/dumper/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -116,12 +117,12 @@ orionis/container/validators/is_subclass.py,sha256=4sBaGLoRs8nUhuWjlP0VJqyTwVHYq
116
117
  orionis/container/validators/is_valid_alias.py,sha256=4uAYcq8xov7jZbXnpKpjNkxcZtlTNnL5RRctVPMwJes,1424
117
118
  orionis/container/validators/lifetime.py,sha256=IQ43fDNrxYHMlZH2zlYDJnlkLO_eS4U7Fs3UJgQBidI,1844
118
119
  orionis/failure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
119
- orionis/failure/catch.py,sha256=Tk2IE6lpt2n3jHn4--3U-QLyDrBIwUnNnKi7ZRmGnOg,3715
120
+ orionis/failure/catch.py,sha256=ZmSVcrCMccLwJXWTYOT6IX_Bx-1_qhy8Ekkf5rcMWb0,6648
120
121
  orionis/failure/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
121
- orionis/failure/base/handler.py,sha256=L6jB2_2f8ZKBuys8o_iXTwMM_yjQHY7iXNF1Q3X8BGY,4661
122
+ orionis/failure/base/handler.py,sha256=a7fQJMWVjALwFiITRsMYg3s7WSO6zcbmq171iQRWy48,4867
122
123
  orionis/failure/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
123
124
  orionis/failure/contracts/catch.py,sha256=e2wM1p6VxbvAjgWm-MwoM9p2ystSsyBu8Qnt6Ehr6Vc,1179
124
- orionis/failure/contracts/handler.py,sha256=4N9yMkMgdhtHbRGAyCtuTx3GmkPP74vhqdRLmwl-ckQ,2216
125
+ orionis/failure/contracts/handler.py,sha256=drNE8iu8RUHi3TgKn-lUEIfVsZeGsMTUecTZOfay19E,2240
125
126
  orionis/failure/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
126
127
  orionis/failure/entities/throwable.py,sha256=ogys062uhim5QMYU62ezlnumRAnYQlUf_vZvQY47S3U,1227
127
128
  orionis/foundation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -241,7 +242,7 @@ orionis/foundation/providers/scheduler_provider.py,sha256=1do4B09bU_6xbFHHVYYTGM
241
242
  orionis/foundation/providers/testing_provider.py,sha256=SrJRpdvcblx9WvX7x9Y3zc7OQfiTf7la0HAJrm2ESlE,3725
242
243
  orionis/foundation/providers/workers_provider.py,sha256=oa_2NIDH6UxZrtuGkkoo_zEoNIMGgJ46vg5CCgAm7wI,3926
243
244
  orionis/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
244
- orionis/metadata/framework.py,sha256=5Up2-YWMRMMui3nVYJBNvG81pm5vlb0awntbaIiHh8A,4109
245
+ orionis/metadata/framework.py,sha256=MR1CweBMS0GVoynVQvHVgX_Q57Tui2yvVfL-crXSC8M,4109
245
246
  orionis/metadata/package.py,sha256=k7Yriyp5aUcR-iR8SK2ec_lf0_Cyc-C7JczgXa-I67w,16039
246
247
  orionis/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
247
248
  orionis/services/asynchrony/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -419,7 +420,7 @@ orionis/test/validators/web_report.py,sha256=n9BfzOZz6aEiNTypXcwuWbFRG0OdHNSmCNu
419
420
  orionis/test/validators/workers.py,sha256=rWcdRexINNEmGaO7mnc1MKUxkHKxrTsVuHgbnIfJYgc,1206
420
421
  orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
421
422
  orionis/test/view/render.py,sha256=f-zNhtKSg9R5Njqujbg2l2amAs2-mRVESneLIkWOZjU,4082
422
- orionis-0.531.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
423
+ orionis-0.533.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
423
424
  tests/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
424
425
  tests/container/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
425
426
  tests/container/context/test_manager.py,sha256=wOwXpl9rHNfTTexa9GBKYMwK0_-KSQPbI-AEyGNkmAE,1356
@@ -565,8 +566,8 @@ tests/testing/validators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
565
566
  tests/testing/validators/test_testing_validators.py,sha256=WPo5GxTP6xE-Dw3X1vZoqOMpb6HhokjNSbgDsDRDvy4,16588
566
567
  tests/testing/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
567
568
  tests/testing/view/test_render.py,sha256=tnnMBwS0iKUIbogLvu-7Rii50G6Koddp3XT4wgdFEYM,1050
568
- orionis-0.531.0.dist-info/METADATA,sha256=zfe49sBuT8RAIkEbWnNODcJ-k9987ERhWzcrBlJ0Vc4,4801
569
- orionis-0.531.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
570
- orionis-0.531.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
571
- orionis-0.531.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
572
- orionis-0.531.0.dist-info/RECORD,,
569
+ orionis-0.533.0.dist-info/METADATA,sha256=l1kdd7oMiNJrpGuVKP_I66xljMNosyOPn-mNVBFcHIg,4801
570
+ orionis-0.533.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
571
+ orionis-0.533.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
572
+ orionis-0.533.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
573
+ orionis-0.533.0.dist-info/RECORD,,