changeset 252:01db33301c3d

valgrind
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 02 Aug 2019 16:12:39 +0200
parents 16a5e79accff
children 74c693e093ce
files Plugins/WSI/Run.py
diffstat 1 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/WSI/Run.py	Fri Aug 02 16:04:41 2019 +0200
+++ b/Plugins/WSI/Run.py	Fri Aug 02 16:12:39 2019 +0200
@@ -60,6 +60,8 @@
 parser.add_argument('--to-tiff',
                     default = '/home/jodogne/Subversion/orthanc-wsi/Applications/i/OrthancWSIDicomToTiff',
                     help = 'Password to the REST API')
+parser.add_argument('--valgrind', help = 'Use valgrind while running the DICOM-izer',
+                    action = 'store_true')
 parser.add_argument('--force', help = 'Do not warn the user',
                     action = 'store_true')
 parser.add_argument('options', metavar = 'N', nargs = '*',
@@ -90,11 +92,20 @@
                         password = args.password,
                         restPort = args.rest)
 
-def CallDicomizer(p):
-    subprocess.check_output([ args.dicomizer,
-                              '--username=%s' % args.username,
-                              '--password=%s' % args.password ] + p,
-                            stderr=subprocess.STDOUT)
+def CallDicomizer(suffix):
+    prefix = []
+    if args.valgrind:
+        prefix = [ 'valgrind' ]
+    
+    log = subprocess.check_output(prefix + [ args.dicomizer,
+                                             '--username=%s' % args.username,
+                                             '--password=%s' % args.password ] + suffix,
+                                  stderr=subprocess.STDOUT)
+
+    # If using valgrind, only print the lines from the log starting
+    # with '==' (they contain the report from valgrind)
+    if args.valgrind:
+        print('\n'.join(filter(lambda x: x.startswith('=='), log.splitlines())))
 
 
 class Orthanc(unittest.TestCase):