changeset 108:7aee4cc64fca

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 10 Jun 2017 11:07:26 +0200
parents fddb35f7289d
children 5b6812f8cc38
files Database/Worklists/Encodings/issue49-latin1.wl Plugins/Worklists/Run.py
diffstat 2 files changed, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
Binary file Database/Worklists/Encodings/issue49-latin1.wl has changed
--- a/Plugins/Worklists/Run.py	Fri Jun 09 15:33:14 2017 +0200
+++ b/Plugins/Worklists/Run.py	Sat Jun 10 11:07:26 2017 +0200
@@ -78,6 +78,9 @@
 DATABASE = os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..', 'Database', 'Worklists')))
 WORKING = os.path.join(DATABASE, 'Working')
 
+print('Database directory: %s' % DATABASE)
+print('Working directory: %s' % WORKING)
+
 try:
     os.mkdir(WORKING)
 except Exception as e:
@@ -106,23 +109,33 @@
         if len(filter(lambda x: x.startswith('E:'), a)) > 0:
             raise Exception('Error while running findscu')
 
-        b = map(lambda x: x[3:], filter(lambda x: x.startswith('W: ---') or x.startswith('W: ('), a))
+        b = map(lambda x: x[3:], filter(lambda x: (x.startswith('I: ---') or
+                                                   x.startswith('W: ---') or
+                                                   x.startswith('I: (') or
+                                                   x.startswith('W: (')), a))
         b = map(lambda x: re.sub(r'\s*#.*', '', x), b)
 
         answers = []
         current = []
+        isQuery = True
 
         for l in b:
+            l = l.replace('\0', '')
+            
             if l[0] == '-':
-                # This is a separator between DICOM datasets
-                if len(current) > 0:
-                    answers.append(current)
-                    current = []
+                if isQuery:
+                    isQuery = False
+                else:
+                    # This is a separator between DICOM datasets
+                    if len(current) > 0:
+                        answers.append(current)
+                        current = []
 
             else:
-                tag = l[1:10].lower()
-                if not tag in ignoreTags:
-                    current.append(l)
+                if not isQuery:
+                    tag = l[1:10].lower()
+                    if not tag in ignoreTags:
+                        current.append(l)
 
         if len(current) > 0:
             answers.append(current)