import os import json from core.Constants import Constants import interact_with_rest_of_app.which_profile_is_being_used as which_profile_module current_profile_number = which_profile_module.which_profile_is_being_used() print('the current profile number is: ', current_profile_number) print('the path is: ', Constants.HV_PROFILE_CONFIG_HOME) def process_the_proxy(returned_data_as_a_dictionary): proxy_ip_address_in_GUI = returned_data_as_a_dictionary.get( 'proxy_ip_address') proxy_password_in_GUI = returned_data_as_a_dictionary.get('proxy_password') proxy_username_in_GUI = returned_data_as_a_dictionary.get('proxy_username') try: proxy_port_in_GUI = int( returned_data_as_a_dictionary.get('proxy_port')) except (ValueError, TypeError): proxy_port_in_GUI = 1080 # Create a new dictionary: new_formatted_dictonary_to_write_to_folder = { "ip_address": proxy_ip_address_in_GUI, "port_number": proxy_port_in_GUI, "username": proxy_username_in_GUI, "password": proxy_password_in_GUI, "time_zone": "America/New_York" } current_profile_number = which_profile_module.which_profile_is_being_used() print('the current profile number is: ', current_profile_number) custom_path = f'{Constants.HV_PROFILE_CONFIG_HOME}/{current_profile_number}/proxyTEST.json' # Ensure the directory exists os.makedirs(os.path.dirname(custom_path), exist_ok=True) # Write the dictionary to a JSON file at the custom path with open(custom_path, 'w') as json_file: json.dump(new_formatted_dictonary_to_write_to_folder, json_file, indent=4)