orionis 0.419.0__py3-none-any.whl → 0.421.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/__init__.py +0 -11
- orionis/foundation/config/app/entities/app.py +15 -14
- orionis/foundation/config/cache/entities/cache.py +2 -1
- orionis/foundation/config/cache/entities/file.py +1 -0
- orionis/foundation/config/cache/entities/stores.py +1 -0
- orionis/foundation/config/cors/entities/cors.py +1 -0
- orionis/foundation/config/database/entities/connections.py +5 -4
- orionis/foundation/config/database/entities/database.py +3 -2
- orionis/foundation/config/database/entities/mysql.py +7 -6
- orionis/foundation/config/database/entities/oracle.py +11 -10
- orionis/foundation/config/database/entities/pgsql.py +7 -6
- orionis/foundation/config/database/entities/sqlite.py +8 -7
- orionis/foundation/config/filesystems/entitites/aws.py +1 -0
- orionis/foundation/config/filesystems/entitites/disks.py +4 -3
- orionis/foundation/config/filesystems/entitites/filesystems.py +2 -1
- orionis/foundation/config/filesystems/entitites/local.py +1 -0
- orionis/foundation/config/filesystems/entitites/public.py +1 -0
- orionis/foundation/config/logging/entities/channels.py +7 -6
- orionis/foundation/config/logging/entities/chunked.py +1 -0
- orionis/foundation/config/logging/entities/daily.py +3 -2
- orionis/foundation/config/logging/entities/hourly.py +1 -0
- orionis/foundation/config/logging/entities/logging.py +2 -1
- orionis/foundation/config/logging/entities/monthly.py +1 -0
- orionis/foundation/config/logging/entities/stack.py +1 -0
- orionis/foundation/config/logging/entities/weekly.py +1 -0
- orionis/foundation/config/mail/entities/mail.py +1 -1
- orionis/foundation/config/mail/entities/mailers.py +2 -2
- orionis/foundation/config/queue/entities/brokers.py +2 -1
- orionis/foundation/config/queue/entities/database.py +1 -0
- orionis/foundation/config/queue/entities/queue.py +2 -1
- orionis/foundation/config/roots/paths.py +63 -62
- orionis/foundation/config/session/entities/session.py +9 -8
- orionis/foundation/config/startup.py +13 -12
- orionis/foundation/config/testing/entities/testing.py +2 -1
- orionis/metadata/framework.py +1 -1
- orionis/support/entities/base.py +25 -0
- {orionis-0.419.0.dist-info → orionis-0.421.0.dist-info}/METADATA +1 -1
- {orionis-0.419.0.dist-info → orionis-0.421.0.dist-info}/RECORD +43 -116
- tests/foundation/config/root/test_foundation_config_root_paths.py +4 -1
- orionis/_contracts/__init__.py +0 -0
- orionis/_contracts/application.py +0 -41
- orionis/_contracts/config/__init__.py +0 -0
- orionis/_contracts/config/config.py +0 -27
- orionis/_contracts/console/__init__.py +0 -0
- orionis/_contracts/console/base/__init__.py +0 -0
- orionis/_contracts/console/base/command.py +0 -437
- orionis/_contracts/console/command_filter.py +0 -32
- orionis/_contracts/console/kernel.py +0 -32
- orionis/_contracts/console/output/__init__.py +0 -0
- orionis/_contracts/console/output/console.py +0 -421
- orionis/_contracts/console/output/executor.py +0 -51
- orionis/_contracts/console/parser.py +0 -75
- orionis/_contracts/console/task_manager.py +0 -37
- orionis/_contracts/facades/__init__.py +0 -0
- orionis/_contracts/facades/commands/__init__.py +0 -0
- orionis/_contracts/facades/commands/commands_facade.py +0 -40
- orionis/_contracts/facades/commands/scheduler_facade.py +0 -28
- orionis/_contracts/facades/config/__init__.py +0 -0
- orionis/_contracts/facades/config/config_facade.py +0 -37
- orionis/_contracts/facades/environment/__init__.py +0 -0
- orionis/_contracts/facades/environment/environment_facade.py +0 -74
- orionis/_contracts/facades/facade.py +0 -38
- orionis/_contracts/facades/files/__init__.py +0 -0
- orionis/_contracts/facades/files/path_facade.py +0 -148
- orionis/_contracts/facades/log/__init__.py +0 -0
- orionis/_contracts/facades/log/log_facade.py +0 -83
- orionis/_contracts/facades/tests/__init__.py +0 -0
- orionis/_contracts/facades/tests/tests_facade.py +0 -30
- orionis/_contracts/foundation/__init__.py +0 -0
- orionis/_contracts/foundation/bootstraper.py +0 -41
- orionis/_contracts/foundation/config/__init__.py +0 -0
- orionis/_contracts/foundation/config/config_bootstrapper.py +0 -140
- orionis/_contracts/foundation/console/__init__.py +0 -0
- orionis/_contracts/foundation/console/command_bootstrapper.py +0 -81
- orionis/_contracts/foundation/environment/__init__.py +0 -0
- orionis/_contracts/foundation/environment/environment_bootstrapper.py +0 -33
- orionis/_contracts/foundation/providers/__init__.py +0 -0
- orionis/_contracts/foundation/providers/service_providers_bootstrapper.py +0 -47
- orionis/_contracts/providers/__init__.py +0 -0
- orionis/_contracts/providers/service_provider.py +0 -14
- orionis/_contracts/services/__init__.py +0 -0
- orionis/_contracts/services/commands/__init__.py +0 -0
- orionis/_contracts/services/commands/reactor_commands_service.py +0 -23
- orionis/_contracts/services/commands/schedule_service.py +0 -317
- orionis/_contracts/services/config/__init__.py +0 -0
- orionis/_contracts/services/config/config_service.py +0 -37
- orionis/_contracts/services/environment/__init__.py +0 -0
- orionis/_contracts/services/environment/environment_service.py +0 -74
- orionis/_contracts/services/files/__init__.py +0 -0
- orionis/_contracts/services/files/path_resolver_service.py +0 -29
- orionis/_contracts/services/log/__init__.py +0 -0
- orionis/_contracts/services/log/log_service.py +0 -89
- orionis/_contracts/support/exception_parse.py +0 -26
- orionis/_contracts/support/reflection.py +0 -352
- orionis/_foundation/__init__.py +0 -0
- orionis/_foundation/console/__init__.py +0 -0
- orionis/_foundation/console/command_bootstrapper.py +0 -175
- orionis/_foundation/environment/__init__.py +0 -0
- orionis/_foundation/environment/environment_bootstrapper.py +0 -76
- orionis/_foundation/exceptions/__init__.py +0 -0
- orionis/_foundation/exceptions/exception_bootstrapper.py +0 -54
- orionis/_foundation/exceptions/exception_providers.py +0 -54
- orionis/_foundation/foundation/config/__init__.py +0 -0
- orionis/_foundation/foundation/config/config_bootstrapper.py +0 -209
- orionis/_foundation/providers/__init__.py +0 -0
- orionis/_foundation/providers/service_providers_bootstrapper.py +0 -107
- orionis/_services/__init__.py +0 -0
- orionis/_services/commands/__init__.py +0 -0
- orionis/_services/commands/reactor_commands_service.py +0 -148
- orionis/_services/commands/scheduler_service.py +0 -611
- orionis/_services/config/__init__.py +0 -0
- orionis/_services/config/config_service.py +0 -72
- {orionis-0.419.0.dist-info → orionis-0.421.0.dist-info}/WHEEL +0 -0
- {orionis-0.419.0.dist-info → orionis-0.421.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.419.0.dist-info → orionis-0.421.0.dist-info}/top_level.txt +0 -0
- {orionis-0.419.0.dist-info → orionis-0.421.0.dist-info}/zip-safe +0 -0
|
@@ -1,611 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
import re
|
|
3
|
-
import sys
|
|
4
|
-
import time
|
|
5
|
-
from datetime import datetime
|
|
6
|
-
from typing import Any
|
|
7
|
-
from apscheduler.schedulers.background import BackgroundScheduler
|
|
8
|
-
from apscheduler.triggers.cron import CronTrigger
|
|
9
|
-
from apscheduler.triggers.interval import IntervalTrigger
|
|
10
|
-
from orionis._console.exceptions.cli_schedule_exception import CLIOrionisScheduleException
|
|
11
|
-
from orionis._facades.commands.commands_facade import Command
|
|
12
|
-
|
|
13
|
-
class ScheduleService:
|
|
14
|
-
"""
|
|
15
|
-
A class that manages the scheduling of tasks using the APScheduler.
|
|
16
|
-
|
|
17
|
-
Attributes
|
|
18
|
-
----------
|
|
19
|
-
scheduler : BackgroundScheduler
|
|
20
|
-
The background scheduler instance used to schedule tasks.
|
|
21
|
-
callback : function | None
|
|
22
|
-
A callback function that will be called when the scheduled task is triggered.
|
|
23
|
-
|
|
24
|
-
Methods
|
|
25
|
-
-------
|
|
26
|
-
command(signature: str, vars: dict[str, Any] = {}, *args: Any, **kwargs: Any) -> 'Schedule':
|
|
27
|
-
Defines a command to execute.
|
|
28
|
-
"""
|
|
29
|
-
|
|
30
|
-
def __init__(self, apscheduler_background : BackgroundScheduler, logger_level=logging.CRITICAL):
|
|
31
|
-
"""
|
|
32
|
-
Initializes the Schedule object.
|
|
33
|
-
|
|
34
|
-
This method sets up the background scheduler, starts it, and configures the logging level for APScheduler.
|
|
35
|
-
|
|
36
|
-
Parameters
|
|
37
|
-
----------
|
|
38
|
-
logger_level : int, optional
|
|
39
|
-
The logging level for the APScheduler logger. Default is `logging.CRITICAL` to suppress most logs.
|
|
40
|
-
"""
|
|
41
|
-
logging.getLogger("apscheduler").setLevel(logger_level)
|
|
42
|
-
self.scheduler = apscheduler_background
|
|
43
|
-
self.scheduler.start()
|
|
44
|
-
self.callback = None
|
|
45
|
-
self.wait = True
|
|
46
|
-
|
|
47
|
-
def command(self, signature: str, vars: dict[str, Any] = {}, *args: Any, **kwargs: Any) -> 'ScheduleService':
|
|
48
|
-
"""
|
|
49
|
-
Defines a Orionis command to be executed.
|
|
50
|
-
|
|
51
|
-
Parameters
|
|
52
|
-
----------
|
|
53
|
-
signature : str
|
|
54
|
-
The signature of the command to execute.
|
|
55
|
-
vars : dict, optional
|
|
56
|
-
A dictionary of variables to pass to the command, by default an empty dictionary.
|
|
57
|
-
*args : Any
|
|
58
|
-
Additional positional arguments to pass to the command.
|
|
59
|
-
**kwargs : Any
|
|
60
|
-
Additional keyword arguments to pass to the command.
|
|
61
|
-
|
|
62
|
-
Returns
|
|
63
|
-
-------
|
|
64
|
-
Schedule
|
|
65
|
-
Returns the Schedule instance itself, allowing method chaining.
|
|
66
|
-
"""
|
|
67
|
-
def func():
|
|
68
|
-
try:
|
|
69
|
-
Command.call(signature, vars, *args, **kwargs)
|
|
70
|
-
finally:
|
|
71
|
-
if not self.scheduler.get_jobs():
|
|
72
|
-
self.wait = False
|
|
73
|
-
|
|
74
|
-
self.callback = func
|
|
75
|
-
return self
|
|
76
|
-
|
|
77
|
-
def _checkCommand(self):
|
|
78
|
-
"""
|
|
79
|
-
Raises an exception to test the exception handling in the CLI.
|
|
80
|
-
"""
|
|
81
|
-
if not self.callback:
|
|
82
|
-
raise CLIOrionisScheduleException("No command has been defined to execute.")
|
|
83
|
-
|
|
84
|
-
def _resetCallback(self):
|
|
85
|
-
"""
|
|
86
|
-
Resets the callback function to None.
|
|
87
|
-
"""
|
|
88
|
-
self.callback = None
|
|
89
|
-
|
|
90
|
-
def _hourFormat(self, at: str):
|
|
91
|
-
"""
|
|
92
|
-
Validates the time format in 'HH:MM' 24-hour format.
|
|
93
|
-
"""
|
|
94
|
-
if not isinstance(at, str):
|
|
95
|
-
raise CLIOrionisScheduleException("Time must be a string in 'HH:MM' format. Example: '23:59'.")
|
|
96
|
-
|
|
97
|
-
# Regular expression for the "HH:MM" 24-hour format
|
|
98
|
-
pattern = r"^(?:[01]\d|2[0-3]):[0-5]\d$"
|
|
99
|
-
|
|
100
|
-
if not re.match(pattern, at):
|
|
101
|
-
raise CLIOrionisScheduleException("Invalid time format. Expected 'HH:MM' (24-hour format). Example: '23:59'.")
|
|
102
|
-
|
|
103
|
-
return at.split(':')
|
|
104
|
-
|
|
105
|
-
def _checkDateTime(self, start_date: datetime = None, end_date: datetime = None):
|
|
106
|
-
"""
|
|
107
|
-
Validates the `start_date` and `end_date` parameters.
|
|
108
|
-
|
|
109
|
-
Ensures that both parameters are either `None` or valid `datetime` instances.
|
|
110
|
-
Additionally, it verifies that `start_date` is earlier than `end_date` if both are provided.
|
|
111
|
-
|
|
112
|
-
Parameters
|
|
113
|
-
----------
|
|
114
|
-
start_date : datetime, optional
|
|
115
|
-
The start time of the scheduled job. Must be a valid `datetime` object if provided.
|
|
116
|
-
end_date : datetime, optional
|
|
117
|
-
The end time of the scheduled job. Must be a valid `datetime` object if provided.
|
|
118
|
-
|
|
119
|
-
Raises
|
|
120
|
-
------
|
|
121
|
-
CLIOrionisScheduleException
|
|
122
|
-
If `start_date` or `end_date` are not valid `datetime` objects.
|
|
123
|
-
If `start_date` is later than or equal to `end_date`.
|
|
124
|
-
"""
|
|
125
|
-
|
|
126
|
-
# Ensure `start_date` is either None or a valid datetime object
|
|
127
|
-
if start_date is not None and not isinstance(start_date, datetime):
|
|
128
|
-
raise CLIOrionisScheduleException("start_date must be a valid datetime object.")
|
|
129
|
-
|
|
130
|
-
# Ensure `end_date` is either None or a valid datetime object
|
|
131
|
-
if end_date is not None and not isinstance(end_date, datetime):
|
|
132
|
-
raise CLIOrionisScheduleException("end_date must be a valid datetime object.")
|
|
133
|
-
|
|
134
|
-
# Ensure `start_date` is earlier than `end_date` if both are provided
|
|
135
|
-
if start_date and end_date and start_date >= end_date:
|
|
136
|
-
raise CLIOrionisScheduleException("start_date must be earlier than end_date.")
|
|
137
|
-
|
|
138
|
-
def _checkGreterThanZero(self, value: int, identifier: str = 'interval'):
|
|
139
|
-
"""
|
|
140
|
-
Validates that the value is greater than 0.
|
|
141
|
-
"""
|
|
142
|
-
if value < 1:
|
|
143
|
-
raise CLIOrionisScheduleException(f"The {identifier} must be greater than 0.")
|
|
144
|
-
|
|
145
|
-
def onceAt(self, date: datetime):
|
|
146
|
-
"""
|
|
147
|
-
Schedule the defined command to execute every X seconds.
|
|
148
|
-
"""
|
|
149
|
-
self._checkCommand()
|
|
150
|
-
|
|
151
|
-
if not isinstance(date, datetime):
|
|
152
|
-
raise CLIOrionisScheduleException("The date must be a valid datetime object.")
|
|
153
|
-
|
|
154
|
-
self.scheduler.add_job(
|
|
155
|
-
self.callback,
|
|
156
|
-
'date',
|
|
157
|
-
run_date=date
|
|
158
|
-
)
|
|
159
|
-
|
|
160
|
-
self._resetCallback()
|
|
161
|
-
|
|
162
|
-
def everySeconds(self, seconds: int, start_date: datetime = None, end_date: datetime = None):
|
|
163
|
-
"""
|
|
164
|
-
Schedule the defined command to execute every X seconds.
|
|
165
|
-
"""
|
|
166
|
-
self._checkCommand()
|
|
167
|
-
self._checkGreterThanZero(seconds)
|
|
168
|
-
self._checkDateTime(start_date, end_date)
|
|
169
|
-
|
|
170
|
-
self.scheduler.add_job(
|
|
171
|
-
self.callback,
|
|
172
|
-
IntervalTrigger(seconds=seconds, start_date=start_date, end_date=end_date),
|
|
173
|
-
replace_existing=True
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
self._resetCallback()
|
|
177
|
-
|
|
178
|
-
def everySecond(self, start_date: datetime = None, end_date: datetime = None):
|
|
179
|
-
"""
|
|
180
|
-
Schedules the defined command to execute every second.
|
|
181
|
-
"""
|
|
182
|
-
self.everySeconds(seconds=1, start_date=start_date, end_date=end_date)
|
|
183
|
-
|
|
184
|
-
def everyTwoSeconds(self, start_date: datetime = None, end_date: datetime = None):
|
|
185
|
-
"""
|
|
186
|
-
Schedules the defined command to execute every two seconds.
|
|
187
|
-
"""
|
|
188
|
-
self.everySeconds(seconds=2, start_date=start_date, end_date=end_date)
|
|
189
|
-
|
|
190
|
-
def everyFiveSeconds(self, start_date: datetime = None, end_date: datetime = None):
|
|
191
|
-
"""
|
|
192
|
-
Schedules the defined command to execute every five seconds.
|
|
193
|
-
"""
|
|
194
|
-
self.everySeconds(seconds=5, start_date=start_date, end_date=end_date)
|
|
195
|
-
|
|
196
|
-
def everyTenSeconds(self, start_date: datetime = None, end_date: datetime = None):
|
|
197
|
-
"""
|
|
198
|
-
Schedules the defined command to execute every ten seconds.
|
|
199
|
-
"""
|
|
200
|
-
self.everySeconds(seconds=10, start_date=start_date, end_date=end_date)
|
|
201
|
-
|
|
202
|
-
def everyFifteenSeconds(self, start_date: datetime = None, end_date: datetime = None):
|
|
203
|
-
"""
|
|
204
|
-
Schedules the defined command to execute every fifteen seconds.
|
|
205
|
-
"""
|
|
206
|
-
self.everySeconds(seconds=15, start_date=start_date, end_date=end_date)
|
|
207
|
-
|
|
208
|
-
def everyTwentySeconds(self, start_date: datetime = None, end_date: datetime = None):
|
|
209
|
-
"""
|
|
210
|
-
Schedules the defined command to execute every twenty seconds.
|
|
211
|
-
"""
|
|
212
|
-
self.everySeconds(seconds=20, start_date=start_date, end_date=end_date)
|
|
213
|
-
|
|
214
|
-
def everyThirtySeconds(self, start_date: datetime = None, end_date: datetime = None):
|
|
215
|
-
"""
|
|
216
|
-
Schedules the defined command to execute every thirty seconds.
|
|
217
|
-
"""
|
|
218
|
-
self.everySeconds(seconds=30, start_date=start_date, end_date=end_date)
|
|
219
|
-
|
|
220
|
-
def everyMinutes(self, minutes: int, start_date: datetime = None, end_date: datetime = None):
|
|
221
|
-
"""
|
|
222
|
-
Schedules the defined command to execute every X minutes.
|
|
223
|
-
"""
|
|
224
|
-
self._checkCommand()
|
|
225
|
-
self._checkGreterThanZero(minutes)
|
|
226
|
-
self._checkDateTime(start_date, end_date)
|
|
227
|
-
|
|
228
|
-
self.scheduler.add_job(
|
|
229
|
-
self.callback,
|
|
230
|
-
IntervalTrigger(minutes=minutes, start_date=start_date, end_date=end_date),
|
|
231
|
-
replace_existing=True
|
|
232
|
-
)
|
|
233
|
-
|
|
234
|
-
self._resetCallback()
|
|
235
|
-
|
|
236
|
-
def everyMinute(self, start_date: datetime = None, end_date: datetime = None):
|
|
237
|
-
"""
|
|
238
|
-
Schedules the defined command to execute every minute.
|
|
239
|
-
"""
|
|
240
|
-
self.everyMinutes(minutes=1, start_date=start_date, end_date=end_date)
|
|
241
|
-
|
|
242
|
-
def everyTwoMinutes(self, start_date: datetime = None, end_date: datetime = None):
|
|
243
|
-
"""
|
|
244
|
-
Schedules the defined command to execute every two minutes.
|
|
245
|
-
"""
|
|
246
|
-
self.everyMinutes(minutes=2, start_date=start_date, end_date=end_date)
|
|
247
|
-
|
|
248
|
-
def everyThreeMinutes(self, start_date: datetime = None, end_date: datetime = None):
|
|
249
|
-
"""
|
|
250
|
-
Schedules the defined command to execute every three minutes.
|
|
251
|
-
"""
|
|
252
|
-
self.everyMinutes(minutes=3, start_date=start_date, end_date=end_date)
|
|
253
|
-
|
|
254
|
-
def everyFourMinutes(self, start_date: datetime = None, end_date: datetime = None):
|
|
255
|
-
"""
|
|
256
|
-
Schedules the defined command to execute every four minutes.
|
|
257
|
-
"""
|
|
258
|
-
self.everyMinutes(minutes=4, start_date=start_date, end_date=end_date)
|
|
259
|
-
|
|
260
|
-
def everyFiveMinutes(self, start_date: datetime = None, end_date: datetime = None):
|
|
261
|
-
"""
|
|
262
|
-
Schedules the defined command to execute every five minutes.
|
|
263
|
-
"""
|
|
264
|
-
self.everyMinutes(minutes=5, start_date=start_date, end_date=end_date)
|
|
265
|
-
|
|
266
|
-
def everyTenMinutes(self, start_date: datetime = None, end_date: datetime = None):
|
|
267
|
-
"""
|
|
268
|
-
Schedules the defined command to execute every ten minutes.
|
|
269
|
-
"""
|
|
270
|
-
self.everyMinutes(minutes=10, start_date=start_date, end_date=end_date)
|
|
271
|
-
|
|
272
|
-
def everyFifteenMinutes(self, start_date: datetime = None, end_date: datetime = None):
|
|
273
|
-
"""
|
|
274
|
-
Schedules the defined command to execute every fifteen minutes.
|
|
275
|
-
"""
|
|
276
|
-
self.everyMinutes(minutes=15, start_date=start_date, end_date=end_date)
|
|
277
|
-
|
|
278
|
-
def everyThirtyMinutes(self, start_date: datetime = None, end_date: datetime = None):
|
|
279
|
-
"""
|
|
280
|
-
Schedules the defined command to execute every thirty minutes.
|
|
281
|
-
"""
|
|
282
|
-
self.everyMinutes(minutes=30, start_date=start_date, end_date=end_date)
|
|
283
|
-
|
|
284
|
-
def hours(self, hours: int, start_date: datetime = None, end_date: datetime = None):
|
|
285
|
-
"""
|
|
286
|
-
Schedules the defined command to execute every X hours.
|
|
287
|
-
"""
|
|
288
|
-
self._checkCommand()
|
|
289
|
-
self._checkGreterThanZero(hours)
|
|
290
|
-
self._checkDateTime(start_date, end_date)
|
|
291
|
-
|
|
292
|
-
self.scheduler.add_job(
|
|
293
|
-
self.callback,
|
|
294
|
-
IntervalTrigger(hours=hours, start_date=start_date, end_date=end_date),
|
|
295
|
-
replace_existing=True
|
|
296
|
-
)
|
|
297
|
-
|
|
298
|
-
self._resetCallback()
|
|
299
|
-
|
|
300
|
-
def hourly(self, start_date: datetime = None, end_date: datetime = None):
|
|
301
|
-
"""
|
|
302
|
-
Schedules the defined command to execute every hour.
|
|
303
|
-
"""
|
|
304
|
-
self.hours(hours=1, start_date=start_date, end_date=end_date)
|
|
305
|
-
|
|
306
|
-
def hourlyAt(self, minute: int, start_date: datetime = None, end_date: datetime = None):
|
|
307
|
-
"""
|
|
308
|
-
Schedules the defined command to execute every hour at a specific minute.
|
|
309
|
-
"""
|
|
310
|
-
self._checkCommand()
|
|
311
|
-
self._checkGreterThanZero(minute)
|
|
312
|
-
self._checkDateTime(start_date, end_date)
|
|
313
|
-
|
|
314
|
-
self.scheduler.add_job(
|
|
315
|
-
self.callback,
|
|
316
|
-
CronTrigger(hour='*', minute=minute, start_date=start_date, end_date=end_date),
|
|
317
|
-
replace_existing=True
|
|
318
|
-
)
|
|
319
|
-
|
|
320
|
-
self._resetCallback()
|
|
321
|
-
|
|
322
|
-
def everyOddHour(self, minute: int, start_date: datetime = None, end_date: datetime = None):
|
|
323
|
-
"""
|
|
324
|
-
Schedules the defined command to execute every odd hour.
|
|
325
|
-
"""
|
|
326
|
-
self._checkCommand()
|
|
327
|
-
self._checkGreterThanZero(minute)
|
|
328
|
-
self._checkDateTime(start_date, end_date)
|
|
329
|
-
|
|
330
|
-
self.scheduler.add_job(
|
|
331
|
-
self.callback,
|
|
332
|
-
CronTrigger(hour='1,3,5,7,9,11,13,15,17,19,21,23', minute=minute, start_date=start_date, end_date=end_date),
|
|
333
|
-
replace_existing=True
|
|
334
|
-
)
|
|
335
|
-
|
|
336
|
-
self._resetCallback()
|
|
337
|
-
|
|
338
|
-
def everyTwoHours(self, minute: int, start_date: datetime = None, end_date: datetime = None):
|
|
339
|
-
"""
|
|
340
|
-
Schedules the defined command to execute every two hours.
|
|
341
|
-
"""
|
|
342
|
-
self._checkCommand()
|
|
343
|
-
self._checkGreterThanZero(minute)
|
|
344
|
-
self._checkDateTime(start_date, end_date)
|
|
345
|
-
|
|
346
|
-
self.scheduler.add_job(
|
|
347
|
-
self.callback,
|
|
348
|
-
CronTrigger(hour='*/2', minute=minute, start_date=start_date, end_date=end_date),
|
|
349
|
-
replace_existing=True
|
|
350
|
-
)
|
|
351
|
-
|
|
352
|
-
self._resetCallback()
|
|
353
|
-
|
|
354
|
-
def everyThreeHours(self, minute: int, start_date: datetime = None, end_date: datetime = None):
|
|
355
|
-
"""
|
|
356
|
-
Schedules the defined command to execute every three hours.
|
|
357
|
-
"""
|
|
358
|
-
self._checkCommand()
|
|
359
|
-
self._checkGreterThanZero(minute)
|
|
360
|
-
self._checkDateTime(start_date, end_date)
|
|
361
|
-
|
|
362
|
-
self.scheduler.add_job(
|
|
363
|
-
self.callback,
|
|
364
|
-
CronTrigger(hour='*/3', minute=minute, start_date=start_date, end_date=end_date),
|
|
365
|
-
replace_existing=True
|
|
366
|
-
)
|
|
367
|
-
|
|
368
|
-
self._resetCallback()
|
|
369
|
-
|
|
370
|
-
def everyFourHours(self, minute: int, start_date: datetime = None, end_date: datetime = None):
|
|
371
|
-
"""
|
|
372
|
-
Schedules the defined command to execute every four hours.
|
|
373
|
-
"""
|
|
374
|
-
self._checkCommand()
|
|
375
|
-
self._checkGreterThanZero(minute)
|
|
376
|
-
self._checkDateTime(start_date, end_date)
|
|
377
|
-
|
|
378
|
-
self.scheduler.add_job(
|
|
379
|
-
self.callback,
|
|
380
|
-
CronTrigger(hour='*/4', minute=minute, start_date=start_date, end_date=end_date),
|
|
381
|
-
replace_existing=True
|
|
382
|
-
)
|
|
383
|
-
|
|
384
|
-
self._resetCallback()
|
|
385
|
-
|
|
386
|
-
def everySixHours(self, minute: int, start_date: datetime = None, end_date: datetime = None):
|
|
387
|
-
"""
|
|
388
|
-
Schedules the defined command to execute every six hours.
|
|
389
|
-
"""
|
|
390
|
-
self._checkCommand()
|
|
391
|
-
self._checkGreterThanZero(minute)
|
|
392
|
-
self._checkDateTime(start_date, end_date)
|
|
393
|
-
|
|
394
|
-
self.scheduler.add_job(
|
|
395
|
-
self.callback,
|
|
396
|
-
CronTrigger(hour='*/6', minute=minute, start_date=start_date, end_date=end_date),
|
|
397
|
-
replace_existing=True
|
|
398
|
-
)
|
|
399
|
-
|
|
400
|
-
self._resetCallback()
|
|
401
|
-
|
|
402
|
-
def days(self, days: int, start_date: datetime = None, end_date: datetime = None):
|
|
403
|
-
"""
|
|
404
|
-
Schedules the defined command to execute every X days.
|
|
405
|
-
"""
|
|
406
|
-
self._checkCommand()
|
|
407
|
-
self._checkGreterThanZero(days)
|
|
408
|
-
self._checkDateTime(start_date, end_date)
|
|
409
|
-
|
|
410
|
-
self.scheduler.add_job(
|
|
411
|
-
self.callback,
|
|
412
|
-
IntervalTrigger(days=days, start_date=start_date, end_date=end_date),
|
|
413
|
-
replace_existing=True
|
|
414
|
-
)
|
|
415
|
-
|
|
416
|
-
self._resetCallback()
|
|
417
|
-
|
|
418
|
-
def daily(self, start_date: datetime = None, end_date: datetime = None):
|
|
419
|
-
"""
|
|
420
|
-
Schedules the defined command to execute daily at midnight.
|
|
421
|
-
"""
|
|
422
|
-
self._checkCommand()
|
|
423
|
-
self._checkDateTime(start_date, end_date)
|
|
424
|
-
|
|
425
|
-
self.scheduler.add_job(
|
|
426
|
-
self.callback,
|
|
427
|
-
CronTrigger(hour=0, minute=0, second=1, start_date=start_date, end_date=end_date),
|
|
428
|
-
replace_existing=True
|
|
429
|
-
)
|
|
430
|
-
|
|
431
|
-
self._resetCallback()
|
|
432
|
-
|
|
433
|
-
def dailyAt(self, at: str, start_date: datetime = None, end_date: datetime = None):
|
|
434
|
-
"""
|
|
435
|
-
Schedules the defined command to execute daily at a specific time.
|
|
436
|
-
"""
|
|
437
|
-
self._checkCommand()
|
|
438
|
-
self._checkDateTime(start_date, end_date)
|
|
439
|
-
hour, minute = self._hourFormat(at)
|
|
440
|
-
|
|
441
|
-
self.scheduler.add_job(
|
|
442
|
-
self.callback,
|
|
443
|
-
CronTrigger(hour=hour, minute=minute, start_date=start_date, end_date=end_date),
|
|
444
|
-
replace_existing=True
|
|
445
|
-
)
|
|
446
|
-
|
|
447
|
-
self._resetCallback()
|
|
448
|
-
|
|
449
|
-
def twiceDaily(self, first_hour: int, second_hour: int, start_date: datetime = None, end_date: datetime = None):
|
|
450
|
-
"""
|
|
451
|
-
Schedules the defined command to execute twice a day at specific hours.
|
|
452
|
-
"""
|
|
453
|
-
self._checkCommand()
|
|
454
|
-
self._checkGreterThanZero(first_hour)
|
|
455
|
-
self._checkGreterThanZero(second_hour)
|
|
456
|
-
self._checkDateTime(start_date, end_date)
|
|
457
|
-
|
|
458
|
-
self.scheduler.add_job(
|
|
459
|
-
self.callback,
|
|
460
|
-
CronTrigger(hour=f'{first_hour},{second_hour}', minute=0, start_date=start_date, end_date=end_date),
|
|
461
|
-
replace_existing=True
|
|
462
|
-
)
|
|
463
|
-
|
|
464
|
-
self._resetCallback()
|
|
465
|
-
|
|
466
|
-
def monday(self, at: str, start_date: datetime = None, end_date: datetime = None):
|
|
467
|
-
"""
|
|
468
|
-
Schedules the defined command to execute every Monday at a specific time.
|
|
469
|
-
"""
|
|
470
|
-
|
|
471
|
-
self._checkCommand()
|
|
472
|
-
self._checkDateTime(start_date, end_date)
|
|
473
|
-
hour, minute = self._hourFormat(at)
|
|
474
|
-
|
|
475
|
-
self.scheduler.add_job(
|
|
476
|
-
self.callback,
|
|
477
|
-
CronTrigger(day_of_week='mon', hour=hour, minute=minute, start_date=start_date, end_date=end_date),
|
|
478
|
-
replace_existing=True
|
|
479
|
-
)
|
|
480
|
-
|
|
481
|
-
self._resetCallback()
|
|
482
|
-
|
|
483
|
-
def tuesday(self, at: str, start_date: datetime = None, end_date: datetime = None):
|
|
484
|
-
"""
|
|
485
|
-
Schedules the defined command to execute every tuesday at a specific time.
|
|
486
|
-
"""
|
|
487
|
-
|
|
488
|
-
self._checkCommand()
|
|
489
|
-
self._checkDateTime(start_date, end_date)
|
|
490
|
-
hour, minute = self._hourFormat(at)
|
|
491
|
-
|
|
492
|
-
self.scheduler.add_job(
|
|
493
|
-
self.callback,
|
|
494
|
-
CronTrigger(day_of_week='tue', hour=hour, minute=minute, start_date=start_date, end_date=end_date),
|
|
495
|
-
replace_existing=True
|
|
496
|
-
)
|
|
497
|
-
|
|
498
|
-
self._resetCallback()
|
|
499
|
-
|
|
500
|
-
def wednesday(self, at: str, start_date: datetime = None, end_date: datetime = None):
|
|
501
|
-
"""
|
|
502
|
-
Schedules the defined command to execute every wednesday at a specific time.
|
|
503
|
-
"""
|
|
504
|
-
|
|
505
|
-
self._checkCommand()
|
|
506
|
-
self._checkDateTime(start_date, end_date)
|
|
507
|
-
hour, minute = self._hourFormat(at)
|
|
508
|
-
|
|
509
|
-
self.scheduler.add_job(
|
|
510
|
-
self.callback,
|
|
511
|
-
CronTrigger(day_of_week='wed', hour=hour, minute=minute, start_date=start_date, end_date=end_date),
|
|
512
|
-
replace_existing=True
|
|
513
|
-
)
|
|
514
|
-
|
|
515
|
-
self._resetCallback()
|
|
516
|
-
|
|
517
|
-
def thursday(self, at: str, start_date: datetime = None, end_date: datetime = None):
|
|
518
|
-
"""
|
|
519
|
-
Schedules the defined command to execute every thursday at a specific time.
|
|
520
|
-
"""
|
|
521
|
-
|
|
522
|
-
self._checkCommand()
|
|
523
|
-
self._checkDateTime(start_date, end_date)
|
|
524
|
-
hour, minute = self._hourFormat(at)
|
|
525
|
-
|
|
526
|
-
self.scheduler.add_job(
|
|
527
|
-
self.callback,
|
|
528
|
-
CronTrigger(day_of_week='thu', hour=hour, minute=minute, start_date=start_date, end_date=end_date),
|
|
529
|
-
replace_existing=True
|
|
530
|
-
)
|
|
531
|
-
|
|
532
|
-
self._resetCallback()
|
|
533
|
-
|
|
534
|
-
def friday(self, at: str, start_date: datetime = None, end_date: datetime = None):
|
|
535
|
-
"""
|
|
536
|
-
Schedules the defined command to execute every friday at a specific time.
|
|
537
|
-
"""
|
|
538
|
-
|
|
539
|
-
self._checkCommand()
|
|
540
|
-
self._checkDateTime(start_date, end_date)
|
|
541
|
-
hour, minute = self._hourFormat(at)
|
|
542
|
-
|
|
543
|
-
self.scheduler.add_job(
|
|
544
|
-
self.callback,
|
|
545
|
-
CronTrigger(day_of_week='fri', hour=hour, minute=minute, start_date=start_date, end_date=end_date),
|
|
546
|
-
replace_existing=True
|
|
547
|
-
)
|
|
548
|
-
|
|
549
|
-
self._resetCallback()
|
|
550
|
-
|
|
551
|
-
def saturday(self, at: str, start_date: datetime = None, end_date: datetime = None):
|
|
552
|
-
"""
|
|
553
|
-
Schedules the defined command to execute every saturday at a specific time.
|
|
554
|
-
"""
|
|
555
|
-
|
|
556
|
-
self._checkCommand()
|
|
557
|
-
self._checkDateTime(start_date, end_date)
|
|
558
|
-
hour, minute = self._hourFormat(at)
|
|
559
|
-
|
|
560
|
-
self.scheduler.add_job(
|
|
561
|
-
self.callback,
|
|
562
|
-
CronTrigger(day_of_week='sat', hour=hour, minute=minute, start_date=start_date, end_date=end_date),
|
|
563
|
-
replace_existing=True
|
|
564
|
-
)
|
|
565
|
-
|
|
566
|
-
self._resetCallback()
|
|
567
|
-
|
|
568
|
-
def sunday(self, at: str, start_date: datetime = None, end_date: datetime = None):
|
|
569
|
-
"""
|
|
570
|
-
Schedules the defined command to execute every sunday at a specific time.
|
|
571
|
-
"""
|
|
572
|
-
|
|
573
|
-
self._checkCommand()
|
|
574
|
-
self._checkDateTime(start_date, end_date)
|
|
575
|
-
hour, minute = self._hourFormat(at)
|
|
576
|
-
|
|
577
|
-
self.scheduler.add_job(
|
|
578
|
-
self.callback,
|
|
579
|
-
CronTrigger(day_of_week='sun', hour=hour, minute=minute, start_date=start_date, end_date=end_date),
|
|
580
|
-
replace_existing=True
|
|
581
|
-
)
|
|
582
|
-
|
|
583
|
-
self._resetCallback()
|
|
584
|
-
|
|
585
|
-
def weekly(self, start_date: datetime = None, end_date: datetime = None):
|
|
586
|
-
"""
|
|
587
|
-
Schedules the defined command to execute weekly on Sunday at midnight.
|
|
588
|
-
"""
|
|
589
|
-
|
|
590
|
-
self._checkCommand()
|
|
591
|
-
self._checkDateTime(start_date, end_date)
|
|
592
|
-
|
|
593
|
-
self.scheduler.add_job(
|
|
594
|
-
self.callback,
|
|
595
|
-
CronTrigger(day_of_week='sun', hour=0, minute=0, second=1, start_date=start_date, end_date=end_date),
|
|
596
|
-
replace_existing=True
|
|
597
|
-
)
|
|
598
|
-
|
|
599
|
-
self._resetCallback()
|
|
600
|
-
|
|
601
|
-
def start(self):
|
|
602
|
-
"""
|
|
603
|
-
Starts the scheduler and stops automatically when there are no more jobs.
|
|
604
|
-
"""
|
|
605
|
-
try:
|
|
606
|
-
while self.wait:
|
|
607
|
-
time.sleep(1)
|
|
608
|
-
except (KeyboardInterrupt, SystemExit):
|
|
609
|
-
if self.scheduler.running:
|
|
610
|
-
self.scheduler.shutdown()
|
|
611
|
-
sys.exit(1)
|
|
File without changes
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import copy
|
|
2
|
-
from typing import Any, Optional
|
|
3
|
-
from orionis._contracts.application import IApplication
|
|
4
|
-
|
|
5
|
-
class ConfigService:
|
|
6
|
-
|
|
7
|
-
def __init__(self, app : IApplication) -> None:
|
|
8
|
-
"""
|
|
9
|
-
Initializes the ConfigService with the provided configuration.
|
|
10
|
-
|
|
11
|
-
Args:
|
|
12
|
-
config (dict): A dictionary containing configuration settings.
|
|
13
|
-
"""
|
|
14
|
-
real_config : dict = app._config if hasattr(app, '_config') else {}
|
|
15
|
-
self._config = copy.deepcopy(real_config)
|
|
16
|
-
|
|
17
|
-
def set(self, key: str, value: Any) -> None:
|
|
18
|
-
"""
|
|
19
|
-
Dynamically sets a configuration value using dot notation.
|
|
20
|
-
|
|
21
|
-
Parameters
|
|
22
|
-
----------
|
|
23
|
-
key : str
|
|
24
|
-
The configuration key (e.g., 'app.debug').
|
|
25
|
-
value : Any
|
|
26
|
-
The value to set.
|
|
27
|
-
"""
|
|
28
|
-
keys = key.split(".")
|
|
29
|
-
section = keys[0]
|
|
30
|
-
sub_keys = keys[1:]
|
|
31
|
-
|
|
32
|
-
if section not in self._config:
|
|
33
|
-
self._config[section] = {}
|
|
34
|
-
|
|
35
|
-
current = self._config[section]
|
|
36
|
-
for sub_key in sub_keys[:-1]:
|
|
37
|
-
if sub_key not in current:
|
|
38
|
-
current[sub_key] = {}
|
|
39
|
-
current = current[sub_key]
|
|
40
|
-
|
|
41
|
-
current[sub_keys[-1]] = value
|
|
42
|
-
|
|
43
|
-
def get(self, key: str, default: Optional[Any] = None) -> Any:
|
|
44
|
-
"""
|
|
45
|
-
Retrieves a configuration value using dot notation.
|
|
46
|
-
|
|
47
|
-
Parameters
|
|
48
|
-
----------
|
|
49
|
-
key : str
|
|
50
|
-
The configuration key (e.g., 'app.debug').
|
|
51
|
-
default : Optional[Any]
|
|
52
|
-
The default value to return if the key is not found.
|
|
53
|
-
|
|
54
|
-
Returns
|
|
55
|
-
-------
|
|
56
|
-
Any
|
|
57
|
-
The configuration value or the default value if the key is not found.
|
|
58
|
-
"""
|
|
59
|
-
keys = key.split(".")
|
|
60
|
-
section = keys[0]
|
|
61
|
-
sub_keys = keys[1:]
|
|
62
|
-
|
|
63
|
-
if section not in self._config:
|
|
64
|
-
return default
|
|
65
|
-
|
|
66
|
-
current = self._config[section]
|
|
67
|
-
for sub_key in sub_keys:
|
|
68
|
-
if sub_key not in current:
|
|
69
|
-
return default
|
|
70
|
-
current = current[sub_key]
|
|
71
|
-
|
|
72
|
-
return current
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|