if not os.path.exists(script_path): repo_msg = script_path + ' repository does not exist' Console.error(repo_msg, prefix=MODULE) else: msg = 'load script from ' + script_path + ' repository' Console.info(msg, prefix=MODULE) # Build server script full path server_script_path = os.path.join(script_path, SCRIPT_NAME) if os.path.exists(server_script_path): if os.path.isfile(server_script_path): try: port = DEFAULT_PORT if GNAThub.port(): port = GNAThub.port() msg_exec = 'execute ' + SCRIPT_NAME msg_exec = msg_exec + ' (PORT NUMBER: ' + str(port) + ')' Console.info(msg_exec, prefix=MODULE) html_dir = os.path.join(GNAThub.root(), 'html-report') os.environ["FLASK_RUN_PORT"] = str(port) os.environ["WEBUI_HTML_FOLDER"] = html_dir exec(compile(open(server_script_path).read(), server_script_path, 'exec')) except Exception as why: msg_excpt = 'failed to load script: ' + server_script_path msg_err = msg_excpt + ' ' + str(why) Console.info(msg_excpt, prefix=MODULE) Console.error(msg_err, prefix=MODULE)
def _import_codepeer_bridge(filename): app.logger.info("Import info into codepeer_bridge") name = 'codepeer_bridge' cmd = [ 'codepeer_bridge', '--output-dir=' + OUTPUT_DIR, '--db-dir=' + DB_DIR, '--import-reviews=' + filename ] GNAThub.Run(name, cmd, out=SERVER_LOG, append_out=True) @app.route('/<path:other>') def fallback(other): app.logger.error("Bad request used.") app.logger.error(other) return make_response("Wrong request", 404) if __name__ == '__main__': flask_port = GNAThub.port() if GNAThub.port() else DEFAULT_PORT if flask_port > 1024: print("Launching flask server on port {}".format(flask_port)) print("Logs redirected to {}".format(SERVER_LOG)) # TODO : Error occur when lauching with debug=True # app.run(port=flask_port, debug=True) app.run(host='0.0.0.0', port=flask_port, threaded=True) else: app.logger.error("Bad port used. Please relauch with port above 1024.") print("Please use a port above 1024")
if not os.path.exists(script_path): repo_msg = script_path + ' repository does not exist' Console.error(repo_msg, prefix=MODULE) else: msg = 'load script from ' + script_path + ' repository' Console.info(msg, prefix=MODULE) # Build server script full path server_script_path = os.path.join(script_path, SCRIPT_NAME) if os.path.exists(server_script_path): if os.path.isfile(server_script_path): try: port = DEFAULT_PORT if GNAThub.port(): port = GNAThub.port() msg_exec = 'execute ' + SCRIPT_NAME msg_exec = msg_exec + ' (PORT NUMBER: ' + str(port) + ')' Console.info(msg_exec, prefix=MODULE) execfile(server_script_path) except Exception as why: msg_excpt = 'failed to load script: ' + server_script_path msg_err = msg_excpt + ' ' + str(why) Console.info(msg_excpt, prefix=MODULE) Console.error(msg_err, prefix=MODULE) else: file_msg = server_script_path + ' server script does not exist' Console.error(file_msg, prefix=MODULE)