From cappy2112 at gmail.com Thu Oct 1 16:22:59 2009 From: cappy2112 at gmail.com (Tony Cappellini) Date: Thu, 1 Oct 2009 07:22:59 -0700 Subject: [python-win32] python-win32 Digest, Vol 79, Issue 1 In-Reply-To: References: Message-ID: <8249c4ac0910010722s659ef6baq4ff2f825e44ff47c@mail.gmail.com> Message: 3 Date: Wed, 30 Sep 2009 11:56:01 -0700 From: Tim Roberts To: Python-Win32 List Subject: Re: [python-win32] Talking to the parallel port Message-ID: <4AC3A9C1.4000209 at probo.com> Content-Type: text/plain; charset=ISO-8859-1 >>Why would you expect any updates? The technology behind the parallel >>port has not changed since 1994. It's not about the technology changing. But people do add improvments to python packages over time, and release newer/better packages. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Oct 1 18:34:55 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 01 Oct 2009 09:34:55 -0700 Subject: [python-win32] Talking to the parallel port In-Reply-To: <8249c4ac0910010722s659ef6baq4ff2f825e44ff47c@mail.gmail.com> References: <8249c4ac0910010722s659ef6baq4ff2f825e44ff47c@mail.gmail.com> Message-ID: <4AC4DA2F.5000600@probo.com> Tony Cappellini wrote: > Tim Roberts > wrote: > > >>Why would you expect any updates? The technology behind the parallel > >>port has not changed since 1994. > It's not about the technology changing. > But people do add improvments to python packages over time, and > release newer/better packages. Yes, and I apologize if I seemed curt. You happened to touch on a pet peeve of mine. In the Windows world, people complain and moan about Microsoft releasing continual updates of their software with obscure and relatively trivial additional features, so much so that I suspect many of the developers within the sound of my voice are still using Office 2003 (now 7 years old) and Visual C++ 6.0 (now an incredible 11 years old). But in the open source world, if a product goes for 12 months without a significant update, people start asking, "Is this product dead? Should I use something else?" There does come a point in the life of every piece of software where the product is DONE, when it does what it was supposed to do. After that point, additional updates are just pointless eye candy. Now in the case of pyparallel, that's not fair of me. It is clear there are additional useful features that could have been added, like EPP and ECP support. So, you were right to ask, and I'm just monologuing. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From caothucodon123 at gmail.com Fri Oct 2 09:23:11 2009 From: caothucodon123 at gmail.com (caothucodon 123) Date: Fri, 2 Oct 2009 14:23:11 +0700 Subject: [python-win32] sgmllib for python3 Message-ID: <5c5728bc0910020023i3ca6c0fas87469b0498c2437f@mail.gmail.com> i use python 3k i have some script in python2k . its use sgmllib but in python 3k it not working what i can use difrrent modul same sgmllib ???????? thank -------------- next part -------------- An HTML attachment was scrubbed... URL: From ajsavige at yahoo.com.au Sun Oct 4 07:39:25 2009 From: ajsavige at yahoo.com.au (Andrew Savige) Date: Sat, 3 Oct 2009 22:39:25 -0700 (PDT) Subject: [python-win32] Unable to install PyWin32 with Python 2.6.2 and 2.6.3 Message-ID: <166165.58186.qm@web56402.mail.re3.yahoo.com> After doing a fresh install of Python 2.6.3, I ran pywin32-214.win32-py2.6.exe, downloaded from http://sourceforge.net/projects/pywin32/ At the end of the install was a dialog box stating that "Postinstall script finished" but with an error message: Traceback (most recent call last): ? File "", line 601, in ? File "", line 311, in install ? File "", line 149, in LoadSystemModule ImportError: DLL load failed: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. Googling uncovered a report of an identical error message at: ?http://mail.python.org/pipermail/python-win32/2009-July/009336.html with pywin32 build 213 and which stated that this problem had been fixed with build 214. In desperation, I uninstalled Python 2.6.3 and installed Python 2.6.2, but still received the same error message shown above when installing pywin32 on top of Python 2.6.2. I'm running Windows XP SP2 and did a brand new install of Python 2.6.2/2.6.3 -- with the "Just for me" dialog box checked -- in directory E:\tools\Python26 (using python-2.6.3.msi downloaded from http://www.python.org/). Please help. Thanks, /-\ __________________________________________________________________________________ Get more done like never before with Yahoo!7 Mail. Learn more: http://au.overview.mail.yahoo.com/ From ajsavige at yahoo.com.au Sun Oct 4 08:00:07 2009 From: ajsavige at yahoo.com.au (Andrew Savige) Date: Sat, 3 Oct 2009 23:00:07 -0700 (PDT) Subject: [python-win32] Unable to install PyWin32 with Python 2.6.2 and 2.6.3 In-Reply-To: <166165.58186.qm@web56402.mail.re3.yahoo.com> References: <166165.58186.qm@web56402.mail.re3.yahoo.com> Message-ID: <922421.45549.qm@web56401.mail.re3.yahoo.com> > I'm running Windows XP SP2 and did a brand new install of Python > 2.6.2/2.6.3 -- with the "Just for me" dialog box checked -- in > directory E:\tools\Python26 (using python-2.6.3.msi downloaded > from http://www.python.org/). Aha, I just reinstalled 2.6.2 without the "Just for me" checkbox and this time pywin32 installed successfully with the following message: Copied pythoncom26.dll to C:\WINDOWS\system32\pythoncom26.dll Copied pywintypes26.dll to C:\WINDOWS\system32\pywintypes26.dll Registered: Python.Interpreter Registered: Python.Dictionary Registered: Python -> Software\Python\PythonCore\2.6\Help[None]=None -> Software\Python\PythonCore\2.6\Help\Pythonwin Reference[None]='E:\\tools\\Python26\\Lib\\site-packages\\PyWin32.chm' Pythonwin has been registered in context menu Creating directory E:\tools\Python26\Lib\site-packages\win32com\gen_py Shortcut for Pythonwin created Shortcut to documentation created The pywin32 extensions were successfully installed. BTW, I've been installing Python with the "Just for me" checked because I don't like polluting my C:\Windows\system32 directory with third party DLLs. In particular, I need to set up a Python installation for all users on a network drive, so don't want any files installed on the local drive. Any tips on setting up a shared Windows Python install on a network drive for all users would be appreciated. Thanks, /-\ __________________________________________________________________________________ Get more done like never before with Yahoo!7 Mail. Learn more: http://au.overview.mail.yahoo.com/ From metolone+gmane at gmail.com Sun Oct 4 08:01:53 2009 From: metolone+gmane at gmail.com (Mark Tolonen) Date: Sat, 3 Oct 2009 23:01:53 -0700 Subject: [python-win32] Unable to install PyWin32 with Python 2.6.2 and 2.6.3 References: <166165.58186.qm@web56402.mail.re3.yahoo.com> Message-ID: "Andrew Savige" wrote in message news:166165.58186.qm at web56402.mail.re3.yahoo.com... After doing a fresh install of Python 2.6.3, I ran pywin32-214.win32-py2.6.exe, downloaded from http://sourceforge.net/projects/pywin32/ At the end of the install was a dialog box stating that "Postinstall script finished" but with an error message: Traceback (most recent call last): File "", line 601, in File "", line 311, in install File "", line 149, in LoadSystemModule ImportError: DLL load failed: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. Googling uncovered a report of an identical error message at: http://mail.python.org/pipermail/python-win32/2009-July/009336.html with pywin32 build 213 and which stated that this problem had been fixed with build 214. In desperation, I uninstalled Python 2.6.3 and installed Python 2.6.2, but still received the same error message shown above when installing pywin32 on top of Python 2.6.2. I'm running Windows XP SP2 and did a brand new install of Python 2.6.2/2.6.3 -- with the "Just for me" dialog box checked -- in directory E:\tools\Python26 (using python-2.6.3.msi downloaded from http://www.python.org/). Please help. ---------------------------------------------------------------------------------------------------------------------------------------------------- I have 2.6.2 running with pywin32-214. On XP SP2 as well. I installed for all users, however. Have you tried that? -Mark From damonwischik at gmail.com Mon Oct 5 17:58:34 2009 From: damonwischik at gmail.com (Damon Wischik) Date: Mon, 5 Oct 2009 16:58:34 +0100 Subject: [python-win32] How to use COM when there isn't a type library or IDL file Message-ID: <51ae820a0910050858u3a87582dhf7bea1700e9110f7@mail.gmail.com> I am trying to use Microsoft's RealTimeStylus COM classes from Python. I want to access the RealTimeStylus object, and I want to create Python objects that support the IStylusAsyncPlugin. The difficulty is that there is no type library specifying the relevant interfaces, nor is there an IDL file. All I can find are Microsoft's C/C++ header files in the Windows 7 SDK. My registry has an entry for the CLSID for RealTimeStylus, but it doesn't have entries for the interfaces IRealTimeStylus or IStylusAsyncPlugin. I know very little about COM, but it seems to me that I should be able to read through the C/C++ header files for the relevant COM interfaces, and write a Python equivalent. (I don't think I can use makepy because there is no type library, and I don't think I can use the Dispatch approach because (a) RealTimeStylus does not implement IDispatch and (b) that's no use anyway for server COM.) I know very little about IDL and about COM, and I have no idea how to go about translating the C/C++ header files into Python. I would be very grateful if anyone could give me some tips, or pointers about what I should read to do this, or correct misconceptions in what I wrote above. The stuff below is excerpted from rtscom.h, and it looks like the interface IRealTimeStylus which I would like to use in Python. Damon. #ifndef __IRealTimeStylus_INTERFACE_DEFINED__ #define __IRealTimeStylus_INTERFACE_DEFINED__ /* interface IRealTimeStylus */ /* [unique][helpstring][uuid][object] */ EXTERN_C const IID IID_IRealTimeStylus; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("A8BB5D22-3144-4a7b-93CD-F34A16BE513A") IRealTimeStylus : public IUnknown { public: virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Enabled( /* [retval][out] */ __RPC__out BOOL *pfEnable) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Enabled( /* [in] */ BOOL fEnable) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_HWND( /* [retval][out] */ __RPC__out HANDLE_PTR *phwnd) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_HWND( /* [in] */ HANDLE_PTR hwnd) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_WindowInputRectangle( /* [retval][out] */ __RPC__out RECT *prcWndInputRect) = 0; virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_WindowInputRectangle( /* [in] */ __RPC__in const RECT *prcWndInputRect) = 0; virtual HRESULT STDMETHODCALLTYPE AddStylusSyncPlugin( /* [in] */ ULONG iIndex, /* [in] */ __RPC__in_opt IStylusSyncPlugin *piPlugin) = 0; virtual HRESULT STDMETHODCALLTYPE RemoveStylusSyncPlugin( /* [in] */ ULONG iIndex, /* [out][in] */ __RPC__deref_inout_opt IStylusSyncPlugin **ppiPlugin) = 0; virtual HRESULT STDMETHODCALLTYPE RemoveAllStylusSyncPlugins( void) = 0; virtual HRESULT STDMETHODCALLTYPE GetStylusSyncPlugin( /* [in] */ ULONG iIndex, /* [out] */ __RPC__deref_out_opt IStylusSyncPlugin **ppiPlugin) = 0; virtual HRESULT STDMETHODCALLTYPE GetStylusSyncPluginCount( /* [out] */ __RPC__out ULONG *pcPlugins) = 0; virtual HRESULT STDMETHODCALLTYPE AddStylusAsyncPlugin( /* [in] */ ULONG iIndex, /* [in] */ __RPC__in_opt IStylusAsyncPlugin *piPlugin) = 0; virtual HRESULT STDMETHODCALLTYPE RemoveStylusAsyncPlugin( /* [in] */ ULONG iIndex, /* [out][in] */ __RPC__deref_inout_opt IStylusAsyncPlugin **ppiPlugin) = 0; virtual HRESULT STDMETHODCALLTYPE RemoveAllStylusAsyncPlugins( void) = 0; virtual HRESULT STDMETHODCALLTYPE GetStylusAsyncPlugin( /* [in] */ ULONG iIndex, /* [out] */ __RPC__deref_out_opt IStylusAsyncPlugin **ppiPlugin) = 0; virtual HRESULT STDMETHODCALLTYPE GetStylusAsyncPluginCount( /* [out] */ __RPC__out ULONG *pcPlugins) = 0; virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ChildRealTimeStylusPlugin( /* [retval][out] */ __RPC__deref_out_opt IRealTimeStylus **ppiRTS) = 0; virtual /* [propputref] */ HRESULT STDMETHODCALLTYPE putref_ChildRealTimeStylusPlugin( /* [unique][in] */ __RPC__in_opt IRealTimeStylus *piRTS) = 0; virtual HRESULT STDMETHODCALLTYPE AddCustomStylusDataToQueue( /* [in] */ StylusQueue sq, /* [in] */ __RPC__in const GUID *pGuidId, /* [range][in] */ __RPC__in_range(0,0x7fff) ULONG cbData, /* [unique][size_is][in] */ __RPC__in_ecount_full_opt(cbData) BYTE *pbData) = 0; virtual HRESULT STDMETHODCALLTYPE ClearStylusQueues( void) = 0; virtual HRESULT STDMETHODCALLTYPE SetAllTabletsMode( /* [in] */ BOOL fUseMouseForInput) = 0; virtual HRESULT STDMETHODCALLTYPE SetSingleTabletMode( /* [in] */ __RPC__in_opt IInkTablet *piTablet) = 0; virtual HRESULT STDMETHODCALLTYPE GetTablet( /* [retval][out] */ __RPC__deref_out_opt IInkTablet **ppiSingleTablet) = 0; virtual HRESULT STDMETHODCALLTYPE GetTabletContextIdFromTablet( /* [in] */ __RPC__in_opt IInkTablet *piTablet, /* [retval][out] */ __RPC__out TABLET_CONTEXT_ID *ptcid) = 0; virtual HRESULT STDMETHODCALLTYPE GetTabletFromTabletContextId( /* [in] */ TABLET_CONTEXT_ID tcid, /* [retval][out] */ __RPC__deref_out_opt IInkTablet **ppiTablet) = 0; virtual HRESULT STDMETHODCALLTYPE GetAllTabletContextIds( /* [out][in] */ __RPC__inout ULONG *pcTcidCount, /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*pcTcidCount) TABLET_CONTEXT_ID **ppTcids) = 0; virtual HRESULT STDMETHODCALLTYPE GetStyluses( /* [retval][out] */ __RPC__deref_out_opt IInkCursors **ppiInkCursors) = 0; virtual HRESULT STDMETHODCALLTYPE GetStylusForId( /* [in] */ STYLUS_ID sid, /* [retval][out] */ __RPC__deref_out_opt IInkCursor **ppiInkCursor) = 0; virtual HRESULT STDMETHODCALLTYPE SetDesiredPacketDescription( /* [range][in] */ __RPC__in_range(0,32) ULONG cProperties, /* [size_is][in] */ __RPC__in_ecount_full(cProperties) const GUID *pPropertyGuids) = 0; virtual HRESULT STDMETHODCALLTYPE GetDesiredPacketDescription( /* [out][in] */ __RPC__inout ULONG *pcProperties, /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*pcProperties) GUID **ppPropertyGuids) = 0; virtual HRESULT STDMETHODCALLTYPE GetPacketDescriptionData( /* [in] */ TABLET_CONTEXT_ID tcid, /* [unique][out][in] */ __RPC__inout_opt FLOAT *pfInkToDeviceScaleX, /* [unique][out][in] */ __RPC__inout_opt FLOAT *pfInkToDeviceScaleY, /* [out][in] */ __RPC__inout ULONG *pcPacketProperties, /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*pcPacketProperties) PACKET_PROPERTY **ppPacketProperties) = 0; }; #else /* C style interface */ typedef struct IRealTimeStylusVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( __RPC__in IRealTimeStylus * This, /* [in] */ __RPC__in REFIID riid, /* [annotation][iid_is][out] */ __RPC__deref_out void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( __RPC__in IRealTimeStylus * This); ULONG ( STDMETHODCALLTYPE *Release )( __RPC__in IRealTimeStylus * This); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Enabled )( __RPC__in IRealTimeStylus * This, /* [retval][out] */ __RPC__out BOOL *pfEnable); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Enabled )( __RPC__in IRealTimeStylus * This, /* [in] */ BOOL fEnable); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_HWND )( __RPC__in IRealTimeStylus * This, /* [retval][out] */ __RPC__out HANDLE_PTR *phwnd); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_HWND )( __RPC__in IRealTimeStylus * This, /* [in] */ HANDLE_PTR hwnd); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_WindowInputRectangle )( __RPC__in IRealTimeStylus * This, /* [retval][out] */ __RPC__out RECT *prcWndInputRect); /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_WindowInputRectangle )( __RPC__in IRealTimeStylus * This, /* [in] */ __RPC__in const RECT *prcWndInputRect); HRESULT ( STDMETHODCALLTYPE *AddStylusSyncPlugin )( __RPC__in IRealTimeStylus * This, /* [in] */ ULONG iIndex, /* [in] */ __RPC__in_opt IStylusSyncPlugin *piPlugin); HRESULT ( STDMETHODCALLTYPE *RemoveStylusSyncPlugin )( __RPC__in IRealTimeStylus * This, /* [in] */ ULONG iIndex, /* [out][in] */ __RPC__deref_inout_opt IStylusSyncPlugin **ppiPlugin); HRESULT ( STDMETHODCALLTYPE *RemoveAllStylusSyncPlugins )( __RPC__in IRealTimeStylus * This); HRESULT ( STDMETHODCALLTYPE *GetStylusSyncPlugin )( __RPC__in IRealTimeStylus * This, /* [in] */ ULONG iIndex, /* [out] */ __RPC__deref_out_opt IStylusSyncPlugin **ppiPlugin); HRESULT ( STDMETHODCALLTYPE *GetStylusSyncPluginCount )( __RPC__in IRealTimeStylus * This, /* [out] */ __RPC__out ULONG *pcPlugins); HRESULT ( STDMETHODCALLTYPE *AddStylusAsyncPlugin )( __RPC__in IRealTimeStylus * This, /* [in] */ ULONG iIndex, /* [in] */ __RPC__in_opt IStylusAsyncPlugin *piPlugin); HRESULT ( STDMETHODCALLTYPE *RemoveStylusAsyncPlugin )( __RPC__in IRealTimeStylus * This, /* [in] */ ULONG iIndex, /* [out][in] */ __RPC__deref_inout_opt IStylusAsyncPlugin **ppiPlugin); HRESULT ( STDMETHODCALLTYPE *RemoveAllStylusAsyncPlugins )( __RPC__in IRealTimeStylus * This); HRESULT ( STDMETHODCALLTYPE *GetStylusAsyncPlugin )( __RPC__in IRealTimeStylus * This, /* [in] */ ULONG iIndex, /* [out] */ __RPC__deref_out_opt IStylusAsyncPlugin **ppiPlugin); HRESULT ( STDMETHODCALLTYPE *GetStylusAsyncPluginCount )( __RPC__in IRealTimeStylus * This, /* [out] */ __RPC__out ULONG *pcPlugins); /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ChildRealTimeStylusPlugin )( __RPC__in IRealTimeStylus * This, /* [retval][out] */ __RPC__deref_out_opt IRealTimeStylus **ppiRTS); /* [propputref] */ HRESULT ( STDMETHODCALLTYPE *putref_ChildRealTimeStylusPlugin )( __RPC__in IRealTimeStylus * This, /* [unique][in] */ __RPC__in_opt IRealTimeStylus *piRTS); HRESULT ( STDMETHODCALLTYPE *AddCustomStylusDataToQueue )( __RPC__in IRealTimeStylus * This, /* [in] */ StylusQueue sq, /* [in] */ __RPC__in const GUID *pGuidId, /* [range][in] */ __RPC__in_range(0,0x7fff) ULONG cbData, /* [unique][size_is][in] */ __RPC__in_ecount_full_opt(cbData) BYTE *pbData); HRESULT ( STDMETHODCALLTYPE *ClearStylusQueues )( __RPC__in IRealTimeStylus * This); HRESULT ( STDMETHODCALLTYPE *SetAllTabletsMode )( __RPC__in IRealTimeStylus * This, /* [in] */ BOOL fUseMouseForInput); HRESULT ( STDMETHODCALLTYPE *SetSingleTabletMode )( __RPC__in IRealTimeStylus * This, /* [in] */ __RPC__in_opt IInkTablet *piTablet); HRESULT ( STDMETHODCALLTYPE *GetTablet )( __RPC__in IRealTimeStylus * This, /* [retval][out] */ __RPC__deref_out_opt IInkTablet **ppiSingleTablet); HRESULT ( STDMETHODCALLTYPE *GetTabletContextIdFromTablet )( __RPC__in IRealTimeStylus * This, /* [in] */ __RPC__in_opt IInkTablet *piTablet, /* [retval][out] */ __RPC__out TABLET_CONTEXT_ID *ptcid); HRESULT ( STDMETHODCALLTYPE *GetTabletFromTabletContextId )( __RPC__in IRealTimeStylus * This, /* [in] */ TABLET_CONTEXT_ID tcid, /* [retval][out] */ __RPC__deref_out_opt IInkTablet **ppiTablet); HRESULT ( STDMETHODCALLTYPE *GetAllTabletContextIds )( __RPC__in IRealTimeStylus * This, /* [out][in] */ __RPC__inout ULONG *pcTcidCount, /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*pcTcidCount) TABLET_CONTEXT_ID **ppTcids); HRESULT ( STDMETHODCALLTYPE *GetStyluses )( __RPC__in IRealTimeStylus * This, /* [retval][out] */ __RPC__deref_out_opt IInkCursors **ppiInkCursors); HRESULT ( STDMETHODCALLTYPE *GetStylusForId )( __RPC__in IRealTimeStylus * This, /* [in] */ STYLUS_ID sid, /* [retval][out] */ __RPC__deref_out_opt IInkCursor **ppiInkCursor); HRESULT ( STDMETHODCALLTYPE *SetDesiredPacketDescription )( __RPC__in IRealTimeStylus * This, /* [range][in] */ __RPC__in_range(0,32) ULONG cProperties, /* [size_is][in] */ __RPC__in_ecount_full(cProperties) const GUID *pPropertyGuids); HRESULT ( STDMETHODCALLTYPE *GetDesiredPacketDescription )( __RPC__in IRealTimeStylus * This, /* [out][in] */ __RPC__inout ULONG *pcProperties, /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*pcProperties) GUID **ppPropertyGuids); HRESULT ( STDMETHODCALLTYPE *GetPacketDescriptionData )( __RPC__in IRealTimeStylus * This, /* [in] */ TABLET_CONTEXT_ID tcid, /* [unique][out][in] */ __RPC__inout_opt FLOAT *pfInkToDeviceScaleX, /* [unique][out][in] */ __RPC__inout_opt FLOAT *pfInkToDeviceScaleY, /* [out][in] */ __RPC__inout ULONG *pcPacketProperties, /* [size_is][size_is][out] */ __RPC__deref_out_ecount_full_opt(*pcPacketProperties) PACKET_PROPERTY **ppPacketProperties); END_INTERFACE } IRealTimeStylusVtbl; interface IRealTimeStylus { CONST_VTBL struct IRealTimeStylusVtbl *lpVtbl; }; From JSouthard at IntouchHealth.com Mon Oct 5 21:01:33 2009 From: JSouthard at IntouchHealth.com (Jon Southard) Date: Mon, 5 Oct 2009 12:01:33 -0700 Subject: [python-win32] Python and ASP - failure on 2nd and subsequent page loads Message-ID: <32AA3A83235A25458AB5387177B883F8110C528AEE@MAIL.ith.local> I would be grateful for any advice about a problem which is preventing me from using Python for my current project. I am hoping to use Python 2.6 on the server side with Microsoft ASP [not ASP.NET; version details below]. The behavior I see is: 1. Load very simple page [text below] into browser [Firefox or IE, versions below]. Everything displays, fine. 2. Exit browser, restart it, and reload the same page; or open a second tab and load the same page. 3. In either case, page fails to load, with error: Python ActiveX Scripting Engine, ASP 0211 (0x80020009) A built-in ASP object has been referenced, which is no longer valid. If I edit the page in any way, or just 'touch' it, and refresh the browser, the page will load correctly the first time, and then fail again as described. The page I am using has no actual Python scripting, just the LANGUAGE directive and then the html and body tags with a little plain text. Of course, things don't get any better if I put in some actual Python. I found a five-year-old newsgroup posting with what seemed to be a similar (but not identical) problem. This thread said that the problem went away if server-side debugging was turned off. I have it turned off, no effect. I also tried adding some Response object settings to disallow cacheing, but these did not have any effect. Version Info: Python: 2.6.2 PyWin: pywin32-214 (I ran the client\pyscript.py and server\axsite.py scripts for setup) Client OS: Windows XP Pro SP2 Browsers: Firefox 3.0.14, IE 8.0.6 [identical bug] Server: IIS 5.1 Note, I also tried using Python 3.1 with corresponding pywin, but I could not get that to work with ASP at all; just got server 500 errors. I'd prefer to use 2.6 anyway since I am fairly new to Python. I would be very grateful for any expert pointers on this, since if I can't solve it I will probably have to go use PHP, Javascript, or something else. Thank you! -------------- next part -------------- An HTML attachment was scrubbed... URL: From david_wormser at cox.net Tue Oct 6 16:41:01 2009 From: david_wormser at cox.net (David Wormser) Date: Tue, 6 Oct 2009 09:41:01 -0500 Subject: [python-win32] Library not Registered Error while running Message-ID: I started getting this error message yesterday. I can use system restore to eliminate it but it returns when ever I try to follow any links. Do you have a permanent fix? -------------- next part -------------- An HTML attachment was scrubbed... URL: From admin at dmarkey.com Fri Oct 9 01:11:24 2009 From: admin at dmarkey.com (David) Date: Fri, 9 Oct 2009 00:11:24 +0100 Subject: [python-win32] SSPI/NTLM authentication via XMLRPC Message-ID: <6894a6470910081611t24da4be8r77370a4fe1061595@mail.gmail.com> Hi, I was wondering if this would be possible: At the minute i have a login xmlrpc call that takes a username/password as an argument. simple enough, authenticates off the windows domain via LogonUser(pywin32), the user then gets a cookie for the session(to execute further xmlrpc calls). I was wondering if it would be possible to achieve SSO using SSPI/NTLM via XMLRPC? I see an example in win32/Demos/sspi/socket_server.py, im not sure if something similar could be used via XMLRPC. Thanks, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Fri Oct 9 07:09:25 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 09 Oct 2009 16:09:25 +1100 Subject: [python-win32] SSPI/NTLM authentication via XMLRPC In-Reply-To: <6894a6470910081611t24da4be8r77370a4fe1061595@mail.gmail.com> References: <6894a6470910081611t24da4be8r77370a4fe1061595@mail.gmail.com> Message-ID: <4ACEC585.1040600@gmail.com> On 9/10/2009 10:11 AM, David wrote: > Hi, > > I was wondering if this would be possible: > > At the minute i have a login xmlrpc call that takes a username/password > as an argument. simple enough, authenticates off the windows domain via > LogonUser(pywin32), the user then gets a cookie for the session(to > execute further xmlrpc calls). > > I was wondering if it would be possible to achieve SSO using SSPI/NTLM > via XMLRPC? > > I see an example in win32/Demos/sspi/socket_server.py, im not sure if > something similar could be used via XMLRPC. Off the top of my head I can't see why not if you control both the client and the server and don't mind making them do an auth dance to set things up - you probably want to check out the simple_auth.py sample for some idea of how it could be implemented. Cheers, Mark From skippy.hammond at gmail.com Fri Oct 9 07:11:52 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 09 Oct 2009 16:11:52 +1100 Subject: [python-win32] How to use COM when there isn't a type library or IDL file In-Reply-To: <51ae820a0910050858u3a87582dhf7bea1700e9110f7@mail.gmail.com> References: <51ae820a0910050858u3a87582dhf7bea1700e9110f7@mail.gmail.com> Message-ID: <4ACEC618.5000806@gmail.com> This is very tricky to do in pure-python. Other interfaces with this issue (eg, the shell interfaces) tend to use custom c++ code (often generated by the 'makegw' package then heavily edited) to implement a win32com 'sub-module'. The best alternative for you may be to investigate how comtypes might help... Cheers, Mark On 6/10/2009 2:58 AM, Damon Wischik wrote: > I am trying to use Microsoft's RealTimeStylus COM classes from Python. > I want to access the RealTimeStylus object, and I want to create > Python objects that support the IStylusAsyncPlugin. The difficulty is > that there is no type library specifying the relevant interfaces, nor > is there an IDL file. All I can find are Microsoft's C/C++ header > files in the Windows 7 SDK. My registry has an entry for the CLSID for > RealTimeStylus, but it doesn't have entries for the interfaces > IRealTimeStylus or IStylusAsyncPlugin. > > I know very little about COM, but it seems to me that I should be able > to read through the C/C++ header files for the relevant COM > interfaces, and write a Python equivalent. (I don't think I can use > makepy because there is no type library, and I don't think I can use > the Dispatch approach because (a) RealTimeStylus does not implement > IDispatch and (b) that's no use anyway for server COM.) > > I know very little about IDL and about COM, and I have no idea how to > go about translating the C/C++ header files into Python. I would be > very grateful if anyone could give me some tips, or pointers about > what I should read to do this, or correct misconceptions in what I > wrote above. > > The stuff below is excerpted from rtscom.h, and it looks like the > interface IRealTimeStylus which I would like to use in Python. > > Damon. > > > #ifndef __IRealTimeStylus_INTERFACE_DEFINED__ > #define __IRealTimeStylus_INTERFACE_DEFINED__ > > /* interface IRealTimeStylus */ > /* [unique][helpstring][uuid][object] */ > > > EXTERN_C const IID IID_IRealTimeStylus; > > #if defined(__cplusplus)&& !defined(CINTERFACE) > > MIDL_INTERFACE("A8BB5D22-3144-4a7b-93CD-F34A16BE513A") > IRealTimeStylus : public IUnknown > { > public: > virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Enabled( > /* [retval][out] */ __RPC__out BOOL *pfEnable) = 0; > > virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Enabled( > /* [in] */ BOOL fEnable) = 0; > > virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_HWND( > /* [retval][out] */ __RPC__out HANDLE_PTR *phwnd) = 0; > > virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_HWND( > /* [in] */ HANDLE_PTR hwnd) = 0; > > virtual /* [propget] */ HRESULT STDMETHODCALLTYPE > get_WindowInputRectangle( > /* [retval][out] */ __RPC__out RECT *prcWndInputRect) = 0; > > virtual /* [propput] */ HRESULT STDMETHODCALLTYPE > put_WindowInputRectangle( > /* [in] */ __RPC__in const RECT *prcWndInputRect) = 0; > > virtual HRESULT STDMETHODCALLTYPE AddStylusSyncPlugin( > /* [in] */ ULONG iIndex, > /* [in] */ __RPC__in_opt IStylusSyncPlugin *piPlugin) = 0; > > virtual HRESULT STDMETHODCALLTYPE RemoveStylusSyncPlugin( > /* [in] */ ULONG iIndex, > /* [out][in] */ __RPC__deref_inout_opt IStylusSyncPlugin > **ppiPlugin) = 0; > > virtual HRESULT STDMETHODCALLTYPE RemoveAllStylusSyncPlugins( void) = 0; > > virtual HRESULT STDMETHODCALLTYPE GetStylusSyncPlugin( > /* [in] */ ULONG iIndex, > /* [out] */ __RPC__deref_out_opt IStylusSyncPlugin **ppiPlugin) = 0; > > virtual HRESULT STDMETHODCALLTYPE GetStylusSyncPluginCount( > /* [out] */ __RPC__out ULONG *pcPlugins) = 0; > > virtual HRESULT STDMETHODCALLTYPE AddStylusAsyncPlugin( > /* [in] */ ULONG iIndex, > /* [in] */ __RPC__in_opt IStylusAsyncPlugin *piPlugin) = 0; > > virtual HRESULT STDMETHODCALLTYPE RemoveStylusAsyncPlugin( > /* [in] */ ULONG iIndex, > /* [out][in] */ __RPC__deref_inout_opt IStylusAsyncPlugin > **ppiPlugin) = 0; > > virtual HRESULT STDMETHODCALLTYPE RemoveAllStylusAsyncPlugins( > void) = 0; > > virtual HRESULT STDMETHODCALLTYPE GetStylusAsyncPlugin( > /* [in] */ ULONG iIndex, > /* [out] */ __RPC__deref_out_opt IStylusAsyncPlugin > **ppiPlugin) = 0; > > virtual HRESULT STDMETHODCALLTYPE GetStylusAsyncPluginCount( > /* [out] */ __RPC__out ULONG *pcPlugins) = 0; > > virtual /* [propget] */ HRESULT STDMETHODCALLTYPE > get_ChildRealTimeStylusPlugin( > /* [retval][out] */ __RPC__deref_out_opt IRealTimeStylus > **ppiRTS) = 0; > > virtual /* [propputref] */ HRESULT STDMETHODCALLTYPE > putref_ChildRealTimeStylusPlugin( > /* [unique][in] */ __RPC__in_opt IRealTimeStylus *piRTS) = 0; > > virtual HRESULT STDMETHODCALLTYPE AddCustomStylusDataToQueue( > /* [in] */ StylusQueue sq, > /* [in] */ __RPC__in const GUID *pGuidId, > /* [range][in] */ __RPC__in_range(0,0x7fff) ULONG cbData, > /* [unique][size_is][in] */ > __RPC__in_ecount_full_opt(cbData) BYTE *pbData) = 0; > > virtual HRESULT STDMETHODCALLTYPE ClearStylusQueues( void) = 0; > > virtual HRESULT STDMETHODCALLTYPE SetAllTabletsMode( > /* [in] */ BOOL fUseMouseForInput) = 0; > > virtual HRESULT STDMETHODCALLTYPE SetSingleTabletMode( > /* [in] */ __RPC__in_opt IInkTablet *piTablet) = 0; > > virtual HRESULT STDMETHODCALLTYPE GetTablet( > /* [retval][out] */ __RPC__deref_out_opt IInkTablet > **ppiSingleTablet) = 0; > > virtual HRESULT STDMETHODCALLTYPE GetTabletContextIdFromTablet( > /* [in] */ __RPC__in_opt IInkTablet *piTablet, > /* [retval][out] */ __RPC__out TABLET_CONTEXT_ID *ptcid) = 0; > > virtual HRESULT STDMETHODCALLTYPE GetTabletFromTabletContextId( > /* [in] */ TABLET_CONTEXT_ID tcid, > /* [retval][out] */ __RPC__deref_out_opt IInkTablet > **ppiTablet) = 0; > > virtual HRESULT STDMETHODCALLTYPE GetAllTabletContextIds( > /* [out][in] */ __RPC__inout ULONG *pcTcidCount, > /* [size_is][size_is][out] */ > __RPC__deref_out_ecount_full_opt(*pcTcidCount) TABLET_CONTEXT_ID > **ppTcids) = 0; > > virtual HRESULT STDMETHODCALLTYPE GetStyluses( > /* [retval][out] */ __RPC__deref_out_opt IInkCursors > **ppiInkCursors) = 0; > > virtual HRESULT STDMETHODCALLTYPE GetStylusForId( > /* [in] */ STYLUS_ID sid, > /* [retval][out] */ __RPC__deref_out_opt IInkCursor > **ppiInkCursor) = 0; > > virtual HRESULT STDMETHODCALLTYPE SetDesiredPacketDescription( > /* [range][in] */ __RPC__in_range(0,32) ULONG cProperties, > /* [size_is][in] */ __RPC__in_ecount_full(cProperties) > const GUID *pPropertyGuids) = 0; > > virtual HRESULT STDMETHODCALLTYPE GetDesiredPacketDescription( > /* [out][in] */ __RPC__inout ULONG *pcProperties, > /* [size_is][size_is][out] */ > __RPC__deref_out_ecount_full_opt(*pcProperties) GUID > **ppPropertyGuids) = 0; > > virtual HRESULT STDMETHODCALLTYPE GetPacketDescriptionData( > /* [in] */ TABLET_CONTEXT_ID tcid, > /* [unique][out][in] */ __RPC__inout_opt FLOAT *pfInkToDeviceScaleX, > /* [unique][out][in] */ __RPC__inout_opt FLOAT *pfInkToDeviceScaleY, > /* [out][in] */ __RPC__inout ULONG *pcPacketProperties, > /* [size_is][size_is][out] */ > __RPC__deref_out_ecount_full_opt(*pcPacketProperties) PACKET_PROPERTY > **ppPacketProperties) = 0; > > }; > > #else /* C style interface */ > > typedef struct IRealTimeStylusVtbl > { > BEGIN_INTERFACE > > HRESULT ( STDMETHODCALLTYPE *QueryInterface )( > __RPC__in IRealTimeStylus * This, > /* [in] */ __RPC__in REFIID riid, > /* [annotation][iid_is][out] */ > __RPC__deref_out void **ppvObject); > > ULONG ( STDMETHODCALLTYPE *AddRef )( > __RPC__in IRealTimeStylus * This); > > ULONG ( STDMETHODCALLTYPE *Release )( > __RPC__in IRealTimeStylus * This); > > /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Enabled )( > __RPC__in IRealTimeStylus * This, > /* [retval][out] */ __RPC__out BOOL *pfEnable); > > /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Enabled )( > __RPC__in IRealTimeStylus * This, > /* [in] */ BOOL fEnable); > > /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_HWND )( > __RPC__in IRealTimeStylus * This, > /* [retval][out] */ __RPC__out HANDLE_PTR *phwnd); > > /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_HWND )( > __RPC__in IRealTimeStylus * This, > /* [in] */ HANDLE_PTR hwnd); > > /* [propget] */ HRESULT ( STDMETHODCALLTYPE > *get_WindowInputRectangle )( > __RPC__in IRealTimeStylus * This, > /* [retval][out] */ __RPC__out RECT *prcWndInputRect); > > /* [propput] */ HRESULT ( STDMETHODCALLTYPE > *put_WindowInputRectangle )( > __RPC__in IRealTimeStylus * This, > /* [in] */ __RPC__in const RECT *prcWndInputRect); > > HRESULT ( STDMETHODCALLTYPE *AddStylusSyncPlugin )( > __RPC__in IRealTimeStylus * This, > /* [in] */ ULONG iIndex, > /* [in] */ __RPC__in_opt IStylusSyncPlugin *piPlugin); > > HRESULT ( STDMETHODCALLTYPE *RemoveStylusSyncPlugin )( > __RPC__in IRealTimeStylus * This, > /* [in] */ ULONG iIndex, > /* [out][in] */ __RPC__deref_inout_opt IStylusSyncPlugin > **ppiPlugin); > > HRESULT ( STDMETHODCALLTYPE *RemoveAllStylusSyncPlugins )( > __RPC__in IRealTimeStylus * This); > > HRESULT ( STDMETHODCALLTYPE *GetStylusSyncPlugin )( > __RPC__in IRealTimeStylus * This, > /* [in] */ ULONG iIndex, > /* [out] */ __RPC__deref_out_opt IStylusSyncPlugin **ppiPlugin); > > HRESULT ( STDMETHODCALLTYPE *GetStylusSyncPluginCount )( > __RPC__in IRealTimeStylus * This, > /* [out] */ __RPC__out ULONG *pcPlugins); > > HRESULT ( STDMETHODCALLTYPE *AddStylusAsyncPlugin )( > __RPC__in IRealTimeStylus * This, > /* [in] */ ULONG iIndex, > /* [in] */ __RPC__in_opt IStylusAsyncPlugin *piPlugin); > > HRESULT ( STDMETHODCALLTYPE *RemoveStylusAsyncPlugin )( > __RPC__in IRealTimeStylus * This, > /* [in] */ ULONG iIndex, > /* [out][in] */ __RPC__deref_inout_opt IStylusAsyncPlugin > **ppiPlugin); > > HRESULT ( STDMETHODCALLTYPE *RemoveAllStylusAsyncPlugins )( > __RPC__in IRealTimeStylus * This); > > HRESULT ( STDMETHODCALLTYPE *GetStylusAsyncPlugin )( > __RPC__in IRealTimeStylus * This, > /* [in] */ ULONG iIndex, > /* [out] */ __RPC__deref_out_opt IStylusAsyncPlugin **ppiPlugin); > > HRESULT ( STDMETHODCALLTYPE *GetStylusAsyncPluginCount )( > __RPC__in IRealTimeStylus * This, > /* [out] */ __RPC__out ULONG *pcPlugins); > > /* [propget] */ HRESULT ( STDMETHODCALLTYPE > *get_ChildRealTimeStylusPlugin )( > __RPC__in IRealTimeStylus * This, > /* [retval][out] */ __RPC__deref_out_opt IRealTimeStylus **ppiRTS); > > /* [propputref] */ HRESULT ( STDMETHODCALLTYPE > *putref_ChildRealTimeStylusPlugin )( > __RPC__in IRealTimeStylus * This, > /* [unique][in] */ __RPC__in_opt IRealTimeStylus *piRTS); > > HRESULT ( STDMETHODCALLTYPE *AddCustomStylusDataToQueue )( > __RPC__in IRealTimeStylus * This, > /* [in] */ StylusQueue sq, > /* [in] */ __RPC__in const GUID *pGuidId, > /* [range][in] */ __RPC__in_range(0,0x7fff) ULONG cbData, > /* [unique][size_is][in] */ > __RPC__in_ecount_full_opt(cbData) BYTE *pbData); > > HRESULT ( STDMETHODCALLTYPE *ClearStylusQueues )( > __RPC__in IRealTimeStylus * This); > > HRESULT ( STDMETHODCALLTYPE *SetAllTabletsMode )( > __RPC__in IRealTimeStylus * This, > /* [in] */ BOOL fUseMouseForInput); > > HRESULT ( STDMETHODCALLTYPE *SetSingleTabletMode )( > __RPC__in IRealTimeStylus * This, > /* [in] */ __RPC__in_opt IInkTablet *piTablet); > > HRESULT ( STDMETHODCALLTYPE *GetTablet )( > __RPC__in IRealTimeStylus * This, > /* [retval][out] */ __RPC__deref_out_opt IInkTablet > **ppiSingleTablet); > > HRESULT ( STDMETHODCALLTYPE *GetTabletContextIdFromTablet )( > __RPC__in IRealTimeStylus * This, > /* [in] */ __RPC__in_opt IInkTablet *piTablet, > /* [retval][out] */ __RPC__out TABLET_CONTEXT_ID *ptcid); > > HRESULT ( STDMETHODCALLTYPE *GetTabletFromTabletContextId )( > __RPC__in IRealTimeStylus * This, > /* [in] */ TABLET_CONTEXT_ID tcid, > /* [retval][out] */ __RPC__deref_out_opt IInkTablet **ppiTablet); > > HRESULT ( STDMETHODCALLTYPE *GetAllTabletContextIds )( > __RPC__in IRealTimeStylus * This, > /* [out][in] */ __RPC__inout ULONG *pcTcidCount, > /* [size_is][size_is][out] */ > __RPC__deref_out_ecount_full_opt(*pcTcidCount) TABLET_CONTEXT_ID > **ppTcids); > > HRESULT ( STDMETHODCALLTYPE *GetStyluses )( > __RPC__in IRealTimeStylus * This, > /* [retval][out] */ __RPC__deref_out_opt IInkCursors > **ppiInkCursors); > > HRESULT ( STDMETHODCALLTYPE *GetStylusForId )( > __RPC__in IRealTimeStylus * This, > /* [in] */ STYLUS_ID sid, > /* [retval][out] */ __RPC__deref_out_opt IInkCursor **ppiInkCursor); > > HRESULT ( STDMETHODCALLTYPE *SetDesiredPacketDescription )( > __RPC__in IRealTimeStylus * This, > /* [range][in] */ __RPC__in_range(0,32) ULONG cProperties, > /* [size_is][in] */ __RPC__in_ecount_full(cProperties) > const GUID *pPropertyGuids); > > HRESULT ( STDMETHODCALLTYPE *GetDesiredPacketDescription )( > __RPC__in IRealTimeStylus * This, > /* [out][in] */ __RPC__inout ULONG *pcProperties, > /* [size_is][size_is][out] */ > __RPC__deref_out_ecount_full_opt(*pcProperties) GUID > **ppPropertyGuids); > > HRESULT ( STDMETHODCALLTYPE *GetPacketDescriptionData )( > __RPC__in IRealTimeStylus * This, > /* [in] */ TABLET_CONTEXT_ID tcid, > /* [unique][out][in] */ __RPC__inout_opt FLOAT *pfInkToDeviceScaleX, > /* [unique][out][in] */ __RPC__inout_opt FLOAT *pfInkToDeviceScaleY, > /* [out][in] */ __RPC__inout ULONG *pcPacketProperties, > /* [size_is][size_is][out] */ > __RPC__deref_out_ecount_full_opt(*pcPacketProperties) PACKET_PROPERTY > **ppPacketProperties); > > END_INTERFACE > } IRealTimeStylusVtbl; > > interface IRealTimeStylus > { > CONST_VTBL struct IRealTimeStylusVtbl *lpVtbl; > }; > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From skippy.hammond at gmail.com Fri Oct 9 07:05:38 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 09 Oct 2009 16:05:38 +1100 Subject: [python-win32] Library not Registered Error while running In-Reply-To: References: Message-ID: <4ACEC4A2.10006@gmail.com> On 7/10/2009 1:41 AM, David Wormser wrote: > I started getting this error message yesterday. I can use system restore > to eliminate it but it returns when ever I try to follow any links. Do > you have a permanent fix? It's not clear how this relates to Python - if it does you will need to provide much more information. Mark From dreadpiratejeff at gmail.com Fri Oct 9 16:28:21 2009 From: dreadpiratejeff at gmail.com (J) Date: Fri, 9 Oct 2009 10:28:21 -0400 Subject: [python-win32] win32api documentation Message-ID: <36dec4ff0910090728k37cd9954rabe430514f550cbc@mail.gmail.com> Hi everyone... I've been searching high and low looking for any sort of decent reference for the win32api in python and I can't find anything that is useful. The only real explanation I've found is the msdn site, but as I'm not a C programmer, translating the various calls to python and guessing what the python functions are called is probably an exercise in futility at best. So I wanted to start off by asking if any of you can point me to some site or document that lists the various python calls to the win32api. What I'm trying to do ultimately, is improve our testing scripts, which are all python. They are cross-platform and geared to run on both windows and Linux systems in test. The linux side is fairly trivial, as I am pretty intimate with getting what I want from a Linux system. However, getting that info, programmatically in Windows is new ground for me and because I want this stuff to be as light as possible, and portable, I don't want to rely on a bunch of extra Windows tools to get the info. The win32api has the calls I need, I just need help or a reference to get them over to python. So what I'm trying to do for now, is fairly simple. I just want to be able to make a couple calls and get system info like the number of processor packages, the number of processor cores, processor flags (if possible), free mem, total mem, OS version and a few other tidbits of system information. Any ideas that will help me get a clue? Jeff -- Stephen Leacock - "I detest life-insurance agents: they always argue that I shall some day die, which is not so." - http://www.brainyquote.com/quotes/authors/s/stephen_leacock.html From mail at timgolden.me.uk Fri Oct 9 17:06:08 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 09 Oct 2009 16:06:08 +0100 Subject: [python-win32] win32api documentation In-Reply-To: <36dec4ff0910090728k37cd9954rabe430514f550cbc@mail.gmail.com> References: <36dec4ff0910090728k37cd9954rabe430514f550cbc@mail.gmail.com> Message-ID: <4ACF5160.8000805@timgolden.me.uk> J wrote: > I've been searching high and low looking for any sort of decent > reference for the win32api in python and I can't find anything that is > useful. There isn't much, in spite of a few attempts (my own included) to get something going. There's never enough time... Ultimately, the win32api calls *are* wrapping the MSDN calls almost directly so you just have to dive in, but ... > So what I'm trying to do for now, is fairly simple. I just want to be > able to make a couple calls and get system info like the number of > processor packages, the number of processor cores, processor flags (if > possible), free mem, total mem, OS version and a few other tidbits of > system information. Here at least I can help. Try using WMI which eats this kind of thing for breakfast[*]. Start here: http://timgolden.me.uk/python/wmi.html taking in this: http://timgolden.me.uk/python/wmi-tutorial.html and this: http://timgolden.me.uk/python/wmi_cookbook.html and feel free to get back with specifics. TJG [*] I hope :) From dreadpiratejeff at gmail.com Fri Oct 9 17:20:47 2009 From: dreadpiratejeff at gmail.com (J) Date: Fri, 9 Oct 2009 11:20:47 -0400 Subject: [python-win32] win32api documentation In-Reply-To: <4ACF5160.8000805@timgolden.me.uk> References: <36dec4ff0910090728k37cd9954rabe430514f550cbc@mail.gmail.com> <4ACF5160.8000805@timgolden.me.uk> Message-ID: <36dec4ff0910090820v1bbd095icaea5c5e0ecf55e@mail.gmail.com> On Fri, Oct 9, 2009 at 11:06, Tim Golden wrote: > Here at least I can help. Try using WMI which eats this kind of > thing for breakfast[*]. Start here: > > ?http://timgolden.me.uk/python/wmi.html > > taking in this: > > ?http://timgolden.me.uk/python/wmi-tutorial.html > > and this: > > ?http://timgolden.me.uk/python/wmi_cookbook.html > > and feel free to get back with specifics. Awesome! Thanks a lot. I'll dig into that after lunch. I finally stumbled on the ActiveState info on win32api with a ref for all the calls, and I'll have to do a little more digging. I found out finally how to pull SYSTEM_INFO (turns out it IS farily trivial) but now I have other things to figure out (which is nice, as it actually gives me something to do while I'm waiting on the next project to start). I can pull most of what I need now after finding the ActiveState reference, but specifically, I'm having trouble with: Number of logical processors (counting cores with and without HyperThreading enabled in BIOS) Number of processor packages Total system RAM Available RAM I think I can figure out the RAM, but right now it's the processor counting and info that's dogging me. Anyway, like I said, I'll dig into the WMI stuff in a bit after a nice break from the lab and this nasty chair. Thanks a lot for the pointers! Jeff -- Ogden Nash - "The trouble with a kitten is that when it grows up, it's always a cat." - http://www.brainyquote.com/quotes/authors/o/ogden_nash.html From admin at dmarkey.com Fri Oct 9 17:42:10 2009 From: admin at dmarkey.com (David) Date: Fri, 9 Oct 2009 16:42:10 +0100 Subject: [python-win32] SSPI/NTLM authentication via XMLRPC In-Reply-To: <4ACEC585.1040600@gmail.com> References: <6894a6470910081611t24da4be8r77370a4fe1061595@mail.gmail.com> <4ACEC585.1040600@gmail.com> Message-ID: <6894a6470910090842m6cd745f3t7b8509ff091047a8@mail.gmail.com> Thanks, Sorry for not doing my homework but what does the "auth dance" entail, how many backwards and forwards would there be, seeing as every bit of data would have to be encapsulated via xmlrpc, would that potentially mean many calls? On Fri, Oct 9, 2009 at 6:09 AM, Mark Hammond wrote: > On 9/10/2009 10:11 AM, David wrote: > >> Hi, >> >> I was wondering if this would be possible: >> >> At the minute i have a login xmlrpc call that takes a username/password >> as an argument. simple enough, authenticates off the windows domain via >> LogonUser(pywin32), the user then gets a cookie for the session(to >> execute further xmlrpc calls). >> >> I was wondering if it would be possible to achieve SSO using SSPI/NTLM >> via XMLRPC? >> >> I see an example in win32/Demos/sspi/socket_server.py, im not sure if >> something similar could be used via XMLRPC. >> > > Off the top of my head I can't see why not if you control both the client > and the server and don't mind making them do an auth dance to set things up > - you probably want to check out the simple_auth.py sample for some idea of > how it could be implemented. > > Cheers, > > Mark > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Fri Oct 9 17:34:14 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 09 Oct 2009 16:34:14 +0100 Subject: [python-win32] win32api documentation In-Reply-To: <36dec4ff0910090820v1bbd095icaea5c5e0ecf55e@mail.gmail.com> References: <36dec4ff0910090728k37cd9954rabe430514f550cbc@mail.gmail.com> <4ACF5160.8000805@timgolden.me.uk> <36dec4ff0910090820v1bbd095icaea5c5e0ecf55e@mail.gmail.com> Message-ID: <4ACF57F6.2080400@timgolden.me.uk> J wrote: > Awesome! Thanks a lot. I'll dig into that after lunch. I finally > stumbled on the ActiveState info on win32api with a ref for all the > calls, and I'll have to do a little more digging. Well that's simply a copy of the CHM which is provided with the pywin32 installation. I host another copy over here: http://timgolden.me.uk/pywin32-docs/contents.html for private entertainment. It's fairly searchable using Google, eg: http://www.google.co.uk/search?q=site%3Atimgolden.me.uk%2Fpywin32-docs+EnumProcesses and has a bit of breadcrumbness about it to help you out. But, as I say, it's merely an online copy of the .chm which is itself eminently searchable. I found out finally > how to pull SYSTEM_INFO (turns out it IS farily trivial) but now I > have other things to figure out (which is nice, as it actually gives > me something to do while I'm waiting on the next project to start). > > I can pull most of what I need now after finding the ActiveState > reference, but specifically, I'm having trouble with: > > Number of logical processors (counting cores with and without > HyperThreading enabled in BIOS) > Number of processor packages > Total system RAM > Available RAM > > I think I can figure out the RAM, but right now it's the processor > counting and info that's dogging me. > > Anyway, like I said, I'll dig into the WMI stuff in a bit after a nice > break from the lab and this nasty chair. Although I'm the author of the Python wmi module, WMI itself covers such a huge area that I have absolutely no pretence at comprehensive knowledge. Faced with queries such as yours, I'd normally just stick, eg, "available ram wmi" into Google and go from there. There's lots of info out there aimed at C or vbs developers; translating it into Python's usually not too hard. TJG From efotinis at yahoo.com Fri Oct 9 18:19:52 2009 From: efotinis at yahoo.com (Elias Fotinis) Date: Fri, 9 Oct 2009 19:19:52 +0300 Subject: [python-win32] PythonWin Grep modifications Message-ID: <62701E6B0F1948DABDD7950A17DBD1A1@efcore> I've made some modifications to PythonWin's Grep functionality. At first I just wanted to add highlighting for the regex matches, but I guess I got carried away. :b I'll eventually submit it to SourceForge, so that Mark may include it in the official release if he wants. In the meantime, here's the current version: http://www.mediafire.com/file/mmjntzmjwmm/sgrepmdi.py To test it, replace "pythonwin\pywin\framework\sgrepmdi.py". If anyone's got any more suggestions, fire away. Here's a list of the changes so far: Functionality: - added match highlighting - replaced editboxes with combos to store MRU items - added keyboard handling: - Enter opens match (same as double-click) - AppMenu opens context menu (same as right-click) - added support for registry root key shorthands ('HKLM', 'HKCU', etc.) - added folder selection via common dlg - changed settings INI location to %AppData%; originally it defaulted to %WinDir% which wouldn't allow writing in Vista - made richedit control readonly Code & UI: - added a couple of comments, docstrings, and constants - added SearchOptions, PathSet, IniFile - replaced list-based dir/file/mask traversal with a generator - added msgboxes for Open/Save errors - added specific types to except clauses - replaced glob() with os.listdir() (glob() chokes on dirnames with square brackets) - replaced 'MS Sans Serif' dlg font with 'MS Shell Dlg' - tweaked dlg layouts and added a couple of icons BUGS: - setting text format is off by 1 sometimes (e.g. XP vs. Vista); maybe richedit EOL related - saved results file has junk at the end and uses \n as EOL - dirs and files are not generated in sorted order - context menu should be shown over the richedit cursor (not the mouse) when opened with the keyboard - right-clicking should move the caret before showing the context menu TODO: - tweak "More" dialog and rename to "Favorites" - keyboard: make Delete remove whole match line - add options for fonts, colors, regex (e.g. highlight all matches, not just first) - test on Python 3 From theller at ctypes.org Fri Oct 9 20:43:55 2009 From: theller at ctypes.org (Thomas Heller) Date: Fri, 09 Oct 2009 20:43:55 +0200 Subject: [python-win32] How to use COM when there isn't a type library or IDL file In-Reply-To: <4ACEC618.5000806@gmail.com> References: <51ae820a0910050858u3a87582dhf7bea1700e9110f7@mail.gmail.com> <4ACEC618.5000806@gmail.com> Message-ID: Mark Hammond schrieb: > This is very tricky to do in pure-python. Other interfaces with this > issue (eg, the shell interfaces) tend to use custom c++ code (often > generated by the 'makegw' package then heavily edited) to implement a > win32com 'sub-module'. The best alternative for you may be to > investigate how comtypes might help... comtypes: If neither a type library nor an idl file is available, then you can still create the interface definition manually. You can probably, given some experience, define the interface by looking at the header file. I started this for the first few methods of the IRealTimeStylus interface: """ # module realtimestylus.py from ctypes import * from ctypes.wintypes import * from comtypes import IUnknown from comtypes import GUID from comtypes import COMMETHOD class IRealTimeStylus(IUnknown): _iid_ = GUID('{A8BB5D22-3144-4A7B-93CD-F34A16BE513A}') IRealTimeStylus._methods_ = [ COMMETHOD(['propget'], HRESULT, 'Enabled', ( ['retval', 'out'], POINTER(c_int), 'pfEnable' )), COMMETHOD(['propput'], HRESULT, 'Enabled', ( ['in'], c_int, 'pfEnable' )), COMMETHOD(['propget'], HRESULT, 'HWND', ( ['retval', 'out'], POINTER(c_int), 'phwnd' )), COMMETHOD(['propput'], HRESULT, 'HWND', ( ['in'], c_int, 'phwnd' )), COMMETHOD(['propget'], HRESULT, 'WindowInputRectangle', ( ['retval', 'out'], POINTER(RECT), 'prcWndInputRect' )), COMMETHOD(['propput'], HRESULT, 'WindowInputRectangle', ( ['in'], c_int, 'prcWndInputRect' )), # here are quite some methods missing... ] """ Then you can create such an object, QI for the interface, and try to use it. I had to look up the CLSID for the RealTimeStylus class in the registry. >>> p = CreateObject("{E26B366D-F998-43CE-836F-CB6D904432B0}") >>> print p >>> p.QueryInterface(IRealTimeStylus) >>> s = p.QueryInterface(IRealTimeStylus) >>> s.Enabled 0 >>> s.Enabled = 1 Traceback (most recent call last): File "", line 1, in File "comtypes\__init__.py", line 278, in __setattr__ value) _ctypes.COMError: (-2144862203, 'The clear disable flag is set and all clear operations now require physical access.', (None, None, None, 0, None)) >>> However, I would only recommend this approach to an experienced COM developer. Thomas From dreadpiratejeff at gmail.com Mon Oct 12 17:54:33 2009 From: dreadpiratejeff at gmail.com (J) Date: Mon, 12 Oct 2009 11:54:33 -0400 Subject: [python-win32] win32api documentation In-Reply-To: <4ACF57F6.2080400@timgolden.me.uk> References: <36dec4ff0910090728k37cd9954rabe430514f550cbc@mail.gmail.com> <4ACF5160.8000805@timgolden.me.uk> <36dec4ff0910090820v1bbd095icaea5c5e0ecf55e@mail.gmail.com> <4ACF57F6.2080400@timgolden.me.uk> Message-ID: <36dec4ff0910120854w372bb51dofd2610ecefae864e@mail.gmail.com> Ok... that all helped a lot. I've been playing around with memory a bit, and cache, and I'll poke at that some more later. Today I've been looking into processors. So WMI provides Win32_Processor and from what I've read, there exists one instance of Win32_Processor for each processor on a SMP machine. So for starters, I assume then that if I had one such machine, I could count all the cores simply by doing something like: for p in c.Win32_Processor : procCount = procCount + 1 which makes sense. Now that I look at it, I seem to be able to pull information based on each core, and I can count cores. But what about counting processor sockets or packages? For example, Lets say, I do that simple loop and get a return of 16. How do I differentiate between 16 cores, or 8 cores with HyperThreading turned on? Admittedly, that's more an educational curiosity. The systems I'll be using all this on are readily accessible, and we'll know ahead of time that System A has 2 4-core processors and that we turned HT off in BIOS, so we should only see 8 logical processors when we test. Any delta from that will fail the test. So like I said, I was just curious if there is any built in way via WMI or whatever to differentiate without having to go and manually create a class based on the Windows API (because I'm not good enough to do that kind of work). Either way, thanks for the help so far, the WMI wrapper is pretty cool. I've never written system level code before, beyond instrumenting some device drivers and services to see why they break, so this has been pretty fun so far as a learning experience. Cheers Jeff -- Pablo Picasso - "Computers are useless. They can only give you answers." - http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html From mail at timgolden.me.uk Mon Oct 12 18:13:11 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 12 Oct 2009 17:13:11 +0100 Subject: [python-win32] win32api documentation In-Reply-To: <36dec4ff0910120854w372bb51dofd2610ecefae864e@mail.gmail.com> References: <36dec4ff0910090728k37cd9954rabe430514f550cbc@mail.gmail.com> <4ACF5160.8000805@timgolden.me.uk> <36dec4ff0910090820v1bbd095icaea5c5e0ecf55e@mail.gmail.com> <4ACF57F6.2080400@timgolden.me.uk> <36dec4ff0910120854w372bb51dofd2610ecefae864e@mail.gmail.com> Message-ID: <4AD35597.2050802@timgolden.me.uk> J wrote: > Ok... that all helped a lot. I've been playing around with memory a > bit, and cache, and I'll poke at that some more later. Today I've > been looking into processors. > > So WMI provides Win32_Processor and from what I've read, there exists > one instance of Win32_Processor for each processor on a SMP machine. > > So for starters, I assume then that if I had one such machine, I could > count all the cores simply by doing something like: > > for p in c.Win32_Processor : > procCount = procCount + 1 > > which makes sense. Ummm. Not quite. c.Win32_Processor is a class-ish thing which you have to call to pull back the *list* of instances. Which you can then just count. So something like this: n_processors = len (c.Win32_Processor ()) I can't at this moment remember how the c.Win32_Processor interacts with physical processors, multicore processors and hyperthreading. It's probably documented somewhere, and a little experimentation should give you answers quite easily. That's the great thing with Python: you just fire up the interpreter and get the answer! > Now that I look at it, I seem to be able to pull information based on > each core, and I can count cores. But what about counting processor > sockets or packages? For example, > > Lets say, I do that simple loop and get a return of 16. > > How do I differentiate between 16 cores, or 8 cores with > HyperThreading turned on? > > Admittedly, that's more an educational curiosity. The systems I'll be > using all this on are readily accessible, and we'll know ahead of time > that System A has 2 4-core processors and that we turned HT off in > BIOS, so we should only see 8 logical processors when we test. Any > delta from that will fail the test. > > So like I said, I was just curious if there is any built in way via > WMI or whatever to differentiate without having to go and manually > create a class based on the Windows API (because I'm not good enough > to do that kind of work). This is definitely the place to look for this kind of information: http://msdn.microsoft.com/en-us/library/aa394373%28VS.85%29.aspx unfortunately, some of the useful information like NumberOfCores and NumberOfLogicalProcessors seems to be available only on the very latest releases. Might be an issue for you? > > Either way, thanks for the help so far, the WMI wrapper is pretty > cool. I've never written system level code before, beyond > instrumenting some device drivers and services to see why they break, > so this has been pretty fun so far as a learning experience. Glad it's been useful. I'm just releasing a new version of the Python module which includes a little web server whichi lets you browse around the classes to a limited extent. If you're interested, let me know. TJG From dreadpiratejeff at gmail.com Tue Oct 13 18:17:05 2009 From: dreadpiratejeff at gmail.com (J) Date: Tue, 13 Oct 2009 12:17:05 -0400 Subject: [python-win32] win32api documentation In-Reply-To: <4AD35597.2050802@timgolden.me.uk> References: <36dec4ff0910090728k37cd9954rabe430514f550cbc@mail.gmail.com> <4ACF5160.8000805@timgolden.me.uk> <36dec4ff0910090820v1bbd095icaea5c5e0ecf55e@mail.gmail.com> <4ACF57F6.2080400@timgolden.me.uk> <36dec4ff0910120854w372bb51dofd2610ecefae864e@mail.gmail.com> <4AD35597.2050802@timgolden.me.uk> Message-ID: <36dec4ff0910130917m62cc09e9p7ff27495b9f2e292@mail.gmail.com> On Mon, Oct 12, 2009 at 12:13, Tim Golden wrote: > Ummm. Not quite. > > c.Win32_Processor is a class-ish thing which you have to call to > pull back the *list* of instances. Which you can then just > count. So something like this: > > n_processors = len (c.Win32_Processor ()) Thanks for saving me from a dumb mistake ;-) > I can't at this moment remember how the c.Win32_Processor interacts > with physical processors, multicore processors and hyperthreading. > It's probably documented somewhere, and a little experimentation > should give you answers quite easily. That's the great thing with > Python: you just fire up the interpreter and get the answer! And it does indeed work. We're using the latest 2.6, and so far everything has worked well. NumberOfCores and NumberOfLogicalProcessors does just what I hoped they would do, so now I have a small bit of n00b code: print "Getting processor information now...\n" numProcs = len(c.Win32_Processor ()) print "Number of Processor Packages found: " + str(numProcs) for p in c.Win32_Processor (): print "Number of processor cores: " + str(p.NumberOfCores) print "Number of Logical processors: " + str(p.NumberOfLogicalProcessors) if p.NumberOfCores != p.NumberOfLogicalProcessors : print "HyperThreading seems to be enabled." and that's enough to start. For now, I just need to be able to actually pull accurate information. Later on, I'll write a class for all this so the other scripts can reference them easily... but this way, I can check packages, cores and logicals, and whether or not HyperThreading is enabled; though my logic should be: if p.NumberOfLogicalProcessors == (p.NumberOfCores * 2) instead of just a !=. BUT, either way should work on any multi-core system I can think of. Know of any instance where that wouldn't work accurately? > This is definitely the place to look for this kind of information: > > http://msdn.microsoft.com/en-us/library/aa394373%28VS.85%29.aspx > > unfortunately, some of the useful information like NumberOfCores > and NumberOfLogicalProcessors seems to be available only on the > very latest releases. Might be an issue for you? THANKS! Once again, you're wisdom blows my mind ;-) and your link-fu. That was one of the things I had hoped to find as I was searching. That was exactly the kind of information I needed to get things going. Just a simple example and a brief explanation of what each item is, without diving into C or C++ and trying to translate that later. > Glad it's been useful. I'm just releasing a new version of the > Python module which includes a little web server whichi lets you > browse around the classes to a limited extent. If you're interested, > let me know. Sure... it'd be neat to play with. Like I've said before, this is going to be actually useful, but I'm doing it out of boredom and as a learning experience more than I am doing it to benefit work or anything like that. They don't pay me enough to really want to work for their benefit ;-) I have run into another issue though with the various Memory classes... I thought I was counting DIMMs, but I think I was just counting sockets. I thought I was totalling the amount of Physical memory, but instead I was getting the max supported for each socket... I've tried CIM_OperatingSystem (which works and gives me the free physical memory). I've also tried Win32_*Memory* classes as well as CIM_Memory, and none of those have successfully given me the actual physical memory. for each class, NumberOfBlocks either returns nothing, or returns the wrong information. I've got 4 256MB DIMMs in my desktop, which is what I'm using to work on this right now. Hopefully, they'll find me something with more DIMMs and higher capacity to play with to make sure this will work on systems other than my desktop... But for now, all I'm ending up with is the max capacity for the system (4GB) not the total installed (1GB)... I can't seem to find the right Memory related class to get either the amount present per dimm or the total physical amount present. I'm still looking into that... and that'll probably be my day. thankfully, they don't really have much at all for me to officially do right now, so I've got plenty of time to mess around with this and see what different things do. Cheers Jeff -- Jonathan Swift - "May you live every day of your life." - http://www.brainyquote.com/quotes/authors/j/jonathan_swift.html From mail at timgolden.me.uk Tue Oct 13 18:33:10 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 13 Oct 2009 17:33:10 +0100 Subject: [python-win32] win32api documentation In-Reply-To: <36dec4ff0910130917m62cc09e9p7ff27495b9f2e292@mail.gmail.com> References: <36dec4ff0910090728k37cd9954rabe430514f550cbc@mail.gmail.com> <4ACF5160.8000805@timgolden.me.uk> <36dec4ff0910090820v1bbd095icaea5c5e0ecf55e@mail.gmail.com> <4ACF57F6.2080400@timgolden.me.uk> <36dec4ff0910120854w372bb51dofd2610ecefae864e@mail.gmail.com> <4AD35597.2050802@timgolden.me.uk> <36dec4ff0910130917m62cc09e9p7ff27495b9f2e292@mail.gmail.com> Message-ID: <4AD4ABC6.8050602@timgolden.me.uk> J wrote: > And it does indeed work. We're using the latest 2.6, and so far > everything has worked well. NumberOfCores and > NumberOfLogicalProcessors does just what I hoped they would do, so now > I have a small bit of n00b code: > > print "Getting processor information now...\n" I suspect you're coming from a C background? Or something similar. Python's a very versatile language and tries to help you avoid boilerplate. So you can do things like this: import wmi c = wmi.WMI () numProcs = len (c.Win32_Processor ()) print "Number ...:", numProcs # or print "Number ...: %s" % numProcs and likewise for your other print statement. (Watch out: print has become a function in Python 3.x). The percent-s thing works just like sprintf in C only with a Python touch: you can use a more restrictive %d %2.3f etc. but if you put %s, Python calls your object's __str__ method which will usually generate what you expect to see. > numProcs = len(c.Win32_Processor ()) > print "Number of Processor Packages found: " + str(numProcs) > for p in c.Win32_Processor (): > print "Number of processor cores: " + str(p.NumberOfCores) > print "Number of Logical processors: " + str(p.NumberOfLogicalProcessors) > if p.NumberOfCores != p.NumberOfLogicalProcessors : > print "HyperThreading seems to be enabled." >> This is definitely the place to look for this kind of information: >> >> http://msdn.microsoft.com/en-us/library/aa394373%28VS.85%29.aspx >> >> unfortunately, some of the useful information like NumberOfCores >> and NumberOfLogicalProcessors seems to be available only on the >> very latest releases. Might be an issue for you? > > THANKS! Once again, you're wisdom blows my mind ;-) and your link-fu. I blush. But in fact (he says, giving away all his secrets) my magic incantation was simply this: http://www.google.co.uk/search?q=site%3Amicrosoft.com+win32_processor Of course, I have done that once or twice before ;) >> Glad it's been useful. I'm just releasing a new version of the >> Python module which includes a little web server whichi lets you >> browse around the classes to a limited extent. If you're interested, >> let me know. > > Sure... it'd be neat to play with. Like I've said before, this is > going to be actually useful, but I'm doing it out of boredom and as a > learning experience more than I am doing it to benefit work or > anything like that. They don't pay me enough to really want to work > for their benefit ;-) I'll put a release notice out in the next day or two and let you know where you can get hold of it. > I have run into another issue though with the various Memory classes... [... snip rather specific Memory stuff ...] I'm afraid I've no particular insight here. I'm sure I can Google around a bit to see, but I'm sure you can too... Keep posting to the list and let's see if someone else has an idea. TJG From dreadpiratejeff at gmail.com Tue Oct 13 20:41:40 2009 From: dreadpiratejeff at gmail.com (J) Date: Tue, 13 Oct 2009 14:41:40 -0400 Subject: [python-win32] win32api documentation In-Reply-To: <4AD4ABC6.8050602@timgolden.me.uk> References: <36dec4ff0910090728k37cd9954rabe430514f550cbc@mail.gmail.com> <4ACF5160.8000805@timgolden.me.uk> <36dec4ff0910090820v1bbd095icaea5c5e0ecf55e@mail.gmail.com> <4ACF57F6.2080400@timgolden.me.uk> <36dec4ff0910120854w372bb51dofd2610ecefae864e@mail.gmail.com> <4AD35597.2050802@timgolden.me.uk> <36dec4ff0910130917m62cc09e9p7ff27495b9f2e292@mail.gmail.com> <4AD4ABC6.8050602@timgolden.me.uk> Message-ID: <36dec4ff0910131141l4ae6f66cu1f8d010fc0b60e6d@mail.gmail.com> On Tue, Oct 13, 2009 at 12:33, Tim Golden wrote: > I suspect you're coming from a C background? Or something > similar. Python's a very versatile language and tries to > help you avoid boilerplate. So you can do things like this: Yeah... similar, I guess. C++ to some degree, VB, Basic, a smattering of perl, Java, and so on... I can read C for the most part (even some of the nasty stuff at the OS and hardware level) but I couldn't really write C if my life depended on it. To be honest, I started working in Perl about 9 years ago, and got about half way through learning it when I discovered Python, and how much easier Python is to write as well as read (especially when reading someone else's code). So I started learning python then. Then I got laid off a few months later, and haven't really done anything with it in ages. So I still remember just enough Python to be dangerous, and I'm trying to re-learn it as I go along... > > import wmi > > c = wmi.WMI () > numProcs = len (c.Win32_Processor ()) > print "Number ...:", numProcs > # or > print "Number ...: %s" % numProcs > Yeah... there's a lot I need to pick up again... and that's probably the hardest part. I have no idea where to even start. Which is why I'm doing this little exercise. It'll get me some class writing, importing, and doing some other stuff, but I'll end up missing some of the most basic stuff, like output formatting and such... Though I was interested in finding the functions to output to stdout and stderr directly, which will be nice too... > I blush. But in fact (he says, giving away all his secrets) my > magic incantation was simply this: > > http://www.google.co.uk/search?q=site%3Amicrosoft.com+win32_processor > > Of course, I have done that once or twice before ;) Heh... honstly, outside of some nice long BASH scripts, this is the first chance in years that I've had to actually write real code. I was a "software engineer" for 6 years, and I very rarely ever engineered any software. Most of what I wrote were shell scripts, though some were rather complex and did some neat things. That's where I picked up the little bit of C I have, as I had to sometimes instrument drivers and user-space applications to find out why a particular test was failing, but that was limited use stuff. I have a very long history with the general theory of programming and writing code, but what I lack is current experience, and most importantly, the vocabulary. Which is why I'm asking so many basic questions that I really could eventually find on my own. I know WHAT I want to do with this program, I just don't know how to tell Python just yet, though I'm pretty close at least to a proof of concept. Just like I know WHAT I want to search the Google for, but I don't know exactly what words to search on, and in that last case, it was really so simple that it never even occurred to me. My second big failing... I sometimes overthink things. :-) My next Python project (which I'll probably start working on later this week as I get bored) is going to be a web CGI to search multiple craigslist sites and display links to matching hits. I know that's been done to death, but it's something I thought of long before the various aggregating sites started popping up, and it looks like it would be fun. Besides, it gives me a definite goal and a definite product that will get me back into some web programming too... something else I haven't done in ages. By the way, I also figured out my own issues with finding memory. CIM_OperatingSystem includes a TotalVisibleMemorySize attribute that is what I was looking for. I kept looking at things that had PhysicalMemory in their names and I missed that one until I read a little deeper into another WMI option... That one gives the total physical memory available to the OS, which is the total Physical minus any shared memory... so on this machine, my 1024MB ends up being 1022MB... which is close enough for my purposes. Cheers Jeff -- Samuel Goldwyn - "I'm willing to admit that I may not always be right, but I am never wrong." - http://www.brainyquote.com/quotes/authors/s/samuel_goldwyn.html From dave at godseyfamily.com Tue Oct 13 18:24:19 2009 From: dave at godseyfamily.com (David G) Date: Tue, 13 Oct 2009 10:24:19 -0600 Subject: [python-win32] dde trouble Message-ID: Hi Patrick, Did you ever get resolution to the dde error you were getting? Traceback (most recent call last): File "D:\Documents\Eclipse\z_test_ecotect\test1.py", line 11, in conversation.Exec("get.app.computer") error: Exec failed I am having the same error now. I am trying to communicate with the Zemax program and get this everytime. Thanks. David Godsey -------------- next part -------------- An HTML attachment was scrubbed... URL: From cappy2112 at gmail.com Wed Oct 14 05:39:30 2009 From: cappy2112 at gmail.com (Tony Cappellini) Date: Tue, 13 Oct 2009 20:39:30 -0700 Subject: [python-win32] Python and Windows Automation Message-ID: <8249c4ac0910132039g1fe6b314u1d477cf22c1ba6bd@mail.gmail.com> I'm curious what other users use for automating Windows & widgets with Python (on Windows platforms that is). By automating- I mean clicking buttons and activating check boxes, menus, maximizing/minimizing Windows, sending keystrokes, etc. >From what I've seen packages/frameworks like this are pretty scarce for Python. PyWinAuto was the only package that looked worthwhile using, but the documentation drove me crazy. I've opted for AutoIt3 which is a superb automation package, is mostly C-like, is open source, very popular, actively supported and extremely full-featured. I'd rather do it through Python if possible. AutoIt3 has COM support but only a measly subset is supported via COM. (I try to stay as far away from COM as possible, though even it it means I can use Python.I've had too many COM servers crash before a call returned, leaving the client hung) Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From shivisi at nana10.co.il Wed Oct 14 10:00:52 2009 From: shivisi at nana10.co.il (shivisi) Date: Wed, 14 Oct 2009 10:00:52 +0200 Subject: [python-win32] Passing Nothing into COM method Message-ID: <0665012E4232B3438D417A337610837B30D9A2@NANAMAILBACK3.nanamail.co.il> I am writing a COM addin, and attempting to trap the ItemAdded/ItemRemoved event in the following object: Application.VBE.Events.ReferencesEvents which is retrieved by passing Nothing as a paramter: Application.VBE.Events.ReferencesEvents(Nothing) Tim Golden wrote in the following post (http://mail.python.org/pipermail/python-win32/2009-February/008826.html) that pythoncom.Empty can be used for Nothing. However, when trying this: try: self.comRefevents=self.app.VBE.Events.ReferencesEvents(pythoncom.Empty) except pythoncom.com_error, (hr, msg, exc, arg): print "The call failed with code %d: %s" % (hr, msg) if exc is None: print "There is no extended error information" else: wcode, source, text, helpFile, helpId, scode = exc print "The source of the error is", source print "The error message is", text print "More info can be found in %s (id=%d)" % (helpFile, helpId) I get back the following (the same as if I had passed no arguments at all): The call failed with code -2147352561: Parameter not optional. There is no extended error information Eric Lippert states in his blog (http://blogs.msdn.com/ericlippert/archive/2004/07/14/183241.aspx): > A common alternative to passing a missing argument is to pass Nothing, Null, or Empty in VBScript, > null or undefined in JScript. Null and null pass VT_NULL, Empty and undefined pass VT_EMPTY, and > Nothing passes a VT_DISPATCH with no value dispatch object pointer. It would seem that VB's Nothing and Empty are two different things. If I try passing pythoncom.VT_DISPATCH, then I get the following traceback: ----------------------------------------------------------------------------------------------------------- Traceback (most recent call last): File "C:\Python26\lib\site-packages\win32com\universal.py", line 177, in dispatch retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None) File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 324, in _InvokeEx_ return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider) File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 649, in _invokeex_ return DesignatedWrapPolicy._invokeex_( self, dispid, lcid, wFlags, args, kwArgs, serviceProvider) File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 585, in _invokeex_ return func(*args) File "C:\Documents and Settings\ABG7\My Documents\Zevi\Python-COMAddin\VBACodeRepository.py", line 104, in OnConnection self.comRefevents=self.app.VBE.Events.ReferencesEvents(pythoncom.VT_DISPATCH) File "C:\Python26\lib\site-packages\win32com\gen_py\0002E157-0000-0000-C000-000000000046x0x5x3.py", line 145, in ReferencesEvents ret = self._oleobj_.InvokeTypes(202, LCID, 2, (13, 0), ((13, 1),),VBProject TypeError: The Python instance can not be converted to a COM object pythoncom error: Unexpected gateway error Traceback (most recent call last): File "C:\Python26\lib\site-packages\win32com\universal.py", line 177, in dispatch retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None) File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 324, in _InvokeEx_ return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider) File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 649, in _invokeex_ return DesignatedWrapPolicy._invokeex_( self, dispid, lcid, wFlags, args, kwArgs, serviceProvider) File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 585, in _invokeex_ return func(*args) File "C:\Documents and Settings\ABG7\My Documents\Python-COMAddin\VBACodeRepository.py", line 104, in OnConnection self.comRefevents=self.app.VBE.Events.ReferencesEvents(pythoncom.VT_DISPATCH) File "C:\Python26\lib\site-packages\win32com\gen_py\0002E157-0000-0000-C000-000000000046x0x5x3.py", line 145, in ReferencesEvents ret = self._oleobj_.InvokeTypes(202, LCID, 2, (13, 0), ((13, 1),),VBProject TypeError: The Python instance can not be converted to a COM object ----------------------------------------------------------------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From threaderslash at gmail.com Wed Oct 14 10:49:36 2009 From: threaderslash at gmail.com (Threader Slash) Date: Wed, 14 Oct 2009 19:49:36 +1100 Subject: [python-win32] win32com.client import problem Message-ID: Hi Everybody, I have 2 imports: import pythoncom from win32com.client import Dispatch if I run it on my Python 2.6 Console, it works nicely. However, when I go to Eclipse IDE, open a project, open a main.py file, and try run, it gives the error: import pythoncom ImportError: No module named pythoncom All other imports are working ok on Eclipse IDE -- e.g. import MySQLdb. Any suggestion about what is missing? All comments and suggestion are welcome. ThreaderSlash -------------- next part -------------- An HTML attachment was scrubbed... URL: From threaderslash at gmail.com Wed Oct 14 20:10:55 2009 From: threaderslash at gmail.com (Threader Slash) Date: Thu, 15 Oct 2009 05:10:55 +1100 Subject: [python-win32] win32com.client import problem : solved Message-ID: ---------- Forwarded message ---------- From: Dave Angel To: Threader Slash Date: Wed, 14 Oct 2009 07:04:21 -0400 Subject: Re: win32com.client import problem Threader Slash wrote: > Hi Everybody, > > I have 2 imports: > > import pythoncom > from win32com.client import Dispatch > > if I run it on my Python 2.6 Console, it works nicely. However, when I go > to > Eclipse IDE, open a project, open a main.py file, and try run, it gives the > error: > > import pythoncom > ImportError: No module named pythoncom > > All other imports are working ok on Eclipse IDE -- e.g. import MySQLdb. > > Any suggestion about what is missing? > > All comments and suggestion are welcome. > > ThreaderSlash > > > Two things to check, python version (sys.version), and sys.path. Add prints for the two of them at the beginning of your script, and try the script in both environments. If there are any differences, figure out how to reconfigure Eclipse to match what you've got at the console. DaveA ---------- ---------- ---------- ---------- -- hope this can help and save time for others too Here is what did and works: * copy the file mfc71.dll on windows\system32 * copy the same also on directories * copy the same to your directories Python26\DLLs and Python26\lib\site-packages\win32 * go to preferences : pydev : interpreter python : remove all the interpreter you have there. apply, ok. then add python 2.6 again, apply, ok. It will do the trick.......|:0), ThreaderSlash ---------- ---------- ---------- ---------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Thu Oct 15 07:30:39 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 15 Oct 2009 16:30:39 +1100 Subject: [python-win32] Python and ASP - failure on 2nd and subsequent page loads In-Reply-To: <32AA3A83235A25458AB5387177B883F8110C528AEE@MAIL.ith.local> References: <32AA3A83235A25458AB5387177B883F8110C528AEE@MAIL.ith.local> Message-ID: <4AD6B37F.4030108@gmail.com> On 6/10/2009 6:01 AM, Jon Southard wrote: > I would be grateful for any advice about a problem which is preventing > me from using Python for my current project. > > I am hoping to use Python 2.6 on the server side with Microsoft ASP [not > ASP.NET; version details below]. The behavior I see is: > > 1. Load very simple page [text below] into browser [Firefox or IE, > versions below]. Everything displays, fine. > 2. Exit browser, restart it, and reload the same page; or open a second > tab and load the same page. > 3. In either case, page fails to load, with error: > Python ActiveX Scripting Engine, ASP 0211 (0x80020009) > A built-in ASP object has been referenced, which is no longer valid. > If I edit the page in any way, or just ?touch? it, and refresh the > browser, the page will load correctly the first time, and then fail > again as described. Sorry for the delay. The problem seems to be caused by a silly bug in the axscript implementation. To fix the issue locally: * open 'win32comext/axscript/client/framework.py' * search for ResetNamesItems - you should find the function def at line 747. * Replace the implementation of that function with the one below: def ResetNamedItems(self): # Due to the way we work, we re-create persistent ones. existing = self.subItems self.subItems = {} for name, item in existing.iteritems(): item.Close() if item.flags & axscript.SCRIPTITEM_ISPERSISTENT: self.AddNamedItem(item.name, item.flags) Note that sadly this file uses tabs for indentation, so make sure you get that correct. Also unwrap any long lines which my mailer wrapped. * Restart IIS. After that I can successfully reload the Python ASP samples (and before that I too saw the symptoms you described). I will check that into cvs so the next pywin32 version will have that fixed. Cheers, Mark > > The page I am using has no actual Python scripting, just the LANGUAGE > directive and then the html and body tags with a little plain text. Of > course, things don?t get any better if I put in some actual Python. > > I found a five-year-old newsgroup posting with what seemed to be a > similar (but not identical) problem. This thread said that the problem > went away if server-side debugging was turned off. I have it turned off, > no effect. I also tried adding some Response object settings to disallow > cacheing, but these did not have any effect. > > Version Info: > > Python: 2.6.2 > PyWin: pywin32-214 (I ran the client\pyscript.py and server\axsite.py > scripts for setup) > Client OS: Windows XP Pro SP2 > Browsers: Firefox 3.0.14, IE 8.0.6 [identical bug] > Server: IIS 5.1 > > Note, I also tried using Python 3.1 with corresponding pywin, but I > could not get that to work with ASP at all; just got server 500 errors. > I?d prefer to use 2.6 anyway since I am fairly new to Python. > > I would be very grateful for any expert pointers on this, since if I > can?t solve it I will probably have to go use PHP, Javascript, or > something else. Thank you! > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From shivisi at nana10.co.il Thu Oct 15 13:50:45 2009 From: shivisi at nana10.co.il (shivisi) Date: Thu, 15 Oct 2009 13:50:45 +0200 Subject: [python-win32] Passing Nothing into ReferencesEvents - resolved, however can't bind events References: Message-ID: <0665012E4232B3438D417A337610837B30D9A4@NANAMAILBACK3.nanamail.co.il> Passing Application.VBE.Events.ReferencesEvents(None) works (at least at this point). However, when I try to bind to an event class, I get the error below. Any assistance, debugging suggestions, would be greatly appreciated. Thanks. # Code from win32com.client import Dispatch, DispatchWithEvents, getevents class RefEvents: def OnItemAdded(self,ref): print '--Event - Reference added' def OnItemRemoved(self,ref): print '--Event - Reference removed' acc=Dispatch('Access.Application') acc.Visible=True refsEvents=DispatchWithEvents(acc.VBE.Events.ReferencesEvents(None),RefEvents) #----------------------------------------------------------------------------- Traceback (most recent call last): File "", line 1, in File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 245, in DispatchWithEvents disp = Dispatch(clsid) File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx) File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 43, in __WrapDispatch return dynamic.Dispatch(dispatch, userName, WrapperClass, typeinfo, clsctx=clsctx) File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 118, in Dispatch typeinfo = IDispatch.GetTypeInfo() AttributeError: 'PyIUnknown' object has no attribute 'GetTypeInfo' #----------------------------------------------------------------------------- >>> acc.VBE.Events.ReferencesEvents > >>> acc.VBE.Events.ReferencesEvents(None) Original message: > I am writing a COM addin, and attempting to trap the ItemAdded/ItemRemoved event in the following object: > Application.VBE.Events.ReferencesEvents > which is retrieved by passing Nothing as a paramter: > Application.VBE.Events.ReferencesEvents(Nothing) > > Tim Golden wrote in the following post (http://mail.python.org/pipermail/python-win32/2009-February/008826.html) that pythoncom.Empty can be used for Nothing. However, when trying this: > > try: > self.comRefevents=self.app.VBE.Events.ReferencesEvents(pythoncom.Empty) > except pythoncom.com_error, (hr, msg, exc, arg): > print "The call failed with code %d: %s" % (hr, msg) > if exc is None: > print "There is no extended error information" > else: > wcode, source, text, helpFile, helpId, scode = exc > print "The source of the error is", source > print "The error message is", text > print "More info can be found in %s (id=%d)" % (helpFile, helpId) > > I get back the following (the same as if I had passed no arguments at all): > > The call failed with code -2147352561: Parameter not optional. > There is no extended error information > > Eric Lippert states in his blog (http://blogs.msdn.com/ericlippert/archive/2004/07/14/183241.aspx): > > A common alternative to passing a missing argument is to pass Nothing, Null, or Empty in VBScript, > > null or undefined in JScript. Null and null pass VT_NULL, Empty and undefined pass VT_EMPTY, and > > Nothing passes a VT_DISPATCH with no value dispatch object pointer. > It would seem that VB's Nothing and Empty are two different things. > > If I try passing pythoncom.VT_DISPATCH, then I get the following traceback: > > ----------------------------------------------------------------------------------------------------------- > Traceback (most recent call last): > File "C:\Python26\lib\site-packages\win32com\universal.py", line 177, in dispatch > retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None) > File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 324, in _InvokeEx_ > return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider) > File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 649, in _invokeex_ > return DesignatedWrapPolicy._invokeex_( self, dispid, lcid, wFlags, args, kwArgs, serviceProvider) > File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 585, in _invokeex_ > return func(*args) > File "C:\Documents and Settings\ABG7\My Documents\Zevi\Python-COMAddin\VBACodeRepository.py", line 104, in OnConnection > self.comRefevents=self.app.VBE.Events.ReferencesEvents(pythoncom.VT_DISPATCH) > File "C:\Python26\lib\site-packages\win32com\gen_py\0002E157-0000-0000-C000-000000000046x0x5x3.py", line 145, in ReferencesEvents > ret = self._oleobj_.InvokeTypes(202, LCID, 2, (13, 0), ((13, 1),),VBProject > TypeError: The Python instance can not be converted to a COM object > pythoncom error: Unexpected gateway error > > Traceback (most recent call last): > File "C:\Python26\lib\site-packages\win32com\universal.py", line 177, in dispatch > retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None) > File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 324, in _InvokeEx_ > return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider) > File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 649, in _invokeex_ > return DesignatedWrapPolicy._invokeex_( self, dispid, lcid, wFlags, args, kwArgs, serviceProvider) > File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 585, in _invokeex_ > return func(*args) > File "C:\Documents and Settings\ABG7\My Documents\Python-COMAddin\VBACodeRepository.py", line 104, in OnConnection > self.comRefevents=self.app.VBE.Events.ReferencesEvents(pythoncom.VT_DISPATCH) > File "C:\Python26\lib\site-packages\win32com\gen_py\0002E157-0000-0000-C000-000000000046x0x5x3.py", line 145, in ReferencesEvents > ret = self._oleobj_.InvokeTypes(202, LCID, 2, (13, 0), ((13, 1),),VBProject > TypeError: The Python instance can not be converted to a COM object -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/ms-tnef Size: 5288 bytes Desc: not available URL: From JSouthard at IntouchHealth.com Thu Oct 15 21:31:07 2009 From: JSouthard at IntouchHealth.com (Jon Southard) Date: Thu, 15 Oct 2009 12:31:07 -0700 Subject: [python-win32] Python and ASP - failure on 2nd and subsequent page loads In-Reply-To: <4AD6B37F.4030108@gmail.com> References: <32AA3A83235A25458AB5387177B883F8110C528AEE@MAIL.ith.local> <4AD6B37F.4030108@gmail.com> Message-ID: <32AA3A83235A25458AB5387177B883F8110F499D5B@MAIL.ith.local> Mark, thank you so much for this fix. I appreciate it. I have verified it as well, in all the problem scenarios. Much appreciated! Thank you! Jon Southard From skippy.hammond at gmail.com Fri Oct 16 02:00:27 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 16 Oct 2009 11:00:27 +1100 Subject: [python-win32] Passing Nothing into ReferencesEvents - resolved, however can't bind events In-Reply-To: <0665012E4232B3438D417A337610837B30D9A4@NANAMAILBACK3.nanamail.co.il> References: <0665012E4232B3438D417A337610837B30D9A4@NANAMAILBACK3.nanamail.co.il> Message-ID: <4AD7B79B.4000608@gmail.com> On 15/10/2009 10:50 PM, shivisi wrote: > Passing Application.VBE.Events.ReferencesEvents(None) works (at least at this point). > However, when I try to bind to an event class, I get the error below. > Any assistance, debugging suggestions, would be greatly appreciated. > Thanks. > > # Code > from win32com.client import Dispatch, DispatchWithEvents, getevents > > class RefEvents: > def OnItemAdded(self,ref): > print '--Event - Reference added' > def OnItemRemoved(self,ref): > print '--Event - Reference removed' > > acc=Dispatch('Access.Application') > acc.Visible=True > refsEvents=DispatchWithEvents(acc.VBE.Events.ReferencesEvents(None),RefEvents) See the docstring for DispatchWithEvents - you probably want something closer to: acc = DispatchWithEvents('Access.Application', RefEvents) acc.Visible = True win32com.PumpMessages() # sit here doing nothing but waiting for events... Cheers, Mark > #----------------------------------------------------------------------------- > Traceback (most recent call last): > File "", line 1, in > File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 245, in DispatchWithEvents > disp = Dispatch(clsid) > File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch > return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx) > File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 43, in __WrapDispatch > return dynamic.Dispatch(dispatch, userName, WrapperClass, typeinfo, clsctx=clsctx) > File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 118, in Dispatch > typeinfo = IDispatch.GetTypeInfo() > AttributeError: 'PyIUnknown' object has no attribute 'GetTypeInfo' > #----------------------------------------------------------------------------- >>>> acc.VBE.Events.ReferencesEvents > > >>>> acc.VBE.Events.ReferencesEvents(None) > > > > Original message: >> I am writing a COM addin, and attempting to trap the ItemAdded/ItemRemoved event in the following object: >> Application.VBE.Events.ReferencesEvents >> which is retrieved by passing Nothing as a paramter: >> Application.VBE.Events.ReferencesEvents(Nothing) >> >> Tim Golden wrote in the following post (http://mail.python.org/pipermail/python-win32/2009-February/008826.html) that pythoncom.Empty can be used for Nothing. However, when trying this: >> >> try: >> self.comRefevents=self.app.VBE.Events.ReferencesEvents(pythoncom.Empty) >> except pythoncom.com_error, (hr, msg, exc, arg): >> print "The call failed with code %d: %s" % (hr, msg) >> if exc is None: >> print "There is no extended error information" >> else: >> wcode, source, text, helpFile, helpId, scode = exc >> print "The source of the error is", source >> print "The error message is", text >> print "More info can be found in %s (id=%d)" % (helpFile, helpId) >> >> I get back the following (the same as if I had passed no arguments at all): >> >> The call failed with code -2147352561: Parameter not optional. >> There is no extended error information >> >> Eric Lippert states in his blog (http://blogs.msdn.com/ericlippert/archive/2004/07/14/183241.aspx): >>> A common alternative to passing a missing argument is to pass Nothing, Null, or Empty in VBScript, >>> null or undefined in JScript. Null and null pass VT_NULL, Empty and undefined pass VT_EMPTY, and >>> Nothing passes a VT_DISPATCH with no value dispatch object pointer. >> It would seem that VB's Nothing and Empty are two different things. >> >> If I try passing pythoncom.VT_DISPATCH, then I get the following traceback: >> >> ----------------------------------------------------------------------------------------------------------- >> Traceback (most recent call last): >> File "C:\Python26\lib\site-packages\win32com\universal.py", line 177, in dispatch >> retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None) >> File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 324, in _InvokeEx_ >> return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider) >> File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 649, in _invokeex_ >> return DesignatedWrapPolicy._invokeex_( self, dispid, lcid, wFlags, args, kwArgs, serviceProvider) >> File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 585, in _invokeex_ >> return func(*args) >> File "C:\Documents and Settings\ABG7\My Documents\Zevi\Python-COMAddin\VBACodeRepository.py", line 104, in OnConnection >> self.comRefevents=self.app.VBE.Events.ReferencesEvents(pythoncom.VT_DISPATCH) >> File "C:\Python26\lib\site-packages\win32com\gen_py\0002E157-0000-0000-C000-000000000046x0x5x3.py", line 145, in ReferencesEvents >> ret = self._oleobj_.InvokeTypes(202, LCID, 2, (13, 0), ((13, 1),),VBProject >> TypeError: The Python instance can not be converted to a COM object >> pythoncom error: Unexpected gateway error >> >> Traceback (most recent call last): >> File "C:\Python26\lib\site-packages\win32com\universal.py", line 177, in dispatch >> retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None) >> File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 324, in _InvokeEx_ >> return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider) >> File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 649, in _invokeex_ >> return DesignatedWrapPolicy._invokeex_( self, dispid, lcid, wFlags, args, kwArgs, serviceProvider) >> File "C:\Python26\lib\site-packages\win32com\server\policy.py", line 585, in _invokeex_ >> return func(*args) >> File "C:\Documents and Settings\ABG7\My Documents\Python-COMAddin\VBACodeRepository.py", line 104, in OnConnection >> self.comRefevents=self.app.VBE.Events.ReferencesEvents(pythoncom.VT_DISPATCH) >> File "C:\Python26\lib\site-packages\win32com\gen_py\0002E157-0000-0000-C000-000000000046x0x5x3.py", line 145, in ReferencesEvents >> ret = self._oleobj_.InvokeTypes(202, LCID, 2, (13, 0), ((13, 1),),VBProject >> TypeError: The Python instance can not be converted to a COM object >> >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 From tmic.mailinglist at gmail.com Fri Oct 16 15:46:16 2009 From: tmic.mailinglist at gmail.com (Michael Gebhardt) Date: Fri, 16 Oct 2009 15:46:16 +0200 Subject: [python-win32] Seemingly identical COM-calls fail in Python client but work in other client Message-ID: Hi! I am trying to control the electromagnetic simulator CST Microwave Studio from Python using COM automation, and I am experiencing trouble: >From Matlab, I use the following calls: cst = actxserver('CSTStudio.Application'); % Launch the simulator application mws = invoke(cst, 'OpenFile', 'my_project_file.cst'); % Open simulation project file a_s11 = invoke(mws, 'Result1D', 'a1(1)1(1)'); % Acces a previously caculated result N = invoke(a_s11, 'GetN'); % Get number of samples in result Everything works fine from Matlab. When I use Python,l however, I find myself in trouble when I attempt to create the "Result1D" object: import win32com.client cst = win32com.client.Dispatch("CSTStudio.Application") mws = cst.OpenFile("my_project_file.cst") # So far, everything is fine, the program starts, and the file opens, but from here on... a_s11 = mws.Result1D("a1(1)1(1)") ... I get the following traceback: [C:AbstractMeas/src]|54> mycst.mws.Result1D("a1(1)1(1)") ----------------------------------------------------------------------- com_error Traceback (most recent call last) C:\Users\emicgeb\workspace\AbstractMeas\src\ in () C:\Python26\lib\site-packages\win32com\client\dynamic.pyc in Result1D(self, *args) com_error: (-2147417851, 'The server threw an exception.', None, None) I have no idea what has gone wrong. Any suggestions how I could find out what's going on? I'm using dynamic dispatch (can't find anything that seems suitable to run through makepy.py... :-( ? ). Python 2.6.3, pywin32-214. I would appreciate any help or suggestions. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at ellipsisphilly.com Fri Oct 16 21:22:16 2009 From: matt at ellipsisphilly.com (Matt Murphy Garmur) Date: Fri, 16 Oct 2009 15:22:16 -0400 Subject: [python-win32] Python and ASP - failure on 2nd and subsequent page loads In-Reply-To: <32AA3A83235A25458AB5387177B883F8110F499D5B@MAIL.ith.local> References: <32AA3A83235A25458AB5387177B883F8110C528AEE@MAIL.ith.local> <4AD6B37F.4030108@gmail.com> <32AA3A83235A25458AB5387177B883F8110F499D5B@MAIL.ith.local> Message-ID: <31d943390910161222l419f5482t3056cc56d5cb5a89@mail.gmail.com> hi mark. thanks so much for looking into the matter. unfortunately, i'm the odd person out here because this fix hasn't solved my problem. i implemented the fix and restarted the server, to no avail. thinking i had screwed up my system with previous tries, i did this: - uninstalled python and pywin32 from my computer. - downloaded and reinstalled python 2.6.3 from python.org. - downloaded and installed pywin32 from sourceforge. - made the change to framework.py using a text editor that could identify tabs vs spaces. - ran python pyscript.py (even did the old --unregister trick first). - rebooted the computer entirely. it came back up and my program looks like this: <%@LANGUAGE=Python%>

Python Test

when i run it, it works the first time. then i hit refresh and i get this: Python ActiveX Scripting Engine error '80020009' Traceback (most recent call last): File "