docs/main/MessagingScenarios.rst | 5 +++++ moksha/commands/cli.py | 31 ++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-)
New commits: commit 69a65b68af9e2064d1b718e9823abb1a7debedda Author: Luke Macken lmacken@redhat.com Date: Sat Oct 2 00:15:42 2010 -0400
Add our --send parser option
diff --git a/moksha/commands/cli.py b/moksha/commands/cli.py index aa152dd..a1ffa56 100644 --- a/moksha/commands/cli.py +++ b/moksha/commands/cli.py @@ -132,8 +132,13 @@ def main(): except Exception, e: print "Caught exception: %s" % str(e) moksha.stop() - elif opts.list: + elif opts.list or 'list' in args: moksha.list() + elif opts.send or 'send' in args: + if len(sys.argv) != 4: + log.error('Usage: moksha send <topic> <message>') + sys.exit(-1) + moksha.send(sys.argv[2], sys.argv[3]) else: parser.print_help()
commit a4fb173d370f4a05c3e1d527f62f4110f35e11a4 Author: Luke Macken lmacken@redhat.com Date: Sat Oct 2 00:15:30 2010 -0400
Setup a basic logging config in our cli
diff --git a/moksha/commands/cli.py b/moksha/commands/cli.py index 30d4091..aa152dd 100644 --- a/moksha/commands/cli.py +++ b/moksha/commands/cli.py @@ -117,7 +117,9 @@ def main(): opts, args = parser.parse_args() moksha = MokshaCLI()
- log.setLevel(logging.INFO) + logging.basicConfig(level=logging.INFO, format= + '%(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s') + stdout = logging.StreamHandler(sys.stdout) stdout.setFormatter(logging.Formatter('%(message)s')) log.addHandler(stdout)
commit 130c5ee972366894d6d0699647ba0048d9f17992 Author: Luke Macken lmacken@redhat.com Date: Sat Oct 2 00:13:41 2010 -0400
Add an initial `moksha send <topic> <message>` command.
This has a few drawbacks. I couldn't figure out how to get the message to flush properly without calling reactor.run(), so we first schedule a task to run 0.2 seconds in the future that stops the reactor. This feels dirty and should eventually be improved. It also spits out fatal connection upon completion when using the STOMP messaging protocol.
diff --git a/moksha/commands/cli.py b/moksha/commands/cli.py index 5f859d9..30d4091 100644 --- a/moksha/commands/cli.py +++ b/moksha/commands/cli.py @@ -84,6 +84,21 @@ class MokshaCLI(object): """ Create a new Moksha component """ # If no arguments given, run `paster moksha --help`
+ def send(self, topic, message): + """ Send a message to a topic """ + from moksha.api.hub import MokshaHub, reactor + hub = MokshaHub() + print "send_message(%s, %s)" % (topic, message) + hub.send_message(topic, {'msg': message}) + + def stop_reactor(): + hub.close() + reactor.stop() + + reactor.callLater(0.2, stop_reactor) + reactor.run() + +
def get_parser(): usage = 'usage: %prog [command]' @@ -92,6 +107,8 @@ def get_parser(): help='Start Moksha') parser.add_option('', '--list', action='store_true', dest='list', help='List all installed Moksha components') + parser.add_option('', '--send', action='store_true', dest='send', + help='Send a message to a given topic. Usage: send <topic> <message>') return parser
commit 2d9b8e093dd72f34ab171c67eb176a64c821f126 Author: Luke Macken lmacken@redhat.com Date: Sat Oct 2 00:12:54 2010 -0400
Set the PYTHONPATH to cwd when spawning processes from the cli
diff --git a/moksha/commands/cli.py b/moksha/commands/cli.py index c18c8bc..5f859d9 100644 --- a/moksha/commands/cli.py +++ b/moksha/commands/cli.py @@ -47,7 +47,8 @@ class MokshaCLI(object): args = args and [process] + list(args) or [process] print "Running %s %s" % (process, ' '.join(args)) pp = MokshaProcessProtocol(name=process) - process = reactor.spawnProcess(pp, process, args, **kw) + process = reactor.spawnProcess(pp, process, args, + env={'PYTHONPATH': os.getcwd()}, **kw) pids.append(process.pid)
def start(self):
commit c710db7515838adc69a1de6b6c0c07ab0a768e11 Author: Luke Macken lmacken@redhat.com Date: Sat Oct 2 00:12:48 2010 -0400
Add a See Also block to our Messaging Scenarios doc
diff --git a/docs/main/MessagingScenarios.rst b/docs/main/MessagingScenarios.rst index 6719906..f33900e 100644 --- a/docs/main/MessagingScenarios.rst +++ b/docs/main/MessagingScenarios.rst @@ -27,3 +27,8 @@ Pros: - Flexibility and power of AMQP queues, exchanges, routing keys, etc. Cons: - Relatively new and not 100% complete JavaScript bindings + +.. seealso:: + + See :doc:`MessageBrokers` for more information on configuring various + protocols and brokers with Moksha.
moksha-commits@lists.fedorahosted.org