Looks promising, but I did need to make one change to the code (and related comment) at lines 331 and 335:
def create_data_subdirectory(ip_address, port_number):
'''
Create a directory with the path as:
current directory + "_<ip_address>-<port_number>_data" at the end
'''
global Data_Subdirectory_Path
end_of_path = f'{ip_address}-{port_number}_data'
data_subdirectory_path = os.path.join(os.getcwd(), end_of_path)
if not os.path.exists(data_subdirectory_path):
os.mkdir(data_subdirectory_path)
Data_Subdirectory_Path = data_subdirectory_path
"_" changed to "-" between {ip_address} and {port_number}
On first run the data files ended up under /root again, but this time I cleverly changed the directory to /config before running the script. Don't know why I didn't think of that before. It's good to have the data files in a subdirectory though.