def button_set(self): """ Sends the update configuration command to the Sensor Units IP, along with the new configuration. """ network_commands = app_variables.CreateNetworkSendCommands() ip_list = self.ip_selection.get_verified_ip_list() threads = [] if len(ip_list) > 0: for ip in ip_list: try: if self.combo_dropdown_selection.value == "Installed Sensors": command = sensor_commands.CreateSensorNetworkCommand( ip, self.current_config.network_timeout_data, network_commands.set_installed_sensors) elif self.combo_dropdown_selection.value == "Configuration": command = sensor_commands.CreateSensorNetworkCommand( ip, self.current_config.network_timeout_data, network_commands.set_configuration) elif self.combo_dropdown_selection.value == "Wifi": command = sensor_commands.CreateSensorNetworkCommand( ip, self.current_config.network_timeout_data, network_commands.set_wifi_configuration) elif self.combo_dropdown_selection.value == "Trigger Variances": command = sensor_commands.CreateSensorNetworkCommand( ip, self.current_config.network_timeout_data, network_commands.set_variance_configuration) else: command = sensor_commands.CreateSensorNetworkCommand( ip, self.current_config.network_timeout_data, "") command.command = "" command.command_data = self.textbox_config.value.strip() threads.append( Thread(target=sensor_commands.put_command, args=[command])) except Exception as error: app_logger.sensor_logger.error(str(error)) for thread in threads: thread.start() guizero.info( "Sensors " + self.combo_dropdown_selection.value + " Set", self.combo_dropdown_selection.value + " set & services restarted on:\n" + str(ip_list)[1:-1]) else: app_useful_functions.no_ip_selected_message()
def test_app_sensor_commands(self): print("\nThis REQUIRES an online sensor @ " + sensor_ip) get_network_commands = app_variables.CreateNetworkGetCommands() send_network_commands = app_variables.CreateNetworkSendCommands() network_timeout = config_default.network_timeout_data sensor_command = sensor_commands.CreateSensorNetworkCommand( sensor_ip, network_timeout, "") log_download = sensor_commands.CreateSensorNetworkCommand( sensor_ip, 2, get_network_commands.download_zipped_logs) zip_log_download_url = "http://" + log_download.ip + ":" + log_download.port + log_download.command sensor_commands.download_zipped_logs(zip_log_download_url) sensor_status = sensor_commands.check_sensor_status( sensor_ip, network_timeout) self.assertEqual(sensor_status, "Online") sleep(2) # self.assertTrue(os.path.isfile(save_to + sensor_ip[-3:].replace(".", "_") + "PrimaryLog.txt")) # self.assertTrue(os.path.isfile(save_to + sensor_ip[-3:].replace(".", "_") + "NetworkLog.txt")) # self.assertTrue(os.path.isfile(save_to + sensor_ip[-3:].replace(".", "_") + "SensorsLog.txt")) sensor_command.command = get_network_commands.sensor_name old_hostname = sensor_commands.get_data(sensor_command) verified_bad_hostname = sensor_commands.get_validated_hostname( "^^$##_###This.is$NOT-Good!**") self.assertEqual(verified_bad_hostname, "_________This_is_NOT_Good___") sensor_command.command = send_network_commands.set_host_name sensor_command.command_data = verified_bad_hostname sensor_commands.put_command(sensor_command) sensor_command.command = get_network_commands.sensor_name verify_hostname = sensor_commands.get_data(sensor_command) self.assertEqual(verify_hostname, verified_bad_hostname) sensor_command.command = send_network_commands.set_host_name sensor_command.command_data = old_hostname sensor_commands.put_command(sensor_command) sensor_command.command = get_network_commands.sensor_name verify_hostname = sensor_commands.get_data(sensor_command) self.assertEqual(verify_hostname, old_hostname)
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. """ import guizero from threading import Thread from tkinter import simpledialog from app_modules import app_logger from app_modules import app_variables from app_modules import app_useful_functions from app_modules import sensor_commands network_commands = app_variables.CreateNetworkSendCommands() get_commands = app_variables.CreateNetworkGetCommands() class CreateSensorDisplayWindow: """ Creates a GUI window for displaying sensor readings on the remote sensor Display. """ def __init__(self, app, ip_selection, current_config): self.ip_selection = ip_selection self.current_config = current_config self.readable_column_names = app_variables.CreateSQLColumnsReadable() self.sql_columns = app_variables.CreateSQLColumnNames() self.window = guizero.Window(app, title="Remote Sensor Display", width=275, height=400,
def __init__(self, app, ip_selection, current_config, database_or_sensor): self.database_or_sensor = database_or_sensor self.current_config = current_config self.ip_selection = ip_selection self.selected_ip = "" self.db_location = "" self.database_notes = [] self.database_notes_dates = [] self.database_user_note_dates = [] self.text_variables_generic = CreateGenericNoteVariables() self.text_variables_sensor = CreateSensorNoteVariables() self.text_variables_database = CreateDatabaseNoteVariables() self.sql_column_names = app_variables.CreateSQLColumnNames() self.network_send_commands = app_variables.CreateNetworkSendCommands() self.sensor_get_commands = app_variables.CreateNetworkGetCommands() self.window = guizero.Window(app, title=self.text_variables_database.window_title, width=580, height=525, layout="grid", visible=False) self.text_connected_to = guizero.Text(self.window, text=self.text_variables_database.text_connected_to, color="red", size=8, grid=[1, 1, 3, 1], align="left") self.checkbox_use_current_datetime = guizero.CheckBox(self.window, text=self.text_variables_generic.checkbox_enable_datetime, command=self._reset_datetime, grid=[4, 1, 5, 1], align="left") self.button_connect = guizero.PushButton(self.window, text=self.text_variables_database.button_connect, command=self._open_database, grid=[1, 5], align="left") self.button_back_note = guizero.PushButton(self.window, text="Back", command=self._back_button, grid=[2, 5], align="left") self.text_note_current = guizero.Text(self.window, text=self.text_variables_generic.text_note_current, color="blue", grid=[3, 5], align="top") self.textbox_on_number_notes = guizero.TextBox(self.window, text="0", width=5, grid=[3, 5], align="bottom") self.text_date_label1 = guizero.Text(self.window, text=self.text_variables_generic.text_date_label1, color="blue", grid=[4, 5], align="top") self.textbox_note_date = guizero.TextBox(self.window, text=self.text_variables_generic.textbox_note_date, grid=[4, 5], width=23, align="bottom") self.text_total_notes_label = guizero.Text(self.window, text=self.text_variables_generic.text_total_notes_label, color="blue", grid=[5, 5], align="top") self.textbox_total_notes = guizero.TextBox(self.window, text="0", width=5, grid=[5, 5], align="bottom") self.button_next_note = guizero.PushButton(self.window, text=self.text_variables_generic.button_next_note, command=self._next_button, grid=[6, 5], align="left") self.textbox_current_note = guizero.TextBox(self.window, text=self.text_variables_database.textbox_current_note, width=70, height=25, grid=[1, 10, 6, 1], multiline=True, scrollbar=True, align="left") self.button_new_note = guizero.PushButton(self.window, text=self.text_variables_generic.button_new_note, command=self._database_add_note_button, grid=[1, 12], align="left") self.button_delete_note = guizero.PushButton(self.window, text=self.text_variables_generic.button_delete_note, command=self._database_delete_button, grid=[4, 12], align="left") self.button_update_note = guizero.PushButton(self.window, text=self.text_variables_generic.button_update_note, command=self._database_update_note_button, grid=[5, 12, 2, 1], align="left") # Window Tweaks self.window.tk.resizable(False, False) self._disable_notes_window_functions() self.checkbox_use_current_datetime.value = True self.textbox_current_note.bg = "black" self.textbox_current_note.text_color = "white" self.textbox_current_note.tk.config(insertbackground="red") if database_or_sensor == self.text_variables_generic.sensor_notes_verification: self._change_for_sensor()