Skip to content

Commit b68b1d9

Browse files
committed
Basic Python 3 compat
1 parent 24c05b2 commit b68b1d9

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

msgflo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
from msgflo import *
2+
from .msgflo import *

msgflo/msgflo.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/usr/bin/env python
22

3-
import sys, os, json, random, urlparse
3+
import sys, os, json, random
44
sys.path.append(os.path.abspath("."))
55

6+
try:
7+
from urllib.parse import urlparse
8+
except ImportError:
9+
from urlparse import urlparse
10+
611
from optparse import OptionParser
712

813
import logging
@@ -71,7 +76,7 @@ def nack(self, msg):
7176
class Engine(object):
7277
def __init__(self, broker, discovery_period=None):
7378
self.broker_url = broker
74-
self.broker_info = urlparse.urlparse(self.broker_url)
79+
self.broker_info = urlparse(self.broker_url)
7580
self.discovery_period = discovery_period if discovery_period else DEFAULT_DISCOVERY_PERIOD
7681

7782
def done_callback(self, done_cb):
@@ -338,7 +343,7 @@ def run(participant, broker=None, done_cb=None, iips={}):
338343
broker = os.environ.get('MSGFLO_BROKER', 'amqp://localhost')
339344

340345
engine = None
341-
broker_info = urlparse.urlparse(broker)
346+
broker_info = urlparse(broker)
342347
if broker_info.scheme == 'amqp':
343348
engine = AmqpEngine(broker)
344349
elif broker_info.scheme == 'mqtt':
@@ -379,6 +384,6 @@ def main(Participant, role=None):
379384
waiter = gevent.event.AsyncResult()
380385
engine = run(participant, done_cb=waiter.set, iips=config.iips)
381386
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))
383388
sys.stdout.flush()
384389
waiter.wait()

0 commit comments

Comments
 (0)