appier 1.31.4__py2.py3-none-any.whl → 1.32.0__py2.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.
- appier/__init__.py +333 -52
- appier/amqp.py +29 -30
- appier/api.py +214 -212
- appier/asgi.py +54 -55
- appier/async_neo.py +46 -35
- appier/async_old.py +55 -42
- appier/asynchronous.py +7 -13
- appier/base.py +1762 -1429
- appier/bus.py +51 -52
- appier/cache.py +99 -84
- appier/common.py +9 -11
- appier/component.py +17 -19
- appier/compress.py +25 -28
- appier/config.py +96 -73
- appier/controller.py +9 -15
- appier/crypt.py +25 -21
- appier/data.py +73 -57
- appier/defines.py +191 -226
- appier/exceptions.py +103 -63
- appier/execution.py +94 -88
- appier/export.py +90 -88
- appier/extra.py +6 -13
- appier/extra_neo.py +8 -11
- appier/extra_old.py +18 -16
- appier/geo.py +57 -47
- appier/git.py +101 -90
- appier/graph.py +23 -24
- appier/http.py +520 -398
- appier/legacy.py +373 -180
- appier/log.py +90 -97
- appier/meta.py +42 -42
- appier/mock.py +32 -34
- appier/model.py +793 -681
- appier/model_a.py +208 -183
- appier/mongo.py +183 -107
- appier/observer.py +39 -31
- appier/part.py +23 -24
- appier/preferences.py +44 -47
- appier/queuing.py +78 -96
- appier/redisdb.py +40 -35
- appier/request.py +227 -175
- appier/scheduler.py +13 -18
- appier/serialize.py +37 -31
- appier/session.py +161 -147
- appier/settings.py +2 -11
- appier/smtp.py +53 -49
- appier/storage.py +39 -33
- appier/structures.py +50 -45
- appier/test/__init__.py +2 -11
- appier/test/base.py +111 -108
- appier/test/cache.py +28 -35
- appier/test/config.py +10 -19
- appier/test/crypt.py +3 -12
- appier/test/data.py +3 -12
- appier/test/exceptions.py +8 -17
- appier/test/export.py +16 -33
- appier/test/graph.py +27 -60
- appier/test/http.py +42 -54
- appier/test/legacy.py +20 -30
- appier/test/log.py +14 -35
- appier/test/mock.py +27 -123
- appier/test/model.py +79 -91
- appier/test/part.py +5 -14
- appier/test/preferences.py +5 -13
- appier/test/queuing.py +29 -37
- appier/test/request.py +61 -73
- appier/test/serialize.py +12 -23
- appier/test/session.py +10 -19
- appier/test/smtp.py +8 -14
- appier/test/structures.py +20 -24
- appier/test/typesf.py +14 -28
- appier/test/util.py +480 -438
- appier/typesf.py +251 -171
- appier/util.py +578 -407
- appier/validation.py +280 -143
- {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/METADATA +6 -1
- appier-1.32.0.dist-info/RECORD +86 -0
- appier-1.31.4.dist-info/RECORD +0 -86
- {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/LICENSE +0 -0
- {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/WHEEL +0 -0
- {appier-1.31.4.dist-info → appier-1.32.0.dist-info}/top_level.txt +0 -0
appier/scheduler.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
4
|
# Hive Appier Framework
|
|
5
|
-
# Copyright (c) 2008-
|
|
5
|
+
# Copyright (c) 2008-2024 Hive Solutions Lda.
|
|
6
6
|
#
|
|
7
7
|
# This file is part of Hive Appier Framework.
|
|
8
8
|
#
|
|
@@ -22,16 +22,7 @@
|
|
|
22
22
|
__author__ = "João Magalhães <joamag@hive.pt>"
|
|
23
23
|
""" The author(s) of the module """
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
""" The version of the module """
|
|
27
|
-
|
|
28
|
-
__revision__ = "$LastChangedRevision$"
|
|
29
|
-
""" The revision number of the module """
|
|
30
|
-
|
|
31
|
-
__date__ = "$LastChangedDate$"
|
|
32
|
-
""" The last change date of the module """
|
|
33
|
-
|
|
34
|
-
__copyright__ = "Copyright (c) 2008-2022 Hive Solutions Lda."
|
|
25
|
+
__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda."
|
|
35
26
|
""" The copyright for the module """
|
|
36
27
|
|
|
37
28
|
__license__ = "Apache License, Version 2.0"
|
|
@@ -49,6 +40,7 @@ loop between ticks, this value should not be too small
|
|
|
49
40
|
to spend many resources or to high to create a long set
|
|
50
41
|
of time between external interactions """
|
|
51
42
|
|
|
43
|
+
|
|
52
44
|
class Scheduler(threading.Thread):
|
|
53
45
|
"""
|
|
54
46
|
Scheduler class that handles all the async tasks
|
|
@@ -58,11 +50,11 @@ class Scheduler(threading.Thread):
|
|
|
58
50
|
new task may be added to it through a queue system.
|
|
59
51
|
"""
|
|
60
52
|
|
|
61
|
-
def __init__(self, owner, timeout
|
|
62
|
-
threading.Thread.__init__(self, name
|
|
53
|
+
def __init__(self, owner, timeout=LOOP_TIMEOUT, daemon=True):
|
|
54
|
+
threading.Thread.__init__(self, name="Scheduler")
|
|
63
55
|
self.owner = owner
|
|
64
|
-
self.timeout = config.conf("SCHEDULER_TIMEOUT", timeout, cast
|
|
65
|
-
self.daemon = config.conf("SCHEDULER_DAEMON", daemon, cast
|
|
56
|
+
self.timeout = config.conf("SCHEDULER_TIMEOUT", timeout, cast=float)
|
|
57
|
+
self.daemon = config.conf("SCHEDULER_DAEMON", daemon, cast=bool)
|
|
66
58
|
self._condition = threading.Condition()
|
|
67
59
|
|
|
68
60
|
def run(self):
|
|
@@ -75,7 +67,8 @@ class Scheduler(threading.Thread):
|
|
|
75
67
|
self.logger.critical("Unhandled scheduler exception raised")
|
|
76
68
|
self.logger.error(exception)
|
|
77
69
|
lines = traceback.format_exc().splitlines()
|
|
78
|
-
for line in lines:
|
|
70
|
+
for line in lines:
|
|
71
|
+
self.logger.warning(line)
|
|
79
72
|
self._condition.acquire()
|
|
80
73
|
self._condition.wait(self.timeout)
|
|
81
74
|
self._condition.release()
|
|
@@ -96,5 +89,7 @@ class Scheduler(threading.Thread):
|
|
|
96
89
|
|
|
97
90
|
@property
|
|
98
91
|
def logger(self):
|
|
99
|
-
if self.owner:
|
|
100
|
-
|
|
92
|
+
if self.owner:
|
|
93
|
+
return self.owner.logger
|
|
94
|
+
else:
|
|
95
|
+
return logging.getLogger()
|
appier/serialize.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
4
|
# Hive Appier Framework
|
|
5
|
-
# Copyright (c) 2008-
|
|
5
|
+
# Copyright (c) 2008-2024 Hive Solutions Lda.
|
|
6
6
|
#
|
|
7
7
|
# This file is part of Hive Appier Framework.
|
|
8
8
|
#
|
|
@@ -22,16 +22,7 @@
|
|
|
22
22
|
__author__ = "João Magalhães <joamag@hive.pt>"
|
|
23
23
|
""" The author(s) of the module """
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
""" The version of the module """
|
|
27
|
-
|
|
28
|
-
__revision__ = "$LastChangedRevision$"
|
|
29
|
-
""" The revision number of the module """
|
|
30
|
-
|
|
31
|
-
__date__ = "$LastChangedDate$"
|
|
32
|
-
""" The last change date of the module """
|
|
33
|
-
|
|
34
|
-
__copyright__ = "Copyright (c) 2008-2022 Hive Solutions Lda."
|
|
25
|
+
__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda."
|
|
35
26
|
""" The copyright for the module """
|
|
36
27
|
|
|
37
28
|
__license__ = "Apache License, Version 2.0"
|
|
@@ -45,25 +36,34 @@ from . import legacy
|
|
|
45
36
|
from . import typesf
|
|
46
37
|
from . import exceptions
|
|
47
38
|
|
|
39
|
+
|
|
48
40
|
def serialize(obj):
|
|
49
|
-
if isinstance(obj, model.Model):
|
|
50
|
-
|
|
51
|
-
if
|
|
41
|
+
if isinstance(obj, model.Model):
|
|
42
|
+
return obj.model
|
|
43
|
+
if isinstance(obj, typesf.AbstractType):
|
|
44
|
+
return obj.json_v()
|
|
45
|
+
if type(obj) == type(None):
|
|
46
|
+
return ""
|
|
52
47
|
return legacy.UNICODE(obj)
|
|
53
48
|
|
|
54
|
-
|
|
49
|
+
|
|
50
|
+
def serialize_csv(
|
|
51
|
+
items, encoding="utf-8", errors="strict", delimiter=";", strict=False
|
|
52
|
+
):
|
|
55
53
|
# verifies if the strict mode is active and there're no items defined
|
|
56
54
|
# if that's the case an operational error is raised, otherwise an in
|
|
57
55
|
# case the items are not provided the default (empty string) is returned
|
|
58
|
-
if strict and not items:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
if strict and not items:
|
|
57
|
+
raise exceptions.OperationalError(
|
|
58
|
+
message="Empty items object provided, no keys available"
|
|
59
|
+
)
|
|
60
|
+
if not items:
|
|
61
|
+
return str()
|
|
62
62
|
|
|
63
63
|
# builds the encoder taking into account the provided encoding string
|
|
64
64
|
# value, this encoder will be used to encode each of the partial values
|
|
65
65
|
# that is going to be set in the target CSV buffer
|
|
66
|
-
encoder = build_encoder(encoding, errors
|
|
66
|
+
encoder = build_encoder(encoding, errors=errors)
|
|
67
67
|
|
|
68
68
|
# retrieves the first element and uses it to determine if the current
|
|
69
69
|
# sequence to be serialized is map or sequence based
|
|
@@ -76,18 +76,19 @@ def serialize_csv(items, encoding = "utf-8", errors = "strict", delimiter = ";",
|
|
|
76
76
|
# that in case the sequence is not map based the first element is ignored
|
|
77
77
|
keys = first.keys() if is_map else first
|
|
78
78
|
keys = legacy.eager(keys)
|
|
79
|
-
if is_map:
|
|
80
|
-
|
|
79
|
+
if is_map:
|
|
80
|
+
keys.sort()
|
|
81
|
+
else:
|
|
82
|
+
items = items[1:]
|
|
81
83
|
|
|
82
84
|
# constructs the first row (names/keys row) using the gathered sequence of keys
|
|
83
85
|
# and encoding them using the currently build encoder
|
|
84
|
-
keys_row = [encoder(key) if type(key) == legacy.UNICODE else
|
|
85
|
-
key for key in keys]
|
|
86
|
+
keys_row = [encoder(key) if type(key) == legacy.UNICODE else key for key in keys]
|
|
86
87
|
|
|
87
88
|
# creates the new string buffer and uses it as the basis for the construction of
|
|
88
89
|
# the CSV writer object, writing then the already build first row
|
|
89
90
|
buffer = legacy.StringIO()
|
|
90
|
-
writer = csv.writer(buffer, delimiter
|
|
91
|
+
writer = csv.writer(buffer, delimiter=delimiter)
|
|
91
92
|
writer.writerow(keys_row)
|
|
92
93
|
|
|
93
94
|
# iterates over the complete set of items to serialize each of it's attribute values
|
|
@@ -111,7 +112,8 @@ def serialize_csv(items, encoding = "utf-8", errors = "strict", delimiter = ";",
|
|
|
111
112
|
# them in case they are defined as unicode based values
|
|
112
113
|
for value in row:
|
|
113
114
|
is_unicode = isinstance(value, legacy.UNICODE)
|
|
114
|
-
if is_unicode:
|
|
115
|
+
if is_unicode:
|
|
116
|
+
value = encoder(value)
|
|
115
117
|
row_e.append(value)
|
|
116
118
|
|
|
117
119
|
# writes the encoded based row sequence to the writer in order to output the
|
|
@@ -123,8 +125,9 @@ def serialize_csv(items, encoding = "utf-8", errors = "strict", delimiter = ";",
|
|
|
123
125
|
result = buffer.getvalue()
|
|
124
126
|
return result
|
|
125
127
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
|
|
129
|
+
def serialize_ics(items, encoding="utf-8", errors="strict"):
|
|
130
|
+
encoder = build_encoder(encoding, errors=errors)
|
|
128
131
|
|
|
129
132
|
buffer = legacy.StringIO()
|
|
130
133
|
buffer.write("BEGIN:VCALENDAR\r\n")
|
|
@@ -165,6 +168,9 @@ def serialize_ics(items, encoding = "utf-8", errors = "strict"):
|
|
|
165
168
|
result = buffer.getvalue()
|
|
166
169
|
return result
|
|
167
170
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
+
|
|
172
|
+
def build_encoder(encoding, errors="strict"):
|
|
173
|
+
if legacy.PYTHON_3:
|
|
174
|
+
return lambda v: v
|
|
175
|
+
else:
|
|
176
|
+
return lambda v: v if v == None else v.encode(encoding, errors=errors)
|