1
- #!/usr/bin/python
1
+ #!/usr/bin/env python3
2
2
3
3
""" Power the gateway server. """
4
4
5
- from __future__ import print_function
6
-
7
5
import os
8
6
import re
9
7
import shutil
23
21
dir_path = os .path .dirname (os .path .realpath (__file__ ))
24
22
25
23
26
- def get_postgres_connection (user = 'web' , database = 'webservers' , host = "pinzgau " ,
24
+ def get_postgres_connection (user = 'web' , database = 'webservers' , host = "localhost " ,
27
25
dictionary_cursor = False ):
28
26
""" Returns a connection to postgres and a cursor."""
29
27
@@ -136,7 +134,7 @@ def inchi_search(inchi=None):
136
134
if not inchi .startswith ('InChI=' ):
137
135
inchi = 'InChI=' + inchi
138
136
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
140
138
141
139
def enumerate_chirality (chiral_inchi_segment ):
142
140
@@ -159,7 +157,7 @@ def enumerate_chirality(chiral_inchi_segment):
159
157
chiral_options = ['' ]
160
158
replace_from = 'DO NOT REPLACE'
161
159
162
- format = request .args .get ('format' , 'html' )
160
+ request_format = request .args .get ('format' , 'html' )
163
161
164
162
# Have to query multiple times or postgres doesn't realize it can use the index - so weird
165
163
cur = get_postgres_connection (dictionary_cursor = True )[1 ]
@@ -169,7 +167,7 @@ def enumerate_chirality(chiral_inchi_segment):
169
167
cur .execute (sql , [inchi .replace (replace_from , chiral_chunk )])
170
168
result = cur .fetchone ()
171
169
if result :
172
- if format == 'json' :
170
+ if request_format == 'json' :
173
171
results .append (dict (result ))
174
172
else :
175
173
results .append (result )
@@ -203,7 +201,7 @@ def name_search():
203
201
204
202
term = request .args .get ('term' , "" )
205
203
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 ()
207
205
else :
208
206
results = None
209
207
var_dict = {'title' : term , 'results' : results , 'active' : 'name' }
0 commit comments