appier 1.34.2__tar.gz → 1.34.4__tar.gz

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.
Files changed (104) hide show
  1. {appier-1.34.2/src/appier.egg-info → appier-1.34.4}/PKG-INFO +1 -1
  2. {appier-1.34.2 → appier-1.34.4}/setup.py +1 -1
  3. {appier-1.34.2 → appier-1.34.4}/src/appier/base.py +9 -3
  4. {appier-1.34.2 → appier-1.34.4}/src/appier/base.pyi +7 -1
  5. {appier-1.34.2 → appier-1.34.4}/src/appier/scheduler.py +35 -7
  6. {appier-1.34.2 → appier-1.34.4}/src/appier/scheduler.pyi +19 -2
  7. {appier-1.34.2 → appier-1.34.4}/src/appier/test/scheduler.py +25 -0
  8. {appier-1.34.2 → appier-1.34.4/src/appier.egg-info}/PKG-INFO +1 -1
  9. {appier-1.34.2 → appier-1.34.4}/MANIFEST.in +0 -0
  10. {appier-1.34.2 → appier-1.34.4}/README.rst +0 -0
  11. {appier-1.34.2 → appier-1.34.4}/setup.cfg +0 -0
  12. {appier-1.34.2 → appier-1.34.4}/src/appier/__init__.py +0 -0
  13. {appier-1.34.2 → appier-1.34.4}/src/appier/amqp.py +0 -0
  14. {appier-1.34.2 → appier-1.34.4}/src/appier/api.py +0 -0
  15. {appier-1.34.2 → appier-1.34.4}/src/appier/asgi.py +0 -0
  16. {appier-1.34.2 → appier-1.34.4}/src/appier/async_neo.py +0 -0
  17. {appier-1.34.2 → appier-1.34.4}/src/appier/async_old.py +0 -0
  18. {appier-1.34.2 → appier-1.34.4}/src/appier/asynchronous.py +0 -0
  19. {appier-1.34.2 → appier-1.34.4}/src/appier/asynchronous.pyi +0 -0
  20. {appier-1.34.2 → appier-1.34.4}/src/appier/bus.py +0 -0
  21. {appier-1.34.2 → appier-1.34.4}/src/appier/bus.pyi +0 -0
  22. {appier-1.34.2 → appier-1.34.4}/src/appier/cache.py +0 -0
  23. {appier-1.34.2 → appier-1.34.4}/src/appier/cache.pyi +0 -0
  24. {appier-1.34.2 → appier-1.34.4}/src/appier/common.py +0 -0
  25. {appier-1.34.2 → appier-1.34.4}/src/appier/component.py +0 -0
  26. {appier-1.34.2 → appier-1.34.4}/src/appier/component.pyi +0 -0
  27. {appier-1.34.2 → appier-1.34.4}/src/appier/compress.py +0 -0
  28. {appier-1.34.2 → appier-1.34.4}/src/appier/config.py +0 -0
  29. {appier-1.34.2 → appier-1.34.4}/src/appier/controller.py +0 -0
  30. {appier-1.34.2 → appier-1.34.4}/src/appier/crypt.py +0 -0
  31. {appier-1.34.2 → appier-1.34.4}/src/appier/data.py +0 -0
  32. {appier-1.34.2 → appier-1.34.4}/src/appier/data.pyi +0 -0
  33. {appier-1.34.2 → appier-1.34.4}/src/appier/defines.py +0 -0
  34. {appier-1.34.2 → appier-1.34.4}/src/appier/exceptions.py +0 -0
  35. {appier-1.34.2 → appier-1.34.4}/src/appier/execution.py +0 -0
  36. {appier-1.34.2 → appier-1.34.4}/src/appier/export.py +0 -0
  37. {appier-1.34.2 → appier-1.34.4}/src/appier/extra.py +0 -0
  38. {appier-1.34.2 → appier-1.34.4}/src/appier/extra_neo.py +0 -0
  39. {appier-1.34.2 → appier-1.34.4}/src/appier/extra_old.py +0 -0
  40. {appier-1.34.2 → appier-1.34.4}/src/appier/geo.py +0 -0
  41. {appier-1.34.2 → appier-1.34.4}/src/appier/git.py +0 -0
  42. {appier-1.34.2 → appier-1.34.4}/src/appier/graph.py +0 -0
  43. {appier-1.34.2 → appier-1.34.4}/src/appier/http.py +0 -0
  44. {appier-1.34.2 → appier-1.34.4}/src/appier/legacy.py +0 -0
  45. {appier-1.34.2 → appier-1.34.4}/src/appier/log.py +0 -0
  46. {appier-1.34.2 → appier-1.34.4}/src/appier/meta.py +0 -0
  47. {appier-1.34.2 → appier-1.34.4}/src/appier/mock.py +0 -0
  48. {appier-1.34.2 → appier-1.34.4}/src/appier/model.py +0 -0
  49. {appier-1.34.2 → appier-1.34.4}/src/appier/model.pyi +0 -0
  50. {appier-1.34.2 → appier-1.34.4}/src/appier/model_a.py +0 -0
  51. {appier-1.34.2 → appier-1.34.4}/src/appier/mongo.py +0 -0
  52. {appier-1.34.2 → appier-1.34.4}/src/appier/observer.py +0 -0
  53. {appier-1.34.2 → appier-1.34.4}/src/appier/part.py +0 -0
  54. {appier-1.34.2 → appier-1.34.4}/src/appier/part.pyi +0 -0
  55. {appier-1.34.2 → appier-1.34.4}/src/appier/preferences.py +0 -0
  56. {appier-1.34.2 → appier-1.34.4}/src/appier/preferences.pyi +0 -0
  57. {appier-1.34.2 → appier-1.34.4}/src/appier/queuing.py +0 -0
  58. {appier-1.34.2 → appier-1.34.4}/src/appier/redisdb.py +0 -0
  59. {appier-1.34.2 → appier-1.34.4}/src/appier/request.py +0 -0
  60. {appier-1.34.2 → appier-1.34.4}/src/appier/res/static/css/base.css +0 -0
  61. {appier-1.34.2 → appier-1.34.4}/src/appier/res/static/images/favicon.ico +0 -0
  62. {appier-1.34.2 → appier-1.34.4}/src/appier/res/static/js/base.js +0 -0
  63. {appier-1.34.2 → appier-1.34.4}/src/appier/res/templates/error.html.tpl +0 -0
  64. {appier-1.34.2 → appier-1.34.4}/src/appier/res/templates/holder.html.tpl +0 -0
  65. {appier-1.34.2 → appier-1.34.4}/src/appier/res/templates/layout.html.tpl +0 -0
  66. {appier-1.34.2 → appier-1.34.4}/src/appier/serialize.py +0 -0
  67. {appier-1.34.2 → appier-1.34.4}/src/appier/session.py +0 -0
  68. {appier-1.34.2 → appier-1.34.4}/src/appier/session.pyi +0 -0
  69. {appier-1.34.2 → appier-1.34.4}/src/appier/settings.py +0 -0
  70. {appier-1.34.2 → appier-1.34.4}/src/appier/smtp.py +0 -0
  71. {appier-1.34.2 → appier-1.34.4}/src/appier/storage.py +0 -0
  72. {appier-1.34.2 → appier-1.34.4}/src/appier/structures.py +0 -0
  73. {appier-1.34.2 → appier-1.34.4}/src/appier/test/__init__.py +0 -0
  74. {appier-1.34.2 → appier-1.34.4}/src/appier/test/base.py +0 -0
  75. {appier-1.34.2 → appier-1.34.4}/src/appier/test/cache.py +0 -0
  76. {appier-1.34.2 → appier-1.34.4}/src/appier/test/config.py +0 -0
  77. {appier-1.34.2 → appier-1.34.4}/src/appier/test/crypt.py +0 -0
  78. {appier-1.34.2 → appier-1.34.4}/src/appier/test/data.py +0 -0
  79. {appier-1.34.2 → appier-1.34.4}/src/appier/test/exceptions.py +0 -0
  80. {appier-1.34.2 → appier-1.34.4}/src/appier/test/export.py +0 -0
  81. {appier-1.34.2 → appier-1.34.4}/src/appier/test/graph.py +0 -0
  82. {appier-1.34.2 → appier-1.34.4}/src/appier/test/http.py +0 -0
  83. {appier-1.34.2 → appier-1.34.4}/src/appier/test/legacy.py +0 -0
  84. {appier-1.34.2 → appier-1.34.4}/src/appier/test/log.py +0 -0
  85. {appier-1.34.2 → appier-1.34.4}/src/appier/test/mock.py +0 -0
  86. {appier-1.34.2 → appier-1.34.4}/src/appier/test/model.py +0 -0
  87. {appier-1.34.2 → appier-1.34.4}/src/appier/test/part.py +0 -0
  88. {appier-1.34.2 → appier-1.34.4}/src/appier/test/preferences.py +0 -0
  89. {appier-1.34.2 → appier-1.34.4}/src/appier/test/queuing.py +0 -0
  90. {appier-1.34.2 → appier-1.34.4}/src/appier/test/request.py +0 -0
  91. {appier-1.34.2 → appier-1.34.4}/src/appier/test/serialize.py +0 -0
  92. {appier-1.34.2 → appier-1.34.4}/src/appier/test/session.py +0 -0
  93. {appier-1.34.2 → appier-1.34.4}/src/appier/test/smtp.py +0 -0
  94. {appier-1.34.2 → appier-1.34.4}/src/appier/test/structures.py +0 -0
  95. {appier-1.34.2 → appier-1.34.4}/src/appier/test/typesf.py +0 -0
  96. {appier-1.34.2 → appier-1.34.4}/src/appier/test/util.py +0 -0
  97. {appier-1.34.2 → appier-1.34.4}/src/appier/test/validation.py +0 -0
  98. {appier-1.34.2 → appier-1.34.4}/src/appier/typesf.py +0 -0
  99. {appier-1.34.2 → appier-1.34.4}/src/appier/util.py +0 -0
  100. {appier-1.34.2 → appier-1.34.4}/src/appier/validation.py +0 -0
  101. {appier-1.34.2 → appier-1.34.4}/src/appier.egg-info/SOURCES.txt +0 -0
  102. {appier-1.34.2 → appier-1.34.4}/src/appier.egg-info/dependency_links.txt +0 -0
  103. {appier-1.34.2 → appier-1.34.4}/src/appier.egg-info/not-zip-safe +0 -0
  104. {appier-1.34.2 → appier-1.34.4}/src/appier.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: appier
3
- Version: 1.34.2
3
+ Version: 1.34.4
4
4
  Summary: Appier Framework
5
5
  Home-page: http://appier.hive.pt
6
6
  Author: Hive Solutions Lda.
@@ -44,7 +44,7 @@ def read_file(path):
44
44
 
45
45
  setuptools.setup(
46
46
  name="appier",
47
- version="1.34.2",
47
+ version="1.34.4",
48
48
  author="Hive Solutions Lda.",
49
49
  author_email="development@hive.pt",
50
50
  description="Appier Framework",
@@ -94,7 +94,7 @@ NAME = "appier"
94
94
  """ The name to be used to describe the framework while working
95
95
  on its own environment, this is just a descriptive value """
96
96
 
97
- VERSION = "1.34.2"
97
+ VERSION = "1.34.4"
98
98
  """ The version of the framework that is currently installed
99
99
  this value may be used for debugging/diagnostic purposes """
100
100
 
@@ -780,6 +780,7 @@ class App(
780
780
  def info_dict(self):
781
781
  return dict(
782
782
  name=self.name,
783
+ version=self.version,
783
784
  instance=self.instance,
784
785
  service=self.service,
785
786
  type=self.type,
@@ -2328,7 +2329,7 @@ class App(
2328
2329
  thread.daemon = True
2329
2330
  thread.start()
2330
2331
 
2331
- def cron(self, job, cron):
2332
+ def cron(self, job, cron, id=None, description=None):
2332
2333
  """
2333
2334
  Schedule the provided method for regular execution using
2334
2335
  the provided Cron like string.
@@ -2342,6 +2343,11 @@ class App(
2342
2343
  :type cron: String/SchedulerDate
2343
2344
  :param cron: The cron like string that is going to be used to
2344
2345
  define the execution time of the provided method.
2346
+ :type id: String
2347
+ :param id: The unique identifier for the task to be created.
2348
+ :type description: String
2349
+ :param description: The description for the task to be created
2350
+ that describes the goal of the task.
2345
2351
  :rtype: SchedulerTask
2346
2352
  :return: The task that has been scheduled for execution at the
2347
2353
  provided time.
@@ -2350,7 +2356,7 @@ class App(
2350
2356
  if self._cron == None:
2351
2357
  self._cron = scheduler.CronScheduler(self)
2352
2358
  self._cron.start()
2353
- return self._cron.schedule(job, cron)
2359
+ return self._cron.schedule(job, cron, id=id, description=description)
2354
2360
 
2355
2361
  def chunks(self, data, size=32768):
2356
2362
  for index in range(0, len(data), size):
@@ -58,7 +58,13 @@ class App:
58
58
  asynchronous: bool = ...,
59
59
  **kwargs
60
60
  ) -> str: ...
61
- def cron(self, job: JobFunction, cron: Cron) -> SchedulerTask: ...
61
+ def cron(
62
+ self,
63
+ job: JobFunction,
64
+ cron: Cron,
65
+ id: str | None = ...,
66
+ description: str | None = ...,
67
+ ) -> SchedulerTask: ...
62
68
  def is_loaded(self) -> bool: ...
63
69
  def is_parent(self) -> bool: ...
64
70
  def is_child(self) -> bool: ...
@@ -29,6 +29,7 @@ __license__ = "Apache License, Version 2.0"
29
29
  """ The license for the module """
30
30
 
31
31
  import time
32
+ import uuid
32
33
  import heapq
33
34
  import datetime
34
35
  import logging
@@ -143,7 +144,7 @@ class CronScheduler(Scheduler):
143
144
 
144
145
  self.timeout = max(0, timestamp - current_ts())
145
146
 
146
- def schedule(self, job, cron, now=None):
147
+ def schedule(self, job, cron, id=None, description=None, now=None):
147
148
  """
148
149
  Schedules the provided job function for execution according
149
150
  to the provided cron string.
@@ -156,13 +157,18 @@ class CronScheduler(Scheduler):
156
157
  :param job: The function to be executed as the job.
157
158
  :type cron: String/SchedulerDate
158
159
  :param cron: The cron like string defining the schedule.
160
+ :type id: String
161
+ :param id: The unique identifier for the task to be created.
162
+ :type description: String
163
+ :param description: The description for the task to be created
164
+ that describes the goal of the task.
159
165
  :type now: datetime
160
166
  :param now: Optional time reference for the job scheduling.
161
167
  :rtype: SchedulerTask
162
168
  :return: The task object that was created for the job.
163
169
  """
164
170
 
165
- task = SchedulerTask(job, cron)
171
+ task = SchedulerTask(job, cron, id=id, description=description)
166
172
  heapq.heappush(self._tasks, (task.next_timestamp(now=now), task))
167
173
  self.awake()
168
174
  return task
@@ -181,16 +187,18 @@ class CronScheduler(Scheduler):
181
187
 
182
188
  class SchedulerTask(object):
183
189
 
184
- def __init__(self, job, cron):
190
+ def __init__(self, job, cron, id=None, description=None):
185
191
  self.job = job
186
192
  self.date = SchedulerDate.from_cron(cron)
193
+ self.id = str(uuid.uuid4()) if id == None else id
194
+ self.description = description
187
195
  self._enabled = True
188
196
 
189
197
  def __repr__(self):
190
- return "<SchedulerTask: %s, %s>" % (self.job, self.date)
198
+ return "<SchedulerTask: [%s] %s, %s>" % (self.id[:-12], self.job, self.date)
191
199
 
192
200
  def __str__(self):
193
- return "<SchedulerTask: %s, %s>" % (self.job, self.date)
201
+ return "<SchedulerTask: [%s] %s, %s>" % (self.id[:-12], self.job, self.date)
194
202
 
195
203
  def __eq__(self, other):
196
204
  if isinstance(other, self.__class__):
@@ -216,6 +224,10 @@ class SchedulerTask(object):
216
224
  def enabled(self):
217
225
  return self._enabled
218
226
 
227
+ @property
228
+ def cron(self):
229
+ return self.date.into_cron()
230
+
219
231
 
220
232
  class SchedulerDate(object):
221
233
 
@@ -229,10 +241,10 @@ class SchedulerDate(object):
229
241
  self.days_of_week = self._parse_field(days_of_week, 0, 6)
230
242
 
231
243
  def __repr__(self):
232
- return "<SchedulerDate: %s>" % self.next_run()
244
+ return "<SchedulerDate: %s, %s>" % (self.into_cron(), self.next_run())
233
245
 
234
246
  def __str__(self):
235
- return "<SchedulerDate: %s>" % self.next_run()
247
+ return "<SchedulerDate: %s, %s>" % (self.into_cron(), self.next_run())
236
248
 
237
249
  @classmethod
238
250
  def from_cron(cls, cron):
@@ -241,6 +253,17 @@ class SchedulerDate(object):
241
253
  values = (value.strip().split(",") for value in cron.split(" "))
242
254
  return cls(*values)
243
255
 
256
+ def into_cron(self):
257
+ return " ".join(
258
+ [
259
+ self._into_cron_field(self.minutes, 0, 59),
260
+ self._into_cron_field(self.hours, 0, 23),
261
+ self._into_cron_field(self.days_of_month, 1, 31),
262
+ self._into_cron_field(self.months, 1, 12),
263
+ self._into_cron_field(self.days_of_week, 0, 6),
264
+ ]
265
+ )
266
+
244
267
  def next_timestamp(self, now=None):
245
268
  date = self.next_run(now=now)
246
269
  return legacy.to_timestamp(date)
@@ -301,6 +324,11 @@ class SchedulerDate(object):
301
324
  else:
302
325
  return set((int(field),))
303
326
 
327
+ def _into_cron_field(self, field, min_value, max_value):
328
+ if field == set(range(min_value, max_value + 1)):
329
+ return "*"
330
+ return ",".join(str(v) for v in sorted(field))
331
+
304
332
 
305
333
  class Cron(object):
306
334
  pass
@@ -29,7 +29,12 @@ class CronScheduler(Scheduler):
29
29
  def __init__(self, owner: App | None, timeout: float = ..., daemon: bool = ...): ...
30
30
  def tick(self, now_ts: float | None = ...): ...
31
31
  def schedule(
32
- self, job: JobFunction, cron: Cron, now: datetime | None = ...
32
+ self,
33
+ job: JobFunction,
34
+ cron: Cron,
35
+ id: str | None = ...,
36
+ description: str | None = ...,
37
+ now: datetime | None = ...,
33
38
  ) -> SchedulerTask: ...
34
39
  def next_run(self) -> datetime | None: ...
35
40
  def next_timestamp(self) -> float | None: ...
@@ -38,13 +43,21 @@ class SchedulerTask(object):
38
43
  job: JobFunction
39
44
  date: SchedulerDate
40
45
 
41
- def __init__(self, job: JobFunction, cron: Cron): ...
46
+ def __init__(
47
+ self,
48
+ job: JobFunction,
49
+ cron: Cron,
50
+ id: str | None = ...,
51
+ description: str | None = ...,
52
+ ): ...
42
53
  def enable(self): ...
43
54
  def disable(self): ...
44
55
  def next_run(self, now: datetime | None = ...) -> datetime: ...
45
56
  def next_timestamp(self, now: datetime | None = ...) -> float: ...
46
57
  @property
47
58
  def enabled(self) -> bool: ...
59
+ @property
60
+ def cron(self) -> str: ...
48
61
 
49
62
  class SchedulerDate(object):
50
63
  minutes: set[int]
@@ -63,8 +76,12 @@ class SchedulerDate(object):
63
76
  ): ...
64
77
  @classmethod
65
78
  def from_cron(cls, cron: Cron) -> SchedulerDate: ...
79
+ def into_cron(self) -> str: ...
66
80
  def next_timestamp(self, now: datetime | None = None) -> float: ...
67
81
  def next_run(self, now: datetime | None = None) -> datetime: ...
68
82
  def _parse_field(
69
83
  self, field: CronField, min_value: int, max_value: int
70
84
  ) -> set[int]: ...
85
+ def _into_cron_field(
86
+ self, field: set[int], min_value: int, max_value: int
87
+ ) -> str: ...
@@ -164,6 +164,12 @@ class CronSchedulerTest(unittest.TestCase):
164
164
 
165
165
  class SchedulerDateTest(unittest.TestCase):
166
166
 
167
+ def test_repr(self):
168
+ date = appier.SchedulerDate.from_cron("11")
169
+ self.assertEqual(
170
+ repr(date), "<SchedulerDate: 11 * * * *, %s>" % str(date.next_run())
171
+ )
172
+
167
173
  def test_from_cron(self):
168
174
  date = appier.SchedulerDate.from_cron("11")
169
175
  self.assertEqual(date.minutes, set((11,)))
@@ -172,6 +178,25 @@ class SchedulerDateTest(unittest.TestCase):
172
178
  self.assertEqual(date.months, set(range(1, 13)))
173
179
  self.assertEqual(date.days_of_week, set(range(0, 7)))
174
180
 
181
+ def test_into_cron(self):
182
+ date = appier.SchedulerDate.from_cron("11")
183
+ self.assertEqual(date.into_cron(), "11 * * * *")
184
+
185
+ date = appier.SchedulerDate.from_cron("11 3")
186
+ self.assertEqual(date.into_cron(), "11 3 * * *")
187
+
188
+ date = appier.SchedulerDate.from_cron("11 3 10")
189
+ self.assertEqual(date.into_cron(), "11 3 10 * *")
190
+
191
+ date = appier.SchedulerDate.from_cron("11 3 10 5")
192
+ self.assertEqual(date.into_cron(), "11 3 10 5 *")
193
+
194
+ date = appier.SchedulerDate.from_cron("11 3 10 5 2")
195
+ self.assertEqual(date.into_cron(), "11 3 10 5 2")
196
+
197
+ date = appier.SchedulerDate.from_cron("* 3 10 5 2")
198
+ self.assertEqual(date.into_cron(), "* 3 10 5 2")
199
+
175
200
  def test_next_run(self):
176
201
  date = appier.SchedulerDate.from_cron("11")
177
202
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.1
2
2
  Name: appier
3
- Version: 1.34.2
3
+ Version: 1.34.4
4
4
  Summary: Appier Framework
5
5
  Home-page: http://appier.hive.pt
6
6
  Author: Hive Solutions Lda.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes