def write_dhcpcd_ip_settings_to_file(self): dhcpcd_template = app_variables.dhcpcd_config_file_content_template eth_replacement_variables = [] wlan_replacement_variables = [] if self.is_eth_ip_settings_ok(): eth_replacement_variables.append("eth0") eth_replacement_variables.append(self.local_ethernet_ip) eth_replacement_variables.append(self.local_ethernet_subnet) eth_replacement_variables.append(self.local_ethernet_gateway) eth_replacement_variables.append(self.local_ethernet_dns1) eth_replacement_variables.append(self.local_ethernet_dns2) else: eth_replacement_variables = ["", "", "", "", "", ""] if self.is_wlan_ip_settings_ok(): wlan_replacement_variables.append("wlan0") wlan_replacement_variables.append(self.local_wireless_ip) wlan_replacement_variables.append(self.local_wireless_subnet) wlan_replacement_variables.append(self.local_wireless_gateway) wlan_replacement_variables.append(self.local_wireless_dns1) wlan_replacement_variables.append(self.local_wireless_dns2) else: wlan_replacement_variables = ["", "", "", "", "", ""] eth_dhcpcd_text = self.get_dhcpcd_replacement_text( eth_replacement_variables) wlan_dhcpcd_text = self.get_dhcpcd_replacement_text( wlan_replacement_variables) new_dhcpcd = dhcpcd_template.replace( "{{ StaticIPSettings }}", eth_dhcpcd_text + wlan_dhcpcd_text) write_file_to_disk(file_locations.dhcpcd_config_file, new_dhcpcd) shutil.chown(file_locations.dhcpcd_config_file, "root", "netdev") os.chmod(file_locations.dhcpcd_config_file, 0o664)
def save_iperf_results_to_file(): primary_logger.info("Saving iPerf 3 test results to file") try: text_time_sec = str(time.time()).split(".")[0] new_file_location = file_locations.location_save_report_folder + "/iperf-" + text_time_sec + ".txt" write_file_to_disk(new_file_location, app_variables.web_iperf_results) app_variables.previous_iperf_results_file_locations = app_variables.get_previous_results_file_names( test_type="iperf") app_variables.previous_iperf_results_total = len( app_variables.previous_iperf_results_file_locations) except Exception as error: primary_logger.error("Error saving iPerf 3 test results to file: " + str(error))
def write_wpa_supplicant_wifi_settings_to_file(self): wpa_supplicant_template = app_variables.wpa_supplicant_file_content_template if self.wifi_security_type == "": wifi_security_type = "" wifi_template = wpa_supplicant_template.replace( "{{ WirelessPSK1 }}", self.wifi_pass_key) else: wifi_security_type = "key_mgmt=None" wifi_template = wpa_supplicant_template.replace( "{{ WirelessPSK1 }}", "") wifi_template = wifi_template.replace("{{ WirelessCountryCode }}", self.wifi_country_code) wifi_template = wifi_template.replace("{{ WirelessSSID1 }}", self.wifi_ssid) wifi_template = wifi_template.replace("{{ WirelessKeyMgmt1 }}", wifi_security_type) write_file_to_disk(file_locations.wpa_supplicant_file, wifi_template)
def save_iperf_results_to_file(): text_time_sec = str(time.time()).split(".")[0] new_file_location = file_locations.location_save_report_folder + "/iperf-" + text_time_sec + ".txt" file_content = app_variables.previous_iperf_start_text + app_variables.previous_iperf_results write_file_to_disk(new_file_location, file_content)
def write_config_to_file(self): """ Writes configuration to local disk. """ write_file_to_disk(file_locations.config_file_location, self._get_config_as_str())
def write_installed_hardware_to_file(self): """ Writes Installed Hardware config to local disk. """ write_file_to_disk(file_locations.installed_hardware_file_location, self._get_installed_hardware_as_str())