aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rwxr-xr-xwqflask/base/webqtlTrait.py17
-rw-r--r--wqflask/wqflask/show_trait/show_trait_page.py21
2 files changed, 24 insertions, 14 deletions
diff --git a/wqflask/base/webqtlTrait.py b/wqflask/base/webqtlTrait.py
index c3c0cded..88226894 100755
--- a/wqflask/base/webqtlTrait.py
+++ b/wqflask/base/webqtlTrait.py
@@ -92,12 +92,13 @@ class webqtlTrait:
WHERE
ProbeSet.Id=ProbeSetXRef.ProbeSetId and
ProbeSetFreeze.Id = ProbeSetXRef.ProbeSetFreezeId and
- ProbeSet.Name = "%s" and
- ProbeSetFreeze.Name = "%s"
- ''' % (self.name, self.db.name)
+ ProbeSet.Name = %s and
+ ProbeSetFreeze.Name = %s
+ ''', (self.name, self.db.name)
print("query is:", query)
- self.cursor.execute(query)
+ self.cursor.execute(*query)
self.sequence = self.cursor.fetchone()[0]
+ print("self.sequence is:", self.sequence)
def getName(self):
@@ -124,7 +125,7 @@ class webqtlTrait:
str = self.name
if self.db and self.name:
if self.db.type=='Temp':
- self.cursor.execute('SELECT description FROM Temp WHERE Name=%s',self.name)
+ self.cursor.execute('SELECT description FROM Temp WHERE Name=%s', self.name)
desc = self.cursor.fetchone()[0]
if desc.__contains__('PCA'):
desc = desc[desc.rindex(':')+1:].strip()
@@ -206,7 +207,7 @@ class webqtlTrait:
def getSequence(self):
assert self.cursor
if self.db.type == 'ProbeSet':
- query = '''
+ self.cursor.execute('''
SELECT
ProbeSet.BlatSeq
FROM
@@ -216,8 +217,8 @@ class webqtlTrait:
ProbeSetFreeze.Id = ProbeSetXRef.ProbSetFreezeId and
ProbeSet.Name = %s
ProbeSetFreeze.Name = %s
- ''' , (self.name, self.db.name)
- self.cursor.execute(query)
+ ''', self.name, self.db.name)
+ #self.cursor.execute(query)
results = self.fetchone()
return results[0]
diff --git a/wqflask/wqflask/show_trait/show_trait_page.py b/wqflask/wqflask/show_trait/show_trait_page.py
index c7d6618e..a34c20cf 100644
--- a/wqflask/wqflask/show_trait/show_trait_page.py
+++ b/wqflask/wqflask/show_trait/show_trait_page.py
@@ -24,6 +24,10 @@
#
# Last updated by GeneNetwork Core Team 2010/10/20
+from __future__ import division, print_function
+
+from flask import request
+
from htmlgen import HTMLgen2 as HT
from base import webqtlConfig
@@ -96,8 +100,12 @@ class ShowTraitPage(DataEditingPage):
at this time, please go back and select other database." % indFullName]
self.error(heading=heading,detail=detail,error="Confidential Database")
return
+ print("environ:", request.environ)
- user_ip = fd.remote_ip
+ # Becuase of proxying remote_addr is probably localhost, so we first try for
+ # HTTP_X_FORWARDED_FOR
+ user_ip = request.environ.get('HTTP_X_FORWARDED_FOR') or request.remote_addr # in old app was fd.remote_ip
+ print("user_ip is:", user_ip)
query = "SELECT count(id) FROM AccessLog WHERE ip_address = %s and \
UNIX_TIMESTAMP()-UNIX_TIMESTAMP(accesstime)<86400"
self.cursor.execute(query,user_ip)
@@ -143,9 +151,9 @@ class ShowTraitPage(DataEditingPage):
"""
##identification, etc.
- fd.identification = '%s : %s'%(thisTrait.db.shortname,ProbeSetID)
+ fd.identification = '%s : %s' % (thisTrait.db.shortname,ProbeSetID)
thisTrait.returnURL = webqtlConfig.CGIDIR + webqtlConfig.SCRIPTFILE + '?FormID=showDatabase&database=%s\
- &ProbeSetID=%s&RISet=%s&parentsf1=on' %(database,ProbeSetID,fd.RISet)
+ &ProbeSetID=%s&RISet=%s&parentsf1=on' %(database, ProbeSetID, fd['RISet'])
if CellID:
fd.identification = '%s/%s'%(fd.identification, CellID)
@@ -156,12 +164,13 @@ class ShowTraitPage(DataEditingPage):
thisTrait.retrieveInfo()
thisTrait.retrieveData()
self.updMysql()
- self.cursor.execute("insert into AccessLog(accesstime,ip_address) values(Now(),%s)" ,user_ip)
+ self.cursor.execute("insert into AccessLog(accesstime,ip_address) values(Now(),%s)", user_ip)
self.openMysql()
- except:
+ except Exception as why:
+ print("Got an exception:", why)
heading = "Retrieve Data"
detail = ["The information you requested is not avaiable at this time."]
- self.error(heading=heading,detail=detail)
+ self.error(heading=heading, detail=detail)
return
##read genotype file