From federico at panizzolo.it Wed Nov 3 18:15:53 2010 From: federico at panizzolo.it (Federico Fanton) Date: Wed, 03 Nov 2010 18:15:53 +0100 Subject: [python-win32] "Could not load file or assembly" using win32com Message-ID: <4CD198C9.2080001@panizzolo.it> Hi everyone! I have a Python program that uses win32com to automate a few tasks exposed by a C# application (Alibre Design[1]). It used to work nicely, but now there's a new version of the application, and upon calling win32com.client.Dispatch, an error message appears: http://i.imgur.com/zgSBJ.png I tried enabling the log as suggested in the message, and it shows that LOG: Appbase = file:///C:/Python26 So I tried copying the required files there, and the message goes away... Is there a way to tell win32com where to look for assemblies? Thanks for your attention! [1]: http://www.alibre.com/ From timr at probo.com Wed Nov 3 18:40:11 2010 From: timr at probo.com (Tim Roberts) Date: Wed, 3 Nov 2010 10:40:11 -0700 Subject: [python-win32] "Could not load file or assembly" using win32com In-Reply-To: <4CD198C9.2080001@panizzolo.it> References: <4CD198C9.2080001@panizzolo.it> Message-ID: <4CD19E7B.9000101@probo.com> Federico Fanton wrote: > Hi everyone! > > I have a Python program that uses win32com to automate a few tasks > exposed by a C# application (Alibre Design[1]). It used to work nicely, > but now there's a new version of the application, and upon calling > win32com.client.Dispatch, an error message appears: > > http://i.imgur.com/zgSBJ.png > > I tried enabling the log as suggested in the message, and it shows that > > LOG: Appbase = file:///C:/Python26 > > So I tried copying the required files there, and the message goes away... > Is there a way to tell win32com where to look for assemblies? Win32com doesn't know anything about assemblies. Assemblies are strictly a .NET concept. The error suggests that the Alibre application has not registered its assemblies properly. That would ordinarily be done when the application installed itself. When you did the upgrade, did you actually run an installer, or did you just copy new files into place? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From federico at panizzolo.it Thu Nov 4 09:32:31 2010 From: federico at panizzolo.it (Federico Fanton) Date: Thu, 04 Nov 2010 09:32:31 +0100 Subject: [python-win32] "Could not load file or assembly" using win32com In-Reply-To: <4CD19E7B.9000101@probo.com> References: <4CD198C9.2080001@panizzolo.it> <4CD19E7B.9000101@probo.com> Message-ID: <4CD26F9F.2000103@panizzolo.it> Tim Roberts wrote: > Win32com doesn't know anything about assemblies. Assemblies are > strictly a .NET concept. The error suggests that the Alibre application > has not registered its assemblies properly. That would ordinarily be > done when the application installed itself. When you did the upgrade, > did you actually run an installer, or did you just copy new files into > place? I used the installer... I'll ask the Alibre guys then, many thanks :) From rnorman at acpropulsion.com Fri Nov 5 20:18:20 2010 From: rnorman at acpropulsion.com (Robert Norman) Date: Fri, 05 Nov 2010 11:18:20 -0800 Subject: [python-win32] Can't access methods of COM object. Message-ID: <4CD4587C.4050206@acpropulsion.com> I have been successful in the past using COM from Python to control ActiveX elements such as LabView programs and a few third-party device servers. I recently tried to integrate a new component which came with a LabView example and some Visual Basic sample code. The LabView example works for me and I can examine the methods and properties of the server but I can't seem to do anything with the server from Python. I can successfully get an instance with: >>>ps = Dispatch("PPServer.PPServerClass") >>>ps >>>cha = ps.ChannelA <--- Fails and none of the expected methods or properties are exposed except those seen in the attached genpy file. The VB example shows: Set pps = New PServer cha = pps.ChannelA I've tried various combinations, in Python, of ps.ChannelA, ps.Start() etc and none of the documented methods or properties seem to work. Any thoughts on how to proceed? Thanks Rob -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: 23D1AE21-8023-11D3-8D47-00C04F949D33x0x1x0.py URL: From timr at probo.com Fri Nov 5 21:22:04 2010 From: timr at probo.com (Tim Roberts) Date: Fri, 5 Nov 2010 13:22:04 -0700 Subject: [python-win32] Can't access methods of COM object. In-Reply-To: <4CD4587C.4050206@acpropulsion.com> References: <4CD4587C.4050206@acpropulsion.com> Message-ID: <4CD4676C.8000408@probo.com> Robert Norman wrote: > I have been successful in the past using COM from Python to control > ActiveX elements such as LabView programs and a few third-party device > servers. I recently tried to integrate a new component which came with > a LabView example and some Visual Basic sample code. The LabView example > works for me and I can examine the methods and properties of the server > but I can't seem to do anything with the server from Python. > > I can successfully get an instance with: > > >>>ps = Dispatch("PPServer.PPServerClass") > ... > The VB example shows: > > Set pps = New PServer That's not the same thing. Is that actually "New PPServerClass"? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From guenter.walser at wanagu.eu Sat Nov 6 00:06:18 2010 From: guenter.walser at wanagu.eu (gatwanagu) Date: Fri, 5 Nov 2010 16:06:18 -0700 (PDT) Subject: [python-win32] gakepy / genpy don't collect all methods/attributes Message-ID: <30145729.post@talk.nabble.com> Please excuse if this question has been asked previously, I did search but couldn't find anything. I want to use com for Excel to access DocumentProperties. Microsoft Office 12.0 Object Library contains the definitions for this. If I now generate the Python Wrapper File (not sure what the correct name would be) either with python makepy.py -v "Microsoft Excel 12.0 Object Library" or by having gencache.EnsureModule('{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}', 0, 2, 4) within the code. The file does contain some properties descriptions like class DocumentProperty(DispatchBaseClass): CLSID = IID('{2DF8D04E-5BFA-101B-BDE5-00AA0044DE52}') coclass_clsid = None _prop_map_get_ = { "Application": (1610743820, 2, (3, 0), ((16393, 10),), "Application", None), "Creator": (1610743821, 2, (3, 0), ((16387, 10),), "Creator", None), "LinkSource": (7, 2, (3, 0), ((16392, 10),), "LinkSource", None), "LinkToContent": (6, 2, (3, 0), ((16395, 10),), "LinkToContent", None), "Parent": (1, 2, (9, 0), (), "Parent", None), } but the ones like Name or Value usable for access are missing. If I use the Python Object Browser from PythonWin to view the object within Microsoft Office 12.0 Object Library I see there these properties defined. Using data from the Browser to manually insert additional entries like "Name": (3, 2, (9, 0), (), "Name", None), "Value": (0, 2, (9, 0), (), "Value", None), to _prop_map_get_ makes it work. Is there a argument to force the generation of these prop entries or whatelse do I wrong. Thank you in advance for any sugestion, BR G?nter -- View this message in context: http://old.nabble.com/gakepy---genpy-don%27t-collect-all-methods-attributes-tp30145729p30145729.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From python at bdurham.com Sat Nov 6 00:35:23 2010 From: python at bdurham.com (python at bdurham.com) Date: Fri, 05 Nov 2010 19:35:23 -0400 Subject: [python-win32] Win32 equivalent of VB doevents() or just use time.sleep()? Message-ID: <1289000123.7823.1403851067@webmail.messagingengine.com> We have a bunch of command line utilities that use all the CPU capacity available to them. Our customer has asked us to find ways we might make these utilities more system friendly by occassionally calling what they refered to as a win32 equivalent of VB's (Visual Basic) doevents() function. I googled this topic and found a Mark Hammond suggestion with qualifications[1]: win32gui.Pump(Waiting)Messages Is there a recommended way to run our utilities in a more CPU friendly way? I was thinking of calling time.sleep( P ) every N iterations through our processing but I'm not clear on the pros and cons of this technique vs. a strategy that proactively pumps waiting messages. Malcolm [1] http://mail.python.org/pipermail/python-win32/2005-October/003920 .html -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sat Nov 6 01:14:42 2010 From: timr at probo.com (Tim Roberts) Date: Fri, 5 Nov 2010 17:14:42 -0700 Subject: [python-win32] Win32 equivalent of VB doevents() or just use time.sleep()? In-Reply-To: <1289000123.7823.1403851067@webmail.messagingengine.com> References: <1289000123.7823.1403851067@webmail.messagingengine.com> Message-ID: <4CD49DF2.60007@probo.com> python at bdurham.com wrote: > We have a bunch of command line utilities that use all the CPU > capacity available to them. Our customer has asked us to find ways we > might make these utilities more system friendly by occassionally > calling what they refered to as a win32 equivalent of VB's (Visual > Basic) doevents() function. > > I googled this topic and found a Mark Hammond suggestion with > qualifications[1]: > > win32gui.Pump(Waiting)Messages > > Is there a recommended way to run our utilities in a more CPU friendly > way? Not if they are command-line utilities. That UI only applies to applications that have a message loop, and yours doesn't have one. One alternative would be to reduce your processes priority: http://code.activestate.com/recipes/496767-set-process-priority-in-windows/ Set yourself to BELOW_NORMAL_PRIORITY_CLASS and you'll be friendlier. > I was thinking of calling time.sleep( P ) every N iterations through > our processing but I'm not clear on the pros and cons of this > technique vs. a strategy that proactively pumps waiting messages. Yep, in a console application, that's exactly the right way. Calling time.sleep(0) will release the CPU if there is anyone else waiting. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rays at blue-cove.com Sat Nov 6 16:21:07 2010 From: rays at blue-cove.com (RayS) Date: Sat, 06 Nov 2010 08:21:07 -0700 Subject: [python-win32] "access violation" debugging advice? Message-ID: <6.2.3.4.2.20101106080612.029098c0@pop-server.san.rr.com> I'm accessing a 3rd party ctypes cDLL function and getting WindowsError "access violation at 0xnnnn" at seemingly random time intervals; what tips does the group have for debugging? The DLL author is an MS C++ guy and not Python literate. The DLL appears to run without error with his MSVC apps. It almost seems CPU-load dependent, but I could be imagining that... It is for data acquisition, and I seem to be forced to restart my app to get around the trapped error and restart (although I haven't tried un-setting the ctypes objects). - Ray From samu.niveri at hotmail.com Mon Nov 8 00:23:10 2010 From: samu.niveri at hotmail.com (Samu Niveri) Date: Mon, 8 Nov 2010 01:23:10 +0200 Subject: [python-win32] SolidWorks & pywin32? Message-ID: Hello, I have created small app for SWx and encountered a minor problem with it. When trying to read properties from SWx-files using API-command: CustomPropertyManager.Get2(ByVal FieldName As String, ByRef ValOut As String, ByRef ReesolvedValOut As String) I get results: CustPropMgr.Get2(CustProperty, ValOut, ResValOut) File ">", line 2, in Get2 pywintypes.com_error: (-2147352571, 'Type mismatch.', None, 2) Definitions in makepy generated file are: def Get2(self, FieldName=defaultNamedNotOptArg, ValOut=pythoncom.Missing, ReesolvedValOut=pythoncom.Missing): """Get a custom property""" return self._ApplyTypes_(10, 1, (24, 0), ((8, 1), (16392, 2), (16392, 2)), 'Get2', None,FieldName , ValOut, ReesolvedValOut) Is there any workarounds for this? It seemed that someone has fixed similar issues with AutoCAD & pywin, but I did not understand where he/she was able to pull out the fixes. -Samu -------------- next part -------------- An HTML attachment was scrubbed... URL: From rnorman at acpropulsion.com Mon Nov 8 18:30:38 2010 From: rnorman at acpropulsion.com (Robert Norman) Date: Mon, 08 Nov 2010 09:30:38 -0800 Subject: [python-win32] python-win32 Digest - Can't access COM methods In-Reply-To: References: Message-ID: <4CD833BE.3000005@acpropulsion.com> Hi Tim, (I wasn't sure how to target your response in the digest. Hope this worked out OK.) > Message: 2 > Date: Fri, 5 Nov 2010 13:22:04 -0700 > From: Tim Roberts > To: Python-Win32 List > Subject: Re: [python-win32] Can't access methods of COM object. > Message-ID:<4CD4676C.8000408 at probo.com> > Content-Type: text/plain; charset="ISO-8859-1" > > Robert Norman wrote: >> I have been successful in the past using COM from Python to control >> ActiveX elements such as LabView programs and a few third-party device >> servers. I recently tried to integrate a new component which came with >> a LabView example and some Visual Basic sample code. The LabView example >> works for me and I can examine the methods and properties of the server >> but I can't seem to do anything with the server from Python. >> >> I can successfully get an instance with: >> >> >>>ps = Dispatch("PPServer.PPServerClass") >> ... >> The VB example shows: >> >> Set pps = New PServer > That's not the same thing. Is that actually "New PPServerClass"? > When I examine the return object, it is a PPServer not the PPServerClass but can't find any way to go the next step. In previous experience with LabView servers, the Dispatch statement gives me usable COM objects. Rob From timr at probo.com Mon Nov 8 19:08:51 2010 From: timr at probo.com (Tim Roberts) Date: Mon, 8 Nov 2010 10:08:51 -0800 Subject: [python-win32] SolidWorks & pywin32? In-Reply-To: References: Message-ID: <4CD83CB3.80903@probo.com> Samu Niveri wrote: > > I have created small app for SWx and encountered a minor problem with > it. When trying to read properties from SWx-files using API-command: > CustomPropertyManager.Get2(ByVal FieldName As String, ByRef ValOut As > String, ByRef ReesolvedValOut As String) I get results: > > CustPropMgr.Get2(CustProperty, ValOut, ResValOut) > File ">", line 2, in Get2 > pywintypes.com_error: (-2147352571, 'Type mismatch.', None, 2) Those are output parameters. You probably want this: (ValOut, ResValOut) = CustPropMgr.Get2(CustProperty) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Nov 8 21:38:39 2010 From: timr at probo.com (Tim Roberts) Date: Mon, 8 Nov 2010 12:38:39 -0800 Subject: [python-win32] "access violation" debugging advice? In-Reply-To: <6.2.3.4.2.20101106080612.029098c0@pop-server.san.rr.com> References: <6.2.3.4.2.20101106080612.029098c0@pop-server.san.rr.com> Message-ID: <4CD85FCF.6090505@probo.com> RayS wrote: > I'm accessing a 3rd party ctypes cDLL function and getting > WindowsError "access violation at 0xnnnn" at seemingly random time > intervals; what tips does the group have for debugging? The DLL > author is an MS C++ guy and not Python literate. The DLL appears to > run without error with his MSVC apps. It almost seems CPU-load > dependent, but I could be imagining that... I think you're going to need to run the app inside a debugger, and get a traceback to figure out where in the DLL it is crashing. There are just too many possibilities. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From asmund.hjulstad at gmail.com Tue Nov 9 09:38:34 2010 From: asmund.hjulstad at gmail.com (=?ISO-8859-1?Q?=C5smund_Hjulstad?=) Date: Tue, 9 Nov 2010 11:38:34 +0300 Subject: [python-win32] Wrong default value for optional argument in makepy signature. Message-ID: I keep getting the following exception when making some calls on a ActiveX DLL library (PISDK). Problem partially solved, posting in case others may find it usefull. TypeError: The Python instance can not be converted to a COM object I have traced it down to an optional parameter, that is set to 0, but should (probably) be set to None. the makepy signature is: GetPoints(self, WhereClause=, pAsynchStatus=0) Doing the call using server.GetPoints(" tag = 'FT12345/*' ", None) works fine. Same with the RecordedValue, with this signature: RecordedValues(self, StartTime=, EndTime=, ? BoundaryType=3, filterExp=u'', ShowFiltered=0, asynchStatus=0) asynchStatus may be a reference to a Ole object (PIAsynchStatus), used for callback / asynchonous querying. As the optional parameter is easy to forget, especially when querying interactively in ipython, is it possible to make makepy understand that the optional parameter should be None, instead of 0? Kind regards, ?smund Hjulstad From samu.niveri at hotmail.com Tue Nov 9 15:00:28 2010 From: samu.niveri at hotmail.com (Samu Niveri) Date: Tue, 9 Nov 2010 16:00:28 +0200 Subject: [python-win32] SolidWorks & pywin32? In-Reply-To: References: Message-ID: > Samu Niveri wrote: > > > > I have created small app for SWx and encountered a minor problem with > > it. When trying to read properties from SWx-files using API-command: > > CustomPropertyManager.Get2(ByVal FieldName As String, ByRef ValOut As > > String, ByRef ReesolvedValOut As String) I get results: > > > > CustPropMgr.Get2(CustProperty, ValOut, ResValOut) > > File ">", line 2, in Get2 > > pywintypes.com_error: (-2147352571, 'Type mismatch.', None, 2) > > Those are output parameters. You probably want this: > (ValOut, ResValOut) = CustPropMgr.Get2(CustProperty) > Thanks Tim, I was also using python 3.1 so actually nothing really worked -> changing back to 2.7 fixed all my issues. -------------- next part -------------- An HTML attachment was scrubbed... URL: From asmund.hjulstad at gmail.com Tue Nov 9 15:43:12 2010 From: asmund.hjulstad at gmail.com (=?ISO-8859-1?Q?=C5smund_Hjulstad?=) Date: Tue, 9 Nov 2010 17:43:12 +0300 Subject: [python-win32] Makepy does not generate all secondary interfaces? Message-ID: I am struggling with secondary interfaces and makepy I have generated an interface with makepy from a library ( PISDKCommon 1.0 Type Library ). It has an object, PIAsynchStatus, that exposes a secondary interface; IPIAsynchStatus2. I cannot find the secondary interface in the generated module, though. I wanted to do something like Mark Hammond suggested here: http://code.activestate.com/lists/python-list/27760/ .. but without the secondary interface, I don't know how to do it. module = gencache.GetModuleForProgID('PISDKCommon.PIAsynchStatus') module.IPIAsynchStatus2 # Throws AttributeError Looking in the makepy-generated .py files, I find references to IPIAsynchStatus2 in the package's __init__.py file (everything from this library appears to end up in a subdirectory), but no class. The references are in the VTablesToPackageMap, NamesToIIDMap. The CLSIDToClassMap dict is empty. Any suggestions as to what can be wrong? Some secondary interfaces from a different, but related library appears in (another) module namespace without any problems. In this library, everything appears in one .py file, though, no subdirectory structure and __init__.py files. ?smund Hjulstad From timr at probo.com Tue Nov 9 18:26:03 2010 From: timr at probo.com (Tim Roberts) Date: Tue, 9 Nov 2010 09:26:03 -0800 Subject: [python-win32] Wrong default value for optional argument in makepy signature. In-Reply-To: References: Message-ID: <4CD9842B.3050705@probo.com> ?smund Hjulstad wrote: > I keep getting the following exception when making some calls on a > ActiveX DLL library (PISDK). Problem partially solved, posting in case > others may find it usefull. > > TypeError: The Python instance can not be converted to a COM object > > I have traced it down to an optional parameter, that is set to 0, but > should (probably) be set to None. > > the makepy signature is: > > GetPoints(self, WhereClause=, pAsynchStatus=0) > > Doing the call using > > server.GetPoints(" tag = 'FT12345/*' ", None) > > works fine. ... > > As the optional parameter is easy to forget, especially when querying > interactively in ipython, is it possible to make makepy understand > that the optional parameter should be None, instead of 0? Makepy makes an educated guess, based on the data type of the parameter. However, some people lie about their data types when they make an interface like this. Instead of declaring it a pointer, they'll declare it as an integer. Makepy isn't omniscient. Do you have the IDL that describes the function, or a web page reference? Can you show us the script that makepy generated? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From asmund.hjulstad at gmail.com Tue Nov 9 18:44:40 2010 From: asmund.hjulstad at gmail.com (=?ISO-8859-1?Q?=C5smund_Hjulstad?=) Date: Tue, 9 Nov 2010 20:44:40 +0300 Subject: [python-win32] Makepy does not generate all secondary interfaces? In-Reply-To: References: Message-ID: After a some more struggling: The reason why some files ended up in a subdirectory, was that I used the gencache.EnsureDispatch call, which defaults to "on demand" building of class interfaces. Not that it matters, though, I have the same problem if I generate using makepy.py on the command line, or use EnsureModule (that has a different default). My latest attempt is pisdkcommonlib = ('{76A44786-EBC8-11D3-BDC5-00C04F779EB2}', 0, 1, 0) win32com.client.makepy.GenerateChildFromTypeLibSpec("IPIAsynchStatus2", pisdkcommonlib, 1) which gives me Generating... Building definitions from type library... Building definitions from type library... Building definitions from type library... Building definitions from type library... Generation complete.. Importing module ImportError: No module named IPIAsynchStatus2 Any pointers appreciated. (Or is this possibly a bug?) 2010/11/9 ?smund Hjulstad : > I am struggling with secondary interfaces and makepy > > I have generated an interface with makepy from a library ( PISDKCommon > 1.0 Type Library ). It has an object, PIAsynchStatus, that exposes a > secondary interface; IPIAsynchStatus2. I cannot find the secondary > interface in the generated module, though. I wanted to do something > like Mark Hammond suggested here: > http://code.activestate.com/lists/python-list/27760/ > > .. but without the secondary interface, I don't know how to do it. > > module = gencache.GetModuleForProgID('PISDKCommon.PIAsynchStatus') > module.IPIAsynchStatus2 ? # Throws AttributeError > > Looking in the makepy-generated .py files, I find references to > IPIAsynchStatus2 in the package's __init__.py file (everything from > this library appears to end up in a subdirectory), but no class. > The references are in the VTablesToPackageMap, NamesToIIDMap. The > CLSIDToClassMap dict is empty. > > Any suggestions as to what can be wrong? Some secondary interfaces > from a different, but related library appears in (another) module > namespace without any problems. In this library, everything appears in > one .py file, though, no subdirectory structure and __init__.py files. > > > ?smund Hjulstad > -- ?smund Hjulstad, asmund at hjulstad.com From timr at probo.com Tue Nov 9 19:03:08 2010 From: timr at probo.com (Tim Roberts) Date: Tue, 9 Nov 2010 10:03:08 -0800 Subject: [python-win32] Makepy does not generate all secondary interfaces? In-Reply-To: References: Message-ID: <4CD98CDC.80909@probo.com> ?smund Hjulstad wrote: > ... > My latest attempt is > > pisdkcommonlib = ('{76A44786-EBC8-11D3-BDC5-00C04F779EB2}', 0, 1, 0) > win32com.client.makepy.GenerateChildFromTypeLibSpec("IPIAsynchStatus2", > pisdkcommonlib, 1) > > which gives me > ... > ImportError: No module named IPIAsynchStatus2 > > Any pointers appreciated. (Or is this possibly a bug?) A Google search for IPIAsynchStatus2 brings up nothing but your messages. Are you sure that's spelled correctly? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From asmund.hjulstad at gmail.com Tue Nov 9 19:03:37 2010 From: asmund.hjulstad at gmail.com (=?ISO-8859-1?Q?=C5smund_Hjulstad?=) Date: Tue, 9 Nov 2010 21:03:37 +0300 Subject: [python-win32] Wrong default value for optional argument in makepy signature. In-Reply-To: <4CD9842B.3050705@probo.com> References: <4CD9842B.3050705@probo.com> Message-ID: 2010/11/9 Tim Roberts : > ?smund Hjulstad wrote: >> I keep getting the following exception when making some calls on a >> ActiveX DLL library (PISDK). Problem partially solved, posting in case >> others may find it usefull. >> >> TypeError: The Python instance can not be converted to a COM object >> >> I have traced it down to an optional parameter, that is set to 0, but >> should (probably) be set to None. >> >> the makepy signature is: >> >> GetPoints(self, WhereClause=, pAsynchStatus=0) >> >> Doing the call using >> >> server.GetPoints(" tag = 'FT12345/*' ", None) >> >> works fine. ... >> >> As the optional parameter is easy to forget, especially when querying >> interactively in ipython, is it possible to make makepy understand >> that the optional parameter should be None, instead of 0? > > Makepy makes an educated guess, based on the data type of the > parameter. ?However, some people lie about their data types when they > make an interface like this. ?Instead of declaring it a pointer, they'll > declare it as an integer. ?Makepy isn't omniscient. > > Do you have the IDL that describes the function, or a web page > reference? ?Can you show us the script that makepy generated? The function is described like this in the accompanying .h file: ( This is from pisdk.h ) virtual /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE GetPoints( /* [in] */ BSTR whereClause, /* [in] */ PointSearchTypeConstants eSearchType, /* [defaultvalue][in] */ /* external definition not present */ _NamedValues *pnvExtraTableList, /* [defaultvalue][in] */ /* external definition not present */ _NamedValues *pnvServerList, /* [defaultvalue][in] */ /* external definition not present */ _PIAsynchStatus *pAsynchStatus, /* [retval][out] */ _PointList **ret) = 0; with _PIAsynchStatus described in pisdkcommon.h interface _PIAsynchStatus { CONST_VTBL struct _PIAsynchStatusVtbl *lpVtbl; }; There are two different DLLs, pisdk.dll and PISDKCommon.dll (which the first one depends on) The generated python code for the relevant method is # Result is of type _PointList def GetPoints(self, WhereClause=defaultNamedNotOptArg, pAsynchStatus=0): """Search for PIPoints on this server.""" ret = self._oleobj_.InvokeTypes(21, LCID, 1, (9, 0), ((8, 1), (9, 49)),WhereClause , pAsynchStatus) if ret is not None: ret = Dispatch(ret, u'GetPoints', '{EF9DDE15-265F-11D2-80F4-00A0240B7FDC}') return ret Please let me know if more information can be of help. From asmund.hjulstad at gmail.com Tue Nov 9 19:20:26 2010 From: asmund.hjulstad at gmail.com (=?ISO-8859-1?Q?=C5smund_Hjulstad?=) Date: Tue, 9 Nov 2010 21:20:26 +0300 Subject: [python-win32] Makepy does not generate all secondary interfaces? In-Reply-To: <4CD98CDC.80909@probo.com> References: <4CD98CDC.80909@probo.com> Message-ID: 2010/11/9 Tim Roberts : > ?smund Hjulstad wrote: >> ... >> My latest attempt is >> >> pisdkcommonlib = ('{76A44786-EBC8-11D3-BDC5-00C04F779EB2}', 0, 1, 0) >> win32com.client.makepy.GenerateChildFromTypeLibSpec("IPIAsynchStatus2", >> pisdkcommonlib, 1) >> >> which gives me >> ... >> ImportError: No module named IPIAsynchStatus2 >> >> Any pointers appreciated. (Or is this possibly a bug?) > > A Google search for IPIAsynchStatus2 brings up nothing but your > messages. ?Are you sure that's spelled correctly? Yes, and makepy also finds something, replacing the text with "IPIAsyncStatus3", for example, gives AssertionError: Cant find the 'IPIAsynchStatus3' interface in the CoClasses, or the interfaces It is described in the header file as: IPIAsynchStatus2 : public IUnknown { public: virtual /* [helpstring][helpcontext][id][propget] */ HRESULT STDMETHODCALLTYPE get_CallCompleteEvent( /* [retval][out] */ long *pHandle) = 0; }; but I don't understand how the original object declares that it can implement the interface. I'm probably in way over my head. Thank you for helping. From timr at probo.com Tue Nov 9 21:50:58 2010 From: timr at probo.com (Tim Roberts) Date: Tue, 9 Nov 2010 12:50:58 -0800 Subject: [python-win32] Makepy does not generate all secondary interfaces? In-Reply-To: References: <4CD98CDC.80909@probo.com> Message-ID: <4CD9B432.4040701@probo.com> ?smund Hjulstad wrote: > 2010/11/9 Tim Roberts : >> ?smund Hjulstad wrote: >>> ... >>> My latest attempt is >>> >>> pisdkcommonlib = ('{76A44786-EBC8-11D3-BDC5-00C04F779EB2}', 0, 1, 0) >>> win32com.client.makepy.GenerateChildFromTypeLibSpec("IPIAsynchStatus2", >>> pisdkcommonlib, 1) That's not the correct usage. Did you see an example of this somewhere? What happens if you do xxx.QueryInterface and specify the GUID of the interface you want? > but I don't understand how the original object declares that it can > implement the interface. I'm probably in way over my head. Thank you > for helping. That's done at run-time. In C++ terms, you call the QueryInterface method, passing it the GUID of the interface you want. If the object supports that interface, it returns a pointer. Otherwise, it returns an error. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From asmund.hjulstad at gmail.com Wed Nov 10 01:57:50 2010 From: asmund.hjulstad at gmail.com (=?ISO-8859-1?Q?=C5smund_Hjulstad?=) Date: Wed, 10 Nov 2010 03:57:50 +0300 Subject: [python-win32] Makepy does not generate all secondary interfaces? In-Reply-To: <4CD9B432.4040701@probo.com> References: <4CD98CDC.80909@probo.com> <4CD9B432.4040701@probo.com> Message-ID: 2010/11/9 Tim Roberts : > ?smund Hjulstad wrote: >>>> My latest attempt is >>>> >>>> pisdkcommonlib = ('{76A44786-EBC8-11D3-BDC5-00C04F779EB2}', 0, 1, 0) >>>> win32com.client.makepy.GenerateChildFromTypeLibSpec("IPIAsynchStatus2", >>>> pisdkcommonlib, 1) > > That's not the correct usage. ?Did you see an example of this somewhere? No, I made a guess from looking at the source code. > What happens if you do xxx.QueryInterface and specify the GUID of the > interface you want? a = EnsureDispatch('PISDKCommon.PIAsynchStatus') a._oleobj_.QueryInterface('{ECA80073-B652-478A-B191-E87A924EB723}') gives this error: TypeError: There is no interface object registered that supports this IID and if I try a = Dispatch('PISDKCommon.PIAsynchStatus', None, '{ECA80073-B652-478A-B191-E87A924EB723}) I get ImportError: No module named IPIAsynchStatus2 Stack trace as follows: (I'm running this from IPython) Traceback (most recent call last): File "C:\Python27\lib\site-packages\IPython\iplib.py", line 2257, in runcode exec code_obj in self.user_global_ns, self.user_ns File "", line 1, in File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx) File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 37, in __WrapDispatch klass = gencache.GetClassForCLSID(resultCLSID) File "C:\Python27\lib\site-packages\win32com\client\gencache.py", line 179, in GetClassForCLSID mod = GetModuleForCLSID(clsid) File "C:\Python27\lib\site-packages\win32com\client\gencache.py", line 240, in GetModuleForCLSID makepy.GenerateChildFromTypeLibSpec(sub_mod, info) File "C:\Python27\lib\site-packages\win32com\client\makepy.py", line 320, in GenerateChildFromTypeLibSpec __import__("win32com.gen_py." + dir_name + "." + child) File "C:\Python27\lib\site-packages\winpdb-1.4.8-py2.7.egg\rpdb2.py", line 13487, in rpdb2_import_wrapper m = g_import(*args, **kwargs) ImportError: No module named IPIAsynchStatus2 Using pdb, I find that the first two arguments for the GenerateChildFromTypeLibSpec function call are child = IPIAsynchStatus2 typelibInfo = ('{76A44786-EBC8-11D3-BDC5-00C04F779EB2}', 0, 1, 0) (which is the same function call as I tried myself, previously) From Erik.Janssens at conceptive.be Wed Nov 10 23:36:43 2010 From: Erik.Janssens at conceptive.be (Erik Janssens) Date: Wed, 10 Nov 2010 23:36:43 +0100 Subject: [python-win32] compiling python-win32 Message-ID: Hi, I'm trying to compile python-win32, but no matter which combination of tools I use, it always fails. currently I'm stuck at the issue described in ticket : Unresolved external symbol _CLSID_MachineDebugManager - ID: 3092278 (Using Visual Studio 2008 Express + Windows SDK 7.1) Therefor I wonder if there is an 'official' combination of tools that is supposed to be able to compile the project ? which tools are being used to make the official builds ? Thanks a lot, Erik From m.tinti at dundee.ac.uk Wed Nov 3 15:26:16 2010 From: m.tinti at dundee.ac.uk (Michele Tinti) Date: Wed, 03 Nov 2010 14:26:16 +0000 Subject: [python-win32] Internet Explorer constants&In-Reply-To= Message-ID: <4CD171080200001E00008218@ia-gw-6.dundee.ac.uk> Hi there! I wonder if you ever find a solution to the "save as" task for ie. Thanks in advance Michele Michele Tinti, PhD MRC Protein Phosphorylation Unit MSI/WTB Complex, Faculty of Life Sciences, University of Dundee Dow Street, Dundee DD1 5EH, Scotland, UK http://www.ppu.mrc.ac.uk/ ----------------------------- Tel: +44-(0)1382-386404 Fax: +44-(0)1382-223778 email: m.tinti at dundee.ac.uk ----------------------------- ************************************************************ Please consider the environment. Do you really need to print this email? The University of Dundee is a registered Scottish charity, No: SC015096 -------------- next part -------------- An HTML attachment was scrubbed... URL: From freesisyphuswang at gmail.com Thu Nov 4 16:13:30 2010 From: freesisyphuswang at gmail.com (^_^Sisyphus^_^) Date: Thu, 4 Nov 2010 16:13:30 +0100 Subject: [python-win32] WMI qualifier Message-ID: Hi everyone, I start to use WMI python binding recently. I want to know whether there is any way to retrieve the qualifier information of a WMI object? For example, in Win32_Process the OtherTransferCountData has a unit in bytes but PageFileUsageData has a unit in kilobytes: OtherTransferCountData type: uint64 Access type: Read-only Qualifiers: Units (Bytes) PageFileUsageData type: uint32 Access type: Read-only Qualifiers: Units (Kilobytes) How could I retrieve those string value from their qualifiers, such as: 'Bytes', 'Kilobytes'? Thanks, Ling -------------- next part -------------- An HTML attachment was scrubbed... URL: From tuttiesandbilly at yahoo.com Mon Nov 8 20:20:31 2010 From: tuttiesandbilly at yahoo.com (Thomas Gleeson) Date: Mon, 8 Nov 2010 11:20:31 -0800 (PST) Subject: [python-win32] Python and ASP - failure on 2nd and subsequent page loads Message-ID: <661451.98342.qm@web55604.mail.re4.yahoo.com> While debugging something else, I broke my Python ASP web site (powered by Mark Hammond's PyWin) getting the dreaded 'failure on subsequent page loads'.? This URL lead me to investigate?if debugging was enabled for the web site.?? http://old.nabble.com/win32com-and-extended-error-messages:-IDL-with--out,-retval--long*-error)-td20773665.html Indeed on my working machine it was *not*, while on my newly-broken?machine it *was*.? Disabling debugging resolved the issue... -------------- next part -------------- An HTML attachment was scrubbed... URL: From ctom at muellersystems.com Mon Nov 8 21:33:12 2010 From: ctom at muellersystems.com (ChristopherTom) Date: Mon, 8 Nov 2010 12:33:12 -0800 (PST) Subject: [python-win32] How to make Python identify GUI buttons by their label Message-ID: <30164133.post@talk.nabble.com> The contractor we hired told us that Python can only recognize GUI objects, specifically buttons, by their ID. This is very inconvenient and hard to work with as the button IDs change a lot between builds. Instead, I want to reference a button by its label like "Save", "Preview", or "Submit." Does anyone know how I can accomplish this? We use ActiveState ActivePython 2.6.4.8 (32 bit), wxPython 2.8.10.1, and PyScripter 2.3.3. Thx in advance, Christopher -- View this message in context: http://old.nabble.com/How-to-make-Python-identify-GUI-buttons-by-their-label-tp30164133p30164133.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From mhammond at skippinet.com.au Thu Nov 11 22:46:01 2010 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 12 Nov 2010 08:46:01 +1100 Subject: [python-win32] Volunteer for list co-moderator Message-ID: <4CDC6419.1090001@skippinet.com.au> Hi all, I just returned from nearly 2 weeks away with poor internet access and found quite a few mailing list posts waiting moderation (mainly due to postings by non-members). I'm letting them through now and I apologize if any of these messages are now "stale". To prevent this happening in the future, it might make sense to have another list moderator - the burden isn't great. Please let me know if you are willing to help here. Thanks, Mark From timr at probo.com Fri Nov 12 00:18:02 2010 From: timr at probo.com (Tim Roberts) Date: Thu, 11 Nov 2010 15:18:02 -0800 Subject: [python-win32] How to make Python identify GUI buttons by their label In-Reply-To: <30164133.post@talk.nabble.com> References: <30164133.post@talk.nabble.com> Message-ID: <4CDC79AA.2050608@probo.com> ChristopherTom wrote: > The contractor we hired told us that Python can only recognize GUI objects, > specifically buttons, by their ID. This is very inconvenient and hard to > work with as the button IDs change a lot between builds. Instead, I want to > reference a button by its label like "Save", "Preview", or "Submit." Does > anyone know how I can accomplish this? I can't tell what this means. Are you poking through another application's window? Typically, control IDs don't change that often. What do you mean by "recognize"? Anything you can do from a C application can be done from Python. If you are searching for subwindows, you can call the FindWindow API, which accepts titles. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Nov 12 00:21:42 2010 From: timr at probo.com (Tim Roberts) Date: Thu, 11 Nov 2010 15:21:42 -0800 Subject: [python-win32] A question about COM in general In-Reply-To: <5E94BFD292E6664094E77128C4C459B5044925567D@eros2.Fekete.com> References: <5E94BFD292E6664094E77128C4C459B5044925567D@eros2.Fekete.com> Message-ID: <4CDC7A86.1030807@probo.com> Eileen Wei wrote: > > I wonder if ctype can be used on C++ code as well? By searching on > line the answer I found seems to be that it can?t, but I don?t know if > those are the ?right? answers. If ctype can be used on C++ then it > seems like the most straightforward way to go, is that correct? > ctypes can't be used to call C++ object methods. It calls DLL entry points. > The applications I would like to test by exposing their APIs are not > designed to be controlled programmatically, and even though some of > them have very limited COM interface, most don?t. And I think I > probably need to expose a function from here and a function from there > depending on what I need to drive my test. > If an application is not designed to be controlled programmatically, then you can't force it to be controlled. It would require modifications to the applications. As long as you are modifying the applications, you might as well expose a COM interface to do what you need. > So if ctype cannot be used on C++, then between COM, SWIG and PyCXX, > which would be a better choice? Also Tim you mentioned learning curve > of SWIG, I wonder how is that compared to COM? > So, what are we talking about here? Are you talking about adding something to an existing application that allows it to be controlled from the outside? In that case, I don't thing SWIG or PyCXX will help you. Those things let you call into DLLs, not into other applications. COM support is already built-in to Python. If you have the option to add a COM interface, that's probably the way to go. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From robert2682 at verizon.net Fri Nov 12 01:50:04 2010 From: robert2682 at verizon.net (robert2682) Date: Thu, 11 Nov 2010 19:50:04 -0500 Subject: [python-win32] Works in 2.6, doesn't in 2.7 Message-ID: <4CDC8F3C.8090100@verizon.net> Hi, I've got a flaky problem. I'm working on a win32com based Excel add-in. The problem I've got is that under python 2.7, importing wx (wxPython) inside the Excel add-in fails. Under python 2.6, the same code works. I've written a sample program (attached) to demonstrate. To run: install Python, Win32 extensions and wxPython, register test program, and fire up Excel. The install binaries I have are: python-2.7.msi pywin32-214.win32-py2.7.exe wxPython2.8-win32-unicode-2.8.11.0-py27.exe This is not obviously a wxPython problem (although it may be), as importing works ok outside Excel, as demonstrated by running the test program to register. Any help or suggestions in tracking this down would be appreciated. Thanks, Robert Kaplan robert2682 at verizon.net -------------- next part -------------- A non-text attachment was scrubbed... Name: excel_wx_bug.py Type: text/x-python Size: 2793 bytes Desc: not available URL: From mike.diehn at ansys.com Fri Nov 12 03:15:10 2010 From: mike.diehn at ansys.com (Mike Diehn) Date: Thu, 11 Nov 2010 21:15:10 -0500 Subject: [python-win32] Volunteer for list co-moderator In-Reply-To: <4CDC6419.1090001@skippinet.com.au> References: <4CDC6419.1090001@skippinet.com.au> Message-ID: Sure, happy to lend a hand if you'd like. On Thu, Nov 11, 2010 at 4:46 PM, Mark Hammond wrote: > Hi all, > I just returned from nearly 2 weeks away with poor internet access and > found quite a few mailing list posts waiting moderation (mainly due to > postings by non-members). I'm letting them through now and I apologize if > any of these messages are now "stale". > > To prevent this happening in the future, it might make sense to have > another list moderator - the burden isn't great. Please let me know if you > are willing to help here. > > Thanks, > > Mark > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- Mike Diehn Senior Systems Administrator ANSYS, Inc - Lebanon, NH Office mike.diehn at ansys.com, (603) 727-5492 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Fri Nov 12 09:57:46 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 12 Nov 2010 08:57:46 +0000 Subject: [python-win32] WMI qualifier In-Reply-To: References: Message-ID: <4CDD018A.4010506@timgolden.me.uk> On 04/11/2010 15:13, ^_^Sisyphus^_^ wrote: > I start to use WMI python binding recently. I want to know whether there is > any way to retrieve the qualifier information of a WMI object? > For example, in Win32_Process the OtherTransferCountData has a unit in bytes > but PageFileUsageData has a unit in kilobytes: > OtherTransferCountData type: uint64 Access type: Read-only Qualifiers: Units > (Bytes) > PageFileUsageData type: uint32 Access type: Read-only Qualifiers: Units > (Kilobytes) > How could I retrieve those string value from their qualifiers, such as: > 'Bytes', 'Kilobytes'? This is a little bit fiddly (basically because I haven't exposed the information straightforwardly): import wmi c = wmi.WMI () for p in c.Win32_Process.Properties_: for q in p.Qualifiers_: if q.Name == "Units": print p.Name, "=>", q.Value break TJG From brian at merrells.org Mon Nov 15 19:14:56 2010 From: brian at merrells.org (Brian Merrell) Date: Mon, 15 Nov 2010 13:14:56 -0500 Subject: [python-win32] Dynamic dispatching and AttributeErrors, Message-ID: I am using Windows 7, 32-bit python 2.6, 2.7 and the latest win32 release. - makepy seems to work, I find what appears to be the one and only appropriate library and it places an early binding skeleton file in the expected gen_py directory. Anticipated classes and methods are observed. - Whenever I call win32com.client.Dispatch on the "common name" (as derived from the skeleton file) it seems to return the dynamic dispatched version (even after using the EnsureModule method) - When I try calling a known method on the returned COM object I get an AttributeError - I've also tried using every CLSID I can find in my skeleton file c = Dispatch(CLSID) which results in either a "Class not registered" or an object that also gives an AttributeError for a known method. The inability to give me the makepy generated early bound COM libary makes me think I am somehow not referring to it correctly. I am new to COM and win32 so I am not sure how to debug from here. Thanks, -b -------------- next part -------------- An HTML attachment was scrubbed... URL: From asmund.hjulstad at gmail.com Tue Nov 16 09:49:06 2010 From: asmund.hjulstad at gmail.com (=?ISO-8859-1?Q?=C5smund_Hjulstad?=) Date: Tue, 16 Nov 2010 11:49:06 +0300 Subject: [python-win32] Makepy does not generate all secondary interfaces? In-Reply-To: References: Message-ID: 2010/11/9 ?smund Hjulstad : > I am struggling with secondary interfaces and makepy > > I have generated an interface with makepy from a library ( PISDKCommon > 1.0 Type Library ). It has an object, PIAsynchStatus, that exposes a > secondary interface; IPIAsynchStatus2. I cannot find the secondary > interface in the generated module, though. I wanted to do something > like Mark Hammond suggested here: > http://code.activestate.com/lists/python-list/27760/ > > .. but without the secondary interface, I don't know how to do it. > > module = gencache.GetModuleForProgID('PISDKCommon.PIAsynchStatus') > module.IPIAsynchStatus2 ? # Throws AttributeError I am guessing the problem is that the library does not declare that the any classes implement these secondary interfaces. I have generated an IDL using the OLE/COM Object Viewer, where I see for example [ odl, uuid(6F8B6B6B-6232-458B-8783-7F73B98CDDC8), helpstring("Extended data operations for a PIPoint"), helpcontext(0x0000348a), dual, nonextensible, oleautomation ] < several methods omitted > interface IPIData2 : _PIData { [id(0x00000066), helpstring("Return interoplated values from the archive as a PIValues collection."), helpcontext(0x0000348d)] HRESULT InterpolatedValues2( [in] VARIANT StartTime, [in] VARIANT EndTime, [in] VARIANT SampleInterval, [in, optional, defaultvalue("")] BSTR filterExp, [in, optional, defaultvalue(0)] FilteredViewConstants ShowFiltered, [in, optional, defaultvalue(0)] _PIAsynchStatus* asynchStatus, [out, retval] _PIValues** ret); < several methods omitted > } but the class definition [ uuid(34B81AB1-F39B-11D2-BD71-00C04F779EB2), helpstring("This object accesses snapshot/archive data for a PIPoint"), noncreatable ] coclass PIData { [default] interface _PIData; }; does not declare that it implements IPIData2. And, possibly because of this, makepy never creates the proper early-bound interfaces for the IPIData2 interface. So, is there a way to force makepy (or gencache) to generate the interface? (or even better, to change the default interface of the returned objects) I have switched to late-bound invocation for now, and it works fine, but I would very much like to get early-bound working as it is much more elegant to work with in ipython. From skippy.hammond at gmail.com Wed Nov 17 04:43:08 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 17 Nov 2010 14:43:08 +1100 Subject: [python-win32] Makepy does not generate all secondary interfaces? In-Reply-To: References: Message-ID: <4CE34F4C.6000700@gmail.com> On 16/11/2010 7:49 PM, ?smund Hjulstad wrote: > I am guessing the problem is that the library does not declare that the > any classes implement these secondary interfaces. It should iterate over every interface in the .idl file - see BuildOleItemsFromType in genpy.py (and maybe some "print debugging" in that file will help you see what is going on) > So, is there a way to force makepy (or gencache) to generate the interface? Nope - as it shouldn't skip them in the first place. > (or even better, to change the default interface of the returned objects) win32com will help you a little here - assuming the interface is generated, you could say something like: mod = win32com.gencache.EnsureModule(...) obj = win32com.client.Dispatch(...) # get default interface. obj = mod.SomeOtherInterface(ob) # convert to SomeOtherInterface This works due to the __init__ method generated for the interfaces (it does a QI - see the generated code for details) HTH, Mark From m.g.bode at web.de Wed Nov 17 07:40:34 2010 From: m.g.bode at web.de (Michael Bode) Date: Wed, 17 Nov 2010 07:40:34 +0100 Subject: [python-win32] How to implement a callback COM object Message-ID: <4CE378E2.60609@web.de> Hi, I've problems to get started with COM programming. I'm trying to write a COM client which uses a COM server controlling an instrument (power meter). The COM Server is using a DLL called FieldMax2ServerDLL which is registered. I've run makepy to get the bindings. Now to do anything useful with the server I have to implement a callback object which implements an interface from said DLL. I have VB sample code, but don't know how to translate that to python: Option Explicit Implements IFM2DeviceEvents Private m_CallbackEvent As String Private m_CallbackMessage As String Private m_DeviceIndex As Integer Private m_SerialNumber As String Private m_ZeroDeviceTimeoutCounter As Integer ' Methods Private Sub IFM2DeviceEvents_DisplayErrorToClient() frmTest.DisplayErrorMessage m_CallbackMessage End Sub Private Sub IFM2DeviceEvents_NotifyData(ByVal CallbackData As IFM2DeviceEvents) frmTest.NotifyData CallbackData End Sub Private Sub IFM2DeviceEvents_NotifyDeviceStatus(ByVal CallbackData As IFM2DeviceEvents, ByVal DevicesList As cFM2Devices) frmTest.NotifyDeviceStatus CallbackData, DevicesList End Sub Private Sub IFM2DeviceEvents_DisplayZeroDeviceProgressToClient() frmTest.DisplayZeroDeviceProgress m_CallbackMessage, m_ZeroDeviceTimeoutCounter End Sub ' Read/write properties Private Property Let IFM2DeviceEvents_CallbackEvent(ByVal RHS As String) m_CallbackEvent = RHS End Property Private Property Get IFM2DeviceEvents_CallbackEvent() As String IFM2DeviceEvents_CallbackEvent = m_CallbackEvent End Property ... -- PGP fingerprint: A391 4109 F8D0 F67B C504 1EF6 0158 E3BB 3687 53CF From skippy.hammond at gmail.com Thu Nov 18 07:19:56 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 18 Nov 2010 17:19:56 +1100 Subject: [python-win32] Dynamic dispatching and AttributeErrors, In-Reply-To: References: Message-ID: <4CE4C58C.3080803@gmail.com> On 16/11/2010 5:14 AM, Brian Merrell wrote: > I am using Windows 7, 32-bit python 2.6, 2.7 and the latest win32 release. > > * makepy seems to work, I find what appears to be the one and only > appropriate library and it places an early binding skeleton file > in the expected gen_py directory. Anticipated classes and methods > are observed. > * Whenever I call win32com.client.Dispatch on the "common name" (as > derived from the skeleton file) it seems to return the dynamic > dispatched version (even after using the EnsureModule method) The above can happen for some objects which don't correctly report their type information at runtime - in which case you can often trick things using code similar to: mod = win32com.gencache.EnsureModule(...) ob = win32com.client.Dispatch(...) # convert from dynamic to makepy supported. ob = mod.GeneratedClassName(ob) > * When I try calling a known method on the returned COM object I get > an AttributeError > * I've also tried using every CLSID I can find in my skeleton file c > = Dispatch(CLSID) which results in either a "Class not registered" > or an object that also gives an AttributeError for a known method. A traceback would be useful here - if the object really is a dynamic object, an AttributeError implies that the object itself also doesn't think the attribute exists (as dynamic objects ask the object for the attribute before raising an AttributeError). HTH, Mark From brian at merrells.org Thu Nov 18 07:45:32 2010 From: brian at merrells.org (Brian Merrell) Date: Thu, 18 Nov 2010 01:45:32 -0500 Subject: [python-win32] Dynamic dispatching and AttributeErrors, In-Reply-To: <4CE4C58C.3080803@gmail.com> References: <4CE4C58C.3080803@gmail.com> Message-ID: Thanks for the response Mark. My results inline below: mod = win32com.gencache.EnsureModule(...) > >>print mod > ob = win32com.client.Dispatch(...) > >>ob >>print ob Traceback (most recent call last): File "", line 1, in File "c:\python26\lib\site-packages\win32com\client\dynamic.py", line 197, in __str__ return str(self.__call__()) File "c:\python26\lib\site-packages\win32com\client\dynamic.py", line 182, in __call__ return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None) pywintypes.com_error: (-2147319779, 'Library not registered.', None, None) # convert from dynamic to makepy supported. > ob = mod.GeneratedClassName(ob) > Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'GeneratedClassName' * When I try calling a known method on the returned COM object I get > >> an AttributeError >> * I've also tried using every CLSID I can find in my skeleton file c >> = Dispatch(CLSID) which results in either a "Class not registered" >> or an object that also gives an AttributeError for a known method. >> > > A traceback would be useful here - if the object really is a dynamic > object, an AttributeError implies that the object itself also doesn't think > the attribute exists (as dynamic objects ask the object for the attribute > before raising an AttributeError). > I am calling a method listed in the gen_py file so I am not sure how the attribute could not exist (I was careful about capitalization. I can post/send a very abbreviated version of this file (just the wrapper stuff and a single method) if it would help. Thanks! -brian -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Thu Nov 18 22:35:50 2010 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 19 Nov 2010 08:35:50 +1100 Subject: [python-win32] Dynamic dispatching and AttributeErrors, In-Reply-To: References: <4CE4C58C.3080803@gmail.com> Message-ID: <4CE59C36.8000005@skippinet.com.au> On 18/11/2010 5:45 PM, Brian Merrell wrote: > ob = win32com.client.Dispatch(...) > > >>ob > > >>print ob > Traceback (most recent call last): > File "", line 1, in > File "c:\python26\lib\site-packages\win32com\client\dynamic.py", line > 197, in __str__ > return str(self.__call__()) > File "c:\python26\lib\site-packages\win32com\client\dynamic.py", line > 182, in __call__ > return > self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None) > pywintypes.com_error: (-2147319779, 'Library not registered.', None, None) That is very strange - it seems at least one type library needed isn't registered - although the fact makepy ran at all means at least one type library *is* registered. > A traceback would be useful here - if the object really is a dynamic > object, an AttributeError implies that the object itself also > doesn't think the attribute exists (as dynamic objects ask the > object for the attribute before raising an AttributeError). > > I am calling a method listed in the gen_py file so I am not sure how the > attribute could not exist (I was careful about capitalization. I can > post/send a very abbreviated version of this file (just the wrapper > stuff and a single method) if it would help. That is why a traceback would be useful for the attribute error - but it sounds like the object you are calling isn't a makepy instance, just a regular dynamic dispatch object, so the makepy class isn't being used. That is what should have been addressed by explicitly wrapping it in the class, but for reasons I can't explain that generates the "type lib not registered" error. I'm afraid I'm out of ideas - can you try reinstalling the COM object, or asking for help from the author of that object? Cheers, Mark From asmund.hjulstad at gmail.com Fri Nov 19 08:05:55 2010 From: asmund.hjulstad at gmail.com (=?ISO-8859-1?Q?=C5smund_Hjulstad?=) Date: Fri, 19 Nov 2010 10:05:55 +0300 Subject: [python-win32] Makepy does not generate all secondary interfaces? In-Reply-To: <4CE34F4C.6000700@gmail.com> References: <4CE34F4C.6000700@gmail.com> Message-ID: 2010/11/17 Mark Hammond : > On 16/11/2010 7:49 PM, ?smund Hjulstad wrote: >> >> I am guessing the problem is that the library does not declare that the >> any classes implement these secondary interfaces. > > It should iterate over every interface in the .idl file - see > BuildOleItemsFromType in genpy.py (and maybe some "print debugging" in that > file will help you see what is going on) It finds the interface, and calls oleItem, vtableItem = self._Build_Interface(type_info_tuple) however, with bForDemand = True, the generated module does not have members matching the interface. With bForDemand = false, it works. As an example, with an emtpy gen_py directory, the following code works for me, but changing to bForDemand = True does not. pisdk = gencache.EnsureModule('{0EE075CE-8C31-11D1-BD73-0060B0290178}', 0, 1, 1, bForDemand = False) medlemmer = pisdk.__dict__ for k,v in medlemmer.iteritems(): if k.startswith("IPIData2"): print k # This prints (only when bForDemand=False) # IPIData2 # IPIData2_vtables_dispatch_ # IPIData2_vtables_ pis = Dispatch("PISDK.PISDK") servernavn = "st-w240" server = pis.Servers(servernavn) tag = server.PIPoints('TT-20130/Meas1/PRIM') data = tag.Data data2 = pisdk.IPIData2(data) # with bForDemand=True, I get an exception here verdier = data2.InterpolatedValues2('*-1h','*','10m',asynchStatus=None) for v in verdier: print(v) I have not looked into how changing bForDemand would affect this, but am happy so far with the "old" behaviour. As a sidenote, the other secondary interface I have been struggling with, IPIAsynchStatus2, still does not work, regardless of the setting. It finds the interface, but oleItem, vtableItem = self._Build_Interface(type_info_tuple) returns a None oleItem. (don't know why, though.) Thank you very much for your help, the stuff I need is working now. Please let me know if more debugging is of interest to you. ?smund From admin at genesisware.de Fri Nov 19 00:13:37 2010 From: admin at genesisware.de (admin at genesisware.de) Date: Fri, 19 Nov 2010 00:13:37 +0100 (CET) Subject: [python-win32] Simple selection of item in list Message-ID: <20101118231337.390A012801A3@dd11004.kasserver.com> Hi, my problem is probably simple but I haven?t found a solution anyway. I want so select items from an item list that allows multiple selections. I have got the handle of a SysListView32 control and the item index of the item I want to select. How can I arrange this in pywin? Every help is appreciated. Thanks, Stefan George From greg.ewing at canterbury.ac.nz Fri Nov 19 09:48:58 2010 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Fri, 19 Nov 2010 21:48:58 +1300 Subject: [python-win32] ANN: PyGUI 2.3.1 Message-ID: <4CE639FA.9090802@canterbury.ac.nz> PyGUI 2.3.1 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ This version incorporates a modification that I hope will improve the behaviour of ScrollableViews on Windows with pywin32 builds later than 212. (There are still problems with it, though. If the Scrollable View doesn't fill all of its containing window, the scroll bars get repositioned incorrectly when the window is resized. This appears to be entirely MFC's doing. I really will have to get away from using CView altogether.) This version also fixes a problem on Windows whereby dismissing a modal dialog with the Return key could spuriously activate a button in another window. What is PyGUI? -------------- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing greg.ewing at canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ From timr at probo.com Fri Nov 19 19:43:38 2010 From: timr at probo.com (Tim Roberts) Date: Fri, 19 Nov 2010 10:43:38 -0800 Subject: [python-win32] Simple selection of item in list In-Reply-To: <20101118231337.390A012801A3@dd11004.kasserver.com> References: <20101118231337.390A012801A3@dd11004.kasserver.com> Message-ID: <4CE6C55A.806@probo.com> admin at genesisware.de wrote: > my problem is probably simple but I haven?t found a solution anyway. I want so select items from an item list that allows multiple selections. > > I have got the handle of a SysListView32 control and the item index of the item I want to select. > > How can I arrange this in pywin? Where did the handle come from? Is this a control within your own application? One of the awkward things about the SysListView32 control is that most of its messages require structures, and the structures are not marshaled properly across process boundaries, so it's very difficult to control one in another process. If it is within your own process, you can send an LVM_SETITEMSTATE message with the appropriate LVITEM structure. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From admin at genesisware.de Sat Nov 20 12:57:50 2010 From: admin at genesisware.de (admin at genesisware.de) Date: Sat, 20 Nov 2010 12:57:50 +0100 (CET) Subject: [python-win32] python-win32 Digest, Vol 92, Issue 16 Message-ID: <20101120115751.17F9C12CC016@dd11004.kasserver.com> Thanks for you answer. The handle is unfortunately from another process. This is a piece of code I have found on the web that works great to get the values of a list from another process. I have marked the part where I want to select a list item: def readListViewItems(hwnd, column_index=0): # Allocate virtual memory inside target process pid = ctypes.create_string_buffer(4) p_pid = ctypes.addressof(pid) GetWindowThreadProcessId(hwnd, p_pid) # process owning the given hwnd hProcHnd = OpenProcess(PROCESS_ALL_ACCESS, False, struct.unpack("i",pid)[0]) pLVI = VirtualAllocEx(hProcHnd, 0, 4096, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE) pBuffer = VirtualAllocEx(hProcHnd, 0, 4096, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE) # Prepare an LVITEM record and write it to target process memory lvitem_str = struct.pack('iiiiiiiii', *[0,0,column_index,0,0,pBuffer,4096,0,0]) lvitem_buffer = ctypes.create_string_buffer(lvitem_str) copied = ctypes.create_string_buffer(4) p_copied = ctypes.addressof(copied) WriteProcessMemory(hProcHnd, pLVI, ctypes.addressof(lvitem_buffer), ctypes.sizeof(lvitem_buffer), p_copied) # iterate items in the SysListView32 control num_items = win32gui.SendMessage(hwnd, LVM_GETITEMCOUNT) item_texts = [] for item_index in range(num_items): win32gui.SendMessage(hwnd, LVM_GETITEMTEXT, item_index, pLVI) target_buff = ctypes.create_string_buffer(4096) ReadProcessMemory(hProcHnd, pBuffer, ctypes.addressof(target_buff), 4096, p_copied) item_texts.append(target_buff.value) if target_buff.value == "something": # HERE THE list item should be selected, if the value of the list item is something # # # pass VirtualFreeEx(hProcHnd, pBuffer, 0, MEM_RELEASE) VirtualFreeEx(hProcHnd, pLVI, 0, MEM_RELEASE) win32api.CloseHandle(hProcHnd) return item_texts Do you have an idea? -----Urspr?ngliche Nachricht----- Von: python-win32-bounces+admin=genesisware.de at python.org [mailto:python-win32-bounces+admin=genesisware.de at python.org] Im Auftrag von python-win32-request at python.org Gesendet: Samstag, 20. November 2010 12:00 An: python-win32 at python.org Betreff: python-win32 Digest, Vol 92, Issue 16 Send python-win32 mailing list submissions to python-win32 at python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-win32 or, via email, send a message with subject or body 'help' to python-win32-request at python.org You can reach the person managing the list at python-win32-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of python-win32 digest..." Today's Topics: 1. Re: Simple selection of item in list (Tim Roberts) ---------------------------------------------------------------------- Message: 1 Date: Fri, 19 Nov 2010 10:43:38 -0800 From: Tim Roberts To: Python-Win32 List Subject: Re: [python-win32] Simple selection of item in list Message-ID: <4CE6C55A.806 at probo.com> Content-Type: text/plain; charset="UTF-8" admin at genesisware.de wrote: > my problem is probably simple but I haven?t found a solution anyway. I want so select items from an item list that allows multiple selections. > > I have got the handle of a SysListView32 control and the item index of the item I want to select. > > How can I arrange this in pywin? Where did the handle come from? Is this a control within your own application? One of the awkward things about the SysListView32 control is that most of its messages require structures, and the structures are not marshaled properly across process boundaries, so it's very difficult to control one in another process. If it is within your own process, you can send an LVM_SETITEMSTATE message with the appropriate LVITEM structure. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. ------------------------------ _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 End of python-win32 Digest, Vol 92, Issue 16 ******************************************** From timr at probo.com Mon Nov 22 19:51:54 2010 From: timr at probo.com (Tim Roberts) Date: Mon, 22 Nov 2010 10:51:54 -0800 Subject: [python-win32] python-win32 Digest, Vol 92, Issue 16 In-Reply-To: <20101120115751.17F9C12CC016@dd11004.kasserver.com> References: <20101120115751.17F9C12CC016@dd11004.kasserver.com> Message-ID: <4CEABBCA.5020508@probo.com> admin at genesisware.de wrote: > Thanks for you answer. The handle is unfortunately from another process. > > This is a piece of code I have found on the web that works great to get the values of a list from another process. I have marked the part where I want to select a list item: Yes, this is what it takes. Do you see how nasty this is? You are injecting code and data into another processes memory space. Sheesh. > def readListViewItems(hwnd, column_index=0): > ... > for item_index in range(num_items): > win32gui.SendMessage(hwnd, LVM_GETITEMTEXT, item_index, pLVI) > target_buff = ctypes.create_string_buffer(4096) > ReadProcessMemory(hProcHnd, pBuffer, ctypes.addressof(target_buff), 4096, p_copied) > item_texts.append(target_buff.value) > > if target_buff.value == "something": > # HERE THE list item should be selected, if the value of the list item is something > # > # > # > pass You will need to send an LVM_GETITEM message to fetch the item's attributes. Then, you'll change the items "state" to make it selected. Then you will send an LVM_SETITEM to make your changes permanent. Note that the LVM_GETITEM can also fetch the text of the item. You'll want to read the description of those messages carefully. Remember that you will have to use ReadProcessMemory and WriteProcessMemory to access the structure. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From hubbardsoftware at sbcglobal.net Mon Nov 22 23:40:53 2010 From: hubbardsoftware at sbcglobal.net (Gary Hubbard) Date: Mon, 22 Nov 2010 14:40:53 -0800 (PST) Subject: [python-win32] Accessing a dictionary like object using WebServices from Win32 Message-ID: <144295.78657.qm@web81102.mail.mud.yahoo.com> Hi I am trying to communicate with a vendor's WebService, using PyWin32.? I am successful using most of the methods, but I don't know how to interpret those returning a dictionary like object. Obfuscating the vendor name with XXX everywhere, to avoid checking on whether it is acceptable to communicate about this, the code looks like ??? sc = win32com.client.Dispatch("MSSOAP.SoapClient") ??? sc.mssoapinit("http://localhost:1024/wsdl/IXXXWebService") ??? sc.connect() ??? ret = sc.ReadMeasureDataParam(paramName) Under C# or VB, ret would be a dictionary like object with?6 different keys, such as LongName and ShortName, accessed as ret.LongName, etc.? Using that under PyWin32 gives an attribute error, but I can index with the [0] to [5].? Unfortunately, doing that still returns an object I don't know how to interpret. There are several other functions that have the same issue, but I think the basic problem is identical. The relevant XML code follows.? I manually chopped the code apart, eliminating what I though was unnecessary.? Thanks, XML Code follows: ? ??? ????? ??????? ????????? ????????? ????????? ????????? ????????? ????????? ??????? ????? ??? ? ? ??? ? ? ??? ? ? ??? ????? ????? ??? ? ? ??? ??? ????? ????? ??????? ????? ????? ??????? ????? ??? ? ? ??? ????? ??? ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From janssen at parc.com Tue Nov 23 20:13:20 2010 From: janssen at parc.com (Bill Janssen) Date: Tue, 23 Nov 2010 11:13:20 PST Subject: [python-win32] Can't see Python27.dll on Win 7 Message-ID: <57598.1290539600@parc.com> Hi. I'm trying to install PyLucene using MinGW on Windows 7. It keeps failing when it tries to load the _jcc.pyd module (JCC is the compiler which wraps the Java Lucene library as a Python module). It fails with the notorious c:\Python27\python.exe: DLL load failed: The specified module could not be found. So, to figure out what's failing, I fired up depends.exe on _jcc.pyd. And I find that the missing DLL appears to be PYTHON27.DLL! Odd, thinks I. So I went to look in c:/Windows/System32/, and sure enough, there it is: $ file /c/Windows/System32/python27.dll /c/Windows/System32/python27.dll: PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit $ Then I try to fire up depends.exe on it, and depends.exe *can't see it*! That is, when I choose "File > Open" from the menu, and select C:\Windows\System32\, the list of dlls that I can inspect goes right from "pwrshplugin.dll" to "QAGENT.dll"! And if I open a cmd shell, "dir" doesn't show it, either! Though msys "ls" does. Does anyone understand what's going on here? I'm baffled. I'm using the 32-bit version of Python 2.7, by the way, and it's a 64-bit install of Windows 7 Enterprise. Bill From timr at probo.com Tue Nov 23 20:21:09 2010 From: timr at probo.com (Tim Roberts) Date: Tue, 23 Nov 2010 11:21:09 -0800 Subject: [python-win32] Can't see Python27.dll on Win 7 In-Reply-To: <57598.1290539600@parc.com> References: <57598.1290539600@parc.com> Message-ID: Bill wrote: > >So I went to look in c:/Windows/System32/, and sure enough, there it is: > >$ file /c/Windows/System32/python27.dll >/c/Windows/System32/python27.dll: PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit >$ On 64-bit Windows, 32-bit DLLs need to be installed in C:\Windows\SysWOW64, not C:\Windows\System32. Yes, that's not a typo. When a 32-bit application refers to System32, the operating system automatically rewrites the path to SysWOW64. Now, if your Cygwin is a 32-bit app, it could be getting fooled as well. I suggest you start up a command shell and see where the file really lives. If it really lives in system32, you'll need to move it. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From janssen at parc.com Tue Nov 23 21:04:22 2010 From: janssen at parc.com (Bill Janssen) Date: Tue, 23 Nov 2010 12:04:22 PST Subject: [python-win32] Can't see Python27.dll on Win 7 In-Reply-To: References: <57598.1290539600@parc.com> Message-ID: <59914.1290542662@parc.com> Tim Roberts wrote: > Bill wrote: > > > >So I went to look in c:/Windows/System32/, and sure enough, there it is: > > > >$ file /c/Windows/System32/python27.dll > >/c/Windows/System32/python27.dll: PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit > >$ > > On 64-bit Windows, 32-bit DLLs need to be installed in C:\Windows\SysWOW64, not C:\Windows\System32. Yes, that's not a typo. Well, it's the Python installer that's doing the installing; I assume it's doing it correctly. In fact, when I look at C:\Windows\SysWOW64, I can see python27.dll. > When a 32-bit application refers to System32, the operating system > automatically rewrites the path to SysWOW64. Now, if your Cygwin is a > 32-bit app, it could be getting fooled as well. So, if I "cd" to "/c/Windows/System32", and do "ls -l python27.dll", it's really looking at "/c/Windows/SysWOW64" instead? That's why I see it with msys's "ls" and "file", but not with cmd.exe and "dir", or depends.exe? > I suggest you start up a command shell and see where the file really > lives. If it really lives in system32, you'll need to move it. Looks like it's in C:\Windows\SysWOW64\, as it should be. Thanks, Tim. Bill From timr at probo.com Tue Nov 23 21:59:23 2010 From: timr at probo.com (Tim Roberts) Date: Tue, 23 Nov 2010 12:59:23 -0800 Subject: [python-win32] Can't see Python27.dll on Win 7 In-Reply-To: <59914.1290542662@parc.com> References: <57598.1290539600@parc.com> <59914.1290542662@parc.com> Message-ID: <4CEC2B2B.8070400@probo.com> Bill Janssen wrote: > > So, if I "cd" to "/c/Windows/System32", and do "ls -l python27.dll", > it's really looking at "/c/Windows/SysWOW64" instead? That's why I see > it with msys's "ls" and "file", but not with cmd.exe and "dir", or > depends.exe? Yes, although "depends" should be smart enough to find it, assuming you have a 32-bit executable. If your root executable is 64-bit, then you will need to install a 64-bit Python. Unlike the 16/32 days, there is no thunking. A 64-bit app cannot load a 32-bit DLL, nor vice versa. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From janssen at parc.com Tue Nov 23 22:56:53 2010 From: janssen at parc.com (Bill Janssen) Date: Tue, 23 Nov 2010 13:56:53 PST Subject: [python-win32] Can't see Python27.dll on Win 7 In-Reply-To: <4CEC2B2B.8070400@probo.com> References: <57598.1290539600@parc.com> <59914.1290542662@parc.com> <4CEC2B2B.8070400@probo.com> Message-ID: <64795.1290549413@parc.com> Tim Roberts wrote: > Bill Janssen wrote: > > > > So, if I "cd" to "/c/Windows/System32", and do "ls -l python27.dll", > > it's really looking at "/c/Windows/SysWOW64" instead? That's why I see > > it with msys's "ls" and "file", but not with cmd.exe and "dir", or > > depends.exe? > > Yes, although "depends" should be smart enough to find it, assuming you > have a 32-bit executable. If your root executable is 64-bit, then you > will need to install a 64-bit Python. Unlike the 16/32 days, there is > no thunking. A 64-bit app cannot load a 32-bit DLL, nor vice versa. No, I'm carefully using 32-bit Python and 32-bit Java. My guess is that the compilation of the JCC module is going wrong somehow. Perhaps the wrong linker flags: C:\MinGW\bin\g++.exe -mno-cygwin -shared -s build\temp.win32-2.7\Release\jcc\sources\jcc.o build\temp.win32-2.7\Release\jcc\sources\jccenv.o build\temp.win32-2.7\Release\jcc\sources\jobject.o build\temp.win32-2.7\Release\jcc\sources\jarray.o build\temp.win32-2.7\Release\jcc\sources\functions.o build\temp.win32-2.7\Release\jcc\sources\types.o build\temp.win32-2.7\Release\_jcc\boot.o build\temp.win32-2.7\Release\_jcc\java\io\printwriter.o build\temp.win32-2.7\Release\_jcc\java\io\stringwriter.o build\temp.win32-2.7\Release\_jcc\java\io\writer.o build\temp.win32-2.7\Release\_jcc\java\io\__init__.o build\temp.win32-2.7\Release\_jcc\java\lang\boolean.o build\temp.win32-2.7\Release\_jcc\java\lang\byte.o build\temp.win32-2.7\Release\_jcc\java\lang\character.o build\temp.win32-2.7\Release\_jcc\java\lang\class.o build\temp.win32-2.7\Release\_jcc\java\lang\double.o build\temp.win32-2.7\Release\_jcc\java\lang\exception.o build\temp.win32-2.7\Release\_jcc\java\lang\float.o build\temp.win32-2.7\Release\_jcc\java\lang\integer.o build\temp.win32-2.7\Release\_jcc\java\lang\long.o build\temp.win32-2.7\Release\_jcc\java\lang\object.o build\temp.win32-2.7\Release\_jcc\java\lang\runtimeexception.o build\temp.win32-2.7\Release\_jcc\java\lang\short.o build\temp.win32-2.7\Release\_jcc\java\lang\string.o build\temp.win32-2.7\Release\_jcc\java\lang\throwable.o build\temp.win32-2.7\Release\_jcc\java\lang\__init__.o build\temp.win32-2.7\Release\_jcc\java\lang\reflect\constructor.o build\temp.win32-2.7\Release\_jcc\java\lang\reflect\field.o build\temp.win32-2.7\Release\_jcc\java\lang\reflect\genericarraytype.o build\temp.win32-2.7\Release\_jcc\java\lang\reflect\genericdeclaration.o build\temp.win32-2.7\Release\_jcc\java\lang\reflect\method.o build\temp.win32-2.7\Release\_jcc\java\lang\reflect\modifier.o build\temp.win32-2.7\Release\_jcc\java\lang\reflect\parameterizedtype.o build\temp.win32-2.7\Release\_jcc\java\lang\reflect\type.o build\temp.win32-2.7\Release\_jcc\java\lang\reflect\typevariable.o build\temp.win32-2.7\Release\_jcc\java\lang\reflect\wildcardtype.o build\temp.win32-2.7\Release\_jcc\java\lang\reflect\__init__.o build\temp.win32-2.7\Release\_jcc\java\util\enumeration.o build\temp.win32-2.7\Release\_jcc\java\util\iterator.o build\temp.win32-2.7\Release\jcc\sources\_jcc.def -Lc:\Python27\libs -Lc:\Python27\PCbuild -lpython27 -lmsvcr90 -o build\lib.win32-2.7\jcc\_jcc.pyd "-LC:\Program Files (x86)\Java\jdk1.6.0_22/lib" -ljvm -Wl,--enable-auto-import -Wl,-S Bill From timr at probo.com Tue Nov 23 23:10:40 2010 From: timr at probo.com (Tim Roberts) Date: Tue, 23 Nov 2010 14:10:40 -0800 Subject: [python-win32] Can't see Python27.dll on Win 7 In-Reply-To: <57598.1290539600@parc.com> References: <57598.1290539600@parc.com> Message-ID: <4CEC3BE0.1000304@probo.com> Bill Janssen wrote: > I'm trying to install PyLucene using MinGW on Windows 7. It keeps > failing when it tries to load the _jcc.pyd module (JCC is the compiler > which wraps the Java Lucene library as a Python module). It fails > with the notorious > > c:\Python27\python.exe: DLL load failed: The specified module could not be found. > > So, to figure out what's failing, I fired up depends.exe on _jcc.pyd. > And I find that the missing DLL appears to be PYTHON27.DLL! Is that the only missing DLL? That would already have been loaded by python.exe, so it should not be a problem. Here's another option. It is not well known that the newer versions of "depends" have a trace mode. You can launch an executable from inside "depends", and it will trace all of the DLL loads and unloads. That might tell you something. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gstellenberg at gmail.com Mon Nov 29 07:20:46 2010 From: gstellenberg at gmail.com (Gerry Stellenberg) Date: Mon, 29 Nov 2010 00:20:46 -0600 Subject: [python-win32] Python COM server corrupting VB parameter? Message-ID: I'm struggling through the development of some python COM server code as a relative newbie and running into an issue. My win32com module is build 214. My python COM server class: class Controller: _public_methods_ = [ ] _reg_progid_ = "VPinMAME.Controller" _reg_clsid_ = "{F389C8B7-144F-4C63-A2E3-246D168F9D39}" _public_attrs_ = [ , 'Switch', ] _readonly_attrs_ = [ ] switch = [True]*128 lastSwitch = 0 def Switch(self, number): return True def SetSwitch(self, number, value): return True My client is a VB client. The issue occurs when the client issues the following: Controller.Switch(mSw(x)) = False mSw is an array. If I print mSw(x) before making the COM call, it prints out the expected value, but if I print it out again after the call, mSw(x) is " ". I'm assuming the parameter is being passed by reference and something on the python side is corrupting it. To rule out the code that I used to have in SetSwitch, I removed it all and now just return, but the corruption still occurs. Do I need to handle the params differently, or is this an issue with win32com? The values of the params are the expected values; so I know the values aren't getting corrupted on the way in. Thanks. - Gerry * * -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at clondiag.com Mon Nov 29 15:19:26 2010 From: matt at clondiag.com (Matthias Kirst) Date: Mon, 29 Nov 2010 15:19:26 +0100 Subject: [python-win32] Python COM server corrupting VB parameter? Message-ID: We stumbled across the same problem (10 years ago) and our solutions are: - use global variables - copy variable to another one and call COM server with this copy Hope this helps, Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From leegold at fastmail.fm Mon Nov 29 17:13:33 2010 From: leegold at fastmail.fm (leegold) Date: Mon, 29 Nov 2010 09:13:33 -0700 Subject: [python-win32] Pythonwin interactive window seems gone ? Message-ID: <1291047213.1892.1407696315@webmail.messagingengine.com> Hi, The interactive window ( the shell window) in Pythonwin is gone, I open it and it's an empty canvas - no window. The buttons are checked to show it. Maybe I'm missing something simple, not sure. Pywin32 build 214, using Activestate 2.6 on XP. Thanks From janssen at parc.com Mon Nov 29 18:49:35 2010 From: janssen at parc.com (Bill Janssen) Date: Mon, 29 Nov 2010 09:49:35 PST Subject: [python-win32] Can't see Python27.dll on Win 7 In-Reply-To: <4CEC3BE0.1000304@probo.com> References: <57598.1290539600@parc.com> <4CEC3BE0.1000304@probo.com> Message-ID: <12703.1291052975@parc.com> Tim Roberts wrote: > Here's another option. It is not well known that the newer versions of > "depends" have a trace mode. You can launch an executable from inside > "depends", and it will trace all of the DLL loads and unloads. That > might tell you something. Oh, very cool! Thanks so much for that tip. Bill From hejibo at gmail.com Mon Nov 29 20:23:25 2010 From: hejibo at gmail.com (He Jibo) Date: Mon, 29 Nov 2010 13:23:25 -0600 Subject: [python-win32] How do I get the URL of the active tab in Internet Explorer Message-ID: Hi, I am writing a small program, which needs to get the URL of the active tab in either of firefox, internet exploerer or chrome. My need is similar as the one posted at, http://stackoverflow.com/questions/3631216/how-do-i-get-the-url-of-the-visible-tab-in-firefox- ie-chrome I did a lot of Googling, and get the following code. The following code can get the url of the first tab in internet explorer. My question is, how can I get the url of the current active tab? Thanks. ''' http://efreedom.com/Question/1-2555905/Get-Internet-Explorer-Address-Bar-Python http://blogs.msdn.com/b/oldnewthing/archive/2005/07/05/435657.aspx http://mail.python.org/pipermail/python-win32/2004-June/002040.html http://code.activestate.com/recipes/302324-browser-automation-tool-py-class-file/ ''' from win32com.client import Dispatch import win32api, win32con,win32gui SHELL = Dispatch("Shell.Application") def get_ie(shell): for win in shell.Windows(): # print win if win.Name == "Windows Internet Explorer": return win return None def main(): ie = get_ie(SHELL) if ie: print ie.LocationURL print ie.LocationName print ie.ReadyState print ie print ie.Document.title print ie.Document.location print ie.Document.forms # title = win32gui.GetWindowText(ie) # print title else: print "no ie window" if __name__ == '__main__': main() --------------------------- He Jibo Department of Psychology, Beckman Institute for Advanced Science and Technology University of Illinois, Urbana Champaign, 603 East Daniel St., Champaign, IL 61820 website: www.hejibo.info -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Mon Nov 29 20:51:50 2010 From: vernondcole at gmail.com (Vernon Cole) Date: Mon, 29 Nov 2010 12:51:50 -0700 Subject: [python-win32] Pythonwin interactive window seems gone ? In-Reply-To: <1291047213.1892.1407696315@webmail.messagingengine.com> References: <1291047213.1892.1407696315@webmail.messagingengine.com> Message-ID: activestate python is a prepackaged kit, which includes pywin32 as part of it. It's a nice package, but most of us in this group don't use it, so we can't be very helpful. Other than saying "It works fine for me" there is not much that we can do, here. It sounds like you may have a problem with your installation. You might try one of the following: 1) Check with the activestate python support group at http://community.activestate.com/forums/activepython/activepython-support or 2) Download python and pywin32 separately from: http://python.org/ and http://sourceforge.net/projects/pywin32/ -- Vernon Cole On Mon, Nov 29, 2010 at 9:13 AM, leegold wrote: > Hi, > > The interactive window ( the shell window) in Pythonwin is gone, I open > it and it's an empty canvas - no window. The buttons are checked to show > it. Maybe I'm missing something simple, not sure. Pywin32 build 214, > using Activestate 2.6 on XP. > > Thanks > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Nov 29 21:44:07 2010 From: timr at probo.com (Tim Roberts) Date: Mon, 29 Nov 2010 12:44:07 -0800 Subject: [python-win32] Pythonwin interactive window seems gone ? In-Reply-To: <1291047213.1892.1407696315@webmail.messagingengine.com> References: <1291047213.1892.1407696315@webmail.messagingengine.com> Message-ID: <4CF41097.1080000@probo.com> leegold wrote: > Hi, > > The interactive window ( the shell window) in Pythonwin is gone, I open > it and it's an empty canvas - no window. The buttons are checked to show > it. Maybe I'm missing something simple, not sure. Pywin32 build 214, > using Activestate 2.6 on XP. Is it possible it has been minimized? Do you see a small window at the lower left? Have you tried Window->Cascade or Window->Tile? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Mon Nov 29 22:50:42 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 30 Nov 2010 08:50:42 +1100 Subject: [python-win32] Pythonwin interactive window seems gone ? In-Reply-To: <1291047213.1892.1407696315@webmail.messagingengine.com> References: <1291047213.1892.1407696315@webmail.messagingengine.com> Message-ID: <4CF42032.2010709@gmail.com> On 30/11/2010 3:13 AM, leegold wrote: > Hi, > > The interactive window ( the shell window) in Pythonwin is gone, I open > it and it's an empty canvas - no window. The buttons are checked to show > it. Maybe I'm missing something simple, not sure. Pywin32 build 214, > using Activestate 2.6 on XP. Have you tried View->Interactive Window? Mark From dgol461 at ECY.WA.GOV Tue Nov 30 01:25:41 2010 From: dgol461 at ECY.WA.GOV (Goldsmith, David) Date: Mon, 29 Nov 2010 16:25:41 -0800 Subject: [python-win32] How to send the Esc key via a telnetlib.Telnet session? Message-ID: Newbie to this list; sorry if it's the wrong one for this question. I need to do the equivalent of: telnetlib.Telnet.write("Esc key") How does one do this? Thanks! -------------------------------------- David Goldsmith Washington State Department of Ecology Environmental Assessment Program Modeling and Information Support Unit 300 Desmond Drive | P.O. Box 47600 Lacey, WA 98503 | Olympia, WA 98504-7600 Tel: (360) 407-6194 Fax: (360) 407-6884 Email: david.goldsmith at ecy.wa.gov Station: C2D-59 Web: http://www.ecy.wa.gov/programs/eap/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From dgol461 at ECY.WA.GOV Tue Nov 30 02:07:34 2010 From: dgol461 at ECY.WA.GOV (Goldsmith, David) Date: Mon, 29 Nov 2010 17:07:34 -0800 Subject: [python-win32] How to send the Esc key via a telnetlib.Telnetsession? In-Reply-To: <78C91C6FD63DD04BB8812EE9288C1E8126A6CCC8FD@EXCHANGE01.office.directedge.net> References: <78C91C6FD63DD04BB8812EE9288C1E8126A6CCC8FD@EXCHANGE01.office.directedge.net> Message-ID: Thanks for the prompt reply, and forgive my ignorance: how do I specify in a telnet transmission that 27 is to be interpreted as an ascii code? Thanks! From: Dahlstrom, Roger [mailto:RDahlstrom at directedge.com] Sent: Monday, November 29, 2010 4:30 PM To: Goldsmith, David Subject: Re: [python-win32] How to send the Esc key via a telnetlib.Telnetsession? Ascii 27 iirc. ________________________________ From: python-win32-bounces+rdahlstrom=directedge.com at python.org To: python-win32 at python.org Sent: Mon Nov 29 19:25:41 2010 Subject: [python-win32] How to send the Esc key via a telnetlib.Telnet session? Newbie to this list; sorry if it?s the wrong one for this question. I need to do the equivalent of: telnetlib.Telnet.write(?Esc key?) How does one do this? Thanks! -------------------------------------- David Goldsmith Washington State Department of Ecology Environmental Assessment Program Modeling and Information Support Unit 300 Desmond Drive | P.O. Box 47600 Lacey, WA 98503 | Olympia, WA 98504-7600 Tel: (360) 407-6194 Fax: (360) 407-6884 Email: david.goldsmith at ecy.wa.gov Station: C2D-59 Web: http://www.ecy.wa.gov/programs/eap/ ________________________________ DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. Direct Edge may, at its discretion, monitor and review the content of all e-mail communications. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Nov 30 02:50:19 2010 From: timr at probo.com (Tim Roberts) Date: Mon, 29 Nov 2010 17:50:19 -0800 Subject: [python-win32] How to send the Esc key via a telnetlib.Telnetsession? In-Reply-To: References: <78C91C6FD63DD04BB8812EE9288C1E8126A6CCC8FD@EXCHANGE01.office.directedge.net> Message-ID: <4CF4585B.7010909@probo.com> Goldsmith, David wrote: > > Thanks for the prompt reply, and forgive my ignorance: how do I > specify in a telnet transmission that 27 is to be interpreted as an > ascii code? Thanks! > Well, this is not specific to Telnet -- it's a Python thing. Telnet just sucks up whatever bytes you send it, so you just need to create a Python string with that character. You can do: telnetlib.Telnet.write( chr(27) ) or telnetlib.Telnet.write( "\x1b" ) (1B being the hexadecimal value of 27 in decimal) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From dgol461 at ECY.WA.GOV Tue Nov 30 03:28:35 2010 From: dgol461 at ECY.WA.GOV (Goldsmith, David) Date: Mon, 29 Nov 2010 18:28:35 -0800 Subject: [python-win32] How to send the Esc key viaa telnetlib.Telnetsession? In-Reply-To: <4CF4585B.7010909@probo.com> References: <78C91C6FD63DD04BB8812EE9288C1E8126A6CCC8FD@EXCHANGE01.office.directedge.net> <4CF4585B.7010909@probo.com> Message-ID: Excellent, thank you both! DG -----Original Message----- From: python-win32-bounces+dgol461=ecy.wa.gov at python.org [mailto:python-win32-bounces+dgol461=ecy.wa.gov at python.org] On Behalf Of Tim Roberts Sent: Monday, November 29, 2010 5:50 PM To: Python-Win32 List Subject: Re: [python-win32] How to send the Esc key viaa telnetlib.Telnetsession? Goldsmith, David wrote: > > Thanks for the prompt reply, and forgive my ignorance: how do I > specify in a telnet transmission that 27 is to be interpreted as an > ascii code? Thanks! > Well, this is not specific to Telnet -- it's a Python thing. Telnet just sucks up whatever bytes you send it, so you just need to create a Python string with that character. You can do: telnetlib.Telnet.write( chr(27) ) or telnetlib.Telnet.write( "\x1b" ) (1B being the hexadecimal value of 27 in decimal) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From leegold at fastmail.fm Tue Nov 30 05:19:08 2010 From: leegold at fastmail.fm (leegold) Date: Mon, 29 Nov 2010 21:19:08 -0700 Subject: [python-win32] Pythonwin interactive window seems gone ? In-Reply-To: References: Message-ID: <1291090748.1094.1407809519@webmail.messagingengine.com> > > leegold wrote: > > Hi, > > > > The interactive window ( the shell window) in Pythonwin is gone, I open > > it and it's an empty canvas - no window. The buttons are checked to show > > it. Maybe I'm missing something simple, not sure. Pywin32 build 214, > > using Activestate 2.6 on XP. > > Is it possible it has been minimized? Yes, it is possible! Window->Tile fixed it and it popped up. Thanks. > Do you see a small window at the > lower left? Have you tried Window->Cascade or Window->Tile? > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > From mdriscoll at co.marshall.ia.us Tue Nov 30 16:09:52 2010 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Tue, 30 Nov 2010 09:09:52 -0600 Subject: [python-win32] How do I get the URL of the active tab in Internet Explorer In-Reply-To: References: Message-ID: <4CF513C0.6060604@co.marshall.ia.us> On 1:59 PM, He Jibo wrote: > Hi, > I am writing a small program, which needs to get the URL of the active > tab in either of firefox, internet exploerer or chrome. > My need is similar as the one posted at, > http://stackoverflow.com/questions/3631216/how-do-i-get-the-url-of-the-visible-tab-in-firefox-ie-chrome > > > I did a lot of Googling, and get the following code. The following > code can get the url of the first tab in internet explorer. My > question is, how can I get the url of the current active tab? Thanks. > > ''' > http://efreedom.com/Question/1-2555905/Get-Internet-Explorer-Address-Bar-Python > http://blogs.msdn.com/b/oldnewthing/archive/2005/07/05/435657.aspx > http://mail.python.org/pipermail/python-win32/2004-June/002040.html > http://code.activestate.com/recipes/302324-browser-automation-tool-py-class-file/ > ''' > from win32com.client import Dispatch > import win32api, win32con,win32gui > > > SHELL = Dispatch("Shell.Application") > > def get_ie(shell): > for win in shell.Windows(): > # print win > if win.Name == "Windows Internet Explorer": > return win > return None > > def main(): > ie = get_ie(SHELL) > if ie: > print ie.LocationURL > print ie.LocationName > print ie.ReadyState > print ie > print ie.Document.title > print ie.Document.location > print ie.Document.forms > > # title = win32gui.GetWindowText(ie) > # print title > > else: > print "no ie window" > > if __name__ == '__main__': > main() > --------------------------- > He Jibo > Department of Psychology, > Beckman Institute for Advanced Science and Technology > University of Illinois, Urbana Champaign, > 603 East Daniel St., > Champaign, IL 61820 > website: www.hejibo.info > It will probably be frowned on here, but one of the easiest ways would be to use SendKeys in combination with some Windows hackery. I have attached some code I came up with after getting help from several of the fine people on this list. It shows how to bring a window into focus by just passing in an expected string. In this case, you would want to use something like "Windows Internet Explorer" and have it search for that. Once that's in focus, you can use the SendKeys package (http://www.rutherfurd.net/python/sendkeys/) to send an ALT+D to select the url and then CTRL+C to copy it. Then you can use the win32clipboard module from PyWin32 to grab the text from the clipboard. It's a hack, but it's kind of fun. Of course, you can't use your PC while the script runs or you might interrupt the process and send the keys to the wrong window. -- Mike Driscoll Applications Specialist Blog: http://blog.pythonlibrary.org -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: bring_to_front.py URL: From robin at reportlab.com Tue Nov 30 16:28:44 2010 From: robin at reportlab.com (Robin Becker) Date: Tue, 30 Nov 2010 15:28:44 +0000 Subject: [python-win32] odbc exceptions Message-ID: <4CF5182C.6010609@chamonix.reportlab.co.uk> I don't know if the odbc module is deprecated, but I'm seeing this strangeness C:\code\rlextra\examples\graphics>cat toad.py try: import odbc print odbc.__file__ conn = odbc.odbc('not_a_db_path') except: raise C:\code\rlextra\examples\graphics>toad.py C:\Python26\lib\site-packages\win32\odbc.pyd Traceback (most recent call last): File "C:\code\rlextra\examples\graphics\toad.py", line 6, in raise TypeError: exceptions must be classes or instances, not str C:\code\rlextra\examples\graphics> so I guess odbc must be raising a string exception -- Robin Becker From vernondcole at gmail.com Tue Nov 30 18:13:23 2010 From: vernondcole at gmail.com (Vernon Cole) Date: Tue, 30 Nov 2010 10:13:23 -0700 Subject: [python-win32] odbc exceptions In-Reply-To: <4CF5182C.6010609@chamonix.reportlab.co.uk> References: <4CF5182C.6010609@chamonix.reportlab.co.uk> Message-ID: Robin: Odbc is still maintained. It is not deprecated, exactly, but is obsolescent since it uses db api version 1 calls. It is maintained that way so that it doesn't break old code. The bug report is appreciated, I'll make sure it gets into the sourceforge bug list if you don't beat me to it. The up-to-date data access method is adodbapi, which uses the db api version 2 (PEP 249) standard, and is also included in pywin32. ODBC may be a little faster than adodbapi, since It is written in C, while adodbapi is written in pure Python. I doubt whether the difference would be noticeable in most cases. Adodbapi has lots more features, since I keep adding things I admire in other db api packages or want for myself. The latest version (not released in pywin32 yet) even has named-column data retrieval. That has been on my to-do list for years. Since ado defaults to odbc mode, you can simply send an odbc connection string, such as a DSN, to it, and it will do the right thing. In simple programs, conversion is as simple as changing the import statement and the connection method. Your example becomes: >>> try: ... import adodbapi as db ... print db.__file__ ... conn = db.connect('not_a_db_path') ... except: ... raise ... c:\python26\lib\site-packages\adodbapi\__init__.py Traceback (most recent call last): File "", line 4, in File "c:\python26\lib\site-packages\adodbapi\adodbapi.py", line 307, in connect raise OperationalError(e, "Error opening connection: " + connection_string) adodbapi.adodbapi.OperationalError: (com_error(-2147352567, 'Exception occurred.',(0, u'Microsoft OLE DB Provider for ODBC Drivers', u'[Microsoft][ODBC DriverManager] Data source name not found and no default driver specified', None, 0, -2147467259), None), 'Error opening connection: not_a_db_path') >>> On Nov 30, 2010 8:47 AM, "Robin Becker" wrote: I don't know if the odbc module is deprecated, but I'm seeing this strangeness C:\code\rlextra\examples\graphics>cat toad.py try: import odbc print odbc.__file__ conn = odbc.odbc('not_a_db_path') except: raise C:\code\rlextra\examples\graphics>toad.py C:\Python26\lib\site-packages\win32\odbc.pyd Traceback (most recent call last): File "C:\code\rlextra\examples\graphics\toad.py", line 6, in raise TypeError: exceptions must be classes or instances, not str C:\code\rlextra\examples\graphics> so I guess odbc must be raising a string exception -- Robin Becker _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From planders at gmail.com Tue Nov 30 18:25:35 2010 From: planders at gmail.com (Preston Landers) Date: Tue, 30 Nov 2010 11:25:35 -0600 Subject: [python-win32] odbc exceptions In-Reply-To: <4CF5182C.6010609@chamonix.reportlab.co.uk> References: <4CF5182C.6010609@chamonix.reportlab.co.uk> Message-ID: That's strange. I don't get that under Python 2.6.5 and PyWin32 v214. I get the kind of error one would expect. >>> try: ... odbc.odbc("asdf") ... except: ... raise ... Traceback (most recent call last): File "", line 2, in dbi.opError: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified in LOGIN However when my organization migrated from Python 2.1 using the odbc module to Python 2.6, we ended up switching to the PyODBC module for various reasons including enhanced support for different data types and so far we have been very pleased with that choice. It did take a bit of work to change to a slightly different API, and we ran into a couple of relatively minor corner-case bugs in PyODBC, but since we got those ironed out it has performed very well. The PyODBC team also fixed all the issues we reported to them. It is compiled C++ code and runs faster than a pure-Python library would. http://pyodbc.sourceforge.net/ regards, Preston On Tue, Nov 30, 2010 at 9:28 AM, Robin Becker wrote: > I don't know if the odbc module is deprecated, but I'm seeing this > strangeness > > C:\code\rlextra\examples\graphics>cat toad.py > try: > import odbc > print odbc.__file__ > conn = odbc.odbc('not_a_db_path') > except: > raise > > C:\code\rlextra\examples\graphics>toad.py > C:\Python26\lib\site-packages\win32\odbc.pyd > Traceback (most recent call last): > File "C:\code\rlextra\examples\graphics\toad.py", line 6, in > raise > TypeError: exceptions must be classes or instances, not str > > C:\code\rlextra\examples\graphics> > > so I guess odbc must be raising a string exception > -- > Robin Becker > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hejibo at gmail.com Tue Nov 30 18:42:52 2010 From: hejibo at gmail.com (He Jibo) Date: Tue, 30 Nov 2010 11:42:52 -0600 Subject: [python-win32] How do I get the URL of the active tab in Internet Explorer In-Reply-To: <4CF513C0.6060604@co.marshall.ia.us> References: <4CF513C0.6060604@co.marshall.ia.us> Message-ID: Thanks so much for your valuable information. I will only need the url of a browser when it is in the front. I am going to try SendKey, it seems to be a good way to go. Have a nice day! --------------------------- He Jibo Department of Psychology, Beckman Institute for Advanced Science and Technology University of Illinois, Urbana Champaign, 603 East Daniel St., Champaign, IL 61820 website: www.hejibo.info On Tue, Nov 30, 2010 at 9:09 AM, Mike Driscoll wrote: > On 1:59 PM, He Jibo wrote: > > Hi, > I am writing a small program, which needs to get the URL of the active > tab in either of firefox, internet exploerer or chrome. > My need is similar as the one posted at, > > http://stackoverflow.com/questions/3631216/how-do-i-get-the-url-of-the-visible-tab-in-firefox- > ie-chrome > > I did a lot of Googling, and get the following code. The following > code can get the url of the first tab in internet explorer. My > question is, how can I get the url of the current active tab? Thanks. > > ''' > > http://efreedom.com/Question/1-2555905/Get-Internet-Explorer-Address-Bar-Python > http://blogs.msdn.com/b/oldnewthing/archive/2005/07/05/435657.aspx > http://mail.python.org/pipermail/python-win32/2004-June/002040.html > > http://code.activestate.com/recipes/302324-browser-automation-tool-py-class-file/ > ''' > from win32com.client import Dispatch > import win32api, win32con,win32gui > > > SHELL = Dispatch("Shell.Application") > > def get_ie(shell): > for win in shell.Windows(): > # print win > if win.Name == "Windows Internet Explorer": > return win > return None > > def main(): > ie = get_ie(SHELL) > if ie: > print ie.LocationURL > print ie.LocationName > print ie.ReadyState > print ie > print ie.Document.title > print ie.Document.location > print ie.Document.forms > > # title = win32gui.GetWindowText(ie) > # print title > > else: > print "no ie window" > > if __name__ == '__main__': > main() > --------------------------- > He Jibo > Department of Psychology, > Beckman Institute for Advanced Science and Technology > University of Illinois, Urbana Champaign, > 603 East Daniel St., > Champaign, IL 61820 > website: www.hejibo.info > > > It will probably be frowned on here, but one of the easiest ways would be > to use SendKeys in combination with some Windows hackery. I have attached > some code I came up with after getting help from several of the fine people > on this list. It shows how to bring a window into focus by just passing in > an expected string. In this case, you would want to use something like > "Windows Internet Explorer" and have it search for that. > > Once that's in focus, you can use the SendKeys package ( > http://www.rutherfurd.net/python/sendkeys/) to send an ALT+D to select the > url and then CTRL+C to copy it. Then you can use the win32clipboard module > from PyWin32 to grab the text from the clipboard. > > It's a hack, but it's kind of fun. Of course, you can't use your PC while > the script runs or you might interrupt the process and send the keys to the > wrong window. > > > -- > Mike Driscoll > Applications Specialist > Blog: http://blog.pythonlibrary.org > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Tue Nov 30 18:46:09 2010 From: vernondcole at gmail.com (Vernon Cole) Date: Tue, 30 Nov 2010 10:46:09 -0700 Subject: [python-win32] odbc exceptions In-Reply-To: References: <4CF5182C.6010609@chamonix.reportlab.co.uk> Message-ID: On Tue, Nov 30, 2010 at 10:25 AM, Preston Landers wrote: > That's strange. I don't get that under Python 2.6.5 and PyWin32 v214. I > get the kind of error one would expect. > > >>> try: > ... odbc.odbc("asdf") > ... except: > ... raise > ... > Traceback (most recent call last): > File "", line 2, in > dbi.opError: [Microsoft][ODBC Driver Manager] Data source name not found > and no default driver specified in LOGIN > > Memo to self: when reading a pywin32 bug report using an Ubuntu workstation, actually re-boot into Windows and test software before dispensing seeming wisdom which may prove foolish... Robin: Works for me, too, now that I actually test it. What versions of Python, pywin32 and Windows are you running? -- Vernon -------------- next part -------------- An HTML attachment was scrubbed... URL: From sharpblade1 at gmail.com Tue Nov 30 23:00:42 2010 From: sharpblade1 at gmail.com (sharpblade) Date: Tue, 30 Nov 2010 22:00:42 +0000 Subject: [python-win32] How do I get the URL of the active tab in Internet Explorer In-Reply-To: References: <4CF513C0.6060604@co.marshall.ia.us> Message-ID: This might be of some help: http://social.msdn.microsoft.com/forums/en-US/ieextensiondevelopment/thread/e3a501d6-2163-4cc0-be2d-5011e7fa9613/ Check out Dan Morris's post, or T E dixons. On Tue, Nov 30, 2010 at 5:42 PM, He Jibo wrote: > Thanks so much for your valuable information. I will only need the url of a > browser when it is in the front. I am going to try SendKey, it seems to be a > good way to go. Have a nice day! > > > --------------------------- > He Jibo > Department of Psychology, > Beckman Institute for Advanced Science and Technology > University of Illinois, Urbana Champaign, > 603 East Daniel St., > Champaign, IL 61820 > website: www.hejibo.info > > > > On Tue, Nov 30, 2010 at 9:09 AM, Mike Driscoll < > mdriscoll at co.marshall.ia.us> wrote: > >> On 1:59 PM, He Jibo wrote: >> >> Hi, >> I am writing a small program, which needs to get the URL of the active >> tab in either of firefox, internet exploerer or chrome. >> My need is similar as the one posted at, >> >> http://stackoverflow.com/questions/3631216/how-do-i-get-the-url-of-the-visible-tab-in-firefox- >> ie-chrome >> >> I did a lot of Googling, and get the following code. The following >> code can get the url of the first tab in internet explorer. My >> question is, how can I get the url of the current active tab? Thanks. >> >> ''' >> >> http://efreedom.com/Question/1-2555905/Get-Internet-Explorer-Address-Bar-Python >> http://blogs.msdn.com/b/oldnewthing/archive/2005/07/05/435657.aspx >> http://mail.python.org/pipermail/python-win32/2004-June/002040.html >> >> http://code.activestate.com/recipes/302324-browser-automation-tool-py-class-file/ >> ''' >> from win32com.client import Dispatch >> import win32api, win32con,win32gui >> >> >> SHELL = Dispatch("Shell.Application") >> >> def get_ie(shell): >> for win in shell.Windows(): >> # print win >> if win.Name == "Windows Internet Explorer": >> return win >> return None >> >> def main(): >> ie = get_ie(SHELL) >> if ie: >> print ie.LocationURL >> print ie.LocationName >> print ie.ReadyState >> print ie >> print ie.Document.title >> print ie.Document.location >> print ie.Document.forms >> >> # title = win32gui.GetWindowText(ie) >> # print title >> >> else: >> print "no ie window" >> >> if __name__ == '__main__': >> main() >> --------------------------- >> He Jibo >> Department of Psychology, >> Beckman Institute for Advanced Science and Technology >> University of Illinois, Urbana Champaign, >> 603 East Daniel St., >> Champaign, IL 61820 >> website: www.hejibo.info >> >> >> It will probably be frowned on here, but one of the easiest ways would be >> to use SendKeys in combination with some Windows hackery. I have attached >> some code I came up with after getting help from several of the fine people >> on this list. It shows how to bring a window into focus by just passing in >> an expected string. In this case, you would want to use something like >> "Windows Internet Explorer" and have it search for that. >> >> Once that's in focus, you can use the SendKeys package ( >> http://www.rutherfurd.net/python/sendkeys/) to send an ALT+D to select >> the url and then CTRL+C to copy it. Then you can use the win32clipboard >> module from PyWin32 to grab the text from the clipboard. >> >> It's a hack, but it's kind of fun. Of course, you can't use your PC while >> the script runs or you might interrupt the process and send the keys to the >> wrong window. >> >> >> -- >> Mike Driscoll >> Applications Specialist >> Blog: http://blog.pythonlibrary.org >> > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: