Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
client-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sally4-core
client-python
Commits
de45a4ae
Commit
de45a4ae
authored
11 years ago
by
Constantin Jucovschi
Browse files
Options
Downloads
Patches
Plain Diff
adding sally client
parents
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
genfromxsd.sh
+2
-0
2 additions, 0 deletions
genfromxsd.sh
sallyclient.py
+79
-0
79 additions, 0 deletions
sallyclient.py
with
81 additions
and
0 deletions
genfromxsd.sh
0 → 100755
+
2
−
0
View file @
de45a4ae
generateDS.py
-o
commcore.py
--namespacedef
=
"xmlns=
\"
http://kwarc.info/sally/comm/core
\"
"
core.xsd
generateDS.py
-o
commlmh.py
--namespacedef
=
"xmlns=
\"
http://kwarc.info/sally/comm/lmh
\"
"
lmh.xsd
This diff is collapsed.
Click to expand it.
sallyclient.py
0 → 100644
+
79
−
0
View file @
de45a4ae
import
stomp
import
random
import
commcore
import
StringIO
class
SallyClient
:
def
__init__
(
self
,
host
,
port
,
user
,
password
,
envid
,
userid
,
interfaces
,
messageHandler
):
conn
=
stomp
.
Connection
(
host_and_ports
=
[(
host
,
port
)])
conn
.
set_listener
(
''
,
self
)
conn
.
start
()
conn
.
connect
(
login
=
user
,
passcode
=
password
)
self
.
queue
=
"
lmh_
"
+
str
(
random
.
randint
(
1
,
1000000
));
self
.
fullqueue
=
"
/queue/
"
+
self
.
queue
self
.
temp_queues
=
{};
self
.
conn
=
conn
;
self
.
messageHandler
=
messageHandler
conn
.
subscribe
(
destination
=
self
.
queue
,
id
=
0
,
ack
=
'
auto
'
)
regdoc
=
commcore
.
registerdocument
(
self
.
queue
,
interfaces
,
envid
,
userid
);
self
.
send
(
"
sally_register
"
,
regdoc
,
self
.
registered
)
def
messageOnDefaultQueue
(
self
,
headers
,
message
):
if
message
.
find
(
"
xmlns=
\"
http://kwarc.info/sally/comm/core
\"
"
)
>
0
:
print
"
core message: trying to parse
"
obj
=
commcore
.
parseString
(
message
)
if
type
(
obj
)
is
commcore
.
heartbeatrequest
:
self
.
respond
(
headers
,
commcore
.
heartbeatresponse
());
else
:
self
.
messageHandler
(
headers
,
message
)
pass
def
registered
(
self
,
headers
,
message
):
obj
=
commcore
.
parseString
(
message
);
if
type
(
obj
)
is
commcore
.
registerdocumentresponse
:
self
.
sallyqueue
=
obj
.
sallyqueue
print
"
registered
"
+
obj
.
sallyqueue
pass
def
respond
(
self
,
headers
,
commObj
):
self
.
send
(
headers
[
"
reply-to
"
],
commObj
,
headers
=
{
"
correlation-id
"
:
headers
[
"
correlation-id
"
]});
def
send
(
self
,
destination
,
commObj
,
callback
=
None
,
headers
=
{}):
output
=
StringIO
.
StringIO
()
commObj
.
export
(
output
,
0
);
msgToSend
=
output
.
getvalue
()
print
(
msgToSend
);
if
callback
!=
None
:
tmp_id
=
str
(
random
.
randint
(
1
,
1000000
));
temp_queue
=
"
/temp-queue/lmh_temp_
"
+
tmp_id
;
headers
[
"
reply-to
"
]
=
temp_queue
;
headers
[
"
correlation-id
"
]
=
tmp_id
;
self
.
temp_queues
[
temp_queue
]
=
callback
self
.
conn
.
subscribe
(
destination
=
temp_queue
,
id
=
0
,
ack
=
'
auto
'
)
self
.
conn
.
send
(
destination
,
msgToSend
,
headers
=
headers
)
def
on_error
(
self
,
headers
,
message
):
print
(
'
received an error %s
'
%
message
)
def
on_message
(
self
,
headers
,
message
):
print
"
on message =
"
,
message
if
headers
[
"
destination
"
]
==
self
.
fullqueue
:
self
.
messageOnDefaultQueue
(
headers
,
message
);
return
if
self
.
temp_queues
[
headers
[
"
destination
"
]]:
self
.
temp_queues
[
headers
[
"
destination
"
]](
headers
,
message
);
return
print
"
cannot sort message
"
+
message
pass
\ No newline at end of file
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