From 7603d9ca6ffe0997ff0b99dc854620f8857155e0 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 12 Oct 2016 09:39:34 +0000 Subject: JS: check for file explicitely --- wqflask/utility/tools.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'wqflask/utility') diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index 77cb6ac5..0ee1146e 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -121,9 +121,14 @@ def assert_writable_dir(dir): fh.close() os.remove(fn) except IOError: - raise Exception('Unable to write test.txt to directory ' + dir ) + raise Exception('Unable to write test.txt to directory ' + dir) return dir +def assert_file(fn): + if not valid_file(fn): + raise Exception('Unable to find file '+fn) + return fn + def mk_dir(dir): if not valid_path(dir): os.makedirs(dir) @@ -234,4 +239,5 @@ if os.environ.get('WQFLASK_OVERRIDES'): logger.debug(OVERRIDES) assert_dir(get_setting("JS_BIODALLIANCE")) +assert_file(get_setting("JS_BIODALLIANCE")+"/build/dalliance-all.js") assert_dir(get_setting("JS_TWITTER_POST_FETCHER")) -- cgit v1.2.3 From 516ffb59cb47f3e34970604dd7eec789156901c7 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 12 Oct 2016 09:40:37 +0000 Subject: JS: check for file explicitely --- wqflask/utility/tools.py | 1 + 1 file changed, 1 insertion(+) (limited to 'wqflask/utility') diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index 0ee1146e..82f78bc0 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -241,3 +241,4 @@ if os.environ.get('WQFLASK_OVERRIDES'): assert_dir(get_setting("JS_BIODALLIANCE")) assert_file(get_setting("JS_BIODALLIANCE")+"/build/dalliance-all.js") assert_dir(get_setting("JS_TWITTER_POST_FETCHER")) +assert_file(get_setting("JS_TWITTER_POST_FETCHER")+"/js/twitterFetcher_min.js") -- cgit v1.2.3 From f0e23bc920b53414c5b698946d3591f31865c95e Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 12 Oct 2016 10:14:38 +0000 Subject: JS: check for file explicitely --- wqflask/utility/tools.py | 1 + 1 file changed, 1 insertion(+) (limited to 'wqflask/utility') diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index 82f78bc0..9860f63e 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -240,5 +240,6 @@ if os.environ.get('WQFLASK_OVERRIDES'): assert_dir(get_setting("JS_BIODALLIANCE")) assert_file(get_setting("JS_BIODALLIANCE")+"/build/dalliance-all.js") +assert_file(get_setting("JS_BIODALLIANCE")+"/build/worker-all.js") assert_dir(get_setting("JS_TWITTER_POST_FETCHER")) assert_file(get_setting("JS_TWITTER_POST_FETCHER")+"/js/twitterFetcher_min.js") -- cgit v1.2.3 From 88fa71d35fe261470bcfcb184aea14c5fb5b7c5e Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 12 Oct 2016 10:51:40 +0000 Subject: API: GN_SERVER_URL and test --- etc/default_settings.py | 6 +++--- wqflask/runserver.py | 11 +++++++++-- wqflask/utility/logger.py | 2 +- wqflask/wqflask/templates/marker_regression_gn1.html | 10 +++++----- wqflask/wqflask/views.py | 1 + 5 files changed, 19 insertions(+), 11 deletions(-) (limited to 'wqflask/utility') diff --git a/etc/default_settings.py b/etc/default_settings.py index ac5dc266..08eae024 100644 --- a/etc/default_settings.py +++ b/etc/default_settings.py @@ -26,7 +26,7 @@ GN_VERSION = open("../VERSION","r").read() SQL_URI = "mysql://gn2:mysql_password@localhost/db_webqtl_s" SQLALCHEMY_DATABASE_URI = 'mysql://gn2:mysql_password@localhost/db_webqtl_s' SQLALCHEMY_POOL_RECYCLE = 3600 -GN_SERVER_URL = "http://localhost:8880/" +GN_SERVER_URL = "http://test-gn2.genenetwork.org/" # ---- Flask configuration (see website) TRAP_BAD_REQUEST_ERRORS = True @@ -37,7 +37,7 @@ SECURITY_RECOVERABLE = True SECURITY_EMAIL_SENDER = "no-reply@genenetwork.org" SECURITY_POST_LOGIN_VIEW = "/thank_you" -SERVER_PORT = 5003 +SERVER_PORT = 5003 # running on localhost SECRET_HMAC_CODE = '\x08\xdf\xfa\x93N\x80\xd9\\H@\\\x9f`\x98d^\xb4a;\xc6OM\x946a\xbc\xfc\x80:*\xebc' # ---- Behavioural settings (defaults) note that logger and log levels can @@ -45,6 +45,7 @@ SECRET_HMAC_CODE = '\x08\xdf\xfa\x93N\x80\xd9\\H@\\\x9f`\x98d^\xb4a;\xc6OM\x946a WEBSERVER_MODE = 'DEV' # Python webserver mode (DEBUG|DEV|PROD) WEBSERVER_BRANDING = None # Set the branding (nyi) WEBSERVER_DEPLOY = None # Deployment specifics (nyi) +WEBSERVER_URL = "http://localhost:"+str(SERVER_PORT)+"/" # external URL LOG_LEVEL = 'WARNING' # Logger mode (DEBUG|INFO|WARNING|ERROR|CRITICAL) LOG_LEVEL_DEBUG = '0' # logger.debugf log level (0-5, 5 = show all) @@ -72,4 +73,3 @@ LOCAL_PRIVATE_FILES = HOME+"/gn2_private_data" # private static data files PYLMM_COMMAND = str.strip(os.popen("which pylmm_redis").read()) PLINK_COMMAND = str.strip(os.popen("which plink2").read()) GEMMA_COMMAND = str.strip(os.popen("which gemma").read()) - diff --git a/wqflask/runserver.py b/wqflask/runserver.py index 0342b7ad..adacc712 100644 --- a/wqflask/runserver.py +++ b/wqflask/runserver.py @@ -19,11 +19,18 @@ ENDC = '\033[0m' import os app.config['SECRET_KEY'] = os.urandom(24) -from utility.tools import WEBSERVER_MODE,get_setting_int +from utility.tools import WEBSERVER_MODE,get_setting_int,get_setting port = get_setting_int("SERVER_PORT") -logger.info("GN2 is running. Visit %shttp://localhost:%s/%s" % (BLUE,port,ENDC)) +print("GN2 API server URL is ["+BLUE+get_setting("GN_SERVER_URL")+ENDC+"]") + +import requests +page = requests.get(get_setting("GN_SERVER_URL")) +if page.status_code != 200: + raise Exception("API server not found!") + +print("GN2 is running. Visit %s[http://localhost:%s/%s](%s)" % (BLUE,str(port),ENDC,get_setting("WEBSERVER_URL"))) werkzeug_logger = logging.getLogger('werkzeug') diff --git a/wqflask/utility/logger.py b/wqflask/utility/logger.py index bacb0aa4..128706df 100644 --- a/wqflask/utility/logger.py +++ b/wqflask/utility/logger.py @@ -72,7 +72,7 @@ LOG_LEVEL_DEBUG (NYI). def warning(self,*args): """Call logging.warning for multiple args""" self.collect(self.logger.warning,*args) - self.logger.warning(self.collect(*args)) + # self.logger.warning(self.collect(*args)) def error(self,*args): """Call logging.error for multiple args""" diff --git a/wqflask/wqflask/templates/marker_regression_gn1.html b/wqflask/wqflask/templates/marker_regression_gn1.html index a39da73a..7aceabee 100644 --- a/wqflask/wqflask/templates/marker_regression_gn1.html +++ b/wqflask/wqflask/templates/marker_regression_gn1.html @@ -414,9 +414,9 @@ provides_entrypoints: true }); BD.putSource({name: 'Genotype', - controlURI: "http://test-gn2.genenetwork.org/api_pre1/genotype/mouse/BXD.json", - URIBase: "http://test-gn2.genenetwork.org/api_pre1/genotype/mouse/", - tier_type: 'rqtl-genotype', + controlURI: gn_server_url+"/api_pre1/genotype/mouse/BXD.json", + URIBase: gn_server_url+"/api_pre1/genotype/mouse/", + tier_type: 'rqtl-genotype', vOffset: 8, pinned: true, transposed: true, @@ -465,7 +465,7 @@ }); BD.putSource({name: 'QTL', tier_type: 'qtl', - uri: 'http://localhost:5003/generated_text/{{csv_filename}}', + uri: '/generated_text/{{csv_filename}}', style: [{ type: 'default', style: { @@ -480,7 +480,7 @@ }], }); BD.putSource({name: 'SNP density', - jbURI: "http://test-gn2.genenetwork.org/api_pre1/snp", + jbURI: gn_server_url+"/api_pre1/snp", jbQuery: "", refetchOnZoom: true, style: [{ diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 289d2dc6..8d5eadb6 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -549,6 +549,7 @@ def marker_regression_page(): gn1_template_vars = marker_regression_gn1.MarkerRegression(result).__dict__ gn1_template_vars['json_filename'] = json_filename; gn1_template_vars['csv_filename'] = csv_filename; + gn1_template_vars['gn_server_url'] = GN_SERVER_URL; pickled_result = pickle.dumps(result, pickle.HIGHEST_PROTOCOL) logger.info("pickled result length:", len(pickled_result)) -- cgit v1.2.3