From c06d2028b7b6bc73ef919e793c647ad8ebbb03f1 Mon Sep 17 00:00:00 2001 From: plup <plup@plup.io> Date: Sat, 28 Mar 2020 19:51:24 +0100 Subject: [PATCH] feature: added install custom command --- djangoldp/management/commands/install.py | 22 +++++++++++++++++++ .../production/{packages.yml => config.yml} | 0 .../{project_name => server}/__init__.py-tpl | 0 .../{project_name => server}/settings.py-tpl | 0 .../{project_name => server}/urls.py-tpl | 0 .../{project_name => server}/wsgi.py-tpl | 0 6 files changed, 22 insertions(+) create mode 100644 djangoldp/management/commands/install.py rename djangoldp/templates/production/{packages.yml => config.yml} (100%) rename djangoldp/templates/production/{project_name => server}/__init__.py-tpl (100%) rename djangoldp/templates/production/{project_name => server}/settings.py-tpl (100%) rename djangoldp/templates/production/{project_name => server}/urls.py-tpl (100%) rename djangoldp/templates/production/{project_name => server}/wsgi.py-tpl (100%) diff --git a/djangoldp/management/commands/install.py b/djangoldp/management/commands/install.py new file mode 100644 index 00000000..3c2b475b --- /dev/null +++ b/djangoldp/management/commands/install.py @@ -0,0 +1,22 @@ +import subprocess +import sys +from django.core.management.base import BaseCommand, CommandError + +class Command(BaseCommand): + + help = 'Install server dependencies' + + def handle(self, *args, **options): + + try: + # load dependencies from the configuration + from django.conf import settings + cmd = [sys.executable, "-m", "pip", "install"] + cmd.extend(settings.DEPENDENCIES) + subprocess.run(cmd).check_returncode() + + self.stdout.write(self.style.SUCCESS('Installation done!')) + + except subprocess.CalledProcessError as e: + self.stderr.write(self.style.ERROR(f'Error with: {e}')) + diff --git a/djangoldp/templates/production/packages.yml b/djangoldp/templates/production/config.yml similarity index 100% rename from djangoldp/templates/production/packages.yml rename to djangoldp/templates/production/config.yml diff --git a/djangoldp/templates/production/project_name/__init__.py-tpl b/djangoldp/templates/production/server/__init__.py-tpl similarity index 100% rename from djangoldp/templates/production/project_name/__init__.py-tpl rename to djangoldp/templates/production/server/__init__.py-tpl diff --git a/djangoldp/templates/production/project_name/settings.py-tpl b/djangoldp/templates/production/server/settings.py-tpl similarity index 100% rename from djangoldp/templates/production/project_name/settings.py-tpl rename to djangoldp/templates/production/server/settings.py-tpl diff --git a/djangoldp/templates/production/project_name/urls.py-tpl b/djangoldp/templates/production/server/urls.py-tpl similarity index 100% rename from djangoldp/templates/production/project_name/urls.py-tpl rename to djangoldp/templates/production/server/urls.py-tpl diff --git a/djangoldp/templates/production/project_name/wsgi.py-tpl b/djangoldp/templates/production/server/wsgi.py-tpl similarity index 100% rename from djangoldp/templates/production/project_name/wsgi.py-tpl rename to djangoldp/templates/production/server/wsgi.py-tpl -- GitLab