Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
f-interop-contributors
utils
Commits
4026ee7c
Commit
4026ee7c
authored
Oct 24, 2017
by
Federico Sismondi
Browse files
amqp_synch_calls should be py2 compliant
parent
b1370dc1
Changes
2
Show whitespace changes
Inline
Side-by-side
amqp_synch_call.py
View file @
4026ee7c
import
six
import
os
import
pika
import
time
import
logging
import
threading
from
binascii
import
unhexlify
from
datetime
import
datetime
from
messages
import
*
VERSION
=
'0.0.
4
'
VERSION
=
'0.0.
5
'
AMQP_EXCHANGE
=
'amq.topic'
def
publish_message
(
connection
,
message
):
""" Published which uses message object metadata
...
...
@@ -27,7 +21,7 @@ def publish_message(connection, message):
properties
=
pika
.
BasicProperties
(
**
message
.
get_properties
())
channel
.
basic_publish
(
exchange
=
AMQP_EXCHANGE
,
exchange
=
AMQP_EXCHANGE
,
routing_key
=
message
.
routing_key
,
properties
=
properties
,
body
=
message
.
to_json
(),
...
...
@@ -38,7 +32,7 @@ def publish_message(connection, message):
channel
.
close
()
def
amqp_request
(
connection
,
request_message
:
Message
,
component_id
:
str
):
def
amqp_request
(
connection
,
request_message
,
component_id
):
# NOTE: channel must be a pika channel
# check first that sender didnt forget about reply to and corr id
...
...
@@ -116,6 +110,7 @@ if __name__ == '__main__':
try
:
from
urllib.parse
import
urlparse
AMQP_URL
=
str
(
os
.
environ
[
'AMQP_URL'
])
p
=
urlparse
(
AMQP_URL
)
AMQP_USER
=
p
.
username
...
...
messages.py
View file @
4026ee7c
...
...
@@ -117,7 +117,7 @@ class Message:
self
.
_msg_data
.
update
(
kwargs
)
# add API's version
if
not
"_api_version"
in
self
.
_msg_data
:
if
"_api_version"
not
in
self
.
_msg_data
:
self
.
_msg_data
[
"_api_version"
]
=
API_VERSION
# add values as objects attributes
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment