Skip to content

Commit

Permalink
python 3.10 support (#75)
Browse files Browse the repository at this point in the history
* python 3.10 updates, may cause issues on older python 3.x versions
  • Loading branch information
diegocepedaw authored Dec 8, 2022
1 parent cd5e522 commit d8f7da6
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .ci/run_mysql_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ echo "[*] Spinning up mysql through docker"
docker run -d --name mysql \
-e MYSQL_ROOT_PASSWORD=admin \
-e MYSQL_ROOT_HOST=% \
-d mysql/mysql-server:5.7
-d mysql/mysql-server:8.0
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
build:
docker:
- image: cimg/python:3.7-browsers
- image: mysql/mysql-server:5.7.27
- image: mysql/mysql-server:8.0
environment:
- MYSQL_ROOT_PASSWORD=admin
- MYSQL_ROOT_HOST=%
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:16.04

RUN apt-get update && apt-get -y dist-upgrade \
&& apt-get -y install python-pip uwsgi virtualenv sudo python-dev libyaml-dev \
&& apt-get -y install python-pip uwsgi virtualenv sudo python-dev3 libyaml-dev \
libsasl2-dev libldap2-dev nginx uwsgi-plugin-python libssl-dev libffi-dev \
&& rm -rf /var/cache/apt/archives/*

Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ machine:
services:
- docker
python:
version: 2.7.11
version: 3.10.8

dependencies:
override:
Expand Down
2 changes: 1 addition & 1 deletion ops/packer/iris-relay.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ provisioners:

- type: "shell"
inline:
- sudo apt-get -y install curl python-pip python-dev python3-pip uwsgi unzip python3-venv sudo python3-dev libyaml-dev libsasl2-dev libldap2-dev nginx uwsgi-plugin-python3 mysql-client xmlsec1 libssl-dev
- sudo apt-get -y install curl python-pip python3-dev python3-pip uwsgi unzip python3-venv sudo python3-dev libyaml-dev libsasl2-dev libldap2-dev nginx uwsgi-plugin-python3 mysql-client xmlsec1 libssl-dev
- sudo rm -rf /var/cache/apt/archives/*
- sudo useradd -m -s /bin/bash iris-relay
- sudo chown -R iris-relay:iris-relay /home/iris-relay /var/log/nginx /var/lib/nginx
Expand Down
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,18 @@
'pysaml2==4.5.0',
'PyYAML',
'gevent==21.12.0',
'requests==2.23.0',
'requests==2.28.1',
'requests-futures==0.9.9',
'google-api-python-client==1.6.2',
'SQLAlchemy==1.3.0',
'PyMySQL==0.7.11',
'oauth2client',
'simplejson',
'slackclient==0.16',
'streql==3.0.2',
'twilio==6.25.0',
'urllib3==1.25.11',
'falcon==1.4.1',
'ujson==5.4.0',
'urllib3==1.26.13',
'falcon==3.1.1',
'ujson==5.5.0',
'irisclient==1.3.0',
'oncallclient==1.1.0',
],
Expand Down
15 changes: 8 additions & 7 deletions src/iris_relay/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import urllib.request as urllib2

from . import db
from streql import equals
from twilio.twiml.voice_response import VoiceResponse
from twilio.twiml.messaging_response import MessagingResponse
from urllib3.exceptions import MaxRetryError
Expand Down Expand Up @@ -610,7 +609,7 @@ def __init__(self, config, iclient):
self.verification_token = self.config['slack']['verification_token']

def valid_token(self, token):
return equals(self.verification_token, token)
return self.verification_token == token

def return_slack_message(self, resp, text):
resp.status = falcon.HTTP_200
Expand Down Expand Up @@ -836,7 +835,7 @@ def process_request(self, req, resp):

auth = re.sub('^Basic ', '', hdr_auth)
usr, pwd = decodebytes(auth).split(':')
if not equals(self.basic_auth.get(usr, ''), pwd):
if not self.basic_auth.get(usr, '') == pwd:
logger.warning('basic auth failure: %s', usr)
raise falcon.HTTPUnauthorized('Access denied', 'Basic auth failure', [])

Expand All @@ -852,7 +851,8 @@ def process_request(self, req, resp):
if sig is None:
logger.warning("no twilio signature found!")
raise falcon.HTTPUnauthorized('Access denied', 'No Twilio signature', [])
uri = [req.protocol, '://',
protocol = (req.scheme if req.scheme else 'https')
uri = [protocol, '://',
req.get_header('HOST'),
self.config['server'].get('lb_routing_path', ''),
req.path]
Expand Down Expand Up @@ -937,11 +937,11 @@ class ReqBodyMiddleware(object):
we often need the post body twice (once for Twilio signature validation and once to relay the message onto Iris
API. To avoid this problem, we read the post body into the request context and access it from there.
IMPORTANT NOTE: Because we use stream.read() here, all other uses of this method will return '', not the post body.
IMPORTANT NOTE: Because we use bounded_stream.read() here, all other uses of this method will return '', not the post body.
'''

def process_request(self, req, resp):
req.context['body'] = req.stream.read()
req.context['body'] = req.bounded_stream.read()


class CORS(object):
Expand Down Expand Up @@ -1009,7 +1009,8 @@ def get_relay_app(config=None):
# Note that ReqBodyMiddleware must be run before AuthMiddleware, since
# authentication uses the post body
cors = CORS(config.get('allow_origins_list', []))
app = falcon.API(middleware=[ReqBodyMiddleware(), AuthMiddleware(config), cors])
app = falcon.App(middleware=[ReqBodyMiddleware(), AuthMiddleware(config), cors])
app.req_options.strip_url_path_trailing_slash = True

ical_relay = OncallCalendarRelay(oncall_client, config['oncall']['url'])
app.add_route('/api/v0/ical/{ical_key}', ical_relay)
Expand Down

0 comments on commit d8f7da6

Please sign in to comment.