MCPcopy
hub / github.com/corpnewt/gibMacOS / get_catalog_data

Method get_catalog_data

gibMacOS.py:190–229  ·  view source on GitHub ↗
(self, local = False)

Source from the content-addressed store, hash-verified

188 )
189
190 def get_catalog_data(self, local = False):
191 # Gets the data based on our current_catalog
192 url = self.build_url(catalog=self.current_catalog, version=self.current_macos)
193 self.u.head("Downloading Catalog")
194 if local:
195 self.u.info("Checking for:\n - {}".format(
196 self.local_catalog
197 ))
198 if os.path.exists(self.local_catalog):
199 self.u.info(" - Found - loading...")
200 try:
201 with open(self.local_catalog, "rb") as f:
202 self.catalog_data = plist.load(f)
203 assert isinstance(self.catalog_data,dict)
204 return True
205 except Exception as e:
206 self.u.info(" - Error loading: {}".format(e))
207 self.u.info(" - Downloading instead...\n")
208 else:
209 self.u.info(" - Not found - downloading instead...\n")
210 self.u.info("Currently downloading {} catalog from:\n\n{}\n".format(self.current_catalog, url))
211 try:
212 b = self.d.get_bytes(url, self.interactive)
213 self.u.info("")
214 self.catalog_data = plist.loads(b)
215 except:
216 self.u.info("Error downloading!")
217 return False
218 try:
219 # Assume it's valid data - dump it to a local file
220 if local or self.force_local:
221 self.u.info(" - Saving to:\n - {}".format(
222 self.local_catalog
223 ))
224 with open(self.local_catalog, "wb") as f:
225 plist.dump(self.catalog_data, f)
226 except Exception as e:
227 self.u.info(" - Error saving: {}".format(e))
228 return False
229 return True
230
231 def get_installers(self, plist_dict = None):
232 if not plist_dict:

Callers 3

set_prodsMethod · 0.95
pick_catalogMethod · 0.95
pick_macosMethod · 0.95

Calls 4

build_urlMethod · 0.95
headMethod · 0.80
infoMethod · 0.80
get_bytesMethod · 0.80

Tested by

no test coverage detected