01234567890123456789012345678901234567890123456789012345678901234567890123456789
59355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975 | <----SKIPPED LINES----> # by the network status being down for at least 30 minutes, as determined # by the .pk file capturing the network status (generated by the # network_monitor.py script). # # Specifically, if the most recent three values of the .pk are all 0s, and # we have been up and running for at least 30 minutes, restart. elif running_minutes > minimum_uptime_minutes: results = MostRecentNetworkStatuses(number_of_intervals) ( network_status_list, last_day, last_interval, first_day, first_interval) = results # Sum the list, handling strings in the list as if they were 0s sum_network_status_list = sum( [x if isinstance(x, int) else 0 for x in network_status_list]) if network_status_list and not sum_network_status_list: # all zeros msg = ( 'Running for %d minutes yet no network for %d intervals (index %d of ' 'day %s to index %d of day %s); rebooting in attempt to re-establish ' 'network connectivity' % ( running_minutes, number_of_intervals, first_day, first_interval, last_day, last_interval)) rpi_restart = True if rpi_restart: Log(msg) SHUTDOWN_SIGNAL = msg return rpi_restart # ---------------------------------------------------------------------------- # Only get here if neither process nor RPi restart # ---------------------------------------------------------------------------- return rpi_restart def MostRecentNetworkStatuses(number_of_intervals): """Returns a list of the most recent number of network statuses. The network status is managed by network_monitory.py, which, every few minutes updates the .pk file with the current network status. The data structure is a dictionary with day names (i.e.: 12-30-2022) and a list of 0s & 1s indicating network down / up respectively, for consecutive <----SKIPPED LINES----> |
01234567890123456789012345678901234567890123456789012345678901234567890123456789
59355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975 | <----SKIPPED LINES----> # by the network status being down for at least 30 minutes, as determined # by the .pk file capturing the network status (generated by the # network_monitor.py script). # # Specifically, if the most recent three values of the .pk are all 0s, and # we have been up and running for at least 30 minutes, restart. elif running_minutes > minimum_uptime_minutes: results = MostRecentNetworkStatuses(number_of_intervals) ( network_status_list, last_day, last_interval, first_day, first_interval) = results # Sum the list, handling strings in the list as if they were 0s sum_network_status_list = sum( [x if isinstance(x, int) else 0 for x in network_status_list]) if network_status_list and not sum_network_status_list: # all zeros msg = ( 'Running for %d minutes yet no network for %d intervals (index %d of ' 'day %s to index %d of day %s); rebooting in attempt to re-establish ' 'network connectivity' % ( running_minutes, number_of_intervals, first_interval, first_day, last_interval, last_day)) rpi_restart = True if rpi_restart: Log(msg) SHUTDOWN_SIGNAL = msg return rpi_restart # ---------------------------------------------------------------------------- # Only get here if neither process nor RPi restart # ---------------------------------------------------------------------------- return rpi_restart def MostRecentNetworkStatuses(number_of_intervals): """Returns a list of the most recent number of network statuses. The network status is managed by network_monitory.py, which, every few minutes updates the .pk file with the current network status. The data structure is a dictionary with day names (i.e.: 12-30-2022) and a list of 0s & 1s indicating network down / up respectively, for consecutive <----SKIPPED LINES----> |