29 lines
781 B
Python
29 lines
781 B
Python
from io import StringIO
|
|
from json import loads as json_parse, dumps as _json_stringify
|
|
from typing import Dict, Optional, Any
|
|
import paho.mqtt.client as mqtt
|
|
from .project import Project
|
|
|
|
def json_stringify(o: Any) -> str:
|
|
return _json_stringify(o, separators=(',', ':'))
|
|
|
|
class ProjectManager():
|
|
def __init__(self, mqttThread=None) :
|
|
self._projectList = []
|
|
self._mqttThread = mqttThread
|
|
|
|
def create(self, project):
|
|
new_project = Project(project, self._mqttThread)
|
|
self._projectList.append(new_project)
|
|
return new_project
|
|
|
|
def remove(self, index):
|
|
self._projectList[index].stop()
|
|
del self._projectList[index]
|
|
|
|
def get(self):
|
|
return self._projectList
|
|
|
|
def run(self, project):
|
|
project.start()
|