Commit 837dcc81 authored by Samuel GAIST's avatar Samuel GAIST

[utils][commands][intall] Refactor "project" handling

It now only tries to install projects based
on the folders inside the beat/beat.examples>.
This will avoid running through the linking
steps again and again when something is not
a project but still listed as one.
parent c8823b66
......@@ -59,6 +59,7 @@ import fnmatch
import logging
import os
import sys
from pathlib import Path
import simplejson
from django.conf import settings
......@@ -1054,13 +1055,17 @@ class Command(BaseCommand):
"beat.examples",
)
# gets a list of all available projects, excluding directories
ignore = ["system", "LICENSE", ".git", ".gitignore", "README.rst"]
projects = os.listdir(self.prefix)
self.projects = []
for candidate in projects:
if (candidate not in ignore) or (candidate not in projects):
self.projects.append(candidate)
# gets a list of all available projects, excluding system as this one
# shall be installed by default and before the others.
ignore = ["system"]
path = Path(self.prefix)
self.projects = [
item.name
for item in path.iterdir()
if item.is_dir()
and not item.name.startswith(".")
and item.name not in ignore
]
def add_arguments(self, parser):
......@@ -1156,21 +1161,14 @@ class Command(BaseCommand):
logger.setLevel(logging.DEBUG)
# Checks projects
if not arguments["project"]:
arguments["project"] = ["test", "advanced"]
projects = list(set(arguments["project"]))
while "system" in arguments["project"]:
logger.warn(
"Removing `system' from the list of projects to "
"install (this is them minimal default anyway)"
)
arguments["project"].remove("system")
for k in arguments["project"]:
if k not in self.projects:
for project in projects:
if project not in self.projects:
logger.error(
"Project `%s' is not available, choose from: %s",
", ".join("`%s'" % k for k in self.projects),
project,
self.projects,
)
sys.exit(1)
......@@ -1210,8 +1208,7 @@ class Command(BaseCommand):
queue = environment.queues.first()
# Iterates over projects to install
for project in ["system"] + arguments["project"]:
for project in ["system"] + projects:
template_data = dict(
system_user=system_user,
plot_user=plot_user,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment