MCPcopy Create free account
hub / github.com/AstroPrint/AstroBox / SoftwareManager

Class SoftwareManager

src/astroprint/software.py:303–729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301 self._completionCb(False)
302
303class SoftwareManager(object):
304 softwareCheckInterval = 86400 #1 day
305
306 def __init__(self):
307 self._settings = settings()
308 self._updater = None
309 self._infoDir = self._settings.get(['software', 'infoDir']) or os.path.join(os.path.dirname(self._settings._configfile), 'software')
310 self._logger = logging.getLogger(__name__)
311 self._wasBadShutdown = None
312 self._badShutdownShown = False
313 self._status = 'idle'
314 self._releases = None
315
316 self.lastCompletionPercent = None
317 self.lastMessage = None
318
319 self.forceUpdateInfo = None
320 self.data = {
321 "version": {
322 "major": 0,
323 "minor": 0,
324 "build": u'0',
325 "date": None,
326 "commit": None
327 },
328 "variant": {
329 "id": None,
330 "name": 'AstroBox'
331 },
332 "manufacturer_pkg_id": None,
333 "platform": 'pcduino',
334 "additional": []
335 }
336
337 if self._infoDir:
338 config = None
339
340 def merge_dict(a,b):
341 for key in b:
342 if isinstance(b[key], dict):
343 merge_dict(a[key], b[key])
344 else:
345 a[key] = b[key]
346
347 with open(os.path.join(self._infoDir,'software.yaml'), "r") as f:
348 config = yaml.safe_load(f)
349
350 merge_dict(self.data, config)
351
352 #Check if there's a manufacturer package
353 manufacturerFile = os.path.join(self._infoDir,'manufacturer.yaml')
354 if os.path.isfile(manufacturerFile):
355 with open(manufacturerFile, "r") as f:
356 config = yaml.safe_load(f)
357
358 self.data['additional'].append(config)
359 self.data['manufacturer_pkg_id'] = config['package']['id']
360

Callers 1

softwareManagerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected