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

Method __init__

src/astroprint/additionaltasks.py:30–57  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

28 REQUIRED_TASK_KEYS = ['id', 'steps']
29
30 def __init__(self):
31 self._settings = settings()
32 self._logger = logging.getLogger(__name__)
33 self.data = []
34 self.errorOnRemove = None
35
36 self._logger.info("Loading Additional Tasks...")
37
38 tasksDir = self._settings.getBaseFolder('tasks')
39 #tasksDir = "%s/tasks" % self._settings.getConfigFolder()
40
41 if os.path.isdir(tasksDir):
42 taskFiles = glob.glob('%s/*.yaml' % tasksDir)
43 if len(taskFiles):
44 self._logger.info("Found %d tasks to load." % len(taskFiles))
45 for f in taskFiles:
46 try:
47 with open(f, "r") as f:
48 config = yaml.safe_load(f)
49 if config:
50 self.data.append(config)
51
52 except:
53 self._logger.info("There was an error loading %s:" % f, exc_info= True)
54
55 return
56
57 self._logger.info("No additional Tasks present.")
58
59 def getTask(self, id):
60 for task in self.data:

Callers

nothing calls this directly

Calls 3

settingsFunction · 0.90
appendMethod · 0.80
getBaseFolderMethod · 0.45

Tested by

no test coverage detected