python/swig
Hy, I need help indeed, about python/swig C wrapper. Exactly, I've built a python library from C library and it seem works. Unfortunatly, a gruop of function that requred pointer to pointer parmeters give me a exception like this: "TypeError: in method 'BestRules', argument 1 of type 'value_type **'" I've tryed to use cpointer.i to obtain a pointer to use in function but this don't work. Could you help me? thanks in advace. Gianluca Massei PS. this is my interface.i file: " %module pyRSL %include "cpointer.i" %{ #include "rough.h" #include "raccess.h" #include "rbasic.h" #include "rclass.h" #include "rcore.h" #include "reduct1.h" #include "reduct2.h" #include "rerror.h" #include "rset.h" #include "rsystem.h" #include "rule1.h" #include "rule2.h" %} %include "rough.h" %include "raccess.h" %include "rbasic.h" %include "rclass.h" %include "rcore.h" %include "reduct1.h" %include "reduct2.h" %include "rerror.h" %include "rset.h" %include "rsystem.h" %include "rule1.h" %include "rule2.h" " -- http://mail.python.org/mailman/listinfo/python-list
rough set & python
I've just wrapped the rough set library from C to python. Could anybody help me to test it and debug? thanks Gianluca -- http://mail.python.org/mailman/listinfo/python-list
ctypes help
Hy, I need help about use dll with ctypes. I've compiled my dll C library and I copied it in c:\windows\system32. When I load it with "myDLL=cdll.LoadLibrary(find_library("myDLL.dll"))" It seem all OK but python don't see the dll function. with dir(myDLL) I've only this: ['_FuncPtr', '__class__', '__delattr__', '__dict__', '__doc__', '__getattr__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_handle', '_name'] Could anybody help me Thanks Gianluca -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes help
On 23 Mag, 01:14, Larry Bates <[EMAIL PROTECTED]> wrote: > gianluca wrote: > > Hy, > > I need help about use dll with ctypes. I've compiled my dll C library > > and I copied it in c:\windows\system32. When I load it with > > "myDLL=cdll.LoadLibrary(find_library("myDLL.dll"))" It seem all OK but > > python don't see the dll function. with dir(myDLL) I've only this: > > ['_FuncPtr', '__class__', '__delattr__', '__dict__', '__doc__', > > '__getattr__', '__getattribute__', '__getitem__', '__hash__', > > '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', > > '__repr__', '__setattr__', '__str__', '__weakref__', '_handle', > > '_name'] > > > Could anybody help me > > > Thanks > > > Gianluca > > Since it isn't python, dir can'd do much introspection on the object to > produce > the type of output you desire. You have to know the functions (methods) that > you want to call in your dll and call them. > > -Larry Bates Yes, I know it but when I load a function (a=myDLL.myFUNCT()) I've an exception like this: Traceback (most recent call last): File "", line 1, in myDLL.myFUNCT() File "C:\Python25\lib\ctypes\__init__.py", line 353, in __getattr__ func = self.__getitem__(name) File "C:\Python25\lib\ctypes\__init__.py", line 358, in __getitem__ func = self._FuncPtr((name_or_ordinal, self)) AttributeError: function 'myFUNCT' not found Thanks for help -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes help
On 23 Mag, 07:48, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Thu, 22 May 2008 21:55:41 -0700, gianluca wrote: > > Yes, I know it but when I load a function (a=myDLL.myFUNCT()) I've an > > exception like this: > > > Traceback (most recent call last): > > File "", line 1, in > > myDLL.myFUNCT() > > File "C:\Python25\lib\ctypes\__init__.py", line 353, in __getattr__ > > func = self.__getitem__(name) > > File "C:\Python25\lib\ctypes\__init__.py", line 358, in __getitem__ > > func = self._FuncPtr((name_or_ordinal, self)) > > AttributeError: function 'myFUNCT' not found > > Then maybe the DLL doesn't contain a function called `myFUNCT`. Any > chance you compiled your C as C++ and name mangling kicked in? > > Can you show a minimal C source for a DLL, how you compiled it, what you > did on the Python side to call it, and how it fails? > > Ciao, > Marc 'BlackJack' Rintsch I've located my dll in c:\windows\system32 (in linux I aven't any problem) and I compiled it with dev-c++. The source code is C standard ANSII and is quite havy. If you like I can send it via mail (you can realy at [EMAIL PROTECTED]) . I've tryed to build a wrape with swig olso with same code and I can access at all the function. thanks Gianluca -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes help
On 23 Mag, 12:30, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > gianluca <[EMAIL PROTECTED]> wrote: > > On 23 Mag, 07:48, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > > On Thu, 22 May 2008 21:55:41 -0700, gianluca wrote: > > > > Yes, I know it but when I load a function (a=myDLL.myFUNCT()) I've an > > > > exception like this: > > > > > Traceback (most recent call last): > > > > File "", line 1, in > > > > myDLL.myFUNCT() > > > > File "C:\Python25\lib\ctypes\__init__.py", line 353, in __getattr__ > > > > func = self.__getitem__(name) > > > > File "C:\Python25\lib\ctypes\__init__.py", line 358, in __getitem__ > > > > func = self._FuncPtr((name_or_ordinal, self)) > > > > AttributeError: function 'myFUNCT' not found > > > > Then maybe the DLL doesn't contain a function called `myFUNCT`. Any > > > chance you compiled your C as C++ and name mangling kicked in? > > > > Can you show a minimal C source for a DLL, how you compiled it, what you > > > did on the Python side to call it, and how it fails? > > > > Ciao, > > > Marc 'BlackJack' Rintsch > > > I've located my dll in c:\windows\system32 (in linux I aven't any > > problem) and I compiled it with dev-c++. The source code is C standard > > ANSII and is quite havy. If you like I can send it via mail (you can > > realy at [EMAIL PROTECTED]) . I've tryed to build a wrape with swig > > olso with same code and I can access at all the function. > > You can use objdump from mingw or cygwin to look inside the dll and > see exactly what it is exporting, eg > > objdump -x OurSharedCodeLibrary.dll > > This prints a great deal of stuff! In the middle you'll see > > [snip] > The Export Tables (interpreted .rdata section contents) > [snip] > Ordinal/Name Pointer] Table > [ 0] OSCL_DEBUG_fakeInitComplete > [ 1] OSCL_close > [ 2] OSCL_displayIdent > [ 3] OSCL_getCurrentDynamicParams > [ 4] OSCL_getCurrentStaticParams > [ 5] OSCL_getErrorString > [ 6] OSCL_getIdent > [snip] > > This is a dll we used in a project, and those names exactly worked > with ctypes, eg some snips from the ctypes code > > self.dll = cdll.LoadLibrary("OurSharedCodeLibrary") > self.dll.OSCL_getErrorString.restype = c_char_p > > def getErrorString(self, status): > return self.dll.OSCL_getErrorString(c_int(status)) > > -- > Nick Craig-Wood <[EMAIL PROTECTED]> --http://www.craig-wood.com/nick Thank you for help! I've done all you suggest and I've a objdump output like this: ... [ 86](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x3755 _IsCoverRelD [ 87](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x3657 _IsCoverRelA [ 88](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x34f5 _IsCoverDX [ 89](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x341b _IsCoverA [ 90](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x3072 _CoreRelD [ 91](sec 1)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x2f5e _CoreRelA ... my funtions are the __IsCoverRelD, __IsCoverRelA, etc but when I call it (myLIB.__IsCoverRelA or myLIB.__IsCoverRelA()) I've the same problem. Hy gianluca -- http://mail.python.org/mailman/listinfo/python-list
printf in python
Hy, I've a problem with may python library generated with swig from C code. I works and I can access all function but a simèple function that print a string don't work's. The function is like this: int PrintTEST() { printf("TEST "); return 1; } If I call the function (myDLL.PrintTEST() ) the function print only the returned value, not the string "TEST". Could anybody help me? Thanks Gianluca -- http://mail.python.org/mailman/listinfo/python-list
Re: printf in python
On 2 Giu, 10:08, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > gianluca <[EMAIL PROTECTED]> writes: > > Hy, I've a problem with may python library generated with swig from C > > code. I works and I can access all function but a simèple function > > that print a string don't work's. > > The function is like this: > > int PrintTEST() > > { > > printf("TEST "); > > return 1; > > } > > Finish the printed string with a newline, or call fflush(stdout). By > default stdout is line-buffered when connected to interactive displays. Exuse me! How could use it?. I've tried with '\n' without result. Thanks Gianluca -- http://mail.python.org/mailman/listinfo/python-list
Re: printf in python
On 2 Giu, 17:54, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Mon, 2 Jun 2008 00:32:33 -0700 (PDT), gianluca <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > Hy, I've a problem with may python library generated with swig from C > > code. I works and I can access all function but a simèple function > > that print a string don't work's. > > The function is like this: > > int PrintTEST() > > { > > printf("TEST "); > > return 1; > > } > > > If I call the function (myDLL.PrintTEST() ) the function print only > > the returned value, not the string "TEST". Could anybody help me? > > Are you running from a command shell? > > If you are testing from inside something like IDLE (or PythonWin, or > pretty much any other GUI development system) you may not have a stdout > for display by C code... > > The return value would be printed by the Python interpreter in > interactive mode... > -- > WulfraedDennis Lee Bieber KD6MOG > [EMAIL PROTECTED] [EMAIL PROTECTED] > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: [EMAIL PROTECTED]) > HTTP://www.bestiaria.com/ Hy, the problem exists both in command shell and in IDLE. The value is correct returned in both envirnment. gianluca -- http://mail.python.org/mailman/listinfo/python-list
Re: printf in python
On 2 Giu, 20:51, gianluca <[EMAIL PROTECTED]> wrote: > On 2 Giu, 17:54, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > > > > > On Mon, 2 Jun 2008 00:32:33 -0700 (PDT), gianluca <[EMAIL PROTECTED]> > > declaimed the following in comp.lang.python: > > > > Hy, I've a problem with may python library generated with swig from C > > > code. I works and I can access all function but a simèple function > > > that print a string don't work's. > > > The function is like this: > > > int PrintTEST() > > > { > > > printf("TEST "); > > > return 1; > > > } > > > > If I call the function (myDLL.PrintTEST() ) the function print only > > > the returned value, not the string "TEST". Could anybody help me? > > > Are you running from a command shell? > > > If you are testing from inside something like IDLE (or PythonWin, or > > pretty much any other GUI development system) you may not have a stdout > > for display by C code... > > > The return value would be printed by the Python interpreter in > > interactive mode... > > -- > > WulfraedDennis Lee Bieber KD6MOG > > [EMAIL PROTECTED] [EMAIL PROTECTED] > > HTTP://wlfraed.home.netcom.com/ > > (Bestiaria Support Staff: [EMAIL PROTECTED]) > > HTTP://www.bestiaria.com/ > > Hy, > the problem exists both in command shell and in IDLE. The value is > correct returned in both envirnment. > > gianluca Anybody help me? -- http://mail.python.org/mailman/listinfo/python-list
Re: printf in python
On 3 Giu, 12:48, gianluca <[EMAIL PROTECTED]> wrote: > On 2 Giu, 20:51, gianluca <[EMAIL PROTECTED]> wrote: > > > > > On 2 Giu, 17:54, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > > > > On Mon, 2 Jun 2008 00:32:33 -0700 (PDT), gianluca <[EMAIL PROTECTED]> > > > declaimed the following in comp.lang.python: > > > > > Hy, I've a problem with may python library generated with swig from C > > > > code. I works and I can access all function but a simèple function > > > > that print a string don't work's. > > > > The function is like this: > > > > int PrintTEST() > > > > { > > > > printf("TEST "); > > > > return 1; > > > > } > > > > > If I call the function (myDLL.PrintTEST() ) the function print only > > > > the returned value, not the string "TEST". Could anybody help me? > > > > Are you running from a command shell? > > > > If you are testing from inside something like IDLE (or PythonWin, > > > or > > > pretty much any other GUI development system) you may not have a stdout > > > for display by C code... > > > > The return value would be printed by the Python interpreter in > > > interactive mode... > > > -- > > > WulfraedDennis Lee Bieber KD6MOG > > > [EMAIL PROTECTED] [EMAIL PROTECTED] > > > HTTP://wlfraed.home.netcom.com/ > > > (Bestiaria Support Staff: [EMAIL PROTECTED]) > > > HTTP://www.bestiaria.com/ > > > Hy, > > the problem exists both in command shell and in IDLE. The value is > > correct returned in both envirnment. > > > gianluca > > Anybody help me? I know!! I'm bore!! But I need help indeed!! I'm looking inside lib_wrap.c generated by swig. In the wrap function there is no printf function. If is this the problem how can I do to resolve it? thanks Gianluca -- http://mail.python.org/mailman/listinfo/python-list
Re: printf in python
On 4 Giu, 03:46, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Tue, 03 Jun 2008 10:28:57 -0300, gianluca <[EMAIL PROTECTED]> > escribió: > > > > >> > > On Mon, 2 Jun 2008 00:32:33 -0700 (PDT), gianluca > >> <[EMAIL PROTECTED]> > >> > > declaimed the following in comp.lang.python: > > >> > > > Hy, I've a problem with may python library generated with swig > >> from C > >> > > > code. I works and I can access all function but a simèple > >> function > >> > > > that print a string don't work's. > >> > > > The function is like this: > >> > > > int PrintTEST() > >> > > > { > >> > > > printf("TEST "); > >> > > > return 1; > >> > > > } > > > I know!! I'm bore!! But I need help indeed!! > > I'm looking inside lib_wrap.c generated by swig. In the wrap function > > there is no printf function. If is this the problem how can I do to > > resolve it? > > Generated swig code is... uhm, ugly at least, and rather undebuggable. I'd > try to avoid it. > Another alternative is Cython: I've not actually used it myself, but I've > seen good reports from it. > If your library is written in C (not C++), you may use directly ctypes > from inside Python. > > -- > Gabriel Genellina Yes, I've tried it (ctypes) but I've problems about pointer as function arguments. I've several truble with it... but I'm working both in ctypes and swig. Thank Gianluca -- http://mail.python.org/mailman/listinfo/python-list
ctypes help
hy, I've a huge problem with ctypes. I've compiled my C library and I'd like use it in python with ctype. One function need to pass a pointer to typed ( like this: typedef int value_type). In python I can access to that funtion but arise an exception because python don't know my value_type typedef. Please I need help, could anybody help me? Gianluca -- http://mail.python.org/mailman/listinfo/python-list
#define in swig
I've a problem with python wrapper of C library. In a library's file there are #define istruction but I can't access it from python. Other functio works correctly. The define istruction is like this: #define START_OF_D _table_element=_mainsys- >matD,_table_end=_table_element+Dsize(_mainsys) #define START_OF_X _table_element=_mainsys- >matX,_table_end=_table_element+_mainsys->matXsize #define START_OF_MAT(set,num) _table_element=(set),_table_end=_table_element+(num)*_mainsys- >setAsize #define END_OF_MAT (_table_element<_table_end) #define NEXT_OF_MAT_table_element+=_mainsys->setAsize #define ELEM_OF_MAT_table_element #define ElemOfRule(rules,num,attr) (rules)[(num)*(_mainsys- >attributes_num)+(attr)] thanks Gianluca -- http://mail.python.org/mailman/listinfo/python-list
ctypes - swig - pointer
I've a problem with dll function colled with python/ctypes. My functions (C) requred a typedef int "value_type" in tree different way: same as value_type; - mydll.foo1(value_type) same as *value_type; - mydll.foo2(*value_type) same as **value_type; - mydll.foo3(**value_type) How can pass it in python. If i do that: rules=POINTER(value_type) opr=rsl.StrengthOfRules(rules,10) R=POINTER(rules) I've this exception: Traceback (most recent call last): File "C:\temp\cRSL.py", line 49, in opr=rsl.StrengthOfRules(rules,10) #/* Creates a table of rules strengths. */ ArgumentError: argument 1: : Don't know how to convert parameter 1 I've tried with swig (cpointer.i) olso but the library don't work correctly and rules look empty. I need help. Could anybody give mi it? gima -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes - swig - pointer
On 30 Giu, 18:26, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > On Mon, 30 Jun 2008 09:13:42 -0700 (PDT), gianluca <[EMAIL PROTECTED]> wrote: > >I've a problem with dll function colled with python/ctypes. My > >functions (C) requred a typedef int "value_type" in tree different > >way: > >same as value_type; - mydll.foo1(value_type) > >same as *value_type; - mydll.foo2(*value_type) > >same as **value_type; - mydll.foo3(**value_type) > > >How can pass it in python. If i do that: > >rules=POINTER(value_type) > >opr=rsl.StrengthOfRules(rules,10) > >R=POINTER(rules) > > POINTER takes a class and returns a new class which represents a pointer > to input class. > > pointer takes an instance and returns a new object which represents a > pointer to that instance. > > Jean-Paul so, if I write this: p=pointer(value_type) mydll.foo1(p) could be correct but python say me: TypeError: _type_ must have storage info what does mean? thank you gima -- http://mail.python.org/mailman/listinfo/python-list
__stack_chk_fail_local
hy list, I've built _libfoo.so and libfoo.py library with swig and I've copied in /usr/lib/python2.5/lib-dynload/ but when import the module >>import libfoo I've that message Traceback (most recent call last): File "", line 1, in ImportError: /usr/lib/python2.5/lib-dynload/_libfoo.so: undefined symbol: __stack_chk_fail_local Could anybody help me? gianluca -- http://mail.python.org/mailman/listinfo/python-list
Re: __stack_chk_fail_local
On 30 Ago, 12:05, "Marco Bizzarri" <[EMAIL PROTECTED]> wrote: > On Fri, Aug 29, 2008 at 7:53 PM, gianluca <[EMAIL PROTECTED]> wrote: > > hy list, > > I've built _libfoo.so and libfoo.py library with swig and I've copied > > in /usr/lib/python2.5/lib-dynload/ but when import the module > > >>>import libfoo > > > I've that message > > > Traceback (most recent call last): > > File "", line 1, in > > ImportError: /usr/lib/python2.5/lib-dynload/_libfoo.so: undefined > > symbol: __stack_chk_fail_local > > > Could anybody help me? > > > gianluca > > -- > >http://mail.python.org/mailman/listinfo/python-list > > Have you tried to use ldd against the _libfoo.so to check if it is > able to get all the libraries it needs? > > Regards > Marco > > -- > Marco Bizzarrihttp://iliveinpisa.blogspot.com/ I've tried with ldd and the library aren't loaded. I don't use my *.i interface so is quite difficult modify it (realy, the libraru is supplied with make). Any suggests? gianluca -- http://mail.python.org/mailman/listinfo/python-list
Web framework
Hi guys, What web framework do you suggest to develop with? I had a look both at Nevow and Quixote. These seemes to be the most appreciated by the community. Anyway, I had no luck looking for a complete and coherent documentation. Thanks for any suggestion, Gianluca -- http://mail.python.org/mailman/listinfo/python-list
Re: Web framework
Hi Christian, thanks for your replay. I gave a quick look at cherryPy too, but I had the impression it wasn't enought to be used in a real world contest. What about performances? Can I safely consider it to develop an Intranet/Extranet? My main concern is with scalability. What will happend if my user-base will grow? What if I had to add web services interface (say XML-RPC or SOAP) to my application? Can I do it in a second time without spending too much time/money? Thanks, Gianluca -- http://mail.python.org/mailman/listinfo/python-list
Re: Web framework
Well, my concern here was mostly about SSL support. It seems it's not supported natively. Anyway, I'm looking at all those frameworks by a 'pre-evaluation' point of you. so I'm fully trusting what I can read on their websites... -- http://mail.python.org/mailman/listinfo/python-list
Python and lotus notes
Hi, i am having a problem when i try to access lotus notes with python, think i do all ok but it seems something is going wrong because i can't print any db title even if i've opened the .nsf file. My code: import win32com.client from win32com.client import Dispatch notesServer='Mail\wed\new\IT' notesFile= 'Apps\Mydb.nsf' notesPass= 'mypass' session = Dispatch('Lotus.NotesSession') session.Initialize(notesPass) print "" db = session.getDatabase(notesServer, notesFile) print db.Open print db.IsOpen print db.Title but i receve: >> False Please can u help me? GL -- https://mail.python.org/mailman/listinfo/python-list
Re: Python and lotus notes
Il giorno lunedì 20 aprile 2015 10:29:42 UTC+2, gianluc...@gmail.com ha scritto: > Hi, > > i am having a problem when i try to access lotus notes with python, think i > do all ok but it seems something is going wrong because i can't print any db > title even if i've opened the .nsf file. > > My code: > > import win32com.client > from win32com.client import Dispatch > > notesServer='Mail\wed\new\IT' > notesFile= 'Apps\Mydb.nsf' > notesPass= 'mypass' > > session = Dispatch('Lotus.NotesSession') > session.Initialize(notesPass) > print "" > > db = session.getDatabase(notesServer, notesFile) > > print db.Open > print db.IsOpen > print db.Title > > but i receve: > > >> > False > > Please can u help me? > GL hi! ive tried but i get this error: File "", line 2, in Open com_error: (-2147352567, 'Eccezione.', (0, 'NotesDatabase', 'Database open failed (Mail\wed/new/IT!!Apps\Mydb.nsf')', None, 0, -2147217461), None) -- https://mail.python.org/mailman/listinfo/python-list
Re: __stack_chk_fail_local
thanks for the help, maybe the solution will be useful: in "various Linux distributions are starting to ship with a version of the GNU C compiler which incorporates an extension which implements protection for stack-smashing". In that case the Makefile has to modified with CFLAGS = -fno-stack-protector gianluca Marco Bizzarri wrote: On Sat, Aug 30, 2008 at 3:03 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Thanks! I've resolved the problem with libraries but... I've still error with this message: ImportError: ./_python_grass6.so: undefined symbol: __stack_chk_fail_local exuse me, I'm not a guru. Gianluca I'm not a guru either, Gianluca ;) I made a little search on Google; the first link is the following: http://ubuntuforums.org/showthread.php?t=352642 can you apply the suggestion? I think you should give a little more context on your problem, also, because I think it has to do with your setup (not that you setup something in the wrong way: just to have context). Regards Marco -- http://mail.python.org/mailman/listinfo/python-list