aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/utility/logger.py8
-rw-r--r--wqflask/utility/tools.py15
-rwxr-xr-xwqflask/wqflask/correlation_matrix/show_corr_matrix.py2
3 files changed, 18 insertions, 7 deletions
diff --git a/wqflask/utility/logger.py b/wqflask/utility/logger.py
new file mode 100644
index 00000000..85a64438
--- /dev/null
+++ b/wqflask/utility/logger.py
@@ -0,0 +1,8 @@
+# GeneNetwork logger
+#
+# The standard python logging module is very good. This logger adds a
+# few facilities on top of that. Main one being that it picks up
+# settings for log levels (global and by module) and (potentially)
+# offers some fine grained log levels for the standard levels.
+#
+# Global settings (defined in default_settings.py).
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py
index 6e9f6d4a..d43e2132 100644
--- a/wqflask/utility/tools.py
+++ b/wqflask/utility/tools.py
@@ -3,8 +3,12 @@
import os
import sys
+import logging
from wqflask import app
+logger = logging.getLogger(__name__ )
+logging.basicConfig(level=logging.INFO)
+
def get_setting(command_id,guess=None):
"""Resolve a setting from the environment or the global settings in
app.config, with valid_path is a function checking whether the
@@ -37,7 +41,7 @@ def get_setting(command_id,guess=None):
return None
# ---- Check whether environment exists
- # sys.stderr.write("Looking for "+command_id+"\n")
+ logger.debug("Looking for "+command_id+"\n")
command = value(os.environ.get(command_id))
if not command:
# ---- Check whether setting exists in app
@@ -46,7 +50,7 @@ def get_setting(command_id,guess=None):
command = value(guess)
if not command:
raise Exception(command_id+' setting unknown or faulty (update settings.py?).')
- sys.stderr.write("Set "+command_id+"="+str(command)+"\n")
+ logger.info("Set "+command_id+"="+str(command))
return command
def valid_bin(bin):
@@ -101,7 +105,7 @@ def locate(name, subdir=None):
if valid_path(base):
lookfor = base + "/" + name
if valid_file(lookfor):
- print("Found: file "+lookfor+"\n")
+ logger.info("Found: file "+lookfor+"\n")
return lookfor
else:
raise Exception("Can not locate "+lookfor)
@@ -121,9 +125,9 @@ def locate_ignore_error(name, subdir=None):
if valid_path(base):
lookfor = base + "/" + name
if valid_file(lookfor):
- print("Found: file "+name+"\n")
+ logger.debug("Found: file "+name+"\n")
return lookfor
- sys.stderr.write("WARNING: file "+name+" not found\n")
+ logger.info("WARNING: file "+name+" not found\n")
return None
def tempdir():
@@ -141,4 +145,3 @@ GEMMA_COMMAND = gemma_command()
PLINK_COMMAND = plink_command()
FLAT_FILES = flat_files()
TEMPDIR = tempdir()
-
diff --git a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
index 5c3354f1..7b67e626 100755
--- a/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
+++ b/wqflask/wqflask/correlation_matrix/show_corr_matrix.py
@@ -21,7 +21,7 @@
from __future__ import absolute_import, print_function, division
import sys
-sys.path.append(".")
+# sys.path.append(".") Never do this in a webserver!
import gc
import string