|
1 | 1 | #!/usr/bin/env python |
2 | 2 |
|
3 | | -import sys, os, json, random, urlparse |
| 3 | +import sys, os, json, random |
4 | 4 | sys.path.append(os.path.abspath(".")) |
5 | 5 |
|
| 6 | +try: |
| 7 | + from urllib.parse import urlparse |
| 8 | +except ImportError: |
| 9 | + from urlparse import urlparse |
| 10 | + |
6 | 11 | from optparse import OptionParser |
7 | 12 |
|
8 | 13 | import logging |
@@ -71,7 +76,7 @@ def nack(self, msg): |
71 | 76 | class Engine(object): |
72 | 77 | def __init__(self, broker, discovery_period=None): |
73 | 78 | self.broker_url = broker |
74 | | - self.broker_info = urlparse.urlparse(self.broker_url) |
| 79 | + self.broker_info = urlparse(self.broker_url) |
75 | 80 | self.discovery_period = discovery_period if discovery_period else DEFAULT_DISCOVERY_PERIOD |
76 | 81 |
|
77 | 82 | def done_callback(self, done_cb): |
@@ -338,7 +343,7 @@ def run(participant, broker=None, done_cb=None, iips={}): |
338 | 343 | broker = os.environ.get('MSGFLO_BROKER', 'amqp://localhost') |
339 | 344 |
|
340 | 345 | engine = None |
341 | | - broker_info = urlparse.urlparse(broker) |
| 346 | + broker_info = urlparse(broker) |
342 | 347 | if broker_info.scheme == 'amqp': |
343 | 348 | engine = AmqpEngine(broker) |
344 | 349 | elif broker_info.scheme == 'mqtt': |
@@ -379,6 +384,6 @@ def main(Participant, role=None): |
379 | 384 | waiter = gevent.event.AsyncResult() |
380 | 385 | engine = run(participant, done_cb=waiter.set, iips=config.iips) |
381 | 386 | anon_url = "%s://%s" % (engine.broker_info.scheme, engine.broker_info.hostname) |
382 | | - print "%s(%s) running on %s" % (d['role'], d['component'], anon_url) |
| 387 | + print("%s(%s) running on %s" % (d['role'], d['component'], anon_url)) |
383 | 388 | sys.stdout.flush() |
384 | 389 | waiter.wait() |
0 commit comments