Index: cloud_sync.py =================================================================== diff -u -rc7fd30aa9eafcefd698820e703b3313a8286cde9 -r029aec0d4746d8a2897e46516cf9d39629d684b5 --- cloud_sync.py (.../cloud_sync.py) (revision c7fd30aa9eafcefd698820e703b3313a8286cde9) +++ cloud_sync.py (.../cloud_sync.py) (revision 029aec0d4746d8a2897e46516cf9d39629d684b5) @@ -32,36 +32,45 @@ sleep(5) # wait for UI to prepare the configurations partition - -# set the execution mode regarding the passed command line argumment - try: ok = False print(SETUP_CONSOLE_LINE) - if EXEC_MODE_REGISTRATION_KEY in arguments: + if EXEC_MODE_UPGRADE_KEY in arguments: # ---------- upgrade # Read from $HOME - if os.path.isfile(CONFIG_PATH) and os.access(CONFIG_PATH, os.R_OK | os.W_OK): + if os.path.isfile(CONFIG_PATH) and os.access(CONFIG_PATH, os.R_OK | os.W_OK): #TODO test if this check needed? + EXEC_MODE = EXEC_MODE_UPGRADE g_config = helpers_read_config(CONFIG_PATH) - EXEC_MODE = EXEC_MODE_REGISTRATION ok = True else: - # Read from /var/configuraitons/ - if os.path.isfile(OPERATION_CONFIG_FILE_PATH) and os.access(OPERATION_CONFIG_FILE_PATH, os.R_OK): - g_config = helpers_read_config(OPERATION_CONFIG_FILE_PATH) + if EXEC_MODE_UPDATE_KEY in arguments: # ---------- update + EXEC_MODE = EXEC_MODE_UPGRADE + print(f"CloudSync starting in {EXEC_MODE} mode") + print("CloudSync update config started...") + # Update the $HOME from /var/configuraitons/ and update result in both for later update + oldConfig = helpers_read_config(OPERATION_CONFIG_FILE_PATH) + newConfig = helpers_read_config(CONFIG_PATH) + newConfig . update (oldConfig) + helpers_write_config(None , CONFIG_PATH , newConfig) + helpers_write_config(OPERATION_CONFIG_PATH, OPERATION_CONFIG_FILE_PATH, newConfig) + print("CloudSync update config done.") + + # Read from /var/configuraitons/ # ---------- normal + if os.path.isfile(OPERATION_CONFIG_FILE_PATH) and os.access(OPERATION_CONFIG_FILE_PATH, os.R_OK): #TODO test if this check needed? + g_config = helpers_read_config(OPERATION_CONFIG_FILE_PATH) CONFIG_PATH = OPERATION_CONFIG_FILE_PATH ok = True if ok: - print("CloudSync started in {0} mode".format(EXEC_MODE)) - print("Using config: ".format(CONFIG_PATH)) + print(f"CloudSync started in {EXEC_MODE} mode") + print(f"Using config: {CONFIG_PATH}") else: - g_utils.logger.error("Error reading config file in {0}".format(EXEC_MODE)) - + g_utils.logger.error(f"Error reading config file in {EXEC_MODE}") + print(SETUP_CONSOLE_LINE) except Exception as e: - g_utils.logger.error("Error reading config file - {0}".format(e)) + g_utils.logger.error(f"Error reading config file - {e}") print(SETUP_CONSOLE_LINE) sys.exit(0)