aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPjotr Prins2015-03-18 10:08:29 +0300
committerPjotr Prins2015-03-18 10:08:29 +0300
commite6e3b12eeb3fc57b9652468304c1fd14a0a816d0 (patch)
tree5c5cb806834f26931c62fda5368e6e8249d5deea
parente615b83d34bcc991e671241db71c6ad0c0267479 (diff)
downloadgenenetwork2-e6e3b12eeb3fc57b9652468304c1fd14a0a816d0.tar.gz
Add callback handlers
-rw-r--r--wqflask/wqflask/my_pylmm/pyLMM/gn2.py38
-rw-r--r--wqflask/wqflask/my_pylmm/pyLMM/standalone.py41
2 files changed, 79 insertions, 0 deletions
diff --git a/wqflask/wqflask/my_pylmm/pyLMM/gn2.py b/wqflask/wqflask/my_pylmm/pyLMM/gn2.py
new file mode 100644
index 00000000..e0c6c8a7
--- /dev/null
+++ b/wqflask/wqflask/my_pylmm/pyLMM/gn2.py
@@ -0,0 +1,38 @@
+# Genenetwork2 specific methods and callback handler
+#
+# Copyright (C) 2015 Pjotr Prins (pjotr.prins@thebird.nl)
+#
+
+from __future__ import absolute_import, print_function, division
+
+import sys
+import logging
+
+# logging.basicConfig(level=logging.DEBUG)
+
+def progress(location, count, total):
+ print("Progress: %s %i %i @%d%%" % (location,count,total,round(count*100.0/total)))
+
+def callbacks():
+ return dict(
+ write = sys.stdout.write,
+ writeln = print,
+ debug = logging.debug,
+ info = logging.info,
+ warning = logging.warning,
+ error = logging.error,
+ critical = logging.critical,
+ progress = progress
+ )
+
+# ----- Minor test cases:
+
+if __name__ == '__main__':
+ logging.basicConfig(level=logging.DEBUG)
+ logging.debug("Test %i" % (1))
+ d = callbacks()['debug']
+ d("TEST")
+ wrln = callbacks()['writeln']
+ wrln("Hello %i" % 34)
+ progress = callbacks()['progress']
+ progress("I am half way",50,100)
diff --git a/wqflask/wqflask/my_pylmm/pyLMM/standalone.py b/wqflask/wqflask/my_pylmm/pyLMM/standalone.py
new file mode 100644
index 00000000..a806729e
--- /dev/null
+++ b/wqflask/wqflask/my_pylmm/pyLMM/standalone.py
@@ -0,0 +1,41 @@
+# Standalone specific methods and callback handler
+#
+# Copyright (C) 2015 Pjotr Prins (pjotr.prins@thebird.nl)
+#
+# Set the log level with
+#
+# logging.basicConfig(level=logging.DEBUG)
+
+from __future__ import absolute_import, print_function, division
+
+import sys
+import logging
+
+logging.basicConfig(level=logging.DEBUG)
+
+def progress(location, count, total):
+ logging.info("Progress: %s %i %i @%d%%" % (location,count,total,round(count*100.0/total)))
+
+def callbacks():
+ return dict(
+ write = sys.stdout.write,
+ writeln = print,
+ debug = logging.debug,
+ info = logging.info,
+ warning = logging.warning,
+ error = logging.error,
+ critical = logging.critical,
+ progress = progress
+ )
+
+# ----- Minor test cases:
+
+if __name__ == '__main__':
+ # logging.basicConfig(level=logging.DEBUG)
+ logging.debug("Test %i" % (1))
+ d = callbacks()['debug']
+ d("TEST")
+ wrln = callbacks()['writeln']
+ wrln("Hello %i" % 34)
+ progress = callbacks()['progress']
+ progress("I am half way",50,100)