+2005-01-13 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+ * Now, python test might work on systems
+
2005-01-13 Jean-Pierre Roux <jpr@creatis.univ-lyon1.fr>
* FIX : First entry following group 0002 was lost for
Explicit Big Endian Transfer Syntax files
)
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:
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
# 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
)
--- /dev/null
+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
+