comparison Plugins/Worklists/Run.py @ 108:7aee4cc64fca

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 10 Jun 2017 11:07:26 +0200
parents 2af6c0fb850d
children 5b6812f8cc38
comparison
equal deleted inserted replaced
107:fddb35f7289d 108:7aee4cc64fca
76 ## 76 ##
77 77
78 DATABASE = os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..', 'Database', 'Worklists'))) 78 DATABASE = os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..', 'Database', 'Worklists')))
79 WORKING = os.path.join(DATABASE, 'Working') 79 WORKING = os.path.join(DATABASE, 'Working')
80 80
81 print('Database directory: %s' % DATABASE)
82 print('Working directory: %s' % WORKING)
83
81 try: 84 try:
82 os.mkdir(WORKING) 85 os.mkdir(WORKING)
83 except Exception as e: 86 except Exception as e:
84 # The working folder has already been created 87 # The working folder has already been created
85 pass 88 pass
104 stderr = subprocess.STDOUT).splitlines() 107 stderr = subprocess.STDOUT).splitlines()
105 108
106 if len(filter(lambda x: x.startswith('E:'), a)) > 0: 109 if len(filter(lambda x: x.startswith('E:'), a)) > 0:
107 raise Exception('Error while running findscu') 110 raise Exception('Error while running findscu')
108 111
109 b = map(lambda x: x[3:], filter(lambda x: x.startswith('W: ---') or x.startswith('W: ('), a)) 112 b = map(lambda x: x[3:], filter(lambda x: (x.startswith('I: ---') or
113 x.startswith('W: ---') or
114 x.startswith('I: (') or
115 x.startswith('W: (')), a))
110 b = map(lambda x: re.sub(r'\s*#.*', '', x), b) 116 b = map(lambda x: re.sub(r'\s*#.*', '', x), b)
111 117
112 answers = [] 118 answers = []
113 current = [] 119 current = []
120 isQuery = True
114 121
115 for l in b: 122 for l in b:
123 l = l.replace('\0', '')
124
116 if l[0] == '-': 125 if l[0] == '-':
117 # This is a separator between DICOM datasets 126 if isQuery:
118 if len(current) > 0: 127 isQuery = False
119 answers.append(current) 128 else:
120 current = [] 129 # This is a separator between DICOM datasets
130 if len(current) > 0:
131 answers.append(current)
132 current = []
121 133
122 else: 134 else:
123 tag = l[1:10].lower() 135 if not isQuery:
124 if not tag in ignoreTags: 136 tag = l[1:10].lower()
125 current.append(l) 137 if not tag in ignoreTags:
138 current.append(l)
126 139
127 if len(current) > 0: 140 if len(current) > 0:
128 answers.append(current) 141 answers.append(current)
129 142
130 return answers 143 return answers