def schedulehostdeletion(hostname, offlinedict, updatesignal, settingswidget, lock,…
- User
def schedule_host_deletion(hostname, offline_dict, update_signal, settings_widget, lock, main_window): def delete_host(): normalized_hostname = hostname.upper() with lock: if normalized_hostname in offline_dict: store_name = offline_dict[normalized_hostname]['store_name'] # Log the host coming online log_online( hostname, store_name, offline_dict, normalized_hostname, offline_dict[normalized_hostname]['inspect_status'] ) # Remove the host from the offline_dict del offline_dict[normalized_hostname] # Save the offline state save_offline_state('offline_state.json', offline_dict) # Play sound when host comes back online hostname_lower = hostname.lower() if any(fnmatch.fnmatch(hostname_lower, pattern.lower()) for pattern in settings_widget.sound_alert_patterns): if hasattr(main_window, 'sound_manager'): message = f"Big C {store_name} return to Online" audio_filename = f"{message}.mp3" audio_path = os.path.join('sounds', audio_filename) fallback_sound_file = "returnonline.mp3"
def play_sound(): if os.path.exists(audio_path): main_window.sound_manager.play(audio_path) else: print(f"Sound file '{audio_filename}' does not exist. Attempting to download...") downloaded_file = download_audio(message) if downloaded_file and os.path.exists(downloaded_file): main_window.sound_manager.play(downloaded_file) else: if os.path.exists(fallback_sound_file): print(f"Failed to download. Playing fallback sound file: {fallback_sound_file}") main_window.sound_manager.play(fallback_sound_file) else: print("Failed to download sound file and no fallback sound available.") sound_thread = threading.Thread(target=play_sound) sound_thread.start() # Remove from exception hosts if necessary if normalized_hostname in settings_widget.exception_hosts: settings_widget.exception_hosts.remove(normalized_hostname) settings_widget.update_exception_hosts_signal.emit(settings_widget.exception_hosts) else: print(f"Hostname {normalized_hostname} was not in offline_dict") # Emit the update signal to refresh the GUI update_signal.emit() # Schedule the deletion after 5 seconds timer = threading.Timer(5.0, delete_host) timer.start()check queue if more than 5, just play first 5 queue
- Assistant
- User
File "C:\Users\Noname\phyper\phyper.v49.5.office.py", line 1233 nonlocal playback_active ^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: no binding for nonlocal 'playback_active' found
- Assistant