Commit ea337a8f authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Pre-merge code cleanup

parent 772349c2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ MANIFEST
*.manifest
.manifest/
*.spec
scripts/aa

# Installer logs
pip-log.txt
pip-delete-this-directory.txt
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
export TFS_REGISTRY_IMAGES="http://localhost:32000/tfs/"

# Set the list of components, separated by spaces, you want to build images for, and deploy.
export TFS_COMPONENTS="context device pathcomp service webui nbi"
export TFS_COMPONENTS="context device pathcomp service nbi webui"

# Uncomment to activate Monitoring (old)
#export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring"
+1 −2
Original line number Diff line number Diff line
@@ -17,6 +17,5 @@ Flask-WTF<2
flask-healthz<2
flask-unittest==0.1.3
lorem-text==2.1
werkzeug==2.3.7
requests==2.27.1
werkzeug==2.3.7
+9 −18
Original line number Diff line number Diff line
@@ -14,12 +14,11 @@

import hashlib, sys, logging
from prometheus_client import start_http_server
from datetime import timedelta
from common.Constants import ServiceNameEnum

from common.Settings import (
    ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_log_level, get_metrics_port,
    get_service_baseurl_http, get_service_port_http, get_setting, wait_for_environment_variables
    ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name,
    get_log_level, get_metrics_port, get_service_baseurl_http, get_service_port_http,
    get_setting, wait_for_environment_variables
)
from webui.service import create_app
from webui.Config import MAX_CONTENT_LENGTH, HOST, SECRET_KEY, DEBUG
@@ -29,7 +28,6 @@ def create_unique_session_cookie_name() -> str:
    if hostname is None: return 'session'
    hasher = hashlib.blake2b(digest_size=8)
    hasher.update(hostname.encode('UTF-8'))
    logging.info('session:{:s}'.format(str(hasher.hexdigest())))
    return 'session:{:s}'.format(str(hasher.hexdigest()))

def main():
@@ -37,7 +35,6 @@ def main():
    logging.basicConfig(level=log_level)
    logger = logging.getLogger(__name__)

    # DEPENDENCY QKD
    wait_for_environment_variables([
        get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST     ),
        get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC),
@@ -45,8 +42,6 @@ def main():
        get_env_var_name(ServiceNameEnum.DEVICE,  ENVVAR_SUFIX_SERVICE_PORT_GRPC),
        get_env_var_name(ServiceNameEnum.SERVICE, ENVVAR_SUFIX_SERVICE_HOST     ),
        get_env_var_name(ServiceNameEnum.SERVICE, ENVVAR_SUFIX_SERVICE_PORT_GRPC),
         get_env_var_name(ServiceNameEnum.OPTICALCONTROLLER, ENVVAR_SUFIX_SERVICE_HOST     ),
        get_env_var_name(ServiceNameEnum.OPTICALCONTROLLER, ENVVAR_SUFIX_SERVICE_PORT_GRPC),
    ])

    logger.info('Starting...')
@@ -60,20 +55,16 @@ def main():
    debug = get_setting('DEBUG', default=DEBUG)
    if isinstance(debug, str): debug = (debug.upper() in {'T', '1', 'TRUE'})

   
    
    app = create_app(use_config={
        'SECRET_KEY': SECRET_KEY,
        'MAX_CONTENT_LENGTH': MAX_CONTENT_LENGTH,
        'SESSION_COOKIE_NAME': create_unique_session_cookie_name(),
        'WTF_CSRF_ENABLED':False,
      
         
    }, web_app_root=web_app_root)
    #app = create_app(use_config=None, web_app_root=web_app_root)

    app.run(host=host, port=service_port, debug=debug)

    logger.info(f'Bye ')
    logger.info('Bye')
    return 0

if __name__ == '__main__':
+2 −3
Original line number Diff line number Diff line
@@ -118,7 +118,6 @@ def home():
        context_client.close()
        device_client.close()

    LOGGER.info(f"erorr {context_topology_form.errors.items()}")
    return render_template(
        'main/home.html', context_topology_form=context_topology_form, descriptor_form=descriptor_form)

Loading