add some rich to the simple dicom checking
This commit is contained in:
@@ -4,29 +4,27 @@ from django.core.management.base import BaseCommand, CommandError
|
|||||||
import pydicom
|
import pydicom
|
||||||
import pydicom.errors
|
import pydicom.errors
|
||||||
|
|
||||||
|
from django_rich.management import RichCommand
|
||||||
|
|
||||||
|
from rich.progress import track
|
||||||
|
|
||||||
import six
|
import six
|
||||||
import os
|
import os
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(RichCommand):
|
||||||
help = 'Checks dicom files for anonymisation'
|
help = 'Checks dicom files for anonymisation'
|
||||||
|
|
||||||
#def add_arguments(self, parser):
|
#def add_arguments(self, parser):
|
||||||
# parser.add_argument('poll_ids', nargs='+', type=int)
|
# parser.add_argument('poll_ids', nargs='+', type=int)
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
#for poll_id in options['poll_ids']:
|
self.console.print("[bold blue]Finding files:[/bold blue]")
|
||||||
# try:
|
|
||||||
# poll = Poll.objects.get(pk=poll_id)
|
|
||||||
# except Poll.DoesNotExist:
|
|
||||||
# raise CommandError('Poll "%s" does not exist' % poll_id)
|
|
||||||
|
|
||||||
# poll.opened = False
|
|
||||||
# poll.save()
|
|
||||||
|
|
||||||
# self.stdout.write(self.style.SUCCESS('Successfully closed poll "%s"' % poll_id))
|
|
||||||
files = get_all_media()
|
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:
|
try:
|
||||||
ds = pydicom.dcmread(file, force=False)
|
ds = pydicom.dcmread(file, force=False)
|
||||||
except pydicom.errors.InvalidDicomError:
|
except pydicom.errors.InvalidDicomError:
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ INSTALLED_APPS = [
|
|||||||
"django_filters",
|
"django_filters",
|
||||||
"easy_thumbnails",
|
"easy_thumbnails",
|
||||||
"filer",
|
"filer",
|
||||||
"mptt",
|
#"mptt",
|
||||||
"sortedm2m",
|
"sortedm2m",
|
||||||
"dal",
|
"dal",
|
||||||
"dal_select2",
|
"dal_select2",
|
||||||
|
|||||||
+2
-1
@@ -35,4 +35,5 @@ debugpy
|
|||||||
git+https://github.com/jazzband/django-cookie-consent#django-cookie-consent
|
git+https://github.com/jazzband/django-cookie-consent#django-cookie-consent
|
||||||
django-crispy-forms
|
django-crispy-forms
|
||||||
django-ninja
|
django-ninja
|
||||||
crispy-bootstrap4
|
crispy-bootstrap4
|
||||||
|
django-rich
|
||||||
Reference in New Issue
Block a user