Check for updates to the Pwnagotchi clone at PWN_REPO_PATH. Returns {'installed': False} when /opt/pwnagotchi/.git is absent so the UI can hide the Updates card and prompt the user to install first.
()
| 9966 | except Exception as e: |
| 9967 | logger.error(f"Error removing old network data file {filename}: {e}") |
| 9968 | |
| 9969 | # Update the last SSID record |
| 9970 | try: |
| 9971 | os.makedirs(os.path.dirname(last_ssid_file), exist_ok=True) |
| 9972 | with open(last_ssid_file, 'w', encoding='utf-8') as f: |
| 9973 | f.write(current_ssid) |
| 9974 | except Exception as e: |
| 9975 | logger.error(f"Error updating last SSID file: {e}") |
| 9976 | |
| 9977 | except Exception as e: |
| 9978 | logger.error(f"Error checking network switch: {e}") |
| 9979 | |
| 9980 | |
| 9981 | def _is_ip_address(value): |
| 9982 | """Check if a value is a valid IP address""" |
| 9983 | try: |
| 9984 | ipaddress.ip_address(value) |
| 9985 | return True |
| 9986 | except ValueError: |
| 9987 | return False |
| 9988 | |
| 9989 | |
| 9990 | def _normalize_port_value(port_entry): |
| 9991 | """Normalize a port entry string for consistent comparisons""" |
| 9992 | try: |
| 9993 | if not port_entry: |
| 9994 | return None |
| 9995 | |
| 9996 | cleaned = port_entry.strip() |
| 9997 | if not cleaned: |
| 9998 | return None |
| 9999 | |
| 10000 | # Extract numeric portion if the port entry contains protocol suffixes |
| 10001 | match = re.match(r"^(\d+)", cleaned) |
| 10002 | if match: |
| 10003 | return match.group(1) |
| 10004 | |
| 10005 | return cleaned |
| 10006 | except Exception: |
| 10007 | return None |
| 10008 | |
| 10009 | |
| 10010 | def _normalize_alive_value(value): |
| 10011 | """Normalize alive column values to boolean""" |
| 10012 | try: |
| 10013 | if value is None: |
| 10014 | return True |
| 10015 | |
| 10016 | if isinstance(value, bool): |
| 10017 | return value |
| 10018 | |
| 10019 | if isinstance(value, (int, float)): |
| 10020 | return value != 0 |
| 10021 | |
| 10022 | text = str(value).strip().lower() |
| 10023 | if text in ('', '1', 'true', 'yes', 'up', 'alive', 'online'): |
| 10024 | return True |
| 10025 | if text in ('0', 'false', 'no', 'down', 'dead', 'offline'): |