add some rich to the simple dicom checking

This commit is contained in:
Ross
2023-10-23 16:51:27 +01:00
parent d3aba9a71e
commit 2a597dc783
3 changed files with 12 additions and 13 deletions
+9 -11
View File
@@ -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: