Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

stomper

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stomper - npm Package Compare versions

Comparing version
0.2.4
to
0.2.5
+14
-5
lib/stomper.egg-info/PKG-INFO

@@ -1,4 +0,4 @@

Metadata-Version: 1.0
Metadata-Version: 1.1
Name: stomper
Version: 0.2.4
Version: 0.2.5
Summary: This is a transport neutral client implementation of the STOMP protocol.

@@ -16,9 +16,11 @@ Home-page: http://code.google.com/p/stomper

:Author:
Oisin Mulvihill
Oisin Mulvihill
Contributors:
Micheal Twomey, Ricky Iacovou <iacovou at gmail dot com>,
Arfrever Frehtes Taifersar Arahesis <arfrever dot fta at gmail dot com>
Micheal Twomey, Ricky Iacovou <iacovou at gmail dot com>,
Arfrever Frehtes Taifersar Arahesis <arfrever dot fta at gmail dot com>
Niki Pore <niki pore at gmail dot com>
Introduction

@@ -83,2 +85,9 @@ ------------

0.2.5
~~~~~
Add the contributed fix for issue #14 by Niki Pore. The issue was reported by
Roger Hoover. This removes the extra line ending which can cause problems.
0.2.4

@@ -85,0 +94,0 @@ ~~~~~

"""
This is a python client implementation of the STOMP protocol.
This is a python client implementation of the STOMP protocol.
It aims to be transport layer neutral. This module provides functions to
It aims to be transport layer neutral. This module provides functions to
create and parse STOMP messages in a programatic fashion.
The examples package contains two examples using twisted as the transport
The examples package contains two examples using twisted as the transport
framework. Other frameworks can be used and I may add other examples as

@@ -16,3 +16,3 @@ time goes on.

I've looked at the stomp client by Jason R. Briggs and have based the message
generation on how his client does it. The client can be found at the follow
generation on how his client does it. The client can be found at the follow
address however it isn't a dependancy.

@@ -59,6 +59,6 @@

VALID_COMMANDS = [
'ABORT', 'ACK', 'BEGIN', 'COMMIT',
'ABORT', 'ACK', 'BEGIN', 'COMMIT',
'CONNECT', 'CONNECTED', 'DISCONNECT', 'MESSAGE',
'SEND', 'SUBSCRIBE', 'UNSUBSCRIBE',
'RECEIPT', 'ERROR',
'RECEIPT', 'ERROR',
]

@@ -69,4 +69,4 @@

return logging.getLogger("stomper")
class FrameError(Exception):

@@ -78,8 +78,8 @@ """Raise for problem with frame generation or parsing.

class Frame(object):
"""This class is used to create or read STOMP message frames.
"""This class is used to create or read STOMP message frames.
The method pack() is used to create a STOMP message ready
for transmission.
The method unpack() is used to read a STOMP message into
The method unpack() is used to read a STOMP message into
a frame instance. It uses the unpack_frame(...) function

@@ -89,20 +89,20 @@ to do the intial parsing.

The frame has three important member variables:
* cmd
* headers
* body
The 'cmd' is a property that represents the STOMP message
The 'cmd' is a property that represents the STOMP message
command. When you assign this a check is done to make sure
its one of the VALID_COMMANDS. If not then FrameError will
be raised.
The 'headers' is a dictionary which the user can added to
if needed. There are no restrictions or checks imposed on
The 'headers' is a dictionary which the user can added to
if needed. There are no restrictions or checks imposed on
what values are inserted.
The 'body' is just a member variable that the body text
is assigned to.
"""
The 'body' is just a member variable that the body text
is assigned to.
"""
def __init__(self):

@@ -113,7 +113,7 @@ """Setup the internal state."""

self.headers = {}
def getCmd(self):
"""Don't use _cmd directly!"""
return self._cmd
def setCmd(self, cmd):

@@ -128,28 +128,27 @@ """Check the cmd is valid, FrameError will be raised if its not."""

self._cmd = cmd
cmd = property(getCmd, setCmd)
def pack(self):
"""Called to create a STOMP message from the internal values.
"""
headers = ['%s:%s'%(f,v) for f,v in self.headers.items()]
headers = "\n".join(headers)
stomp_mesage = "%s\n%s\n\n%s%s\n" % (self._cmd, headers, self.body, NULL)
headers = ''.join(
['%s:%s\n' % (f, v) for f, v in self.headers.items()]
)
stomp_mesage = "%s\n%s\n%s%s\n" % (self._cmd, headers, self.body, NULL)
# import pprint
# print "stomp_mesage: ", pprint.pprint(stomp_mesage)
return stomp_mesage
def unpack(self, message):
"""Called to extract a STOMP message into this instance.
message:
This is a text string representing a valid
This is a text string representing a valid
STOMP (v1.0) message.
This method uses unpack_frame(...) to extract the
This method uses unpack_frame(...) to extract the
information, before it is assigned internally.

@@ -159,12 +158,12 @@

The result of the unpack_frame(...) call.
"""
if not message:
raise FrameError("Unpack error! The given message isn't valid '%s'!" % message)
msg = unpack_frame(message)
self.cmd = msg['cmd']
self.headers = msg['headers']
# Assign directly as the message will have the null

@@ -179,7 +178,7 @@ # character in the message already.

"""Called to unpack a STOMP message into a dictionary.
returned = {
# STOMP Command:
'cmd' : '...',
# Headers e.g.

@@ -192,11 +191,11 @@ 'headers' : {

}
# Body:
'body' : '...1234...\x00',
}
"""
body = []
returned = dict(cmd='', headers={}, body='')
breakdown = message.split('\n')

@@ -215,3 +214,3 @@

data = field[index+1:].strip()
# print "header '%s' data '%s'" % (header, data)
# print "header '%s' data '%s'" % (header, data)
returned['headers'][header.strip()] = data.strip()

@@ -241,6 +240,6 @@

# print "2. body: <%s>" % returned['body']
return returned
def abort(transactionid):

@@ -250,6 +249,6 @@ """STOMP abort transaction command.

Rollback whatever actions in this transaction.
transactionid:
This is the id that all actions in this transaction.
"""

@@ -261,3 +260,3 @@ return "ABORT\ntransaction: %s\n\n\x00\n" % transactionid

"""STOMP acknowledge command.
Acknowledge receipt of a specific message from the server.

@@ -268,8 +267,8 @@

what else could it be? ;)
transactionid:
This is the id that all actions in this transaction
This is the id that all actions in this transaction
will have. If this is not given then a random UUID
will be generated for this.
"""

@@ -280,6 +279,6 @@ header = 'message-id: %s' % messageid

header = 'message-id: %s\ntransaction: %s' % (messageid, transactionid)
return "ACK\n%s\n\n\x00\n" % header
def begin(transactionid=None):

@@ -289,8 +288,8 @@ """STOMP begin command.

Start a transaction...
transactionid:
This is the id that all actions in this transaction
This is the id that all actions in this transaction
will have. If this is not given then a random UUID
will be generated for this.
"""

@@ -303,3 +302,3 @@ if not transactionid:

def commit(transactionid):

@@ -310,6 +309,6 @@ """STOMP commit command.

permenant for this transactionid.
transactionid:
This is the id that all actions in this transaction.
"""

@@ -321,10 +320,10 @@ return "COMMIT\ntransaction: %s\n\n\x00\n" % transactionid

"""STOMP connect command.
username, password:
These are the needed auth details to connect to the
These are the needed auth details to connect to the
message server.
After sending this we will receive a CONNECTED
message which will contain our session id.
"""

@@ -336,38 +335,38 @@ return "CONNECT\nlogin:%s\npasscode:%s\n\n\x00\n" % (username, password)

"""STOMP disconnect command.
Tell the server we finished and we'll be closing the
socket soon.
"""
return "DISCONNECT\n\n\x00\n"
def send(dest, msg, transactionid=None):
"""STOMP send command.
dest:
This is the channel we wish to subscribe to
msg:
This is the message body to be sent.
transactionid:
This is an optional field and is not needed
by default.
"""
transheader = ''
if transactionid:
transheader = 'transaction: %s' % transactionid
return "SEND\ndestination: %s\n%s\n\n%s\x00\n" % (dest, transheader, msg)
def subscribe(dest, ack='auto'):
"""STOMP subscribe command.
dest:
This is the channel we wish to subscribe to
ack: 'auto' | 'client'

@@ -377,3 +376,3 @@ If the ack is set to client, then messages received will

will assume delivery failure.
"""

@@ -385,28 +384,28 @@ return "SUBSCRIBE\ndestination: %s\nack: %s\n\n\x00\n" % (dest, ack)

"""STOMP unsubscribe command.
dest:
This is the channel we wish to subscribe to
Tell the server we no longer wish to receive any
further messages for the given subscription.
"""
return "UNSUBSCRIBE\ndestination:%s\n\n\x00\n" % dest
class Engine(object):
"""This is a simple state machine to return a response to received
"""This is a simple state machine to return a response to received
message if needed.
"""
def __init__(self, testing=False):
self.testing = testing
self.log = logging.getLogger("stomper.Engine")
self.sessionId = ''
# Entry Format:
#
# COMMAND : Handler_Function
# COMMAND : Handler_Function
#

@@ -419,7 +418,7 @@ self.states = {

}
def react(self, msg):
"""Called to provide a response to a message if needed.
msg:

@@ -432,10 +431,10 @@ This is a dictionary as returned by unpack_frame(...)

A message to return or an empty string.
"""
returned = ""
# If its not a string assume its a dict.
# If its not a string assume its a dict.
mtype = type(msg)
if mtype in types.StringTypes:
msg = unpack_frame(msg)
msg = unpack_frame(msg)
elif mtype == types.DictType:

@@ -445,23 +444,23 @@ pass

raise FrameError("Unknown message type '%s', I don't know what to do with this!" % mtype)
if self.states.has_key(msg['cmd']):
# print("reacting to message - %s" % msg['cmd'])
returned = self.states[msg['cmd']](msg)
return returned
def connected(self, msg):
"""No reponse is needed to a connected frame.
This method stores the session id as a the
"""No reponse is needed to a connected frame.
This method stores the session id as a the
member sessionId for later use.
returned:
NO_RESPONSE_NEEDED
"""
self.sessionId = msg['headers']['session']
#print "connected: session id '%s'." % self.sessionId
return NO_RESPONSE_NEEDED

@@ -472,8 +471,8 @@

"""Called when a MESSAGE has been received.
Override this method to handle received messages.
This function will generate an acknowlege message
This function will generate an acknowlege message
for the given message and transaction (if present).
"""

@@ -485,5 +484,5 @@ message_id = msg['headers']['message-id']

transaction_id = msg['headers']['transaction-id']
# print "acknowledging message id <%s>." % message_id
return ack(message_id, transaction_id)

@@ -494,21 +493,21 @@

"""Called to handle an error message received from the server.
This method just logs the error message
returned:
NO_RESPONSE_NEEDED
"""
body = msg['body'].replace(NULL, '')
brief_msg = ""
if msg['headers'].has_key('message'):
brief_msg = msg['headers']['message']
self.log.error("Received server error - message%s\n\n%s" % (brief_msg, body))
returned = NO_RESPONSE_NEEDED
if self.testing:
returned = 'error'
return returned

@@ -519,22 +518,22 @@

"""Called to handle a receipt message received from the server.
This method just logs the receipt message
returned:
NO_RESPONSE_NEEDED
"""
body = msg['body'].replace(NULL, '')
brief_msg = ""
if msg['headers'].has_key('receipt-id'):
brief_msg = msg['headers']['receipt-id']
self.log.info("Received server receipt message - receipt-id:%s\n\n%s" % (brief_msg, body))
returned = NO_RESPONSE_NEEDED
if self.testing:
returned = 'receipt'
return returned

@@ -9,3 +9,3 @@ """

I've looked and the stomp client by Jason R. Briggs and have based the message
generation on how his client did it. The client can be found at the follow
generation on how his client did it. The client can be found at the follow
address however it isn't a dependancy.

@@ -51,6 +51,4 @@

class StomperTest(unittest.TestCase):
def testEngineToServerMessages(self):

@@ -64,3 +62,6 @@ """Test the state machines reaction

msg.cmd = 'MESSAGE'
msg.headers = {'destination:':'/queue/a','message-id:':'some-message-id'}
msg.headers = {
'destination:': '/queue/a',
'message-id:': 'some-message-id'
}
msg.body = "hello queue a"

@@ -75,3 +76,3 @@

error.cmd = 'ERROR'
error.headers = {'mesage:':'malformed packet received!'}
error.headers = {'mesage:': 'malformed packet received!'}
error.body = """The message:

@@ -84,3 +85,3 @@ -----

-----
Did not contain a destination header, which is required for message propagation.
Did not contain a destination header, which is required for message propagation.
\x00

@@ -96,4 +97,4 @@ """

receipt.cmd = 'RECEIPT'
receipt.headers = {'receipt-id:':'message-12345'}
receipt.headers = {'receipt-id:': 'message-12345'}
rc = e.react(receipt.pack())

@@ -103,3 +104,2 @@ self.assertEquals(rc, 'receipt')

def testEngine(self):

@@ -121,3 +121,2 @@ """Test the basic state machine.

# test message:

@@ -136,3 +135,2 @@ msg = """MESSAGE

# test error:

@@ -149,3 +147,3 @@ msg = """ERROR

self.assertEquals(returned, correct)
# test receipt:

@@ -161,3 +159,2 @@ msg = """RECEIPT

def testFramepack1(self):

@@ -167,9 +164,11 @@ """Testing pack, unpacking and the Frame class.

# Check bad frame generation:
frame = stomper.Frame()
frame = stomper.Frame()
def bad():
frame.cmd = 'SOME UNNOWN CMD'
self.assertRaises(stomper.FrameError, bad)
# Generate a MESSAGE frame:
frame = stomper.Frame()
frame = stomper.Frame()
frame.cmd = 'MESSAGE'

@@ -180,3 +179,3 @@ frame.headers['destination'] = '/queue/a'

result = frame.pack()
# print "\n-- result " + "----" * 10

@@ -187,5 +186,5 @@ # pprint.pprint(result)

# Try bad message unpack catching:
bad_frame = stomper.Frame()
bad_frame = stomper.Frame()
self.assertRaises(stomper.FrameError, bad_frame.unpack, None)
self.assertRaises(stomper.FrameError, bad_frame.unpack, '')
self.assertRaises(stomper.FrameError, bad_frame.unpack, '')

@@ -195,5 +194,5 @@ # Try to read the generated frame back in

# correctly:
frame2 = stomper.Frame()
frame2 = stomper.Frame()
frame2.unpack(result)
self.assertEquals(frame2.cmd, 'MESSAGE')

@@ -206,3 +205,3 @@ self.assertEquals(frame2.headers['destination'], '/queue/a')

correct = "MESSAGE\ndestination:/queue/a\nmessage-id:card_data\n\nhello queue a\x00\n"
# print "result: "

@@ -213,3 +212,3 @@ # pprint.pprint(result)

# pprint.pprint(correct)
# print
# print
#

@@ -219,3 +218,3 @@ self.assertEquals(result, correct)

result = stomper.unpack_frame(result)
self.assertEquals(result['cmd'], 'MESSAGE')

@@ -225,4 +224,13 @@ self.assertEquals(result['headers']['destination'], '/queue/a')

self.assertEquals(result['body'], 'hello queue a')
def testFramepack2(self):
"""Testing pack, unpacking and the Frame class.
"""
# Check bad frame generation:
frame = stomper.Frame()
frame.cmd = 'DISCONNECT'
result = frame.pack()
correct = 'DISCONNECT\n\n\x00\n'
self.assertEquals(result, correct)
def testFrameUnpack2(self):

@@ -238,3 +246,3 @@ """Testing unpack frame function against MESSAGE

result = stomper.unpack_frame(msg)
self.assertEquals(result['cmd'], 'MESSAGE')

@@ -244,4 +252,3 @@ self.assertEquals(result['headers']['destination'], '/queue/a')

self.assertEquals(result['body'], 'hello queue a')
def testFrameUnpack3(self):

@@ -254,8 +261,7 @@ """Testing unpack frame function against CONNECTED

result = stomper.unpack_frame(msg)
self.assertEquals(result['cmd'], 'CONNECTED')
self.assertEquals(result['headers']['session'], 'ID:snorky.local-49191-1185461799654-3:18')
self.assertEquals(result['body'], '')
def testBugInFrameUnpack1(self):

@@ -271,3 +277,3 @@ msg = """MESSAGE

result = stomper.unpack_frame(msg)
self.assertEquals(result['cmd'], 'MESSAGE')

@@ -278,4 +284,3 @@ self.assertEquals(result['headers']['destination'], '/queue/a')

def testCommit(self):
def testCommit(self):
transactionid = '1234'

@@ -294,7 +299,7 @@ correct = "COMMIT\ntransaction: %s\n\n\x00\n" % transactionid

self.assertEquals(stomper.begin(transactionid), correct)
def testAck(self):
messageid = '1234'
transactionid = '9876'
header = 'message-id: %s\ntransaction: %s' % (messageid, transactionid)
header = 'message-id: %s\ntransaction: %s' % (messageid, transactionid)
correct = "ACK\n%s\n\n\x00\n" % header

@@ -324,3 +329,2 @@ self.assertEquals(stomper.ack(messageid, transactionid), correct)

def testConnect(self):

@@ -330,3 +334,2 @@ username, password = 'bob', '123'

self.assertEquals(stomper.connect(username, password), correct)

@@ -337,3 +340,2 @@ def testDisconnect(self):

def testSend(self):

@@ -343,3 +345,3 @@ dest, transactionid, msg = '/queue/myplace', '', '123 456 789'

result = stomper.send(dest, msg, transactionid)
# print "result: "

@@ -350,5 +352,4 @@ # pprint.pprint(result)

# pprint.pprint(correct)
# print
# print
self.assertEquals(result, correct)

@@ -359,10 +360,4 @@

self.assertEquals(stomper.send(dest, msg, transactionid), correct)
if __name__ == "__main__":
unittest.main()

@@ -1,4 +0,4 @@

Metadata-Version: 1.0
Metadata-Version: 1.1
Name: stomper
Version: 0.2.4
Version: 0.2.5
Summary: This is a transport neutral client implementation of the STOMP protocol.

@@ -16,9 +16,11 @@ Home-page: http://code.google.com/p/stomper

:Author:
Oisin Mulvihill
Oisin Mulvihill
Contributors:
Micheal Twomey, Ricky Iacovou <iacovou at gmail dot com>,
Arfrever Frehtes Taifersar Arahesis <arfrever dot fta at gmail dot com>
Micheal Twomey, Ricky Iacovou <iacovou at gmail dot com>,
Arfrever Frehtes Taifersar Arahesis <arfrever dot fta at gmail dot com>
Niki Pore <niki pore at gmail dot com>
Introduction

@@ -83,2 +85,9 @@ ------------

0.2.5
~~~~~
Add the contributed fix for issue #14 by Niki Pore. The issue was reported by
Roger Hoover. This removes the extra line ending which can cause problems.
0.2.4

@@ -85,0 +94,0 @@ ~~~~~

+21
-21

@@ -12,12 +12,18 @@ """

Name='stomper'
ProjecUrl="http://code.google.com/p/stomper"
Version='0.2.4' # alpha release
Author='Oisin Mulvihill'
AuthorEmail='oisin dot mulvihill at gmail com'
Maintainer=' Oisin Mulvihill'
Summary='This is a transport neutral client implementation of the STOMP protocol.'
License='http://www.apache.org/licenses/LICENSE-2.0'
ShortDescription="This is a transport neutral client implementation of the STOMP protocol."
Classifiers=[
Name = 'stomper'
ProjectUrl = "http://code.google.com/p/stomper"
Version = '0.2.5'
Author = 'Oisin Mulvihill'
AuthorEmail = 'oisin dot mulvihill at gmail com'
Maintainer = 'Oisin Mulvihill'
Summary = (
'This is a transport neutral client implementation '
'of the STOMP protocol.'
)
License = 'http://www.apache.org/licenses/LICENSE-2.0'
ShortDescription = (
"This is a transport neutral client implementation of the "
"STOMP protocol."
)
Classifiers = [
"Development Status :: 4 - Beta",

@@ -31,3 +37,3 @@ "Intended Audience :: Developers",

fd = file("lib/stomper/doc/stomper.stx")
Description=fd.read()
Description = fd.read()
fd.close()

@@ -40,10 +46,7 @@

ProjectScripts = []
ProjectScripts = [
# '',
]
PackageData = {
# If any package contains *.txt or *.rst files, include them:
'stomper': ['doc/*.stx',],
'stomper': ['doc/*.stx'],
}

@@ -59,3 +62,2 @@

setup(
# url=ProjecUrl,
name=Name,

@@ -67,3 +69,3 @@ version=Version,

long_description=Description,
url=ProjecUrl,
url=ProjectUrl,
license=License,

@@ -76,5 +78,3 @@ classifiers=Classifiers,

package_data=PackageData,
package_dir = {'': 'lib'},
package_dir={'': 'lib'},
)

Sorry, the diff of this file is not supported yet