From 54acf0f254e30b280eeddfa980cd5cc0b9445638 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 15 May 2019 14:56:31 -0400 Subject: [PATCH] Add the checkdependencies command Signed-off-by: Roberto Rosario --- HISTORY.rst | 1 + docs/releases/3.2.rst | 1 + mayan/apps/dependencies/classes.py | 30 ++++++++++++++++++- .../management/commands/checkdependencies.py | 12 ++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 mayan/apps/dependencies/management/commands/checkdependencies.py diff --git a/HISTORY.rst b/HISTORY.rst index bee71a8699..28ddb00811 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -268,6 +268,7 @@ * The document link URL when mailed is now composed of the COMMON_PROJECT_URL + document URL instead of the Site domain. +* Add the checkdependencies command. 3.1.11 (2019-04-XX) =================== diff --git a/docs/releases/3.2.rst b/docs/releases/3.2.rst index 65267119ce..00dabce915 100644 --- a/docs/releases/3.2.rst +++ b/docs/releases/3.2.rst @@ -578,6 +578,7 @@ Other changes * The document link URL when mailed is now composed of the COMMON_PROJECT_URL + document URL instead of the Site domain. +* Add the checkdependencies command. Removals diff --git a/mayan/apps/dependencies/classes.py b/mayan/apps/dependencies/classes.py index 4b7f75b5de..82de9032e3 100644 --- a/mayan/apps/dependencies/classes.py +++ b/mayan/apps/dependencies/classes.py @@ -18,7 +18,7 @@ from django.utils.encoding import ( from django.utils.functional import cached_property from django.utils.module_loading import import_string from django.utils.six import PY3 -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ugettext_lazy as _, ugettext from mayan.apps.common.compat import FileNotFoundErrorException from mayan.apps.common.utils import resolve_attribute @@ -150,6 +150,34 @@ class Dependency(object): def return_sorted(dependencies): return sorted(dependencies, key=lambda x: x.get_label()) + @classmethod + def check_all(cls): + template = '{:<35}{:<10} {:<15} {:<20} {:<15} {:<30} {:<10}' + + print('\n ', end='') + print( + template.format( + ugettext('Name'), ugettext('Type'), ugettext('Version'), + ugettext('App'), ugettext('Environment'), + ugettext('Other data'), ugettext('Check') + ) + ) + print('-' * 140) + + for dependency in cls.get_all(): + print('* ', end='') + print(template.format( + dependency.name, + force_text(dependency.class_name_verbose_name), + force_text(dependency.get_version_string()), + force_text(dependency.app_label_verbose_name()), + force_text(dependency.get_environment_verbose_name()), + force_text(dependency.get_other_data()), + force_text(dependency.check()), + ) + ) + sys.stdout.flush() + @classmethod def get(cls, pk): return cls._registry[pk] diff --git a/mayan/apps/dependencies/management/commands/checkdependencies.py b/mayan/apps/dependencies/management/commands/checkdependencies.py new file mode 100644 index 0000000000..f192047857 --- /dev/null +++ b/mayan/apps/dependencies/management/commands/checkdependencies.py @@ -0,0 +1,12 @@ +from __future__ import unicode_literals + +from django.core import management + +from ...classes import Dependency + + +class Command(management.BaseCommand): + help = 'Output the status of the defined dependencies.' + + def handle(self, *args, **options): + Dependency.check_all()