aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/mechnical-rob111
-rw-r--r--etc/VERSION2
-rw-r--r--etc/default_settings.py2
-rw-r--r--etc/nginx-genenetwork.conf54
-rw-r--r--test/lib/gntest.rb6
-rw-r--r--test/lib/link_checker.rb50
-rw-r--r--test/lib/main_web_functionality.rb62
-rw-r--r--test/lib/mapping.rb58
-rw-r--r--test/lib/navigation.rb43
-rw-r--r--test/requests/link_checker.py18
-rwxr-xr-xtest/requests/test-website.py6
-rw-r--r--wqflask/other_config/dot.pylintrc249
-rw-r--r--wqflask/other_config/nginx-old.conf108
-rw-r--r--wqflask/other_config/nginx_conf/gn2-lei.conf41
-rw-r--r--wqflask/other_config/nginx_conf/gn2-zach.conf52
-rw-r--r--wqflask/other_config/nginx_conf/gn2.conf41
-rw-r--r--wqflask/other_config/nginx_conf/gn2_sam.conf42
-rw-r--r--wqflask/other_config/nginx_conf/penguin.conf44
-rw-r--r--wqflask/other_config/pylintrc264
-rw-r--r--wqflask/wqflask/collect.py45
-rw-r--r--wqflask/wqflask/static/dbdoc/TODO.md1
-rw-r--r--wqflask/wqflask/user_manager.py57
22 files changed, 76 insertions, 1280 deletions
diff --git a/bin/mechnical-rob b/bin/mechnical-rob
deleted file mode 100755
index be223d94..00000000
--- a/bin/mechnical-rob
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/usr/bin/env ruby
-
-
-USAGE = <<EOT
-This is Mechanical-Rob - an automated web server tester for
- Genenetwork.org that uses the brilliant
- mechanize gem with minitest.
-
-To use this software you need to install mechanize. Run it from
-the root of the genenetwork2 source tree as, for example,
-
- ./bin/test-website http://localhost:5003/ (default)
-
-If you are using the small deployment database you can use
-
- ./bin/test-website --skip -n
-
-To run all tests
-
- ./bin/test-website --all
-
-To run individual tests on localhost you can do
-
- ruby -Itest -Itest/lib test/lib/mapping.rb --name="/Mapping/"
-
-For more information see http://genenetwork.org/
-
-EOT
-$stderr.print USAGE
-
-require 'optparse'
-
-options = { database: :small, link_checker: false}
-opts = OptionParser.new do |o|
- o.banner = "Usage: #{File.basename($0)} [options] URL"
-
- o.on('-d','--database', String, 'Use database (default db_webqtl_s)') do |s|
- options[:database] =
- case s
- when 'xx'
- :unknown
- else
- :small
- end
- end
-
- o.on('--all', 'Run all tests') do
- options[:all] = true
- end
-
- o.on('-l','--link-checker', 'Check for dead links') do
- options[:link_checker] = true
- end
-
- o.on('--navigation', 'Check for navigation') do
- options[:navigation] = true
- end
-
- o.on('--mapping', 'Check for mapping') do
- options[:mapping] = true
- end
-
- o.on('--skip-broken', 'Skip tests that are known to be broken') do
- options[:skip_broken] = true
- end
-
- o.separator ""
- o.on_tail('-h', '--help', 'display this help and exit') do
- options[:show_help] = true
- end
-end
-
-opts.parse!(ARGV)
-
-if options[:show_help]
- print opts
- exit 1
-end
-
-$options = options # we are using a global here
-$host =
- if ARGV.size>0
- ARGV.shift
- else
- "http://localhost:5003"
- end
-
-$stderr.print "Testing <",$host,">\n"
-
-require 'mechanize'
-require 'minitest/spec'
-require 'minitest/autorun'
-
-# These are the actual testing modules
-
-libpath = File.dirname(File.dirname(__FILE__))
-$: << File.join(libpath,'test/lib')
-
-require 'main_web_functionality'
-
-if options[:all] or options[:mapping]
- require 'mapping'
-end
-
-if options[:all] or options[:link_checker]
- require 'link_checker'
-end
-
-if options[:all] or options[:navigation]
- require 'navigation'
-end
diff --git a/etc/VERSION b/etc/VERSION
index ca9e199c..a4320e6f 100644
--- a/etc/VERSION
+++ b/etc/VERSION
@@ -1 +1 @@
-2.11-rc1
+2.11-rc2
diff --git a/etc/default_settings.py b/etc/default_settings.py
index a70d8aec..da8cbb7c 100644
--- a/etc/default_settings.py
+++ b/etc/default_settings.py
@@ -54,7 +54,7 @@ ORCID_TOKEN_URL = "UNKNOWN"
ELASTICSEARCH_HOST = "localhost"
ELASTICSEARCH_PORT = '9200'
-SMTP_CONNECT = "UNKNOWN"
+SMTP_CONNECT = "localhost"
SMTP_USERNAME = "UNKNOWN"
SMTP_PASSWORD = "UNKNOWN"
diff --git a/etc/nginx-genenetwork.conf b/etc/nginx-genenetwork.conf
deleted file mode 100644
index 06fd3c57..00000000
--- a/etc/nginx-genenetwork.conf
+++ /dev/null
@@ -1,54 +0,0 @@
-user nobody;
-worker_processes 4;
-pid /var/run/nginx.pid;
-
-error_log /var/log/nginx/error.log;
-
-events {
- worker_connections 16;
-}
-
-http {
- include mime.types;
- # default_type application/octet-stream;
-
- # sendfile on;
- keepalive_timeout 480;
-
- server {
- listen 80;
- server_name localhost;
-
- location / {
- root html;
- index index.html index.htm;
- }
-
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- }
-
- server {
- listen 80;
- server_name test-gn2.genenetwork.org;
- access_log logs/test-gn2.access.log;
-
- proxy_connect_timeout 3000;
- proxy_send_timeout 3000;
- proxy_read_timeout 3000;
- send_timeout 3000;
-
- location / {
- # proxy_set_header Host $host;
- proxy_set_header Host $http_host;
- # proxy_redirect off;
- proxy_set_header Connection keep-alive;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Host $server_name;
- proxy_pass http://127.0.0.1:5003;
- }
- }
-}
diff --git a/test/lib/gntest.rb b/test/lib/gntest.rb
deleted file mode 100644
index 5b21b3d5..00000000
--- a/test/lib/gntest.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require 'minitest/autorun'
-require 'mechanize'
-require 'json'
-
-# ---- Use some default parameters if not set
-$host = "http://localhost:5003" if !$host
diff --git a/test/lib/link_checker.rb b/test/lib/link_checker.rb
deleted file mode 100644
index 36cb36c8..00000000
--- a/test/lib/link_checker.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-
-SKIP = "mailto:"
-
-class LinkChecker
-end
-
-describe LinkChecker do
- before do
- @agent = Mechanize.new
- @agent.agent.http.ca_file = '/etc/ssl/certs/ca-certificates.crt'
- end
-
- it "Get to front page" do
- page = @agent.get($host)
- page.links.each do |link|
- puts link.href
- if link.href !~ /#{SKIP}/ # /static\/dbdoc\/Hippocampus/ and link.href !~ /mailto:|glossary.html|sample_r|grits.eecs.utk.edu|correlationAnnotation.html/
- # Fetch link, program will crash with exception if link is broken
- linkpage = @agent.get(link.href)
- puts "Link to #{link.href} is valid, response code #{linkpage.code}"
- end
- end
-
- end
-
- describe LinkChecker do
- it "Get to trait page" do
- page = @agent.get($host+'/show_trait?trait_id=1435395_s_at&dataset=HC_M2_0606_P')
- # p page
-
- # Get to trait page for 1435395_s_at
- # form2 = show_trait_page.forms_with("trait_page")[0]
- # form2.fields[30].name.must_equal "variance:C57BL/6J"
- # form2.fields[30].value.must_equal "15.287"
-
- # Test every link on the page to check if it's broken or not
- page.links.each do |link|
- puts link.href
- if link.href !~ /#{SKIP}/ # /static\/dbdoc\/Hippocampus/ and link.href !~ /mailto:|glossary.html|sample_r|grits.eecs.utk.edu|correlationAnnotation.html/
- # Fetch link, program will crash with exception if link is broken
- linkpage = @agent.get(link.href)
- puts "Link to #{link.href} is valid, response code #{linkpage.code}"
- end
- end
-
- end
-
- end
-
-end
diff --git a/test/lib/main_web_functionality.rb b/test/lib/main_web_functionality.rb
deleted file mode 100644
index 9ae49995..00000000
--- a/test/lib/main_web_functionality.rb
+++ /dev/null
@@ -1,62 +0,0 @@
-# In these tests we navigate from the main page to search
-
-class MainWebFunctionality
-end
-
-describe MainWebFunctionality do
- before do
- @agent = Mechanize.new
- @agent.agent.http.ca_file = '/etc/ssl/certs/ca-certificates.crt'
- end
-
- describe MainWebFunctionality do
-
- it "Get to trait page" do
- page = @agent.get($host)
- p page
- form = page.forms[1]
- form.buttons[0].value.must_equal "Search" # main menu is loaded
-
- # http://localhost:5003/search?species=mouse&group=BXD&type=Hippocampus+mRNA&dataset=HC_M2_0606_P&search_terms_or=&search_terms_and=MEAN%3D%2815+16%29+LRS%3D%2823+46%29&FormID=searchResult
- form.fields[0].value.must_equal "searchResult"
- form.fields[2].value = "MEAN=(15 16) LRS=(23 46)"
- form.fields[3].value = "mouse"
- form.fields[4].value = "BXD"
- form.fields[5].value = "Hippocampus mRNA"
- form.fields[6].value = "HC_M2_0606_P"
- search_page = @agent.submit(form, form.buttons.first)
- p "=================="
- p search_page
- probe_link = search_page.links.find { |l| l.text =~ /1435395_s_at/ }
- probe_link.uri.to_s.must_equal "/show_trait?trait_id=1435395_s_at&dataset=HC_M2_0606_P"
- show_trait_page = probe_link.click
- # p show_trait_page
-
- # Get to trait page for 1435395_s_at
-
- form2 = show_trait_page.forms_with("trait_page")[0]
- # [name: corr_dataset value: HC_M2_0606_P]
- form2.fields.select { |fld| fld.name == 'corr_dataset' }.first.value.must_equal 'HC_M2_0606_P'
- if $options[:database] == :small
- form2.fields[30].name.must_equal "value:DBA/2J"
- else
- form2.fields[30].name.must_equal "variance:C57BL/6J"
- end
- # form2.fields[30].value.must_equal "15.287"
-
- # Test every link on the page to check if it's broken or not
- break if not $options[:link_checker]
- show_trait_page.links.each do |link|
- puts link.href
- if link.href !~ /static\/dbdoc\/Hippocampus/ and link.href !~ /glossary.html|sample_r|grits.eecs.utk.edu|correlationAnnotation.html/
- # Fetch link, program will crash with exception if link is broken
- linkpage = @agent.get(link.href)
- puts "Link to #{link.href} is valid, response code #{linkpage.code}"
- end
- end
-
- end
-
- end
-
-end
diff --git a/test/lib/mapping.rb b/test/lib/mapping.rb
deleted file mode 100644
index 20e5bd40..00000000
--- a/test/lib/mapping.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-# In these tests we navigate from the main page to a specific trait then hit the different mapping tool buttons (In this case pylMM and r/qtl) followed by computing the results (marker regressions).
-
-require 'gntest'
-
-class MappingTest
-end
-
-describe MappingTest do
- before do
- @agent = Mechanize.new
- @agent.agent.http.ca_file = '/etc/ssl/certs/ca-certificates.crt'
- end
-
- describe MappingTest do
- it "pylmm mapping tool selection" do
- url = $host+'/marker_regression'
-
- json = JSON::load(File.read('test/data/input/mapping/1435395_s_at_HC_M2_0606_P.json'))
- json["method"] = "pylmm"
- # p json
- page = @agent.post(URI.encode(url), json)
- # Unpacking the page is slow - somehow - but the run is enough as a test
- # form = page.forms_with("marker_regression")[0]
- # form.fields.select { |fld| fld.name == 'dataset' }.first.value.must_equal 'HC_M2_0606_P'
- # form.fields.select { |fld| fld.name == 'value:BXD1' }.first.value.must_equal '6.749'
- end
- end
-
- describe MappingTest do
- it "R/qtl mapping tool selection" do
- url = $host+'/marker_regression' # ?trait_id=1435395_s_at&dataset=HC_M2_0606_P'
-
- json = JSON::load(File.read('test/data/input/mapping/1435395_s_at_HC_M2_0606_P.json'))
- # p json
- page = @agent.post(URI.encode(url),
- json,
- ({'Content-Type' => 'application/x-www-form-urlencoded'}))
- form = page.forms_with("marker_regression")[0]
- p form
- form.fields.select { |fld| fld.name == 'dataset' }.first.value.must_equal 'HC_M2_0606_P'
- form.fields.select { |fld| fld.name == 'value:BXD1' }.first.value.must_equal "15.034"
- end
- end
-
- describe MappingTest do
- it "CIM mapping tool selection (using reaper)" do
- url = $host+'/marker_regression'
-
- json = JSON::load(File.read('test/data/input/mapping/1435395_s_at_HC_M2_0606_P.json'))
- json["method"] = "reaper"
- page = @agent.post(URI.encode(url), json)
- form = page.forms_with("marker_regression")[0]
- form.fields.select { |fld| fld.name == 'dataset' }.first.value.must_equal 'HC_M2_0606_P'
- form.fields.select { |fld| fld.name == 'value:BXD1' }.first.value.must_equal "15.034"
- end
- end
-
-end
diff --git a/test/lib/navigation.rb b/test/lib/navigation.rb
deleted file mode 100644
index ee9f41d2..00000000
--- a/test/lib/navigation.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# In these tests we navigate from the main page to a specific trait then hit the different mapping tool buttons (In this case pylMM and r/qtl) followed by computing the results (marker regressions).
-
-
-class MappingTest
-end
-
-describe MappingTest do
- before do
- @agent = Mechanize.new
- @agent.agent.http.ca_file = '/etc/ssl/certs/ca-certificates.crt'
- end
-
- describe MappingTest do
- it "pyLMM mapping tool selection" do
- break if $options[:skip_broken]
- page = @agent.get($host+'/show_trait?trait_id=1435395_s_at&dataset=HC_M2_0606_P')
-#Navigates to http://localhost:5003/show_trait?trait_id=1435395_s_at&dataset=HC_M2_0606_P and clicks respective buttons.
- link = page.link_with(text: 'pyLMM')
- page = link.click
- puts page.uri
- link = page.link_with(text: 'Compute')
- page = link.click
- puts page.uri
- probe_link.uri.to_s.must_equal "/marker_regression"
- end
- end
-
-end
-
-describe MappingTest do
- it "R/qtl mapping tool selection" do
- break if $options[:skip_broken]
- page = @agent.get($host+'/show_trait?trait_id=1435395_s_at&dataset=HC_M2_0606_P')
- link = page.link_with(text: 'R/qtl')
- page = link.click
- puts page.uri
- form.field_with(:name => 'Methods').options[2].select
- link = page.link_with(text: 'Compute')
- page = link.click
- puts page.uri
- probe_link.uri.to_s.must_equal "/marker_regression"
- end
-end
diff --git a/test/requests/link_checker.py b/test/requests/link_checker.py
index 256bf6ef..64553ed8 100644
--- a/test/requests/link_checker.py
+++ b/test/requests/link_checker.py
@@ -4,6 +4,8 @@ import requests
from lxml.html import parse
from requests.exceptions import ConnectionError
+DO_FAIL=False # fail on error
+
def is_root_link(link):
pattern = re.compile("^/$")
return pattern.match(link)
@@ -25,24 +27,34 @@ def get_links(doc):
, doc.cssselect("a")))
def verify_link(link):
+ if link[0] == "#":
+ # local link on page
+ return
+ print("verifying "+link)
try:
- result = requests.get(link, timeout=20)
+ result = requests.get(link, timeout=20, verify=False)
if result.status_code == 200:
print(link+" ==> OK")
+ elif result.status_code == 307:
+ print(link+" ==> REDIRECT")
else:
print("ERROR: link `"+link+"` failed with status "
, result.status_code)
+ if DO_FAIL:
+ raise Exception("Failed verify")
except ConnectionError as ex:
print("ERROR: ", link, ex)
+ if DO_FAIL:
+ raise ex
def check_page(host, start_url):
print("")
- print("Checking links in page `"+start_url+"`")
+ print("Checking links host "+host+" in page `"+start_url+"`")
doc = parse(start_url).getroot()
links = get_links(doc)
internal_links = filter(is_internal_link, links)
external_links = filter(lambda x: not is_internal_link(x), links)
- external_links.append("http://somenon-existentsite.brr")
+ # external_links.append("http://somenon-existentsite.brr")
for link in internal_links:
verify_link(host+link)
diff --git a/test/requests/test-website.py b/test/requests/test-website.py
index 2bef6eb1..118c9df1 100755
--- a/test/requests/test-website.py
+++ b/test/requests/test-website.py
@@ -8,12 +8,16 @@ import argparse
from link_checker import check_links
from mapping_tests import check_mapping
from main_web_functionality import check_main_web_functionality
+import link_checker
+import sys
print("Mechanical Rob firing up...")
def run_all(args_obj, parser):
print("")
print("Running all tests.")
+ print(args_obj)
+ link_checker.DO_FAIL = args_obj.fail
check_main_web_functionality(args_obj, parser)
check_links(args_obj, parser)
check_mapping(args_obj, parser)
@@ -32,6 +36,8 @@ This is Mechanical-Rob - an automated web server tester for
"""
parser = argparse.ArgumentParser(description=desc)
+parser.add_argument("--fail", help="Fail and stop on any error", action="store_true")
+
parser.add_argument("-d", "--database", metavar="DB", type=str
, default="db_webqtl_s"
, help="Use database (default db_webqtl_s)")
diff --git a/wqflask/other_config/dot.pylintrc b/wqflask/other_config/dot.pylintrc
deleted file mode 100644
index 2774300a..00000000
--- a/wqflask/other_config/dot.pylintrc
+++ /dev/null
@@ -1,249 +0,0 @@
-[MASTER]
-
-# Specify a configuration file.
-#rcfile=
-
-# Python code to execute, usually for sys.path manipulation such as
-# pygtk.require().
-#init-hook=
-
-# Profiled execution.
-profile=no
-
-# Add files or directories to the blacklist. They should be base names, not
-# paths.
-ignore=CVS
-
-# Pickle collected data for later comparisons.
-persistent=yes
-
-# List of plugins (as comma separated values of python modules names) to load,
-# usually to register additional checkers.
-load-plugins=
-
-
-[MESSAGES CONTROL]
-
-# Enable the message, report, category or checker with the given id(s). You can
-# either give multiple identifier separated by comma (,) or put this option
-# multiple time.
-#enable=
-
-# Disable the message, report, category or checker with the given id(s). You
-# can either give multiple identifier separated by comma (,) or put this option
-# multiple time (only on the command line, not in the configuration file where
-# it should appear only once).
-#disable=
-
-
-[REPORTS]
-
-# Set the output format. Available formats are text, parseable, colorized, msvs
-# (visual studio) and html
-output-format=colorized
-
-# Include message's id in output
-include-ids=no
-
-# Put messages in a separate file for each module / package specified on the
-# command line instead of printing them on stdout. Reports (if any) will be
-# written in a file name "pylint_global.[txt|html]".
-files-output=no
-
-# Tells whether to display a full report or only the messages
-reports=yes
-
-# Python expression which should return a note less than 10 (10 is the highest
-# note). You have access to the variables errors warning, statement which
-# respectively contain the number of errors / warnings messages and the total
-# number of statements analyzed. This is used by the global evaluation report
-# (RP0004).
-evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
-
-# Add a comment according to your evaluation note. This is used by the global
-# evaluation report (RP0004).
-comment=no
-
-
-[MISCELLANEOUS]
-
-# List of note tags to take in consideration, separated by a comma.
-notes=FIXME,XXX,TODO
-
-
-[TYPECHECK]
-
-# Tells whether missing members accessed in mixin class should be ignored. A
-# mixin class is detected if its name ends with "mixin" (case insensitive).
-ignore-mixin-members=yes
-
-# List of classes names for which member attributes should not be checked
-# (useful for classes with attributes dynamically set).
-ignored-classes=SQLObject
-
-# When zope mode is activated, add a predefined set of Zope acquired attributes
-# to generated-members.
-zope=no
-
-# List of members which are set dynamically and missed by pylint inference
-# system, and so shouldn't trigger E0201 when accessed. Python regular
-# expressions are accepted.
-generated-members=REQUEST,acl_users,aq_parent
-
-
-[SIMILARITIES]
-
-# Minimum lines number of a similarity.
-min-similarity-lines=4
-
-# Ignore comments when computing similarities.
-ignore-comments=yes
-
-# Ignore docstrings when computing similarities.
-ignore-docstrings=yes
-
-
-[BASIC]
-
-# Required attributes for module, separated by a comma
-required-attributes=
-
-# List of builtins function names that should not be used, separated by a comma
-bad-functions=map,filter,apply,input
-
-# Regular expression which should only match correct module names
-module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
-
-# Regular expression which should only match correct module level names
-const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
-
-# Regular expression which should only match correct class names
-class-rgx=[A-Z_][a-zA-Z0-9]+$
-
-# Regular expression which should only match correct function names
-function-rgx=[a-z_][a-z0-9_]{2,30}$
-
-# Regular expression which should only match correct method names
-method-rgx=[a-z_][a-z0-9_]{2,30}$
-
-# Regular expression which should only match correct instance attribute names
-attr-rgx=[a-z_][a-z0-9_]{2,30}$
-
-# Regular expression which should only match correct argument names
-argument-rgx=[a-z_][a-z0-9_]{2,30}$
-
-# Regular expression which should only match correct variable names
-variable-rgx=[a-z_][a-z0-9_]{2,30}$
-
-# Regular expression which should only match correct list comprehension /
-# generator expression variable names
-inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
-
-# Good variable names which should always be accepted, separated by a comma
-good-names=i,j,k,ex,Run,_
-
-# Bad variable names which should always be refused, separated by a comma
-bad-names=foo,bar,baz,toto,tutu,tata
-
-# Regular expression which should only match functions or classes name which do
-# not require a docstring
-no-docstring-rgx=__.*__
-
-
-[VARIABLES]
-
-# Tells whether we should check for unused import in __init__ files.
-init-import=no
-
-# A regular expression matching the beginning of the name of dummy variables
-# (i.e. not used).
-dummy-variables-rgx=_|dummy
-
-# List of additional names supposed to be defined in builtins. Remember that
-# you should avoid to define new builtins when possible.
-additional-builtins=
-
-
-[FORMAT]
-
-# Maximum number of characters on a single line.
-max-line-length=100
-
-# Maximum number of lines in a module
-max-module-lines=1000
-
-# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
-# tab).
-indent-string=' '
-
-
-[IMPORTS]
-
-# Deprecated modules which should not be used, separated by a comma
-deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
-
-# Create a graph of every (i.e. internal and external) dependencies in the
-# given file (report RP0402 must not be disabled)
-import-graph=
-
-# Create a graph of external dependencies in the given file (report RP0402 must
-# not be disabled)
-ext-import-graph=
-
-# Create a graph of internal dependencies in the given file (report RP0402 must
-# not be disabled)
-int-import-graph=
-
-
-[DESIGN]
-
-# Maximum number of arguments for function / method
-max-args=5
-
-# Argument names that match this expression will be ignored. Default to name
-# with leading underscore
-ignored-argument-names=_.*
-
-# Maximum number of locals for function / method body
-max-locals=15
-
-# Maximum number of return / yield for function / method body
-max-returns=6
-
-# Maximum number of branch for function / method body
-max-branchs=12
-
-# Maximum number of statements in function / method body
-max-statements=50
-
-# Maximum number of parents for a class (see R0901).
-max-parents=7
-
-# Maximum number of attributes for a class (see R0902).
-max-attributes=7
-
-# Minimum number of public methods for a class (see R0903).
-min-public-methods=2
-
-# Maximum number of public methods for a class (see R0904).
-max-public-methods=20
-
-
-[CLASSES]
-
-# List of interface methods to ignore, separated by a comma. This is used for
-# instance to not check methods defines in Zope's Interface base class.
-ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
-
-# List of method names used to declare (i.e. assign) instance attributes.
-defining-attr-methods=__init__,__new__,setUp
-
-# List of valid names for the first argument in a class method.
-valid-classmethod-first-arg=cls
-
-
-[EXCEPTIONS]
-
-# Exceptions that will emit a warning when being caught. Defaults to
-# "Exception"
-overgeneral-exceptions=Exception
diff --git a/wqflask/other_config/nginx-old.conf b/wqflask/other_config/nginx-old.conf
deleted file mode 100644
index 65ee768c..00000000
--- a/wqflask/other_config/nginx-old.conf
+++ /dev/null
@@ -1,108 +0,0 @@
-
-#user nobody;
-worker_processes 1;
-
-#error_log logs/error.log;
-#error_log logs/error.log notice;
-#error_log logs/error.log info;
-
-#pid logs/nginx.pid;
-
-
-events {
- worker_connections 1024;
-}
-
-
-http {
- include mime.types;
- default_type application/octet-stream;
-
- #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- # '$status $body_bytes_sent "$http_referer" '
- # '"$http_user_agent" "$http_x_forwarded_for"';
-
- #access_log logs/access.log main;
-
- sendfile on;
- #tcp_nopush on;
-
- #keepalive_timeout 0;
- keepalive_timeout 65;
-
- gzip on;
-
- server {
- # Modeled after http://flask.pocoo.org/docs/deploying/wsgi-standalone/
- listen 80;
-
- server_name _;
-
- access_log /var/log/nginx/access.log;
- error_log /var/log/nginx/error.log;
-
- location ^~ /css/ {
- root /home/sam/gene/wqflask/wqflask/static/;
- }
-
- location ^~ /javascript/ {
- root /home/sam/gene/wqflask/wqflask/static/;
- }
-
-# location ^~ /image/ {
-# root /home/sam/gene/wqflask/wqflask/static/;
-# }
-
- location ^~ /images/ {
- root /home/sam/gene/wqflask/wqflask/static/;
- }
-
- location / {
- proxy_pass http://127.0.0.1:5000/;
- proxy_redirect off;
-
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- }
-
- }
-
-
- # another virtual host using mix of IP-, name-, and port-based configuration
- #
- #server {
- # listen 8000;
- # listen somename:8080;
- # server_name somename alias another.alias;
-
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
-
-
- # HTTPS server
- #
- #server {
- # listen 443;
- # server_name localhost;
-
- # ssl on;
- # ssl_certificate cert.pem;
- # ssl_certificate_key cert.key;
-
- # ssl_session_timeout 5m;
-
- # ssl_protocols SSLv2 SSLv3 TLSv1;
- # ssl_ciphers HIGH:!aNULL:!MD5;
- # ssl_prefer_server_ciphers on;
-
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
-
-}
diff --git a/wqflask/other_config/nginx_conf/gn2-lei.conf b/wqflask/other_config/nginx_conf/gn2-lei.conf
deleted file mode 100644
index 893ad435..00000000
--- a/wqflask/other_config/nginx_conf/gn2-lei.conf
+++ /dev/null
@@ -1,41 +0,0 @@
-server {
- # Modeled after http://flask.pocoo.org/docs/deploying/wsgi-standalone/
- listen 80;
-
- server_name gn2-lei.genenetwork.org;
-
- access_log /var/log/nginx/lei_access.log;
- error_log /var/log/nginx/lei_error.log;
-
- location ^~ /css/ {
- root /gene/wqflask/wqflask/static/;
- }
-
- location ^~ /javascript/ {
- root /gene/wqflask/wqflask/static/;
- }
-
-# location ^~ /image/ {
-# root /gene/wqflask/wqflask/static/;
-# }
-
- location ^~ /images/ {
- root /gene/wqflask/wqflask/static/;
- }
-
- ### New - added by Sam
- #location ^~ /static/ {
- # root /gene/wqflask/wqflask/static/;
- #}
-
- location / {
- proxy_pass http://127.0.0.1:5001/;
- proxy_redirect off;
-
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
- proxy_read_timeout 40m;
- }
-}
diff --git a/wqflask/other_config/nginx_conf/gn2-zach.conf b/wqflask/other_config/nginx_conf/gn2-zach.conf
deleted file mode 100644
index 38347292..00000000
--- a/wqflask/other_config/nginx_conf/gn2-zach.conf
+++ /dev/null
@@ -1,52 +0,0 @@
-server {
- # Modeled after http://flask.pocoo.org/docs/deploying/wsgi-standalone/
- listen 80;
-
- server_name gn2-zach.genenetwork.org;
-
- access_log /var/log/nginx/access.log;
- error_log /var/log/nginx/error.log;
-
- location ^~ /css/ {
- root /gene/wqflask/wqflask/static/;
- }
-
- location ^~ /javascript/ {
- root /gene/wqflask/wqflask/static/;
- }
-
-# location ^~ /image/ {
-# root /gene/wqflask/wqflask/static/;
-# }
-
- location ^~ /images/ {
- root /gene/wqflask/wqflask/static/;
- }
-
- ### New - added by Sam
- #location ^~ /static/ {
- # root /gene/wqflask/wqflask/static/;
- #}
-
- location /plink_gemma/ {
- root /home/zas1024/gene/wqflask/wqflask/;
- autoindex on;
- }
-
- location /download/ {
- root /home/zas1024/gene/wqflask/wqflask/;
- autoindex on;
- }
-
- location / {
- proxy_pass http://127.0.0.1:5002/;
- proxy_redirect off;
-
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
- proxy_read_timeout 40m;
- }
-}
-
diff --git a/wqflask/other_config/nginx_conf/gn2.conf b/wqflask/other_config/nginx_conf/gn2.conf
deleted file mode 100644
index a51b4113..00000000
--- a/wqflask/other_config/nginx_conf/gn2.conf
+++ /dev/null
@@ -1,41 +0,0 @@
-server {
- # Modeled after http://flask.pocoo.org/docs/deploying/wsgi-standalone/
- listen 80;
-
- server_name gn2.genenetwork.org;
-
- access_log /var/log/nginx/access.log;
- error_log /var/log/nginx/error.log;
-
- location ^~ /css/ {
- root /gene/wqflask/wqflask/static/;
- }
-
- location ^~ /javascript/ {
- root /gene/wqflask/wqflask/static/;
- }
-
-# location ^~ /image/ {
-# root /gene/wqflask/wqflask/static/;
-# }
-
- location ^~ /images/ {
- root /gene/wqflask/wqflask/static/;
- }
-
- ### New - added by Sam
- #location ^~ /static/ {
- # root /gene/wqflask/wqflask/static/;
- #}
-
- location / {
- proxy_pass http://127.0.0.1:5000/;
- proxy_redirect off;
-
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
- proxy_read_timeout 40m;
- }
-}
diff --git a/wqflask/other_config/nginx_conf/gn2_sam.conf b/wqflask/other_config/nginx_conf/gn2_sam.conf
deleted file mode 100644
index f9abbbd2..00000000
--- a/wqflask/other_config/nginx_conf/gn2_sam.conf
+++ /dev/null
@@ -1,42 +0,0 @@
-server {
- # Modeled after http://flask.pocoo.org/docs/deploying/wsgi-standalone/
- listen 80;
-
- server_name gn2_sam.genenetwork.org;
-
- access_log /var/log/nginx/access.log;
- error_log /var/log/nginx/error.log;
-
- location ^~ /css/ {
- root /gene/wqflask/wqflask/static/;
- }
-
- location ^~ /javascript/ {
- root /gene/wqflask/wqflask/static/;
- }
-
-# location ^~ /image/ {
-# root /gene/wqflask/wqflask/static/;
-# }
-
- location ^~ /images/ {
- root /gene/wqflask/wqflask/static/;
- }
-
- ### New - added by Sam
- #location ^~ /static/ {
- # root /gene/wqflask/wqflask/static/;
- #}
-
- location / {
- proxy_pass http://127.0.0.1:5005/;
- proxy_redirect off;
-
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
- proxy_read_timeout 40m;
- }
-}
-
diff --git a/wqflask/other_config/nginx_conf/penguin.conf b/wqflask/other_config/nginx_conf/penguin.conf
deleted file mode 100644
index c819951c..00000000
--- a/wqflask/other_config/nginx_conf/penguin.conf
+++ /dev/null
@@ -1,44 +0,0 @@
-server {
- # Modeled after http://flask.pocoo.org/docs/deploying/wsgi-standalone/
-
- client_max_body_size 20M;
- listen 80;
-
- server_name penguin.uthsc.edu;
-
- access_log /var/log/nginx/access.log;
- error_log /var/log/nginx/error.log;
-
- location ^~ /css/ {
- root /gene/wqflask/wqflask/static/;
- }
-
- location ^~ /javascript/ {
- root /gene/wqflask/wqflask/static/;
- }
-
-# location ^~ /image/ {
-# root /gene/wqflask/wqflask/static/;
-# }
-
- location ^~ /images/ {
- root /gene/wqflask/wqflask/static/;
- }
-
- ### New - added by Sam
- #location ^~ /static/ {
- # root /gene/wqflask/wqflask/static/;
- #}
-
- location / {
- proxy_pass http://127.0.0.1:5000/;
- proxy_redirect off;
-
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
- proxy_read_timeout 40m;
- }
-}
-
diff --git a/wqflask/other_config/pylintrc b/wqflask/other_config/pylintrc
deleted file mode 100644
index b23af7a4..00000000
--- a/wqflask/other_config/pylintrc
+++ /dev/null
@@ -1,264 +0,0 @@
-[MASTER]
-
-# Specify a configuration file.
-#rcfile=
-
-# Python code to execute, usually for sys.path manipulation such as
-# pygtk.require().
-#init-hook=
-
-# Profiled execution.
-profile=no
-
-# Add files or directories to the blacklist. They should be base names, not
-# paths.
-ignore=CVS
-
-# Pickle collected data for later comparisons.
-persistent=yes
-
-# List of plugins (as comma separated values of python modules names) to load,
-# usually to register additional checkers.
-load-plugins=
-
-
-[MESSAGES CONTROL]
-
-# Enable the message, report, category or checker with the given id(s). You can
-# either give multiple identifier separated by comma (,) or put this option
-# multiple time. See also the "--disable" option for examples.
-#enable=
-
-# Disable the message, report, category or checker with the given id(s). You
-# can either give multiple identifiers separated by comma (,) or put this
-# option multiple times (only on the command line, not in the configuration
-# file where it should appear only once).You can also use "--disable=all" to
-# disable everything first and then reenable specific checks. For example, if
-# you want to run only the similarities checker, you can use "--disable=all
-# --enable=similarities". If you want to run only the classes checker, but have
-# no Warning level messages displayed, use"--disable=all --enable=classes
-# --disable=W"
-disable=no-init, star-args, no-member, import-error
-
-
-[REPORTS]
-
-# Set the output format. Available formats are text, parseable, colorized, msvs
-# (visual studio) and html. You can also give a reporter class, eg
-# mypackage.mymodule.MyReporterClass.
-output-format=text
-
-# Include message's id in output
-include-ids=no
-
-# Include symbolic ids of messages in output
-symbols=no
-
-# Put messages in a separate file for each module / package specified on the
-# command line instead of printing them on stdout. Reports (if any) will be
-# written in a file name "pylint_global.[txt|html]".
-files-output=no
-
-# Tells whether to display a full report or only the messages
-reports=yes
-
-# Python expression which should return a note less than 10 (10 is the highest
-# note). You have access to the variables errors warning, statement which
-# respectively contain the number of errors / warnings messages and the total
-# number of statements analyzed. This is used by the global evaluation report
-# (RP0004).
-evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
-
-# Add a comment according to your evaluation note. This is used by the global
-# evaluation report (RP0004).
-comment=no
-
-
-[SIMILARITIES]
-
-# Minimum lines number of a similarity.
-min-similarity-lines=4
-
-# Ignore comments when computing similarities.
-ignore-comments=yes
-
-# Ignore docstrings when computing similarities.
-ignore-docstrings=yes
-
-# Ignore imports when computing similarities.
-ignore-imports=no
-
-
-[VARIABLES]
-
-# Tells whether we should check for unused import in __init__ files.
-init-import=no
-
-# A regular expression matching the beginning of the name of dummy variables
-# (i.e. not used).
-dummy-variables-rgx=_|dummy
-
-# List of additional names supposed to be defined in builtins. Remember that
-# you should avoid to define new builtins when possible.
-additional-builtins=
-
-
-[BASIC]
-
-# Required attributes for module, separated by a comma
-required-attributes=
-
-# List of builtins function names that should not be used, separated by a comma
-bad-functions=map,filter,apply,input
-
-# Regular expression which should only match correct module names
-module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
-
-# Regular expression which should only match correct module level names
-const-rgx=(([A-Z_][A-Za-z0-9_]*)|(__.*__))$
-
-# Regular expression which should only match correct class names
-class-rgx=[A-Z_][a-zA-Z0-9]+$
-
-# Regular expression which should only match correct function names
-function-rgx=[a-z_][a-z0-9_]{2,30}$
-
-# Regular expression which should only match correct method names
-method-rgx=[a-z_][a-z0-9_]{2,30}$
-
-# Regular expression which should only match correct instance attribute names
-attr-rgx=[a-z_][a-z0-9_]{2,30}$
-
-# Regular expression which should only match correct argument names
-argument-rgx=[a-z_][a-z0-9_]{2,30}$
-
-# Regular expression which should only match correct variable names
-variable-rgx=[a-z_][a-z0-9_]{2,30}$
-
-# Regular expression which should only match correct list comprehension /
-# generator expression variable names
-inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
-
-# Good variable names which should always be accepted, separated by a comma
-good-names=i,j,k,ex,Run,_
-
-# Bad variable names which should always be refused, separated by a comma
-bad-names=foo,bar,baz,toto,tutu,tata
-
-# Regular expression which should only match functions or classes name which do
-# not require a docstring
-no-docstring-rgx=__.*__
-
-
-[FORMAT]
-
-# Maximum number of characters on a single line.
-max-line-length=100
-
-# Maximum number of lines in a module
-max-module-lines=1000
-
-# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
-# tab).
-indent-string=' '
-
-
-[MISCELLANEOUS]
-
-# List of note tags to take in consideration, separated by a comma.
-notes=FIXME,XXX,TODO
-
-
-[TYPECHECK]
-
-# Tells whether missing members accessed in mixin class should be ignored. A
-# mixin class is detected if its name ends with "mixin" (case insensitive).
-ignore-mixin-members=yes
-
-# List of classes names for which member attributes should not be checked
-# (useful for classes with attributes dynamically set).
-ignored-classes=SQLObject
-
-# When zope mode is activated, add a predefined set of Zope acquired attributes
-# to generated-members.
-zope=no
-
-# List of members which are set dynamically and missed by pylint inference
-# system, and so shouldn't trigger E0201 when accessed. Python regular
-# expressions are accepted.
-generated-members=REQUEST,acl_users,aq_parent
-
-
-[DESIGN]
-
-# Maximum number of arguments for function / method
-max-args=5
-
-# Argument names that match this expression will be ignored. Default to name
-# with leading underscore
-ignored-argument-names=_.*
-
-# Maximum number of locals for function / method body
-max-locals=15
-
-# Maximum number of return / yield for function / method body
-max-returns=6
-
-# Maximum number of branch for function / method body
-max-branchs=12
-
-# Maximum number of statements in function / method body
-max-statements=50
-
-# Maximum number of parents for a class (see R0901).
-max-parents=7
-
-# Maximum number of attributes for a class (see R0902).
-max-attributes=7
-
-# Minimum number of public methods for a class (see R0903).
-min-public-methods=2
-
-# Maximum number of public methods for a class (see R0904).
-max-public-methods=20
-
-
-[IMPORTS]
-
-# Deprecated modules which should not be used, separated by a comma
-deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
-
-# Create a graph of every (i.e. internal and external) dependencies in the
-# given file (report RP0402 must not be disabled)
-import-graph=
-
-# Create a graph of external dependencies in the given file (report RP0402 must
-# not be disabled)
-ext-import-graph=
-
-# Create a graph of internal dependencies in the given file (report RP0402 must
-# not be disabled)
-int-import-graph=
-
-
-[CLASSES]
-
-# List of interface methods to ignore, separated by a comma. This is used for
-# instance to not check methods defines in Zope's Interface base class.
-ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
-
-# List of method names used to declare (i.e. assign) instance attributes.
-defining-attr-methods=__init__,__new__,setUp
-
-# List of valid names for the first argument in a class method.
-valid-classmethod-first-arg=cls
-
-# List of valid names for the first argument in a metaclass class method.
-valid-metaclass-classmethod-first-arg=mcs
-
-
-[EXCEPTIONS]
-
-# Exceptions that will emit a warning when being caught. Defaults to
-# "Exception"
-overgeneral-exceptions=Exception
diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py
index 0f72b29d..ffc698de 100644
--- a/wqflask/wqflask/collect.py
+++ b/wqflask/wqflask/collect.py
@@ -36,6 +36,10 @@ from utility.formatting import numify
from base import trait
from base.data_set import create_dataset
+import logging
+from utility.logger import getLogger
+logger = getLogger(__name__)
+
def get_collection():
if g.user_session.logged_in:
return UserCollection()
@@ -93,7 +97,7 @@ class AnonCollection(object):
self.traits = list(process_traits(params['traits']))
#len_before = len(Redis.smembers(self.key))
existing_collections = Redis.get(self.key)
- print("existing_collections:", existing_collections)
+ logger.debug("existing_collections:", existing_collections)
if existing_collections != None and existing_collections != "None":
collections_list = json.loads(existing_collections)
collection_position = 0 #ZS: Position of collection in collection_list, if it exists
@@ -158,8 +162,8 @@ class UserCollection(object):
"""User is logged in"""
def add_traits(self, params, collection_name):
- print("---> params are:", params.keys())
- print(" type(params):", type(params))
+ logger.debug("---> params are:", params.keys())
+ logger.debug(" type(params):", type(params))
if collection_name=="Default":
uc = g.user_session.user_ob.get_collection_by_name("Default")
# Doesn't exist so we'll create it
@@ -187,7 +191,7 @@ class UserCollection(object):
db_session.commit()
- print("added to existing, now set is:" + str(uc.members))
+ logger.debug("added to existing, now set is:" + str(uc.members))
report_change(len_before, len_now)
# Probably have to change that
@@ -210,12 +214,12 @@ def process_traits(unprocessed_traits):
def report_change(len_before, len_now):
new_length = len_now - len_before
if new_length:
- print("We've added {} to your collection.".format(
+ logger.debug("We've added {} to your collection.".format(
numify(new_length, 'new trait', 'new traits')))
flash("We've added {} to your collection.".format(
numify(new_length, 'new trait', 'new traits')))
else:
- print("No new traits were added.")
+ logger.debug("No new traits were added.")
@app.route("/collections/add")
@@ -223,8 +227,9 @@ def collections_add():
traits=request.args['traits']
if g.user_session.logged_in:
+ logger.debug("user_session",g.user_session)
user_collections = g.user_session.user_ob.user_collections
- print("user_collections are:", user_collections)
+ logger.debug("user_collections are:", user_collections)
return render_template("collections/add.html",
traits = traits,
collections = user_collections,
@@ -246,11 +251,11 @@ def collections_new():
if "sign_in" in params:
return redirect(url_for('login'))
if "create_new" in params:
- print("in create_new")
+ logger.debug("in create_new")
collection_name = params['new_collection']
return create_new(collection_name)
elif "add_to_existing" in params:
- print("in add to existing")
+ logger.debug("in add to existing")
collection_name = params['existing_collection'].split(":")[1]
if g.user_session.logged_in:
return UserCollection().add_traits(params, collection_name)
@@ -270,7 +275,7 @@ def create_new(collection_name):
if g.user_session.logged_in:
uc = model.UserCollection()
uc.name = collection_name
- print("user_session:", g.user_session.__dict__)
+ logger.debug("user_session:", g.user_session.__dict__)
uc.user = g.user_session.user_id
uc.members = json.dumps(list(traits))
db_session.add(uc)
@@ -286,17 +291,17 @@ def create_new(collection_name):
@app.route("/collections/list")
def list_collections():
params = request.args
- print("PARAMS:", params)
+ logger.debug("PARAMS:", params)
if g.user_session.logged_in:
user_collections = list(g.user_session.user_ob.user_collections)
- print("user_collections are:", user_collections)
+ logger.debug("user_collections are:", user_collections)
return render_template("collections/list.html",
params = params,
collections = user_collections,
)
else:
anon_collections = user_manager.AnonUser().get_collections()
- print("anon_collections are:", anon_collections)
+ logger.debug("anon_collections are:", anon_collections)
return render_template("collections/list.html",
params = params,
collections = anon_collections)
@@ -305,17 +310,17 @@ def list_collections():
@app.route("/collections/remove", methods=('POST',))
def remove_traits():
params = request.form
- print("params are:", params)
+ logger.debug("params are:", params)
if "uc_id" in params:
uc_id = params['uc_id']
uc = model.UserCollection.query.get(uc_id)
traits_to_remove = params.getlist('traits[]')
traits_to_remove = process_traits(traits_to_remove)
- print("\n\n after processing, traits_to_remove:", traits_to_remove)
+ logger.debug("\n\n after processing, traits_to_remove:", traits_to_remove)
all_traits = uc.members_as_set()
members_now = all_traits - traits_to_remove
- print(" members_now:", members_now)
+ logger.debug(" members_now:", members_now)
uc.members = json.dumps(list(members_now))
uc.changed_timestamp = datetime.datetime.utcnow()
db_session.commit()
@@ -332,7 +337,7 @@ def remove_traits():
@app.route("/collections/delete", methods=('POST',))
def delete_collection():
params = request.form
- print("params:", params)
+ logger.debug("params:", params)
if g.user_session.logged_in:
uc_id = params['uc_id']
if len(uc_id.split(":")) > 1:
@@ -363,7 +368,7 @@ def delete_collection():
@app.route("/collections/view")
def view_collection():
params = request.args
- print("PARAMS in view collection:", params)
+ logger.debug("PARAMS in view collection:", params)
if "uc_id" in params:
uc_id = params['uc_id']
@@ -379,7 +384,7 @@ def view_collection():
#this_collection = user_collections[params['collection_id']]
traits = this_collection['members']
- print("in view_collection traits are:", traits)
+ logger.debug("in view_collection traits are:", traits)
trait_obs = []
json_version = []
@@ -405,7 +410,7 @@ def view_collection():
collection_info = dict(trait_obs=trait_obs,
collection_name=this_collection['name'])
if "json" in params:
- print("json_version:", json_version)
+ logger.debug("json_version:", json_version)
return json.dumps(json_version)
else:
return render_template("collections/view.html",
diff --git a/wqflask/wqflask/static/dbdoc/TODO.md b/wqflask/wqflask/static/dbdoc/TODO.md
deleted file mode 100644
index c0a8bab7..00000000
--- a/wqflask/wqflask/static/dbdoc/TODO.md
+++ /dev/null
@@ -1 +0,0 @@
-TODO: Add all database documentation into this folder
diff --git a/wqflask/wqflask/user_manager.py b/wqflask/wqflask/user_manager.py
index c55649f3..a0605803 100644
--- a/wqflask/wqflask/user_manager.py
+++ b/wqflask/wqflask/user_manager.py
@@ -23,9 +23,6 @@ import urlparse
import simplejson as json
-import sqlalchemy
-from sqlalchemy import orm
-
#from redis import StrictRedis
import redis
Redis = redis.StrictRedis()
@@ -46,7 +43,6 @@ from wqflask.database import db_session
from wqflask import model
from utility import Bunch, Struct, after
-from utility.tools import LOG_SQL, LOG_SQL_ALCHEMY
import logging
from utility.logger import getLogger
@@ -55,7 +51,10 @@ logger = getLogger(__name__)
from base.data_set import create_datasets_list
import requests
-from utility.elasticsearch_tools import get_elasticsearch_connection, get_user_by_unique_column, save_user
+from utility.elasticsearch_tools import get_elasticsearch_connection, get_user_by_unique_column, get_item_by_unique_column, save_user, es_save_data
+
+from smtplib import SMTP
+from utility.tools import SMTP_CONNECT, SMTP_USERNAME, SMTP_PASSWORD
THREE_DAYS = 60 * 60 * 24 * 3
#THREE_DAYS = 45
@@ -220,6 +219,7 @@ class UserSession(object):
def user_ob(self):
"""Actual sqlalchemy record"""
# Only look it up once if needed, then store it
+ raise "OBSOLETE: use ElasticSearch instead"
try:
if LOG_SQL_ALCHEMY:
logging.getLogger('sqlalchemy.pool').setLevel(logging.DEBUG)
@@ -386,6 +386,7 @@ class ForgotPasswordEmail(VerificationEmail):
"email_address": toaddr,
"timestamp": timestamp()
}
+ es = get_elasticsearch_connection()
es_save_data(es, self.key_prefix, "local", data, verification_code)
subject = self.subject
@@ -437,12 +438,12 @@ def verify_email():
@app.route("/n/password_reset", methods=['GET'])
def password_reset():
logger.debug("in password_reset request.url is:", request.url)
-
# We do this mainly just to assert that it's in proper form for displaying next page
# Really not necessary but doesn't hurt
# user_encode = DecodeUser(ForgotPasswordEmail.key_prefix).reencode_standalone()
verification_code = request.args.get('code')
hmac = request.args.get('hm')
+ es = get_elasticsearch_connection()
if verification_code:
code_details = get_item_by_unique_column(
es
@@ -466,7 +467,6 @@ def password_reset():
@app.route("/n/password_reset_step2", methods=('POST',))
def password_reset_step2():
- from utility.elasticsearch_tools import es
logger.debug("in password_reset request.url is:", request.url)
errors = []
@@ -748,6 +748,7 @@ def forgot_password():
def forgot_password_submit():
params = request.form
email_address = params['email_address']
+ es = get_elasticsearch_connection()
user_details = get_user_by_unique_column(es, "email_address", email_address)
if user_details:
ForgotPasswordEmail(user_details["email_address"])
@@ -840,19 +841,6 @@ def register():
return render_template("new_security/register_user.html", values=params, errors=errors)
-
-
-#@app.route("/n/login", methods=('GET', 'POST'))
-#def login():
-# return user_manager.login()
-#
-#@app.route("/manage/verify")
-#def verify():
-# user_manager.verify_email()
-# return render_template("new_security/verified.html")
-
-
-
################################# Sign and unsign #####################################
def url_for_hmac(endpoint, **values):
@@ -914,15 +902,26 @@ app.jinja_env.globals.update(url_for_hmac=url_for_hmac,
# Redis.rpush("mail_queue", msg)
def send_email(toaddr, msg, fromaddr="no-reply@genenetwork.org"):
- from smtplib import SMTP
- from utility.tools import SMTP_CONNECT, SMTP_USERNAME, SMTP_PASSWORD
- server = SMTP(SMTP_CONNECT)
- server.starttls()
- server.login(SMTP_USERNAME, SMTP_PASSWORD)
- server.sendmail(fromaddr, toaddr, msg)
- server.quit()
-
-
+ """Send an E-mail through SMTP_CONNECT host. If SMTP_USERNAME is not
+ 'UNKNOWN' TLS is used
+
+ """
+ if SMTP_USERNAME == 'UNKNOWN':
+ logger.debug("SMTP: connecting with host "+SMTP_CONNECT)
+ server = SMTP(SMTP_CONNECT)
+ server.sendmail(fromaddr, toaddr, msg)
+ else:
+ logger.debug("SMTP: connecting TLS with host "+SMTP_CONNECT)
+ server = SMTP(SMTP_CONNECT)
+ server.starttls()
+ logger.debug("SMTP: login with user "+SMTP_USERNAME)
+ server.login(SMTP_USERNAME, SMTP_PASSWORD)
+ logger.debug("SMTP: "+fromaddr)
+ logger.debug("SMTP: "+toaddr)
+ logger.debug("SMTP: "+msg)
+ server.sendmail(fromaddr, toaddr, msg)
+ server.quit()
+ logger.info("Successfully sent email to "+toaddr)
class GroupsManager(object):
def __init__(self, kw):