diff options
-rw-r--r-- | test/requests/link_checker.py | 53 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 15 |
2 files changed, 47 insertions, 21 deletions
diff --git a/test/requests/link_checker.py b/test/requests/link_checker.py index 47454c75..d040ba54 100644 --- a/test/requests/link_checker.py +++ b/test/requests/link_checker.py @@ -52,6 +52,21 @@ def verify_link(link): if DO_FAIL: raise ex + +def verify_static_file(link): + print("verifying "+link) + try: + result = requests.get(link, timeout=20, verify=False) + if (result.status_code == 200 and + result.content.find("Error: 404 Not Found") <= 0): + print(link+" ==> OK") + else: + print("ERROR: link {}".format(link)) + raise Exception("Failed verify") + except ConnectionError as ex: + print("ERROR: ", link, ex) + + def check_page(host, start_url): print("") print("Checking links host "+host+" in page `"+start_url+"`") @@ -85,28 +100,28 @@ def check_packaged_js_files(args_obj, parser): host = args_obj.host js_files = [ # Datatables Extensions: - "/DataTablesExtensions/buttonsBootstrap/css/buttons.bootstrap.css", - "/DataTablesExtensions/buttons/js/dataTables.buttons.min.js", - "/DataTablesExtensions/buttonStyles/css/buttons.dataTables.min.css", - "/DataTablesExtensions/buttons/js/dataTables.buttons.min.js", - "/DataTablesExtensions/colResize/dataTables.colResize.js", - "/DataTablesExtensions/colReorder/js/dataTables.colReorder.js", - "/DataTablesExtensions/buttons/js/buttons.colVis.min.js", - "/DataTables/js/jquery.dataTables.js", - "/DataTablesExtensions/scroller/css/scroller.dataTables.min.css", + "/css/DataTablesExtensions/buttonsBootstrap/css/buttons.bootstrap.css", + "/js/DataTablesExtensions/buttons/js/dataTables.buttons.min.js", + "/css/DataTablesExtensions/buttonStyles/css/buttons.dataTables.min.css", + "/js/DataTablesExtensions/buttons/js/dataTables.buttons.min.js", + "/js/DataTablesExtensions/colResize/dataTables.colResize.js", + "/js/DataTablesExtensions/colReorder/js/dataTables.colReorder.js", + "/js/DataTablesExtensions/buttons/js/buttons.colVis.min.js", + "/js/DataTables/js/jquery.dataTables.js", + "/css/DataTablesExtensions/scroller/css/scroller.dataTables.min.css", # Datatables plugins: - "/DataTablesExtensions/plugins/sorting/natural.js", - "/DataTablesExtensions/plugins/sorting/scientific.js", + "/js/DataTablesExtensions/plugins/sorting/natural.js", + "/js/DataTablesExtensions/plugins/sorting/scientific.js", # Other js libraries - "/chroma/chroma.min.js", - "/d3-tip/d3-tip.js", - "/d3js/d3.min.js", - "/js_alt/underscore.min.js", - "/nvd3/nv.d3.min.css", - "/qtip2/jquery.qtip.min.js", - "/js_alt/md5.min.js", + "/js/chroma/chroma.min.js", + "/js/d3-tip/d3-tip.js", + "/js/d3js/d3.min.js", + "/js/js_alt/underscore.min.js", + "/js/nvd3/nv.d3.min.css", + "/js/qtip2/jquery.qtip.min.js", + "/js/js_alt/md5.min.js", ] print("Checking links") for link in js_files: - verify_link(host+link) + verify_static_file(host+link) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 91d1a279..fc9949a8 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -175,13 +175,24 @@ def tmp_page(img_path): return render_template("show_image.html", img_base64 = bytesarray ) + @app.route("/js/<path:filename>") def js(filename): - return send_from_directory(JS_GUIX_PATH, filename) + js_path = JS_GUIX_PATH + name = filename + if 'js_alt/' in filename: + js_path = js_path.replace('genenetwork2/javascript', 'javascript') + name = name.replace('js_alt/', '') + return send_from_directory(js_path, name) @app.route("/css/<path:filename>") def css(filename): - return send_from_directory(CSS_PATH, filename) + js_path = JS_GUIX_PATH + name = filename + if 'js_alt/' in filename: + js_path = js_path.replace('genenetwork2/javascript', 'javascript') + name = name.replace('js_alt/', '') + return send_from_directory(js_path, name) @app.route("/twitter/<path:filename>") def twitter(filename): |