Skip to content

Commit 51bf930

Browse files
author
Jon Wedell
committed
Updates to python3, new environment
1 parent 8876a84 commit 51bf930

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

gateway.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/env python3
22

33
""" Power the gateway server. """
44

5-
from __future__ import print_function
6-
75
import os
86
import re
97
import shutil
@@ -23,7 +21,7 @@
2321
dir_path = os.path.dirname(os.path.realpath(__file__))
2422

2523

26-
def get_postgres_connection(user='web', database='webservers', host="pinzgau",
24+
def get_postgres_connection(user='web', database='webservers', host="localhost",
2725
dictionary_cursor=False):
2826
""" Returns a connection to postgres and a cursor."""
2927

@@ -136,7 +134,7 @@ def inchi_search(inchi=None):
136134
if not inchi.startswith('InChI='):
137135
inchi = 'InChI=' + inchi
138136

139-
#InChI=1S/C6H12O6/c7-1-3(9)5(11)6(12)4(10)2-8/h3,5-9,11-12H,1-2H2/t3?,5?,6u/m1/s1
137+
# InChI=1S/C6H12O6/c7-1-3(9)5(11)6(12)4(10)2-8/h3,5-9,11-12H,1-2H2/t3?,5?,6u/m1/s1
140138

141139
def enumerate_chirality(chiral_inchi_segment):
142140

@@ -159,7 +157,7 @@ def enumerate_chirality(chiral_inchi_segment):
159157
chiral_options = ['']
160158
replace_from = 'DO NOT REPLACE'
161159

162-
format = request.args.get('format', 'html')
160+
request_format = request.args.get('format', 'html')
163161

164162
# Have to query multiple times or postgres doesn't realize it can use the index - so weird
165163
cur = get_postgres_connection(dictionary_cursor=True)[1]
@@ -169,7 +167,7 @@ def enumerate_chirality(chiral_inchi_segment):
169167
cur.execute(sql, [inchi.replace(replace_from, chiral_chunk)])
170168
result = cur.fetchone()
171169
if result:
172-
if format == 'json':
170+
if request_format == 'json':
173171
results.append(dict(result))
174172
else:
175173
results.append(result)
@@ -203,7 +201,7 @@ def name_search():
203201

204202
term = request.args.get('term', "")
205203
if term:
206-
results = requests.get('http://alatis.nmrfam.wisc.edu/search/inchi', params={'term': term}).json()
204+
results = requests.get('http://alatis.nmrbox.org/search/inchi', params={'term': term}).json()
207205
else:
208206
results = None
209207
var_dict = {'title': term, 'results': results, 'active': 'name'}

requirements.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
psycopg2-binary==2.7.6.1
2-
flask==1.0.2
3-
requests==2.19.1
1+
psycopg2-binary==2.8.6
2+
flask==1.1.2
3+
requests==2.25.1
4+
uwsgi==2.0.19.1

setup_virtualenv.sh

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
#!/bin/bash
2-
python -m virtualenv env
3-
source ./env/bin/activate
4-
pip install pip==9.0.3
5-
export PATH="${PATH}:/usr/pgsql-9.2/bin/"
6-
pip install -r requirements.txt
2+
python3 -m venv venv
3+
source ./venv/bin/activate && pip3 install -r requirements.txt

uwsgi.ini

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[uwsgi]
2+
3+
home=/websites/gateway/application/venv
4+
socket=/var/run/gateway/uwsgi.sock
5+
chdir=/websites/gateway/application
6+
module=gateway
7+
chmod-socket=664
8+
user=www-data
9+
group=www-data
10+
11+
RuntimeDirectory=gateway
12+
master=true
13+
processes=3
14+
vacuum=true
15+
16+
# Why? https://uwsgi-docs.readthedocs.io/en/latest/ThingsToKnow.html
17+
# Look for wsgi-disable-file-wrapper
18+
wsgi-disable-file-wrapper=true

0 commit comments

Comments
 (0)