~landscape/txamqp/trunk

« back to all changes in this revision

Viewing changes to src/examples/simple/txpublisher.py

  • Committer: Thomas Hervé
  • Date: 2011-04-08 16:12:36 UTC
  • mfrom: (19.1.38 trunk)
  • Revision ID: thomas@canonical.com-20110408161236-21pd9d3bie4avhe3
Merge from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from twisted.internet.defer import inlineCallbacks
2
2
from twisted.internet import reactor, task
3
3
from twisted.internet.protocol import ClientCreator
 
4
from twisted.python import log
4
5
from txamqp.protocol import AMQClient
5
6
from txamqp.client import TwistedDelegate
6
7
from txamqp.content import Content
45
46
    import sys
46
47
    if len(sys.argv) < 8:
47
48
        print "%s host port vhost username password path_to_spec content [count]" % sys.argv[0]
48
 
        print "e.g. %s localhost 5672 / guest guest ../../specs/standard/amqp0-8.xml hello 1000" % sys.argv[0]
 
49
        print "e.g. %s localhost 5672 / guest guest ../../specs/standard/amqp0-8.stripped.xml hello 1000" % sys.argv[0]
49
50
        sys.exit(1)
50
51
 
51
52
    host = sys.argv[1]
69
70
 
70
71
    d.addCallback(gotConnection, username, password, content, count)
71
72
 
 
73
    def whoops(err):
 
74
        if reactor.running:
 
75
            log.err(err)
 
76
            reactor.stop()
 
77
 
 
78
    d.addErrback(whoops)
 
79
 
72
80
    reactor.run()