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/__init__.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
|
#
|
|
@@ -19,16 +19,7 @@
|
|
|
19
19
|
# You should have received a copy of the Apache License along with
|
|
20
20
|
# Hive Appier Framework. If not, see <http://www.apache.org/licenses/>.
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
""" The version of the module """
|
|
24
|
-
|
|
25
|
-
__revision__ = "$LastChangedRevision$"
|
|
26
|
-
""" The revision number of the module """
|
|
27
|
-
|
|
28
|
-
__date__ = "$LastChangedDate$"
|
|
29
|
-
""" The last change date of the module """
|
|
30
|
-
|
|
31
|
-
__copyright__ = "Copyright (c) 2008-2022 Hive Solutions Lda."
|
|
22
|
+
__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda."
|
|
32
23
|
""" The copyright for the module """
|
|
33
24
|
|
|
34
25
|
__license__ = "Apache License, Version 2.0"
|
|
@@ -80,14 +71,75 @@ from . import validation
|
|
|
80
71
|
|
|
81
72
|
from .amqp import AMQP
|
|
82
73
|
from .api import API, OAuthAPI, OAuth1API, OAuth2API
|
|
83
|
-
from .asynchronous import
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
74
|
+
from .asynchronous import (
|
|
75
|
+
ASYNC_HEADER,
|
|
76
|
+
AsyncManager,
|
|
77
|
+
SimpleManager,
|
|
78
|
+
QueueManager,
|
|
79
|
+
AwaitWrapper,
|
|
80
|
+
CoroutineWrapper,
|
|
81
|
+
AyncgenWrapper,
|
|
82
|
+
await_wrap,
|
|
83
|
+
await_yield,
|
|
84
|
+
ensure_generator,
|
|
85
|
+
is_coroutine,
|
|
86
|
+
is_coroutine_object,
|
|
87
|
+
is_coroutine_native,
|
|
88
|
+
to_coroutine,
|
|
89
|
+
wrap_silent,
|
|
90
|
+
unavailable,
|
|
91
|
+
is_neo,
|
|
92
|
+
Future,
|
|
93
|
+
coroutine,
|
|
94
|
+
wakeup,
|
|
95
|
+
sleep,
|
|
96
|
+
wait,
|
|
97
|
+
notify,
|
|
98
|
+
build_future,
|
|
99
|
+
ensure_async,
|
|
100
|
+
header_a,
|
|
101
|
+
ensure_a,
|
|
102
|
+
)
|
|
103
|
+
from .base import (
|
|
104
|
+
APP,
|
|
105
|
+
LEVEL,
|
|
106
|
+
NAME,
|
|
107
|
+
VERSION,
|
|
108
|
+
PLATFORM,
|
|
109
|
+
IDENTIFIER_SHORT,
|
|
110
|
+
IDENTIFIER_LONG,
|
|
111
|
+
IDENTIFIER,
|
|
112
|
+
API_VERSION,
|
|
113
|
+
BUFFER_SIZE,
|
|
114
|
+
MAX_LOG_SIZE,
|
|
115
|
+
MAX_LOG_COUNT,
|
|
116
|
+
App,
|
|
117
|
+
APIApp,
|
|
118
|
+
WebApp,
|
|
119
|
+
Template,
|
|
120
|
+
get_app,
|
|
121
|
+
get_name,
|
|
122
|
+
get_base_path,
|
|
123
|
+
get_cache,
|
|
124
|
+
get_preferences,
|
|
125
|
+
get_bus,
|
|
126
|
+
get_request,
|
|
127
|
+
get_session,
|
|
128
|
+
get_model,
|
|
129
|
+
get_controller,
|
|
130
|
+
get_part,
|
|
131
|
+
get_adapter,
|
|
132
|
+
get_manager,
|
|
133
|
+
get_logger,
|
|
134
|
+
get_level,
|
|
135
|
+
is_loaded,
|
|
136
|
+
is_devel,
|
|
137
|
+
is_safe,
|
|
138
|
+
to_locale,
|
|
139
|
+
on_exit,
|
|
140
|
+
build_asgi,
|
|
141
|
+
build_asgi_i,
|
|
142
|
+
)
|
|
91
143
|
from .bus import Bus, MemoryBus, RedisBus
|
|
92
144
|
from .cache import Cache, MemoryCache, FileCache, RedisCache, SerializedCache
|
|
93
145
|
from .component import Component
|
|
@@ -95,56 +147,285 @@ from .compress import Compress
|
|
|
95
147
|
from .config import conf, conf_prefix, conf_suffix, conf_s, conf_r, conf_d, conf_ctx
|
|
96
148
|
from .controller import Controller
|
|
97
149
|
from .crypt import Cipher, RC4, Spritz
|
|
98
|
-
from .data import
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
150
|
+
from .data import (
|
|
151
|
+
DataAdapter,
|
|
152
|
+
MongoAdapter,
|
|
153
|
+
TinyAdapter,
|
|
154
|
+
Collection,
|
|
155
|
+
MongoCollection,
|
|
156
|
+
TinyCollection,
|
|
157
|
+
)
|
|
158
|
+
from .defines import (
|
|
159
|
+
ITERABLES,
|
|
160
|
+
MOBILE_REGEX,
|
|
161
|
+
TABLET_REGEX,
|
|
162
|
+
MOBILE_PREFIX_REGEX,
|
|
163
|
+
BODY_REGEX,
|
|
164
|
+
TAG_REGEX,
|
|
165
|
+
EMAIL_REGEX,
|
|
166
|
+
BROWSER_INFO,
|
|
167
|
+
OS_INFO,
|
|
168
|
+
WINDOWS_LOCALE,
|
|
169
|
+
SLUG_PERMUTATIONS,
|
|
170
|
+
)
|
|
171
|
+
from .exceptions import (
|
|
172
|
+
AppierException,
|
|
173
|
+
OperationalError,
|
|
174
|
+
SecurityError,
|
|
175
|
+
AssertionError,
|
|
176
|
+
ValidationError,
|
|
177
|
+
NotFoundError,
|
|
178
|
+
NotImplementedError,
|
|
179
|
+
BaseInternalError,
|
|
180
|
+
ValidationInternalError,
|
|
181
|
+
ValidationMultipleError,
|
|
182
|
+
HTTPError,
|
|
183
|
+
APIError,
|
|
184
|
+
APIAccessError,
|
|
185
|
+
OAuthAccessError,
|
|
186
|
+
)
|
|
187
|
+
from .execution import (
|
|
188
|
+
ExecutionThread,
|
|
189
|
+
background,
|
|
190
|
+
insert_work,
|
|
191
|
+
interval_work,
|
|
192
|
+
seconds_work,
|
|
193
|
+
minutes_work,
|
|
194
|
+
hourly_work,
|
|
195
|
+
daily_work,
|
|
196
|
+
weekly_work,
|
|
197
|
+
monthly_work,
|
|
198
|
+
seconds_eval,
|
|
199
|
+
minutes_eval,
|
|
200
|
+
hourly_eval,
|
|
201
|
+
daily_eval,
|
|
202
|
+
weekly_eval,
|
|
203
|
+
monthly_eval,
|
|
204
|
+
)
|
|
107
205
|
from .export import ExportManager
|
|
108
|
-
from .extra import
|
|
206
|
+
from .extra import (
|
|
207
|
+
get_a,
|
|
208
|
+
post_a,
|
|
209
|
+
put_a,
|
|
210
|
+
delete_a,
|
|
211
|
+
patch_a,
|
|
212
|
+
get_w,
|
|
213
|
+
post_w,
|
|
214
|
+
put_w,
|
|
215
|
+
delete_w,
|
|
216
|
+
patch_w,
|
|
217
|
+
)
|
|
109
218
|
from .geo import GeoResolver
|
|
110
219
|
from .git import Git
|
|
111
220
|
from .graph import Graph
|
|
112
221
|
from .http import file_g, get_f, get, post, put, delete, patch, basic_auth, HTTPResponse
|
|
113
|
-
from .log import
|
|
114
|
-
|
|
222
|
+
from .log import (
|
|
223
|
+
MemoryHandler,
|
|
224
|
+
BaseFormatter,
|
|
225
|
+
ThreadFormatter,
|
|
226
|
+
DummyLogger,
|
|
227
|
+
reload_format,
|
|
228
|
+
rotating_handler,
|
|
229
|
+
smtp_handler,
|
|
230
|
+
in_signature,
|
|
231
|
+
)
|
|
115
232
|
from .meta import Ordered, Indexed
|
|
116
233
|
from .mock import MockObject, MockResponse, MockApp
|
|
117
|
-
from .model import
|
|
118
|
-
|
|
119
|
-
|
|
234
|
+
from .model import (
|
|
235
|
+
Model,
|
|
236
|
+
LocalModel,
|
|
237
|
+
Field,
|
|
238
|
+
link,
|
|
239
|
+
operation,
|
|
240
|
+
view,
|
|
241
|
+
field,
|
|
242
|
+
type_d,
|
|
243
|
+
is_unset,
|
|
244
|
+
)
|
|
245
|
+
from .mongo import (
|
|
246
|
+
Mongo,
|
|
247
|
+
MongoAsync,
|
|
248
|
+
MongoEncoder,
|
|
249
|
+
get_connection,
|
|
250
|
+
get_connection_a,
|
|
251
|
+
reset_connection,
|
|
252
|
+
reset_connection_a,
|
|
253
|
+
get_db,
|
|
254
|
+
get_db_a,
|
|
255
|
+
drop_db,
|
|
256
|
+
drop_db_a,
|
|
257
|
+
object_id,
|
|
258
|
+
dumps,
|
|
259
|
+
)
|
|
120
260
|
from .observer import Observable
|
|
121
261
|
from .part import Part
|
|
122
|
-
from .preferences import
|
|
262
|
+
from .preferences import (
|
|
263
|
+
Preferences,
|
|
264
|
+
MemoryPreferences,
|
|
265
|
+
FilePreferences,
|
|
266
|
+
RedisPreferences,
|
|
267
|
+
)
|
|
123
268
|
from .queuing import Queue, MemoryQueue, MultiprocessQueue, AMQPQueue
|
|
124
269
|
from .redisdb import Redis
|
|
125
270
|
from .request import CODE_STRINGS, Request, MockRequest
|
|
126
271
|
from .scheduler import Scheduler
|
|
127
272
|
from .serialize import serialize_csv, serialize_ics, build_encoder
|
|
128
|
-
from .session import
|
|
273
|
+
from .session import (
|
|
274
|
+
Session,
|
|
275
|
+
MockSession,
|
|
276
|
+
MemorySession,
|
|
277
|
+
FileSession,
|
|
278
|
+
RedisSession,
|
|
279
|
+
ClientSession,
|
|
280
|
+
)
|
|
129
281
|
from .settings import DEBUG, USERNAME, PASSWORD
|
|
130
|
-
from .smtp import
|
|
131
|
-
|
|
282
|
+
from .smtp import (
|
|
283
|
+
message,
|
|
284
|
+
message_base,
|
|
285
|
+
message_netius,
|
|
286
|
+
smtp_engine,
|
|
287
|
+
multipart,
|
|
288
|
+
plain,
|
|
289
|
+
html,
|
|
290
|
+
application,
|
|
291
|
+
header,
|
|
292
|
+
)
|
|
132
293
|
from .storage import StorageEngine, BaseEngine, FsEngine
|
|
133
294
|
from .structures import OrderedDict, LazyDict, LazyValue, GeneratorFile, lazy_dict, lazy
|
|
134
|
-
from .typesf import
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
295
|
+
from .typesf import (
|
|
296
|
+
AbstractType,
|
|
297
|
+
Type,
|
|
298
|
+
File,
|
|
299
|
+
Files,
|
|
300
|
+
ImageFile,
|
|
301
|
+
ImageFiles,
|
|
302
|
+
image,
|
|
303
|
+
images,
|
|
304
|
+
Reference,
|
|
305
|
+
reference,
|
|
306
|
+
References,
|
|
307
|
+
references,
|
|
308
|
+
Encrypted,
|
|
309
|
+
encrypted,
|
|
310
|
+
secure,
|
|
311
|
+
)
|
|
312
|
+
from .util import (
|
|
313
|
+
to_limit,
|
|
314
|
+
to_find,
|
|
315
|
+
to_sort,
|
|
316
|
+
is_iterable,
|
|
317
|
+
is_mobile,
|
|
318
|
+
is_tablet,
|
|
319
|
+
is_browser,
|
|
320
|
+
is_bot,
|
|
321
|
+
browser_info,
|
|
322
|
+
email_parts,
|
|
323
|
+
email_mime,
|
|
324
|
+
email_name,
|
|
325
|
+
email_base,
|
|
326
|
+
date_to_timestamp,
|
|
327
|
+
obfuscate,
|
|
328
|
+
import_pip,
|
|
329
|
+
ensure_pip,
|
|
330
|
+
install_pip,
|
|
331
|
+
install_pip_s,
|
|
332
|
+
request_json,
|
|
333
|
+
get_context,
|
|
334
|
+
get_object,
|
|
335
|
+
resolve_alias,
|
|
336
|
+
page_types,
|
|
337
|
+
find_types,
|
|
338
|
+
norm_object,
|
|
339
|
+
set_object,
|
|
340
|
+
leafs,
|
|
341
|
+
gather_errors,
|
|
342
|
+
gen_token,
|
|
343
|
+
html_to_text,
|
|
344
|
+
camel_to_underscore,
|
|
345
|
+
camel_to_readable,
|
|
346
|
+
underscore_to_camel,
|
|
347
|
+
underscore_to_readable,
|
|
348
|
+
quote,
|
|
349
|
+
unquote,
|
|
350
|
+
escape,
|
|
351
|
+
unescape,
|
|
352
|
+
count_unescape,
|
|
353
|
+
split_unescape,
|
|
354
|
+
call_safe,
|
|
355
|
+
base_name,
|
|
356
|
+
base_name_m,
|
|
357
|
+
is_content_type,
|
|
358
|
+
parse_content_type,
|
|
359
|
+
parse_cookie,
|
|
360
|
+
parse_multipart,
|
|
361
|
+
decode_params,
|
|
362
|
+
load_form,
|
|
363
|
+
check_login,
|
|
364
|
+
check_user,
|
|
365
|
+
check_token,
|
|
366
|
+
check_tokens,
|
|
367
|
+
ensure_login,
|
|
368
|
+
get_tokens_m,
|
|
369
|
+
to_tokens_m,
|
|
370
|
+
dict_merge,
|
|
371
|
+
deprecated,
|
|
372
|
+
cached,
|
|
373
|
+
private,
|
|
374
|
+
ensure,
|
|
375
|
+
delayed,
|
|
376
|
+
route,
|
|
377
|
+
error_handler,
|
|
378
|
+
exception_handler,
|
|
379
|
+
before_request,
|
|
380
|
+
after_request,
|
|
381
|
+
is_detached,
|
|
382
|
+
sanitize,
|
|
383
|
+
verify,
|
|
384
|
+
verify_equal,
|
|
385
|
+
verify_not_equal,
|
|
386
|
+
verify_type,
|
|
387
|
+
verify_many,
|
|
388
|
+
execute,
|
|
389
|
+
ctx_locale,
|
|
390
|
+
ctx_request,
|
|
391
|
+
FileTuple,
|
|
392
|
+
BaseThread,
|
|
393
|
+
JSONEncoder,
|
|
394
|
+
)
|
|
395
|
+
from .validation import (
|
|
396
|
+
validate,
|
|
397
|
+
validate_b,
|
|
398
|
+
validate_e,
|
|
399
|
+
safe,
|
|
400
|
+
eq,
|
|
401
|
+
gt,
|
|
402
|
+
gte,
|
|
403
|
+
lt,
|
|
404
|
+
lte,
|
|
405
|
+
not_null,
|
|
406
|
+
not_empty,
|
|
407
|
+
not_false,
|
|
408
|
+
is_in,
|
|
409
|
+
is_upper,
|
|
410
|
+
is_lower,
|
|
411
|
+
is_simple,
|
|
412
|
+
is_email,
|
|
413
|
+
is_url,
|
|
414
|
+
is_regex,
|
|
415
|
+
field_eq,
|
|
416
|
+
field_gt,
|
|
417
|
+
field_gte,
|
|
418
|
+
field_lt,
|
|
419
|
+
field_lte,
|
|
420
|
+
string_gt,
|
|
421
|
+
string_lt,
|
|
422
|
+
string_eq,
|
|
423
|
+
equals,
|
|
424
|
+
not_past,
|
|
425
|
+
not_duplicate,
|
|
426
|
+
all_different,
|
|
427
|
+
no_self,
|
|
428
|
+
)
|
|
148
429
|
|
|
149
430
|
from .amqp import get_connection as get_amqp
|
|
150
431
|
from .amqp import properties as properties_amqp
|
appier/amqp.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"
|
|
@@ -42,8 +33,10 @@ from . import config
|
|
|
42
33
|
from . import legacy
|
|
43
34
|
from . import exceptions
|
|
44
35
|
|
|
45
|
-
try:
|
|
46
|
-
|
|
36
|
+
try:
|
|
37
|
+
import pika
|
|
38
|
+
except ImportError:
|
|
39
|
+
pika = None
|
|
47
40
|
|
|
48
41
|
URL = "amqp://guest:guest@localhost"
|
|
49
42
|
""" The default URL to be used for the connection when
|
|
@@ -58,14 +51,15 @@ connection = None
|
|
|
58
51
|
""" The global wide connection to the AMQP server
|
|
59
52
|
that is meant to be used across sessions """
|
|
60
53
|
|
|
61
|
-
class AMQP(object):
|
|
62
54
|
|
|
63
|
-
|
|
55
|
+
class AMQP(object):
|
|
56
|
+
def __init__(self, url=None):
|
|
64
57
|
self.url = url
|
|
65
58
|
self._connection = None
|
|
66
59
|
|
|
67
|
-
def get_connection(self, url
|
|
68
|
-
if self._connection:
|
|
60
|
+
def get_connection(self, url=None, timeout=TIMEOUT):
|
|
61
|
+
if self._connection:
|
|
62
|
+
return self._connection
|
|
69
63
|
url_c = config.conf("AMQP_URL", None)
|
|
70
64
|
url_c = config.conf("CLOUDAMQP_URL", url_c)
|
|
71
65
|
url_c = config.conf("RABBITMQ_URL", url_c)
|
|
@@ -74,34 +68,37 @@ class AMQP(object):
|
|
|
74
68
|
username = "guest" if url_p.username == None else url_p.username
|
|
75
69
|
password = "guest" if url_p.password == None else url_p.password
|
|
76
70
|
parameters = _pika().ConnectionParameters(
|
|
77
|
-
host
|
|
78
|
-
virtual_host
|
|
79
|
-
credentials
|
|
71
|
+
host=url_p.hostname,
|
|
72
|
+
virtual_host=url_p.path or "/",
|
|
73
|
+
credentials=_pika().PlainCredentials(username, password),
|
|
80
74
|
)
|
|
81
75
|
parameters.socket_timeout = timeout
|
|
82
76
|
self._connection = _pika().BlockingConnection(parameters)
|
|
83
77
|
self._connection = _set_fixes(self._connection)
|
|
84
78
|
return self._connection
|
|
85
79
|
|
|
86
|
-
|
|
80
|
+
|
|
81
|
+
def get_connection(url=URL, timeout=TIMEOUT):
|
|
87
82
|
global connection
|
|
88
83
|
url = config.conf("AMQP_URL", url)
|
|
89
84
|
url = config.conf("CLOUDAMQP_URL", url)
|
|
90
85
|
url = config.conf("RABBITMQ_URL", url)
|
|
91
86
|
url_p = legacy.urlparse(url)
|
|
92
87
|
parameters = _pika().ConnectionParameters(
|
|
93
|
-
host
|
|
94
|
-
virtual_host
|
|
95
|
-
credentials
|
|
88
|
+
host=url_p.hostname,
|
|
89
|
+
virtual_host=url_p.path or "/",
|
|
90
|
+
credentials=_pika().PlainCredentials(url_p.username, url_p.password),
|
|
96
91
|
)
|
|
97
92
|
parameters.socket_timeout = timeout
|
|
98
93
|
connection = _pika().BlockingConnection(parameters)
|
|
99
94
|
connection = _set_fixes(connection)
|
|
100
95
|
return connection
|
|
101
96
|
|
|
97
|
+
|
|
102
98
|
def properties(*args, **kwargs):
|
|
103
99
|
return _pika().BasicProperties(*args, **kwargs)
|
|
104
100
|
|
|
101
|
+
|
|
105
102
|
def _set_fixes(connection):
|
|
106
103
|
def disconnect():
|
|
107
104
|
connection.socket.close()
|
|
@@ -110,10 +107,12 @@ def _set_fixes(connection):
|
|
|
110
107
|
connection.disconnect = disconnect
|
|
111
108
|
return connection
|
|
112
109
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
|
|
111
|
+
def _pika(verify=True):
|
|
112
|
+
if verify:
|
|
113
|
+
util.verify(
|
|
114
|
+
not pika == None,
|
|
115
|
+
message="Pika library not available",
|
|
116
|
+
exception=exceptions.OperationalError,
|
|
117
|
+
)
|
|
119
118
|
return pika
|