From bd1185376275b24ac00404c1f36c041e8ebb5e47 Mon Sep 17 00:00:00 2001 From: suchinton2001 Date: Thu, 26 Oct 2023 18:11:52 +0530 Subject: agl-demo-control-panel: Add Fullscreen / maximized option V1: - Add fullscreen flag in config.ini to hide the header bar and launch the control-center in fullscreen mode. V2: - Write default user-session config if not found in config.ini Bug-AGL: SPEC-4948 Signed-off-by: suchinton2001 Change-Id: I549390711cdda95f99ee166d99c302176d105f1f --- extras/config.py | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'extras/config.py') diff --git a/extras/config.py b/extras/config.py index 48a63e2..1a10719 100644 --- a/extras/config.py +++ b/extras/config.py @@ -52,21 +52,17 @@ GRPC_TOKEN_PATHS = check_paths( ) config = ConfigParser() -config_path = next( - (path for path, exists in CONFIG_PATHS.items() if exists), None) +config_path = next((path for path, exists in CONFIG_PATHS.items() if exists), None) if config_path: config.read(config_path) CA_PATH = next((path for path, exists in CA_PATHS.items() if exists), None) -WS_TOKEN = next( - (path for path, exists in WS_TOKEN_PATHS.items() if exists), None) -GRPC_TOKEN = next( - (path for path, exists in GRPC_TOKEN_PATHS.items() if exists), None) +WS_TOKEN = next((path for path, exists in WS_TOKEN_PATHS.items() if exists), None) +GRPC_TOKEN = next((path for path, exists in GRPC_TOKEN_PATHS.items() if exists), None) KUKSA_CONFIG = {} KUKSA_TOKEN = None - def select_config(preferred_config): """ Selects a configuration from the config.ini file based on the preferred_config parameter. @@ -131,8 +127,6 @@ def save_session_config(session_config, auth_token, CA_File=None): """ save values to config.ini under [user-session] """ - if not config.has_section('user-session'): - config.add_section('user-session') config.set('user-session', 'ip', str(session_config['ip'])) config.set('user-session', 'port', str(session_config['port'])) @@ -140,15 +134,33 @@ def save_session_config(session_config, auth_token, CA_File=None): config.set('user-session', 'insecure', str(session_config['insecure'])) config.set('user-session', 'tls_server_name', str(session_config['tls_server_name'])) - if auth_token in WS_TOKEN_PATHS or auth_token in GRPC_TOKEN_PATHS: + if auth_token in WS_TOKEN_PATHS or auth_token in GRPC_TOKEN_PATHS or auth_token == 'default': config.set('user-session', 'token', 'default') else: config.set('user-session', 'token', str(auth_token)) - if CA_File in CA_PATHS: + if CA_File in CA_PATHS or CA_File == 'default': config.set('user-session', 'cacert', 'default') else: config.set('user-session', 'cacert', str(CA_File)) with open(config_path, 'w') as configfile: config.write(configfile) + + +def fullscreen_mode(): + return config.getboolean('default', 'fullscreen-mode') + + +if not config.has_section('user-session'): + config.add_section('user-session') + temp = { + 'ip': "", + 'port': "", + 'protocol': "", + 'insecure': "", + 'cacert': "", + 'token': "", + 'tls_server_name': "", + } + save_session_config(temp, 'default', 'default') \ No newline at end of file -- cgit