Browse Source

Fixed case about volume for AtomaticImport is not exist

Aleksandr Lizin 9 years ago
parent
commit
7e2fd662be

+ 8 - 17
automaticimport/views.py

@@ -36,7 +36,7 @@ def trigger(request):
 
     for path in paths:
         automatic_import = AutomaticImport.objects(path=path).first()
-        if(automatic_import is None):
+        if automatic_import is None:
             volume = Volume()
             volume.imageSequence = True
             volume.path = os.path.join(path, DEFAULT_SLICE_FOLDER)
@@ -49,15 +49,11 @@ def trigger(request):
             automatic_import.volume_id = str(volume.id)
             automatic_import.save()
 
-            # TODO: Why do next line is not work?
             logger.info("Sequence in dir: " + path + " will be processed")
-            print("Sequence in dir: " + path + " will be processed")
-
+        
     if len(volumes_to_process) > 0:
-        # TODO: Why do next line is not work?
         logger.info("Processing sequences in dir: " + settings.DEFAULT_IMPORT_PATH + " ...")
-        print("Processing sequences in dir: " + settings.DEFAULT_IMPORT_PATH + " ...")
-
+        
         process = Process(target=SliceGenerator.generateListOfVolumes, args=(volumes_to_process,))
         process.start()
 
@@ -71,23 +67,18 @@ def clear(request):
     models = AutomaticImport.objects()
 
     if len(models) == 0:
-        # TODO: Why do next line is not work?
         logger.info("No automatic imported volumes!")
-        print("No automatic imported volumes!")
-
+        
     for automatic_import in models:
         try:
             volume = Volume.objects(id=automatic_import.volume_id)[0]
-        except (IndexError, ValidationError) as e:
-            return handleException(request, id, e)
-
-        volume.delete()
+            volume.delete()
+        except IndexError as e:
+            logger.info("Volume with id = " + str(automatic_import.volume_id + " which was binded to AutomaticImport for path = " + automatic_import.path + " not found!"))
 
         automatic_import.delete()
 
-        # TODO: Why do next line is not work?
         logger.info("Automaticly generated volume with id: " + automatic_import.volume_id + " deleted!")
-        print("Automaticly generated volume with id: " + automatic_import.volume_id + " deleted!")
-
+        
 
     return HttpResponse(json.dumps({'deleted': len(models)}), content_type="json")

+ 4 - 0
imageprocessing/sliceMapCreator.py

@@ -14,6 +14,8 @@ import copy
 
 import logging
 
+import pdb
+
 logger = logging.getLogger(__name__)
 
 
@@ -190,6 +192,8 @@ def processFrames(frames, frameFrom, frameTo, imageFrom, imageTo, imgFormat, des
 
     del frames
 
+    # pdb.set_trace()
+
     return __resizeSprites(sprites, destSize, imgFormat)
 
 

+ 5 - 0
visualization/settings.py

@@ -213,6 +213,11 @@ LOGGING = {
             'level': 'DEBUG',
             'propagate': False,
         },
+        'automaticimport': {
+            'handlers': ['console'],
+            'level': 'DEBUG',
+            'propagate': False,
+        },
     },
 }
 

+ 1 - 1
volumes/processing/service/SliceGenerator.py

@@ -12,7 +12,7 @@ import numpy as np
 from imageprocessing import tiffPreparer, sliceMapCreator, binary_preparer
 from . import MultiProcessUByte, Normalizer
 
-import logging
+import logging, pdb
 
 logger = logging.getLogger(__name__)