def get_sys_info_message(): date_now = strftime("%d/%m/%y") time_now = strftime("%H:%M") os_text = get_os_name_version() remote_ip = current_config.remote_tester_ip remote_port = app_variables.flask_http_port if current_config.running_on_rpi: lines = os_text.split(" ") os_text = lines[0] + " " + lines[2] eth_ip = network_ip.get_dhcpcd_ip() wifi_ip = network_ip.get_dhcpcd_ip(wireless=True) eth_dhcp = " - Static" wifi_dhcp = " - Static" if network_ip.check_for_dhcp(): eth_dhcp = " - DHCP" if network_ip.check_for_dhcp(wireless=True): wifi_dhcp = " - DHCP" remote_version = str(get_remote_data("http://" + remote_ip + ":" + str(remote_port) + "/Version"))[2:-1] if 3 > len(remote_version) or len(remote_version) > 14: remote_version = "NA" text_msg = "Version: " + current_config.app_version + \ "\nOS: " + os_text + \ "\nDate: " + date_now + " (D/M/Y)" + \ "\nTime: " + time_now + \ "\n\nEthernet IP" + eth_dhcp + "\n" + eth_ip + \ "\nWireless IP" + wifi_dhcp + "\n" + wifi_ip + \ "\n\nRemote Server - " + check_tester_online_status(remote_ip, remote_port) + \ "\nIP " + current_config.remote_tester_ip + \ "\nVersion: " + remote_version return text_msg
def load_dhcpcd_conf_from_file(self): try: app_variables.dhcpcd_config_file_content = get_file_content( file_locations.dhcpcd_config_file) self.local_ethernet_dhcp = network_ip.check_for_dhcp() self.local_ethernet_ip = network_ip.get_dhcpcd_ip() self.local_ethernet_subnet = network_ip.get_subnet() self.local_ethernet_gateway = network_ip.get_gateway() self.local_ethernet_dns1 = network_ip.get_dns(dns_server=0) self.local_ethernet_dns2 = network_ip.get_dns(dns_server=1) self.local_wireless_dhcp = network_ip.check_for_dhcp(wireless=True) self.local_wireless_ip = network_ip.get_dhcpcd_ip(wireless=True) self.local_wireless_subnet = network_ip.get_subnet(wireless=True) self.local_wireless_gateway = network_ip.get_gateway(wireless=True) self.local_wireless_dns1 = network_ip.get_dns(dns_server=0, wireless=True) self.local_wireless_dns2 = network_ip.get_dns(dns_server=1, wireless=True) except Exception as error: print("Unable to get IP information from dhcpcd.conf: " + str(error))
def _get_networking_tabs(): ethernet_dhcp = "" if current_config.local_ethernet_dhcp: ethernet_dhcp = "checked" wireless_dhcp = "" if current_config.local_wireless_dhcp: wireless_dhcp = "checked" wifi_type_wpa = "" wifi_type_none = "" if current_config.wifi_security_type == "": wifi_type_wpa = "checked" else: wifi_type_none = "checked" wifi_country_code_disable = "disabled" if current_config.running_on_rpi: wifi_country_code_disable = "" return render_template("network_tabs.html", EthernetCheckedDHCP=ethernet_dhcp, EthernetIPv4Address=get_dhcpcd_ip(), EthernetIPv4Subnet=current_config.local_ethernet_subnet, EthernetIPGateway=current_config.local_ethernet_gateway, EthernetIPDNS1=current_config.local_ethernet_dns1, EthernetIPDNS2=current_config.local_ethernet_dns2, WirelessCheckedDHCP=wireless_dhcp, WifiCountryCodeDisabled=wifi_country_code_disable, WirelessIPv4Address=get_dhcpcd_ip(wireless=True), WirelessIPv4Subnet=current_config.local_wireless_subnet, WirelessIPGateway=current_config.local_wireless_gateway, WirelessIPDNS1=current_config.local_wireless_dns1, WirelessIPDNS2=current_config.local_wireless_dns2, WirelessCountryCode=current_config.wifi_country_code, CheckedWiFiSecurityWPA1=wifi_type_wpa, CheckedWiFiSecurityNone1=wifi_type_none, SSID1=current_config.wifi_ssid)
def html_root(): tests_running_msg = "" button_disabled = "" if current_config.tests_running: tests_running_msg = "Running Tests Please Wait ..." button_disabled = "disabled" iperf_server_enabled = "" if current_config.is_iperf_server: iperf_server_enabled = "checked" wave_share_27_enabled = "" if current_config.installed_interactive_hw["WaveShare27"]: wave_share_27_enabled = "checked" ethernet_dhcp = "" if current_config.local_ethernet_dhcp: ethernet_dhcp = "checked" wireless_dhcp = "" if current_config.local_wireless_dhcp: wireless_dhcp = "checked" mtr_results = "" if app_variables.previous_mtr_results: mtr_results = app_variables.previous_mtr_start_text + str( app_variables.previous_mtr_results) iperf_results = "" if app_variables.previous_iperf_results: iperf_results = app_variables.previous_iperf_start_text + str( app_variables.previous_iperf_results) wifi_type_wpa = "" wifi_type_none = "" if current_config.wifi_security_type == "": wifi_type_wpa = "checked" else: wifi_type_none = "checked" wifi_country_code_disable = "disabled" if current_config.running_on_rpi: wifi_country_code_disable = "" ip = current_config.remote_tester_ip port = app_variables.flask_http_port remote_tester_online_status = app_generic_functions.check_tester_online_status( ip, port) remote_tester_colour = "#B71C1C" if remote_tester_online_status == "Online": remote_tester_colour = "darkgreen" remote_ip = current_config.remote_tester_ip remote_port = app_variables.flask_http_port remote_version = str( app_generic_functions.get_remote_data("http://" + remote_ip + ":" + str(remote_port) + "/Version"))[2:-1] if 3 > len(remote_version) or len(remote_version) > 14: remote_version = "NA" return render_template( "index.html", RemoteIPandPort=current_config.remote_tester_ip + ":" + str(app_variables.flask_http_port), RemoteVersion=remote_version, TestsRunning=tests_running_msg, MTRChecked=app_variables.html_mtr_checked, iPerfChecked=app_variables.html_iperf_checked, IPHostname=str(gethostname()), DisabledButton=button_disabled, OSVersion=app_generic_functions.get_os_name_version(), InternetIPAddress=get_ip_from_socket(), KootnetVersion=current_config.app_version, FreeDiskSpace=app_generic_functions.get_disk_free_percent(), RemoteTesterStatus=remote_tester_online_status, RemoteTesterStatusColor=remote_tester_colour, Results_MTR=mtr_results, Results_iPerf=iperf_results, CheckediPerfServer=iperf_server_enabled, InteractiveIP=current_config.local_ethernet_ip, ServerIP=current_config.remote_tester_ip, iPerfPort=current_config.iperf_port, MTRCount=current_config.mtr_run_count, CheckedWaveShare27EInk=wave_share_27_enabled, EthernetCheckedDHCP=ethernet_dhcp, EthernetIPv4Address=get_dhcpcd_ip(), EthernetIPv4Subnet=current_config.local_ethernet_subnet, EthernetIPGateway=current_config.local_ethernet_gateway, EthernetIPDNS1=current_config.local_ethernet_dns1, EthernetIPDNS2=current_config.local_ethernet_dns2, WirelessCheckedDHCP=wireless_dhcp, WifiCountryCodeDisabled=wifi_country_code_disable, WirelessIPv4Address=get_dhcpcd_ip(wireless=True), WirelessIPv4Subnet=current_config.local_wireless_subnet, WirelessIPGateway=current_config.local_wireless_gateway, WirelessIPDNS1=current_config.local_wireless_dns1, WirelessIPDNS2=current_config.local_wireless_dns2, WirelessCountryCode=current_config.wifi_country_code, CheckedWiFiSecurityWPA1=wifi_type_wpa, CheckedWiFiSecurityNone1=wifi_type_none, SSID1=current_config.wifi_ssid)
def update_cached_variables(): """ Updates app_cached_variables.py variables. """ global first_run if first_run: first_run = False thread_function(_update_ks_info_table_data) demo_mode = app_config_access.primary_config.demo_mode if not app_cached_variables.running_with_root: click_msg = "Without root access, the following functions will be unavailable - " click_msg += "Hardware Sensors, Network Configurations, Upgrade & Power commands" icon = "fas fa-exclamation-triangle" notification_short_msg = "Warning: Not running with root<br>Click Here for more information" atpro_notifications.add_custom_message(notification_short_msg, click_msg=click_msg, icon=icon) if demo_mode: click_msg = "In Demo mode, there are no login prompts and the following functions will be unavailable - " click_msg += "Network Configurations, SSL, Change Login, Upgrade & Power commands" notification_short_msg = "Info: Running in Demo mode<br>Click Here for more information" atpro_notifications.add_custom_message(notification_short_msg, click_msg=click_msg) if default_http_flask_user == app_cached_variables.http_flask_user and not demo_mode: if verify_password_to_hash(default_http_flask_password): atpro_notifications.manage_default_login_detected() if app_cached_variables.current_platform == "Linux": try: os_release_content_lines = get_file_content( "/etc/os-release").split("\n") os_release_name = "" for line in os_release_content_lines: name_and_value = line.split("=") if name_and_value[0].strip() == "PRETTY_NAME": os_release_name = name_and_value[1].strip()[1:-1] app_cached_variables.operating_system_name = str(os_release_name) except Exception as error: logger.sensors_logger.error("Error caching OS Name: " + str(error)) app_cached_variables.operating_system_name = "NA" if app_cached_variables.operating_system_name[:8] == "Raspbian": try: if app_cached_variables.running_with_root: wifi_config_lines = get_file_content( file_locations.wifi_config_file).split("\n") else: wifi_config_lines = "" app_cached_variables.wifi_country_code = network_wifi.get_wifi_country_code( wifi_config_lines) app_cached_variables.wifi_ssid = network_wifi.get_wifi_ssid( wifi_config_lines) app_cached_variables.wifi_security_type = network_wifi.get_wifi_security_type( wifi_config_lines) app_cached_variables.wifi_psk = network_wifi.get_wifi_psk( wifi_config_lines) except Exception as error: logger.primary_logger.warning( "Error checking WiFi configuration: " + str(error)) try: dhcpcd_config_lines = get_file_content( file_locations.dhcpcd_config_file).split("\n") if not network_ip.check_for_dhcp(dhcpcd_config_lines): app_cached_variables.ip = network_ip.get_dhcpcd_ip( dhcpcd_config_lines) app_cached_variables.ip_subnet = network_ip.get_subnet( dhcpcd_config_lines) app_cached_variables.gateway = network_ip.get_gateway( dhcpcd_config_lines) app_cached_variables.dns1 = network_ip.get_dns( dhcpcd_config_lines) app_cached_variables.dns2 = network_ip.get_dns( dhcpcd_config_lines, dns_server=1) except Exception as error: logger.primary_logger.warning("Error checking dhcpcd.conf: " + str(error)) try: app_cached_variables.total_ram_memory = round( psutil.virtual_memory().total / 1024 / 1024 / 1024, 3) except Exception as error: logger.primary_logger.warning("Error caching total RAM: " + str(error)) try: app_cached_variables.total_disk_space = round( psutil.disk_usage("/").total / 1024 / 1024 / 1024, 2) except Exception as error: logger.primary_logger.warning("Error caching total Disk Space: " + str(error)) last_updated = "" if not os.path.isfile(file_locations.program_last_updated): logger.sensors_logger.debug( "Previous version file not found - Creating version file") write_file_to_disk(file_locations.program_last_updated, "No Update Detected") last_updated_file = get_file_content(file_locations.program_last_updated) last_updated_lines = last_updated_file.split("\n") for line in last_updated_lines: last_updated += str(line) app_cached_variables.program_last_updated = last_updated.strip() app_cached_variables.zipped_db_backup_list = get_names_list_from_dir( file_locations.database_backup_folder) app_cached_variables.uploaded_databases_list = get_names_list_from_dir( file_locations.uploaded_databases_folder) _update_cached_sensor_reboot_count() _update_cached_note_variables() _update_cached_ip() _update_cached_hostname()