From 1d6e5bd55ffd44376edf185ce2737d24494ced36 Mon Sep 17 00:00:00 2001 From: regrain Date: Thu, 13 Jan 2005 10:37:55 +0000 Subject: [PATCH] * Now, python test might work on systems -- BeNours --- ChangeLog | 3 ++ gdcmPython/CMakeLists.txt | 8 ----- gdcmPython/demo/CMakeLists.txt | 5 ++-- gdcmPython/demo/PrintHeader.py.in | 50 +++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 11 deletions(-) create mode 100644 gdcmPython/demo/PrintHeader.py.in diff --git a/ChangeLog b/ChangeLog index 58ab6ab1..bd232deb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2005-01-13 Benoit Regrain + * Now, python test might work on systems + 2005-01-13 Jean-Pierre Roux * FIX : First entry following group 0002 was lost for Explicit Big Endian Transfer Syntax files diff --git a/gdcmPython/CMakeLists.txt b/gdcmPython/CMakeLists.txt index c417bf45..91fe9c0d 100644 --- a/gdcmPython/CMakeLists.txt +++ b/gdcmPython/CMakeLists.txt @@ -243,14 +243,6 @@ IF(GDCM_VTK) ) ENDIF(GDCM_VTK) -#----------------------------------------------------------------------------- -# Copy the testSuite.py file -CONFIGURE_FILE( - ${GDCM_SOURCE_DIR}/gdcmPython/testSuite.py - ${GDCM_BINARY_DIR}/gdcmPython/testSuite.py - COPYONLY -) - #----------------------------------------------------------------------------- # Add test from demo subdir: diff --git a/gdcmPython/demo/CMakeLists.txt b/gdcmPython/demo/CMakeLists.txt index 93c5dd15..f34df9c5 100644 --- a/gdcmPython/demo/CMakeLists.txt +++ b/gdcmPython/demo/CMakeLists.txt @@ -17,7 +17,7 @@ MARK_AS_ADVANCED(PYTHON_EXECUTABLE) IF(PYTHON_EXECUTABLE) ADD_TEST(Python-PrintHeader ${PYTHON_EXECUTABLE} - ${GDCM_SOURCE_DIR}/gdcmPython/demo/PrintHeader.py + ${GDCM_BINARY_DIR}/gdcmPython/demo/PrintHeader.py ) ELSE(PYTHON_EXECUTABLE) MESSAGE(FATAL_ERROR "You requested testing for python, but python was not @@ -28,8 +28,7 @@ ENDIF(PYTHON_EXECUTABLE) # Copy all the demo directory content to the cmake bin # Without it, tests can't be launched CONFIGURE_FILE( - ${GDCM_SOURCE_DIR}/gdcmPython/demo/PrintHeader.py + ${GDCM_SOURCE_DIR}/gdcmPython/demo/PrintHeader.py.in ${GDCM_BINARY_DIR}/gdcmPython/demo/PrintHeader.py - COPYONLY ) diff --git a/gdcmPython/demo/PrintHeader.py.in b/gdcmPython/demo/PrintHeader.py.in new file mode 100644 index 00000000..affa5f48 --- /dev/null +++ b/gdcmPython/demo/PrintHeader.py.in @@ -0,0 +1,50 @@ +import sys +import os + +sys.path.append('${GDCM_BINARY_DIR}') +if os.name == 'posix': + sys.path.append('${GDCM_BINARY_DIR}/bin') +else: + sys.path.append('${GDCM_BINARY_DIR}/bin/Release') + sys.path.append('${GDCM_BINARY_DIR}/bin/Debug') + +from gdcmPython.core import * + +### Get filename from command line or default it +try: + fileName = sys.argv[1] +except IndexError: + fileName = os.path.join(GDCM_DATA_PATH, "test.acr") + +try: + printLevel = int(sys.argv[2]) +except IndexError: + printLevel = 1 + +#if not os.path.isfile(FileName): +# print "Cannot open file ", FileName +# sys.exit() + +# On debugging purposes uncomment the next line +#s = raw_input("Hit any key in this window to exit") + +### Build the header element list +print fileName, type(fileName) +header = gdcm.Header(fileName) +if not header.IsReadable(): + print "The ", fileName, " file is not readable with gdcm. Sorry." + sys.exit() + +print "##############################################################" +print "### Display all the elements and their respective values" +print "## found in the ", fileName, " file." +print "##############################################################" + +header.Initialize() +val=header.GetNextEntry() +while(val): + val.Print() + print "" + val=header.GetNextEntry() +val=None + -- 2.45.0