orionis 0.427.0__py3-none-any.whl → 0.429.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/{_console → console}/commands/version.py +2 -2
- orionis/console/contracts/kernel.py +15 -0
- orionis/console/exceptions/__init__.py +11 -0
- orionis/console/kelnel.py +25 -0
- orionis/foundation/application.py +4 -2
- orionis/metadata/framework.py +1 -1
- orionis/test/kernel.py +63 -48
- {orionis-0.427.0.dist-info → orionis-0.429.0.dist-info}/METADATA +1 -1
- {orionis-0.427.0.dist-info → orionis-0.429.0.dist-info}/RECORD +17 -31
- orionis/_console/__init__.py +0 -0
- orionis/_console/base/__init__.py +0 -0
- orionis/_console/base/command.py +0 -436
- orionis/_console/command_filter.py +0 -36
- orionis/_console/commands/__init__.py +0 -0
- orionis/_console/commands/cache_clear.py +0 -76
- orionis/_console/commands/help.py +0 -70
- orionis/_console/commands/schedule_work.py +0 -55
- orionis/_console/dumper/__init__.py +0 -0
- orionis/_console/dumper/dump_die.py +0 -418
- orionis/_console/exceptions/__init__.py +0 -0
- orionis/_console/kernel.py +0 -31
- orionis/_console/output/__init__.py +0 -0
- orionis/_console/output/console.py +0 -587
- orionis/_console/output/executor.py +0 -90
- orionis/_console/output/progress_bar.py +0 -100
- orionis/_console/parser.py +0 -159
- /orionis/{_console → console}/exceptions/cli_exception.py +0 -0
- /orionis/{_console/exceptions/cli-orionis-value-error.py → console/exceptions/cli_orionis_value_error.py} +0 -0
- /orionis/{_console → console}/exceptions/cli_runtime_error.py +0 -0
- /orionis/{_console → console}/exceptions/cli_schedule_exception.py +0 -0
- {orionis-0.427.0.dist-info → orionis-0.429.0.dist-info}/WHEEL +0 -0
- {orionis-0.427.0.dist-info → orionis-0.429.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.427.0.dist-info → orionis-0.429.0.dist-info}/top_level.txt +0 -0
- {orionis-0.427.0.dist-info → orionis-0.429.0.dist-info}/zip-safe +0 -0
orionis/_console/base/command.py
DELETED
|
@@ -1,436 +0,0 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
from orionis._console.output.console import Console
|
|
3
|
-
from orionis._console.output.progress_bar import ProgressBar
|
|
4
|
-
from orionis._contracts.console.base.command import IBaseCommand
|
|
5
|
-
|
|
6
|
-
class BaseCommand(IBaseCommand):
|
|
7
|
-
"""
|
|
8
|
-
A base class for handling common console output functionalities. This class provides methods to print messages of
|
|
9
|
-
various types (success, info, warning, etc.) in different styles (e.g., text, bold, colored).
|
|
10
|
-
|
|
11
|
-
This class acts as a foundation for command classes, offering utility methods to interact with the console.
|
|
12
|
-
|
|
13
|
-
Parameters
|
|
14
|
-
----------
|
|
15
|
-
args : dict, optional
|
|
16
|
-
A dictionary containing the command arguments (default is an empty dictionary).
|
|
17
|
-
"""
|
|
18
|
-
args = {}
|
|
19
|
-
|
|
20
|
-
def success(self, message: str, timestamp: bool = True) -> None:
|
|
21
|
-
"""
|
|
22
|
-
Prints a success message with a green background.
|
|
23
|
-
|
|
24
|
-
Parameters
|
|
25
|
-
----------
|
|
26
|
-
message : str
|
|
27
|
-
The message to display.
|
|
28
|
-
timestamp : bool, optional
|
|
29
|
-
Whether to include a timestamp (default is True).
|
|
30
|
-
"""
|
|
31
|
-
Console.success(message, timestamp)
|
|
32
|
-
|
|
33
|
-
def textSuccess(self, message: str) -> None:
|
|
34
|
-
"""
|
|
35
|
-
Prints a success message in green.
|
|
36
|
-
|
|
37
|
-
Parameters
|
|
38
|
-
----------
|
|
39
|
-
message : str
|
|
40
|
-
The message to display.
|
|
41
|
-
"""
|
|
42
|
-
Console.textSuccess(message)
|
|
43
|
-
|
|
44
|
-
def textSuccessBold(self, message: str) -> None:
|
|
45
|
-
"""
|
|
46
|
-
Prints a bold success message in green.
|
|
47
|
-
|
|
48
|
-
Parameters
|
|
49
|
-
----------
|
|
50
|
-
message : str
|
|
51
|
-
The message to display.
|
|
52
|
-
"""
|
|
53
|
-
Console.textSuccessBold(message)
|
|
54
|
-
|
|
55
|
-
def info(self, message: str, timestamp: bool = True) -> None:
|
|
56
|
-
"""
|
|
57
|
-
Prints an informational message with a blue background.
|
|
58
|
-
|
|
59
|
-
Parameters
|
|
60
|
-
----------
|
|
61
|
-
message : str
|
|
62
|
-
The message to display.
|
|
63
|
-
timestamp : bool, optional
|
|
64
|
-
Whether to include a timestamp (default is True).
|
|
65
|
-
"""
|
|
66
|
-
Console.info(message, timestamp)
|
|
67
|
-
|
|
68
|
-
def textInfo(self, message: str) -> None:
|
|
69
|
-
"""
|
|
70
|
-
Prints an informational message in blue.
|
|
71
|
-
|
|
72
|
-
Parameters
|
|
73
|
-
----------
|
|
74
|
-
message : str
|
|
75
|
-
The message to display.
|
|
76
|
-
"""
|
|
77
|
-
Console.textInfo(message)
|
|
78
|
-
|
|
79
|
-
def textInfoBold(self, message: str) -> None:
|
|
80
|
-
"""
|
|
81
|
-
Prints a bold informational message in blue.
|
|
82
|
-
|
|
83
|
-
Parameters
|
|
84
|
-
----------
|
|
85
|
-
message : str
|
|
86
|
-
The message to display.
|
|
87
|
-
"""
|
|
88
|
-
Console.textInfoBold(message)
|
|
89
|
-
|
|
90
|
-
def warning(self, message: str, timestamp: bool = True):
|
|
91
|
-
"""
|
|
92
|
-
Prints a warning message with a yellow background.
|
|
93
|
-
|
|
94
|
-
Parameters
|
|
95
|
-
----------
|
|
96
|
-
message : str
|
|
97
|
-
The message to display.
|
|
98
|
-
timestamp : bool, optional
|
|
99
|
-
Whether to include a timestamp (default is True).
|
|
100
|
-
"""
|
|
101
|
-
Console.warning(message, timestamp)
|
|
102
|
-
|
|
103
|
-
def textWarning(self, message: str) -> None:
|
|
104
|
-
"""
|
|
105
|
-
Prints a warning message in yellow.
|
|
106
|
-
|
|
107
|
-
Parameters
|
|
108
|
-
----------
|
|
109
|
-
message : str
|
|
110
|
-
The message to display.
|
|
111
|
-
"""
|
|
112
|
-
Console.textWarning(message)
|
|
113
|
-
|
|
114
|
-
def textWarningBold(self, message: str) -> None:
|
|
115
|
-
"""
|
|
116
|
-
Prints a bold warning message in yellow.
|
|
117
|
-
|
|
118
|
-
Parameters
|
|
119
|
-
----------
|
|
120
|
-
message : str
|
|
121
|
-
The message to display.
|
|
122
|
-
"""
|
|
123
|
-
Console.textWarningBold(message)
|
|
124
|
-
|
|
125
|
-
def fail(self, message: str, timestamp: bool = True) -> None:
|
|
126
|
-
"""
|
|
127
|
-
Prints a failure message with a red background.
|
|
128
|
-
|
|
129
|
-
Parameters
|
|
130
|
-
----------
|
|
131
|
-
message : str
|
|
132
|
-
The message to display.
|
|
133
|
-
timestamp : bool, optional
|
|
134
|
-
Whether to include a timestamp (default is True).
|
|
135
|
-
"""
|
|
136
|
-
Console.fail(message, timestamp)
|
|
137
|
-
|
|
138
|
-
def error(self, message: str, timestamp: bool = True) -> None:
|
|
139
|
-
"""
|
|
140
|
-
Prints an error message with a red background.
|
|
141
|
-
|
|
142
|
-
Parameters
|
|
143
|
-
----------
|
|
144
|
-
message : str
|
|
145
|
-
The message to display.
|
|
146
|
-
timestamp : bool, optional
|
|
147
|
-
Whether to include a timestamp (default is True).
|
|
148
|
-
"""
|
|
149
|
-
Console.error(message, timestamp)
|
|
150
|
-
|
|
151
|
-
def textError(self, message: str) -> None:
|
|
152
|
-
"""
|
|
153
|
-
Prints an error message in red.
|
|
154
|
-
|
|
155
|
-
Parameters
|
|
156
|
-
----------
|
|
157
|
-
message : str
|
|
158
|
-
The message to display.
|
|
159
|
-
"""
|
|
160
|
-
Console.textError(message)
|
|
161
|
-
|
|
162
|
-
def textErrorBold(self, message: str) -> None:
|
|
163
|
-
"""
|
|
164
|
-
Prints a bold error message in red.
|
|
165
|
-
|
|
166
|
-
Parameters
|
|
167
|
-
----------
|
|
168
|
-
message : str
|
|
169
|
-
The message to display.
|
|
170
|
-
"""
|
|
171
|
-
Console.textErrorBold(message)
|
|
172
|
-
|
|
173
|
-
def textMuted(self, message: str) -> None:
|
|
174
|
-
"""
|
|
175
|
-
Prints a muted (gray) message.
|
|
176
|
-
|
|
177
|
-
Parameters
|
|
178
|
-
----------
|
|
179
|
-
message : str
|
|
180
|
-
The message to display.
|
|
181
|
-
"""
|
|
182
|
-
Console.textMuted(message)
|
|
183
|
-
|
|
184
|
-
def textMutedBold(self, message: str) -> None:
|
|
185
|
-
"""
|
|
186
|
-
Prints a bold muted (gray) message.
|
|
187
|
-
|
|
188
|
-
Parameters
|
|
189
|
-
----------
|
|
190
|
-
message : str
|
|
191
|
-
The message to display.
|
|
192
|
-
"""
|
|
193
|
-
Console.textMutedBold(message)
|
|
194
|
-
|
|
195
|
-
def textUnderline(self, message: str) -> None:
|
|
196
|
-
"""
|
|
197
|
-
Prints an underlined message.
|
|
198
|
-
|
|
199
|
-
Parameters
|
|
200
|
-
----------
|
|
201
|
-
message : str
|
|
202
|
-
The message to display.
|
|
203
|
-
"""
|
|
204
|
-
Console.textUnderline(message)
|
|
205
|
-
|
|
206
|
-
def clear(self) -> None:
|
|
207
|
-
"""
|
|
208
|
-
Clears the console screen.
|
|
209
|
-
"""
|
|
210
|
-
Console.clear()
|
|
211
|
-
|
|
212
|
-
def clearLine(self) -> None:
|
|
213
|
-
"""
|
|
214
|
-
Clears the current console line.
|
|
215
|
-
"""
|
|
216
|
-
Console.clearLine()
|
|
217
|
-
|
|
218
|
-
def line(self) -> None:
|
|
219
|
-
"""
|
|
220
|
-
Prints a line empty.
|
|
221
|
-
"""
|
|
222
|
-
Console.line()
|
|
223
|
-
|
|
224
|
-
def newLine(self, count: int = 1) -> None:
|
|
225
|
-
"""
|
|
226
|
-
Prints multiple new lines.
|
|
227
|
-
|
|
228
|
-
Parameters
|
|
229
|
-
----------
|
|
230
|
-
count : int, optional
|
|
231
|
-
The number of new lines to print (default is 1).
|
|
232
|
-
"""
|
|
233
|
-
Console.newLine(count)
|
|
234
|
-
|
|
235
|
-
def write(self, message: str) -> None:
|
|
236
|
-
"""
|
|
237
|
-
Prints a message without moving to the next line.
|
|
238
|
-
|
|
239
|
-
Parameters
|
|
240
|
-
----------
|
|
241
|
-
message : str, optional
|
|
242
|
-
The message to display.
|
|
243
|
-
"""
|
|
244
|
-
Console.write(message)
|
|
245
|
-
|
|
246
|
-
def writeLine(self, message: str) -> None:
|
|
247
|
-
"""
|
|
248
|
-
Prints a message and moves to the next line.
|
|
249
|
-
|
|
250
|
-
Parameters
|
|
251
|
-
----------
|
|
252
|
-
message : str, optional
|
|
253
|
-
The message to display (default is an empty string).
|
|
254
|
-
"""
|
|
255
|
-
Console.writeLine(message)
|
|
256
|
-
|
|
257
|
-
def ask(self, question: str) -> str:
|
|
258
|
-
"""
|
|
259
|
-
Prompts the user for input and returns the response.
|
|
260
|
-
|
|
261
|
-
Parameters
|
|
262
|
-
----------
|
|
263
|
-
question : str
|
|
264
|
-
The question to ask the user.
|
|
265
|
-
|
|
266
|
-
Returns
|
|
267
|
-
-------
|
|
268
|
-
str
|
|
269
|
-
The user's input.
|
|
270
|
-
"""
|
|
271
|
-
return Console.ask(question).strip()
|
|
272
|
-
|
|
273
|
-
def confirm(self, question: str, default: bool = False) -> bool:
|
|
274
|
-
"""
|
|
275
|
-
Asks a confirmation question and returns True/False based on the user's response.
|
|
276
|
-
|
|
277
|
-
Parameters
|
|
278
|
-
----------
|
|
279
|
-
question : str
|
|
280
|
-
The confirmation question to ask.
|
|
281
|
-
default : bool, optional
|
|
282
|
-
The default response if the user presses Enter without typing a response (default is False).
|
|
283
|
-
|
|
284
|
-
Returns
|
|
285
|
-
-------
|
|
286
|
-
bool
|
|
287
|
-
The user's response.
|
|
288
|
-
"""
|
|
289
|
-
return Console.confirm(question, default)
|
|
290
|
-
|
|
291
|
-
def secret(self, question: str) -> str:
|
|
292
|
-
"""
|
|
293
|
-
Prompts for hidden input (e.g., password).
|
|
294
|
-
|
|
295
|
-
Parameters
|
|
296
|
-
----------
|
|
297
|
-
question : str
|
|
298
|
-
The prompt to ask the user.
|
|
299
|
-
|
|
300
|
-
Returns
|
|
301
|
-
-------
|
|
302
|
-
str
|
|
303
|
-
The user's hidden input.
|
|
304
|
-
"""
|
|
305
|
-
return Console.secret(question)
|
|
306
|
-
|
|
307
|
-
def table(self, headers: list, rows: list):
|
|
308
|
-
"""
|
|
309
|
-
Prints a formatted table in the console.
|
|
310
|
-
|
|
311
|
-
Parameters
|
|
312
|
-
----------
|
|
313
|
-
headers : list of str
|
|
314
|
-
The column headers for the table.
|
|
315
|
-
rows : list of list of str
|
|
316
|
-
The rows of the table.
|
|
317
|
-
|
|
318
|
-
Raises
|
|
319
|
-
------
|
|
320
|
-
ValueError
|
|
321
|
-
If headers or rows are empty.
|
|
322
|
-
"""
|
|
323
|
-
Console.table(headers, rows)
|
|
324
|
-
|
|
325
|
-
def anticipate(self, question: str, options: list, default=None):
|
|
326
|
-
"""
|
|
327
|
-
Provides autocomplete suggestions for user input.
|
|
328
|
-
|
|
329
|
-
Parameters
|
|
330
|
-
----------
|
|
331
|
-
question : str
|
|
332
|
-
The prompt for the user.
|
|
333
|
-
options : list of str
|
|
334
|
-
The list of possible options for autocomplete.
|
|
335
|
-
default : str, optional
|
|
336
|
-
The default value if no matching option is found (default is None).
|
|
337
|
-
|
|
338
|
-
Returns
|
|
339
|
-
-------
|
|
340
|
-
str
|
|
341
|
-
The chosen option or the default value.
|
|
342
|
-
"""
|
|
343
|
-
Console.anticipate(question, options, default)
|
|
344
|
-
|
|
345
|
-
def choice(self, question: str, choices: list, default_index: int = 0) -> str:
|
|
346
|
-
"""
|
|
347
|
-
Prompts the user to select a choice from a list.
|
|
348
|
-
|
|
349
|
-
Parameters
|
|
350
|
-
----------
|
|
351
|
-
question : str
|
|
352
|
-
The prompt for the user.
|
|
353
|
-
choices : list of str
|
|
354
|
-
The list of available choices.
|
|
355
|
-
default_index : int, optional
|
|
356
|
-
The index of the default choice (default is 0).
|
|
357
|
-
|
|
358
|
-
Returns
|
|
359
|
-
-------
|
|
360
|
-
str
|
|
361
|
-
The selected choice.
|
|
362
|
-
|
|
363
|
-
Raises
|
|
364
|
-
------
|
|
365
|
-
ValueError
|
|
366
|
-
If `default_index` is out of the range of choices.
|
|
367
|
-
"""
|
|
368
|
-
Console.choice(question, choices, default_index)
|
|
369
|
-
|
|
370
|
-
def createProgressBar(self, total: int = 100, width: int = 50) -> ProgressBar:
|
|
371
|
-
"""
|
|
372
|
-
Creates and returns a new progress bar.
|
|
373
|
-
|
|
374
|
-
This method initializes a `ProgressBar` object with the specified total and width.
|
|
375
|
-
|
|
376
|
-
Parameters
|
|
377
|
-
----------
|
|
378
|
-
total : int, optional
|
|
379
|
-
The total number of steps for the progress bar. Default is 100.
|
|
380
|
-
width : int, optional
|
|
381
|
-
The width (in characters) of the progress bar. Default is 50.
|
|
382
|
-
|
|
383
|
-
Returns
|
|
384
|
-
-------
|
|
385
|
-
ProgressBar
|
|
386
|
-
A new instance of the `ProgressBar` class, initialized with the specified `total` and `width`.
|
|
387
|
-
|
|
388
|
-
Notes
|
|
389
|
-
-----
|
|
390
|
-
The progress bar can be used to visually track the progress of a task.
|
|
391
|
-
The `total` parameter represents the number of steps to complete the task,
|
|
392
|
-
and the `width` parameter controls the number of characters used to represent the progress bar in the console.
|
|
393
|
-
"""
|
|
394
|
-
return ProgressBar(total=total, width=width)
|
|
395
|
-
|
|
396
|
-
def handle(self, **kwargs):
|
|
397
|
-
"""
|
|
398
|
-
Abstract method to define the logic of the command.
|
|
399
|
-
|
|
400
|
-
This method must be overridden in subclasses.
|
|
401
|
-
|
|
402
|
-
Arguments:
|
|
403
|
-
**kwargs: Arbitrary keyword arguments.
|
|
404
|
-
|
|
405
|
-
Raises:
|
|
406
|
-
NotImplementedError: If the method is not implemented in a subclass. This ensures that all command classes
|
|
407
|
-
adhere to the expected structure.
|
|
408
|
-
"""
|
|
409
|
-
raise NotImplementedError("The 'handle' method must be implemented in the child class.")
|
|
410
|
-
|
|
411
|
-
def setArgs(self, args) -> None:
|
|
412
|
-
"""
|
|
413
|
-
Define the logic of setting command arguments.
|
|
414
|
-
|
|
415
|
-
Parameters
|
|
416
|
-
----------
|
|
417
|
-
args : argparse.Namespace or dict
|
|
418
|
-
Contain the arguments to be set for the command.
|
|
419
|
-
"""
|
|
420
|
-
if isinstance(args, argparse.Namespace):
|
|
421
|
-
self.args = vars(args)
|
|
422
|
-
elif isinstance(args, dict):
|
|
423
|
-
self.args = args
|
|
424
|
-
else:
|
|
425
|
-
raise ValueError("Invalid argument type. Expected 'argparse.Namespace' or 'dict'.")
|
|
426
|
-
|
|
427
|
-
def getArgs(self) -> dict:
|
|
428
|
-
"""
|
|
429
|
-
Get the command arguments.
|
|
430
|
-
|
|
431
|
-
Returns
|
|
432
|
-
-------
|
|
433
|
-
dict
|
|
434
|
-
The command arguments.
|
|
435
|
-
"""
|
|
436
|
-
return self.args
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
from orionis._contracts.console.command_filter import ICommandFilter
|
|
2
|
-
|
|
3
|
-
class CommandFilter(ICommandFilter):
|
|
4
|
-
"""
|
|
5
|
-
CommandFilter handles the exclusion of specific commands from output formatting.
|
|
6
|
-
|
|
7
|
-
This class:
|
|
8
|
-
- Determines whether a command should be excluded from output formatting based on a predefined list.
|
|
9
|
-
- Can be extended or modified to support more advanced filtering if needed.
|
|
10
|
-
|
|
11
|
-
Methods
|
|
12
|
-
-------
|
|
13
|
-
isExcluded(command: str) -> bool
|
|
14
|
-
Checks if the given command is excluded from output formatting.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
@staticmethod
|
|
18
|
-
def isExcluded(command: str) -> bool:
|
|
19
|
-
"""
|
|
20
|
-
Checks if the given command is in the excluded commands list.
|
|
21
|
-
|
|
22
|
-
Parameters
|
|
23
|
-
----------
|
|
24
|
-
command : str
|
|
25
|
-
The command to check.
|
|
26
|
-
|
|
27
|
-
Returns
|
|
28
|
-
-------
|
|
29
|
-
bool
|
|
30
|
-
Returns True if the command is excluded from output formatting, False otherwise.
|
|
31
|
-
"""
|
|
32
|
-
return command in [
|
|
33
|
-
'schedule:work', # Command to handle scheduled work
|
|
34
|
-
'help', # Command to show help information
|
|
35
|
-
'version', # Command to display version information
|
|
36
|
-
]
|
|
File without changes
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import shutil
|
|
3
|
-
from orionis._console.base.command import BaseCommand
|
|
4
|
-
from orionis._console.exceptions.cli_runtime_error import CLIOrionisRuntimeError
|
|
5
|
-
|
|
6
|
-
class CacheClearCommand(BaseCommand):
|
|
7
|
-
"""
|
|
8
|
-
Clears Python bytecode caches (__pycache__) within the project directory.
|
|
9
|
-
|
|
10
|
-
This command recursively searches for and removes all `__pycache__` directories
|
|
11
|
-
in the project folder to ensure that no stale bytecode files persist.
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
signature = 'cache:clear'
|
|
15
|
-
|
|
16
|
-
description = 'Clears the project cache by removing all __pycache__ directories.'
|
|
17
|
-
|
|
18
|
-
def __init__(self) -> None:
|
|
19
|
-
"""
|
|
20
|
-
Initializes the command instance, setting the list of directories to exclude from the cache clearing process.
|
|
21
|
-
"""
|
|
22
|
-
self.exclude_dirs = [
|
|
23
|
-
'venv',
|
|
24
|
-
'env',
|
|
25
|
-
'virtualenv',
|
|
26
|
-
'venv3',
|
|
27
|
-
'env3',
|
|
28
|
-
'venv2',
|
|
29
|
-
'env2',
|
|
30
|
-
'vendor',
|
|
31
|
-
'node_modules',
|
|
32
|
-
'environment'
|
|
33
|
-
]
|
|
34
|
-
|
|
35
|
-
def handle(self) -> None:
|
|
36
|
-
"""
|
|
37
|
-
Executes the cache clearing process.
|
|
38
|
-
|
|
39
|
-
This method performs the following actions:
|
|
40
|
-
- Recursively searches the project directory for `__pycache__` directories.
|
|
41
|
-
- Deletes all found `__pycache__` directories and their contents.
|
|
42
|
-
- Logs a success message if the process completes successfully, or an error message if an exception occurs.
|
|
43
|
-
"""
|
|
44
|
-
try:
|
|
45
|
-
|
|
46
|
-
# Get the base project path
|
|
47
|
-
base_path = os.getcwd()
|
|
48
|
-
|
|
49
|
-
# Normalize the base path to ensure consistent formatting
|
|
50
|
-
base_path = os.path.normpath(base_path)
|
|
51
|
-
|
|
52
|
-
# Recursively traverse directories starting from the base path
|
|
53
|
-
for root, dirs, files in os.walk(base_path, topdown=True):
|
|
54
|
-
|
|
55
|
-
# Skip common environment directories (e.g., venv, env, vendor, node_modules)
|
|
56
|
-
for env_dir in self.exclude_dirs:
|
|
57
|
-
if env_dir in dirs:
|
|
58
|
-
dirs.remove(env_dir)
|
|
59
|
-
|
|
60
|
-
# Check for __pycache__ directories
|
|
61
|
-
if '__pycache__' in dirs:
|
|
62
|
-
pycache_path = os.path.join(root, '__pycache__')
|
|
63
|
-
|
|
64
|
-
# Attempt to remove the __pycache__ directory
|
|
65
|
-
try:
|
|
66
|
-
shutil.rmtree(pycache_path)
|
|
67
|
-
except OSError as e:
|
|
68
|
-
self.fail(f"Error removing {pycache_path}: {e}")
|
|
69
|
-
|
|
70
|
-
# Log a success message once all caches are cleared
|
|
71
|
-
self.success(message='The application cache has been successfully cleared.')
|
|
72
|
-
|
|
73
|
-
except Exception as e:
|
|
74
|
-
|
|
75
|
-
# Handle any unexpected error and display the error message
|
|
76
|
-
raise CLIOrionisRuntimeError(f"An unexpected error occurred while clearing the cache: {e}") from e
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
from orionis.metadata.framework import NAME
|
|
2
|
-
from orionis._console.base.command import BaseCommand
|
|
3
|
-
from orionis._console.exceptions.cli_runtime_error import CLIOrionisRuntimeError
|
|
4
|
-
from orionis._contracts.application import IApplication
|
|
5
|
-
|
|
6
|
-
class HelpCommand(BaseCommand):
|
|
7
|
-
"""
|
|
8
|
-
Command class to display the list of available commands in the Orionis application.
|
|
9
|
-
This command fetches all registered commands from the cache and presents them in a table format.
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
signature = "help"
|
|
13
|
-
|
|
14
|
-
description = "Prints the list of available commands along with their descriptions."
|
|
15
|
-
|
|
16
|
-
def __init__(self, app : IApplication):
|
|
17
|
-
"""
|
|
18
|
-
Initialize the HelpCommand class.
|
|
19
|
-
|
|
20
|
-
Parameters
|
|
21
|
-
----------
|
|
22
|
-
app : IApplication
|
|
23
|
-
The application instance that is passed to the command class.
|
|
24
|
-
"""
|
|
25
|
-
self._commands : dict = app._commands if hasattr(app, '_commands') else {}
|
|
26
|
-
|
|
27
|
-
def handle(self) -> None:
|
|
28
|
-
"""
|
|
29
|
-
Execute the help command.
|
|
30
|
-
|
|
31
|
-
This method retrieves all available commands from the cache, sorts them alphabetically,
|
|
32
|
-
and displays them in a structured table format.
|
|
33
|
-
|
|
34
|
-
Raises
|
|
35
|
-
------
|
|
36
|
-
ValueError
|
|
37
|
-
If an unexpected error occurs during execution, a ValueError is raised
|
|
38
|
-
with the original exception message.
|
|
39
|
-
"""
|
|
40
|
-
try:
|
|
41
|
-
|
|
42
|
-
# Display the available commands
|
|
43
|
-
self.newLine()
|
|
44
|
-
self.textSuccessBold(f" ({str(NAME).upper()} CLI Interpreter) Available Commands: ")
|
|
45
|
-
|
|
46
|
-
# Initialize an empty list to store the rows.
|
|
47
|
-
rows = []
|
|
48
|
-
for signature, command_data in self._commands.items():
|
|
49
|
-
rows.append([
|
|
50
|
-
signature,
|
|
51
|
-
command_data['description'],
|
|
52
|
-
'Core Command' if 'orionis.console.commands' in command_data['concrete'].__module__ else 'User Command'
|
|
53
|
-
])
|
|
54
|
-
|
|
55
|
-
# Sort commands alphabetically
|
|
56
|
-
rows_sorted = sorted(rows, key=lambda x: x[0])
|
|
57
|
-
|
|
58
|
-
# Display the commands in a table format
|
|
59
|
-
self.table(
|
|
60
|
-
["Signature", "Description", "Type"],
|
|
61
|
-
rows_sorted
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
# Add a new line after the table
|
|
65
|
-
self.newLine()
|
|
66
|
-
|
|
67
|
-
except Exception as e:
|
|
68
|
-
|
|
69
|
-
# Handle any unexpected error and display the error message
|
|
70
|
-
raise CLIOrionisRuntimeError(f"An unexpected error occurred: {e}") from e
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import importlib
|
|
2
|
-
from orionis._console.base.command import BaseCommand
|
|
3
|
-
from orionis._console.exceptions.cli_runtime_error import CLIOrionisRuntimeError
|
|
4
|
-
from orionis._contracts.console.task_manager import ITaskManager
|
|
5
|
-
from orionis._facades.commands.scheduler_facade import Schedule
|
|
6
|
-
|
|
7
|
-
class ScheduleWorkCommand(BaseCommand):
|
|
8
|
-
"""
|
|
9
|
-
Command class to handle scheduled tasks within the Orionis application.
|
|
10
|
-
|
|
11
|
-
This command initializes the scheduling system, registers the schedule,
|
|
12
|
-
and starts the execution of scheduled tasks.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
signature = "schedule:work"
|
|
16
|
-
|
|
17
|
-
description = "Starts the scheduled tasks."
|
|
18
|
-
|
|
19
|
-
def __init__(self, schedule : Schedule) -> None:
|
|
20
|
-
"""
|
|
21
|
-
Initialize a new instance of the ScheduleWorkCommand class.
|
|
22
|
-
|
|
23
|
-
Args:
|
|
24
|
-
schedule (ScheduleService): The schedule instance to use for scheduling tasks.
|
|
25
|
-
"""
|
|
26
|
-
self.schedule : Schedule = schedule
|
|
27
|
-
|
|
28
|
-
def handle(self) -> None:
|
|
29
|
-
"""
|
|
30
|
-
Execute the scheduled tasks.
|
|
31
|
-
|
|
32
|
-
This method initializes a Schedule instance, creates a TaskManager (Kernel),
|
|
33
|
-
registers the schedule, and starts the execution of scheduled tasks.
|
|
34
|
-
|
|
35
|
-
Raises
|
|
36
|
-
------
|
|
37
|
-
RuntimeError
|
|
38
|
-
If an unexpected error occurs during execution, a RuntimeError is raised
|
|
39
|
-
with the original exception message.
|
|
40
|
-
"""
|
|
41
|
-
try:
|
|
42
|
-
|
|
43
|
-
# Create an instance of the TaskManager to manage the scheduling.
|
|
44
|
-
tasks_manager = importlib.import_module("app.console.tasks_manager")
|
|
45
|
-
TaskManager = getattr(tasks_manager, "TaskManager")
|
|
46
|
-
kernel: ITaskManager = TaskManager()
|
|
47
|
-
kernel.schedule(self.schedule)
|
|
48
|
-
|
|
49
|
-
# Start running the scheduled tasks using the schedule runner.
|
|
50
|
-
self.schedule.start()
|
|
51
|
-
|
|
52
|
-
except Exception as e:
|
|
53
|
-
|
|
54
|
-
# Handle any unexpected error and display the error message
|
|
55
|
-
raise CLIOrionisRuntimeError(f"An unexpected error occurred: {e}") from e
|
|
File without changes
|