Commit e62e7716 authored by Rashad Kanavath's avatar Rashad Kanavath
Browse files

BUG: workaround for failing python test due to bug in libdl python on centos5

parent b5627f5a
# Import the otb applications package
import otbApplication
import sys
# The following line creates an instance of the Convert application
Convert = otbApplication.Registry.CreateApplication("Convert")
import sys
def test(otbApplication, argv):
# The following line creates an instance of the Convert application
Convert = otbApplication.Registry.CreateApplication("Convert")
# The following lines set all the application parameters:
Convert.SetParameterString("in", sys.argv[1])
# The following lines set all the application parameters:
Convert.SetParameterString("in", argv[1])
Convert.SetParameterString("out", sys.argv[2])
Convert.SetParameterString("out", argv[2])
Convert.SetParameterString("type","linear")
Convert.SetParameterString("type","linear")
# The following line execute the application
sys.exit(Convert.ExecuteAndWriteOutput())
# The following line execute the application
sys.exit(Convert.ExecuteAndWriteOutput())
import otbApplication
import sys
RadiometricIndices = otbApplication.Registry.CreateApplication('RadiometricIndices')
RadiometricIndices.SetParameterString("in", sys.argv[1])
RadiometricIndices.SetParameterString("out", sys.argv[2])
RadiometricIndices.SetParameterInt("channels.red", 3)
RadiometricIndices.SetParameterInt("channels.green", 2)
RadiometricIndices.SetParameterInt("channels.nir", 4)
RadiometricIndices.SetParameterStringList("list",
["Vegetation:NDVI","Vegetation:RVI","Vegetation:IPVI"])
print RadiometricIndices.GetParameterStringList("list")
def test(otbApplication, argv):
RadiometricIndices = otbApplication.Registry.CreateApplication('RadiometricIndices')
RadiometricIndices.SetParameterString("in", argv[1])
RadiometricIndices.SetParameterString("out", argv[2])
RadiometricIndices.SetParameterInt("channels.red", 3)
RadiometricIndices.SetParameterInt("channels.green", 2)
RadiometricIndices.SetParameterInt("channels.nir", 4)
print RadiometricIndices.GetParameterValue("list")
RadiometricIndices.SetParameterStringList("list", ["Vegetation:NDVI","Vegetation:RVI","Vegetation:IPVI"])
RadiometricIndices.ExecuteAndWriteOutput()
\ No newline at end of file
print RadiometricIndices.GetParameterStringList("list")
print RadiometricIndices.GetParameterValue("list")
RadiometricIndices.ExecuteAndWriteOutput()
import otbApplication
app = otbApplication.Registry_CreateApplication('TrainImagesClassifier')
app.SetParameterFloat('classifier.libsvm.opt',True)
print app.GetParameterValue('classifier.libsvm.opt')
def test(otb, argv):
app = otb.Registry.CreateApplication('TrainImagesClassifier')
app.SetParameterFloat('classifier.libsvm.opt',True)
print app.GetParameterValue('classifier.libsvm.opt')
import otbApplication,sys
app = otbApplication.Registry.CreateApplication('Rasterization')
try:
app.GetParameterInt('szx')
except RuntimeError as e:
print "Exception message : " + e.args[0]
if e.args[0].startswith("boost::bad_any_cast"):
sys.exit(1)
sys.exit(0)
from sys import exit
def test(otb, argv):
app = otb.Registry.CreateApplication('Rasterization')
try:
app.GetParameterInt('szx')
except RuntimeError, e:
print "Exception message : " + e.args[0]
if e.args[0].startswith("boost::bad_any_cast"):
exit(1)
exit(0)
......@@ -11,94 +11,107 @@ if(WIN32)
endif(WIN32)
add_test( NAME pyTvSmoothing
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonSmoothingTest.py
${OTB_DATA_ROOT}/Input/ToulouseExtract_WithGeom.tif
${TEMP}/pyTvSmoothing_ )
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
PythonSmoothingTest
${OTB_DATA_ROOT}/Input/ToulouseExtract_WithGeom.tif
${TEMP}/pyTvSmoothing_ )
add_test( NAME pyTvRescale
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonRescaleTest.py
${OTB_DATA_ROOT}/Input/ToulouseExtract_WithGeom.tif
${TEMP}/pyTvRescale)
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
PythonRescaleTest
${OTB_DATA_ROOT}/Input/ToulouseExtract_WithGeom.tif
${TEMP}/pyTvRescale)
add_test( NAME pyTvHyperspectralUnmixingUCLS
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonHyperspectralUnmixing1.py
${OTB_DATA_ROOT}/Input/Hyperspectral/synthetic/hsi_cube.tif
${TEMP}/pyTvHyperspectralUnmixing_ucls.tif
${OTB_DATA_ROOT}/Input/Hyperspectral/synthetic/endmembers.tif
ucls
)
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
PythonHyperspectralUnmixing1
${OTB_DATA_ROOT}/Input/Hyperspectral/synthetic/hsi_cube.tif
${TEMP}/pyTvHyperspectralUnmixing_ucls.tif
${OTB_DATA_ROOT}/Input/Hyperspectral/synthetic/endmembers.tif
ucls
)
add_test( NAME pyTvBug440
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Bug440.py
${OTB_DATA_ROOT}/Input/scene.png
${TEMP}/pyTvBug440Output.tif
)
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
Bug440
${OTB_DATA_ROOT}/Input/scene.png
${TEMP}/pyTvBug440Output.tif
)
add_test( NAME pyTvBug804
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Bug804.py
)
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
Bug804
)
add_test( NAME pyTvBug823
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Bug823.py
)
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
Bug823
)
add_test( NAME pyTvBug736
COMMAND ${TEST_DRIVER}
--compare-image ${NOTOL}
${BASELINE}/apTvRIRadiometricVegetationIndices.tif
${TEMP}/pyTvBug736Output.tif
Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Bug736.py
${OTB_DATA_ROOT}/Input/veryverySmallFSATSW.tif
${TEMP}/pyTvBug736Output.tif
)
COMMAND ${TEST_DRIVER}
--compare-image ${NOTOL}
${BASELINE}/apTvRIRadiometricVegetationIndices.tif
${TEMP}/pyTvBug736Output.tif
Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
Bug736
${OTB_DATA_ROOT}/Input/veryverySmallFSATSW.tif
${TEMP}/pyTvBug736Output.tif
)
add_test( NAME pyTvBandMathOutXML
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonOutXMLTest.py
${OTB_DATA_ROOT}/Input/verySmallFSATSW_r.tif
${OTB_DATA_ROOT}/Input/verySmallFSATSW_nir.tif
${OTB_DATA_ROOT}/Input/verySmallFSATSW.tif
${TEMP}/pyTvBandMathOutXML.tif
${TEMP}/pyTvBandMathOutXML.xml
)
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
PythonOutXMLTest
${OTB_DATA_ROOT}/Input/verySmallFSATSW_r.tif
${OTB_DATA_ROOT}/Input/verySmallFSATSW_nir.tif
${OTB_DATA_ROOT}/Input/verySmallFSATSW.tif
${TEMP}/pyTvBandMathOutXML.tif
${TEMP}/pyTvBandMathOutXML.xml
)
add_test( NAME pyTvBandMathInXML
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonInXMLTest.py
${INPUTDATA}/pyTvBandMathInXML.xml
${OTB_DATA_ROOT}/Input/verySmallFSATSW_r.tif
${OTB_DATA_ROOT}/Input/verySmallFSATSW_nir.tif
${OTB_DATA_ROOT}/Input/verySmallFSATSW.tif
${TEMP}/pyTvBandMathInXML.tif
)
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
PythonInXMLTest
${INPUTDATA}/pyTvBandMathInXML.xml
${OTB_DATA_ROOT}/Input/verySmallFSATSW_r.tif
${OTB_DATA_ROOT}/Input/verySmallFSATSW_nir.tif
${OTB_DATA_ROOT}/Input/verySmallFSATSW.tif
${TEMP}/pyTvBandMathInXML.tif
)
add_test( NAME pyTvNumpyIO
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonNumpyTest.py
${OTB_DATA_ROOT}/Examples/ROI_QB_MUL_1_SVN_CLASS_MULTI.png
${TEMP}/pyTvNumpyIO_SmoothingOut.png )
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
PythonNumpyTest
${OTB_DATA_ROOT}/Examples/ROI_QB_MUL_1_SVN_CLASS_MULTI.png
${TEMP}/pyTvNumpyIO_SmoothingOut.png )
add_test( NAME pyTvNewStyleParameters
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonNewStyleParametersTest.py
${OTB_DATA_ROOT}/Input/poupees.tif
${TEMP}/pyTvNewStyleParametersTest.tif
${OTB_DATA_ROOT}/Input/apTvUtSmoothingTest_OutXML.xml)
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
PythonNewStyleParametersTest
${OTB_DATA_ROOT}/Input/poupees.tif
${TEMP}/pyTvNewStyleParametersTest.tif
${OTB_DATA_ROOT}/Input/apTvUtSmoothingTest_OutXML.xml)
add_test( NAME pyTvNewStyleParametersInstanciateAll
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonNewStyleParametersInstanciateAllTest.py
)
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
PythonNewStyleParametersInstanciateAllTest
)
add_test( NAME pyTvConnectApplications
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonConnectApplications.py
${OTB_DATA_ROOT}/Input/poupees.tif
${TEMP}/pyTvConnectApplicationsOutput.tif)
add_test( NAME pyTvConnectApplications
COMMAND ${TEST_DRIVER} Execute
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/PythonTestDriver.py
PythonConnectApplications
${OTB_DATA_ROOT}/Input/poupees.tif
${TEMP}/pyTvConnectApplicationsOutput.tif)
# -*- coding: utf-8 -*-
#
# Example on the use of the Rescale
# Example on the use of the Rescale
#
from sys import argv
import otbApplication as otb
app1 = otb.Registry.CreateApplication("Smoothing")
app2 = otb.Registry.CreateApplication("Smoothing")
app3 = otb.Registry.CreateApplication("Smoothing")
app4 = otb.Registry.CreateApplication("ConcatenateImages")
def test(otb, argv):
app1 = otb.Registry.CreateApplication("Smoothing")
app2 = otb.Registry.CreateApplication("Smoothing")
app3 = otb.Registry.CreateApplication("Smoothing")
app4 = otb.Registry.CreateApplication("ConcatenateImages")
app1.IN = argv[1]
app1.Execute()
app1.IN = argv[1]
app1.Execute()
app2.SetParameterInputImage("in",app1.GetParameterOutputImage("out"))
app2.Execute()
app2.SetParameterInputImage("in",app1.GetParameterOutputImage("out"))
app2.Execute()
app3.IN = argv[1]
app3.Execute()
app3.IN = argv[1]
app3.Execute()
app4.AddImageToParameterInputImageList("il",app2.GetParameterOutputImage("out"));
app4.AddImageToParameterInputImageList("il",app3.GetParameterOutputImage("out"));
app4.AddImageToParameterInputImageList("il",app2.GetParameterOutputImage("out"));
app4.AddImageToParameterInputImageList("il",app3.GetParameterOutputImage("out"));
app4.OUT = argv[2]
app4.ExecuteAndWriteOutput()
app4.OUT = argv[2]
app4.ExecuteAndWriteOutput()
# -*- coding: utf-8 -*-
#
# Example on the use of the Rescale
# Example on the use of the Rescale
#
from sys import argv
import otbApplication as otb
app = otb.Registry.CreateApplication("HyperspectralUnmixing")
def test(otb, argv):
app = otb.Registry.CreateApplication("HyperspectralUnmixing")
# input image
app.SetParameterString("in", argv[1])
# input image
app.SetParameterString("in", argv[1])
#output image
app.SetParameterString("out", argv[2])
#output image
app.SetParameterString("out", argv[2])
#input endmembers
app.SetParameterString("ie", argv[3])
#input endmembers
app.SetParameterString("ie", argv[3])
#unmixing algorithm
app.SetParameterString("ua", argv[4])
#unmixing algorithm
app.SetParameterString("ua", argv[4])
app.ExecuteAndWriteOutput()
app.ExecuteAndWriteOutput()
......@@ -3,16 +3,15 @@
#
# Example on the use of the inxml via BandMath
#
from sys import argv
import otbApplication as otb
app = otb.Registry_CreateApplication('BandMath')
def test(otb, argv):
app = otb.Registry.CreateApplication('BandMath')
imagelist = argv[2:-1]
app.SetParameterStringList("il", imagelist, True)
imagelist = argv[2:-1]
app.SetParameterStringList("il", imagelist, True)
app.SetParameterString("inxml", argv[1])
app.UpdateParameters()
app.SetParameterString("inxml", argv[1])
app.UpdateParameters()
app.SetParameterString("out" , argv[-1])
app.ExecuteAndWriteOutput()
app.SetParameterString("out" , argv[-1])
app.ExecuteAndWriteOutput()
import otbApplication as otb
import operator
import inspect
# List applications
appNames = [app for app in otb.Registry.GetAvailableApplications()]
for appName in appNames:
app = otb.Registry.CreateApplication(appName)
# Generate parameters
parameters = app.GetParametersKeys()
for param in parameters:
upParam = param.upper()
if app.HasValue(param):
operator.attrgetter(upParam)(app)
def test(otb, argv):
# List applications
appNames = [app for app in otb.Registry.GetAvailableApplications()]
for appName in appNames:
app = otb.Registry.CreateApplication(appName)
# Generate parameters
parameters = app.GetParametersKeys()
for param in parameters:
upParam = param.upper()
if app.HasValue(param):
operator.attrgetter(upParam)(app)
......@@ -6,125 +6,123 @@
#
# Example on the use of otb "pythonization"
#
from sys import argv
import otbApplication as otb
def cm_assert(a,b):
print "debug print before assert check: '%s'== '%s'" %(a, b)
assert a == b
app = otb.Registry.CreateApplication('OrthoRectification')
def test(otb, argv):
app = otb.Registry.CreateApplication('OrthoRectification')
#test GetParameterTypeAsString() method in python.
print app.GetParameterTypeAsString(otb.ParameterType_InputImage)
print app.GetParameterTypeAsString(otb.ParameterType_String)
print app.GetParameterTypeAsString(otb.ParameterType_Empty)
# test GetParameterTypeAsString() method in python.
print app.GetParameterTypeAsString(otb.ParameterType_InputImage)
print app.GetParameterTypeAsString(otb.ParameterType_String)
print app.GetParameterTypeAsString(otb.ParameterType_Empty)
# one test for each parameter type (string, float, int, ...)
# one test for each parameter type (string, float, int, ...)
# # parameter group io.in
# 1 - input image parameter set
app.IO.IN = argv[1]
cm_assert(app.GetParameterString('io.in'), argv[1])
# # parameter group io.in
# 1 - input image parameter set
app.IO.IN = argv[1]
cm_assert(app.GetParameterString('io.in'), argv[1])
# 2 - input image parameter get
cm_assert(app.IO.IN, argv[1])
# 2 - input image parameter get
cm_assert(app.IO.IN, argv[1])
# # parameter group io.in
# 3 - output image parameter set
app.IO.OUT = argv[2]
cm_assert(app.GetParameterString('io.out'), argv[2])
# # parameter group io.in
# 3 - output image parameter set
app.IO.OUT = argv[2]
cm_assert(app.GetParameterString('io.out'), argv[2])
# 4 - output image parameter get
cm_assert(app.IO.OUT, argv[2])
# 4 - output image parameter get
cm_assert(app.IO.OUT, argv[2])
# 5 - choice with sub parameters set
app.MAP = 'lambert2'
cm_assert(app.GetParameterString('map'), 'lambert2')
# 5 - choice with sub parameters set
app.MAP = 'lambert2'
cm_assert(app.GetParameterString('map'), 'lambert2')
# 5.1 - choice with sub parameters get
app.SetParameterString('map', 'wgs')
cm_assert('wgs', app.MAP)
# 5.1 - choice with sub parameters get
app.SetParameterString('map', 'wgs')
cm_assert('wgs', app.MAP)
# 5.2 - choice with sub parameters set
app.MAP = 'lambert93'
cm_assert('lambert93', app.GetParameterString('map'))
# 5.2 - choice with sub parameters set
app.MAP = 'lambert93'
cm_assert('lambert93', app.GetParameterString('map'))
# 5.3 - choice with sub parameters set
app.SetParameterString('map', 'epsg')
cm_assert(app.MAP, 'epsg')
# 5.3 - choice with sub parameters set
app.SetParameterString('map', 'epsg')
cm_assert(app.MAP, 'epsg')
# 6 - int type 2nd level sub parameters of choice parameter set
app.MAP.EPSG.CODE = 32768
cm_assert(32768, app.GetParameterInt('map.epsg.code'))
# 6 - int type 2nd level sub parameters of choice parameter set
app.MAP.EPSG.CODE = 32768
cm_assert(32768, app.GetParameterInt('map.epsg.code'))
# 7 - another choice with sub parameters set
app.MAP = 'utm'
cm_assert('utm', app.GetParameterString('map'))
# 7 - another choice with sub parameters set
app.MAP = 'utm'
cm_assert('utm', app.GetParameterString('map'))
# 8 - int type sub parameters of choice parameter set
app.MAP.UTM.ZONE = 47
cm_assert(47,app.GetParameterInt('map.utm.zone'))
# 8 - int type sub parameters of choice parameter set
app.MAP.UTM.ZONE = 47
cm_assert(47,app.GetParameterInt('map.utm.zone'))
# 9 - int type sub parameters of choice parameter get
app.SetParameterInt('map.utm.zone', 31)
cm_assert(app.MAP.UTM.ZONE, 31)
# 9 - int type sub parameters of choice parameter get
app.SetParameterInt('map.utm.zone', 31)
cm_assert(app.MAP.UTM.ZONE, 31)
# 10 - bool type sub parameters of choice parameter get
app.DisableParameter('map.utm.northhem')
cm_assert(app.MAP.UTM.NORTHHEM, False)
# 10 - bool type sub parameters of choice parameter get
app.DisableParameter('map.utm.northhem')
cm_assert(app.MAP.UTM.NORTHHEM, False)
# 11 - bool type sub parameters of choice parameter set
app.MAP.UTM.NORTHHEM = True
cm_assert(True, app.IsParameterEnabled('map.utm.northhem') )
# 11 - bool type sub parameters of choice parameter set
app.MAP.UTM.NORTHHEM = True
cm_assert(True, app.IsParameterEnabled('map.utm.northhem') )
#12 - simple choice parameter set
app.OUTPUTS.MODE = 'auto'
cm_assert('auto', app.GetParameterString('outputs.mode'))
#12 - simple choice parameter set
app.OUTPUTS.MODE = 'auto'
cm_assert('auto', app.GetParameterString('outputs.mode'))
#13 - simple choice parameter get
app.SetParameterString('outputs.mode', 'orthofit')
cm_assert(app.OUTPUTS.MODE, 'orthofit')
#13 - simple choice parameter get
app.SetParameterString('outputs.mode', 'orthofit')
cm_assert(app.OUTPUTS.MODE, 'orthofit')
#14 - inputxml parameter set
app.INXML = argv[3]
cm_assert(app.GetParameterString('inxml'), argv[3])
#14 - inputxml parameter set
app.INXML = argv[3]
cm_assert(app.GetParameterString('inxml'), argv[3])
#15 - outputxml parameter get
app.SetParameterString('outxml', 'output.xml')
cm_assert("output.xml", app.OUTXML)
#15 - outputxml parameter get
app.SetParameterString('outxml', 'output.xml')
cm_assert("output.xml", app.OUTXML)
#16 - parameter float get
app.SetParameterFloat('elev.default', 5.0)
cm_assert(5.0, app.ELEV.DEFAULT)
#16 - parameter float get
app.SetParameterFloat('elev.default', 5.0)
cm_assert(5.0, app.ELEV.DEFAULT)
#17 -parameter float set
app.ELEV.DEFAULT = -2.5
cm_assert(app.GetParameterFloat('elev.default'), -2.5)
#17 -parameter float set
app.ELEV.DEFAULT = -2.5
cm_assert(app.GetParameterFloat('elev.default'), -2.5)
#18 - parameter ram get
app.SetParameterString('opt.ram', '256')
cm_assert(256, app.OPT.RAM)
#18 - parameter ram get
app.SetParameterString('opt.ram', '256')
cm_assert(256