| 189 | self._cache_loaded = True |
| 190 | |
| 191 | def _update_cache(self): |
| 192 | try: |
| 193 | import requests |
| 194 | |
| 195 | # Respect the --no-verify-ssl switch |
| 196 | response = requests.get(self.MODEL_INFO_URL, timeout=5, verify=self.verify_ssl) |
| 197 | if response.status_code == 200: |
| 198 | self.content = response.json() |
| 199 | try: |
| 200 | self.cache_file.write_text(json.dumps(self.content, indent=4)) |
| 201 | except OSError: |
| 202 | pass |
| 203 | except Exception as ex: |
| 204 | print(str(ex)) |
| 205 | try: |
| 206 | # Save empty dict to cache file on failure |
| 207 | self.cache_file.write_text("{}") |
| 208 | except OSError: |
| 209 | pass |
| 210 | |
| 211 | def get_model_from_cached_json_db(self, model): |
| 212 | data = self.local_model_metadata.get(model) |