Skip to content

Commit

Permalink
Python 3 migration: BREAKING CHANGE
Browse files Browse the repository at this point in the history
All in on Python 3 for Python 2.7 EOL in 2020
  • Loading branch information
dwang159 committed Mar 9, 2019
1 parent 5de7628 commit ed3910b
Show file tree
Hide file tree
Showing 44 changed files with 236 additions and 253 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -4,7 +4,7 @@ jobs:
services:
- docker
docker:
- image: circleci/python:2.7-stretch-browsers
- image: circleci/python:3.7-stretch-browsers
- image: mysql/mysql-server:5.7
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=1
Expand Down
3 changes: 2 additions & 1 deletion configs/config.dev.yaml
Expand Up @@ -55,7 +55,8 @@ qr_login_url: Null
## Refer to their class name in this array.
## The webhook will be available at /v0/webhooks/$name and requires being called with
## ?application=xxx&key=xxx
#webhooks: []
webhooks:
- alertmanager

#####################
### Iris-sender
Expand Down
18 changes: 9 additions & 9 deletions ops/entrypoint.py
Expand Up @@ -14,7 +14,7 @@


def load_sqldump(config, sqlfile, one_db=True):
print 'Importing %s...' % sqlfile
print('Importing %s...' % sqlfile)
with open(sqlfile) as h:
cmd = ['/usr/bin/mysql', '-h', config['host'], '-u',
config['user'], '-p' + config['password']]
Expand All @@ -24,17 +24,17 @@ def load_sqldump(config, sqlfile, one_db=True):
proc.communicate()

if proc.returncode == 0:
print 'DB successfully loaded ' + sqlfile
print('DB successfully loaded ' + sqlfile)
return True
else:
print ('Ran into problems during DB bootstrap. '
print(('Ran into problems during DB bootstrap. '
'IRIS will likely not function correctly. '
'mysql exit code: %s for %s') % (proc.returncode, sqlfile)
'mysql exit code: %s for %s') % (proc.returncode, sqlfile))
return False


def wait_for_mysql(config):
print 'Checking MySQL liveness on %s...' % config['host']
print('Checking MySQL liveness on %s...' % config['host'])
db_address = (config['host'], 3306)
tries = 0
while True:
Expand All @@ -45,17 +45,17 @@ def wait_for_mysql(config):
break
except socket.error:
if tries > 20:
print 'Waited too long for DB to come up. Bailing.'
print('Waited too long for DB to come up. Bailing.')
sys.exit(1)

print 'DB not up yet. Waiting a few seconds..'
print('DB not up yet. Waiting a few seconds..')
time.sleep(2)
tries += 1
continue


def initialize_mysql_schema(config):
print 'Initializing Iris database'
print('Initializing Iris database')
# disable one_db to let schema_0.sql create the database
re = load_sqldump(config, os.path.join(dbpath, 'schema_0.sql'), one_db=False)
if not re:
Expand All @@ -71,7 +71,7 @@ def initialize_mysql_schema(config):
sys.stderr.write('Failed to load dummy data.')

with open(initializedfile, 'w'):
print 'Wrote %s so we don\'t bootstrap db again' % initializedfile
print('Wrote %s so we don\'t bootstrap db again' % initializedfile)


def main():
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Expand Up @@ -15,20 +15,20 @@
include_package_data=True,
install_requires=[
'streql==3.0.2',
'dnspython==1.14.0',
'dnspython==1.16.0',
'phonenumbers==7.4.1',
'twilio==4.5.0',
'google-api-python-client==1.4.2',
'oauth2client==1.4.12',
'slackclient==0.16',
'PyYAML==3.11',
'gevent==1.1.2',
'PyYAML==3.13',
'gevent==1.4.0',
'falcon==1.1.0',
'falcon-cors==1.1.2',
'ujson==1.35',
'requests==2.20.0',
'PyMySQL==0.7.2',
'SQLAlchemy==1.0.11',
'PyMySQL==0.9.3',
'SQLAlchemy==1.3.0',
'Jinja2==2.10',
'importlib==1.0.3',
'Markdown==2.4.1',
Expand All @@ -47,7 +47,7 @@
'pyqrcode==1.2.1'
],
extras_require={
'kazoo': ['kazoo==2.3.1'],
'kazoo': ['kazoo==2.6.1'],
# plugin deps
'influxdb': ['influxdb'],
'prometheus': ['prometheus_client'],
Expand Down
2 changes: 1 addition & 1 deletion src/iris/__main__.py
Expand Up @@ -15,5 +15,5 @@
app = API(config)
logging.basicConfig()
server = config['server']
print 'LISTENING: %(host)s:%(port)d' % server
print('LISTENING: %(host)s:%(port)d' % server)
WSGIServer((server['host'], server['port']), app).serve_forever()

0 comments on commit ed3910b

Please sign in to comment.