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