api python library : raise AttributeError(“No constructor defined”)

I'm trying to execute a python script using saga_api library, unfortunately I'm stopped in the first step :(. when I tray to execute this command on python: aga_api.CSG_Module_Library() I have this error message:

def init(self, args, *kwargs):
    raise AttributeError("No constructor defined")
        AttributeError: No constructor defined

and it dose the same thing on windows !

Can you, please, help me to overpass this step ?!

System : Ubuntu 13.10 x64
python version : 2.7.5+
saga_api library version : 2.1.1
SAGA program version : 2.1.1
swig version : 2.0.10

This is the code:

!/usr/bin/env python

import saga_api, sys, os

def Import_raster(in__grid):

print saga_api.SAGA_API_Get_Version()

fmlb = '/usr/lib/saga/libio_gdal.so'

Library = saga_api.CSG_Module_Library() # here is the bug !!!

if Library.Create(saga_api.CSG_String(fmlb)) == 0:
    print 'unable to load SAGA module library'
    return 0

print '... success'

Module = Library.Get_Module('GDAL: Import Raster')

Parms = Module.Get_Parameters()
Parms('FILES').Set_Value(in__grid) 
Parms('SELECT').Set_Value(1) 
Parms('TRANSFORM').Set_Value(0)
Parms('INTERPOL').Set_Value(0)

Parms = Module.Get_Parameters(0) # additional parameter list

print Module.Get_Name() + ': ' + Parms('FILE').asString()

if Module.Execute() == 0:
    print 'module execution failed'
    return 0
print 'module successfully executed'

print 'save as SAGA grid'
if Parms('GRID').asGrid().Save(saga_api.CSG_String(in__grid)) == 0:
    print '... failed'
    return 0
print '... success'

return 1

if name == ' main ':

if len( sys.argv ) != 4:
    print 'Usage: this_script.py <in: gridfile> <out: gridfile> <in: shapefile> <out: shapefile>'
    in__grid = '/home/.../CC432_landsat8.tif'
    in__grid = os.path.abspath(in__grid)

else:
    in__grid = sys.argv[1]

    if os.path.split(in__grid)[0] == '':
        in__grid    = './' + in__grid

Import_raster(in__grid)

print "Done !"

Here is the init : .... class CSG_Module_Library(_object): swig_setmethods = {} setattr = lambda self, name, value: _swig_setattr(self, CSG_Module_Library, name, value) swig_getmethods = {} getattr = lambda self, name: _swig_getattr(self, CSG_Module_Library, name) def init (self, *args, **kwargs): raise AttributeError("No constructor defined") repr = _swig_repr def is_Valid(self): return _saga_api.CSG_Module_Library_is_Valid(self) def Get_File_Name(self): return _saga_api.CSG_Module_Library_Get_File_Name(self) def Get_Library_Name(self): return _saga_api.CSG_Module_Library_Get_Library_Name(self) def Get_Info(self, *args): return _saga_api.CSG_Module_Library_Get_Info(self, *args) def Get_Name(self): return _saga_api.CSG_Module_Library_Get_Name(self) def Get_Description(self): return _saga_api.CSG_Module_Library_Get_Description(self) def Get_Author(self): return _saga_api.CSG_Module_Library_Get_Author(self) def Get_Version(self): return _saga_api.CSG_Module_Library_Get_Version(self) def Get_Summary(self, *args): return _saga_api.CSG_Module_Library_Get_Summary(self, *args) def Get_Count(self): return _saga_api.CSG_Module_Library_Get_Count(self) def Get_Menu(self, *args): return _saga_api.CSG_Module_Library_Get_Menu(self, *args) def Get_Module(self, *args): return _saga_api.CSG_Module_Library_Get_Module(self, *args) def Get_Module_Grid(self, *args): return _saga_api.CSG_Module_Library_Get_Module_Grid(self, *args) def Get_Module_Interactive(self, *args): return _saga_api.CSG_Module_Library_Get_Module_Interactive(self, *args) def Get_Module_Grid_Interactive(self, *args): return _saga_api.CSG_Module_Library_Get_Module_Grid_Interactive(self, *args) CSG_Module_Library_swigregister = _saga_api.CSG_Module_Library_swigregister CSG_Module_Library_swigregister(CSG_Module_Library) ....

链接地址: http://www.djcxy.com/p/56426.html

上一篇: Python readline,使用Cmd界面循环制表符

下一篇: api python库:raise AttributeError(“No constructor defined”)