diff --git a/generic/management/commands/checkdicoms.py b/generic/management/commands/checkdicoms.py index 86106815..f46d5598 100644 --- a/generic/management/commands/checkdicoms.py +++ b/generic/management/commands/checkdicoms.py @@ -4,29 +4,27 @@ from django.core.management.base import BaseCommand, CommandError import pydicom import pydicom.errors +from django_rich.management import RichCommand + +from rich.progress import track + import six import os -class Command(BaseCommand): +class Command(RichCommand): help = 'Checks dicom files for anonymisation' #def add_arguments(self, parser): # parser.add_argument('poll_ids', nargs='+', type=int) def handle(self, *args, **options): - #for poll_id in options['poll_ids']: - # try: - # poll = Poll.objects.get(pk=poll_id) - # except Poll.DoesNotExist: - # raise CommandError('Poll "%s" does not exist' % poll_id) + self.console.print("[bold blue]Finding files:[/bold blue]") - # poll.opened = False - # poll.save() - - # self.stdout.write(self.style.SUCCESS('Successfully closed poll "%s"' % poll_id)) files = get_all_media() - for file in files: + self.console.print(f"[bold blue]Files to check: {len(files)}[/bold blue]") + + for file in track(files, description="Checking file..."): try: ds = pydicom.dcmread(file, force=False) except pydicom.errors.InvalidDicomError: diff --git a/rad/settings.py b/rad/settings.py index 71eb5322..570cc651 100644 --- a/rad/settings.py +++ b/rad/settings.py @@ -55,7 +55,7 @@ INSTALLED_APPS = [ "django_filters", "easy_thumbnails", "filer", - "mptt", + #"mptt", "sortedm2m", "dal", "dal_select2", diff --git a/requirements.txt b/requirements.txt index 6b438f45..b9ed83eb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -35,4 +35,5 @@ debugpy git+https://github.com/jazzband/django-cookie-consent#django-cookie-consent django-crispy-forms django-ninja -crispy-bootstrap4 \ No newline at end of file +crispy-bootstrap4 +django-rich \ No newline at end of file