6
0

ProjectManager.py 876 B

1234567891011121314151617181920212223242526272829
  1. from glob import glob
  2. from json import load
  3. from os import path
  4. from pycs import ApplicationStatus
  5. class ProjectManager:
  6. def __init__(self, app_status: ApplicationStatus):
  7. # TODO create projects folder if it does not exist
  8. # find projects
  9. for folder in glob('projects/*'):
  10. # load project.json
  11. with open(path.join(folder, 'project.json'), 'r') as file:
  12. project = load(file)
  13. project['status'] = 'close'
  14. app_status['projects'].append(project)
  15. # subscribe to changes
  16. app_status['projects'].subscribe(self.update)
  17. def update(self, data):
  18. # detect project to load
  19. to_load = list(filter(lambda x: x['status'] == 'load', data))
  20. for project in to_load:
  21. # TODO actually load pipeline
  22. project['status'] = 'open'