Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
60ae71a4
Commit
60ae71a4
authored
10 years ago
by
Jan Rinze Peterzon
Browse files
Options
Downloads
Patches
Plain Diff
Task #7342: Add python message bus library
parent
cb4302f6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitattributes
+1
-0
1 addition, 0 deletions
.gitattributes
LCS/MessageBus/src/MsgBus.py
+81
-0
81 additions, 0 deletions
LCS/MessageBus/src/MsgBus.py
with
82 additions
and
0 deletions
.gitattributes
+
1
−
0
View file @
60ae71a4
...
...
@@ -2425,6 +2425,7 @@ LCS/MSLofar/test/tBeamTables.in_hd/DE601-iHBADeltas.conf -text
LCS/MSLofar/test/tBeamTables.in_hd/RS106-iHBADeltas.conf -text
LCS/MessageBus/src/LofarMsgTemplate.txt -text
LCS/MessageBus/src/Message.cc -text
LCS/MessageBus/src/MsgBus.py -text
LCS/MessageBus/test/tMessage.cc -text
LCS/MessageBus/test/tMsgBus.cc -text
LCS/Stream/include/Stream/SocketStream.tcc -text
...
...
This diff is collapsed.
Click to expand it.
LCS/MessageBus/src/MsgBus.py
0 → 100644
+
81
−
0
View file @
60ae71a4
#!/usr/bin/python
# Copyright (C) 2012-2013 ASTRON (Netherlands Institute for Radio Astronomy)
# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands
#
# This file is part of the LOFAR software suite.
# The LOFAR software suite is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# The LOFAR software suite is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>.
#
# id.. TDB
from
qpid.messaging
import
*
# Candidate for a config file
broker
=
"
localhost
"
options
=
"
create:always, node: { type: queue, durable: True}
"
class
ToBus
():
def
__init__
(
self
,
address
=
address
,
options
=
options
,
broker
=
broker
):
self
.
connection
=
Connection
(
broker
)
self
.
connection
.
reconnect
=
True
try
:
self
.
connection
.
open
()
self
.
session
=
self
.
connection
.
session
()
self
.
sender
=
self
.
session
.
sender
(
address
)
except
MessagingError
,
m
:
print
"
OMG!!
"
print
m
def
sendstr
(
self
,
Str
):
msg
=
Message
(
Str
)
msg
.
durable
=
True
if
(
reply_to
!=
""
):
msg
.
reply_to
=
reply_to
self
.
sender
.
send
(
msg
)
class
FromBus
():
def
__init__
(
self
,
address
,
options
=
options
,
broker
=
broker
):
self
.
connection
=
Connection
(
broker
)
self
.
connection
.
reconnect
=
True
try
:
self
.
connection
.
open
()
self
.
session
=
self
.
connection
.
session
()
receiver
=
self
.
session
.
receiver
(
"
%s;{%s}
"
%
(
address
,
options
))
receiver
.
capacity
=
1
#32
except
MessagingError
,
m
:
print
"
OMG!!
"
print
m
def
add
(
self
,
address
,
options
=
options
):
try
:
receiver
=
self
.
session
.
receiver
(
"
%s;{%s}
"
%
(
address
,
options
))
receiver
.
capacity
=
1
#32
except
MessagingError
,
m
:
print
"
Error adding receiver
"
print
m
def
getmsg
(
self
,
timeout
=
None
):
msg
=
None
try
:
receiver
=
self
.
session
.
next_receiver
(
timeout
)
if
(
receiver
!=
None
)
msg
=
self
.
receiver
.
get
()
except
exceptions
.
Empty
,
e
:
return
"
None
"
,
"
None
"
return
msg
def
ack
(
self
,
msg
):
self
.
session
.
acknowledge
(
msg
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment