Calling Script from Command line not working

Sathish S sathish at solitontech.com
Fri Sep 2 02:17:18 EDT 2011


Hey Gabriel,
Thanks a lot for replying. I was able to run this python script from
console/command prompt using cygwin python. I'm not sure whats the
difference between these two versions of python. But it seems to be working.
Searching theough the web i found that having cygwin1.dll could be causing
this issue. So I'm trying to build my DLL using MinGW which will not create
an dependecy DLL's. But I'm stuck up with few more issue in porting few
functions to MinGW.

I'm using Python2.7 and Cygwin Python 2.6.5

*Reply to your comments:*

** why do you initialize cygwin1.dll in Python? If it's a dependency of
my.dll, it might be better to load and initialize it there.*
Yes, cygwin1.dll is actually a dependency to my.dll. hence I'm loading it
and initializing it
** for this function prototype: void cygwin_dll_init(void);*
*you should declare it using:*
I'm doing this as you said. But didn't mention it in my mail

hCyg = cdll.LoadLibrary(CygWinDLL_Name)
hCyg = CDLL(CygWinDLL_Name)
Prototype_Cyg = CFUNCTYPE(c_void_p)
Init = Prototype_Cyg (("cygwin_dll_init", hCyg))
Init.restype = c_void_p
Init()

Thanks,
Sathish


On Fri, Sep 2, 2011 at 7:56 AM, Gabriel Genellina <gagsl-py2 at yahoo.com.ar>wrote:

> En Mon, 29 Aug 2011 07:40:06 -0300, Sathish S <sathish at solitontech.com>
> escribió:
>
>
>  We created a DLL using cygwin and have written a class based python module
>> for the same. We have created a sample script for the class based python
>> module, that creates an object of the class and calls various methods in
>> the
>> class. This Test script works fine while I run it from IDLE. However when
>> I
>> run it from command prompt it either hangs or just returns without
>> executing
>> the functions. When it returns I do not get a error trace.
>>
>> When I tried to findout where exactly the issue is happening. the issue
>> occurs when I try to call the *cygwin_dll_init* method of the cygwin1.dll
>> .
>> This cygwin1.dll is actualy a dependency to the DLL we have built. So we
>> have to load this DLL and call this *cygwin_dll_init* method before
>> loading
>> my DLL.
>>
>>
>> cyg = cdll.LoadLibrary("cygwin1.dll"**)
>> cyg.cygwin_dll_init() #hangs or returns here
>> mydll=cdll.LoadLibrary("my.**dll")
>> mydll.func1()
>> I'm trying to understand what exactly is the difference, when we call it
>> IDLE and when we call it from command prompt using the python command. I
>> will have to get the script working from command prompt as well.
>>
>
> A few comments:
>
> * why do you initialize cygwin1.dll in Python? If it's a dependency of
> my.dll, it might be better to load and initialize it there.
>
> * for this function prototype: void cygwin_dll_init(void);
> you should declare it using:
>
>
> cyg = cdll.LoadLibrary("cygwin1.dll"**)
> cyg.restype = None
>
> cyg.cygwin_dll_init() #hangs or returns here
> ...
>
> Anyway, I don't see why a console application would fail but not inside
> IDLE.
>
> --
> Gabriel Genellina
>
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110902/b704f011/attachment-0001.html>


More information about the Python-list mailing list