Detect if running on Raspberry Pi Zero (vs Pi 4/5 which are server-capable)
(self)
| 179 | self.capabilities.cpu_cores = os.cpu_count() or 1 |
| 180 | except Exception: |
| 181 | self.capabilities.cpu_cores = 1 |
| 182 | |
| 183 | # RAM detection |
| 184 | try: |
| 185 | import psutil |
| 186 | mem = psutil.virtual_memory() |
| 187 | self.capabilities.total_ram_gb = mem.total / (1024 ** 3) |
| 188 | self.capabilities.available_ram_gb = mem.available / (1024 ** 3) |
| 189 | except ImportError: |
| 190 | # Fallback: read from /proc/meminfo |
| 191 | self._detect_ram_from_proc() |
| 192 | |
| 193 | # Pi Zero detection |
| 194 | self._detect_pi_zero() |
| 195 | |
| 196 | # Determine if server capable |
| 197 | # Pi 5 with 8GB is definitely capable, Pi 4/5 with 4GB gets partial features |
| 198 | self.capabilities.is_server_capable = ( |
| 199 | arch in self.SUPPORTED_ARCHS and |
| 200 | self.capabilities.total_ram_gb >= self.MIN_RAM_GB and |
| 201 | self.capabilities.cpu_cores >= self.MIN_CORES and |
| 202 | not self.capabilities.is_pi_zero |
| 203 | ) |
| 204 | |
| 205 | # Log detailed capability info for debugging |
| 206 | logger.debug(f"Capability check: arch={arch} (supported={arch in self.SUPPORTED_ARCHS}), " |
| 207 | f"ram={self.capabilities.total_ram_gb:.1f}GB (min={self.MIN_RAM_GB}GB), " |
| 208 | f"cores={self.capabilities.cpu_cores} (min={self.MIN_CORES}), " |
| 209 | f"is_pi_zero={self.capabilities.is_pi_zero}") |
| 210 | |
| 211 | def _detect_ram_from_proc(self): |
| 212 | """Fallback RAM detection from /proc/meminfo""" |
| 213 | try: |
| 214 | with open('/proc/meminfo', 'r') as f: |
| 215 | for line in f: |
| 216 | if line.startswith('MemTotal:'): |
| 217 | # Value is in kB |
| 218 | kb = int(line.split()[1]) |
no test coverage detected