From marc at marchankin.com Sun Jan 2 06:18:45 2011 From: marc at marchankin.com (Marc Hankin) Date: Sat, 1 Jan 2011 21:18:45 -0800 Subject: [python-win32] Attempting to install pyWin32: Skipping exchdapi: No library 'Ex2KSdk' Skipping directsound: The header 'dsound.h' can not be located Message-ID: I just downloaded pyWin32 (https://sourceforge.net/projects/pywin32/) and started to install it. I get these error msgs: Skipping exchange: No library 'Ex2KSdk' Skipping exchdapi: No library 'Ex2KSdk' Skipping directsound: The header 'dsound.h' can not be located Does anyone have any suggestions about how to address this? Thanks, Marceepoo -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Sun Jan 2 10:27:04 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Sun, 2 Jan 2011 02:27:04 -0700 Subject: [python-win32] Attempting to install pyWin32: Skipping exchdapi: No library 'Ex2KSdk' Skipping directsound: The header 'dsound.h' can not be located In-Reply-To: References: Message-ID: Unless for some reason you actually NEED to compile pywin32, such as if you are testing patches or new modules or such, then use the binary installer. It is much easier. On Jan 1, 2011 10:42 PM, "Marc Hankin" wrote: I just downloaded pyWin32 (https://sourceforge.net/projects/pywin32/) and started to install it. I get these error msgs: Skipping exchange: No library 'Ex2KSdk' Skipping exchdapi: No library 'Ex2KSdk' Skipping directsound: The header 'dsound.h' can not be located Does anyone have any suggestions about how to address this? Thanks, Marceepoo _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From halgrim.s at ghc.org Mon Jan 3 22:52:10 2011 From: halgrim.s at ghc.org (Halgrim, Scott) Date: Mon, 3 Jan 2011 13:52:10 -0800 Subject: [python-win32] adodbapi returns None for text field in first row In-Reply-To: References: Message-ID: Thanks, Vernon. I am using Windows XP, Python 2.7, and adodbapi version 2.2.6 from pywin32 v214. The difference between what I'm running and your attempt at replication is that the problem is occurring with a column of type text, not of type varchar. (In fact, I've currently created a workaround to the problem by creating a duplicate table where the column is varchar(8000).) Here's my verbose output per your request (on the table with the text column). Note rows[0] has None in its second column, but that's not what's in that row/column in the database. Also note that rows[1] returns what is actually in that row. >>> conn = adodbapi.connect(connectstring) adodbapi v2.2.6 attempting: "[connectstring]" adodbapi New connection at 1347FD0 >>> c = conn.cursor() adodbapi New cursor at 1387C30 on conn 1347FD0 >>> query = 'SELECT fword, text, cui FROM TABLE' >>> c.execute(query) >>> print 'description=',repr(c.description) description= [(u'fword', 200, 12, 80, 255, 255, False), (u'text', 201, 29, 2147483647, 255, 255, True), (u'cui', 200, 8, 8, 255, 255, False)] >>> rows = c.fetchall() Converting type_code=200, val=u'infiltrating' conversion function= output=u'infiltrating' Converting type_code=200, val=u'infitrating' conversion function= output=u'infitrating' ...see attachment for remaining... >>> print repr(rows[0]) (u'infiltrating', None, u'C0007124') >>> print repr(rows[1]) (u'infitrating', u'infitrating ductal carcinoma', u'C0007124') >>> c.close() >>> conn.close() adodbapi Closed connection at 1347FD0 Thanks again, Scott ________________________________ From: Vernon Cole [mailto:vernondcole at gmail.com] Sent: Thursday, December 30, 2010 9:58 PM To: Halgrim, Scott Cc: python-win32 at python.org Subject: Re: [python-win32] adodbapi returns None for text field in first row Scott: Something is indeed fishy. What os, version of python, and version of pywin32 are you using? As an attempt to duplicate your result, I built a table "tblTemp" on my Windows Vista laptop's SQL express 2008 with three VarChar fields and loaded two rows of data. I defined an ODBC DSN to point to my local server, since you are running in ODBC mode. I added some debug details to your sample, corrected a typo, altered the database info, and ran the following... #Note: odbcTest is a DSN defined using "Control Panel"->"Administrative Tools"->"Data Sources (ODBC)" connStrSQLServer = 'Data Source=odbcTest;Initial Catalog=Northwind;' + 'Trusted_Connection=true;' import sys print sys.version import adodbapi print 'adodbapi version=',adodbapi.version adodbapi.adodbapi.verbose = 4 cnctn = adodbapi.connect(connStrSQLServer) c = cnctn.cursor() # Note: corrected from crsr = cnctn.cursor() query = 'SELECT fword, text, cui FROM TblTemp' c.execute(query) print 'description=',repr(c.description) rows = c.fetchall() print repr(rows[0]) print repr(rows[1]) c.close() cnctn.close() I got this result... C:\hg\adodbapi\test>c:\python26\python.exe x.py 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] adodbapi version= adodbapi v2.4.0.2 adodbapi v2.4.0.2 attempting: "Data Source=odbcTest;Initial Catalog=Northwind;Tusted_Connection=true;" adodbapi New connection at 2C70450 adodbapi New cursor at 2C70BF0 on conn 2C70450 Executing command="SELECT fword, text, cui FROM TblTemp" with parameters= [] description= [(u'fword', 200, 6, 10, 255, 255, True), (u'text', 200, 15, 30, 255, 255, True), (u'cui', 200, 8, 12, 255, 255, True)] adodbapi Closed connection at 2C70450 Try again with verbose=4 all of the "print repr(..." lines added, and see if the additional information helps. -- Vernon On Thu, Dec 30, 2010 at 4:07 PM, Halgrim, Scott > wrote: Has anybody ever had an issue like this? I submit a query to a table and everything works out fine, except for one column in one row. The column of type text in the first row returned is always None. I've modified the query by adding a WHERE clause so that a different row was the first one returned, and the same thing happens where the first row returned has a None in that column. I'm running adodbapi 2.4 and querying SQL Server 2008. Here's my code. >>> from adodbapi import connect >>> cnctn = connect('Data Source=InstanceName;Initial Catalog=DbName;' + 'Trusted_Connection=true;') >>> crsr = cnctn.cursor() >>> query = 'SELECT fword, text, cui FROM TABLE' >>> c.execute(query) >>> rows = c.fetchall() >>> print rows[0], rows[1] (u'breast', None, u'C0006142') (u'breast', u'breast carcinoma', u'C0006142') Any help is appreciated. Thanks, Scott ________________________________ GHC Confidentiality Statement This message and any attached files might contain confidential information protected by federal and state law. The information is intended only for the use of the individual(s) or entities originally named as addressees. The improper disclosure of such information may be subject to civil or criminal penalties. If this message reached you in error, please contact the sender and destroy this message. Disclosing, copying, forwarding, or distributing the information by unauthorized individuals or entities is strictly prohibited by law. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: verboseconversions.txt URL: From timr at probo.com Tue Jan 4 00:06:34 2011 From: timr at probo.com (Tim Roberts) Date: Mon, 3 Jan 2011 15:06:34 -0800 Subject: [python-win32] adodbapi returns None for text field in first row In-Reply-To: References: Message-ID: <4D22567A.8050907@probo.com> Halgrim, Scott wrote: > > Thanks, Vernon. > > > > I am using Windows XP, Python 2.7, and adodbapi version 2.2.6 from > pywin32 v214. > > > > The difference between what I?m running and your attempt at > replication is that the problem is occurring with a column of type > text, not of type varchar. (In fact, I?ve currently created a > workaround to the problem by creating a duplicate table where the > column is varchar(8000).) > You're using Microsoft SQL Server, right? It may be a problem that you have a column with the same name as a reserved word. If you're in SQL Server 2005 or above, "TEXT" is no longer recommended as a data type. You're supposed to use VARCHAR(MAX). -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From vernondcole at gmail.com Tue Jan 4 01:34:48 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Mon, 3 Jan 2011 17:34:48 -0700 Subject: [python-win32] adodbapi returns None for text field in first row In-Reply-To: References: Message-ID: Scott: Thanks! Exactly the kind of detective work needed. There has been suspicion of a problem with large binary fields, but your example is the first to nail it down. I suspect that the reported "internal size" of 2 GB for that field may lead us to the source of the bug. Would you be so kind as to download a copy of adodbapi from http://sourceforge.net/projects/adodbapi and confirm that the bug still exists on the new version? Adodbapi has been extensively refactored, so this could have already been fixed without my knowing it. Meanwhile, I'll roll your example into the unit test. -- Vernon On Mon, Jan 3, 2011 at 2:52 PM, Halgrim, Scott wrote: > Thanks, Vernon. > > > > I am using Windows XP, Python 2.7, and adodbapi version 2.2.6 from pywin32 > v214. > > > > The difference between what I?m running and your attempt at replication is > that the problem is occurring with a column of type text, not of type > varchar. (In fact, I?ve currently created a workaround to the problem by > creating a duplicate table where the column is varchar(8000).) > > > > Here?s my verbose output per your request (on the table with the text > column). Note rows[0] has None in its second column, but that?s not what?s > in that row/column in the database. Also note that rows[1] returns what is > actually in that row. > > > > >>> conn = adodbapi.connect(connectstring) > > adodbapi v2.2.6 attempting: "[connectstring]" > > adodbapi New connection at 1347FD0 > > >>> c = conn.cursor() > > adodbapi New cursor at 1387C30 on conn 1347FD0 > > >>> query = 'SELECT fword, text, cui FROM TABLE? > > >>> c.execute(query) > > >>> print 'description=',repr(c.description) > > description= [(u'fword', 200, 12, 80, 255, 255, False), (u'text', 201, 29, > 2147483647, 255, 255, True), (u'cui', 200, 8, 8, 255, 255, False)] > > >>> rows = c.fetchall() > > Converting type_code=200, val=u'infiltrating' > > conversion function= > > output=u'infiltrating' > > Converting type_code=200, val=u'infitrating' > > conversion function= > > output=u'infitrating' > > ?see attachment for remaining? > > >>> print repr(rows[0]) > > (u'infiltrating', None, u'C0007124') > > >>> print repr(rows[1]) > > (u'infitrating', u'infitrating ductal carcinoma', u'C0007124') > > >>> c.close() > > >>> conn.close() > > adodbapi Closed connection at 1347FD0 > > > > Thanks again, > > > > Scott > > > ------------------------------ > > *From:* Vernon Cole [mailto:vernondcole at gmail.com] > *Sent:* Thursday, December 30, 2010 9:58 PM > *To:* Halgrim, Scott > *Cc:* python-win32 at python.org > *Subject:* Re: [python-win32] adodbapi returns None for text field in > first row > > > > Scott: > Something is indeed fishy. What os, version of python, and version of > pywin32 are you using? > As an attempt to duplicate your result, I built a table "tblTemp" on my > Windows Vista laptop's SQL express 2008 with three VarChar fields > and loaded two rows of data. I defined an ODBC DSN to point to my local > server, since you are running in ODBC mode. > > I added some debug details to your sample, corrected a typo, altered the > database info, and ran the following... > > > #Note: odbcTest is a DSN defined using "Control Panel"->"Administrative > Tools"->"Data Sources (ODBC)" > connStrSQLServer = 'Data Source=odbcTest;Initial Catalog=Northwind;' + > 'Trusted_Connection=true;' > import sys > print sys.version > import adodbapi > print 'adodbapi version=',adodbapi.version > adodbapi.adodbapi.verbose = 4 > > cnctn = adodbapi.connect(connStrSQLServer) > c = cnctn.cursor() # Note: corrected from crsr = cnctn.cursor() > query = 'SELECT fword, text, cui FROM TblTemp' > c.execute(query) > print 'description=',repr(c.description) > rows = c.fetchall() > print repr(rows[0]) > print repr(rows[1]) > c.close() > cnctn.close() > > > I got this result... > > > C:\hg\adodbapi\test>c:\python26\python.exe x.py > 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] > adodbapi version= adodbapi v2.4.0.2 > adodbapi v2.4.0.2 attempting: "Data Source=odbcTest;Initial > Catalog=Northwind;Tusted_Connection=true;" > adodbapi New connection at 2C70450 > adodbapi New cursor at 2C70BF0 on conn 2C70450 > Executing command="SELECT fword, text, cui FROM TblTemp" > with parameters= [] > description= [(u'fword', 200, 6, 10, 255, 255, True), (u'text', 200, 15, > 30, 255, 255, True), (u'cui', 200, 8, 12, 255, 255, True)] > > > adodbapi Closed connection at 2C70450 > > > > Try again with verbose=4 all of the "print repr(..." lines added, and see > if the additional information helps. > -- > Vernon > > On Thu, Dec 30, 2010 at 4:07 PM, Halgrim, Scott wrote: > > Has anybody ever had an issue like this? > > > > I submit a query to a table and everything works out fine, except for one > column in one row. The column of type text in the first row returned is > always None. I?ve modified the query by adding a WHERE clause so that a > different row was the first one returned, and the same thing happens where > the first row returned has a None in that column. > > > > I?m running adodbapi 2.4 and querying SQL Server 2008. Here?s my code. > > > > >>> from adodbapi import connect > > >>> cnctn = connect('Data Source=InstanceName;Initial Catalog=DbName;' + > 'Trusted_Connection=true;') > > >>> crsr = cnctn.cursor() > > >>> query = 'SELECT fword, text, cui FROM TABLE' > > >>> c.execute(query) > > >>> rows = c.fetchall() > > >>> print rows[0], rows[1] > > (u'breast', None, u'C0006142') (u'breast', u'breast carcinoma', > u'C0006142') > > > > Any help is appreciated. > > > > Thanks, > > > > Scott > > > > > > * ________________________________ * > > GHC Confidentiality Statement > > This message and any attached files might contain confidential information > protected by federal and state law. The information is intended only for the > use of the individual(s) or entities originally named as addressees. The > improper disclosure of such information may be subject to civil or criminal > penalties. If this message reached you in error, please contact the sender > and destroy this message. Disclosing, copying, forwarding, or distributing > the information by unauthorized individuals or entities is strictly > prohibited by law. > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From halgrim.s at ghc.org Tue Jan 4 19:56:54 2011 From: halgrim.s at ghc.org (Halgrim, Scott) Date: Tue, 4 Jan 2011 10:56:54 -0800 Subject: [python-win32] adodbapi returns None for text field in first row - solved In-Reply-To: References: Message-ID: Thanks, Vernon, for pointing out the new version. Updating my version of adodbapi fixed the issue. Thanks again, Scott ________________________________ From: Vernon Cole [mailto:vernondcole at gmail.com] Sent: Monday, January 03, 2011 4:35 PM To: Halgrim, Scott Cc: python-win32 at python.org Subject: Re: [python-win32] adodbapi returns None for text field in first row Scott: Thanks! Exactly the kind of detective work needed. There has been suspicion of a problem with large binary fields, but your example is the first to nail it down. I suspect that the reported "internal size" of 2 GB for that field may lead us to the source of the bug. Would you be so kind as to download a copy of adodbapi from http://sourceforge.net/projects/adodbapi and confirm that the bug still exists on the new version? Adodbapi has been extensively refactored, so this could have already been fixed without my knowing it. Meanwhile, I'll roll your example into the unit test. -- Vernon On Mon, Jan 3, 2011 at 2:52 PM, Halgrim, Scott > wrote: Thanks, Vernon. I am using Windows XP, Python 2.7, and adodbapi version 2.2.6 from pywin32 v214. The difference between what I'm running and your attempt at replication is that the problem is occurring with a column of type text, not of type varchar. (In fact, I've currently created a workaround to the problem by creating a duplicate table where the column is varchar(8000).) Here's my verbose output per your request (on the table with the text column). Note rows[0] has None in its second column, but that's not what's in that row/column in the database. Also note that rows[1] returns what is actually in that row. >>> conn = adodbapi.connect(connectstring) adodbapi v2.2.6 attempting: "[connectstring]" adodbapi New connection at 1347FD0 >>> c = conn.cursor() adodbapi New cursor at 1387C30 on conn 1347FD0 >>> query = 'SELECT fword, text, cui FROM TABLE' >>> c.execute(query) >>> print 'description=',repr(c.description) description= [(u'fword', 200, 12, 80, 255, 255, False), (u'text', 201, 29, 2147483647, 255, 255, True), (u'cui', 200, 8, 8, 255, 255, False)] >>> rows = c.fetchall() Converting type_code=200, val=u'infiltrating' conversion function= output=u'infiltrating' Converting type_code=200, val=u'infitrating' conversion function= output=u'infitrating' ...see attachment for remaining... >>> print repr(rows[0]) (u'infiltrating', None, u'C0007124') >>> print repr(rows[1]) (u'infitrating', u'infitrating ductal carcinoma', u'C0007124') >>> c.close() >>> conn.close() adodbapi Closed connection at 1347FD0 Thanks again, Scott ________________________________ From: Vernon Cole [mailto:vernondcole at gmail.com] Sent: Thursday, December 30, 2010 9:58 PM To: Halgrim, Scott Cc: python-win32 at python.org Subject: Re: [python-win32] adodbapi returns None for text field in first row Scott: Something is indeed fishy. What os, version of python, and version of pywin32 are you using? As an attempt to duplicate your result, I built a table "tblTemp" on my Windows Vista laptop's SQL express 2008 with three VarChar fields and loaded two rows of data. I defined an ODBC DSN to point to my local server, since you are running in ODBC mode. I added some debug details to your sample, corrected a typo, altered the database info, and ran the following... #Note: odbcTest is a DSN defined using "Control Panel"->"Administrative Tools"->"Data Sources (ODBC)" connStrSQLServer = 'Data Source=odbcTest;Initial Catalog=Northwind;' + 'Trusted_Connection=true;' import sys print sys.version import adodbapi print 'adodbapi version=',adodbapi.version adodbapi.adodbapi.verbose = 4 cnctn = adodbapi.connect(connStrSQLServer) c = cnctn.cursor() # Note: corrected from crsr = cnctn.cursor() query = 'SELECT fword, text, cui FROM TblTemp' c.execute(query) print 'description=',repr(c.description) rows = c.fetchall() print repr(rows[0]) print repr(rows[1]) c.close() cnctn.close() I got this result... C:\hg\adodbapi\test>c:\python26\python.exe x.py 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] adodbapi version= adodbapi v2.4.0.2 adodbapi v2.4.0.2 attempting: "Data Source=odbcTest;Initial Catalog=Northwind;Tusted_Connection=true;" adodbapi New connection at 2C70450 adodbapi New cursor at 2C70BF0 on conn 2C70450 Executing command="SELECT fword, text, cui FROM TblTemp" with parameters= [] description= [(u'fword', 200, 6, 10, 255, 255, True), (u'text', 200, 15, 30, 255, 255, True), (u'cui', 200, 8, 12, 255, 255, True)] adodbapi Closed connection at 2C70450 Try again with verbose=4 all of the "print repr(..." lines added, and see if the additional information helps. -- Vernon On Thu, Dec 30, 2010 at 4:07 PM, Halgrim, Scott > wrote: Has anybody ever had an issue like this? I submit a query to a table and everything works out fine, except for one column in one row. The column of type text in the first row returned is always None. I've modified the query by adding a WHERE clause so that a different row was the first one returned, and the same thing happens where the first row returned has a None in that column. I'm running adodbapi 2.4 and querying SQL Server 2008. Here's my code. >>> from adodbapi import connect >>> cnctn = connect('Data Source=InstanceName;Initial Catalog=DbName;' + 'Trusted_Connection=true;') >>> crsr = cnctn.cursor() >>> query = 'SELECT fword, text, cui FROM TABLE' >>> c.execute(query) >>> rows = c.fetchall() >>> print rows[0], rows[1] (u'breast', None, u'C0006142') (u'breast', u'breast carcinoma', u'C0006142') Any help is appreciated. Thanks, Scott ________________________________ GHC Confidentiality Statement This message and any attached files might contain confidential information protected by federal and state law. The information is intended only for the use of the individual(s) or entities originally named as addressees. The improper disclosure of such information may be subject to civil or criminal penalties. If this message reached you in error, please contact the sender and destroy this message. Disclosing, copying, forwarding, or distributing the information by unauthorized individuals or entities is strictly prohibited by law. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From wyley.r at gmail.com Wed Jan 5 19:11:19 2011 From: wyley.r at gmail.com (Richard Lawrence) Date: Wed, 5 Jan 2011 10:11:19 -0800 Subject: [python-win32] Passing parameters to FoxPro COM methods In-Reply-To: References: Message-ID: Dear Pythonistas, I still haven't figured out a way around this issue: > 2) Regarding late binding: the way that attributes are looked up in > win32com.client.dynamic.CDispatch.__getattr__ seems not to play nicely > with Foxpro's way of responding to queries about the interface. ?I > think what's happening is that __getattr__('some_method') attempts > first to call Invoke with pythoncom.INVOKE_PROPERTYGET as the > invocation type. ?As the win32com documentation indicates sometimes > happens, Foxpro seems to respond to this by *calling* the method. I can confirm that this is the problem I am having (or at least one of them). The way win32com.client.dynamic.CDispatch looks up attributes -- by first trying an invocation with INVOKE_PROPERTYGET and only building a method if that raises a pythoncom.com_error -- doesn't work for me, because when the requested attribute is a method, this invocation simply calls the method and returns the result, rather than throwing an error. (At least some of the methods on the component that I am interested in using seem to be implemented in such a way that they have default behavior when called with no arguments, though I am not sure if this is the way Foxpro implements *all* method calls. That is, I'm not sure if my DLL's author simply provided fallback functionality on these methods, where Foxpro would normally throw an error if these methods were not called with the right number of arguments, or if Foxpro itself simply assigns default values to all missing arguments, and my DLL's author is working within that limitation.) > This means that if, say, some_method returns a string, then a call > like: > > c.d.some_method(param1, param2) > > blows up because __getattr__('some_method') returns a string value > that results from calling some_method, rather than a reference to the > method, so I get a TypeError to the effect that a string value is not > callable; whereas > > c.d.some_method > > actually calls the method and returns a value, but of course I can't > pass the call any parameters. So, I'm still wondering: what's the best way to use PythonCOM with late binding such that I can: - prevent component *methods* from being mistakenly called (with no arguments) by an Invoke with pythoncom.INVOKE_PROPERTYGET as the invocation type - call component methods (with arguments) using an Invoke with python.INVOKE_FUNC as the invocation type - continue to get component *properties* via an Invoke with pythoncom.INVOKE_PROPERTYGET as the invocation type Is overriding __getattr__ the way to go here? Or is there a more data-driven approach? Thanks! Richard From david.briant at ubs.com Wed Jan 5 17:40:15 2011 From: david.briant at ubs.com (david.briant at ubs.com) Date: Wed, 5 Jan 2011 16:40:15 -0000 Subject: [python-win32] WSAAsyncSelect Message-ID: Hi I'm looking for a little help on using WSAAsyncSelect via ctypes. I imagine this has been asked before but I couldn't figure out how to search the archives (and trawling through them randomly didn't really help). So basically I want to receive winsock events in a windows message proc (which I do have working). Just not familiar with how to convert the ms description: int WSAAsyncSelect( __in SOCKET s, __in HWND hWnd, __in unsigned int wMsg, __in long lEvent ); into a ctypes one. Would it be something like the following? winsock = ctypes.windll.ws2_32 WM_MY_SOCKET_MESSAGE = WM_USER + 1 ... s = 12345 hWnd = 1234 wMsg = WM_MY_SOCKET_MESSAGE lEvent = FD_READ | FD_WRITE | FD_ACCEPT | FD_CONNECT | FD_CLOSE socketErrorOrZero = winsock.WSAAsyncSelect(s, hWnd, wMsg, lEvent) Thx David -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company limited by shares incorporated in the United Kingdom registered in England and Wales with number 2035362. Registered office: 1 Finsbury Avenue, London EC2M 2PP. UBS Limited is authorised and regulated by the Financial Services Authority. UBS AG is a public company incorporated with limited liability in Switzerland domiciled in the Canton of Basel-City and the Canton of Zurich respectively registered at the Commercial Registry offices in those Cantons with Identification No: CH-270.3.004.646-4 and having respective head offices at Aeschenvorstadt 1, 4051 Basel and Bahnhofstrasse 45, 8001 Zurich, Switzerland. Registered in the United Kingdom as a foreign company with No: FC021146 and having a UK Establishment registered at Companies House, Cardiff, with No: BR 004507. The principal office of UK Establishment: 1 Finsbury Avenue, London EC2M 2PP. In the United Kingdom, UBS AG is authorised and regulated by the Financial Services Authority. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases. From timr at probo.com Wed Jan 5 23:35:32 2011 From: timr at probo.com (Tim Roberts) Date: Wed, 5 Jan 2011 14:35:32 -0800 Subject: [python-win32] WSAAsyncSelect In-Reply-To: References: Message-ID: <4D24F234.7020602@probo.com> david.briant at ubs.com wrote: > > I?m looking for a little help on using WSAAsyncSelect via ctypes.I > imagine this has been asked before but I couldn?t figure out how to > search the archives (and trawling through them randomly didn?t really > help). > > ...Would it be something likethe following? > > winsock = ctypes.windll.ws2_32 > > WM_MY_SOCKET_MESSAGE= WM_USER + 1 > > ? > > s =12345 > > hWnd = 1234 > > wMsg = WM_MY_SOCKET_MESSAGE > > lEvent =FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT|FD_CLOSE > > socketErrorOrZero = winsock.WSAAsyncSelect(s, hWnd, wMsg, lEvent) > Yes, indeed. I think that sock.socket.fileno should get you the socket handle for the first parameter. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From chiradeepv at gmail.com Thu Jan 6 01:38:05 2011 From: chiradeepv at gmail.com (Chiradeep Vittal) Date: Wed, 5 Jan 2011 16:38:05 -0800 Subject: [python-win32] python wmi testing question Message-ID: My module is using the WMI module to use WMI Hyper-V provider. My module obeys a public contract that needs to be exercised by the build automation framework. The build machine is not running on Windows. How could I easily mock the calls to WMI (and the subsequent calls to WMI objects returned by the calls the wmi.MsVmFoo()) ? It seems that using Mock (or similar) will fail since these WMI objects themselves have some getattr magic going on behind the scenes? Thanks -- CV -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Thu Jan 6 03:20:37 2011 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 06 Jan 2011 13:20:37 +1100 Subject: [python-win32] Com server on 64 bit Windows 7 In-Reply-To: References: <4D1D3F5A.4020107@gmail.com> Message-ID: <4D2526F5.6050806@skippinet.com.au> On 31/12/2010 3:50 PM, vijayendra bapte wrote: > I have turned on logger in > `Python27/Lib/site-packages/py2exe/boot_com_servers.py` and here is the > traceback which I am getting in `comerror.txt` on `regsvr32 > test_icon_overlay.dll` > > PATH is > ['C:\\root\\avalon\\module\\sync\\python\\src\\dist\\library.zip'] > Traceback (most recent call last): > File "boot_com_servers.py", line 37, in > pywintypes.error: (126, 'GetModuleFileName', 'The specified module > could not be found.') That is very strange - boot_com_servers.py is attempting to locate the path to the DLL - I can't think of why this might be failing. > Traceback (most recent call last): > File "", line 1, in > NameError: name 'DllRegisterServer' is not defined This looks like a different error and appears to be a simple NameError in the top-level script. > Looks like there might be a problem with > `win32api.GetModuleFileName(sys.frozendllhandle)` or with the dll build > on 64-bit Windows 7 . I'm really not sure what the problem could be - I'm strugging to make py2exe work at the moment for other bizarre reasons and I'm out of time for today - hopefully I'll get back to it soon... Cheers, Mark From vijayendra.bapte at gmail.com Thu Jan 6 05:42:09 2011 From: vijayendra.bapte at gmail.com (vijayendra bapte) Date: Thu, 6 Jan 2011 10:12:09 +0530 Subject: [python-win32] Com server on 64 bit Windows 7 In-Reply-To: <4D2526F5.6050806@skippinet.com.au> References: <4D1D3F5A.4020107@gmail.com> <4D2526F5.6050806@skippinet.com.au> Message-ID: On Thu, Jan 6, 2011 at 7:50 AM, Mark Hammond wrote: > On 31/12/2010 3:50 PM, vijayendra bapte wrote: > >> I have turned on logger in >> `Python27/Lib/site-packages/py2exe/boot_com_servers.py` and here is the >> traceback which I am getting in `comerror.txt` on `regsvr32 >> test_icon_overlay.dll` >> >> PATH is >> ['C:\\root\\avalon\\module\\sync\\python\\src\\dist\\library.zip'] >> Traceback (most recent call last): >> File "boot_com_servers.py", line 37, in >> pywintypes.error: (126, 'GetModuleFileName', 'The specified module >> could not be found.') >> > > That is very strange - boot_com_servers.py is attempting to locate the path > to the DLL - I can't think of why this might be failing. Yes, its very strange. Issue is only on 64-bit machine and its working fine on 32-bit machine. > > Looks like there might be a problem with >> `win32api.GetModuleFileName(sys.frozendllhandle)` or with the dll build >> on 64-bit Windows 7 . >> > > I'm really not sure what the problem could be - I'm strugging to make > py2exe work at the moment for other bizarre reasons and I'm out of time for > today - hopefully I'll get back to it soon... > > Sure. Thanks for the help :) - Vijayendra. -------------- next part -------------- An HTML attachment was scrubbed... URL: From matteo.boscolo at boscolini.eu Thu Jan 6 10:13:13 2011 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Thu, 06 Jan 2011 10:13:13 +0100 Subject: [python-win32] Problem on com server ony in a specifie application Message-ID: <4D2587A9.5050209@boscolini.eu> Hi List, this is my first post .. I can't find a solution at this little scripts. if you run the test.vbs the scripts work very well .. but if I try to get it work under a thinkdesign (A cad package) I got an error in the test.comInit method .. this is the error that the cad give to me : Automation error 0x4005 any idea on how to survive from this error ? any help suggestion will be very helpful Regards, Matteo #test.py from test1 import test1 class test(object): """ The main client application """ _reg_clsid_ = "{F92FB064-0B23-4AE7-BE1A-79DD8B820100}" _reg_desc_ = "test module" _reg_progid_ = "test.application" _public_methods_ = ['comInit','Now','GetIstance'] def __init__(self): self._test1=None def comInit(self,ob): self._obj=test1(obj) def Now(self,msg): return"Now" +str(msg) def GetIstance(self): return str(self._obj.getArg()) #Thinkdesing command line sequence #o:=newObj('test.application') #o->Now("ciao") #o->comInit("aa") if __name__=='__main__': import win32com.server.register win32com.server.register.UseCommandLine(test) t=test() t.Now("now ") t.comInit("aa") print t.GetIstance() #test1.py class test1: def __init__(self,arg=None): self._arg=arg def getArg(self): return "done "+str(self._arg) 'test.vbs dim o set o=createObject("test.application") msgbox o.now(" ciao") o.comInit("aaa") msgbox o.GetIstance From timr at probo.com Thu Jan 6 19:08:30 2011 From: timr at probo.com (Tim Roberts) Date: Thu, 6 Jan 2011 10:08:30 -0800 Subject: [python-win32] Problem on com server ony in a specifie application In-Reply-To: <4D2587A9.5050209@boscolini.eu> References: <4D2587A9.5050209@boscolini.eu> Message-ID: <4D26051E.40707@probo.com> Matteo Boscolo wrote: > I can't find a solution at this little scripts. > > if you run the test.vbs the scripts work very well .. > but if I try to get it work under a thinkdesign (A cad package) I got an > error in the test.comInit method .. > this is the error that the cad give to me : > Automation error 0x4005 > any idea on how to survive from this error ? That error code (0x80004005) is the very unhelpful E_FAIL. Does ThinkDesign have its own scripting language? Is it already set up to use late-bound COM objects? Do you possibly have a 32-bit/64-bit confusion? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From matteo.boscolo at boscolini.eu Thu Jan 6 20:40:46 2011 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Thu, 06 Jan 2011 20:40:46 +0100 Subject: [python-win32] Problem on com server ony in a specifie application In-Reply-To: <4D26051E.40707@probo.com> References: <4D2587A9.5050209@boscolini.eu> <4D26051E.40707@probo.com> Message-ID: <4D261ABE.3060809@boscolini.eu> Il 06/01/2011 19:08, Tim Roberts ha scritto: > Matteo Boscolo wrote: >> I can't find a solution at this little scripts. >> >> if you run the test.vbs the scripts work very well .. >> but if I try to get it work under a thinkdesign (A cad package) I got an >> error in the test.comInit method .. >> this is the error that the cad give to me : >> Automation error 0x4005 >> any idea on how to survive from this error ? > That error code (0x80004005) is the very unhelpful E_FAIL. > > Does ThinkDesign have its own scripting language? yes > Is it already set up > to use late-bound COM objects? I do not know > Do you possibly have a 32-bit/64-bit > confusion? My machine is a 64Bit w7 thinkdesing is 32Bit compiled and python is 32Bit compiled may be it could be a 32/64 confusion .. how can I understand how to fix this problem ? It's quite a strange behaviour, this is the method that fails, and it fails only if the argument is != None def comInit(self,obj=None): if obj==None: return "ss" + str(test1) else: self._obj=test1(obj) return self._obj Thank in advance, Matteo From timr at probo.com Thu Jan 6 21:05:30 2011 From: timr at probo.com (Tim Roberts) Date: Thu, 6 Jan 2011 12:05:30 -0800 Subject: [python-win32] Problem on com server ony in a specifie application In-Reply-To: <4D261ABE.3060809@boscolini.eu> References: <4D2587A9.5050209@boscolini.eu> <4D26051E.40707@probo.com> <4D261ABE.3060809@boscolini.eu> Message-ID: <4D26208A.2070709@probo.com> Matteo Boscolo wrote: > > how can I understand how to fix this problem ? > > It's quite a strange behaviour, > this is the method that fails, and it fails only if the argument is != None > > def comInit(self,obj=None): > if obj==None: > return "ss" + str(test1) > else: > self._obj=test1(obj) > return self._obj What do you expect this to do? You are returning a Python object as the return value of a COM method. What do you expect a C program to do with this object? The Python COM support isn't going to know how to create a wrapper for this. If you need to return a new object, then that object should be a Python COM object as well. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From matteo.boscolo at boscolini.eu Thu Jan 6 21:14:41 2011 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Thu, 06 Jan 2011 21:14:41 +0100 Subject: [python-win32] Problem on com server ony in a specifie application In-Reply-To: <4D26208A.2070709@probo.com> References: <4D2587A9.5050209@boscolini.eu> <4D26051E.40707@probo.com> <4D261ABE.3060809@boscolini.eu> <4D26208A.2070709@probo.com> Message-ID: <4D2622B1.4090500@boscolini.eu> Il 06/01/2011 21:05, Tim Roberts ha scritto: > Matteo Boscolo wrote: >> how can I understand how to fix this problem ? >> >> It's quite a strange behaviour, >> this is the method that fails, and it fails only if the argument is != None >> >> def comInit(self,obj=None): >> if obj==None: >> return "ss" + str(test1) >> else: >> self._obj=test1(obj) >> return self._obj > What do you expect this to do? You are returning a Python object as the > return value of a COM method. What do you expect a C program to do with > this object? The Python COM support isn't going to know how to create a > wrapper for this. If you need to return a new object, then that object > should be a Python COM object as well. > the return is a mistake because I make a lot of test .. the code crash before the return at self._obj=test1(obj) when I try to create a new instance of the class test1 it gives me the error the some code in the vbs dose not give me any error .. Regards, Matteo From matteo.boscolo at boscolini.eu Fri Jan 7 08:11:30 2011 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Fri, 07 Jan 2011 08:11:30 +0100 Subject: [python-win32] Problem on com server ony in a specifie application In-Reply-To: <4D26208A.2070709@probo.com> References: <4D2587A9.5050209@boscolini.eu> <4D26051E.40707@probo.com> <4D261ABE.3060809@boscolini.eu> <4D26208A.2070709@probo.com> Message-ID: <4D26BCA2.4000004@boscolini.eu> Hi all, I made the following test: I create a c# application that call the some method //code object obj = Activator.CreateInstance (Type.GetTypeFromProgID("test.Application")); object[] objArgs = new object[1]; objArgs[0] = "ciao"; obj.GetType().InvokeMember("comInit", BindingFlags.InvokeMethod, null, obj, objArgs); object ret=obj.GetType().InvokeMember("Now", BindingFlags.InvokeMethod, null, obj, objArgs); If I compile the code under any cpu I got the some problem that in thinkdesing If I compile the code under 32Bit cpu I have no error and the com server works well .. So now my question is : Can I manage this situation under python code ? The strange think is if I use the anyCpu compilation the method Now works without any problem...!??!? Regards, Matteo Il 06/01/2011 21:05, Tim Roberts ha scritto: > Matteo Boscolo wrote: >> how can I understand how to fix this problem ? >> >> It's quite a strange behaviour, >> this is the method that fails, and it fails only if the argument is != None >> >> def comInit(self,obj=None): >> if obj==None: >> return "ss" + str(test1) >> else: >> self._obj=test1(obj) >> return self._obj > What do you expect this to do? You are returning a Python object as the > return value of a COM method. What do you expect a C program to do with > this object? The Python COM support isn't going to know how to create a > wrapper for this. If you need to return a new object, then that object > should be a Python COM object as well. > From timr at probo.com Fri Jan 7 18:47:00 2011 From: timr at probo.com (Tim Roberts) Date: Fri, 7 Jan 2011 09:47:00 -0800 Subject: [python-win32] Problem on com server ony in a specifie application In-Reply-To: <4D26BCA2.4000004@boscolini.eu> References: <4D2587A9.5050209@boscolini.eu> <4D26051E.40707@probo.com> <4D261ABE.3060809@boscolini.eu> <4D26208A.2070709@probo.com> <4D26BCA2.4000004@boscolini.eu> Message-ID: <4D275194.3020809@probo.com> Matteo Boscolo wrote: > I made the following test: > I create a c# application that call the some method > //code > object obj = Activator.CreateInstance > (Type.GetTypeFromProgID("test.Application")); > object[] objArgs = new object[1]; > objArgs[0] = "ciao"; > obj.GetType().InvokeMember("comInit", > BindingFlags.InvokeMethod, null, obj, objArgs); > > object ret=obj.GetType().InvokeMember("Now", > BindingFlags.InvokeMethod, null, obj, objArgs); > > If I compile the code under any cpu I got the some problem that in > thinkdesing > If I compile the code under 32Bit cpu I have no error and the com server > works well .. > > So now my question is : > Can I manage this situation under python code ? This suggests that ThinkDesign is actually a 64-bit app. First, a couple of facts. A 64-bit application cannot call a 32-bit DLL (nor vice versa). Your Python code is a 32-bit DLL. .NET applications are kind of a strange beast. You probably know that, when you compile a .NET app, it is actually creating a generic "intermediate language". It is not creating machine CPU instructions, the way a C compiler does When you run a .NET application, the .NET runtime does a "just-in-time" compile, which turns the intermediate language into machine code for whatever CPU it is running on. That's why a single .NET application can run in many different systems. When you build a .NET exe as "any CPU" and run that code on a 64-bit system, the JIT compile will turn it into 64-bit code. That application cannot call a 32-bit DLL. When you build a .NET exe as "Win32" and run that code on a 64-bit system, the JIT compile will turn it into 32-bit code. There, the call is OK. Same exact code, different circumstances. So, one answer is to build your applications as Win32 instead of "Any CPU". Another possible answer is to turn your COM server into an "out of process" COM server. That way, instead of a DLL, you will have an EXE which will run in a separate process. I do not know how to do that with PythonCOM. Hopefully, Mark will chime in here with a helpful suggestion. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From david.briant at ubs.com Fri Jan 7 19:31:29 2011 From: david.briant at ubs.com (david.briant at ubs.com) Date: Fri, 7 Jan 2011 18:31:29 -0000 Subject: [python-win32] WSAAsyncSelect In-Reply-To: <4D24F234.7020602@probo.com> References: <4D24F234.7020602@probo.com> Message-ID: Thx. I realise I now also need to understand the GIL and locking it and unlocking it. Does anyone know of any links where blocking I/O calls are demonstrated in pure python? I'm currently parsing the c code for _socket.pyd and reading up on Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS. My goal is basically to produce a high performance socket that I can use with a Windows UI (wxpython) - so was thinking of calling ws2_32.dll but it looks like I might need to be a bit more careful. Any comments / pointers / help appreciated. David -----Original Message----- From: python-win32-bounces+david.briant=ubs.com at python.org [mailto:python-win32-bounces+david.briant=ubs.com at python.org] On Behalf Of Tim Roberts Sent: Wed 5-Jan-2011 22:36 To: Python-Win32 List Subject: Re: [python-win32] WSAAsyncSelect david.briant at ubs.com wrote: > > I'm looking for a little help on using WSAAsyncSelect via ctypes.I > imagine this has been asked before but I couldn't figure out how to > search the archives (and trawling through them randomly didn't really > help). > > ...Would it be something likethe following? > > winsock = ctypes.windll.ws2_32 > > WM_MY_SOCKET_MESSAGE= WM_USER + 1 > > ... > > s =12345 > > hWnd = 1234 > > wMsg = WM_MY_SOCKET_MESSAGE > > lEvent =FD_READ|FD_WRITE|FD_ACCEPT|FD_CONNECT|FD_CLOSE > > socketErrorOrZero = winsock.WSAAsyncSelect(s, hWnd, wMsg, lEvent) > Yes, indeed. I think that sock.socket.fileno should get you the socket handle for the first parameter. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company limited by shares incorporated in the United Kingdom registered in England and Wales with number 2035362. Registered office: 1 Finsbury Avenue, London EC2M 2PP. UBS Limited is authorised and regulated by the Financial Services Authority. UBS AG is a public company incorporated with limited liability in Switzerland domiciled in the Canton of Basel-City and the Canton of Zurich respectively registered at the Commercial Registry offices in those Cantons with Identification No: CH-270.3.004.646-4 and having respective head offices at Aeschenvorstadt 1, 4051 Basel and Bahnhofstrasse 45, 8001 Zurich, Switzerland. Registered in the United Kingdom as a foreign company with No: FC021146 and having a UK Establishment registered at Companies House, Cardiff, with No: BR 004507. The principal office of UK Establishment: 1 Finsbury Avenue, London EC2M 2PP. In the United Kingdom, UBS AG is authorised and regulated by the Financial Services Authority. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases. From timr at probo.com Fri Jan 7 19:44:43 2011 From: timr at probo.com (Tim Roberts) Date: Fri, 7 Jan 2011 10:44:43 -0800 Subject: [python-win32] WSAAsyncSelect In-Reply-To: References: <4D24F234.7020602@probo.com> Message-ID: <4D275F1B.9060303@probo.com> david.briant at ubs.com wrote: > Does anyone know of any links where blocking I/O calls are demonstrated > in pure python? Virtually all I/O calls in pure Python are blocking calls. Did you mean to ask about non-blocking I/O? > I'm currently parsing the c code for _socket.pyd and reading up on > Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS. My goal is basically to > produce a high performance socket that I can use with a Windows UI > (wxpython) - so was thinking of calling ws2_32.dll but it looks like I > might need to be a bit more careful. Well, any time I hear "high performance," I start to wonder whether Python is really the right choice. How much performance do you need? WSAAsyncSelect is a pretty snazzy way to deal with a socket server, and I suspect it could be adapted here without much trouble. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From david.briant at ubs.com Fri Jan 7 20:27:42 2011 From: david.briant at ubs.com (david.briant at ubs.com) Date: Fri, 7 Jan 2011 19:27:42 -0000 Subject: [python-win32] WSAAsyncSelect In-Reply-To: <4D275F1B.9060303@probo.com> References: <4D24F234.7020602@probo.com> <4D275F1B.9060303@probo.com> Message-ID: I'm looking for how to do blocking calls. If I do a blocking call into a dll and don't release the GIL the whole of python is blocked!!! It says in the C-API whenever you call into a C-DLL with a blocking call you need to release the GIL i.e. the Py_BEGIN_ALLOW_THREADS macro, and when the call returns you need to relock the GIL i.e. Py_END_ALLOW_THREADS. So want to know how to release and acquire the GIL from pure python (i.e. via ctypes or win32). By high performance I mean as high as python can offer - I don't want to poll and select doesn't allow you to check events from the UI - so either WSAAsyncSelect or possibly I/O completion ports. If I need more performance then it'll be a C / C++ extension, but I'd like to get the architecture prototyped in python first. I have a app written in wx that needs to get and send data out of process. All the solutions I've looked at have slow response times (due to polling loops mainly). I have a windows message handler so I should be able to get events from WSAAsyncSelect but I don't know how to release and reacquire the GIL from python if I call a blocking function in a dll. (the select package works fine if the asynchronicity is coming from a socket but not from a UI). Thx David -----Original Message----- From: python-win32-bounces+david.briant=ubs.com at python.org [mailto:python-win32-bounces+david.briant=ubs.com at python.org] On Behalf Of Tim Roberts Sent: Fri 7-Jan-2011 18:45 To: Python-Win32 List Subject: Re: [python-win32] WSAAsyncSelect david.briant at ubs.com wrote: > Does anyone know of any links where blocking I/O calls are demonstrated > in pure python? Virtually all I/O calls in pure Python are blocking calls. Did you mean to ask about non-blocking I/O? > I'm currently parsing the c code for _socket.pyd and reading up on > Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS. My goal is basically to > produce a high performance socket that I can use with a Windows UI > (wxpython) - so was thinking of calling ws2_32.dll but it looks like I > might need to be a bit more careful. Well, any time I hear "high performance," I start to wonder whether Python is really the right choice. How much performance do you need? WSAAsyncSelect is a pretty snazzy way to deal with a socket server, and I suspect it could be adapted here without much trouble. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company limited by shares incorporated in the United Kingdom registered in England and Wales with number 2035362. Registered office: 1 Finsbury Avenue, London EC2M 2PP. UBS Limited is authorised and regulated by the Financial Services Authority. UBS AG is a public company incorporated with limited liability in Switzerland domiciled in the Canton of Basel-City and the Canton of Zurich respectively registered at the Commercial Registry offices in those Cantons with Identification No: CH-270.3.004.646-4 and having respective head offices at Aeschenvorstadt 1, 4051 Basel and Bahnhofstrasse 45, 8001 Zurich, Switzerland. Registered in the United Kingdom as a foreign company with No: FC021146 and having a UK Establishment registered at Companies House, Cardiff, with No: BR 004507. The principal office of UK Establishment: 1 Finsbury Avenue, London EC2M 2PP. In the United Kingdom, UBS AG is authorised and regulated by the Financial Services Authority. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases. From timr at probo.com Fri Jan 7 23:44:11 2011 From: timr at probo.com (Tim Roberts) Date: Fri, 7 Jan 2011 14:44:11 -0800 Subject: [python-win32] WSAAsyncSelect In-Reply-To: References: <4D24F234.7020602@probo.com> <4D275F1B.9060303@probo.com> Message-ID: <4D27973B.5060200@probo.com> david.briant at ubs.com wrote: > I'm looking for how to do blocking calls. If I do a blocking call into a > dll and don't release the GIL the whole of python is blocked!!! > > It says in the C-API whenever you call into a C-DLL with a blocking call > you need to release the GIL i.e. the Py_BEGIN_ALLOW_THREADS macro, and > when the call returns you need to relock the GIL i.e. > Py_END_ALLOW_THREADS. > > So want to know how to release and acquire the GIL from pure python > (i.e. via ctypes or win32). That's impossible. The whole point of releasing the GIL is to say "I hereby promise I won't be interpreting any Python code until I reacquire the lock". If you could do that from Python code itself, you would create a singularity that will suck in the solar system. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From matteo.boscolo at boscolini.eu Sat Jan 8 08:11:17 2011 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Sat, 08 Jan 2011 08:11:17 +0100 Subject: [python-win32] Problem on com server ony in a specifie application In-Reply-To: <4D275194.3020809@probo.com> References: <4D2587A9.5050209@boscolini.eu> <4D26051E.40707@probo.com> <4D261ABE.3060809@boscolini.eu> <4D26208A.2070709@probo.com> <4D26BCA2.4000004@boscolini.eu> <4D275194.3020809@probo.com> Message-ID: <4D280E15.6090909@boscolini.eu> After a lot of testing I find a solution that solve the problem . When I call my comInit method I need to accept a return type.. for c# : object o=obj.GetType().InvokeMember("comInit", BindingFlags.InvokeMethod, null, obj, objArgs); In This way, and modifying the comInit function to make it return a value, all works with anycpu 64Bit and 32Bit and thinkdesing :-). S_OK=1 . . . . def comInit(self,obj=None): self._obj=test1(obj) return S_OK There is a standard return way to use in com server method ? I try with None but It dose not work. Thanks in advance, Matteo Il 07/01/2011 18:47, Tim Roberts ha scritto: > Matteo Boscolo wrote: >> I made the following test: >> I create a c# application that call the some method >> //code >> object obj = Activator.CreateInstance >> (Type.GetTypeFromProgID("test.Application")); >> object[] objArgs = new object[1]; >> objArgs[0] = "ciao"; >> obj.GetType().InvokeMember("comInit", >> BindingFlags.InvokeMethod, null, obj, objArgs); >> >> object ret=obj.GetType().InvokeMember("Now", >> BindingFlags.InvokeMethod, null, obj, objArgs); >> >> If I compile the code under any cpu I got the some problem that in >> thinkdesing >> If I compile the code under 32Bit cpu I have no error and the com server >> works well .. >> >> So now my question is : >> Can I manage this situation under python code ? > This suggests that ThinkDesign is actually a 64-bit app. > > First, a couple of facts. A 64-bit application cannot call a 32-bit DLL > (nor vice versa). Your Python code is a 32-bit DLL. .NET applications > are kind of a strange beast. You probably know that, when you compile a > .NET app, it is actually creating a generic "intermediate language". It > is not creating machine CPU instructions, the way a C compiler does > > When you run a .NET application, the .NET runtime does a "just-in-time" > compile, which turns the intermediate language into machine code for > whatever CPU it is running on. That's why a single .NET application can > run in many different systems. > > When you build a .NET exe as "any CPU" and run that code on a 64-bit > system, the JIT compile will turn it into 64-bit code. That application > cannot call a 32-bit DLL. When you build a .NET exe as "Win32" and run > that code on a 64-bit system, the JIT compile will turn it into 32-bit > code. There, the call is OK. Same exact code, different circumstances. > > So, one answer is to build your applications as Win32 instead of "Any > CPU". Another possible answer is to turn your COM server into an "out > of process" COM server. That way, instead of a DLL, you will have an > EXE which will run in a separate process. I do not know how to do that > with PythonCOM. Hopefully, Mark will chime in here with a helpful > suggestion. > From Andrew.MacIntyre at acma.gov.au Mon Jan 10 00:46:58 2011 From: Andrew.MacIntyre at acma.gov.au (Andrew MacIntyre) Date: Mon, 10 Jan 2011 10:46:58 +1100 Subject: [python-win32] WSAAsyncSelect [SEC=UNCLASSIFIED] In-Reply-To: References: <4D24F234.7020602@probo.com><4D275F1B.9060303@probo.com> Message-ID: > david.briant at ubs.com wrote: > So want to know how to release and acquire the GIL from pure python > (i.e. via ctypes or win32). Have you read the ctypes documentation? The "Loading shared libraries" section (s15.15.2.2 in the Python 2.6 docs) in particular seems pertinent. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre Operations Branch tel: +61 2 6219 5356 Communications Infrastructure Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: andrew.macintyre at acma.gov.au http://www.acma.gov.au/ NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. From vijayendra.bapte at gmail.com Mon Jan 10 05:40:28 2011 From: vijayendra.bapte at gmail.com (vijayendra bapte) Date: Mon, 10 Jan 2011 10:10:28 +0530 Subject: [python-win32] Com server on 64 bit Windows 7 In-Reply-To: References: <4D1D3F5A.4020107@gmail.com> <4D2526F5.6050806@skippinet.com.au> Message-ID: Mark, Per comment on http://stackoverflow.com/questions/4582819/com-server-build-using-python-on-64-bit-windows-7-machine/4621124#4621124it was an issue with py2exe and patch provided here worked well. Thanks, Vijayendra. On Thu, Jan 6, 2011 at 10:12 AM, vijayendra bapte < vijayendra.bapte at gmail.com> wrote: > > > On Thu, Jan 6, 2011 at 7:50 AM, Mark Hammond wrote: > >> On 31/12/2010 3:50 PM, vijayendra bapte wrote: >> >>> I have turned on logger in >>> `Python27/Lib/site-packages/py2exe/boot_com_servers.py` and here is the >>> traceback which I am getting in `comerror.txt` on `regsvr32 >>> test_icon_overlay.dll` >>> >>> PATH is >>> ['C:\\root\\avalon\\module\\sync\\python\\src\\dist\\library.zip'] >>> Traceback (most recent call last): >>> File "boot_com_servers.py", line 37, in >>> pywintypes.error: (126, 'GetModuleFileName', 'The specified module >>> could not be found.') >>> >> >> That is very strange - boot_com_servers.py is attempting to locate the >> path to the DLL - I can't think of why this might be failing. > > > Yes, its very strange. Issue is only on 64-bit machine and its working fine > on 32-bit machine. > > >> >> Looks like there might be a problem with >>> `win32api.GetModuleFileName(sys.frozendllhandle)` or with the dll build >>> on 64-bit Windows 7 . >>> >> >> I'm really not sure what the problem could be - I'm strugging to make >> py2exe work at the moment for other bizarre reasons and I'm out of time for >> today - hopefully I'll get back to it soon... >> >> Sure. Thanks for the help :) > > - Vijayendra. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.briant at ubs.com Mon Jan 10 09:18:09 2011 From: david.briant at ubs.com (david.briant at ubs.com) Date: Mon, 10 Jan 2011 08:18:09 -0000 Subject: [python-win32] WSAAsyncSelect [SEC=UNCLASSIFIED] In-Reply-To: References: <4D24F234.7020602@probo.com><4D275F1B.9060303@probo.com> Message-ID: Perfect. Thank you very much. That solves that problem. ;o) -----Original Message----- From: python-win32-bounces+david.briant=ubs.com at python.org [mailto:python-win32-bounces+david.briant=ubs.com at python.org] On Behalf Of Andrew MacIntyre Sent: Sun 9-Jan-2011 23:47 To: python-win32 at python.org Subject: Re: [python-win32] WSAAsyncSelect [SEC=UNCLASSIFIED] > david.briant at ubs.com wrote: > So want to know how to release and acquire the GIL from pure python > (i.e. via ctypes or win32). Have you read the ctypes documentation? The "Loading shared libraries" section (s15.15.2.2 in the Python 2.6 docs) in particular seems pertinent. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre Operations Branch tel: +61 2 6219 5356 Communications Infrastructure Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: andrew.macintyre at acma.gov.au http://www.acma.gov.au/ NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company limited by shares incorporated in the United Kingdom registered in England and Wales with number 2035362. Registered office: 1 Finsbury Avenue, London EC2M 2PP. UBS Limited is authorised and regulated by the Financial Services Authority. UBS AG is a public company incorporated with limited liability in Switzerland domiciled in the Canton of Basel-City and the Canton of Zurich respectively registered at the Commercial Registry offices in those Cantons with Identification No: CH-270.3.004.646-4 and having respective head offices at Aeschenvorstadt 1, 4051 Basel and Bahnhofstrasse 45, 8001 Zurich, Switzerland. Registered in the United Kingdom as a foreign company with No: FC021146 and having a UK Establishment registered at Companies House, Cardiff, with No: BR 004507. The principal office of UK Establishment: 1 Finsbury Avenue, London EC2M 2PP. In the United Kingdom, UBS AG is authorised and regulated by the Financial Services Authority. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases. From droptix at web.de Sat Jan 15 16:18:05 2011 From: droptix at web.de (Tom) Date: Sat, 15 Jan 2011 15:18:05 +0000 (UTC) Subject: [python-win32] Boolean type changed in Python 3.0? References: <44EE1E31095AE349AC6C3C0B69FFBF02932E0B3D6F@ENFIMBOX1.ad.datcon.co.uk> Message-ID: I have the same problems and googled a lot but just found Sunny Carter's requests with no solution. Is there any, yet? Thanks! From btimby at gmail.com Sun Jan 16 05:06:01 2011 From: btimby at gmail.com (Ben Timby) Date: Sat, 15 Jan 2011 23:06:01 -0500 Subject: [python-win32] Trouble with SetWindowLong(). Message-ID: I am using pywin32 214 on Windows XP 32 bit. I am calling SetWindowLong like so: -- import win32api, win32con def fun(): print 'fun' h = win32api.GetCurrentProcess() win32api.SetWindowLong(h, win32con.GWL_WNDPROC, fun) -- But receiving: TypeError: Unable to convert function to pointer-sized value My google-fu fails me. Any hints? From mail at timgolden.me.uk Sun Jan 16 11:49:10 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 16 Jan 2011 10:49:10 +0000 Subject: [python-win32] Trouble with SetWindowLong(). In-Reply-To: References: Message-ID: <4D32CD26.8000300@timgolden.me.uk> On 16/01/2011 4:06 AM, Ben Timby wrote: > I am using pywin32 214 on Windows XP 32 bit. I am calling SetWindowLong like so: > > -- > import win32api, win32con > > def fun(): > print 'fun' > > h = win32api.GetCurrentProcess() > win32api.SetWindowLong(h, win32con.GWL_WNDPROC, fun) > -- > > But receiving: > > TypeError: Unable to convert function to pointer-sized value > > My google-fu fails me. Any hints? I'm puzzled: what do you think "SetWindowLong" is doing? And why do you think that passing in a process handle and a Python function will achieve it? And do you understand what a WNDPROC function is? This isn't sarcasm: it's bewilderment. I'm genuinely unsure what you're trying to achieve and how you think that you can achieve it with the above code. Feel free to post back with a fuller explanation of your goals and hopefully someone here can guide you towards a possible way of achieving them. TJG From stef.mientki at gmail.com Sun Jan 16 13:51:54 2011 From: stef.mientki at gmail.com (Stef Mientki) Date: Sun, 16 Jan 2011 13:51:54 +0100 Subject: [python-win32] wbemtest might be interesting Message-ID: <4D32E9EA.7020207@gmail.com> hello, I just got tipped about a program that's standard available in windows, wbemtest might be interesting to find or browse wmi settings. cheers, Stef From btimby at gmail.com Sun Jan 16 15:51:25 2011 From: btimby at gmail.com (Ben Timby) Date: Sun, 16 Jan 2011 09:51:25 -0500 Subject: [python-win32] Trouble with SetWindowLong(). In-Reply-To: <4D32CD26.8000300@timgolden.me.uk> References: <4D32CD26.8000300@timgolden.me.uk> Message-ID: IIUC, WndProc receives messages from the message pump. I am attempting to override the default message handler with my own. The code I posted is a contrived example. So really, I am not interested in the correctness of it, but why does the call to SetWindowLong() fail the way it does when I call it. For a less contrived example, just google, and you will find many code samples doing almost exactly what my sample does (and ostensibly not failing). Here is a good one: http://wiki.wxpython.org/HookingTheWndProc How can that code run while passing a function reference as the last parameter, and mine fails? That is the underlying issue, not my sample code. I appreciate your bewilderment, but would be more interested in an answer to my question. From smokefloat at gmail.com Sun Jan 16 15:59:38 2011 From: smokefloat at gmail.com (David Hutto) Date: Sun, 16 Jan 2011 09:59:38 -0500 Subject: [python-win32] Trouble with SetWindowLong(). In-Reply-To: References: <4D32CD26.8000300@timgolden.me.uk> Message-ID: On Sun, Jan 16, 2011 at 9:51 AM, Ben Timby wrote: > IIUC, WndProc receives messages from the message pump. I am attempting > to override the default message handler with my own. The code I posted > is a contrived example. So really, I am not interested in the > correctness of it, but why does the call to SetWindowLong() fail the > way it does when I call it. > > For a less contrived example, just google, and you will find many code > samples doing almost exactly what my sample does (and ostensibly not > failing). > > Here is a good one: > http://wiki.wxpython.org/HookingTheWndProc > > How can that code run while passing a function reference as the last > parameter, and mine fails? That is the underlying issue, not my sample > code. > > I appreciate your bewilderment, Be wild erment would be the appropriate term for programmers. but would be more interested in an > answer to my question. > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- Sometimes...my mama...says I get over excited about technology. From mail at timgolden.me.uk Sun Jan 16 17:42:02 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 16 Jan 2011 16:42:02 +0000 Subject: [python-win32] Trouble with SetWindowLong(). In-Reply-To: References: <4D32CD26.8000300@timgolden.me.uk> Message-ID: <4D331FDA.3090604@timgolden.me.uk> On 16/01/2011 2:51 PM, Ben Timby wrote: > IIUC, WndProc receives messages from the message pump. I am attempting > to override the default message handler with my own. The code I posted > is a contrived example. So really, I am not interested in the > correctness of it, but why does the call to SetWindowLong() fail the > way it does when I call it. OK: because the parameters to the win32api.SetWindowLong function are (cut-and-pasted and lightly reformatted from the docs): """ hwnd : int - The handle to the window. offset : int - Specifies the zero-based byte offset of the value to change. Valid values are [.. snipped ...] or one of the GWL_ constants. val : int - Specifies the long value to place in the window's reserved memory. """ The MSDN docs at: http://msdn.microsoft.com/en-us/library/ms633591%28v=vs.85%29.aspx give for the "offset param": """ GWL_WNDPROC - Sets a new address for the window procedure. You cannot change this attribute if the window does not belong to the same process as the calling thread. [... snip ...] If you use SetWindowLong with the GWL_WNDPROC index to replace the window procedure, the window procedure must conform to the guidelines specified in the description of the WindowProc callback function. """ and there's some extra stuff about the GWL_WNDPROC as well which I've missed. > Here is a good one: > http://wiki.wxpython.org/HookingTheWndProc OK. Well I have to apologise because I hadn't appreciated how much work the win32 modules are doing behind the scenes on this one. They generally just wrap Win32 API calls fairly directly. On the other hand, you do have a couple of issues: 1) You're using the win32api version of SetWindowLong. The win32gui version -- which your linked example uses -- does in fact do some jiggery-pokery with the final parameter if the "offset" param is GWL_WNDPROC. Without that extra work by win32gui, the first one is trying to convert your Python function object into a pointer-ish value (such as an integer) which it can then pass directly to the underlying API call. 2) The first parameter is a *window* handle, not a process handle. Now, in your initial post, you've given no suggestion that you're even operating inside a windowed context, so I was suprised to find you trying to replace the underlying Windows message-handling proc. So, sorry if I came across a bit brusquely, but if you'd posted the link to the example in the first place and given a little bit of context I'd have been able to give a better answer up-front. Obviously, the callable you pass in should have the signature of a Windows proc, as in the example you linked to. I'm not sure whether it will complain if it doesn't or whether it will merely fall over in a big heap. Feel free to find out and let us know! In short, then: 1) Use the win32gui version of SetWindowLong 2) Pass a valid window handle (from within the same process as your code) as the first param 3) Pass a suitable function as the third param and, hopefully, all should be well. (Famous Last Words...) TJG From mail at timgolden.me.uk Sun Jan 16 17:44:30 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 16 Jan 2011 16:44:30 +0000 Subject: [python-win32] wbemtest might be interesting In-Reply-To: <4D32E9EA.7020207@gmail.com> References: <4D32E9EA.7020207@gmail.com> Message-ID: <4D33206E.2040201@timgolden.me.uk> On 16/01/2011 12:51 PM, Stef Mientki wrote: > hello, > > I just got tipped about a program that's standard available in windows, > wbemtest > might be interesting to find or browse wmi settings. Thanks. It is quite useful. If you want a slightly less powerful, python-based alternative, you might want to try the wmiweb module which comes packaged with the wmi module: http://timgolden.me.uk/python/wmi/index.html TJG From stef.mientki at gmail.com Mon Jan 17 00:16:18 2011 From: stef.mientki at gmail.com (Stef Mientki) Date: Mon, 17 Jan 2011 00:16:18 +0100 Subject: [python-win32] wbemtest might be interesting In-Reply-To: <4D33206E.2040201@timgolden.me.uk> References: <4D32E9EA.7020207@gmail.com> <4D33206E.2040201@timgolden.me.uk> Message-ID: <4D337C41.1070808@gmail.com> On 16-01-2011 17:44, Tim Golden wrote: > On 16/01/2011 12:51 PM, Stef Mientki wrote: >> hello, >> >> I just got tipped about a program that's standard available in windows, >> wbemtest >> might be interesting to find or browse wmi settings. > > Thanks. It is quite useful. If you want a slightly less powerful, > python-based alternative, you might want to try the wmiweb > module which comes packaged with the wmi module: > > http://timgolden.me.uk/python/wmi/index.html hi Tim, I certainly don't want to promote wbemtest as a replacement for your fabuluous WMI module !! But for more complex things, where there is no example in your excellent WMI pages, often examples in Visual Basic can be found. Translating these VB examples to python-wmi is not always that straight forward. In those cases wbemtest is very usefull to test the wmi queries and then these queries can easily be transportec to wmi-python. cheers, Stef > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From btimby at gmail.com Mon Jan 17 01:40:40 2011 From: btimby at gmail.com (Ben Timby) Date: Sun, 16 Jan 2011 19:40:40 -0500 Subject: [python-win32] Trouble with SetWindowLong(). In-Reply-To: <4D331FDA.3090604@timgolden.me.uk> References: <4D32CD26.8000300@timgolden.me.uk> <4D331FDA.3090604@timgolden.me.uk> Message-ID: No problem Tim. I am not a Windows developer so I barely know what I am talking about. I am in fact NOT in a windowed environment. I have a background process that is spawned by a GUI that I want to kill gracefully. I am trying to emulate the pattern that I use on Linux: os.kill(pid, signal.SIGTERM) ... signal.signal(signal.SIGTERM, shutdown) ... My understanding is that I need a window to receive messages (such as WM_CLOSE) so that I can shutdown gracefully when killed by the task manager or my GUI. I am using PostMessage to send a WM_CLOSE to the daemon currently. I don't think I am going to end up using a WndProc as that brings a lot of overhead, namely the need to call PumpWaitingMessages() or similar. The solution I am looking at right now is to simply create a hidden window and then call PeekMessage() passing it's hwnd. This polling method is simpler and works better with the structure of the daemon. I can simply check for messages inside each iteration of my main loop and exit when WM_CLOSE is received. However, this discussion does raise a couple questions. 1. Do I in fact need a window to receive a WM_CLOSE message? If not, how do I post a message to a process, rather than a window? 2. Why is there two flavors of SetWindowLong() (win32gui and win32api)? 3. If I DO need a window to receive messages, what is the best way to find said window? Currently I am using FindWindow, but I am not very happy searching for the window by it's title, I would be happier with an approach that allowed me to enumerate the windows that belong to a given process (I have the pid readily available). I tried EnumWindows() and then checking the pid using GetWindowThreadProcessId() inside the callback but my window was not returned using this method. My guess is that this is because it is not a "top-level" window, or that it is not visible? Anyway, thank you for taking the time to respond, the information you provided is valuable, I think probably my problem was that originally I was not creating a window, and thus had no hwnd to pass to SetWindowLong() only my process handle. From mehgcap at gmail.com Mon Jan 17 01:46:50 2011 From: mehgcap at gmail.com (Alex Hall) Date: Sun, 16 Jan 2011 19:46:50 -0500 Subject: [python-win32] set mouse pointer to custom image? Message-ID: Hello all, I have been on the list for quite a while, but rarely post. I have sort of a strange question. My sister is visually impaired. She can read print, but finding the mouse pointer is often quite difficult so she has to move the mouse up to the top left of the screen (it will stop there so she knows where it is) a lot. I am wondering if I can write a small python script which would do the following: 1. At a global keystroke, turn the pointer into a very large, easy-to-see image. 2. As soon as the mouse moves a set distance, the custom image would disappear and the normal pointer would return. 3. Offer the option to force the pointer into a set position, such as the top left corner or the center of the screen, at another global keystroke. 4. The mouse movement should not care about which window it is in, which is why I figure I will use pythonwin32 instead of a gui package like wx. TIA for any information or suggestions. Also, if you know of a program already out there that does this, please let me know so I do not go re-inventing the wheel. -- Have a great day, Alex (msg sent from GMail website) mehgcap at gmail.com; http://www.facebook.com/mehgcap From rupole at hotmail.com Mon Jan 17 04:17:48 2011 From: rupole at hotmail.com (Roger Upole) Date: Sun, 16 Jan 2011 22:17:48 -0500 Subject: [python-win32] Boolean type changed in Python 3.0? References: <44EE1E31095AE349AC6C3C0B69FFBF02932E0B3D6F@ENFIMBOX1.ad.datcon.co.uk> Message-ID: A fix has been committed to the code base, but there hasn't been a release in the meantime. If you can build from source, check out the current CVS and make sure it solves your issue. Roger "Tom" wrote in message news:loom.20110115T161528-653 at post.gmane.org... >I have the same problems and googled a lot but just found Sunny Carter's > requests with no solution. Is there any, yet? > > Thanks! From rupole at hotmail.com Mon Jan 17 04:25:29 2011 From: rupole at hotmail.com (Roger Upole) Date: Sun, 16 Jan 2011 22:25:29 -0500 Subject: [python-win32] set mouse pointer to custom image? References: Message-ID: There's an accessibility option built into Windows to do something like this. Look under Control Panel->Mouse->Options, and you should see an option to highlight the mouse cursor when the CTRL key is pressed. Roger "Alex Hall" wrote in message news:AANLkTi=y0mX86gcR67Ot=SzZdjQ1MFhVuzx-+xRs8Txs at mail.gmail.com... > Hello all, > I have been on the list for quite a while, but rarely post. > I have sort of a strange question. My sister is visually impaired. She > can read print, but finding the mouse pointer is often quite difficult > so she has to move the mouse up to the top left of the screen (it will > stop there so she knows where it is) a lot. I am wondering if I can > write a small python script which would do the following: > 1. At a global keystroke, turn the pointer into a very large, easy-to-see > image. > 2. As soon as the mouse moves a set distance, the custom image would > disappear and the normal pointer would return. > 3. Offer the option to force the pointer into a set position, such as > the top left corner or the center of the screen, at another global > keystroke. > 4. The mouse movement should not care about which window it is in, > which is why I figure I will use pythonwin32 instead of a gui package > like wx. > > TIA for any information or suggestions. Also, if you know of a program > already out there that does this, please let me know so I do not go > re-inventing the wheel. > > -- > Have a great day, > Alex (msg sent from GMail website) > mehgcap at gmail.com; http://www.facebook.com/mehgcap From rupole at hotmail.com Mon Jan 17 04:29:01 2011 From: rupole at hotmail.com (Roger Upole) Date: Sun, 16 Jan 2011 22:29:01 -0500 Subject: [python-win32] Passing parameters to FoxPro COM methods References: Message-ID: Dynamic objects have a _make_method method that you can use to ensure that it will be called with parameters. Roger "Richard Lawrence" wrote in message news:AANLkTi=5D1egw5DxRU-bU_-ioKa4nQvsNx-FOTw_VaVp at mail.gmail.com... Dear Pythonistas, I still haven't figured out a way around this issue: > 2) Regarding late binding: the way that attributes are looked up in > win32com.client.dynamic.CDispatch.__getattr__ seems not to play nicely > with Foxpro's way of responding to queries about the interface. I > think what's happening is that __getattr__('some_method') attempts > first to call Invoke with pythoncom.INVOKE_PROPERTYGET as the > invocation type. As the win32com documentation indicates sometimes > happens, Foxpro seems to respond to this by *calling* the method. I can confirm that this is the problem I am having (or at least one of them). The way win32com.client.dynamic.CDispatch looks up attributes -- by first trying an invocation with INVOKE_PROPERTYGET and only building a method if that raises a pythoncom.com_error -- doesn't work for me, because when the requested attribute is a method, this invocation simply calls the method and returns the result, rather than throwing an error. (At least some of the methods on the component that I am interested in using seem to be implemented in such a way that they have default behavior when called with no arguments, though I am not sure if this is the way Foxpro implements *all* method calls. That is, I'm not sure if my DLL's author simply provided fallback functionality on these methods, where Foxpro would normally throw an error if these methods were not called with the right number of arguments, or if Foxpro itself simply assigns default values to all missing arguments, and my DLL's author is working within that limitation.) > This means that if, say, some_method returns a string, then a call > like: > > c.d.some_method(param1, param2) > > blows up because __getattr__('some_method') returns a string value > that results from calling some_method, rather than a reference to the > method, so I get a TypeError to the effect that a string value is not > callable; whereas > > c.d.some_method > > actually calls the method and returns a value, but of course I can't > pass the call any parameters. So, I'm still wondering: what's the best way to use PythonCOM with late binding such that I can: - prevent component *methods* from being mistakenly called (with no arguments) by an Invoke with pythoncom.INVOKE_PROPERTYGET as the invocation type - call component methods (with arguments) using an Invoke with python.INVOKE_FUNC as the invocation type - continue to get component *properties* via an Invoke with pythoncom.INVOKE_PROPERTYGET as the invocation type Is overriding __getattr__ the way to go here? Or is there a more data-driven approach? Thanks! Richard From mehgcap at gmail.com Mon Jan 17 07:19:28 2011 From: mehgcap at gmail.com (Alex Hall) Date: Mon, 17 Jan 2011 01:19:28 -0500 Subject: [python-win32] set mouse pointer to custom image? In-Reply-To: References: Message-ID: Thanks, we'll investigate this tomorrow and see if highlighting is enough. On 1/16/11, Roger Upole wrote: > There's an accessibility option built into Windows to do something > like this. Look under Control Panel->Mouse->Options, and you > should see an option to highlight the mouse cursor when the CTRL > key is pressed. > > Roger > > "Alex Hall" wrote in message > news:AANLkTi=y0mX86gcR67Ot=SzZdjQ1MFhVuzx-+xRs8Txs at mail.gmail.com... >> Hello all, >> I have been on the list for quite a while, but rarely post. >> I have sort of a strange question. My sister is visually impaired. She >> can read print, but finding the mouse pointer is often quite difficult >> so she has to move the mouse up to the top left of the screen (it will >> stop there so she knows where it is) a lot. I am wondering if I can >> write a small python script which would do the following: >> 1. At a global keystroke, turn the pointer into a very large, easy-to-see >> image. >> 2. As soon as the mouse moves a set distance, the custom image would >> disappear and the normal pointer would return. >> 3. Offer the option to force the pointer into a set position, such as >> the top left corner or the center of the screen, at another global >> keystroke. >> 4. The mouse movement should not care about which window it is in, >> which is why I figure I will use pythonwin32 instead of a gui package >> like wx. >> >> TIA for any information or suggestions. Also, if you know of a program >> already out there that does this, please let me know so I do not go >> re-inventing the wheel. >> >> -- >> Have a great day, >> Alex (msg sent from GMail website) >> mehgcap at gmail.com; http://www.facebook.com/mehgcap > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- Have a great day, Alex (msg sent from GMail website) mehgcap at gmail.com; http://www.facebook.com/mehgcap From mail at timgolden.me.uk Mon Jan 17 10:44:51 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 17 Jan 2011 09:44:51 +0000 Subject: [python-win32] wbemtest might be interesting In-Reply-To: <4D337C41.1070808@gmail.com> References: <4D32E9EA.7020207@gmail.com> <4D33206E.2040201@timgolden.me.uk> <4D337C41.1070808@gmail.com> Message-ID: <4D340F93.9000300@timgolden.me.uk> On 16/01/2011 23:16, Stef Mientki wrote: > I certainly don't want to promote wbemtest as a replacement for your fabuluous WMI module !! > > But for more complex things, > where there is no example in your excellent WMI pages, > often examples in Visual Basic can be found. > > Translating these VB examples to python-wmi is not always that straight forward. > In those cases wbemtest is very usefull to test the wmi queries > and then these queries can easily be transportec to wmi-python. All good points. FWIW, I'm usually available to help translating VBS examples if there are specifics you're after. But obviously, a tool which helps one to help oneself is always useful. TJG From somnathnaskar7 at gmail.com Mon Jan 17 11:07:30 2011 From: somnathnaskar7 at gmail.com (Somnath Naskar) Date: Mon, 17 Jan 2011 15:37:30 +0530 Subject: [python-win32] About COM Message-ID: Hi All, I am having an issue with 64 bit machine while using COM interface.I am describing my problem in details.... 1. I have a 64 bit machine and there I have installed python 64 bit and 64 bit win32 module. 2. In that machine I have installed Lotus Domino Admin Client of 32 bit version(because it's 64 bit version is not available.). 3. Now I am Dispatching the Com objects of the Domino like ... from win32com.client import Dispatch ses = Dispatch('Lotus.NotesSession') But I am getting the below error. File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 104, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 84, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221164, 'Class not registered', None, None) Is there any work around for this scenario.I want a solution for this. Please help , I am new to this COM things.It's working fine for 32 bit machine. Thanks & Regards, Somnath Naskar -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.briant at ubs.com Mon Jan 17 11:22:06 2011 From: david.briant at ubs.com (david.briant at ubs.com) Date: Mon, 17 Jan 2011 10:22:06 -0000 Subject: [python-win32] Trouble with SetWindowLong(). In-Reply-To: <4D331FDA.3090604@timgolden.me.uk> References: <4D32CD26.8000300@timgolden.me.uk> <4D331FDA.3090604@timgolden.me.uk> Message-ID: You can use PostThreadMessage instead of PostMessage. To get the address of a python WndProc I use ctypes: WNDPROC = WINFUNCTYPE(c_int, c_ulong, c_ulong, c_ulong, c_ulong) lpfnwndproc = WNDPROC(wndproc) where: def wndproc(hWnd, Msg, wParam, lParam): ... I intercept WM_QUIT for shutdown - I believe WM_CLOSE is just for a window my message pump looks like this: msg = MSG() lpmsg = byref(msg) while 1: ret = user32.GetMessageA(lpmsg, 0, 0, 0) if ret == -1: raise WinError() elif ret == 0: return # got WM_QUIT if not self.filter_message(lpmsg): user32.TranslateMessage(lpmsg) user32.DispatchMessageA(lpmsg) HTH David -----Original Message----- From: python-win32-bounces+david.briant=ubs.com at python.org [mailto:python-win32-bounces+david.briant=ubs.com at python.org] On Behalf Of Tim Golden Sent: Sun 16-Jan-2011 16:42 Cc: python-win32 at python.org Subject: Re: [python-win32] Trouble with SetWindowLong(). On 16/01/2011 2:51 PM, Ben Timby wrote: > IIUC, WndProc receives messages from the message pump. I am attempting > to override the default message handler with my own. The code I posted > is a contrived example. So really, I am not interested in the > correctness of it, but why does the call to SetWindowLong() fail the > way it does when I call it. OK: because the parameters to the win32api.SetWindowLong function are (cut-and-pasted and lightly reformatted from the docs): """ hwnd : int - The handle to the window. offset : int - Specifies the zero-based byte offset of the value to change. Valid values are [.. snipped ...] or one of the GWL_ constants. val : int - Specifies the long value to place in the window's reserved memory. """ The MSDN docs at: http://msdn.microsoft.com/en-us/library/ms633591%28v=vs.85%29.aspx give for the "offset param": """ GWL_WNDPROC - Sets a new address for the window procedure. You cannot change this attribute if the window does not belong to the same process as the calling thread. [... snip ...] If you use SetWindowLong with the GWL_WNDPROC index to replace the window procedure, the window procedure must conform to the guidelines specified in the description of the WindowProc callback function. """ and there's some extra stuff about the GWL_WNDPROC as well which I've missed. > Here is a good one: > http://wiki.wxpython.org/HookingTheWndProc OK. Well I have to apologise because I hadn't appreciated how much work the win32 modules are doing behind the scenes on this one. They generally just wrap Win32 API calls fairly directly. On the other hand, you do have a couple of issues: 1) You're using the win32api version of SetWindowLong. The win32gui version -- which your linked example uses -- does in fact do some jiggery-pokery with the final parameter if the "offset" param is GWL_WNDPROC. Without that extra work by win32gui, the first one is trying to convert your Python function object into a pointer-ish value (such as an integer) which it can then pass directly to the underlying API call. 2) The first parameter is a *window* handle, not a process handle. Now, in your initial post, you've given no suggestion that you're even operating inside a windowed context, so I was suprised to find you trying to replace the underlying Windows message-handling proc. So, sorry if I came across a bit brusquely, but if you'd posted the link to the example in the first place and given a little bit of context I'd have been able to give a better answer up-front. Obviously, the callable you pass in should have the signature of a Windows proc, as in the example you linked to. I'm not sure whether it will complain if it doesn't or whether it will merely fall over in a big heap. Feel free to find out and let us know! In short, then: 1) Use the win32gui version of SetWindowLong 2) Pass a valid window handle (from within the same process as your code) as the first param 3) Pass a suitable function as the third param and, hopefully, all should be well. (Famous Last Words...) TJG _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company limited by shares incorporated in the United Kingdom registered in England and Wales with number 2035362. Registered office: 1 Finsbury Avenue, London EC2M 2PP. UBS Limited is authorised and regulated by the Financial Services Authority. UBS AG is a public company incorporated with limited liability in Switzerland domiciled in the Canton of Basel-City and the Canton of Zurich respectively registered at the Commercial Registry offices in those Cantons with Identification No: CH-270.3.004.646-4 and having respective head offices at Aeschenvorstadt 1, 4051 Basel and Bahnhofstrasse 45, 8001 Zurich, Switzerland. Registered in the United Kingdom as a foreign company with No: FC021146 and having a UK Establishment registered at Companies House, Cardiff, with No: BR 004507. The principal office of UK Establishment: 1 Finsbury Avenue, London EC2M 2PP. In the United Kingdom, UBS AG is authorised and regulated by the Financial Services Authority. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases. From timr at probo.com Mon Jan 17 19:54:40 2011 From: timr at probo.com (Tim Roberts) Date: Mon, 17 Jan 2011 10:54:40 -0800 Subject: [python-win32] About COM In-Reply-To: References: Message-ID: <4D349070.9020403@probo.com> Somnath Naskar wrote: > > I am having an issue with 64 bit machine while using COM interface.I > am describing my problem in details.... > > 1. I have a 64 bit machine and there I have installed python 64 bit > and 64 bit win32 module. > 2. In that machine I have installed Lotus Domino Admin Client of 32 > bit version(because it's 64 bit version is not available.). > 3. Now I am Dispatching the Com objects of the Domino like ... > > from win32com.client import Dispatch > ses = Dispatch('Lotus.NotesSession') > > But I am getting the below error. > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > pythoncom.IID_IDispatch) > > com_error: (-2147221164, 'Class not registered', None, None) > > Is there any work around for this scenario.I want a solution for this. > You cannot call a 32-bit in-process COM object from a 64-bit process. It is simply not possible. You have several options. You can try to create the object as an out-of-process server, which means that it will run as a separate executable, instead of as a DLL in your process. The server has to support this explicitly, but Lotus is big enough that it might be there: import pythoncom ses = Dispatch('Lotus.NotesSession', clsctx=pythoncom.CLSCTX_LOCAL_SERVER) If that doesn't work, you'll have to create your own 32-bit process to communicate with Lotus, with some kind of cross-process scheme to pass requests between you and the other process. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Jan 17 20:00:13 2011 From: timr at probo.com (Tim Roberts) Date: Mon, 17 Jan 2011 11:00:13 -0800 Subject: [python-win32] Trouble with SetWindowLong(). In-Reply-To: References: <4D32CD26.8000300@timgolden.me.uk> <4D331FDA.3090604@timgolden.me.uk> Message-ID: <4D3491BD.3040903@probo.com> Ben Timby wrote: > I don't think I am going to end up using a WndProc as that brings a > lot of overhead, namely the need to call PumpWaitingMessages() or > similar. The solution I am looking at right now is to simply create a > hidden window and then call PeekMessage() passing it's hwnd. This > polling method is simpler and works better with the structure of the > daemon. I can simply check for messages inside each iteration of my > main loop and exit when WM_CLOSE is received. > > However, this discussion does raise a couple questions. > > 1. Do I in fact need a window to receive a WM_CLOSE message? If not, > how do I post a message to a process, rather than a window? Messages in Windows are actually targeted to threads. When you send a message to a window, it gets sent to the message queue for the thread that created the window. It is possible for a thread to have a message queue even without a window, but the queue is not created until the thread checks for messages, so you would still need a message pump. However, there are LOTS of ways to communicate between processes besides window messages. In your case, for example, you could easily create a named event, and signal an event when you want the thread to die. That can be done without creating any windows at all. > 2. Why is there two flavors of SetWindowLong() (win32gui and win32api)? History. Win32api attempts to map a wide variety of API calls as simply as possible -- no typing, little parameter validation. Win32gui is a more sophisticated wrapper around the UI-specific parts of the API, which attempts to provide a mapping between the API parameters and Python types. > 3. If I DO need a window to receive messages, what is the best way to > find said window? Currently I am using FindWindow, but I am not very > happy searching for the window by it's title, I'm voting for a named event. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From chester_lab at fltg.net Mon Jan 17 20:21:25 2011 From: chester_lab at fltg.net (FT) Date: Mon, 17 Jan 2011 14:21:25 -0500 Subject: [python-win32] Fetching Battery Monitor Data Message-ID: <2B602B53D89E450ABF2B9DA00081CE1B@1B1B1L1> Hi Mark, I could not find using Google any information on how to get the Laptop Battery Level information so I could have my Screen Reader Or voices from Sapi to talk the information. So, I would need the modules or a sample code that fetches the data from that location on the screen. I figure I could study the code and learn how to do it after getting the information. I have already posted information on other lists about using PYTTS but would like to have information on getting batter info and work up from there. Sincerely Bruce From rays at blue-cove.com Mon Jan 17 22:22:33 2011 From: rays at blue-cove.com (RayS) Date: Mon, 17 Jan 2011 13:22:33 -0800 Subject: [python-win32] DDE and OLE/COM Message-ID: <6.2.3.4.2.20110117131633.028d3090@pop-server.san.rr.com> An HTML attachment was scrubbed... URL: From naveen.garg at gmail.com Mon Jan 17 22:43:33 2011 From: naveen.garg at gmail.com (Naveen Garg) Date: Mon, 17 Jan 2011 21:43:33 +0000 (UTC) Subject: [python-win32] what's required to use win32com in a portable python directory. Message-ID: Is it possible to use win32com without setting up registry keys ? From timr at probo.com Mon Jan 17 23:30:46 2011 From: timr at probo.com (Tim Roberts) Date: Mon, 17 Jan 2011 14:30:46 -0800 Subject: [python-win32] what's required to use win32com in a portable python directory. In-Reply-To: References: Message-ID: <4D34C316.1000205@probo.com> Naveen Garg wrote: > Is it possible to use win32com without setting up registry keys ? A COM server can only be accessed through the registry. So, if you are writing a COM server, then you must create registry keys. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From somnathnaskar7 at gmail.com Tue Jan 18 05:54:30 2011 From: somnathnaskar7 at gmail.com (Somnath Naskar) Date: Tue, 18 Jan 2011 10:24:30 +0530 Subject: [python-win32] About COM In-Reply-To: <4D349070.9020403@probo.com> References: <4D349070.9020403@probo.com> Message-ID: On Tue, Jan 18, 2011 at 12:24 AM, Tim Roberts wrote: > Somnath Naskar wrote: > > > > I am having an issue with 64 bit machine while using COM interface.I > > am describing my problem in details.... > > > > 1. I have a 64 bit machine and there I have installed python 64 bit > > and 64 bit win32 module. > > 2. In that machine I have installed Lotus Domino Admin Client of 32 > > bit version(because it's 64 bit version is not available.). > > 3. Now I am Dispatching the Com objects of the Domino like ... > > > > from win32com.client import Dispatch > > ses = Dispatch('Lotus.NotesSession') > > > > But I am getting the below error. > > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > > pythoncom.IID_IDispatch) > > > > com_error: (-2147221164, 'Class not registered', None, None) > > > > Is there any work around for this scenario.I want a solution for this. > > > > You cannot call a 32-bit in-process COM object from a 64-bit process. > It is simply not possible. > > You have several options. You can try to create the object as an > out-of-process server, which means that it will run as a separate > executable, instead of as a DLL in your process. The server has to > support this explicitly, but Lotus is big enough that it might be there: > > import pythoncom > ses = Dispatch('Lotus.NotesSession', > clsctx=pythoncom.CLSCTX_LOCAL_SERVER) > > If that doesn't work, you'll have to create your own 32-bit process to > communicate with Lotus, with some kind of cross-process scheme to pass > requests between you and the other process. > > Hi Roberts, Thank you for your response.Thank you very much.I am new in the industry. I tried what you told as first option but it is giving following error... >>> ses = Dispatch("Lotus.NoteSession",clsctx=pythoncom.CLSCTX_LOCAL_SERVER) Traceback (most recent call last): File "", line 1, in File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c lsctx) File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 104, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 84, in _ GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II D_IDispatch) pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) The Second option you told is like to create my own 32 bit process to communicate with Lotus, but I am afraid that I have no idea about how to create q 32 bit process and also how to communicate to Lotus using that. Please give me some code example and idea regarding that. Thanks & Regards, Somnath Naskar -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.briant at ubs.com Tue Jan 18 08:21:12 2011 From: david.briant at ubs.com (david.briant at ubs.com) Date: Tue, 18 Jan 2011 07:21:12 -0000 Subject: [python-win32] what's required to use win32com in a portable python directory. In-Reply-To: <4D34C316.1000205@probo.com> References: <4D34C316.1000205@probo.com> Message-ID: I don't know if that's just true for pywin32 but in general you don't need to register COM dlls if you provide manifest files. Google for side-by-side sxs registryless regfree. Also this company are helpful - helped me use reg-free COM and .NET together - http://www.mazecomputer.com/. David -----Original Message----- From: python-win32-bounces+david.briant=ubs.com at python.org [mailto:python-win32-bounces+david.briant=ubs.com at python.org] On Behalf Of Tim Roberts Sent: Mon 17-Jan-2011 22:31 To: Python-Win32 List Subject: Re: [python-win32] what's required to use win32com in a portable python directory. Naveen Garg wrote: > Is it possible to use win32com without setting up registry keys ? A COM server can only be accessed through the registry. So, if you are writing a COM server, then you must create registry keys. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company limited by shares incorporated in the United Kingdom registered in England and Wales with number 2035362. Registered office: 1 Finsbury Avenue, London EC2M 2PP. UBS Limited is authorised and regulated by the Financial Services Authority. UBS AG is a public company incorporated with limited liability in Switzerland domiciled in the Canton of Basel-City and the Canton of Zurich respectively registered at the Commercial Registry offices in those Cantons with Identification No: CH-270.3.004.646-4 and having respective head offices at Aeschenvorstadt 1, 4051 Basel and Bahnhofstrasse 45, 8001 Zurich, Switzerland. Registered in the United Kingdom as a foreign company with No: FC021146 and having a UK Establishment registered at Companies House, Cardiff, with No: BR 004507. The principal office of UK Establishment: 1 Finsbury Avenue, London EC2M 2PP. In the United Kingdom, UBS AG is authorised and regulated by the Financial Services Authority. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases. From david.briant at ubs.com Tue Jan 18 08:42:50 2011 From: david.briant at ubs.com (david.briant at ubs.com) Date: Tue, 18 Jan 2011 07:42:50 -0000 Subject: [python-win32] what's required to use win32com in a portable python directory. In-Reply-To: <4D34C316.1000205@probo.com> References: <4D34C316.1000205@probo.com> Message-ID: I don't know if that's just true for pywin32 but in general you don't need to register COM dlls if you provide manifest files. Google for side-by-side sxs registryless regfree. Also this company are helpful - helped me use reg-free COM and .NET together - http://www.mazecomputer.com/. David -----Original Message----- From: python-win32-bounces+david.briant=ubs.com at python.org [mailto:python-win32-bounces+david.briant=ubs.com at python.org] On Behalf Of Tim Roberts Sent: Mon 17-Jan-2011 22:31 To: Python-Win32 List Subject: Re: [python-win32] what's required to use win32com in a portable python directory. Naveen Garg wrote: > Is it possible to use win32com without setting up registry keys ? A COM server can only be accessed through the registry. So, if you are writing a COM server, then you must create registry keys. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company limited by shares incorporated in the United Kingdom registered in England and Wales with number 2035362. Registered office: 1 Finsbury Avenue, London EC2M 2PP. UBS Limited is authorised and regulated by the Financial Services Authority. UBS AG is a public company incorporated with limited liability in Switzerland domiciled in the Canton of Basel-City and the Canton of Zurich respectively registered at the Commercial Registry offices in those Cantons with Identification No: CH-270.3.004.646-4 and having respective head offices at Aeschenvorstadt 1, 4051 Basel and Bahnhofstrasse 45, 8001 Zurich, Switzerland. Registered in the United Kingdom as a foreign company with No: FC021146 and having a UK Establishment registered at Companies House, Cardiff, with No: BR 004507. The principal office of UK Establishment: 1 Finsbury Avenue, London EC2M 2PP. In the United Kingdom, UBS AG is authorised and regulated by the Financial Services Authority. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases. From rupole at hotmail.com Tue Jan 18 14:34:47 2011 From: rupole at hotmail.com (Roger Upole) Date: Tue, 18 Jan 2011 08:34:47 -0500 Subject: [python-win32] Fetching Battery Monitor Data References: <2B602B53D89E450ABF2B9DA00081CE1B@1B1B1L1> Message-ID: "FT" wrote in message news:2B602B53D89E450ABF2B9DA00081CE1B at 1B1B1L1... > > Hi Mark, > > I could not find using Google any information on how to get the Laptop > Battery Level information so I could have my Screen Reader Or voices from > Sapi to talk the information. > So, I would need the modules or a sample code that fetches the data > from that location on the screen. > I figure I could study the code and learn how to do it after getting > the information. > I have already posted information on other lists about using PYTTS but > would like to have information on getting batter info and work up from > there. > > Sincerely > Bruce You can use WMI to get the battery level. import win32com.client wmi=win32com.client.GetObject('winmgmts:') b=wmi.InstancesOf('win32_battery') print b[0].EstimatedChargeRemaining Roger From maubriga at gmail.com Tue Jan 18 10:33:21 2011 From: maubriga at gmail.com (Mauro) Date: Tue, 18 Jan 2011 09:33:21 +0000 Subject: [python-win32] win32com error when importing numpy Message-ID: I get an error (below) when trying to use a python code including numpy. Is win32 somehow incompatible with numpy? I would appreciate any information you can provide regarding this issue. I only get the error if I import any function from numpy! Minimal example: import win32com.server.register import pythoncom from numpy import mean class TimeSeriesManipulation: _public_methods_ = [ 'SplitString'] _reg_progid_ = "PythonUtils.NumpyError" _reg_clsid_ = "{08A4D1F8-0185-4692-BE40-4AD081DB90B1}" def SplitString(self, val, item=None): from string import split if item != None: item = str(item) return split(str(val), item) if __name__=='__main__': print "Registering COM server..." import win32com.server.register win32com.server.register.UseCommandLine(TimeSeriesManipulation) Sub tt() Set PythonUtils = CreateObject("PythonUtils.NumpyError") response = PythonUtils.SplitString("Hello from VB") For Each Item In response MsgBox Item Next End Sub I get a run-time error ' -21474677259(80004005)': Unexpected Python Error: Traceback (most recent call last): File "C:\appl\python26\lib\site-packages\win32com\server\policy.py", line 136 in CreateInstance return retObj._CreateInstance_(clsid, reqIID) File "C:\appl\python26\lib\site-packages\win32com\server\policy.py", line 194, in _CreateInstance_ mvob = call func(classSpec) -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Jan 18 19:34:26 2011 From: timr at probo.com (Tim Roberts) Date: Tue, 18 Jan 2011 10:34:26 -0800 Subject: [python-win32] About COM In-Reply-To: References: <4D349070.9020403@probo.com> Message-ID: <4D35DD32.3070600@probo.com> Somnath Naskar wrote: > Thank you for your response.Thank you very much.I am new in the industry. > I tried what you told as first option but it is giving following error... > > >>> ses = > Dispatch("Lotus.NoteSession",clsctx=pythoncom.CLSCTX_LOCAL_SERVER) > ... > pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) > I think you misspelled it. Didn't you say it was "Lotus.NotesSession"? > The Second option you told is like to create my own 32 bit process to > communicate with Lotus, but I am afraid that I have no idea about how > to create q 32 bit process and also how to communicate to Lotus using > that. > Please give me some code example and idea regarding that. You might consider forgetting about 64-bit Python and install 32-bit Python instead, especially if this interface is important for you. The 32-bit Python works perfectly well on 64-bit systems. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From somnathnaskar7 at gmail.com Wed Jan 19 06:24:01 2011 From: somnathnaskar7 at gmail.com (Somnath Naskar) Date: Wed, 19 Jan 2011 10:54:01 +0530 Subject: [python-win32] About COM In-Reply-To: <4D35DD32.3070600@probo.com> References: <4D349070.9020403@probo.com> <4D35DD32.3070600@probo.com> Message-ID: On Wed, Jan 19, 2011 at 12:04 AM, Tim Roberts wrote: > Somnath Naskar wrote: > > Thank you for your response.Thank you very much.I am new in the industry. > > I tried what you told as first option but it is giving following error... > > > > >>> ses = > > Dispatch("Lotus.NoteSession",clsctx=pythoncom.CLSCTX_LOCAL_SERVER) > > ... > > pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) > > > > I think you misspelled it. Didn't you say it was "Lotus.NotesSession"? > Yea I misspelled it but after correction I got the first error like Class not register. > > > The Second option you told is like to create my own 32 bit process to > > communicate with Lotus, but I am afraid that I have no idea about how > > to create q 32 bit process and also how to communicate to Lotus using > > that. > > Please give me some code example and idea regarding that. > > You might consider forgetting about 64-bit Python and install 32-bit > Python instead, especially if this interface is important for you. The > 32-bit Python works perfectly well on 64-bit systems. > Yea I tried 32 bit python also and it was telling that something is not a valid win32 program like that. Thanks Somnath Naskar -------------- next part -------------- An HTML attachment was scrubbed... URL: From chester_lab at fltg.net Wed Jan 19 14:35:32 2011 From: chester_lab at fltg.net (FT) Date: Wed, 19 Jan 2011 08:35:32 -0500 Subject: [python-win32] Fetching Battery Monitor Data (Roger Upole) Message-ID: <80A78A3DF230456DB8BFAA6232A765FB@1B1B1L1> Hi Roger, OK, I had downloaded WMI after posting my message under others recommendation from another Python list and one sample file directory program worked. Will set this up and see if it works, thanks! But, those also said to look at several websites on tutorials and documentation. What I found there was very little and only one example but no real structured approach concerning objects and such. Do you or anyone have a better site to give more details? I ask this for what I found had a lot more then just this simple task you mention below, thus making it very confusing. I need everything in text format since I only use a screen reader. I can read .PDF but it can be a pain. HTML tags type format is the best besides the .chm format, for you can jump around by reference and links. You can use WMI to get the battery level. import win32com.client wmi=win32com.client.GetObject('winmgmts:') b=wmi.InstancesOf('win32_battery') print b[0].EstimatedChargeRemaining Roger From chester_lab at fltg.net Wed Jan 19 15:53:40 2011 From: chester_lab at fltg.net (FT) Date: Wed, 19 Jan 2011 09:53:40 -0500 Subject: [python-win32] Battery Level Indicator With voice Message-ID: Hello everyone, Since I got a simple answer from Roger on the Python Win32 web site I decided to post it here for those who would want that information, especially those who can not see. The first 2 lines are all that is needed along with the battery level instances using that object, ( BatteryPercentage = wmi.InstancesOf('win32_battery')) This program uses the computer voices and will list them if the specified one is not found. In this case I used Karen. When the list is displayed you do not need to insert everything in the name, just the obvious part of the name, like Karen. Just make sure you spell it correctly or you will always get the list printed on the screen. this also will sound off every minute because of the sleep amounts I use. It can also be changed to voice the percentage every percent change, just do what you want to do. Bruce #BatteryLevel.py import win32com.client wmi=win32com.client.GetObject('winmgmts:') from random import randint, uniform import msvcrt #INPUT KEYBOARD COMMANDS! import sys import time import pyTTS #VOICE SETUP! tts = pyTTS.Create() purge = pyTTS.tts_purge_before_speak async = pyTTS.tts_async PITCH=0 tts.Volume = 100 tts.Rate = 2 VOICECOUNT = len(tts.GetVoiceNames()) VOICES=[] for v in range( VOICECOUNT): VOICES.append( tts.GetVoiceNames()[v]) def setVoice2Name( name): "SET VOICE BY NAME!" t=-1 for v in range( VOICECOUNT): if name in VOICES[ v]: tts.SetVoiceByName( VOICES[v]) t=v if t==-1: tts.Speak( " %d Voices with %s Name Not Found! " % (VOICECOUNT, name)) print " %d Voices with %s Name Not Found! " % (VOICECOUNT, name) print "Voices:" for v in range( VOICECOUNT): print "%d= %s" % (v, VOICES[ v]) def Speak(text, pitch=999): if pitch==999: pitch=PITCH tts.Speak( " %s" % (pitch, text), async, purge) def SpeakNext(text, pitch=999): if pitch==999: pitch=PITCH tts.Speak( " %s" % (pitch, text), async) def setRate( rate): tts.Rate= rate if __name__ == '__main__': setVoice2Name( "Karen") PITCH=3 setRate( 2) # clear the keyboard buffer while msvcrt.kbhit(): ch = msvcrt.getch() ch=""; ch1=""; sch="" while ch != chr(27) and ch != chr(13): while msvcrt.kbhit(): ch1 = msvcrt.getch() ch = ch1 if ch1 == chr(0) or ch1 == chr(224): ch = msvcrt.getch() sch = ch1+ch #SAVE ANY MULTIKEYS! if ch != chr(27) and ch != chr(13): BatteryPercentage = wmi.InstancesOf('win32_battery') print (" %d Percent battery charge remaining! " % BatteryPercentage[0].EstimatedChargeRemaining) print "Hay! Battery power is getting low! Plug in the power cord:" print "Please Press Enter To Exit This Battery Alert!" SpeakNext(" %d Percent battery charge remaining! " % BatteryPercentage[0].EstimatedChargeRemaining) SpeakNext( "Hay! Battery power is getting low! Plug in the power cord:") SpeakNext( "Please Press Enter To Exit This Battery Alert!") # time.sleep(10) c = 0 while c < 30: if msvcrt.kbhit(): SpeakNext( "Key Was Hit!") c = 100 time.sleep(1) else: time.sleep(2) c += 1 # if msvcrt.kbhit(): # SpeakNext( "Key Was Hit!") # time.sleep(1) # else: # time.sleep(5) SpeakNext( "OK, Goodbye!") time.sleep(2) #RELEASE VOICE INSTANCE FROM MEMORY! del tts sys.exit() From naveen.garg at gmail.com Thu Jan 20 00:49:58 2011 From: naveen.garg at gmail.com (tinku99) Date: Wed, 19 Jan 2011 15:49:58 -0800 (PST) Subject: [python-win32] what's required to use win32com in a portable python directory. In-Reply-To: References: <4D34C316.1000205@probo.com> Message-ID: <30715118.post@talk.nabble.com> I got it to work. Just need to put these two files on the path: pythoncom26.dll pywintypes26.dl then, i was able to import win32com from the interactive python shell. i can temporarily register the CLSID of my com classes with the windows registry or pass the object pointers of the python classes wrapped in com... -- View this message in context: http://old.nabble.com/what%27s-required-to-use-win32com-in-a-portable-python-directory.-tp30695144p30715118.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From gary.smith28 at comcast.net Sun Jan 23 06:33:44 2011 From: gary.smith28 at comcast.net (Gary L Smith) Date: Sun, 23 Jan 2011 00:33:44 -0500 Subject: [python-win32] odbc under windows 7? Message-ID: <898F0C65FE654023B8B6359FD41B5E0D@Aesop> Dear Pythoners, I need to access data in an MS Access 2003 database using Python 2.5 or 2.6 running in Windows7. Windows7 doesn't seem to have appropriate drivers for ODBC. My error messages consistently contain the phrase, "Data source name not found and no default driver specified." While I see that others have run into the same problem, my web searches have only deepened my confusion - questions are routinely answered with suggestions that turn out to not work in Windows7. Suggestions such as SQL Alchemy or pyODBC don't solve the problem, because it still boils down to the missing drivers. This is a volunteer effort, so even the Egenix product, mxODBC, at $69 is a little much. Are there suitable open-source codes to get at Access 2003 data in Windows7? Please point me in a productive direction, or, it it's just not possible, put me out of my misery. Cheers, Gary Smith -------------- next part -------------- An HTML attachment was scrubbed... URL: From matteo.boscolo at boscolini.eu Sun Jan 23 08:19:13 2011 From: matteo.boscolo at boscolini.eu (Matteo Boscolo) Date: Sun, 23 Jan 2011 08:19:13 +0100 Subject: [python-win32] odbc under windows 7? In-Reply-To: <898F0C65FE654023B8B6359FD41B5E0D@Aesop> References: <898F0C65FE654023B8B6359FD41B5E0D@Aesop> Message-ID: <4D3BD671.4080002@boscolini.eu> hi Gray, have you a 64 bit macine with python 32 bit installed on your pc ? if yes may be the problem it's there .. 64 bit macine have a different loaction for odbc you need to use a different odbc administrator, try to use the one under, C:\Windows\SysWOW64\odbcad32.exe Regards, Matteo Il 23/01/2011 06:33, Gary L Smith ha scritto: > > Dear Pythoners, > > I need to access data in an MS Access 2003 database using Python 2.5 > or 2.6 running in Windows7. Windows7 doesn't seem to have appropriate > drivers for ODBC. My error messages consistently contain the phrase, > "Data source name not found and no default driver specified." > > While I see that others have run into the same problem, my web > searches have only deepened my confusion -- questions are routinely > answered with suggestions that turn out to not work in Windows7. > > Suggestions such as SQL Alchemy or pyODBC don't solve the problem, > because it still boils down to the missing drivers. > > This is a volunteer effort, so even the Egenix product, mxODBC, at $69 > is a little much. > > Are there suitable open-source codes to get at Access 2003 data in > Windows7? Please point me in a productive direction, or, it it's just > not possible, put me out of my misery. > > Cheers, Gary Smith > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > Nessun virus nel messaggio. > Controllato da AVG - www.avg.com > Versione: 10.0.1191 / Database dei virus: 1435/3396 - Data di > rilascio: 22/01/2011 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Andrew.MacIntyre at acma.gov.au Mon Jan 24 00:28:31 2011 From: Andrew.MacIntyre at acma.gov.au (Andrew MacIntyre) Date: Mon, 24 Jan 2011 10:28:31 +1100 Subject: [python-win32] odbc under windows 7? [SEC=PERSONAL] In-Reply-To: <898F0C65FE654023B8B6359FD41B5E0D@Aesop> References: <898F0C65FE654023B8B6359FD41B5E0D@Aesop> Message-ID: If you run out of other options, I've successfully used comtypes on top of the ctypes module included in Python 2.5 & 2.6 to read & write data in Access 2003 databases. Regards, Andrew MacIntyre. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre Operations Branch tel: +61 2 6219 5356 Communications Infrastructure Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: andrew.macintyre at acma.gov.au http://www.acma.gov.au/ Gary L Smith wrote: Are there suitable open-source codes to get at Access 2003 data in Windows7? Please point me in a productive direction, or, it it's just not possible, put me out of my misery. NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdriscoll at co.marshall.ia.us Mon Jan 24 16:21:31 2011 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Mon, 24 Jan 2011 09:21:31 -0600 Subject: [python-win32] odbc under windows 7? In-Reply-To: <898F0C65FE654023B8B6359FD41B5E0D@Aesop> References: <898F0C65FE654023B8B6359FD41B5E0D@Aesop> Message-ID: <4D3D98FB.2060302@co.marshall.ia.us> On 1:59 PM, Gary L Smith wrote: > > Dear Pythoners, > > I need to access data in an MS Access 2003 database using Python 2.5 > or 2.6 running in Windows7. Windows7 doesn't seem to have appropriate > drivers for ODBC. My error messages consistently contain the phrase, > "Data source name not found and no default driver specified." > > While I see that others have run into the same problem, my web > searches have only deepened my confusion -- questions are routinely > answered with suggestions that turn out to not work in Windows7. > > Suggestions such as SQL Alchemy or pyODBC don't solve the problem, > because it still boils down to the missing drivers. > > This is a volunteer effort, so even the Egenix product, mxODBC, at $69 > is a little much. > > Are there suitable open-source codes to get at Access 2003 data in > Windows7? Please point me in a productive direction, or, it it's just > not possible, put me out of my misery. > > Cheers, Gary Smith > I've used SqlAlchemy to get data out of MS Access, but you have to use one of the old 0.5 versions. I only did that on Windows XP though. I also found this recipe which might help you: http://code.activestate.com/recipes/528868-extraction-and-manipulation-class-for-microsoft-ac/ -- Mike Driscoll -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Jan 24 19:46:55 2011 From: timr at probo.com (Tim Roberts) Date: Mon, 24 Jan 2011 10:46:55 -0800 Subject: [python-win32] odbc under windows 7? In-Reply-To: <898F0C65FE654023B8B6359FD41B5E0D@Aesop> References: <898F0C65FE654023B8B6359FD41B5E0D@Aesop> Message-ID: <4D3DC91F.3080208@probo.com> Gary L Smith wrote: > > > > I need to access data in an MS Access 2003 database using Python 2.5 > or 2.6 running in Windows7. Windows7 doesn?t seem to have appropriate > drivers for ODBC. My error messages consistently contain the phrase, > ?Data source name not found and no default driver specified.? > > > > While I see that others have run into the same problem, my web > searches have only deepened my confusion ? questions are routinely > answered with suggestions that turn out to not work in Windows7. > > > > Suggestions such as SQL Alchemy or pyODBC don?t solve the problem, > because it still boils down to the missing drivers. > > > > This is a volunteer effort, so even the Egenix product, mxODBC, at $69 > is a little much. > > > > Are there suitable open-source codes to get at Access 2003 data in > Windows7? Please point me in a productive direction, or, it it?s just > not possible, put me out of my misery. > Do you have Access installed on this machine? That's always been one of the downsides of Access -- you have to have the Access run-time installed to use an Access database. Note that ODBC does not really have anything to do with Access. ODBC is just a generic database layer. If you don't have the Access runtime, then even mxODBC won't get you into the data. From the message, it sounds like you are getting into ODBC just fine, but there is no ODBC Access driver installed. Have you tried ADODB and direct DAO access? Both of them can be used with Access, although again without the runtime, I think you're in trouble. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From vernondcole at gmail.com Mon Jan 24 23:14:42 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Mon, 24 Jan 2011 15:14:42 -0700 Subject: [python-win32] odbc under windows 7? In-Reply-To: <4D3DC91F.3080208@probo.com> References: <898F0C65FE654023B8B6359FD41B5E0D@Aesop> <4D3DC91F.3080208@probo.com> Message-ID: I think Tim's last suggestion is the way to go, and you should NOT need ACCESS installed. Microsoft invented ODBC. Everybody saw it was a great idea and adopted it. So Microsoft had to invent something even newer, which everybody else does not support. That's called ADO. ADO defaults to ODBC mode, so usually you can happily forget it is there, and use ODBC drivers for everything. But in native ADO mode, you don't use *drivers*, you use *providers*, (along with a connection string which is completely different from odbc.) The provider for Access-type data bases is called JET. It should be included on any NT-based Windows version. ACCESS is not required. The setup I use for testing ado's ability to read and write an ACCESS .mdb file is something like this: import adodbapi _databasename = "Test.mdb" constr = 'Provider=Microsoft.Jet.OLEDB.4.0; Data Source=%s' % _databasename _table_name= 'Products' #create the connection con = adodbapi.connect(constr) #make a cursor on the connection c = con.cursor() #run an SQL statement on the cursor sql = 'select * from %s' % _table_name c.execute(sql) #get the results db = c.fetchmany(5) #print them for rec in db: print rec print print 'repr() of next row is...' print repr(c.next()) print c.close() con.close() Running the script (on my 32-bit Vista laptop with no Microsoft Office components installed) gives: ('1', 'Widgit', '5.0', '15.1234', '2009-01-29 13:05:30') ('2', 'Thingamajig, Standard', '505.0', '0.1', '2009-01-29 15:05:19') ('3', 'Left Handed Smoke Shifter', '1.0', '1000000', '2008-04-01 12:00:00') ('4', 'Gravel (Bulk)', '100.25', '32.4567', '2009-01-29 13:05:31') ('5', 'Tube, Drinking, Plastic, For cold liquids', '500000.0', '0.0013', '2009-01-29 13:05:32') repr() of next row is... ------------------- Notes: * Test.mdb is in the /test folder of the adodbapi source distribution. * to get that fancy row object with the column names, you must be running the latest version of adodbapi from http://sourceforge.net/projects/adodbapi/. The version which ships with pywin32 at will just give a normal tuple -- until the next release of pywin32. * I could not locate a 64 bit Windows 7 box to test this on. I tried. Sorry. Please report back whether or not this works for you. -- Vernon On Mon, Jan 24, 2011 at 11:46 AM, Tim Roberts wrote: > Gary L Smith wrote: > > > > > > > > I need to access data in an MS Access 2003 database using Python 2.5 > > or 2.6 running in Windows7. Windows7 doesn?t seem to have appropriate > > drivers for ODBC. My error messages consistently contain the phrase, > > ?Data source name not found and no default driver specified.? > > > > > > > > While I see that others have run into the same problem, my web > > searches have only deepened my confusion ? questions are routinely > > answered with suggestions that turn out to not work in Windows7. > > > > > > > > Suggestions such as SQL Alchemy or pyODBC don?t solve the problem, > > because it still boils down to the missing drivers. > > > > > > > > This is a volunteer effort, so even the Egenix product, mxODBC, at $69 > > is a little much. > > > > > > > > Are there suitable open-source codes to get at Access 2003 data in > > Windows7? Please point me in a productive direction, or, it it?s just > > not possible, put me out of my misery. > > > > Do you have Access installed on this machine? That's always been one of > the downsides of Access -- you have to have the Access run-time > installed to use an Access database. > > Note that ODBC does not really have anything to do with Access. ODBC is > just a generic database layer. If you don't have the Access runtime, > then even mxODBC won't get you into the data. From the message, it > sounds like you are getting into ODBC just fine, but there is no ODBC > Access driver installed. > > Have you tried ADODB and direct DAO access? Both of them can be used > with Access, although again without the runtime, I think you're in trouble. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bburan at cns.nyu.edu Tue Jan 25 07:44:41 2011 From: bburan at cns.nyu.edu (Brad Buran) Date: Tue, 25 Jan 2011 01:44:41 -0500 Subject: [python-win32] Fixing type ID for an interface file generated by makepy Message-ID: When I generate the interface file for a COM object using makepy, it generates an incorrect signature for one of the methods: def ReadTag(self, Name=defaultNamedNotOptArg, pBuf=defaultNamedNotOptArg, nOS=defaultNamedNotOptArg, nWords=defaultNamedNotOptArg): return self._oleobj_.InvokeTypes(9, LCID, 1, (3, 0), ((8, 0), (16388, 0), (3, 0), (3, 0)),Name , pBuf, nOS, nWords) The C++ signature for the method is (based on a working C++ example provided by the manufacturer): long ReadTag(LPCTSTR Name, float * pBuf, long nOS, long nWords) { long result; static BYTE parms[] = VTS_BSTR VTS_PR4 VTS_I4 VTS_I4 ; InvokeHelper(0x9, DISPATCH_METHOD, VT_I4, (void*)&result, parms, Name, pBuf, nOS, nWords); return result; } My understanding is that 16388 corresponds to VT_R4 (based on an old email thread on this list). However, it should be a type code that corresponds to VTS_PR4. I have hunted all over the internet (Google, Bing, etc) and cannot find the correct number that I need to plug in for VTS_PR4 to fix the signature in the interface file. The closest I can find is this website, http://msdn.microsoft.com/en-us/library/cc237865%28PROT.13%29.aspx. However, it does not list VTS_PR4 (not to mention that 16388 is not in the list either). I would really appreciate any guidance in 1) figuring out the best way to fix the signature or 2) finding a more comprehensive list of the actual constant the type codes corresponds to. Brad From maubriga at gmail.com Tue Jan 25 10:30:04 2011 From: maubriga at gmail.com (Mauro) Date: Tue, 25 Jan 2011 09:30:04 +0000 Subject: [python-win32] Problem with win32com and scikits timeseries Message-ID: Hello, I get the following error when importing Date from scikits.timeseries. The error is there only when I interface python with Excel using COM. It is enough to import anything from scikits.timeseries to get the error. Any help? I am using Python2.7 and scikits.timeseries-0.91.3 in _Invoke_ with 1004 1033 3 (, 20.0, 0.0027397260273972603, 34.0) Traceback (most recent call last): File "C:\Appl\Python27\lib\site- packages\win32com\server\ dispatcher.py", line 47, in _Invoke_ return self.policy._Invoke_(dispid, lcid, wFlags, args) File "C:\Appl\Python27\lib\site-packages\win32com\server\policy.py", line 277, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "C:\Appl\Python27\lib\site-packages\win32com\server\policy.py", line 282, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None) File "C:\Appl\Python27\lib\site-packages\win32com\server\policy.py", line 585, in _invokeex_ return func(*args) File "C:\Repositories\ComInterface.py", line 109, in addTree newmatrix, header = convertObjectToList(forwardVolatilityArray) File "C:\Repositories\ComInterface.py", line 40, in convertObjectToList newrow.append(fromTimeToDateTime(int(cell))) File "C:\Repositories\ComInterface.py", line 13, in fromTimeToDateTime from scikits.timeseries import Date File "C:\Appl\Python27\lib\site-packages\scikits.timeseries-0.91.3-py2.7-win32.egg\scikits\timeseries\__init__.py", line 13, in import const File "C:\Appl\Python27\lib\site-packages\scikits.timeseries-0.91.3-py2.7-win32.egg\scikits\timeseries\const.py", line 79, in from cseries import freq_constants ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed. pythoncom error: Python error invoking COM method. Traceback (most recent call last): File "C:\Appl\Python27\lib\site-packages\win32com\server\dispatcher.py", line 163, in _Invoke_ return DispatcherBase._Invoke_(self, dispid, lcid, wFlags, args) File "C:\Appl\Python27\lib\site-packages\win32com\server\dispatcher.py", line 49, in _Invoke_ return self._HandleException_() File "C:\Appl\Python27\lib\site-packages\win32com\server\dispatcher.py", line 47, in _Invoke_ return self.policy._Invoke_(dispid, lcid, wFlags, args) File "C:\Appl\Python27\lib\site-packages\win32com\server\policy.py", line 277, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "C:\Appl\Python27\lib\site-packages\win32com\server\policy.py", line 282, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None) File "C:\Appl\Python27\lib\site-packages\win32com\server\policy.py", line 585, in _invokeex_ return func(*args) File "C:\Repositories\ComInterface.py", line 109, in addTree newmatrix, header = convertObjectToList(forwardVolatilityArray) File "C:\Repositories\ComInterface.py", line 40, in convertObjectToList newrow.append(fromTimeToDateTime(int(cell))) File "C:\Repositories\ComInterface.py", line 13, in fromTimeToDateTime from scikits.timeseries import Date File "C:\Appl\Python27\lib\site-packages\scikits.timeseries-0.91.3-py2.7-win32.egg\scikits\timeseries\__init__.py", line 13, in import const File "C:\Appl\Python27\lib\site-packages\scikits.timeseries-0.91.3-py2.7-win32.egg\scikits\timeseries\const.py", line 79, in from cseries import freq_constants ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed. in ._QueryInterface_ with unsupported IID IProvideClassInfo ({B196B283-BAB4-101A-B69C-00AA00341D07}) in ._QueryInterface_ with unsupported IID {CACC1E85-622B-11D2-AA78-00C04F9901D2} ({CACC1E85-622B-11D2-AA78-00C04F9901D2}) in _GetTypeInfo_ with index=0, lcid=1033 in _GetTypeInfo_ with index=0, lcid=0 -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Tue Jan 25 19:06:00 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Tue, 25 Jan 2011 11:06:00 -0700 Subject: [python-win32] odbc under windows 7? In-Reply-To: References: <898F0C65FE654023B8B6359FD41B5E0D@Aesop> <4D3DC91F.3080208@probo.com> Message-ID: Gary: I was able to track down a Windows 7 - 64 bit computer this morning. Installed Python 3.1 (32 bit) Installed pywin32-214 for py31 (32 bit) Installed adodbapi 2.4 (to get the test.mdb database) I was able to read the data correctly. No Microsoft office components were installed. (I also found an error in my db_read.py sample program when run from Python 3, so this was a good test.) -- Vernon -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Jan 25 19:37:41 2011 From: timr at probo.com (Tim Roberts) Date: Tue, 25 Jan 2011 10:37:41 -0800 Subject: [python-win32] Fixing type ID for an interface file generated by makepy In-Reply-To: References: Message-ID: <4D3F1875.8040403@probo.com> Brad Buran wrote: > When I generate the interface file for a COM object using makepy, it > generates an incorrect signature for one of the methods: > > def ReadTag(self, Name=defaultNamedNotOptArg, > pBuf=defaultNamedNotOptArg, nOS=defaultNamedNotOptArg, > nWords=defaultNamedNotOptArg): > return self._oleobj_.InvokeTypes(9, LCID, 1, (3, 0), ((8, 0), > (16388, 0), (3, 0), (3, 0)),Name > , pBuf, nOS, nWords) > > The C++ signature for the method is (based on a working C++ example > provided by the manufacturer): > > long ReadTag(LPCTSTR Name, float * pBuf, long nOS, long nWords) > { > long result; > static BYTE parms[] = VTS_BSTR VTS_PR4 VTS_I4 VTS_I4 ; > InvokeHelper(0x9, DISPATCH_METHOD, VT_I4, (void*)&result, parms, > Name, pBuf, nOS, nWords); > return result; > } > > My understanding is that 16388 corresponds to VT_R4 (based on an old > email thread on this list). No. 16388 is 4+16384, which is VT_R4+VT_BYREF. So, this is a single-precision float passed by reference -- meaning by pointer. So, the Python declaration says VT_I4 (return type), VT_BSTR, VT_R4+VT_BYREF, VT_I4, and VT_I4. That's mostly correct. What problems are you seeing? There is one potential issue here, in that the C++ string is declared as LPCTSTR. That's not a valid COM type. All COM strings have to be Unicode (as VT_BSTR will be), but if the server is compiled ANSI, then LPCTSTR will be expecting an ANSI string. > However, it should be a type code that corresponds to VTS_PR4. That must be something the manufacturer invented, because VTS_PR4 does not occur anywhere in the Windows SDK. > I would really appreciate any guidance in 1) figuring out the best way > to fix the signature or 2) finding a more comprehensive list of the > actual constant the type codes corresponds to. Do you have the SDK? The master list is in the header file WTypes.h. The VT codes are a bit field -- the low 12-bits are the type code, and the bits above that are flags, like VT_BYREF. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Tue Jan 25 19:58:04 2011 From: timr at probo.com (Tim Roberts) Date: Tue, 25 Jan 2011 10:58:04 -0800 Subject: [python-win32] Fixing type ID for an interface file generated by makepy In-Reply-To: <4D3F1875.8040403@probo.com> References: <4D3F1875.8040403@probo.com> Message-ID: <4D3F1D3C.8030600@probo.com> Tim Roberts wrote: > Brad Buran wrote: >> When I generate the interface file for a COM object using makepy, it >> generates an incorrect signature for one of the methods: >> >> def ReadTag(self, Name=defaultNamedNotOptArg, >> pBuf=defaultNamedNotOptArg, nOS=defaultNamedNotOptArg, >> nWords=defaultNamedNotOptArg): >> return self._oleobj_.InvokeTypes(9, LCID, 1, (3, 0), ((8, 0), >> (16388, 0), (3, 0), (3, 0)),Name >> , pBuf, nOS, nWords) >> >> The C++ signature for the method is (based on a working C++ example >> provided by the manufacturer): >> >> long ReadTag(LPCTSTR Name, float * pBuf, long nOS, long nWords) >> { >> long result; >> static BYTE parms[] = VTS_BSTR VTS_PR4 VTS_I4 VTS_I4 ; >> InvokeHelper(0x9, DISPATCH_METHOD, VT_I4, (void*)&result, parms, >> Name, pBuf, nOS, nWords); >> return result; >> } >> >> My understanding is that 16388 corresponds to VT_R4 (based on an old >> email thread on this list). > No. 16388 is 4+16384, which is VT_R4+VT_BYREF. So, this is a > single-precision float passed by reference -- meaning by pointer. > > So, the Python declaration says VT_I4 (return type), VT_BSTR, > VT_R4+VT_BYREF, VT_I4, and VT_I4. That's mostly correct. This just occurred to me -- I'll bet that is supposed to be a pointer to an array of floats, isn't it? Then yes, you have a problem. That's not the proper way to pass an array in COM. In the dispatch mechanism, you're supposed to pass it as a safe array structure that contains sizing information. By declaring a float *, there's no way for the marshalling mechanism to know how large the array is. I think you are going to have to use other magic to access this function. I'm not sure there is any way to coerce makepy into generating an array of floats to satisfy a float *. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From bburan at cns.nyu.edu Wed Jan 26 04:03:12 2011 From: bburan at cns.nyu.edu (Brad Buran) Date: Tue, 25 Jan 2011 22:03:12 -0500 Subject: [python-win32] Fixing type ID for an interface file generated by makepy In-Reply-To: <4D3F1D3C.8030600@probo.com> References: <4D3F1875.8040403@probo.com> <4D3F1D3C.8030600@probo.com> Message-ID: > This just occurred to me -- I'll bet that is supposed to be a pointer to > an array of floats, isn't it? ?Then yes, you have a problem. ?That's not > the proper way to pass an array in COM. ?In the dispatch mechanism, > you're supposed to pass it as a safe array structure that contains > sizing information. ?By declaring a float *, there's no way for the > marshalling mechanism to know how large the array is. Yes! That's what it is supposed to be (no wonder I wasn't able to find it on Google, I assumed that VTS_PR4 was a standardized constant). The manufacturer has acknowledged that they set it up wrong, but it's unlikely they'll fix it. > I think you are going to have to use other magic to access this > function. ?I'm not sure there is any way to coerce makepy into > generating an array of floats to satisfy a float *. Hmm. As in abandoning win32com.Client and writing a Cython wrapper? The function in question (ReadTag) takes both a pointer to an array of floats plus a parameter, nWords, that indicates the size of the array. Perhaps I could do something like this: from array import array a = array('f', [0, 0, 0, 0, 0]) iface = win32com.Client('RPco.X') # last parameter to method is array size iface.ReadTag('data', a, 0, len(a)) len(a) would provide the information the COM object needs about the array size. However, when I attempt this code, I get the following error: *only length-1 arrays can be converted to Python scalars* I'm a bit stumped at this point. Is there an easy way to marshal the array into the right format needed? Brad From graham.bloice at trihedral.com Wed Jan 26 11:47:12 2011 From: graham.bloice at trihedral.com (Graham Bloice) Date: Wed, 26 Jan 2011 10:47:12 +0000 Subject: [python-win32] odbc under windows 7? In-Reply-To: <4D3DC91F.3080208@probo.com> References: <898F0C65FE654023B8B6359FD41B5E0D@Aesop> <4D3DC91F.3080208@probo.com> Message-ID: <4D3FFBB0.8010003@trihedral.com> On 24/01/2011 18:46, Tim Roberts wrote: > Gary L Smith wrote: >> >> >> I need to access data in an MS Access 2003 database using Python 2.5 >> or 2.6 running in Windows7. Windows7 doesn?t seem to have appropriate >> drivers for ODBC. My error messages consistently contain the phrase, >> ?Data source name not found and no default driver specified.? >> >> >> >> While I see that others have run into the same problem, my web >> searches have only deepened my confusion ? questions are routinely >> answered with suggestions that turn out to not work in Windows7. >> >> >> >> Suggestions such as SQL Alchemy or pyODBC don?t solve the problem, >> because it still boils down to the missing drivers. >> >> >> >> This is a volunteer effort, so even the Egenix product, mxODBC, at $69 >> is a little much. >> >> >> >> Are there suitable open-source codes to get at Access 2003 data in >> Windows7? Please point me in a productive direction, or, it it?s just >> not possible, put me out of my misery. >> > Do you have Access installed on this machine? That's always been one of > the downsides of Access -- you have to have the Access run-time > installed to use an Access database. > > Note that ODBC does not really have anything to do with Access. ODBC is > just a generic database layer. If you don't have the Access runtime, > then even mxODBC won't get you into the data. From the message, it > sounds like you are getting into ODBC just fine, but there is no ODBC > Access driver installed. > > Have you tried ADODB and direct DAO access? Both of them can be used > with Access, although again without the runtime, I think you're in trouble. Originally set to Tim instead of the list, sorry for that. I'm not so sure about this. The Jet drivers (32 bit only) which can be used from ODBC have been supplied with every MS OS (even 64 bit ones). I've used this driver and ODBC to access .mdb files without Office or Access ever having been near machines. To see the drivers on your machine run up odbcad32.exe and check the drivers tab. To see 32 bit drivers on a 64 bit machine run Windows\SysWOW64\odbcad32.exe There is no 64 bit Jet driver, but from Office 2007 on, MS produced the ACE drivers (which are also available as a separate redistributable) which do appear in a 64 bit guise. Unfortunately I haven't been impressed with the drivers stability when multithreading. -- Regards, Graham Bloice From graham.bloice at trihedral.com Wed Jan 26 11:44:56 2011 From: graham.bloice at trihedral.com (Graham Bloice) Date: Wed, 26 Jan 2011 10:44:56 +0000 Subject: [python-win32] Fixing type ID for an interface file generated by makepy In-Reply-To: References: Message-ID: <4D3FFB28.9050009@trihedral.com> On 25/01/2011 06:44, Brad Buran wrote: > When I generate the interface file for a COM object using makepy, it > generates an incorrect signature for one of the methods: > > def ReadTag(self, Name=defaultNamedNotOptArg, > pBuf=defaultNamedNotOptArg, nOS=defaultNamedNotOptArg, > nWords=defaultNamedNotOptArg): > return self._oleobj_.InvokeTypes(9, LCID, 1, (3, 0), ((8, 0), > (16388, 0), (3, 0), (3, 0)),Name > , pBuf, nOS, nWords) > > The C++ signature for the method is (based on a working C++ example > provided by the manufacturer): > > long ReadTag(LPCTSTR Name, float * pBuf, long nOS, long nWords) > { > long result; > static BYTE parms[] = VTS_BSTR VTS_PR4 VTS_I4 VTS_I4 ; > InvokeHelper(0x9, DISPATCH_METHOD, VT_I4, (void*)&result, parms, > Name, pBuf, nOS, nWords); > return result; > } > > My understanding is that 16388 corresponds to VT_R4 (based on an old > email thread on this list). However, it should be a type code that > corresponds to VTS_PR4. I have hunted all over the internet (Google, > Bing, etc) and cannot find the correct number that I need to plug in > for VTS_PR4 to fix the signature in the interface file. The closest I > can find is this website, > http://msdn.microsoft.com/en-us/library/cc237865%28PROT.13%29.aspx. > However, it does not list VTS_PR4 (not to mention that 16388 is not in > the list either). > > I would really appreciate any guidance in 1) figuring out the best way > to fix the signature or 2) finding a more comprehensive list of the > actual constant the type codes corresponds to. > > Originally sent to the OP instead of the list. sorry for that. The numbers in the type code are the bit flags from the variant type enumeration (http://msdn.microsoft.com/en-us/library/cc237865%28PROT.13%29.aspx). 16388 equates to 0x4004 which is VT_BYREF | VT_R4 which is correct for the second parm of the function "float * pBuf). IMHO the C++ example is misleading with the notation VT_PR4 which I've never come across before. If you have access to it (usually via a Visual Studio install) the OLE-COM object viewer tool is very useful for spelunking into type libraries. -- Regards, Graham Bloice -------------- next part -------------- An HTML attachment was scrubbed... URL: From cricogik at gmail.com Wed Jan 26 15:09:07 2011 From: cricogik at gmail.com (user) Date: Wed, 26 Jan 2011 15:09:07 +0100 Subject: [python-win32] win32com + Excel + Django + Apache = problem Message-ID: Hello, I have some problems while opening Excel (via win32com) document in a web application running under Apache(mod_wsgi)/Windows 2008 Server (there is no problem when the application is running on django developer server - one thread). My code: def my_view(request): import pythoncom from win32com.client import DispatchEx pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED) xl = win32com.client.dynamic.Dispatch('Excel.Application') xl.DisplayAlerts = False xl.Visible = 0 doc = xl.Workbooks.Open("C:\\path\to\\file.xlsx") doc.Saved = True ... doc.Close(SaveChanges=0) xl.Quit() pythoncom.CoUninitialize() Error message: (-2147352567, 'Exception occurred.', (0, u'Microsoft Office Excel', u"Microsoft Office Excel cannot access the file 'C:\\path\to\ \file.xlsx'. There are several possible reasons: The file name or path does not exist. The file is being used by another program. The workbook you are trying to save has the same name as a currently open workbook.", u'C:\\Program Files (x86)\\Microsoft Office\\Office12\ \1033\\XLMAIN11.CHM', 0, -2146827284), None) I know that problem is localized somewhere in threading, but where? I'm using pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED). Maybe changing the server will solve the problem? Libs: Django 1.2, Apache 2.2 (mod_wsgi), win32com (latest) I hope somebody can help me. Thank You, regards. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rsyring at inteli-com.com Wed Jan 26 16:31:37 2011 From: rsyring at inteli-com.com (Randy Syring) Date: Wed, 26 Jan 2011 10:31:37 -0500 Subject: [python-win32] win32com + Excel + Django + Apache = problem In-Reply-To: References: Message-ID: <4D403E59.2040909@inteli-com.com> I don't know much of anything about COM or multi-threading in Apache, but the error seems to indicate a permissions problem. What system user is Apache running under? Does that user have access to that path? Another option is to use "run as" to open a command prompt as the same system user that apache runs under. Once you get to that point, then run the Django developer server and see if what you are trying to do works. -------------------------------------- Randy Syring Intelicom Direct: 502-276-0459 Office: 502-212-9913 For the wages of sin is death, but the free gift of God is eternal life in Christ Jesus our Lord (Rom 6:23) On 01/26/2011 09:09 AM, user wrote: > > Hello, > > I have some problems while opening Excel (via win32com) document in a > web application > running under Apache(mod_wsgi)/Windows 2008 Server (there is no > problem when the application is running on django developer server - > one thread). > > My code: > > def my_view(request): > import pythoncom > from win32com.client import DispatchEx > > pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED) > xl = win32com.client.dynamic.Dispatch('Excel.Application') > xl.DisplayAlerts = False > xl.Visible = 0 > doc = xl.Workbooks.Open("C:\\path\to\\file.xlsx") > doc.Saved = True > ... > doc.Close(SaveChanges=0) > xl.Quit() > pythoncom.CoUninitialize() > > Error message: > > (-2147352567, 'Exception occurred.', (0, u'Microsoft Office Excel', > u"Microsoft Office Excel cannot access the file 'C:\\path\to\ > \file.xlsx'. There are several possible reasons: The file name or path > does not exist. The file is being used by another program. The > workbook you are trying to save has the same name as a currently open > workbook.", u'C:\\Program Files (x86)\\Microsoft Office\\Office12\ > \1033\\XLMAIN11.CHM', 0, -2146827284), None) > > I know that problem is localized somewhere in threading, but where? > I'm using pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED). > Maybe changing the server will solve the problem? > > Libs: Django 1.2, Apache 2.2 (mod_wsgi), win32com (latest) > > I hope somebody can help me. > > Thank You, > regards. > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From cricogik at gmail.com Wed Jan 26 16:34:21 2011 From: cricogik at gmail.com (user) Date: Wed, 26 Jan 2011 16:34:21 +0100 Subject: [python-win32] win32com + Excel + Django + Apache = problem In-Reply-To: References: Message-ID: This line it's not a "copy past" from my source. In the code every path is ok, I checked many times. 2011/1/26 Mike Mazurek > C:\\path\to\\file.xlsx" <-- you need another back slash before the "to" > > On Wed, Jan 26, 2011 at 9:09 AM, user wrote: > >> >> Hello, >> >> I have some problems while opening Excel (via win32com) document in a web >> application >> running under Apache(mod_wsgi)/Windows 2008 Server (there is no >> problem when the application is running on django developer server - >> one thread). >> >> My code: >> >> def my_view(request): >> import pythoncom >> from win32com.client import DispatchEx >> >> pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED) >> xl = win32com.client.dynamic.Dispatch('Excel.Application') >> xl.DisplayAlerts = False >> xl.Visible = 0 >> doc = xl.Workbooks.Open("C:\\path\to\\file.xlsx") >> doc.Saved = True >> ... >> doc.Close(SaveChanges=0) >> xl.Quit() >> pythoncom.CoUninitialize() >> >> Error message: >> >> (-2147352567, 'Exception occurred.', (0, u'Microsoft Office Excel', >> u"Microsoft Office Excel cannot access the file 'C:\\path\to\ >> \file.xlsx'. There are several possible reasons: The file name or path >> does not exist. The file is being used by another program. The >> workbook you are trying to save has the same name as a currently open >> workbook.", u'C:\\Program Files (x86)\\Microsoft Office\\Office12\ >> \1033\\XLMAIN11.CHM', 0, -2146827284), None) >> >> I know that problem is localized somewhere in threading, but where? >> I'm using pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED). >> Maybe changing the server will solve the problem? >> >> Libs: Django 1.2, Apache 2.2 (mod_wsgi), win32com (latest) >> >> I hope somebody can help me. >> >> Thank You, >> regards. >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bburan at cns.nyu.edu Wed Jan 26 18:47:05 2011 From: bburan at cns.nyu.edu (Brad Buran) Date: Wed, 26 Jan 2011 12:47:05 -0500 Subject: [python-win32] Fixing type ID for an interface file generated by makepy In-Reply-To: <4D3FFB28.9050009@trihedral.com> References: <4D3FFB28.9050009@trihedral.com> Message-ID: Ok! I'll install Visual Studio and see if I can make any headway. Thanks for your help! Brad On Wed, Jan 26, 2011 at 5:44 AM, Graham Bloice wrote: > On 25/01/2011 06:44, Brad Buran wrote: > > When I generate the interface file for a COM object using makepy, it > generates an incorrect signature for one of the methods: > > def ReadTag(self, Name=defaultNamedNotOptArg, > pBuf=defaultNamedNotOptArg, nOS=defaultNamedNotOptArg, > nWords=defaultNamedNotOptArg): > return self._oleobj_.InvokeTypes(9, LCID, 1, (3, 0), ((8, 0), > (16388, 0), (3, 0), (3, 0)),Name > , pBuf, nOS, nWords) > > The C++ signature for the method is (based on a working C++ example > provided by the manufacturer): > > long ReadTag(LPCTSTR Name, float * pBuf, long nOS, long nWords) > { > long result; > static BYTE parms[] = VTS_BSTR VTS_PR4 VTS_I4 VTS_I4 ; > InvokeHelper(0x9, DISPATCH_METHOD, VT_I4, (void*)&result, parms, > Name, pBuf, nOS, nWords); > return result; > } > > My understanding is that 16388 corresponds to VT_R4 (based on an old > email thread on this list). However, it should be a type code that > corresponds to VTS_PR4. I have hunted all over the internet (Google, > Bing, etc) and cannot find the correct number that I need to plug in > for VTS_PR4 to fix the signature in the interface file. The closest I > can find is this website, > http://msdn.microsoft.com/en-us/library/cc237865%28PROT.13%29.aspx. > However, it does not list VTS_PR4 (not to mention that 16388 is not in > the list either). > > I would really appreciate any guidance in 1) figuring out the best way > to fix the signature or 2) finding a more comprehensive list of the > actual constant the type codes corresponds to. > > > Originally sent to the OP instead of the list.? sorry for that. > > The numbers in the type code are the bit flags from the variant type > enumeration > (http://msdn.microsoft.com/en-us/library/cc237865%28PROT.13%29.aspx). > > 16388 equates to 0x4004 which is VT_BYREF | VT_R4 which is correct for the > second parm of the function "float * pBuf). > > IMHO the C++ example is misleading with the notation VT_PR4 which I've never > come across before.? If you have access to it (usually via a Visual Studio > install) the OLE-COM object viewer tool is very useful for spelunking into > type libraries. > > -- > Regards, > > Graham Bloice > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From cricogik at gmail.com Wed Jan 26 19:51:35 2011 From: cricogik at gmail.com (cricogik) Date: Wed, 26 Jan 2011 19:51:35 +0100 Subject: [python-win32] win32com + Excel + Django + Apache = problem Message-ID: > Does that user have access to that path? Yes, apache has full access. It's problem in win32com, because when I add before calling Workbooks.Open: open("C:\\path\\to\\file.xlsx") application won't crash, so apache can open/read/write this file. Also when I running application under django developer server everything works. I tested code on Apache 2.2 (mod_wsgi), py2.6, Windows 2008 Server (64 bit) and Windows 7 (32 bit) .. the same result ;/ >I don't know much of anything about COM or multi-threading in Apache, >but the error seems to indicate a permissions problem. What system user >is Apache running under? Does that user have access to that path? >Another option is to use "run as" to open a command prompt as the same >system user that apache runs under. Once you get to that point, then >run the Django developer server and see if what you are trying to do works. >-------------------------------------- >Randy Syring >Intelicom >Direct: 502-276-0459 >Office: 502-212-9913 > >For the wages of sin is death, but the >free gift of God is eternal life in >Christ Jesus our Lord (Rom 6:23) >On 01/26/2011 09:09 AM, user wrote: >> >> Hello, >> >> I have some problems while opening Excel (via win32com) document in a >> web application >> running under Apache(mod_wsgi)/Windows 2008 Server (there is no >> problem when the application is running on django developer server - >> one thread). >> >> My code: >> >> def my_view(request): >> import pythoncom >> from win32com.client import DispatchEx >> >> pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED) >> xl = win32com.client.dynamic.Dispatch('Excel.Application') >> xl.DisplayAlerts = False >> xl.Visible = 0 >> doc = xl.Workbooks.Open("C:\\path\to\\file.xlsx") >> doc.Saved = True >> ... >> doc.Close(SaveChanges=0) >> xl.Quit() >> pythoncom.CoUninitialize() >> >> Error message: >> >> (-2147352567, 'Exception occurred.', (0, u'Microsoft Office Excel', >> u"Microsoft Office Excel cannot access the file 'C:\\path\to\ >> \file.xlsx'. There are several possible reasons: The file name or path >> does not exist. The file is being used by another program. The >> workbook you are trying to save has the same name as a currently open >> workbook.", u'C:\\Program Files (x86)\\Microsoft Office\\Office12\ >> \1033\\XLMAIN11.CHM', 0, -2146827284), None) >> >> I know that problem is localized somewhere in threading, but where? >> I'm using pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED). >> Maybe changing the server will solve the problem? >> >> Libs: Django 1.2, Apache 2.2 (mod_wsgi), win32com (latest) >> >> I hope somebody can help me. >> >> Thank You, >> regards. >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Thu Jan 27 01:08:47 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 26 Jan 2011 14:08:47 -1000 Subject: [python-win32] win32com + Excel + Django + Apache = problem In-Reply-To: References: Message-ID: <4D40B78F.5050004@gmail.com> On 26/01/2011 8:51 AM, cricogik wrote: > > Does that user have access to that path? > Yes, apache has full access. It's problem in win32com Are you sure about that? > because when I > add before calling Workbooks.Open: > > open("C:\\path\\to\\file.xlsx") > > application won't crash, so apache can open/read/write this file. Also > when I running application under django developer server everything works. ... > >> doc = xl.Workbooks.Open("C:\\path\to\\file.xlsx") You have a tab character (\t) in that path. Mark From skippy.hammond at gmail.com Thu Jan 27 01:12:11 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 26 Jan 2011 14:12:11 -1000 Subject: [python-win32] win32com + Excel + Django + Apache = problem In-Reply-To: References: Message-ID: <4D40B85B.8090404@gmail.com> Oops - I didn't see this reply when I posted mine. On 26/01/2011 5:34 AM, user wrote: > This line it's not a "copy past" from my source. In the code every path > is ok, I checked many times. I suggest you modify your code to the smallest example which demonstrates the problem, then copy-paste it - there could be other errors you made in transcribing it. Mark From skippy.hammond at gmail.com Thu Jan 27 01:15:51 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 26 Jan 2011 14:15:51 -1000 Subject: [python-win32] Problem with win32com and scikits timeseries In-Reply-To: References: Message-ID: <4D40B937.8060300@gmail.com> On 24/01/2011 11:30 PM, Mauro wrote: > Hello, > > I get the following error when importing Date from scikits.timeseries. > The error is there only when I interface python with Excel using COM. It > is enough to import anything from scikits.timeseries to get the error. > > Any help? > I am using Python2.7 and scikits.timeseries-0.91.3 ... > "C:\Appl\Python27\lib\site-packages\scikits.timeseries-0.91.3-py2.7-win32.egg\scikits\timeseries\const.py", > line 79, in > from cseries import freq_constants > ImportError: DLL load failed: A dynamic link library (DLL) > initialization routine failed. > pythoncom error: Python error invoking COM method. This is the root of your problem - the 'cseries' module, which appears to be part of the timeseries package, has failed to load. You probably need to talk to whoever provides that module. HTH, Mark From bburan at cns.nyu.edu Thu Jan 27 02:38:12 2011 From: bburan at cns.nyu.edu (Brad Buran) Date: Wed, 26 Jan 2011 20:38:12 -0500 Subject: [python-win32] speed of win32com versus comtypes Message-ID: I've been using win32com.client for the past year or so. Recently, I noticed that there was a bottleneck in my code, and I tracked this down to _get_good_single_object (line 478). When using comtypes instead of win32com.client, calling the ReadTagVEX method on my COM object is 4.8 times faster so the slowdown appears to be in _get_good_object_. The COM function in question, ReadTagVEX, is supposed to return an Array of VARIANT. These arrays are quite large (on the order of 100,000 or 200,000 samples) on each read. I'd much rather stick with win32com.client if possible. Are there any suggestions for speeding up this function? I already know that the array returned will be an array of float32. The signature of ReadTagVEX generated by makepy: def ReadTagVEX(self, Name=defaultNamedNotOptArg, nOS=defaultNamedNotOptArg, nWords=defaultNamedNotOptArg, SrcType=defaultNamedNotOptArg , DstType=defaultNamedNotOptArg, nChans=defaultNamedNotOptArg): return self._ApplyTypes_(25, 1, (12, 0), ((8, 0), (3, 0), (3, 0), (8, 0), (8, 0), (3, 0)), u'ReadTagVEX', None,Name , nOS, nWords, SrcType, DstType, nChans ) Output of the cProfile function: 11 0.000 0.000 10.823 0.984 c:\Python26\lib\site-packages\win32com\gen_py\D323A622-1D13-11D4-8858-444553540000x0x1x0.py:192(ReadTagVEX) 11 0.025 0.002 10.823 0.984 c:\Python26\lib\site-packages\win32com\client\__init__.py:454(_ApplyTypes_) 11 0.000 0.000 10.046 0.913 c:\Python26\lib\site-packages\win32com\client\__init__.py:474(_get_good_object_) 3801275/11 4.605 0.000 10.046 0.913 c:\Python26\lib\site-packages\win32com\client\__init__.py:483(_get_good_object_) 192/16 2.009 0.010 10.046 0.628 {map} 3801088 1.765 0.000 1.765 0.000 c:\Python26\lib\site-packages\win32com\client\__init__.py:478(_get_good_single_object_) 3813844 1.677 0.000 1.677 0.000 {isinstance} 351 0.867 0.002 0.867 0.002 {method 'InvokeTypes' of 'PyIDispatch' objects} From skippy.hammond at gmail.com Thu Jan 27 03:21:53 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 26 Jan 2011 16:21:53 -1000 Subject: [python-win32] speed of win32com versus comtypes In-Reply-To: References: Message-ID: <4D40D6C1.7030504@gmail.com> On 26/01/2011 3:38 PM, Brad Buran wrote: > I've been using win32com.client for the past year or so. Recently, I > noticed that there was a bottleneck in my code, and I tracked this > down to _get_good_single_object (line 478). When using comtypes > instead of win32com.client, calling the ReadTagVEX method on my COM > object is 4.8 times faster so the slowdown appears to be in > _get_good_object_. The COM function in question, ReadTagVEX, is > supposed to return an Array of VARIANT. These arrays are quite large > (on the order of 100,000 or 200,000 samples) on each read. > > I'd much rather stick with win32com.client if possible. Are there any > suggestions for speeding up this function? I already know that the > array returned will be an array of float32. You could just call InvokeTypes directly using a copy-paste of the generated makepy code - somewhat ugly, but probably effective. (There is probably an optimization opportunity to avoid the call to _get_good_object completely when the result of the function is other than a generic "object" (ie, VT_DISPATCH) or array of such objects - but in this case, the function declares it does return a generic VT_DISPATCH, so the optimization wouldn't be able to be used in this particular case...) Mark From timjohnson at google.com Thu Jan 27 23:19:22 2011 From: timjohnson at google.com (Tim Johnson) Date: Thu, 27 Jan 2011 14:19:22 -0800 Subject: [python-win32] New project: py-ad-ldap - Automate AD tasks from any OS. Message-ID: I won't waste too much of your time pitching this, but I'm passing this on in the hopes that a certain segment of the readers on this list will find it useful, and maybe will want to contribute. I mulled over whether or not to send it to this list because technically it's platform-agnostic, but it seemed like this is the right audience, at least those of you who work in mixed-OS environments. I've created a Python module that uses python-ldap to connect to Active Directory and wrap LDAP results in utility classes to make it possible to work with Active Directory from any OS that supports python-ldap. I created it to fill a particular need at work, and I'm interested to see whether it is more generally useful. In any case, here's the link: http://code.google.com/p/py-ad-ldap/ Comments and criticisms welcome, but if it seems germane to the shaping of the project, please do it through the project site. -- Tim "They Call Me Tojo" Johnson Systems Administrator Gooooooooooooooogle -------------- next part -------------- An HTML attachment was scrubbed... URL: From g.rodola at gmail.com Thu Jan 27 23:46:34 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Thu, 27 Jan 2011 23:46:34 +0100 Subject: [python-win32] How to use win32file.TransmitFile with non blocking sockets? Message-ID: Hi all, I'm trying to take advantage of TransmitFile function in pyftpdlib: http://code.google.com/p/pyftpdlib/issues/detail?id=152 I've noticed pywin32 provides a wrapper: http://sourceforge.net/tracker/index.php?func=detail&aid=1962146&group_id=78018&atid=551956 The example shown in there, though, assumes the socket is in blocking state and the file gets sent entirely in a unique call. I need to adapt that example to make it work with non-blocking sockets. Specifically I want TransmitFile() and GetOverlappedResult() to return immediately reporting the number of bytes sent. The code below is what I managed to come up with so far but it obviously doesn't work. It either fails with "error: (996, 'GetOverlappedResult', 'Overlapped I/O event is not in a signaled state.')" or the file delivered is corrupted. I don't have a clue on how should I use the overllaped structure, neither it's clear to me what should I do to detect when EOF is reached. Any hint? def sendfile(sock, file, offset, nbytes): """Windows TranmistFile() wrapper, adapted to look like UNIX sendfile(). """ ol = pywintypes.OVERLAPPED() ol.Offset = offset ol.hEvent = win32event.CreateEvent(None, 0, 0, None) filehandle = win32file._get_osfhandle(file) win32file.TransmitFile(sock, filehandle, nbytes, offset, ol, 0) try: sent = win32file.GetOverlappedResult(filehandle, ol, 0) except pywintypes.error, err: if err.args[0] == 38: # EOF return 0 raise else: return sent Thanks in advance, --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ From g.rodola at gmail.com Thu Jan 27 23:11:57 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Thu, 27 Jan 2011 23:11:57 +0100 Subject: [python-win32] How to use win32file.TransmitFile with non blocking sockets? Message-ID: Hi all, I'm trying to take advantage of TransmitFile function in pyftpdlib: http://code.google.com/p/pyftpdlib/issues/detail?id=152 I've noticed pywin32 provides a wrapper: http://sourceforge.net/tracker/index.php?func=detail&aid=1962146&group_id=78018&atid=551956 The example shown in there, though, assumes the socket is in blocking state and the file gets sent entirely in a unique call. I need to adapt that example to make it work with non-blocking sockets. Specifically I want TransmitFile() and GetOverlappedResult() to return immediately reporting the number of bytes sent. The code below is what I managed to come up with so far but it obviously doesn't work. It either fails with "error: (996, 'GetOverlappedResult', 'Overlapped I/O event is not in a signaled state.')" or the file delivered is corrupted. I don't have a clue on how should I use the overllaped structure, neither it's clear to me what should I do to detect when EOF is reached. Any hint? def sendfile(sock, file, offset, nbytes): """Windows TranmistFile() wrapper, adapted to look like UNIX sendfile(). """ ol = pywintypes.OVERLAPPED() ol.Offset = offset ol.hEvent = win32event.CreateEvent(None, 0, 0, None) filehandle = win32file._get_osfhandle(file) win32file.TransmitFile(sock, filehandle, nbytes, offset, ol, 0) try: sent = win32file.GetOverlappedResult(filehandle, ol, 0) except pywintypes.error, err: if err.args[0] == 38: # EOF return 0 raise else: return sent Thanks in advance, --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ From rupole at hotmail.com Fri Jan 28 14:01:52 2011 From: rupole at hotmail.com (Roger Upole) Date: Fri, 28 Jan 2011 08:01:52 -0500 Subject: [python-win32] How to use win32file.TransmitFile with non blockingsockets? References: Message-ID: Giampaolo Rodol? wrote: > Hi all, > I'm trying to take advantage of TransmitFile function in pyftpdlib: > http://code.google.com/p/pyftpdlib/issues/detail?id=152 > > I've noticed pywin32 provides a wrapper: > http://sourceforge.net/tracker/index.php?func=detail&aid=1962146&group_id=78018&atid=551956 > The example shown in there, though, assumes the socket is in blocking > state and the file gets sent entirely in a unique call. > I need to adapt that example to make it work with non-blocking sockets. > Specifically I want TransmitFile() and GetOverlappedResult() to return > immediately reporting the number of bytes sent. > The code below is what I managed to come up with so far but it > obviously doesn't work. > It either fails with "error: (996, 'GetOverlappedResult', 'Overlapped > I/O event is not in a signaled state.')" or the file delivered is > corrupted. > I don't have a clue on how should I use the overllaped structure, > neither it's clear to me what should I do to detect when EOF is > reached. > > Any hint? > > def sendfile(sock, file, offset, nbytes): > """Windows TranmistFile() wrapper, adapted to look like > UNIX sendfile(). > """ > ol = pywintypes.OVERLAPPED() > ol.Offset = offset > ol.hEvent = win32event.CreateEvent(None, 0, 0, None) > filehandle = win32file._get_osfhandle(file) > win32file.TransmitFile(sock, filehandle, nbytes, offset, ol, 0) > try: > sent = win32file.GetOverlappedResult(filehandle, ol, 0) > except pywintypes.error, err: > if err.args[0] == 38: # EOF > return 0 > raise > else: > return sent > > > Thanks in advance, > > --- Giampaolo The third arg to GetOverlappedResult should be True to wait for an async operation to complete. Roger From g.rodola at gmail.com Fri Jan 28 14:38:19 2011 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Fri, 28 Jan 2011 14:38:19 +0100 Subject: [python-win32] How to use win32file.TransmitFile with non blockingsockets? In-Reply-To: References: Message-ID: Point of asynchronous programming is that all function calls should return immediately. "wait for an async operation to complete" sounds kinda wrong to me. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/1/28 Roger Upole : > Giampaolo Rodol? wrote: >> Hi all, >> I'm trying to take advantage of TransmitFile function in pyftpdlib: >> http://code.google.com/p/pyftpdlib/issues/detail?id=152 >> >> I've noticed pywin32 provides a wrapper: >> http://sourceforge.net/tracker/index.php?func=detail&aid=1962146&group_id=78018&atid=551956 >> The example shown in there, though, assumes the socket is in blocking >> state and the file gets sent entirely in a unique call. >> I need to adapt that example to make it work with non-blocking sockets. >> Specifically I want TransmitFile() and GetOverlappedResult() to return >> immediately reporting the number of bytes sent. >> The code below is what I managed to come up with so far but it >> obviously doesn't work. >> It either fails with "error: (996, 'GetOverlappedResult', 'Overlapped >> I/O event is not in a signaled state.')" or the file delivered is >> corrupted. >> I don't have a clue on how should I use the overllaped structure, >> neither it's clear to me what should I do to detect when EOF is >> reached. >> >> Any hint? >> >> ? ? ? def sendfile(sock, file, offset, nbytes): >> ? ? ? ? ? """Windows TranmistFile() wrapper, adapted to look like >> ? ? ? ? ? UNIX sendfile(). >> ? ? ? ? ? """ >> ? ? ? ? ? ol = pywintypes.OVERLAPPED() >> ? ? ? ? ? ol.Offset = offset >> ? ? ? ? ? ol.hEvent = win32event.CreateEvent(None, 0, 0, None) >> ? ? ? ? ? filehandle = win32file._get_osfhandle(file) >> ? ? ? ? ? win32file.TransmitFile(sock, filehandle, nbytes, offset, ol, 0) >> ? ? ? ? ? try: >> ? ? ? ? ? ? ? sent = win32file.GetOverlappedResult(filehandle, ol, 0) >> ? ? ? ? ? except pywintypes.error, err: >> ? ? ? ? ? ? ? if err.args[0] == 38: ?# EOF >> ? ? ? ? ? ? ? ? ? return 0 >> ? ? ? ? ? ? ? raise >> ? ? ? ? ? else: >> ? ? ? ? ? ? ? return sent >> >> >> Thanks in advance, >> >> --- Giampaolo > > The third arg to GetOverlappedResult should be True to wait for an > async operation to complete. > > ? ? ? ? ?Roger > > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From rupole at hotmail.com Fri Jan 28 15:38:27 2011 From: rupole at hotmail.com (Roger Upole) Date: Fri, 28 Jan 2011 09:38:27 -0500 Subject: [python-win32] How to use win32file.TransmitFile with nonblockingsockets? References: Message-ID: If you want the final result it returns, you kinda have to wait for it to finish. Roger "Giampaolo Rodol?" wrote in message news:AANLkTikeLdqHyPzJitdOxs2mcVws4W8QxhMya9YCzCNv at mail.gmail.com... Point of asynchronous programming is that all function calls should return immediately. "wait for an async operation to complete" sounds kinda wrong to me. --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/1/28 Roger Upole : > Giampaolo Rodol? wrote: >> Hi all, >> I'm trying to take advantage of TransmitFile function in pyftpdlib: >> http://code.google.com/p/pyftpdlib/issues/detail?id=152 >> >> I've noticed pywin32 provides a wrapper: >> http://sourceforge.net/tracker/index.php?func=detail&aid=1962146&group_id=78018&atid=551956 >> The example shown in there, though, assumes the socket is in blocking >> state and the file gets sent entirely in a unique call. >> I need to adapt that example to make it work with non-blocking sockets. >> Specifically I want TransmitFile() and GetOverlappedResult() to return >> immediately reporting the number of bytes sent. >> The code below is what I managed to come up with so far but it >> obviously doesn't work. >> It either fails with "error: (996, 'GetOverlappedResult', 'Overlapped >> I/O event is not in a signaled state.')" or the file delivered is >> corrupted. >> I don't have a clue on how should I use the overllaped structure, >> neither it's clear to me what should I do to detect when EOF is >> reached. >> >> Any hint? >> >> def sendfile(sock, file, offset, nbytes): >> """Windows TranmistFile() wrapper, adapted to look like >> UNIX sendfile(). >> """ >> ol = pywintypes.OVERLAPPED() >> ol.Offset = offset >> ol.hEvent = win32event.CreateEvent(None, 0, 0, None) >> filehandle = win32file._get_osfhandle(file) >> win32file.TransmitFile(sock, filehandle, nbytes, offset, ol, 0) >> try: >> sent = win32file.GetOverlappedResult(filehandle, ol, 0) >> except pywintypes.error, err: >> if err.args[0] == 38: # EOF >> return 0 >> raise >> else: >> return sent >> >> >> Thanks in advance, >> >> --- Giampaolo > > The third arg to GetOverlappedResult should be True to wait for an > async operation to complete. > > Roger > > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From maubriga at gmail.com Fri Jan 28 17:15:06 2011 From: maubriga at gmail.com (Mauro) Date: Fri, 28 Jan 2011 16:15:06 +0000 Subject: [python-win32] Problem with win32com and scikits timeseries In-Reply-To: <4D40B937.8060300@gmail.com> References: <4D40B937.8060300@gmail.com> Message-ID: I tried to dig a little further in this, but with no success. I can import the module with no problem and I can't replicate the error outside of the COM object. If I run in pythonWin the following lines >>> from win32com.server.policy import _import_module >>> a= _import_module('scikits.timeseries.cseries') >>> a I do not get any error. Matt Knox suggested it could have something to do with threading, but even calling CoInitialize before importing the scikits.timeseries module does not solve the problem. Why would 'cseries' fail to load only when used though the com interface? Any help? On Thu, Jan 27, 2011 at 12:15 AM, Mark Hammond wrote: > On 24/01/2011 11:30 PM, Mauro wrote: > >> Hello, >> >> I get the following error when importing Date from scikits.timeseries. >> The error is there only when I interface python with Excel using COM. It >> is enough to import anything from scikits.timeseries to get the error. >> >> Any help? >> I am using Python2.7 and scikits.timeseries-0.91.3 >> > ... > > > "C:\Appl\Python27\lib\site-packages\scikits.timeseries-0.91.3-py2.7-win32.egg\scikits\timeseries\const.py", >> line 79, in >> from cseries import freq_constants >> ImportError: DLL load failed: A dynamic link library (DLL) >> initialization routine failed. >> pythoncom error: Python error invoking COM method. >> > > This is the root of your problem - the 'cseries' module, which appears to > be part of the timeseries package, has failed to load. You probably need to > talk to whoever provides that module. > > HTH, > > Mark > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kpoman at hotmail.com Sun Jan 30 17:52:12 2011 From: kpoman at hotmail.com (Patricio Stegmann) Date: Sun, 30 Jan 2011 14:52:12 -0200 Subject: [python-win32] attaching an event handler to already created object Message-ID: Hello, I am trying to attach an event handler to a running pythoncom object. The problem is I am not instantiating it via Dispatch. Basically I generated the python wrapper code (via makepy), and renamed it to a specific name, say, SignpadActivex. The code is the following: """ import os, sys import win32com import SignpadActivex class MyEvents(): def OnPenDown(self): print 'evt pendown' self.m__signpad.SetEventEnableMask(7) def OnPenUp(self): print 'evt penup' self.m__signpad.SetEventEnableMask(7) def OnPenPoint(self): print 'pen point' self.m__signpad.SetEventEnableMask(7) class SignPad(): def __init__(self): self.m__signpad = None def createControl(self): self.m__signpad = TopazSigPlus.SigPlus() print dir(self.m__signpad) win32com.client.WithEvents(self.m__signpad, MyEvents) self.m__signpad.SetEventEnableMask(7) if __name__ == '__main__': l__obj = None l__resp = raw_input('enter option ...:') while l__resp != 'x': if l__resp == 'c': l__obj = SignPad() l__obj.createControl() l__resp = raw_input('enter option ...:') """ Because I do instantiate this way, I dont have the DispatchWithEvents method. So I dont know how to add MyEvents event handler class managing the control's events. >From the generated python code I got this: """ # This CoClass is known by the name 'SIGPLUS.SigPlusCtrl.1' class SigPlus(CoClassBaseClass): # A CoClass # SigPlus Control CLSID = IID('{69A40DA3-4D42-11D0-86B0-0000C025864A}') coclass_sources = [ _DSigPlusEvents, ] default_source = _DSigPlusEvents coclass_interfaces = [ _DSigPlus, ] default_interface = _DSigPlus """ So basically how do I attach an event handler to that running object ? Thank you ! -------------- next part -------------- An HTML attachment was scrubbed... URL: From rupole at hotmail.com Mon Jan 31 02:20:57 2011 From: rupole at hotmail.com (Roger Upole) Date: Sun, 30 Jan 2011 20:20:57 -0500 Subject: [python-win32] attaching an event handler to already created object References: Message-ID: You can pass an existing IDispatch object to DispatchWithEvents as the first arg in place of a clsid. Roger From kpoman at hotmail.com Mon Jan 31 03:48:41 2011 From: kpoman at hotmail.com (Patricio Eduardo Stegmann) Date: Mon, 31 Jan 2011 00:48:41 -0200 Subject: [python-win32] attaching an event handler to already created object In-Reply-To: References: Message-ID: Hi Roger, could you please be a bit more specific ? ----- Original message ----- > You can pass an existing IDispatch object to DispatchWithEvents > as the first arg in place of a clsid. > >? ? ? ? ? ? ? ? ? Roger > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From kpoman at hotmail.com Mon Jan 31 03:48:41 2011 From: kpoman at hotmail.com (Patricio Eduardo Stegmann) Date: Mon, 31 Jan 2011 00:48:41 -0200 Subject: [python-win32] attaching an event handler to already created object In-Reply-To: References: Message-ID: Hi Roger, could you please be a bit more specific ? ----- Original message ----- > You can pass an existing IDispatch object to DispatchWithEvents > as the first arg in place of a clsid. > >? ? ? ? ? ? ? ? ? Roger > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From rupole at hotmail.com Mon Jan 31 06:30:32 2011 From: rupole at hotmail.com (Roger Upole) Date: Mon, 31 Jan 2011 00:30:32 -0500 Subject: [python-win32] attaching an event handler to alreadycreated object References: Message-ID: Try replacing self.m__signpad = TopazSigPlus.SigPlus() with self.m__signpad = win32com.client.DispatchWithEvents(TopazSigPlus.SigPlus(), MyEvents) Roger Patricio Eduardo Stegmann wrote: > Hi Roger, > > could you please be a bit more specific ? > > > ----- Original message ----- >> You can pass an existing IDispatch object to DispatchWithEvents >> as the first arg in place of a clsid. >> >> Roger >> >> >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From kpoman at hotmail.com Mon Jan 31 11:57:16 2011 From: kpoman at hotmail.com (Patricio Stegmann) Date: Mon, 31 Jan 2011 08:57:16 -0200 Subject: [python-win32] attaching an event handler to alreadycreated object In-Reply-To: References: , , Message-ID: Roger, Thanks for your tip ! I tried that but it's still not reporting the events. Maybe this activex does rely or force one to have a gui. Do you know a workaround for this kind of cases ? Is there a way to print if this is the case ? Or to see what is going on ? Thank you, > To: python-win32 at python.org > From: rupole at hotmail.com > Date: Mon, 31 Jan 2011 00:30:32 -0500 > Subject: Re: [python-win32] attaching an event handler to alreadycreated object > > Try replacing > > self.m__signpad = TopazSigPlus.SigPlus() > > with > > self.m__signpad = win32com.client.DispatchWithEvents(TopazSigPlus.SigPlus(), > MyEvents) > > Roger > > Patricio Eduardo Stegmann wrote: > > Hi Roger, > > > > could you please be a bit more specific ? > > > > > > ----- Original message ----- > >> You can pass an existing IDispatch object to DispatchWithEvents > >> as the first arg in place of a clsid. > >> > >> Roger > >> > >> > >> > >> _______________________________________________ > >> python-win32 mailing list > >> python-win32 at python.org > >> http://mail.python.org/mailman/listinfo/python-win32 > >> > > > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From developers at tefnet.pl Mon Jan 31 12:54:48 2011 From: developers at tefnet.pl (Tefnet Developers) Date: Mon, 31 Jan 2011 12:54:48 +0100 Subject: [python-win32] Problem with msvcr90.dll Message-ID: <1296474888.4858.21.camel@cacko> Hi, I am developing a msgina replacement. I am at the point where I have the whole Gina API handled in python (a dll written in C, calling methods of a python object). My problem is that somehow my program cannot import pywin32 modules: Jan 31 12:12:41 p11 pygina: callproxy.caller: File "c:\teflogon\system_nt.py", line 4, in Jan 31 12:12:41 p11 pygina: callproxy.caller: import pywintypes Jan 31 12:12:41 p11 pygina: callproxy.caller: File "C:\Python26\lib\site-packages\win32\lib\pywintypes.py", line 124, in Jan 31 12:12:41 p11 pygina: callproxy.caller: __import_pywin32_system_module__("pywintypes", globals()) Jan 31 12:12:41 p11 pygina: callproxy.caller: File "C:\Python26\lib\site-packages\win32\lib\pywintypes.py", line 64, in __import_pywin32_system_module__ Jan 31 12:12:41 p11 pygina: callproxy.caller: import _win32sysloader Jan 31 12:12:41 p11 pygina: callproxy.caller: ImportError: DLL load failed: The specified module could not be found I did a check and replaced the failing method with execution of python.exe running the same code: if __name__ != '__main__': subprocess.call( [r'c:\python26\python.exe', r'c:\teflogon\tefgina.py', pMessage], ) And pywintypes gets imported fine there. My dll is built using mingw, like this: i586-mingw32msvc-gcc -L./lib -shared -Wl,--kill-at pygina.o -o pygina.dll -lpython26 I thought it had something to do with msvcr90.dll, so I've tried the following: 1. Adding -lmsvcr90 at the end of the linking command 2. Including a manifest in the dll: $ cat pygina.dll.manifest $ grep manifest pygina.rc.in 2 RT_MANIFEST pygina.dll.manifest $ But it did not change a thing. So the question is - why can python.exe load pywin32 modules and my dll cannot? I have been stuck with this for a couple of days now and any pointers would be great :). Thanks, Filip Zyzniewski Tefnet -------------- next part -------------- An HTML attachment was scrubbed... URL: From rupole at hotmail.com Mon Jan 31 15:11:15 2011 From: rupole at hotmail.com (Roger Upole) Date: Mon, 31 Jan 2011 09:11:15 -0500 Subject: [python-win32] attaching an event handler to alreadycreated object References: , , Message-ID: Many OCX controls require a full activex container to function correctly. Pythonwin can act as a host, or you could embed your control in IE with an tag and access it thru IE's COM interfaces. Roger "Patricio Stegmann" wrote in message news:SNT128-W10372245B8A4D462238F49D9E20 at phx.gbl... Roger, Thanks for your tip ! I tried that but it's still not reporting the events. Maybe this activex does rely or force one to have a gui. Do you know a workaround for this kind of cases ? Is there a way to print if this is the case ? Or to see what is going on ? Thank you, > To: python-win32 at python.org > From: rupole at hotmail.com > Date: Mon, 31 Jan 2011 00:30:32 -0500 > Subject: Re: [python-win32] attaching an event handler to alreadycreated > object > > Try replacing > > self.m__signpad = TopazSigPlus.SigPlus() > > with > > self.m__signpad = > win32com.client.DispatchWithEvents(TopazSigPlus.SigPlus(), > MyEvents) > > Roger > > Patricio Eduardo Stegmann wrote: > > Hi Roger, > > > > could you please be a bit more specific ? > > > > > > ----- Original message ----- > >> You can pass an existing IDispatch object to DispatchWithEvents > >> as the first arg in place of a clsid. > >> > >> Roger > >> > >> > >> > >> _______________________________________________ > >> python-win32 mailing list > >> python-win32 at python.org > >> http://mail.python.org/mailman/listinfo/python-win32 > >> > > > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 -------------------------------------------------------------------------------- > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From amelie.lesser at googlemail.com Mon Jan 31 15:41:59 2011 From: amelie.lesser at googlemail.com (Amelie Lesser) Date: Mon, 31 Jan 2011 15:41:59 +0100 Subject: [python-win32] error importing win32com for Dispatch Message-ID: Hello Group, I am struggling very hard with using the win32com.client to use Dispatch. I've been looking around quite a lot, but couldn't find any help that solved my problem. I only started working with python 2 months ago, so I am still quite the newbie. I'm working on a python script that is supposed to read a database into a list. It then should take certain information from each data entry, plug them into an excel file, let excel do a rather complex calculation using macros, and append the results from certain cells back to the list. I am working on Windows using the python IDLE shell and also tried it in gedit running the file on the cmd line. I downloaded the pywin32 extension from http://sourceforge.net/projects/pywin32/ and ran the setup.py file. The program starts with: *from win32com.client import Dispatch * For which I receive the following Error message: *Traceback (most recent call last): File "Z:\testpython\dbf_converter\testing.py", line 3, in from win32com.client import Dispatch ImportError: No module named win32com.client* - I read through the Installation Problems on http://starship.python.net/~skippy/win32/InstallationProblems.html. I found that I do have two versions of the python27.dll file, and deleted the one in the C:\Python27 directory, but everytime I start IDLE it re-creates that file. - I also tried setting the path using (separately) ...but no difference. - *sys.path.append('C:\\WINDOWS\\system32\\')* - *sys.path.append('C:\\Python27\\pywin32-214\\pywin32-214\\com')* - I tried deleting and reinstalling the extension I am completely lost and would really appreciate any help. Amelie -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Jan 31 20:02:55 2011 From: timr at probo.com (Tim Roberts) Date: Mon, 31 Jan 2011 11:02:55 -0800 Subject: [python-win32] error importing win32com for Dispatch In-Reply-To: References: Message-ID: <4D47075F.9000603@probo.com> Amelie Lesser wrote: > > I am struggling very hard with using the win32com.client to use > Dispatch. I've been looking around quite a lot, but couldn't find any > help that solved my problem. I only started working with python 2 > months ago, so I am still quite the newbie. > ... > I downloaded the pywin32 extension from > http://sourceforge.net/projects/pywin32/ and ran the setup.py file. > The program starts with: > > /from win32com.client import Dispatch > / > For which I receive the following Error message: > > /Traceback (most recent call last): > File "Z:\testpython\dbf_converter\testing.py", line 3, in > from win32com.client import Dispatch > ImportError: No module named win32com.client/ > > * I read through the Installation Problems on > http://starship.python.net/~skippy/win32/InstallationProblems.html > . > I found that I do have two versions of the python27.dll file, > and deleted the one in the C:\Python27 directory, but everytime > I start IDLE it re-creates that file. > * I also tried setting the path using (separately) ...but no > difference. > o /sys.path.append('C:\\WINDOWS\\system32\\')/ > o /sys.path.append('C:\\Python27\\pywin32-214\\pywin32-214\\com')/ > That's not the right location. Did you get and run the pywin32 installer? What command did you use to call "setup.py"? In a properly installed system, win32com will live in \Python27\lib\site-packages\win32com. Are you running a 32-bit system or a 64-bit system? Did you install 32-bit Python or 64-bit Python? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From vernondcole at gmail.com Mon Jan 31 20:10:39 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Mon, 31 Jan 2011 12:10:39 -0700 Subject: [python-win32] error importing win32com for Dispatch In-Reply-To: References: Message-ID: Don't use the ZIP file. It is a pain to install, and (as you see) sometimes does not install correctly. Unfortunately, sourceforge sets it as the default thing to do. What you want to do is push the "view all files" button and select the latest Windows installer for the version of Python you are running. (also note that even if you are running a 64 bit version of Windows, you should probably select a 32 bit version of Python.) -- Vernon On Mon, Jan 31, 2011 at 7:41 AM, Amelie Lesser wrote: > Hello Group, > > I am struggling very hard with using the win32com.client to use Dispatch. > I've been looking around quite a lot, but couldn't find any help that solved > my problem. I only started working with python 2 months ago, so I am still > quite the newbie. > > I'm working on a python script that is supposed to read a database into a > list. It then should take certain information from each data entry, plug > them into an excel file, let excel do a rather complex calculation using > macros, and append the results from certain cells back to the list. > I am working on Windows using the python IDLE shell and also tried it in > gedit running the file on the cmd line. > > I downloaded the pywin32 extension from > http://sourceforge.net/projects/pywin32/ and ran the setup.py file. > The program starts with: > > *from win32com.client import Dispatch > * > For which I receive the following Error message: > > *Traceback (most recent call last): > File "Z:\testpython\dbf_converter\testing.py", line 3, in > from win32com.client import Dispatch > ImportError: No module named win32com.client* > > > - I read through the Installation Problems on > http://starship.python.net/~skippy/win32/InstallationProblems.html. > I found that I do have two versions of the python27.dll file, and deleted > the one in the C:\Python27 directory, but everytime I start IDLE it > re-creates that file. > - I also tried setting the path using (separately) ...but no > difference. > - *sys.path.append('C:\\WINDOWS\\system32\\')* > - *sys.path.append('C:\\Python27\\pywin32-214\\pywin32-214\\com')* > - I tried deleting and reinstalling the extension > > > I am completely lost and would really appreciate any help. > > Amelie > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From yacek87 at gmail.com Mon Jan 31 22:44:45 2011 From: yacek87 at gmail.com (Jacek Jablonski) Date: Mon, 31 Jan 2011 22:44:45 +0100 Subject: [python-win32] AtributeError with long opening Excel files Message-ID: Hi, I have got a problem with code that opens my Excel workbook and try to perform some operations: self.app = Dispatch('Excel.Application') self.app.Workbooks.Open('someexcel.xls') print(self.app.ActiveWorkbook.Sheets('test').Range('D4')) I receive AttributeError, but I know what caused it. My workbook has pivot tables that are refreshed on workbook opening, so it takes some time to open and Workbook.Open() function returns immediatly without waiting. If I add some time.sleep() between 2nd and 3rd line, it works fine. What is the best way to solve this problem? Are there any other ways to open workbook (sync open)? Is there any way to detect if file is fully opened? Cheers, Jacek From skippy.hammond at gmail.com Mon Jan 31 23:08:03 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 01 Feb 2011 09:08:03 +1100 Subject: [python-win32] Problem with win32com and scikits timeseries In-Reply-To: References: <4D40B937.8060300@gmail.com> Message-ID: <4D4732C3.1040008@gmail.com> As a work-around, try doing the problematic import in the top-level of the module rather than in a method. HTH, Mark On 29/01/2011 3:15 AM, Mauro wrote: > I tried to dig a little further in this, but with no success. > I can import the module with no problem and I can't replicate the error > outside of the COM object. > > If I run in pythonWin the following lines > > >>> from win32com.server.policy import _import_module > >>> a= _import_module('scikits.timeseries.cseries') > >>> a > 'C:\Appl\Python27\lib\site-packages\scikits.timeseries-0.91.3-py2.7-win32.egg\scikits\timeseries\cseries.pyd'> > > I do not get any error. Matt Knox suggested it could have something to > do with threading, but even calling CoInitialize before importing the > scikits.timeseries module does not solve the problem. > > Why would 'cseries' fail to load only when used though the com interface? > > Any help? > > On Thu, Jan 27, 2011 at 12:15 AM, Mark Hammond > wrote: > > On 24/01/2011 11:30 PM, Mauro wrote: > > Hello, > > I get the following error when importing Date from > scikits.timeseries. > The error is there only when I interface python with Excel using > COM. It > is enough to import anything from scikits.timeseries to get the > error. > > Any help? > I am using Python2.7 and scikits.timeseries-0.91.3 > > ... > > > "C:\Appl\Python27\lib\site-packages\scikits.timeseries-0.91.3-py2.7-win32.egg\scikits\timeseries\const.py", > line 79, in > from cseries import freq_constants > ImportError: DLL load failed: A dynamic link library (DLL) > initialization routine failed. > pythoncom error: Python error invoking COM method. > > > This is the root of your problem - the 'cseries' module, which > appears to be part of the timeseries package, has failed to load. > You probably need to talk to whoever provides that module. > > HTH, > > Mark > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32