Skip to content
Permalink
Browse files

Upgrade to Python3

  • Loading branch information...
DavidLemayian committed May 9, 2019
1 parent c07dd20 commit 730c8dc592a6647b2315a719f6937f19145494fd
@@ -1,11 +1,6 @@
language: python
python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
- "nightly"
- "3.7"
# command to install dependencies
install:
- pip install -r requirements.txt
@@ -1,12 +1,12 @@
FROM python:2.7
FROM python:3.7
ENV DEBIAN_FRONTEND noninteractive

COPY . /htools-api

WORKDIR /htools-api

RUN pip install --upgrade pip
RUN pip install -r requirements.txt
RUN pip install -r requirements.txt && pip install --upgrade requests
RUN pip install -e .

EXPOSE 8000
@@ -1,5 +1,7 @@
from future import standard_library
standard_library.install_aliases()
from elasticsearch import helpers
import urllib2, json
import urllib.request, urllib.error, urllib.parse, json
from flask.cli import AppGroup

from healthtools.manage import app
@@ -10,7 +12,7 @@
@htools_cli.command('loaddata')
def load_data():
url = 'https://s3-eu-west-1.amazonaws.com/cfa-healthtools-ke/data/doctors.json'
response = urllib2.urlopen(url)
response = urllib.request.urlopen(url)
helpers.bulk(es, json.load(response), index=es_index, doc_type='doctors')

@htools_cli.command('resetindex')
@@ -1,3 +1,4 @@
from builtins import str
import logging

from werkzeug.local import LocalProxy
@@ -63,5 +64,5 @@ def get_es_index():
class AWS4AuthNotUnicode(AWS4Auth):
def __call__(self, req):
req = super(AWS4AuthNotUnicode, self).__call__(req)
req.headers = {str(name): value for name, value in req.headers.items()}
req.headers = {str(name): value for name, value in list(req.headers.items())}
return req
@@ -1,3 +1,5 @@
from builtins import str
from builtins import zip
import requests
import logging
from bs4 import BeautifulSoup
@@ -20,8 +22,6 @@ def get_clinical_officers(query):
clinicalofficers = {'hits': [], 'total': 0}
try:
response = requests.post(COC_REGISTER_URL, data = {'search_register':'1', 'search_text': query})
if 'No results' in response.content:
return clinicalofficers

# make soup for parsing out of response and get the table
soup = BeautifulSoup(response.content, 'html.parser')
@@ -1,3 +1,4 @@
from builtins import str
import logging
from healthtools.core import es, es_index

@@ -1,3 +1,5 @@
from builtins import str
from builtins import zip
import requests
import logging
from bs4 import BeautifulSoup
@@ -20,9 +22,7 @@ def get_people(query):
people = {'hits': [], 'total': 0}
try:
response = requests.post(FETCH_URL, data = {'search_register':'1', 'search_text': query})
if 'No results' in response.content:
return people


# make soup for parsing out of response and get the table
soup = BeautifulSoup(response.content, 'html.parser')
table = soup.find('table', {'class': 'datatables'}).find('tbody')
@@ -81,7 +81,7 @@ def determine_doc_type_using_wit(query, doc_type=None):
message_text = query
resp = client.message(message_text)
query = ''.join(nested_lookup('value', resp['entities']['query']))
doc_type = ''.join([var for var in (resp['entities'].keys()) if var != 'query'])
doc_type = ''.join([var for var in (list(resp['entities'].keys())) if var != 'query'])
doc_type = doc_type.replace("_", "-") # changes underscore to hyphen
if doc_exists(doc_type) == True:
return doc_type, query
@@ -1,3 +1,4 @@
from builtins import str
import logging

from healthtools.sms import twilio, mtech
@@ -43,7 +43,7 @@ def test_nurses_endpoint_can_retrieve_cached_result(self):
self.client.get("search/nurses?q=Marie")
# second time should retrieve cached result
response = self.client.get("search/nurses?q=Marie")
self.assertIn(b"X-Retrieved-From-Cache", response.headers.keys())
self.assertIn(b"X-Retrieved-From-Cache", list(response.headers.keys()))

def test_nurses_endpoint_with_bad_endpoint(self):
"""
@@ -7,4 +7,4 @@
@blueprint.route('/')
def index():
# TODO: Redirect to HealthTools docs instead
return redirect('https://github.com/CodeForAfricaLabs/HealthTools.API')
return redirect('https://github.com/CodeForAfrica/HealthTools.API')
@@ -1,3 +1,4 @@
from builtins import str
import logging
from flask import Blueprint, request, jsonify

@@ -1,15 +1,11 @@
bs4==0.0.1
beautifulsoup4==4.7.1
elasticsearch==5.5.3
emoji==0.5.0
flask-cors==3.0.4
gunicorn==19.7.1
nested-lookup==0.1.5
pip-chill==0.1.8
pipreqs==0.4.9
pylint==1.8.4
flask-cors==3.0.7
gunicorn==19.9.0
nested-lookup==0.2.12
pylint==2.3.1
python-memcached==1.59
requests-aws4auth==0.9
telegram==0.0.1
twilio==6.6.3
virtualenv==16.0.0
wit==5.1.0
twilio==6.26.3
wit==5.1.0
@@ -2,11 +2,11 @@

setup(
name='healthtools',
version='0.0.4',
version='0.0.5',
keywords='healthtools',
author='Code for Africa',
author_email='support@codeforafrica.org',
url='https://github.com/CodeForAfricaLabs/HealthTools.API',
url='https://github.com/CodeForAfrica/HealthTools.API',
license='MIT',
packages=find_packages(exclude=['ez_setup', 'examples', 'test']),
include_package_data=True,

0 comments on commit 730c8dc

Please sign in to comment.
You can’t perform that action at this time.