Mercurial > hg > orthanc-tests
comparison Tests/Toolbox.py @ 318:bac7cc80f240
dicomweb: test_wado_transcoding
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 22 Jun 2020 16:15:31 +0200 |
parents | b8399213b840 |
children | ec13ace43bde |
comparison
equal
deleted
inserted
replaced
317:5ea07ecade93 | 318:bac7cc80f240 |
---|---|
340 | 340 |
341 | 341 |
342 class ExternalCommandThread: | 342 class ExternalCommandThread: |
343 @staticmethod | 343 @staticmethod |
344 def ExternalCommandFunction(arg, stop_event, command, env): | 344 def ExternalCommandFunction(arg, stop_event, command, env): |
345 external = subprocess.Popen(command, env = env) | 345 with open(os.devnull, 'w') as devnull: |
346 | 346 external = subprocess.Popen(command, env = env, stderr = devnull) |
347 while (not stop_event.is_set()): | 347 |
348 error = external.poll() | 348 while (not stop_event.is_set()): |
349 if error != None: | 349 error = external.poll() |
350 # http://stackoverflow.com/a/1489838/881731 | 350 if error != None: |
351 os._exit(-1) | 351 # http://stackoverflow.com/a/1489838/881731 |
352 stop_event.wait(0.1) | 352 os._exit(-1) |
353 stop_event.wait(0.1) | |
353 | 354 |
354 print('Stopping the external command') | 355 print('Stopping the external command') |
355 external.terminate() | 356 external.terminate() |
356 external.communicate() # Wait for the command to stop | 357 external.communicate() # Wait for the command to stop |
357 | 358 |
387 | 388 |
388 def GetTransferSyntax(dicom): | 389 def GetTransferSyntax(dicom): |
389 with tempfile.NamedTemporaryFile(delete = True) as f: | 390 with tempfile.NamedTemporaryFile(delete = True) as f: |
390 f.write(dicom) | 391 f.write(dicom) |
391 f.flush() | 392 f.flush() |
392 data = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ]) | 393 |
394 with open(os.devnull, 'w') as devnull: | |
395 data = subprocess.check_output([ FindExecutable('dcm2xml'), f.name ], | |
396 stderr = devnull) | |
393 | 397 |
394 return re.search('<data-set xfer="(.*?)"', data).group(1) | 398 return re.search('<data-set xfer="(.*?)"', data).group(1) |
395 | 399 |
396 | 400 |
397 def HasGdcmPlugin(orthanc): | 401 def HasGdcmPlugin(orthanc): |