From cappy2112 at gmail.com Tue Aug 1 05:03:34 2006 From: cappy2112 at gmail.com (Tony Cappellini) Date: Mon, 31 Jul 2006 20:03:34 -0700 Subject: [python-win32] Once Click Shutdown, restart or Switch User Message-ID: <8249c4ac0607312003l787104abl7ef30c3ad66cef1c@mail.gmail.com> I would like to write a simple program so I can initiate a Shutdown (power off), Restart, or Switch User. Would someone point to the API's that I need to do this? thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060731/15c21099/attachment.html From rwupole at msn.com Tue Aug 1 08:45:14 2006 From: rwupole at msn.com (Roger Upole) Date: Tue, 1 Aug 2006 02:45:14 -0400 Subject: [python-win32] Re: Once Click Shutdown, restart or Switch User Message-ID: Tony Cappellini wrote: >I would like to write a simple program so I can initiate a Shutdown (power > off), Restart, or Switch User. > > Would someone point to the API's that I need to do this? You can do a shutdown or reboot with win32api.ExitWindowsEx. To switch users, use win32ts.WTSDisconnectSession. Roger From gregpinero at gmail.com Tue Aug 1 20:24:14 2006 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Tue, 1 Aug 2006 14:24:14 -0400 Subject: [python-win32] Cleanly Close System Tray Process Message-ID: <312cfe2b0608011124s435750c9i87d7b055fbcae60d@mail.gmail.com> Hi guys, I've got this little yellow icon sitting in my system tray: http://i7.tinypic.com/21n08ig.png I'd like to use the windows API to somehow ask it to shutdown? If a system tray icon counts as a window then perhaps I could get its hwnd and do something like: win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0) ? FYI so far I've been closing it with kill process but the problem is that it leaves the icon in the system tray and after a few days of opening and closing this thing I have 1000's of icons left over in the system tray. Much thanks! -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com) From mark.m.mcmahon at gmail.com Tue Aug 1 20:55:01 2006 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Tue, 1 Aug 2006 14:55:01 -0400 Subject: [python-win32] Cleanly Close System Tray Process In-Reply-To: <312cfe2b0608011124s435750c9i87d7b055fbcae60d@mail.gmail.com> References: <312cfe2b0608011124s435750c9i87d7b055fbcae60d@mail.gmail.com> Message-ID: <71b6302c0608011155h8a76924ja48d134c1022cf6b@mail.gmail.com> Hi, On 8/1/06, Gregory Pi?ero wrote: > Hi guys, > > I've got this little yellow icon sitting in my system tray: > http://i7.tinypic.com/21n08ig.png > > I'd like to use the windows API to somehow ask it to shutdown? If a > system tray icon counts as a window then perhaps I could get its hwnd > and do something like: > win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0) > ? > > FYI so far I've been closing it with kill process but the problem is > that it leaves the icon in the system tray and after a few days of > opening and closing this thing I have 1000's of icons left over in the > system tray. I would suggest killing and refreshing the system tray (or notification area). As far as I know if you kill the process and then move your mouse over the icon - it will disappear. Though it sounds much better to stop that process running if you really don't want it to run. Look in the registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx "Startup" Start menu folder Not sure if those help? > > Much thanks! > Mark From gregpinero at gmail.com Tue Aug 1 21:34:56 2006 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Tue, 1 Aug 2006 15:34:56 -0400 Subject: [python-win32] Cleanly Close System Tray Process In-Reply-To: <71b6302c0608011155h8a76924ja48d134c1022cf6b@mail.gmail.com> References: <312cfe2b0608011124s435750c9i87d7b055fbcae60d@mail.gmail.com> <71b6302c0608011155h8a76924ja48d134c1022cf6b@mail.gmail.com> Message-ID: <312cfe2b0608011234u3b315474h27a555cc9d6831c5@mail.gmail.com> Ok I figured out how to do it: Here's the code I made mostly from copying the examples. If anyone could tell me how the code works, that would still be appriciated, for example why/how do I need this function _MyCallback? -Greg My code: import sys import win32process, win32api, win32pdhutil, win32con, win32security import win32event, msvcrt, win32gui def get_all_windows(): """Returns dict with window desc and hwnd, don't ask me how it works!""" def _MyCallback( hwnd, extra ): """Helper function for above??""" hwnds, classes = extra hwnds.append(hwnd) classes[win32gui.GetClassName(hwnd)] = hwnd windows = [] classes = {} win32gui.EnumWindows(_MyCallback, (windows, classes)) return classes def request_windows_to_close(list_window_descs_to_close): """Send me a list of stuff to close such as: stuff_to_close=['OP15_OmniPage_Agent_Class',]""" classes=get_all_windows() for windesc_to_close in list_window_descs_to_close: if classes.has_key(windesc_to_close): win32gui.PostMessage(classes[windesc_to_close], win32con.WM_CLOSE, 0, 0) print 'requested closure with', windesc_to_close else: print 'Did not find a window desc. as',windesc_to_close From bwmetz at att.com Tue Aug 1 21:42:42 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Tue, 1 Aug 2006 14:42:42 -0500 Subject: [python-win32] Cleanly Close System Tray Process In-Reply-To: <312cfe2b0608011124s435750c9i87d7b055fbcae60d@mail.gmail.com> Message-ID: <01D5341D04A2E64AB9B34576904733670233E13B@OCCLUST01EVS1.ugd.att.com> Does mousing over the icon not make it disappear after it's killed? If you can get the handle to the process, say via EnumWindows, you can user the TerminateProcess API call. Bobby -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Gregory Pi?ero Sent: Tuesday, August 01, 2006 11:24 AM To: python-win32 at python.org Subject: [python-win32] Cleanly Close System Tray Process Hi guys, I've got this little yellow icon sitting in my system tray: http://i7.tinypic.com/21n08ig.png I'd like to use the windows API to somehow ask it to shutdown? If a system tray icon counts as a window then perhaps I could get its hwnd and do something like: win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0) ? FYI so far I've been closing it with kill process but the problem is that it leaves the icon in the system tray and after a few days of opening and closing this thing I have 1000's of icons left over in the system tray. Much thanks! -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com) _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From odiogo at kameruuh.eu Wed Aug 2 13:16:46 2006 From: odiogo at kameruuh.eu (Diogo) Date: Wed, 2 Aug 2006 13:16:46 +0200 Subject: [python-win32] OLE Server Busy dialog box Message-ID: <67dcd18b0608020416m37406313ofda268b7651c6402@mail.gmail.com> Hi all! I've been trying to solve a small but disturbing problem with win32com, but I can't. It's the "OLE Server Busy" problem [1]: "If you call a method on a COM server from an MFC COM client application and if the method takes a long time to process and return back, you won't be able to do anything on the client application and the OLE Server Busy dialog box pops up..." The link explains how to solve it. But it's not that straight forward in python. They suggest using Afx* functions. So I tried putting that on a DLL and then calling them from python using pyrex. But it didn't work out. The functions are called, but the program crashes when trying to access a member of the Filter. And adding a DLL only makes it more complex. There should be a simple-clean way to do that. Anyone had this problem before? Anyone figured out a way to fix it? Thanks in advance, Diogo [1] http://support.microsoft.com/?scid=kb%3Ben-us%3B248019&x=14&y=15 From mhammond at skippinet.com.au Wed Aug 2 14:12:14 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 2 Aug 2006 22:12:14 +1000 Subject: [python-win32] OLE Server Busy dialog box In-Reply-To: <67dcd18b0608020416m37406313ofda268b7651c6402@mail.gmail.com> Message-ID: <007101c6b62c$e4b5be10$0200a8c0@enfoldsystems.local> > I've been trying to solve a small but disturbing problem with > win32com, but I can't. > It's the "OLE Server Busy" problem [1]: > "If you call a method on a COM server from an MFC COM client > application and if the method takes a long time to process and return > back, you won't be able to do anything on the client application and > the OLE Server Busy dialog box pops up..." Unless you are using the win32ui module, its unlikely you qualify as an "MFC COM client". > The link explains how to solve it. But it's not that straight forward > in python. They suggest using Afx* functions. It also casually mentions at the bottom: | Another way to suppress the server busy dialog box is to use | OleInitialize and OleUninitialize instead of AfxOleInit in your | application. which are easy to call. > on a DLL and then calling them from python using pyrex. But it didn't > work out. The functions are called, but the program crashes when > trying to access a member of the Filter. And adding a DLL only makes > it more complex. Yeah - things aren't going to work that well if MFC isn't correctly initialized. > There should be a simple-clean way to do that. > > Anyone had this problem before? Anyone figured out a way to fix it? Try and ensure your threads are all initialized for free-threading (setting sys.coinit_flags=0 before importing win32com/pythoncom will ensure that is true for the main thread), and that all threads are running message loops. Mark From benn at cenix-bioscience.com Wed Aug 2 14:22:01 2006 From: benn at cenix-bioscience.com (Neil Benn) Date: Wed, 02 Aug 2006 14:22:01 +0200 Subject: [python-win32] Dispatches With Events on COM Object Message-ID: <44D098E9.1030209@cenix-bioscience.com> Hello, I am trying to use PythonCOM to interact with a provided proprietary COM object. The Object consists of three dispatch interfaces: IApplication IApplicationEvents IDocumentEvents This can be accessed using the CoBaseClass by ProgID 'OpalControl.Applcation' - so far so good. The first thing I do is to run the following code: import win32com.client import time objCybio = win32com.client.Dispatch('OpalControl.Application', CybioEvents) objCybio.ConfigFile = r"C:\CyBio Software\Config\opalctrl.ini" objCybio.Config = "CyBi-Well" objCybio.visible = True objCybio.OpenDocument(r'C:\testscript.igl', True) time.sleep(2) objCybio.CloseDocument(r'C:\testscript.igl', True) objCybio = None This works fine and it does what I expect, so the next thing to do is to try and write something to get the events: import win32com.client import time import win32com.client.gencache class CybioEvents(object): def __init__(self): super(CybioEvents, self).__init__() def onCommand(pstrTitle, pstrParam): print 'OnCommand\n', pstrTitle,'\n', pstrParam objCybio = win32com.client.DispatchWithEvents('OpalControl.Application', CybioEvents) objCybio.ConfigFile = r"C:\CyBio Software\Config\opalctrl.ini" objCybio.Config = "CyBi-Well" objCybio.visible = True objCybio.OpenDocument(r'C:\testscript.igl', True) time.sleep(2) objCybio.CloseDocument(r'C:\testscript.igl', True) objCybio = None When I run this, I get the following error: Traceback (most recent call last): File "C:\Program Files\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\Documents and Settings\benn\Desktop\cybio test.py", line 9, in ? objCybio = win32com.client.DispatchWithEvents("OpalControl.Application", CybioEvents) File "C:\Program Files\Python24\Lib\site-packages\win32com\client\__init__.py", line 254, in DispatchWithEvents raise TypeError, "This COM object can not automate the makepy process - please run makepy manually for this object" TypeError: This COM object can not automate the makepy process - please run makepy manually for this object So no probs, using the makepy utility in PythonWin (I'll automate this later ;-) ) I generate the required stubs and a file does appear which seems to be OK (contains the correct GUIDs and interfaces and so on). Running this again, I get : Traceback (most recent call last): File "C:\Program Files\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\Documents and Settings\benn\Desktop\cybio test.py", line 9, in ? objCybio = win32com.client.DispatchWithEvents("OpalControl.Application", CybioEvents) File "C:\Program Files\Python24\Lib\site-packages\win32com\client\__init__.py", line 254, in DispatchWithEvents raise TypeError, "This COM object can not automate the makepy process - please run makepy manually for this object" TypeError: This COM object can not automate the makepy process - please run makepy manually for this object Basically the same as above, I've checked this COM object out with VB and it works fine - no probs. In addition looking at the stub file in the cache in gen_py, the class has not been compiled to a pyc file (I'm assuming that it should be here) so it seems like it is not even finding this - although that is a guess. I've also tried using the GUID to get hold of the CoBaseClass using the GUID but I get the same error, unfortunately I cannot give you the COM object as it is dongle protected and therefore will not run. I can attach the generated file from makepy but I won't do that as yet because it is relatively big. Can anyone shed any light as to how I can track down this problem? Thanks in advance for your help. Cheers, Neil -- Neil Benn MSc Head of Automation Cenix BioScience GmbH Tatzberg 47 01307 Dresden Germany http://wwww.cenix-bioscience.com From aryeh at bigfoot.com Wed Aug 2 16:01:33 2006 From: aryeh at bigfoot.com (ah) Date: Wed, 2 Aug 2006 16:01:33 +0200 Subject: [python-win32] How to create an ActiveX/OLE control Message-ID: <00e701c6b63c$29be05d0$9c01a8c0@dev03> Hello list, Can I make an ActiveX/OLE control from a wxPython GUI app ? Any info would be greatly appreciated ! All the best. Arye. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060802/e906f007/attachment.htm From timr at probo.com Wed Aug 2 19:18:40 2006 From: timr at probo.com (Tim Roberts) Date: Wed, 02 Aug 2006 10:18:40 -0700 Subject: [python-win32] Cleanly Close System Tray Process In-Reply-To: References: Message-ID: <44D0DE70.5000906@probo.com> On Tue, 1 Aug 2006 15:34:56 -0400, " Gregory Pi?ero " wrote: >Ok I figured out how to do it: > >Here's the code I made mostly from copying the examples. If anyone >could tell me how the code works, that would still be appriciated, for >example why/how do I need this function _MyCallback? > > The EnumWindows API runs through the system's linked list of all top-level windows. For every window it finds, it calls a function that you provide. If you know C++, it's a lot like the for_each function in STL. _MyCallback is the function that gets called, once for every top-level window. It is passed the handle of each window in turn, along with a "context" parameter that you provide. In your example, the context parameter is a tuple that will be used to keep track of all of the windows and window classes that were found. So, when "get_all_windows" finishes, it returns a dictionary that contains one entry for every window class. request_windows_to_close then checks to see if the class(es) you requested are present in the dictionary, and if they are, it sends them a WM_CLOSE message. This code is not actually correct. There can be many windows for a given window class, but your get_all_windows function will only return the last one found for each class. A better implementation of _MyCallback would be: def _MyCallback( hwnd, extra ): hwnds, classes = extra hwnds.append(hwnd) classn = win32gui.GetClassName(hwnd) if not classn in classes: classes[classn] = [] classes[classn].append( hwnd ) Then request_windows_to_close becomes: for windesc_to_close in list_window_descs_to_close: if windesc_to_close in classes: for hwnd in classes[windesc_to_close]: win32gui.PostMessage( hwnd, win32con, WM_CLOSE, 0, 0 ) ... -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gregpinero at gmail.com Wed Aug 2 20:50:12 2006 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Wed, 2 Aug 2006 14:50:12 -0400 Subject: [python-win32] Cleanly Close System Tray Process In-Reply-To: <44D0DE70.5000906@probo.com> References: <44D0DE70.5000906@probo.com> Message-ID: <312cfe2b0608021150h4c03df73w3fd2962492da36@mail.gmail.com> On 8/2/06, Tim Roberts wrote: > This code is not actually correct. There can be many windows for a > given window class, but your get_all_windows function will only return > the last one found for each class. A better implementation of > _MyCallback would be: Thanks for the corrections, Tim. I updated my code, it works well. From gregpinero at gmail.com Wed Aug 2 20:51:55 2006 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Wed, 2 Aug 2006 14:51:55 -0400 Subject: [python-win32] Cleanly Close System Tray Process In-Reply-To: <312cfe2b0608021150h4c03df73w3fd2962492da36@mail.gmail.com> References: <44D0DE70.5000906@probo.com> <312cfe2b0608021150h4c03df73w3fd2962492da36@mail.gmail.com> Message-ID: <312cfe2b0608021151q7126556dhb4f37399d2a3e482@mail.gmail.com> I documented this code and added some background info here: http://www.answermysearches.com/index.php/why-killing-processes-may-be-hurting-you-and-what-to-do-about-it/154/ On 8/2/06, Gregory Pi?ero wrote: > On 8/2/06, Tim Roberts wrote: > > This code is not actually correct. There can be many windows for a > > given window class, but your get_all_windows function will only return > > the last one found for each class. A better implementation of > > _MyCallback would be: > > Thanks for the corrections, Tim. I updated my code, it works well. > -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com) From mhammond at skippinet.com.au Wed Aug 2 23:35:40 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 3 Aug 2006 07:35:40 +1000 Subject: [python-win32] Dispatches With Events on COM Object In-Reply-To: <44D098E9.1030209@cenix-bioscience.com> Message-ID: <022a01c6b67b$9c4bbe00$0200a8c0@enfoldsystems.local> > When I run this, I get the following error: > > Traceback (most recent call last): > File "C:\Program > Files\Python24\Lib\site-packages\pythonwin\pywin\framework\scr > iptutils.py", > line 310, in RunScript > exec codeObject in __main__.__dict__ > File "C:\Documents and Settings\benn\Desktop\cybio > test.py", line 9, in ? > objCybio = > win32com.client.DispatchWithEvents("OpalControl.Application", > CybioEvents) > File "C:\Program > Files\Python24\Lib\site-packages\win32com\client\__init__.py", > line 254, > in DispatchWithEvents > raise TypeError, "This COM object can not automate the makepy > process - please run makepy manually for this object" > TypeError: This COM object can not automate the makepy > process - please > run makepy manually for this object The problem will be that the object itself doesn't supply the typeinfo necessary to associate the object with the makepy generated class. It should however be possible for you to manually extract a suitable object though. What you need is something like: from win32com.client import gencache mod = gencache.EnsureModule(...) # use 'makepy -i' to see the params ob = mod.Application() objCybio = win32com.client.DispatchWithEvents(ob, CybioEvents) 'mod' will be a reference to the makepy generated module. Assuming this module defines a class called 'Application', 'ob' should be an instance of the COM object, but with makepy support. Passing this object to DispatchWithEvents instead of the CLSID means the type info is available. Hope this helps, Mark From benn at cenix-bioscience.com Thu Aug 3 12:49:14 2006 From: benn at cenix-bioscience.com (Neil Benn) Date: Thu, 03 Aug 2006 12:49:14 +0200 Subject: [python-win32] Dispatches With Events on COM Object In-Reply-To: <022a01c6b67b$9c4bbe00$0200a8c0@enfoldsystems.local> References: <022a01c6b67b$9c4bbe00$0200a8c0@enfoldsystems.local> Message-ID: <44D1D4AA.9030201@cenix-bioscience.com> Mark Hammond wrote: > > The problem will be that the object itself doesn't supply the typeinfo > necessary to associate the object with the makepy generated class. It > should however be possible for you to manually extract a suitable object > though. > > What you need is something like: > > from win32com.client import gencache > mod = gencache.EnsureModule(...) # use 'makepy -i' to see the params > ob = mod.Application() > objCybio = win32com.client.DispatchWithEvents(ob, CybioEvents) > > > Hello, Hmm the type info looks like an issue, the new code is now: mod = gencache.EnsureModule('{A4818FD5-6479-11D4-8452-00104B92DD56}', 0, 1, 0) print dir(mod) ob = mod.Application objCybio = win32com.client.DispatchWithEvents(ob, CybioEvents) -- This now gives me the following error: Traceback (most recent call last): File "C:\Program Files\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\Documents and Settings\benn\Desktop\cybio test.py", line 15, in ? objCybio = win32com.client.DispatchWithEvents(ob, CybioEvents) File "C:\Program Files\Python24\Lib\site-packages\win32com\client\__init__.py", line 243, in DispatchWithEvents disp = Dispatch(clsid) File "C:\Program Files\Python24\Lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx) File "C:\Program Files\Python24\Lib\site-packages\win32com\client\__init__.py", line 44, in __WrapDispatch return dynamic.Dispatch(dispatch, userName, WrapperClass, typeinfo, UnicodeToString=UnicodeToString,clsctx=clsctx) File "C:\Program Files\Python24\Lib\site-packages\win32com\client\dynamic.py", line 111, in Dispatch typeinfo = IDispatch.GetTypeInfo() AttributeError: class Application has no attribute 'GetTypeInfo' Interestingly, the printout of dir(mod) gives me: ['Application', 'CLSID', 'CLSIDToClassMap', 'CLSIDToPackageMap', 'CoClassBaseClass', 'Dispatch', 'DispatchBaseClass', 'IApplication', 'IApplicationEvents', 'IApplicationEvents_vtables_', 'IApplicationEvents_vtables_dispatch_', 'IDocumentEvents', 'IDocumentEvents_vtables_', 'IDocumentEvents_vtables_dispatch_', 'IID', 'LCID', 'LibraryFlags', 'MajorVersion', 'MinorVersion', 'NamesToIIDMap', 'RecordMap', 'VTablesToClassMap', 'VTablesToPackageMap', '__builtins__', '__doc__', '__file__', '__name__', '_in_gencache_', 'defaultNamedNotOptArg', 'defaultNamedOptArg', 'defaultUnnamedArg', 'makepy_version', 'python_version', 'pythoncom', 'win32com'] For completeness, I've attached the generated file from makepy (the above test was done without this present). I've done some playing around, if I do a simlpe dispatch (without events) the makepy file does not get compiled to a pyc but the __init__ does. Any thoughts? Thanks for any and all help/advice. Cheers, Neil -- Neil Benn MSc Head of Automation Cenix BioScience GmbH Tatzberg 47 01307 Dresden Germany http://wwww.cenix-bioscience.com -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: A4818FD5-6479-11D4-8452-00104B92DD56x0x1x0.py Url: http://mail.python.org/pipermail/python-win32/attachments/20060803/fe1b2a51/attachment.asc From gregpinero at gmail.com Thu Aug 3 18:13:01 2006 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Thu, 3 Aug 2006 12:13:01 -0400 Subject: [python-win32] win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0) - What are the last two Parameters? Message-ID: <312cfe2b0608030913o2ba321c5lb034f450e817be3c@mail.gmail.com> Hi Guys, I've been looking everywhere to find this out. Would someone please fill me in? BTW how can I locate this kind of information for myself in the future? I can't even find this function in the source code for some reason. Much Thanks! -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com) From simon at brunningonline.net Thu Aug 3 18:22:17 2006 From: simon at brunningonline.net (Simon Brunning) Date: Thu, 3 Aug 2006 17:22:17 +0100 Subject: [python-win32] win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0) - What are the last two Parameters? In-Reply-To: <312cfe2b0608030913o2ba321c5lb034f450e817be3c@mail.gmail.com> References: <312cfe2b0608030913o2ba321c5lb034f450e817be3c@mail.gmail.com> Message-ID: <8c7f10c60608030922h4b549cb0n1a374e99b833eee6@mail.gmail.com> On 8/3/06, Gregory Pi?ero wrote: > I've been looking everywhere to find this out. Would someone please > fill me in? > > BTW how can I locate this kind of information for myself in the > future? I can't even find this function in the source code for some > reason. Much of the win32 stuff fairly thinly wraps the Windows API, so MSDN is often a good place to look. For example: . -- Cheers, Simon B, simon at brunningonline.net, http://www.brunningonline.net/simon/blog/ From gregpinero at gmail.com Thu Aug 3 18:34:16 2006 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Thu, 3 Aug 2006 12:34:16 -0400 Subject: [python-win32] win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0) - What are the last two Parameters? In-Reply-To: <8c7f10c60608030922h4b549cb0n1a374e99b833eee6@mail.gmail.com> References: <312cfe2b0608030913o2ba321c5lb034f450e817be3c@mail.gmail.com> <8c7f10c60608030922h4b549cb0n1a374e99b833eee6@mail.gmail.com> Message-ID: <312cfe2b0608030934i7dc13271x777f5210924a1f9@mail.gmail.com> On 8/3/06, Simon Brunning wrote: > Much of the win32 stuff fairly thinly wraps the Windows API, so MSDN > is often a good place to look. For example: > . Thanks Simon that worked! FYI, future readers the answer is that those two parameters are message specific and for wm_close they don't do anything. Probably just search for your message on MSDN to find out what the parameters are for other messages: WM_CLOSE Notification The WM_CLOSE message is sent as a signal that a window or an application should terminate. A window receives this message through its WindowProc function. Syntax WM_CLOSE WPARAM wParam LPARAM lParam; Parameters wParam This parameter is not used. lParam This parameter is not used. Return Value If an application processes this message, it should return zero. Greg From mhammond at skippinet.com.au Fri Aug 4 00:04:07 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 4 Aug 2006 08:04:07 +1000 Subject: [python-win32] Dispatches With Events on COM Object In-Reply-To: <44D1D4AA.9030201@cenix-bioscience.com> Message-ID: <067001c6b748$bfa3cff0$0200a8c0@enfoldsystems.local> > print dir(mod) > ob = mod.Application Try adding parens after that line - currently 'ob' is the class, where you want an instance of the class. ob = mod.Application() That may get closer. Mark From rays at blue-cove.com Fri Aug 4 03:45:00 2006 From: rays at blue-cove.com (Ray Schumacher) Date: Thu, 03 Aug 2006 18:45:00 -0700 Subject: [python-win32] sleep() for less than .001s? Message-ID: <6.2.3.4.2.20060803182830.058e2c28@blue-cove.com> I have been trying to use sleep() and kernel32.QueryPerformanceCounter together; I want to delay until a particular tick without trying up the CPU badly. However, while time.sleep(.001) relieves the CPU, it has wildly unpredictable delay, and sleep(.0001) delays almost nothing at all! (I'm watching the parallel port on a scope). If I use a while and just count ticks with QueryPerformanceCounter(), it is very stable and as desired - but it uses 100% CPU. RTAI LINUX has a nanosleep() function that does it all very nicely on our Debian install, is there a parallel in Win32? The MS Sleep() function is in integer milliseconds... sample code: ___________________________________________________________________ TTLHighDur = ticksPerMs/2 currTicksPerRot = fsTicksPerRot qPC(byref(c0)) tick0 = c0.value # initial count nextTTL = tick0 ## make a TTLOUT endTick = tick0+pF* 15 #seconds rotN = 0 while(True): nextTTL = currTicksPerRot+nextTTL sleep(.0001)# sleep for most of the time needed while(True): #loop until the exact tick qPC(byref(c1)) if c1.value>nextTTL: break out(0x378, 0xFF) #set all bits high while(True): #loop until the exact tick qPC(byref(c1)) if c1.value>nextTTL+TTLHighDur: break out(0x378, 0x00) #set all bits low rotN += 1 if c1.value>endTick: break Ray Schumacher Blue Cove Interactive 8580 Production Avenue, Suite B San Diego, CA 92121 858.695.8801 http://Blue-Cove.com Disclaimer ;-) By sending an email to ANY of my addresses you are agreeing that: * I am by definition, "the intended recipient" * All information in the email is mine to do with as I see fit and make such financial profit, political mileage, or good joke as it lends itself to. In particular, I may quote it on USENET. * I may take the contents as representing the views of your company. * This overrides any disclaimer or statement of confidentiality that may be included on your message. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060803/e7d10945/attachment-0001.html From benn at cenix-bioscience.com Fri Aug 4 10:46:33 2006 From: benn at cenix-bioscience.com (Neil Benn) Date: Fri, 04 Aug 2006 10:46:33 +0200 Subject: [python-win32] Dispatches With Events on COM Object In-Reply-To: <067001c6b748$bfa3cff0$0200a8c0@enfoldsystems.local> References: <067001c6b748$bfa3cff0$0200a8c0@enfoldsystems.local> Message-ID: <44D30969.7010202@cenix-bioscience.com> Mark Hammond wrote: >> print dir(mod) >> ob = mod.Application >> > > Try adding parens after that line - currently 'ob' is the class, where you > want an instance of the class. > > ob = mod.Application() > > Ah good point, I put back in the brackets (doh!) and I am now back to the previous place: mod = gencache.EnsureModule('{A4818FD5-6479-11D4-8452-00104B92DD56}', 0, 1, 0) print dir(mod) ob = mod.Application() print dir(ob) objCybio = win32com.client.DispatchWithEvents(ob, CybioEvents) >>> ['Application', 'CLSID', 'CLSIDToClassMap', 'CLSIDToPackageMap', 'CoClassBaseClass', 'Dispatch', 'DispatchBaseClass', 'IApplication', 'IApplicationEvents', 'IApplicationEvents_vtables_', 'IApplicationEvents_vtables_dispatch_', 'IDocumentEvents', 'IDocumentEvents_vtables_', 'IDocumentEvents_vtables_dispatch_', 'IID', 'LCID', 'LibraryFlags', 'MajorVersion', 'MinorVersion', 'NamesToIIDMap', 'RecordMap', 'VTablesToClassMap', 'VTablesToPackageMap', '__builtins__', '__doc__', '__file__', '__name__', '_in_gencache_', 'defaultNamedNotOptArg', 'defaultNamedOptArg', 'defaultUnnamedArg', 'makepy_version', 'python_version', 'pythoncom', 'win32com'] ['CLSID', '__doc__', '__getattr__', '__init__', '__module__', '__repr__', '__setattr__', '_dispobj_', 'coclass_interfaces', 'coclass_sources', 'default_interface', 'default_source'] Traceback (most recent call last): File "C:\Program Files\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\Documents and Settings\benn\Desktop\cybio test.py", line 16, in ? objCybio = win32com.client.DispatchWithEvents(ob, CybioEvents) File "C:\Program Files\Python24\Lib\site-packages\win32com\client\__init__.py", line 254, in DispatchWithEvents raise TypeError, "This COM object can not automate the makepy process - please run makepy manually for this object" TypeError: This COM object can not automate the makepy process - please run makepy manually for this object I've got it working OK with C# running through SharpDevelop - I'd prefer not to use C# though as my company is a python programming company and using C# would cause support issues. Although I'm not sure if there are any other solutions in the python environment - is there a debug switch on the native code I can turn on to if the problems are coming from there? Cheers, Neil -- Neil Benn MSc Head of Automation Cenix BioScience GmbH Tatzberg 47 01307 Dresden Germany http://wwww.cenix-bioscience.com From gagsl-p32 at yahoo.com.ar Fri Aug 4 11:59:34 2006 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 04 Aug 2006 06:59:34 -0300 Subject: [python-win32] sleep() for less than .001s? In-Reply-To: <6.2.3.4.2.20060803182830.058e2c28@blue-cove.com> References: <6.2.3.4.2.20060803182830.058e2c28@blue-cove.com> Message-ID: <7.0.1.0.0.20060804063852.03a9c138@yahoo.com.ar> At Thursday 3/8/2006 22:45, Ray Schumacher wrote: >I have been trying to use sleep() and >kernel32.QueryPerformanceCounter together; I want to delay until a >particular tick without trying up the CPU badly. >However, while time.sleep(.001) relieves the CPU, it has wildly >unpredictable delay, and sleep(.0001) delays almost nothing at all! >(I'm watching the parallel port on a scope). >If I use a while and just count ticks with >QueryPerformanceCounter(), it is very stable and as desired - but it >uses 100% CPU. I'm not sure if this really works, but you could try: - Raise your thread/process's priority using SetPriorityClass or SetThreadPriority. This is to minimize the (unpredictable) delay of sleep() - Keep your qPC loop, but insert a sleep(0) call, this would free the CPU. Gabriel Genellina Softlab SRL __________________________________________________ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas From odiogo at kameruuh.eu Fri Aug 4 13:42:32 2006 From: odiogo at kameruuh.eu (Diogo) Date: Fri, 4 Aug 2006 13:42:32 +0200 Subject: [python-win32] OLE Server Busy dialog box In-Reply-To: <007101c6b62c$e4b5be10$0200a8c0@enfoldsystems.local> References: <67dcd18b0608020416m37406313ofda268b7651c6402@mail.gmail.com> <007101c6b62c$e4b5be10$0200a8c0@enfoldsystems.local> Message-ID: <67dcd18b0608040442l47d01d68o82e0b2af83c644ff@mail.gmail.com> > Unless you are using the win32ui module, its unlikely you qualify as an "MFC > COM client". I'm not using the win32ui. And this makes me wonder I would get this box. > | Another way to suppress the server busy dialog box is to use > | OleInitialize and OleUninitialize instead of AfxOleInit in your > | application. > > which are easy to call. The program was using CoInitialize() only. Now it uses OleInitialize(). The "busy message" doesn't appear always, and with OleInitialize it stopped appering in my computer. But while running in another computer it still appears. BTW, there's no OleUninitialize. Should I use the Co one? Thanks for the help, Diogo From rays at blue-cove.com Fri Aug 4 16:02:53 2006 From: rays at blue-cove.com (RayS) Date: Fri, 04 Aug 2006 07:02:53 -0700 Subject: [python-win32] sleep() for less than .001s? In-Reply-To: <7.0.1.0.0.20060804063852.03a9c138@yahoo.com.ar> References: <6.2.3.4.2.20060803182830.058e2c28@blue-cove.com> <7.0.1.0.0.20060804063852.03a9c138@yahoo.com.ar> Message-ID: <6.2.3.4.2.20060804062541.03261dc0@blue-cove.com> At 02:59 AM 8/4/2006, Gabriel Genellina wrote: >I'm not sure if this really works, but you could try: >- Raise your thread/process's priority using SetPriorityClass or >SetThreadPriority. This is to minimize the (unpredictable) delay of sleep() I do launch the module with CreateProcess with RealTimePriority - it does stabilize things a bit >- Keep your qPC loop, but insert a sleep(0) call, this would free the CPU. Does 0 have a special meaning vs. .0000001 for example? I'll give it a try. The desired total delay is about .0056s, so I'd like to sleep() for ~.004 and then wake up and catch the exact tick. For some reason, sleep(.001) actually adds up to a good bit more, like .004, and sleep(.0001) collapses to ~statement execution time, like 10us! That's why if I use .0001 the CPU is still 100% loaded; with .001 it drops to near zero, but, the timing is way off. I'l do an example code to demonstrate, and see if others get the same responses. I'm wondering if sleep() uses the 8254 or RTC timers instead of the TSC counter or APIC timer(?) I did see an interesting point about RTAI as well " Also, one should note that nanosleep() is a busy wait in the kernel when the request to sleep is for an amount of two milliseconds or less. Therefore, a busy wait would not simulate interrupt response time as well as a true sleep. ", so LINUX does not have a true short sleep() either... http://www.rtems.com/ml/rtems-users/2004/march/msg00067.html has a good discussion as well that I need to look into. Thanks, Ray From timr at probo.com Fri Aug 4 19:29:10 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 04 Aug 2006 10:29:10 -0700 Subject: [python-win32] sleep() for less than .001s? In-Reply-To: <6.2.3.4.2.20060803182830.058e2c28@blue-cove.com> References: <6.2.3.4.2.20060803182830.058e2c28@blue-cove.com> Message-ID: <44D383E6.4020704@probo.com> Ray Schumacher wrote: > I have been trying to use sleep() and kernel32.QueryPerformanceCounter > together; I want to delay until a particular tick without trying up > the CPU badly. > However, while time.sleep(.001) relieves the CPU, it has wildly > unpredictable delay, and sleep(.0001) delays almost nothing at all! > (I'm watching the parallel port on a scope). > If I use a while and just count ticks with QueryPerformanceCounter(), > it is very stable and as desired - but it uses 100% CPU. > > RTAI LINUX has a nanosleep() function that does it all very nicely on > our Debian install, is there a parallel in Win32? > The MS Sleep() function is in integer milliseconds... No. Windows simply has no mechanism for doing sub-millisecond sleeps. The default scheduling interval in XP is 10 milliseconds. You can't get an interrupt more granular than that, even in kernel mode. It is possible to change the scheduling interval to 1 millisecond by using timeBeginTime, although performance suffers. It is possible to use QueryPerformanceCounter to do a spin-stall, but you are essentially in an infinite loop. ALSO remember that you are still sharing the CPU with other processes. If another process decides it wants to hog the CPU for its whole time slice, you'll lose 10 milliseconds. If a driver decides it needs to do a thermal recalibration on your disk drive and stalls for 5 milliseconds, you'll lose 5 milliseconds. Remember that RTAI LINUX is a real-time operating system designed for deterministic processing. Windows most definitely is not. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rays at blue-cove.com Fri Aug 4 19:40:01 2006 From: rays at blue-cove.com (Ray Schumacher) Date: Fri, 04 Aug 2006 10:40:01 -0700 Subject: [python-win32] sleep() for less than .001s? In-Reply-To: <7.0.1.0.0.20060804063852.03a9c138@yahoo.com.ar> References: <6.2.3.4.2.20060803182830.058e2c28@blue-cove.com> <7.0.1.0.0.20060804063852.03a9c138@yahoo.com.ar> Message-ID: <6.2.3.4.2.20060804101842.0590bad8@blue-cove.com> In the attached test code, I get - for test in [0, .1, .01, .001, .00001] seconds # 2.9us hi 5.2us low, # 110ms hi and low, # 16ms hi and low, # 16ms hi and low, # 2.9us hi 5.2us low Intestingly, if I un-comment the #print '\r', then the processor usage drops by ~11 per cent. If anyone has comments on these sleep() results, please enlighten me as to why. Ideally, on how to implement a shorter sleep() (wrap/weave C?) and still relieve the CPU... Ray http://rjs.org -------------- next part -------------- from ctypes import * from time import * #import test1 # to compile it... import win32process from sys import argv import os priorityclasses = [win32process.IDLE_PRIORITY_CLASS, win32process.BELOW_NORMAL_PRIORITY_CLASS, win32process.NORMAL_PRIORITY_CLASS, win32process.ABOVE_NORMAL_PRIORITY_CLASS, win32process.HIGH_PRIORITY_CLASS, win32process.REALTIME_PRIORITY_CLASS] if len(argv)<3: print 'usage: >>python startApp.py progToRun.py {priority}' print 'where priority is in [0:5] of:' print priorityclasses def setpriority(pid=None,priority=1): """ Set The Priority of a Windows Process. Priority is a value between 0-5 where 2 is normal priority. Default sets the priority of the current python process but can take any valid process ID. """ import win32api, win32con if pid == None: pid = win32api.GetCurrentProcessId() handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid) win32process.SetPriorityClass(handle, priorityclasses[priority]) k32=windll.kernel32 c1 = c_ulonglong() qPC = k32.QueryPerformanceCounter qPC(byref(c1)) #print c1.value priority = priorityclasses[int(argv[2])] StartupInfo = win32process.STARTUPINFO() execute_target=None commandLine='python '+argv[1]+' '+argv[2]+' '+str(c1.value) processAttributes=None threadAttributes=None bInheritHandles=0 dwCreationFlags=priority#|win32process.CREATE_NO_WINDOW ## hide it! newEnvironment=None processHndl, primary_thread, pid, tid = win32process.CreateProcess(execute_target, commandLine, processAttributes, threadAttributes, bInheritHandles, dwCreationFlags, newEnvironment, os.getcwd(), StartupInfo) #print processHndl, primary_thread, pid, tid -------------- next part -------------- # start with ">>python startapp.py t1.py 5" print 'test1.py' from ctypes import * from time import * import sys import os thisOS = os.name if thisOS=='nt': from dlportio import * else: from parallel import * k32=windll.kernel32 c0 = c_ulonglong() c1 = c_ulonglong() qPC = k32.QueryPerformanceCounter qpFreq = k32.QueryPerformanceFrequency l=[[]]*1000 for i in range(1000): qPC(byref(c0)) qPC(byref(c1)) l[i] = c1.value - c0.value tickCallTicks = sum(l[40:50])/10. print 'tick call time', tickCallTicks t = c_ulonglong() qpFreq(byref(t)) pFreq = t.value print 'processor freq:', pFreq, 'inst./s' ticksPerUs = pFreq/1000000. qPC(byref(c0)) sleep(.000001) qPC(byref(c1)) minSleepTicks = c1.value-c0.value-tickCallTicks print 'minSleep tics', minSleepTicks print c1.value-int(sys.argv[1]), 'ticks to start up (',(c1.value-int(sys.argv[1]))/float(pFreq),'s)' TTLHighDur = ticksPerUs*500 # ~500us currTicksPerPrd = 10333543 prdN = 0 """ qPC(byref(c0)) tick0 = c0.value # initial count nextTTL = tick0 endTick = tick0+pFreq* 15 #seconds ## make a decent TTLOUT while(True): nextTTL = currTicksPerPrd+nextTTL #sleep(.001)# sleep does almost nothing? while(True): #loop until ~the exact tick qPC(byref(c1)) if c1.value>nextTTL: break out(0x378, 0xFF) #set all bits high while(True): #loop until ~the exact tick qPC(byref(c1)) if c1.value>nextTTL+TTLHighDur: break out(0x378, 0x00) #set all bits low prdN += 1 if c1.value>endTick: break """ ## test sleep() test = [0, .1, .01, .001, .00001] tNum = 0 for slpT in test: # result: # 2.9us hi 5.2us low, # 110ms hi and low, # 16ms hi and low, # 16ms hi and low, # 2.9us hi 5.2us low print 'testing', slpT qPC(byref(c0)) tick0 = c0.value # initial count nextTTL = tick0 endTick = tick0+pFreq* 8 #seconds while(True): #print '\r', qPC(byref(c0)) sleep(slpT) out(0x378, 0xFF) #set all bits high sleep(slpT) out(0x378, 0x00) #set all bits low prdN += 1 qPC(byref(c1)) if c1.value>endTick: break #print '\r ', int(.5*(c1.value-c0.value)/float(ticksPerUs)), 'us', print '\t', .5*(c1.value-c0.value)/float(ticksPerUs), '\n' test[tNum] = .5*(c1.value-c0.value)/float(ticksPerUs) tNum += 1 print test From rays at blue-cove.com Fri Aug 4 19:58:55 2006 From: rays at blue-cove.com (Ray Schumacher) Date: Fri, 04 Aug 2006 10:58:55 -0700 Subject: [python-win32] sleep() for less than .001s? In-Reply-To: <44D383E6.4020704@probo.com> References: <6.2.3.4.2.20060803182830.058e2c28@blue-cove.com> <44D383E6.4020704@probo.com> Message-ID: <6.2.3.4.2.20060804105134.05901ca8@blue-cove.com> At 10:29 AM 8/4/2006, Tim Roberts wrote: >Ray Schumacher wrote: > >> I have been trying to use sleep() and kernel32.QueryPerformanceCounter >> together; I want to delay until a particular tick without trying up >> the CPU badly. >> However, while time.sleep(.001) relieves the CPU, it has wildly >> unpredictable delay, and sleep(.0001) delays almost nothing at all! >> (I'm watching the parallel port on a scope). >> If I use a while and just count ticks with QueryPerformanceCounter(), >> it is very stable and as desired - but it uses 100% CPU. >> >> RTAI LINUX has a nanosleep() function that does it all very nicely on >> our Debian install, is there a parallel in Win32? >> The MS Sleep() function is in integer milliseconds... > > >No. Windows simply has no mechanism for doing sub-millisecond sleeps. >The default scheduling interval in XP is 10 milliseconds. You can't get >an interrupt more granular than that, even in kernel mode. ahh >It is >possible to change the scheduling interval to 1 millisecond by using >timeBeginTime, although performance suffers. I see a timeBeginPeriod (?): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_timegettime.asp used with timeGetTime, normally... "Windows NT/2000: The default precision of the timeGetTime function can be five milliseconds or more, depending on the machine. You can use the timeBeginPeriod and timeEndPeriod functions to increase the precision of timeGetTime. If you do so, the minimum difference between successive values returned by timeGetTime can be as large as the minimum period value set using timeBeginPeriod and timeEndPeriod. Use the QueryPerformanceCounter and QueryPerformanceFrequency functions to measure short time intervals at a high resolution, Windows 95: The default precision of the timeGetTime function is 1 millisecond. In other words, the timeGetTime function can return successive values that differ by just 1 millisecond. This is true no matter what calls have been made to the timeBeginPeriod and timeEndPeriod functions. " I'll fiddle with these later. >It is possible to use QueryPerformanceCounter to do a spin-stall, but >you are essentially in an infinite loop. ALSO remember that you are >still sharing the CPU with other processes. If another process decides >it wants to hog the CPU for its whole time slice, you'll lose 10 >milliseconds. If a driver decides it needs to do a thermal >recalibration on your disk drive and stalls for 5 milliseconds, you'll >lose 5 milliseconds. > >Remember that RTAI LINUX is a real-time operating system designed for >deterministic processing. Windows most definitely is not. Thanks for the info, Ray -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060804/9f0125c1/attachment.htm From timr at probo.com Fri Aug 4 20:01:07 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 04 Aug 2006 11:01:07 -0700 Subject: [python-win32] sleep() for less than .001s? In-Reply-To: <6.2.3.4.2.20060804101842.0590bad8@blue-cove.com> References: <6.2.3.4.2.20060803182830.058e2c28@blue-cove.com> <7.0.1.0.0.20060804063852.03a9c138@yahoo.com.ar> <6.2.3.4.2.20060804101842.0590bad8@blue-cove.com> Message-ID: <44D38B63.3010303@probo.com> Ray Schumacher wrote: >In the attached test code, I get - for test in [0, .1, .01, .001, .00001] seconds > > # 2.9us hi 5.2us low, > # 110ms hi and low, > # 16ms hi and low, > # 16ms hi and low, > # 2.9us hi 5.2us low > >Intestingly, if I un-comment the > #print '\r', >then the processor usage drops by ~11 per cent. > >If anyone has comments on these sleep() results, please enlighten me as to why. > > What surprises you? The Win32 Sleep() function takes integer milliseconds. Thus, .00001 will round to 0, which says "give up the CPU only if a higher-priority task is waiting.". The default scheduling interval on your system is 16ms. Some Windows systems use that, some use 10ms; it depends on the HAL. Windows only checks for timer expiration when its scheduling runs, and the scheduler doesn't run any more often than that. You can reduce that to 1ms by using timeBeginPeriod (I said timeBeginTime before; that was wrong), but it will cost overall system performance, because you're getting interrupts 16x as often. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rays at blue-cove.com Fri Aug 4 22:01:49 2006 From: rays at blue-cove.com (Ray Schumacher) Date: Fri, 04 Aug 2006 13:01:49 -0700 Subject: [python-win32] sleep() for less than .001s? In-Reply-To: <44D38B63.3010303@probo.com> References: <6.2.3.4.2.20060803182830.058e2c28@blue-cove.com> <7.0.1.0.0.20060804063852.03a9c138@yahoo.com.ar> <6.2.3.4.2.20060804101842.0590bad8@blue-cove.com> <44D38B63.3010303@probo.com> Message-ID: <6.2.3.4.2.20060804125317.058d9998@blue-cove.com> At 11:01 AM 8/4/2006, Tim Roberts wrote: >What surprises you? The Win32 Sleep() function takes integer >milliseconds. Thus, .00001 will round to 0, which says "give up the CPU >only if a higher-priority task is waiting.". > >The default scheduling interval on your system is 16ms. Some Windows >systems use that, some use 10ms; it depends on the HAL. Windows only >checks for timer expiration when its scheduling runs, and the scheduler >doesn't run any more often than that. You can reduce that to 1ms by >using timeBeginPeriod (I said timeBeginTime before; that was wrong), but >it will cost overall system performance, because you're getting >interrupts 16x as often. Then, it will just have to be seen whether a faster scheduler is worse than tying up one half of a dual core CPU with a thread just doing whiles and checking for messages. A test on Win9x might be interesting too, to use its 1ms schedule. Thanks again, Ray From mhammond at skippinet.com.au Sat Aug 5 03:56:43 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 5 Aug 2006 11:56:43 +1000 Subject: [python-win32] Dispatches With Events on COM Object In-Reply-To: <44D30969.7010202@cenix-bioscience.com> Message-ID: <0ab901c6b832$6711e760$0200a8c0@enfoldsystems.local> > Ah good point, I put back in the brackets (doh!) and I am now back to > the previous place: > > mod = > gencache.EnsureModule('{A4818FD5-6479-11D4-8452-00104B92DD56}', 0, > 1, 0) > print dir(mod) > ob = mod.Application() > print dir(ob) > objCybio = win32com.client.DispatchWithEvents(ob, CybioEvents) > > >>> ['Application', 'CLSID', 'CLSIDToClassMap', 'CLSIDToPackageMap', > 'CoClassBaseClass', 'Dispatch', 'DispatchBaseClass', 'IApplication', > 'IApplicationEvents', 'IApplicationEvents_vtables_', > 'IApplicationEvents_vtables_dispatch_', 'IDocumentEvents', > 'IDocumentEvents_vtables_', > 'IDocumentEvents_vtables_dispatch_', 'IID', > 'LCID', 'LibraryFlags', 'MajorVersion', 'MinorVersion', > 'NamesToIIDMap', > 'RecordMap', 'VTablesToClassMap', 'VTablesToPackageMap', > '__builtins__', > '__doc__', '__file__', '__name__', '_in_gencache_', > 'defaultNamedNotOptArg', 'defaultNamedOptArg', 'defaultUnnamedArg', > 'makepy_version', 'python_version', 'pythoncom', 'win32com'] > ['CLSID', '__doc__', '__getattr__', '__init__', '__module__', > '__repr__', '__setattr__', '_dispobj_', 'coclass_interfaces', > 'coclass_sources', 'default_interface', 'default_source'] > Traceback (most recent call last): > File "C:\Program > Files\Python24\Lib\site-packages\pythonwin\pywin\framework\scr > iptutils.py", > line 310, in RunScript > exec codeObject in __main__.__dict__ > File "C:\Documents and Settings\benn\Desktop\cybio > test.py", line 16, in ? > objCybio = win32com.client.DispatchWithEvents(ob, CybioEvents) > File "C:\Program > Files\Python24\Lib\site-packages\win32com\client\__init__.py", > line 254, > in DispatchWithEvents > raise TypeError, "This COM object can not automate the makepy > process - please run makepy manually for this object" > TypeError: This COM object can not automate the makepy > process - please > run makepy manually for this object That surprises me, and sadly I can't think of a reasonable COM object I can use to help test this with. Note the offending code in __init__.py: if not disp.__class__.__dict__.get("CLSID"): # Eeek - no makepy support - try and build it. try: ... except pythoncom.com_error: raise TypeError, "This COM object can not automate the makepy process - please run makepy manually for this object" I'm expecting that first if statement to cause the entire block to be skipped. Indeed, 'CLSID' is one of the attributes in that list printed above. You may like to try and see if you can workout why we are entering that block. Cheers, Mark From kc106_2005-pywin32 at yahoo.com Sat Aug 5 04:55:22 2006 From: kc106_2005-pywin32 at yahoo.com (kc106_2005-pywin32 at yahoo.com) Date: Fri, 4 Aug 2006 19:55:22 -0700 (PDT) Subject: [python-win32] Need help with converting a simple Excel macro Message-ID: <20060805025522.15460.qmail@web51409.mail.yahoo.com> Hi list, I have a need to copy 3 rows of data from the top of my Excel spreadsheet to another location. I would have throught that this should be very straightforward since I've done a fair amount of Excel/Python programming. Unforturnately, I am stuck on this one. The VB Macro says I need to: Range("1:1,2:2,3:3").Select Range("A3").Activate Selection.Copy Rows("20:20").Select ActiveSheet.Paste So, I figure the Python code would be something like: 1) xlSheet=xlApp.ActiveWorkbook.ActiveSheet 2) xlSel=xlSheet.Range("1:1,2:2,3:3").Select() 3) #xlSel=xlSheet.Range("A3").Activate() 4) xlSel.Copy() 5) xlSheet.Rows("20:20").Select() 6) xlSheet.Paste() Unfortunately, this doesn't work. After line 2, xlSel becomes "True" - not a "Selection" and so the code fails at line 4). I am not sure why I have to do the "Activate" on line 3 but it didn't matter, the code still fails at line 4. What am I doing wrong? Any help is greatly appreciated. Regards, -- John Henry From rwupole at msn.com Sat Aug 5 05:25:55 2006 From: rwupole at msn.com (Roger Upole) Date: Fri, 4 Aug 2006 23:25:55 -0400 Subject: [python-win32] Re: Need help with converting a simple Excel macro Message-ID: > Hi list, > > I have a need to copy 3 rows of data from the top of > my Excel spreadsheet to another location. I would > have throught that this should be very straightforward > since I've done a fair amount of Excel/Python > programming. Unforturnately, I am stuck on this one. > > The VB Macro says I need to: > > Range("1:1,2:2,3:3").Select > Range("A3").Activate > Selection.Copy > Rows("20:20").Select > ActiveSheet.Paste > > So, I figure the Python code would be something like: > > > 1) xlSheet=xlApp.ActiveWorkbook.ActiveSheet > 2) xlSel=xlSheet.Range("1:1,2:2,3:3").Select() In this line, the result of the Select call is bound to xlSel, rather than the Range object you need. Try these 2 lines instead: xlSel=xlSheet.Range("1:1,2:2,3:3") xlSel.Select() Roger From kc106_2005-pywin32 at yahoo.com Sat Aug 5 20:09:19 2006 From: kc106_2005-pywin32 at yahoo.com (kc106_2005-pywin32 at yahoo.com) Date: Sat, 5 Aug 2006 11:09:19 -0700 (PDT) Subject: [python-win32] Need help with converting a simple Excel Message-ID: <20060805180919.8326.qmail@web51406.mail.yahoo.com> Thanks for the help, Roger. Yes, that works. I just have to remember that: xlSel=xlSheet.Range("1:1,2:2,3:3").Select() is *NOT* the same as: xlSel=xlSheet.Range("1:1,2:2,3:3") xlSel.Select() Thanks again. > Hi list, > > I have a need to copy 3 rows of data from the top of > my Excel spreadsheet to another location. I would > have throught that this should be very straightforward > since I've done a fair amount of Excel/Python > programming. Unforturnately, I am stuck on this one. > > The VB Macro says I need to: > > Range("1:1,2:2,3:3").Select > Range("A3").Activate > Selection.Copy > Rows("20:20").Select > ActiveSheet.Paste > > So, I figure the Python code would be something like: > > > 1) xlSheet=xlApp.ActiveWorkbook.ActiveSheet > 2) xlSel=xlSheet.Range("1:1,2:2,3:3").Select() In this line, the result of the Select call is bound to xlSel, rather than the Range object you need. Try these 2 lines instead: xlSel=xlSheet.Range("1:1,2:2,3:3") xlSel.Select() Roger -- John Henry From hadaqada at gmail.com Mon Aug 7 11:53:51 2006 From: hadaqada at gmail.com (Uffe Wassmann) Date: Mon, 7 Aug 2006 11:53:51 +0200 Subject: [python-win32] Embedding an OLE object through ADO. How..? In-Reply-To: References: Message-ID: My employer would like an Access database updated. It has been made partly by hand before, but I thought it should be automated, as 99% of the relevant information is available by looking at the file system and parsing some text files. In the past week this has led me to learn something about python dictionaries, tuples, lists, classes, expected syntax, WinPython (got that book here, ya :), and I'm at the point where I've created a new database with nice relations between the tables and all information available. Except the preview pictures. Now, other db's can take binary things beyond 1kb without coughing, but he needs it to be Access for the customers' sake. So, ADO and creation of an embedded OLE object it is, I'm thinking. Visual Basic guides inherits the OLE object from a base class and uses the creation method from it. So my question is.. where do I get this method and object from in WinPython? It is probably simple, but I can't find it :] I use Python 2.4, WinPython, and have run makepy on DAO and ADO libraries. I did -not- attempt to parse makepy's generated files beyond skimming it :] _____________________________________________________________ Code: _____________________________________________________________ import win32com.client from pprint import pprint adoConn = win32com.client.Dispatch('ADODB.Connection') adoConn.Open('MS Access-database') adoRS=win32com.client.Dispatch('ADODB.Recordset') adoConn.Execute("DROP TABLE Preview") adoConn.Execute("CREATE TABLE Preview (SceneId int, Preview OLEObject)") adoRS.Open("[Preview]",adoConn, 1, 3) # 1=adOpenKeyset, 3=adLockOptimistic adoRS.AddNew() adoRS.Fields("SceneId").Value=1 adoRS.Fields("Preview").Value=**** What is expected here? ***** adoRS.Update() adoRS.Close() From benn at cenix-bioscience.com Tue Aug 8 11:08:52 2006 From: benn at cenix-bioscience.com (Neil Benn) Date: Tue, 08 Aug 2006 11:08:52 +0200 Subject: [python-win32] Dispatches With Events on COM Object In-Reply-To: <0ab901c6b832$6711e760$0200a8c0@enfoldsystems.local> References: <0ab901c6b832$6711e760$0200a8c0@enfoldsystems.local> Message-ID: <44D854A4.9060906@cenix-bioscience.com> Mark Hammond wrote: >> Ah good point, I put back in the brackets (doh!) and I am now back to >> the previous place: >> >> mod = >> gencache.EnsureModule('{A4818FD5-6479-11D4-8452-00104B92DD56}', 0, >> 1, 0) >> print dir(mod) >> ob = mod.Application() >> print dir(ob) >> objCybio = win32com.client.DispatchWithEvents(ob, CybioEvents) >> >> >>> ['Application', 'CLSID', 'CLSIDToClassMap', 'CLSIDToPackageMap', >> 'CoClassBaseClass', 'Dispatch', 'DispatchBaseClass', 'IApplication', >> 'IApplicationEvents', 'IApplicationEvents_vtables_', >> 'IApplicationEvents_vtables_dispatch_', 'IDocumentEvents', >> 'IDocumentEvents_vtables_', >> 'IDocumentEvents_vtables_dispatch_', 'IID', >> 'LCID', 'LibraryFlags', 'MajorVersion', 'MinorVersion', >> 'NamesToIIDMap', >> 'RecordMap', 'VTablesToClassMap', 'VTablesToPackageMap', >> '__builtins__', >> '__doc__', '__file__', '__name__', '_in_gencache_', >> 'defaultNamedNotOptArg', 'defaultNamedOptArg', 'defaultUnnamedArg', >> 'makepy_version', 'python_version', 'pythoncom', 'win32com'] >> ['CLSID', '__doc__', '__getattr__', '__init__', '__module__', >> '__repr__', '__setattr__', '_dispobj_', 'coclass_interfaces', >> 'coclass_sources', 'default_interface', 'default_source'] >> Traceback (most recent call last): >> File "C:\Program >> Files\Python24\Lib\site-packages\pythonwin\pywin\framework\scr >> iptutils.py", >> line 310, in RunScript >> exec codeObject in __main__.__dict__ >> File "C:\Documents and Settings\benn\Desktop\cybio >> test.py", line 16, in ? >> objCybio = win32com.client.DispatchWithEvents(ob, CybioEvents) >> File "C:\Program >> Files\Python24\Lib\site-packages\win32com\client\__init__.py", >> line 254, >> in DispatchWithEvents >> raise TypeError, "This COM object can not automate the makepy >> process - please run makepy manually for this object" >> TypeError: This COM object can not automate the makepy >> process - please >> run makepy manually for this object >> > > That surprises me, and sadly I can't think of a reasonable COM object I can > use to help test this with. Note the offending code in __init__.py: > > if not disp.__class__.__dict__.get("CLSID"): # Eeek - no makepy support - > try and build it. > try: > ... > except pythoncom.com_error: > raise TypeError, "This COM object can not automate the makepy > process - please run makepy manually for this object" > > Hello, Thanks for your reply, I put logging onto the screen and here is what I found: * The call to Dispatch happens * The __wrapDispatch is called with an object for dispatch but the username is None * The getTypeInfo method throws an pywintypes.com_error which has the message of (-2147467263, 'Not implemented', None, None) * The dynamic dispatch method is called which returns an instance of COMObject * the __class__.__dict__ for this has the following key/value pairs 0 = _wrap_dispatch_ 1 = __module__ 2 = __doc__ Therefore there is no CLSID for the object which causes the makepy message to appear. I've printed out the return from the dynamic dispatch call: DISPATCH PRINT > DIR DISPATCH PRINT ['_ApplyTypes_', '_FlagAsMethod', '_LazyAddAttr_', '_NewEnum', '_Release_', '__A ttrToID__', '__LazyMap__', '__call__', '__cmp__', '__doc__', '__getattr__', '__g etitem__', '__init__', '__int__', '__len__', '__module__', '__nonzero__', '__rep r__', '__setattr__', '__setitem__', '__str__', '_builtMethods_', '_enum_', '_fin d_dispatch_type_', '_get_good_object_', '_get_good_single_object_', '_lazydata_' , '_make_method_', '_mapCachedItems_', '_oleobj_', '_olerepr_', '_print_details_ ', '_proc_', '_unicode_to_string_', '_username_', '_wrap_dispatch_'] DISPATCH MAP 0 = _wrap_dispatch_ 1 = __module__ 2 = __doc__ Is there anything there which could provide a clue? Cheers, Neil -- Neil Benn MSc Head of Automation Cenix BioScience GmbH Tatzberg 47 01307 Dresden Germany http://wwww.cenix-bioscience.com From rwupole at msn.com Wed Aug 9 03:15:30 2006 From: rwupole at msn.com (Roger Upole) Date: Tue, 8 Aug 2006 21:15:30 -0400 Subject: [python-win32] Re:Embedding an OLE object through ADO. How..? Message-ID: Apparently access uses some kind of undocumented byte stream format for ole objects. There's some code in this article http://www.codeguru.com/cpp/data/mfc_database/microsoftaccess/article.php/c1123 but it uses some functions not wrapped by pywin32. Roger From odiogo at kameruuh.eu Wed Aug 9 14:30:50 2006 From: odiogo at kameruuh.eu (Diogo) Date: Wed, 9 Aug 2006 14:30:50 +0200 Subject: [python-win32] OLE Server Busy dialog box In-Reply-To: <67dcd18b0608040442l47d01d68o82e0b2af83c644ff@mail.gmail.com> References: <67dcd18b0608020416m37406313ofda268b7651c6402@mail.gmail.com> <007101c6b62c$e4b5be10$0200a8c0@enfoldsystems.local> <67dcd18b0608040442l47d01d68o82e0b2af83c644ff@mail.gmail.com> Message-ID: <67dcd18b0608090530l3276e907h4313ea65b256d481@mail.gmail.com> Hi! Some more details about the server busy dialog box. This program, that I'm working with, calls MakeActiveXClass(wxPython), which calls pywin.mfc.CreateControl, which calls win32ui.CreateControl. If I connect to a slow COM server just _before_ the call to win32ui.CreateControl, then everything is fine, no busy message. But after the Control is created, it seems that the program gets in an "incorrect" state, i.e, whenever I call a slow COM server, _after_ CreateControl has been called, the busy message box will appears. is there perhaps any initialization that I may have forgotten, or any other ideas? Thanks a lot, Diogo 2006/8/4, Diogo : > > Unless you are using the win32ui module, its unlikely you qualify as an "MFC > > COM client". > > I'm not using the win32ui. And this makes me wonder I would get this box. I was wrong at this point. The program is using win32ui. > > > | Another way to suppress the server busy dialog box is to use > > | OleInitialize and OleUninitialize instead of AfxOleInit in your > > | application. > > > > which are easy to call. > The program was using CoInitialize() only. Now it uses OleInitialize(). > The "busy message" doesn't appear always, and with OleInitialize it > stopped appering in my computer. But while running in another computer > it still appears. > > BTW, there's no OleUninitialize. Should I use the Co one? > > Thanks for the help, > Diogo > From mhammond at skippinet.com.au Wed Aug 9 15:04:13 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 9 Aug 2006 23:04:13 +1000 Subject: [python-win32] OLE Server Busy dialog box In-Reply-To: <67dcd18b0608090530l3276e907h4313ea65b256d481@mail.gmail.com> Message-ID: <169101c6bbb4$509a1360$0200a8c0@enfoldsystems.local> I can throw you a new win32uiole module with the functions referenced in the knowledge base article, but apart from trying to fiddle with the main thread's thread-state (search for 'sys.coinit_flags'), I can't offer much more help... Mark > Some more details about the server busy dialog box. > > This program, that I'm working with, calls MakeActiveXClass(wxPython), > which calls pywin.mfc.CreateControl, which calls > win32ui.CreateControl. If I connect to a slow COM server just _before_ > the call to win32ui.CreateControl, then everything is fine, no busy > message. But after the Control is created, it seems that the program > gets in an "incorrect" state, i.e, whenever I call a slow COM server, > _after_ CreateControl has been called, the busy message box will > appears. > > is there perhaps any initialization that I may have forgotten, or any > other ideas? > > Thanks a lot, > Diogo > > > > 2006/8/4, Diogo : > > > Unless you are using the win32ui module, its unlikely you > qualify as an "MFC > > > COM client". > > > > I'm not using the win32ui. And this makes me wonder I would > get this box. > I was wrong at this point. The program is using win32ui. > > > > > > | Another way to suppress the server busy dialog box is to use > > > | OleInitialize and OleUninitialize instead of AfxOleInit in your > > > | application. > > > > > > which are easy to call. > > The program was using CoInitialize() only. Now it uses > OleInitialize(). > > The "busy message" doesn't appear always, and with OleInitialize it > > stopped appering in my computer. But while running in > another computer > > it still appears. > > > > BTW, there's no OleUninitialize. Should I use the Co one? > > > > Thanks for the help, > > Diogo > > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From mhammond at skippinet.com.au Wed Aug 9 15:12:56 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 9 Aug 2006 23:12:56 +1000 Subject: [python-win32] Dispatches With Events on COM Object In-Reply-To: <44D854A4.9060906@cenix-bioscience.com> Message-ID: <169601c6bbb5$887b1440$0200a8c0@enfoldsystems.local> > * The call to Dispatch happens > * The __wrapDispatch is called with an object for dispatch but the > username is None > * The getTypeInfo method throws an pywintypes.com_error which has > the message of (-2147467263, 'Not implemented', None, None) It is that last step where things go wrong it seems. If the object is already a makepy wrapped object, we shouldn't call GetTypeInfo - the object should just be used as-is. We might need a similar check for a CLSID attribute there (or better, a function eg, gencache.IsGeneratedObject() that abstracts that implementation detail). I'm afraid I'm out of time for today though... Cheers, Mark From riltim at gmail.com Wed Aug 9 21:55:52 2006 From: riltim at gmail.com (Tim Riley) Date: Wed, 9 Aug 2006 15:55:52 -0400 Subject: [python-win32] win32ui.CreateFileDialog error Message-ID: Can anyone explain to me why the following code will return a list if I select 12 files but will return None if I select 13? #file: pdf_batch_plot.py #auth: Tim Riley #rev: 0 #desc: Allows the selection of multiple pdf files and batch plots them to pdf. # #Note: This program requires the win32all package for Python as it makes use # of Windows API calls to create the open file dialog box as well as # COM calls to control AutoCAD. #------------------------------------------------------------------------------ import sys, os import win32ui import win32con # create an OpenFileDialog using win32ui.CreateFileDialog def GetFiles(): dlg = win32ui.CreateFileDialog(1, None, None, (win32con.OFN_FILEMUSTEXIST| win32con.OFN_EXPLORER| win32con.OFN_ALLOWMULTISELECT), 'AutoCAD Drawings (*.dwg)|*.dwg||') dlg.SetOFNTitle('Select Drawing Files') testvalue = dlg.DoModal() if testvalue == win32con.IDOK: return dlg.GetPathNames() if __name__ == '__main__': printfiles = GetFiles() print printfiles blah = raw_input('hit enter...') -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060809/47b3174e/attachment.html From timr at probo.com Wed Aug 9 22:41:57 2006 From: timr at probo.com (Tim Roberts) Date: Wed, 09 Aug 2006 13:41:57 -0700 Subject: [python-win32] win32ui.CreateFileDialog error In-Reply-To: References: Message-ID: <44DA4895.9050407@probo.com> Tim Riley wrote: > Can anyone explain to me why the following code will return a list if > I select 12 files but will return None if I select 13? It's an ugly but well-known limitation: the buffer passed to CreateFileDialog is big, but not big enough. When you select more files than will fit, the API returns an error, and the wrapper returns that error instead of reallocating and retrying. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rwupole at msn.com Thu Aug 10 03:43:36 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 9 Aug 2006 21:43:36 -0400 Subject: [python-win32] Re: win32ui.CreateFileDialog error Message-ID: You can call win32gui.CommDlgExtendedError() to find the reason why it failed. If the buffer size is actually the problem, it will return winerror.FNERR_BUFFERTOOSMALL (12291). win32gui.GetOpenFileNameW creates the same type of dialog, and you can use the MaxFile argument to specify a large buffer size if needed. Roger From gagsl-p32 at yahoo.com.ar Thu Aug 10 06:48:44 2006 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Aug 2006 01:48:44 -0300 Subject: [python-win32] win32ui.CreateFileDialog error In-Reply-To: <44DA4895.9050407@probo.com> References: <44DA4895.9050407@probo.com> Message-ID: <7.0.1.0.0.20060810014535.03f89d90@yahoo.com.ar> At Wednesday 9/8/2006 17:41, Tim Roberts wrote: > > Can anyone explain to me why the following code will return a list if > > I select 12 files but will return None if I select 13? > > >It's an ugly but well-known limitation: the buffer passed to >CreateFileDialog is big, but not big enough. When you select more files >than will fit, the API returns an error, and the wrapper returns that >error instead of reallocating and retrying. But how can one detect that? DoModal() returns 2 (IDCANCEL) in this case, how can be distinguished from the user pressing the Cancel button? Gabriel Genellina Softlab SRL __________________________________________________ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas From odiogo at kameruuh.eu Thu Aug 10 14:15:44 2006 From: odiogo at kameruuh.eu (Diogo) Date: Thu, 10 Aug 2006 14:15:44 +0200 Subject: [python-win32] OLE Server Busy dialog box In-Reply-To: <67dcd18b0608020416m37406313ofda268b7651c6402@mail.gmail.com> References: <67dcd18b0608020416m37406313ofda268b7651c6402@mail.gmail.com> Message-ID: <67dcd18b0608100515i5115b5a2s2acd2cd47a68621e@mail.gmail.com> Hi list! It follows how the "OLE Server Busy" problem can be solved. The problem is this: "If you call a method on a COM server from an MFC COM client application and if the method takes a long time to process and return back, you won't be able to do anything on the client application and the OLE Server Busy dialog box pops up..." [1] To solve that, Mark modified the win32uiole, adding the necessary functions. Something like the following should be enough: import win32ui import win32uiole if hasattr(win32uiole,'SetMessagePendingDelay'): win32uiole.AfxOleInit() win32uiole.SetMessagePendingDelay(aBigDelay); win32uiole.EnableNotRespondingDialog(False); win32uiole.EnableBusyDialog(False); Note that these functions are not yet avaiable in release 209. Thanks for the help! Regards, Diogo [1] http://support.microsoft.com/?scid=kb%3Ben-us%3B248019&x=14&y=15 From nospam at marcmittag.de Thu Aug 10 19:02:34 2006 From: nospam at marcmittag.de (Marc Mittag) Date: Thu, 10 Aug 2006 19:02:34 +0200 Subject: [python-win32] use of dcom-interface on a windows machine with Plone on linux Message-ID: <67640350.20060810190234@marcmittag.de> Hi! I would like to connect to a dcom interface on windows from Plone /Zope on Linux. For Linux there exists an dcom-implementation, that probably is not really cheap http://www.softwareag.com/Corporate/products/entirex/downloads/default.asp and will be much more, than we need and can invest for a little application. Does anyone know something else? Perhaps especially for python and / or open source? thanks in advance Marc PS: I don't know, if this is the right mailinglist - if not, please tell me. From timr at probo.com Thu Aug 10 19:19:03 2006 From: timr at probo.com (Tim Roberts) Date: Thu, 10 Aug 2006 10:19:03 -0700 Subject: [python-win32] win32ui.CreateFileDialog error In-Reply-To: <44DA4895.9050407@probo.com> References: <44DA4895.9050407@probo.com> Message-ID: <44DB6A87.5010202@probo.com> Tim Roberts wrote: >Tim Riley wrote: > > >>Can anyone explain to me why the following code will return a list if >>I select 12 files but will return None if I select 13? >> >> > >It's an ugly but well-known limitation: the buffer passed to >CreateFileDialog is big, but not big enough. When you select more files >than will fit, the API returns an error, and the wrapper returns that >error instead of reallocating and retrying. > Allow me to apologize to pywin32. The problem is not in the pywin32 wrapper, the problem is in MFC. Pywin32 uses the MFC CFileDialog class, and that class has a hard-coded 256-byte buffer for the file names. Pywin32 cannot "reallocate and retry"; the interface is simply not exposed. Roger Upole's advice is the best: use win32gui.GetOpenFileNameW. It's not quite as friendly, but it doesn't have the same limitation. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From can at wasmerschroeder.com Wed Aug 16 01:11:30 2006 From: can at wasmerschroeder.com (Christopher A. Nethery) Date: Tue, 15 Aug 2006 19:11:30 -0400 Subject: [python-win32] Multithreaded Service Message-ID: <8C4B4388BC176244B5F36267D14B0BC9011FC3C9@exchange.wsdomain.lan> I am new to this group, but I'm hoping someone could offer some advice as to a complicated issue I am having. I have created a (multithreaded) Python application that performs asynchronous queries. Unfortunately, I'm having a very difficult time setting it up as a service. It should run as follows: 1) A remote server starts the service 2) while the service is running, it performs its asynchronous lookups--something like: while 1: ASYNCH_QUERY() time.sleep(30) else: sys.exit() I have taken a look at the pipeTestServiceClient.py and pipeTestService.py examples from win32all build 209, but I couldn't figure out how to adapt it to my own code, since nothing needs to be echoed back to the "invoking" server. Does anyone have any ideas? Thanking you in advance, CAN -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060815/26753861/attachment.htm From indy.liu at thinkingcactus.com Wed Aug 16 05:46:51 2006 From: indy.liu at thinkingcactus.com (Indy Liu) Date: Wed, 16 Aug 2006 15:46:51 +1200 Subject: [python-win32] Need help with COM MSN Messenger Interface Message-ID: <44E2952B.7090706@thinkingcactus.com> I need to write a plug-in for MSN Messenger in python. All it does is analyze a new message string and does some string ops on it. Can some body please give me some tips as to how I achieve this with win32com? I managed to obtain the messenger API type library as follows, and just don't know what to do from here. " >>> MSN = gencache.EnsureModule('{E02AD29E-80F5-46c6-B416-9B3EBDDF057E}', 0, 1, 0) >>> dir(MSN) ['CLSID', 'CLSIDToClassMap', 'CLSIDToPackageMap', 'CoClassBaseClass', 'DMessengerEvents', 'Dispatch', 'DispatchBaseClass', 'IID', 'IMessenger', 'IMessenger2', 'IMessenger2_vtables_', 'IMessenger2_vtables_dispatch_', 'IMessenger3', 'IMessenger3_vtables_', 'IMessenger3_vtables_dispatch_', 'IMessengerContact', 'IMessengerContact_vtables_', 'IMessengerContact_vtables_dispatch_', 'IMessengerContacts', 'IMessengerContacts_vtables_', 'IMessengerContacts_vtables_dispatch_', 'IMessengerConversationWnd', 'IMessengerConversationWnd_vtables_', 'IMessengerConversationWnd_vtables_dispatch_', 'IMessengerGroup', 'IMessengerGroup_vtables_', 'IMessengerGroup_vtables_dispatch_', 'IMessengerGroups', 'IMessengerGroups_vtables_', 'IMessengerGroups_vtables_dispatch_', 'IMessengerService', 'IMessengerService_vtables_', 'IMessengerService_vtables_dispatch_', 'IMessengerServices', 'IMessengerServices_vtables_', 'IMessengerServices_vtables_dispatch_', 'IMessengerWindow', 'IMessengerWindow_vtables_', 'IMessengerWindow_vtables_dispatch_', 'IMessenger_vtables_', 'IMessenger_vtables_dispatch_', 'LCID', 'LibraryFlags', 'MajorVersion', 'Messenger', 'MessengerNative', 'MinorVersion', 'NamesToIIDMap', 'RecordMap', 'VTablesToClassMap', 'VTablesToPackageMap', '__builtins__', '__doc__', '__file__', '__name__', '_in_gencache_', 'constants', 'defaultNamedNotOptArg', 'defaultNamedOptArg', 'defaultUnnamedArg', 'makepy_version', 'python_version', 'pythoncom', 'win32com'] " I don't want to use msnp.py since it requires the user to log in with msnp session manually as well as their MSN Messenger. I did hours of search online and the conclusion is posting & crying for help in this forum is really my best bet. Thanks. From patter001 at gmail.com Wed Aug 16 14:38:47 2006 From: patter001 at gmail.com (Kevin Patterson) Date: Wed, 16 Aug 2006 08:38:47 -0400 Subject: [python-win32] Need help with COM MSN Messenger Interface In-Reply-To: <44E2952B.7090706@thinkingcactus.com> References: <44E2952B.7090706@thinkingcactus.com> Message-ID: Have you tried the MSDN help on this COM Module? Mmmmm...actually after looking through the docs, maybe its not a whole lot of help. I see a lot of "Not Currently Supported" statements. Well, here's the link anyway in case there's something there: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winmessenger/winmessenger/reference/messengeruasdk/ifaces/imessenger/instantmessage.asp On 8/15/06, Indy Liu wrote: > > I need to write a plug-in for MSN Messenger in python. All it does is > analyze a new message string and does some string ops on it. Can some > body please give me some tips as to how I achieve this with win32com? > > I managed to obtain the messenger API type library as follows, and just > don't know what to do from here. > " > >>> MSN = > gencache.EnsureModule('{E02AD29E-80F5-46c6-B416-9B3EBDDF057E}', 0, 1, 0) > >>> dir(MSN) > ['CLSID', 'CLSIDToClassMap', 'CLSIDToPackageMap', 'CoClassBaseClass', > 'DMessengerEvents', 'Dispatch', 'DispatchBaseClass', 'IID', > 'IMessenger', 'IMessenger2', 'IMessenger2_vtables_', > 'IMessenger2_vtables_dispatch_', 'IMessenger3', 'IMessenger3_vtables_', > 'IMessenger3_vtables_dispatch_', 'IMessengerContact', > 'IMessengerContact_vtables_', 'IMessengerContact_vtables_dispatch_', > 'IMessengerContacts', 'IMessengerContacts_vtables_', > 'IMessengerContacts_vtables_dispatch_', 'IMessengerConversationWnd', > 'IMessengerConversationWnd_vtables_', > 'IMessengerConversationWnd_vtables_dispatch_', 'IMessengerGroup', > 'IMessengerGroup_vtables_', 'IMessengerGroup_vtables_dispatch_', > 'IMessengerGroups', 'IMessengerGroups_vtables_', > 'IMessengerGroups_vtables_dispatch_', 'IMessengerService', > 'IMessengerService_vtables_', 'IMessengerService_vtables_dispatch_', > 'IMessengerServices', 'IMessengerServices_vtables_', > 'IMessengerServices_vtables_dispatch_', 'IMessengerWindow', > 'IMessengerWindow_vtables_', 'IMessengerWindow_vtables_dispatch_', > 'IMessenger_vtables_', 'IMessenger_vtables_dispatch_', 'LCID', > 'LibraryFlags', 'MajorVersion', 'Messenger', 'MessengerNative', > 'MinorVersion', 'NamesToIIDMap', 'RecordMap', 'VTablesToClassMap', > 'VTablesToPackageMap', '__builtins__', '__doc__', '__file__', > '__name__', '_in_gencache_', 'constants', 'defaultNamedNotOptArg', > 'defaultNamedOptArg', 'defaultUnnamedArg', 'makepy_version', > 'python_version', 'pythoncom', 'win32com'] > " > > I don't want to use msnp.py since it requires the user to log in with > msnp session manually as well as their MSN Messenger. I did hours of > search online and the conclusion is posting & crying for help in this > forum is really my best bet. > > 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: http://mail.python.org/pipermail/python-win32/attachments/20060816/f01dcb30/attachment.html From patter001 at gmail.com Wed Aug 16 15:11:25 2006 From: patter001 at gmail.com (Kevin Patterson) Date: Wed, 16 Aug 2006 09:11:25 -0400 Subject: [python-win32] Variant ByRef 2D array returned as 1D array Message-ID: I'm working with a COM module that is returning a 2D array as a VARIANT BYREF. The 2D array is 30x8 (with each entry being 1 byte) When the data is returned I'm getting a buffer of length 30. This tells me that win32com only sees 1D of the array (documentation states that the buffer is expected for variants-byref with entries of 1 byte). Any ideas on why win32com doesn't see that there is really an array of arrays? The author of the code tests with VB so it seems to be working there, but not with Python. Here's a rough code snippet from the com module on how it is building the variant that needs to be returned. long lDimension[2] = {0,0}; SAFEARRAY *dataBuffer = variantReturn.parray; psaDataBuffer->rgsabound[0].cElements // this is programmed to 8 somewhere psaDataBuffer->rgsabound[1].cElements // this is programmed to 30 somewhere // For each field of the entry for(int outerindex=0; outerindex<30; outerindex++){ lDimension[0] = outerindex; for(int innerindex=0; innerindex<8; innerindex++){ lDimension[1] = innerindex SafeArrayPutElement(dataBuffer,lDimension, &data[outerindex][innerindex]) } } // variantReturn is the actuall return that I'm trying to get. Any ideas? Thanks, Kevin From patter001 at gmail.com Wed Aug 16 16:48:38 2006 From: patter001 at gmail.com (Kevin Patterson) Date: Wed, 16 Aug 2006 10:48:38 -0400 Subject: [python-win32] Need help with COM MSN Messenger Interface In-Reply-To: <44E42CFB.7000302@thinkingcactus.com> References: <44E2952B.7090706@thinkingcactus.com> <44E42CFB.7000302@thinkingcactus.com> Message-ID: I think the problem is just the MSN documentation...The pythoncom stuff is working as expected. To make things a little easier, I recommend using the MakePy in pythonwin. It will create a .py file that helps a small amount when trying to figure out what functions and such you need to call. I renamed the output file to msn.py and ran the following: import msn mapp = msn.Messenger() person = mapp.GetContact("someoe at emai.com",mapp.MyServiceId) imsg = b.InstanteMessage(person) No clue how to send a message from here...I recommend just googling on these function names and you'll end up seeing some VB code, but the same function calls usually work pretty similarly in python On 8/17/06, Indy LIU wrote: > Hi, > > Thank you for the reply. I think it comes down to my lack of knowledge > about using COM objects. > > C++ is my native programming language and I've done some python. But the > whole COM thing is totally new to me. Unfortunately, as you probably > have found out most PythonCom examples are about word, excel or outlook. > It's really hard to extend those examples to other COM objects when > there's no clear instruction but 'go to MSDN or use the COM Browser'. To > make matters worse the MSN API was poorly documented. For example the > only COM object that visibly starts my MSN Messenger Client is > 'Messenger.MessengerApp' but on the website it says 'not supported'. > > Can you just give me a simple example as to how I can invoke the > 'IMessenger' Interface and use a method such as 'GetContact'? I'm sure > it'll benefit the whole pythonwin/MSN community immensely.(After over 4 > hours search I'm 80% sure there's no tutorial about pythoncom and MSN > messenger. It's clearly a gap.) > > Cheers. > > Kevin Patterson wrote: > > Have you tried the MSDN help on this COM Module? Mmmmm...actually > > after looking through the docs, maybe its not a whole lot of help. I > > see a lot of "Not Currently Supported" statements. Well, here's the > > link anyway in case there's something there: > > > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winmessenger/winmessenger/reference/messengeruasdk/ifaces/imessenger/instantmessage.asp > > > > > > > > On 8/15/06, *Indy Liu* > > wrote: > > > > I need to write a plug-in for MSN Messenger in python. All it does is > > analyze a new message string and does some string ops on it. Can some > > body please give me some tips as to how I achieve this with win32com? > > > > I managed to obtain the messenger API type library as follows, and > > just > > don't know what to do from here. > > " > > >>> MSN = > > gencache.EnsureModule('{E02AD29E-80F5-46c6-B416-9B3EBDDF057E}', 0, > > 1, 0) > > >>> dir(MSN) > > ['CLSID', 'CLSIDToClassMap', 'CLSIDToPackageMap', 'CoClassBaseClass', > > 'DMessengerEvents', 'Dispatch', 'DispatchBaseClass', 'IID', > > 'IMessenger', 'IMessenger2', 'IMessenger2_vtables_', > > 'IMessenger2_vtables_dispatch_', 'IMessenger3', > > 'IMessenger3_vtables_', > > 'IMessenger3_vtables_dispatch_', 'IMessengerContact', > > 'IMessengerContact_vtables_', 'IMessengerContact_vtables_dispatch_', > > 'IMessengerContacts', 'IMessengerContacts_vtables_', > > 'IMessengerContacts_vtables_dispatch_', 'IMessengerConversationWnd', > > 'IMessengerConversationWnd_vtables_', > > 'IMessengerConversationWnd_vtables_dispatch_', 'IMessengerGroup', > > 'IMessengerGroup_vtables_', 'IMessengerGroup_vtables_dispatch_', > > 'IMessengerGroups', 'IMessengerGroups_vtables_', > > 'IMessengerGroups_vtables_dispatch_', 'IMessengerService', > > 'IMessengerService_vtables_', 'IMessengerService_vtables_dispatch_', > > 'IMessengerServices', 'IMessengerServices_vtables_', > > 'IMessengerServices_vtables_dispatch_', 'IMessengerWindow', > > 'IMessengerWindow_vtables_', 'IMessengerWindow_vtables_dispatch_', > > 'IMessenger_vtables_', 'IMessenger_vtables_dispatch_', 'LCID', > > 'LibraryFlags', 'MajorVersion', 'Messenger', 'MessengerNative', > > 'MinorVersion', 'NamesToIIDMap', 'RecordMap', 'VTablesToClassMap', > > 'VTablesToPackageMap', '__builtins__', '__doc__', '__file__', > > '__name__', '_in_gencache_', 'constants', 'defaultNamedNotOptArg', > > 'defaultNamedOptArg', 'defaultUnnamedArg', 'makepy_version', > > 'python_version', 'pythoncom', 'win32com'] > > " > > > > I don't want to use msnp.py since it requires the user to log in with > > msnp session manually as well as their MSN Messenger. I did hours of > > search online and the conclusion is posting & crying for help in this > > forum is really my best bet. > > > > Thanks. > > > > _______________________________________________ > > Python-win32 mailing list > > Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > From mhammond at skippinet.com.au Wed Aug 16 17:01:18 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 17 Aug 2006 01:01:18 +1000 Subject: [python-win32] Multithreaded Service In-Reply-To: <8C4B4388BC176244B5F36267D14B0BC9011FC3C9@exchange.wsdomain.lan> Message-ID: If your application works as expected before converting to a service, there should be no problem getting it working as a service. At the most basic level, your service's main thread can do nothing more than interact with the service control manager, and your application code should be able to run in its own thread, quite independent of the service interactions. The only minor complication will be to have the main service thread communicate service shutdown to your app code. Can you be more specific about what problems you are having? Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Christopher A. Nethery Sent: Wednesday, 16 August 2006 9:11 AM To: python-win32 at python.org Subject: [python-win32] Multithreaded Service I am new to this group, but I'm hoping someone could offer some advice as to a complicated issue I am having. I have created a (multithreaded) Python application that performs asynchronous queries. Unfortunately, I'm having a very difficult time setting it up as a service. It should run as follows: 1) A remote server starts the service 2) while the service is running, it performs its asynchronous lookups--something like: while 1: ASYNCH_QUERY() time.sleep(30) else: sys.exit() I have taken a look at the pipeTestServiceClient.py and pipeTestService.py examples from win32all build 209, but I couldn't figure out how to adapt it to my own code, since nothing needs to be echoed back to the "invoking" server. Does anyone have any ideas? Thanking you in advance, CAN -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060817/8be014d8/attachment.html From mhammond at skippinet.com.au Wed Aug 16 17:01:27 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 17 Aug 2006 01:01:27 +1000 Subject: [python-win32] Variant ByRef 2D array returned as 1D array In-Reply-To: Message-ID: > I'm working with a COM module that is returning a 2D array as a > VARIANT BYREF. The 2D array is 30x8 (with each entry being 1 byte) > When the data is returned I'm getting a buffer of length 30. This > tells me that win32com only sees 1D of the array (documentation states > that the buffer is expected for variants-byref with entries of 1 > byte). Any ideas on why win32com doesn't see that there is really an > array of arrays? If the type of one dimension is VT_UI8, then pythoncom will treat that as a 'byte buffer', so will return a string - in which case you will simply need to pretend the string is actually an array of bytes! Otherwise you are probably going to need to help create a test case so I can see exactly what is going on - what language is this object implemented in, and is the source available? We have test COM objects written in VB and C, so creating a test case shouldn't be too hard. Cheers, Mark From patter001 at gmail.com Wed Aug 16 18:17:21 2006 From: patter001 at gmail.com (Kevin Patterson) Date: Wed, 16 Aug 2006 12:17:21 -0400 Subject: [python-win32] Variant ByRef 2D array returned as 1D array In-Reply-To: References: Message-ID: win32com is definitely treating it as a string (or byte buffer), but I would have expected to get a byte buffer with the data for ALL the elements. For example the array being returned should be 30x8 array, but i get a string with a length of 30 instead of a string of length 30*8. Does the pythoncom know to traverse both arrays and convert in to one big buffer? Seems like I'm getting only the first element of each entry in the 30x8 array. Juduging from your statement I think the fact that its a buffer (instead of a 2D list) is ok, but I should be getting a buffer of lenghth = 30x8 instead of just 30. Thanks for the offer of help, I'll fight some guys on my end to reduce the code down and see what I get :) The problem occurs both on the read and write. In other words: I can't seem to write a 2D array back in to the COM module by refrence either, so hopefully the writers of the COM can also tell me what data they are getting versus what they are expecting to help pinpoint the problem. On 8/16/06, Mark Hammond wrote: > > I'm working with a COM module that is returning a 2D array as a > > VARIANT BYREF. The 2D array is 30x8 (with each entry being 1 byte) > > When the data is returned I'm getting a buffer of length 30. This > > tells me that win32com only sees 1D of the array (documentation states > > that the buffer is expected for variants-byref with entries of 1 > > byte). Any ideas on why win32com doesn't see that there is really an > > array of arrays? > > If the type of one dimension is VT_UI8, then pythoncom will treat that as a > 'byte buffer', so will return a string - in which case you will simply need > to pretend the string is actually an array of bytes! Otherwise you are > probably going to need to help create a test case so I can see exactly what > is going on - what language is this object implemented in, and is the source > available? We have test COM objects written in VB and C, so creating a test > case shouldn't be too hard. > > Cheers, > > Mark > > From frauenberger at dcs.qmul.ac.uk Thu Aug 17 17:12:13 2006 From: frauenberger at dcs.qmul.ac.uk (Christopher Frauenberger) Date: Thu, 17 Aug 2006 16:12:13 +0100 Subject: [python-win32] python and rtf Message-ID: Hi, since python 2.3.4 and wxPython 0.6 it was possible to render rtf in wxTextCtr like class RTFWindow(wx.TextCtrl): def __init__ (self,parent): wx.TextCtrl.__init__(self,parent,style = wx.TE_MULTILINE | wx.TE_RICH | wx.TE_READONLY) ... win = RTFWindow(None) win.rtfSubWin.LoadFile(path) and it would render RTF correctly. However, since then, I only get the source of the RTF as plain text... any ideas why this is? Is there any way to easily convert the RTF into HTML in python? Then I could use wx.HTML... thanks for advice Chris From kc106_2005-pywin32 at yahoo.com Thu Aug 17 20:12:23 2006 From: kc106_2005-pywin32 at yahoo.com (kc106_2005-pywin32 at yahoo.com) Date: Thu, 17 Aug 2006 11:12:23 -0700 (PDT) Subject: [python-win32] Excel corrupted display problem Message-ID: <20060817181223.50635.qmail@web51411.mail.yahoo.com> Hi list, I have a Python script that pops up Excel, fill it, and then continue. If the user clicks on my Python side to close Excel (via a call to the Quit() function), then I can reopen it later via another dispatch call and so forth. However, if the user close Excel from the Excel side, next time Python side starts Excel again, the Excel display area (the area where the spreadsheet cells goes) is screwed up. The rest of things works fine (like the menu bar and so forth) - but the spreadsheet display area is useless. Is there any cure to this? Thanks, -- John Henry From bgailer at alum.rpi.edu Fri Aug 18 01:36:30 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Thu, 17 Aug 2006 16:36:30 -0700 Subject: [python-win32] Excel corrupted display problem In-Reply-To: <20060817181223.50635.qmail@web51411.mail.yahoo.com> References: <20060817181223.50635.qmail@web51411.mail.yahoo.com> Message-ID: <44E4FD7E.4090202@alum.rpi.edu> kc106_2005-pywin32 at yahoo.com wrote: > Hi list, > > I have a Python script that pops up Excel, fill it, > and then continue. If the user clicks on my Python > side to close Excel (via a call to the Quit() > function), then I can reopen it later via another > dispatch call and so forth. > > However, if the user close Excel from the Excel side, > next time Python side starts Excel again, the Excel > display area (the area where the spreadsheet cells > goes) is screwed up. The rest of things works fine > (like the menu bar and so forth) - but the spreadsheet > display area is useless. > Is there any cure to this? > I have dealt with this a lot. The "cure" is somewhere in Redmond, but probably too low a priority for Microsoft. Sigh. The only workaround I know is to kill the excel process. -- Bob Gailer 510-978-4454 From bwmetz at att.com Fri Aug 18 02:51:42 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Thu, 17 Aug 2006 19:51:42 -0500 Subject: [python-win32] Excel corrupted display problem In-Reply-To: <44E4FD7E.4090202@alum.rpi.edu> Message-ID: <01D5341D04A2E64AB9B3457690473367024C1201@OCCLUST01EVS1.ugd.att.com> Interesting description. Sounds similar to a non-MS app I automate which does something similar. If closed from Python everything works fine; however, if user closes app before Python the next time it's launched it opens hidden and user can't see it at all. The only partial work around I've found is to use a certain routine in that app to detect the condition and enum the toplevel windows to find and kill the pid of the hidden app. Sounds awfully similar. Is the Excel issue definitely a MS one I wonder...just thinking out loud. Bobby -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Bob Gailer Sent: Thursday, August 17, 2006 4:37 PM To: kc106_2005-pywin32 at yahoo.com Cc: python-win32 at python.org Subject: Re: [python-win32] Excel corrupted display problem kc106_2005-pywin32 at yahoo.com wrote: > Hi list, > > I have a Python script that pops up Excel, fill it, > and then continue. If the user clicks on my Python > side to close Excel (via a call to the Quit() > function), then I can reopen it later via another > dispatch call and so forth. > > However, if the user close Excel from the Excel side, > next time Python side starts Excel again, the Excel > display area (the area where the spreadsheet cells > goes) is screwed up. The rest of things works fine > (like the menu bar and so forth) - but the spreadsheet > display area is useless. > Is there any cure to this? > I have dealt with this a lot. The "cure" is somewhere in Redmond, but probably too low a priority for Microsoft. Sigh. The only workaround I know is to kill the excel process. -- Bob Gailer 510-978-4454 _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Fri Aug 18 18:28:38 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 19 Aug 2006 02:28:38 +1000 Subject: [python-win32] python and rtf In-Reply-To: Message-ID: You may be better off trying the various wx mailing lists - not many wx people hang out here (I guess as most wx users are targetting more than Windows!) Regards, Mark > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of Christopher > Frauenberger > Sent: Friday, 18 August 2006 1:12 AM > To: python-win32 at python.org > Subject: [python-win32] python and rtf > > > Hi, > > since python 2.3.4 and wxPython 0.6 it was possible to render rtf in > wxTextCtr like > > class RTFWindow(wx.TextCtrl): > > def __init__ (self,parent): > wx.TextCtrl.__init__(self,parent,style = wx.TE_MULTILINE | > wx.TE_RICH | wx.TE_READONLY) > > ... > win = RTFWindow(None) > win.rtfSubWin.LoadFile(path) > > and it would render RTF correctly. > > However, since then, I only get the source of the RTF as plain > text... any ideas why this is? > > Is there any way to easily convert the RTF into HTML in python? Then > I could use wx.HTML... > > thanks for advice > Chris > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From rays at blue-cove.com Fri Aug 18 19:22:16 2006 From: rays at blue-cove.com (Ray Schumacher) Date: Fri, 18 Aug 2006 10:22:16 -0700 Subject: [python-win32] python and rtf In-Reply-To: References: Message-ID: <6.2.3.4.2.20060818102152.07ef0298@blue-cove.com> I think the problem is that there is not a lexer for RTF in the TextCtrl family. But: For wx 2.7... http://www.wxwidgets.org/wiki/index.php/Development:_wxRichTextEditor http://wiki.wxwidgets.org/docbrowse.cgi/wxwin_wxrichtextctrl.html I think you can use this for now: http://www.anthemion.co.uk/wxwin/ Best, Ray Schumacher At 09:28 AM 8/18/2006, you wrote: >You may be better off trying the various wx mailing lists - not many wx >people hang out here (I guess as most wx users are targetting more than >Windows!) > >Regards, > >Mark > >> -----Original Message----- >> From: python-win32-bounces at python.org >> [mailto:python-win32-bounces at python.org]On Behalf Of Christopher >> Frauenberger >> Sent: Friday, 18 August 2006 1:12 AM >> To: python-win32 at python.org >> Subject: [python-win32] python and rtf >> >> >> Hi, >> >> since python 2.3.4 and wxPython 0.6 it was possible to render rtf in >> wxTextCtr like >> >> class RTFWindow(wx.TextCtrl): >> >> def __init__ (self,parent): >> wx.TextCtrl.__init__(self,parent,style = wx.TE_MULTILINE | >> wx.TE_RICH | wx.TE_READONLY) >> >> ... >> win = RTFWindow(None) >> win.rtfSubWin.LoadFile(path) >> >> and it would render RTF correctly. >> >> However, since then, I only get the source of the RTF as plain >> text... any ideas why this is? >> >> Is there any way to easily convert the RTF into HTML in python? Then >> I could use wx.HTML... >> >> thanks for advice >> Chris >> >> _______________________________________________ >> Python-win32 mailing list >> Python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 From igowhari at gmail.com Fri Aug 18 20:50:54 2006 From: igowhari at gmail.com (iman gowhari) Date: Fri, 18 Aug 2006 22:20:54 +0330 Subject: [python-win32] FrontPage COM Object Events Message-ID: <14aabe70608181150v2723aef1v76278ffdda41aebc@mail.gmail.com> # Hi # I want to get events of FrontPage Web and Page object models with this code. # OnPageNew and OnActivate works properly but when I click on the page nothing happen. # I know that I want to get events of two different COM objects. # But I don't know how can I do that. # (I run this when FrontPage is active. Then I create a new page.) # Thanks from win32com.client import DispatchWithEvents import time, pythoncom, msvcrt, types class FrontPageEvents: def __init__(self): print 'FrontPageEvents' def OnPageNew(self, page): global t1, t2 t1=DispatchWithEvents(page, PageExEvents) t2=DispatchWithEvents(fp.ActiveDocument, PageEvents) print fp.ActiveDocument class PageExEvents: def __init__(self): print 'PageExEvents' def OnActivate(self): print 'OnActivate' class PageEvents: def __init__(self): print 'PageEvents' def onclick(self): print 'onclick' t1=None t2=None fp=DispatchWithEvents("FrontPage.Application", FrontPageEvents) while not msvcrt.kbhit(): pythoncom.PumpWaitingMessages() time.sleep(.2) msvcrt.getch() -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060818/01fc8fab/attachment.htm From rwupole at msn.com Mon Aug 21 12:47:56 2006 From: rwupole at msn.com (Roger Upole) Date: Mon, 21 Aug 2006 06:47:56 -0400 Subject: [python-win32] Re: Excel corrupted display problem Message-ID: John Henry wrote: > Hi list, > > I have a Python script that pops up Excel, fill it, > and then continue. If the user clicks on my Python > side to close Excel (via a call to the Quit() > function), then I can reopen it later via another > dispatch call and so forth. > > However, if the user close Excel from the Excel side, > next time Python side starts Excel again, the Excel > display area (the area where the spreadsheet cells > goes) is screwed up. The rest of things works fine > (like the menu bar and so forth) - but the spreadsheet > display area is useless. > > Is there any cure to this? > > Thanks, > > -- > John Henry You might be able to use win32com.client.DispatchEx to start Excel. This should make sure you always get a new Excel process, rather than returning a reference to the one that the user closed. Roger From mc at mclaveau.com Mon Aug 21 22:06:21 2006 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 21 Aug 2006 22:06:21 +0200 Subject: [python-win32] attribut de classe References: Message-ID: <000001c6c55d$48256b00$0701a8c0@PORTABLES> Hi! *sorry for my bad english* A COM server, in PyWin32, is a class. When this class has a "attribut de class" (sorry it's in french ; english = attr of class?) , and if this attr of class is also in the _public_attrs_ list, it is changed, like a attr of instance. If I open twice the COM server, in the same application, when the first instance change the attr of class, the change is not visible from the second instance. Am I correct, or am I fail? @-salutations Michel Claveau From mc at mclaveau.com Mon Aug 21 22:23:30 2006 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 21 Aug 2006 22:23:30 +0200 Subject: [python-win32] smart : __del__ replace atexit References: Message-ID: <000701c6c55f$acd12330$0701a8c0@PORTABLES> Hi! A little stunt : in COM server (with pywin32), atexit is not interesting. Then, look, in the class-serverCOM, the method __del__(self): When you close the COM-server, or when you exit the application who called the COM-server, the method is called. And... "le tour est jou?" (french sentence) @-salutations Michel Claveau From mhammond at skippinet.com.au Tue Aug 22 09:08:33 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 22 Aug 2006 17:08:33 +1000 Subject: [python-win32] smart : __del__ replace atexit In-Reply-To: <000701c6c55f$acd12330$0701a8c0@PORTABLES> Message-ID: <02ad01c6c5b9$c84933a0$2f0a0a0a@enfoldsystems.local> > A little stunt : in COM server (with pywin32), atexit is not > interesting. Yeah, Python is never 'finalized' when it is loaded for use by a COM object. > Then, look, in the class-serverCOM, the method __del__(self): > When you close the COM-server, or when you exit the > application who called > the COM-server, the method is called. This should be reliable - assuming that the program *using* the COM object always destroys the COM object correctly. However, it would be possible to write a Python program that used the COM object that did *not* cleanup the object, so would not cause this method to be executed... Mark From mhammond at skippinet.com.au Tue Aug 22 09:14:29 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 22 Aug 2006 17:14:29 +1000 Subject: [python-win32] attribut de classe In-Reply-To: <000001c6c55d$48256b00$0701a8c0@PORTABLES> Message-ID: <02b001c6c5ba$9c7e9c50$2f0a0a0a@enfoldsystems.local> > If I open twice the COM server, in the same application, when > the first > instance change the attr of class, the change is not visible > from the second > instance. When a COM attribute is set, Python does the equivalent of: setattr(instance, 'attr', 'value') So - even if you have: class Foo: attr = 'original value' If 'Foo' was a COM object, it is equivalent to: f1 = Foo() f2 = Foo() setattr(f1, 'attr', 'new value') The way Python works, this means that 'f1' now has an *instance* attribute 'attr' - the setattr() did *not* change the class attribute - so 'f2' will still return 'original value' when queried for that attribute. Hope this helps, Mark > > Am I correct, or am I fail? > > @-salutations > > Michel Claveau > > > > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From Tim.Gallagher at gd-ais.com Tue Aug 22 18:38:34 2006 From: Tim.Gallagher at gd-ais.com (Gallagher, Tim (NE)) Date: Tue, 22 Aug 2006 12:38:34 -0400 Subject: [python-win32] New to Python from Perl Message-ID: <794CB73454A59D488ED061055AA282073CBBB9@miaa01-mail01.ad.gd-ais.com> Hey all I am learning Python and having a fun time doing so. I have a question for y'all, it has to do with active directory. I want to get the last login for a computer from Active Directory. I am using the active_directory module and here is my code. [START] import active_directory computer = active_directory.root() for cpu in computer.search ("cn='Computer_Name'"): print cpu.samAccountName ?--- Works find print cpu.operatingSystem ?--- Works find print cpu.lastLogon ?--- Getting Error [END] I get an error that I am not sure what to do with, the error is TypeError: coercing to Unicode: need string or buffer, instance found in my line Do I have to change the output to meet Unicode formation? -T ? From torerik81 at gmail.com Wed Aug 23 20:24:40 2006 From: torerik81 at gmail.com (=?ISO-8859-1?Q?Tor_Erik_S=F8nvisen?=) Date: Wed, 23 Aug 2006 20:24:40 +0200 Subject: [python-win32] running windows 'start' cmd using spawnl Message-ID: <44EC9D68.3040306@gmail.com> Hi, I need to start a program in a new cmd-window. To do this I need to execute: start [command] With os.system this is straight-forward. But I need to do it with spawnl and P_NOWAIT. I.e, asynchronously. The problem is that I need to know the path where start resides, which I'm unable to find. Does anyone know where this command is located, or an alternative way of doing what I want? regards tores From bwmetz at att.com Wed Aug 23 21:41:24 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Wed, 23 Aug 2006 14:41:24 -0500 Subject: [python-win32] running windows 'start' cmd using spawnl In-Reply-To: <44EC9D68.3040306@gmail.com> Message-ID: <01D5341D04A2E64AB9B345769047336702537627@OCCLUST01EVS1.ugd.att.com> There is no path to start, it's a built-in shell cmd. If you want to start it asynchronously just use start's background method. os.system("start /B command") I use this all the time to launch things in the background and continue on my merry way. Bobby -----Original Message----- From: python-win32-bounces+bwmetz=att.com at python.org [mailto:python-win32-bounces+bwmetz=att.com at python.org]On Behalf Of Tor Erik S?nvisen Sent: Wednesday, August 23, 2006 11:25 AM To: python-win32 at python.org Subject: [python-win32] running windows 'start' cmd using spawnl Hi, I need to start a program in a new cmd-window. To do this I need to execute: start [command] With os.system this is straight-forward. But I need to do it with spawnl and P_NOWAIT. I.e, asynchronously. The problem is that I need to know the path where start resides, which I'm unable to find. Does anyone know where this command is located, or an alternative way of doing what I want? regards tores _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From rwupole at msn.com Thu Aug 24 04:46:59 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 23 Aug 2006 22:46:59 -0400 Subject: [python-win32] Re: New to Python from Perl Message-ID: > Hey all I am learning Python and having a fun time doing so. I have a question for y'all, it has to do with active directory. > > I want to get the last login for a computer from Active Directory. I am using the active_directory module and here is my > code. > > [START] > > import active_directory > > computer = active_directory.root() > for cpu in computer.search ("cn='Computer_Name'"): > print cpu.samAccountName ?--- Works find > print cpu.operatingSystem ?--- Works find > print cpu.lastLogon ?--- Getting Error > > [END] > > > I get an error that I am not sure what to do with, the error is TypeError: coercing to Unicode: need string or buffer, > instance found in my line > Do I have to change the output to meet Unicode formation? > I get back an ADLargeInteger for this property, which actually represents a FILETIME. What does type(cpu.lastLogon) show? Roger From rwupole at msn.com Thu Aug 24 05:01:13 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 23 Aug 2006 23:01:13 -0400 Subject: [python-win32] Re: running windows 'start' cmd using spawnl Message-ID: > Hi, > > I need to start a program in a new cmd-window. To do this I need to > execute: start [command] > With os.system this is straight-forward. > But I need to do it with spawnl and P_NOWAIT. I.e, asynchronously. > The problem is that I need to know the path where start resides, > which I'm unable to find. > > Does anyone know where this command is located, or an alternative way of > doing what I want? > > regards tores os.startfile is async. You could also use win32api.ShellExecute directly (os.startfile call this function under the covers) or win32process.CreateProcess if you need more flexibility. Roger From rwupole at msn.com Thu Aug 24 05:23:58 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 23 Aug 2006 23:23:58 -0400 Subject: [python-win32] Re: FrontPage COM Object Events Message-ID: ># Hi > # I want to get events of FrontPage Web and Page object models with this > code. > # OnPageNew and OnActivate works properly but when I click on the page > nothing happen. > # I know that I want to get events of two different COM objects. > # But I don't know how can I do that. > # (I run this when FrontPage is active. Then I create a new page.) > # Thanks > > from win32com.client import DispatchWithEvents > import time, pythoncom, msvcrt, types > > class FrontPageEvents: > def __init__(self): > print 'FrontPageEvents' > def OnPageNew(self, page): > global t1, t2 > t1=DispatchWithEvents(page, PageExEvents) > t2=DispatchWithEvents(fp.ActiveDocument, PageEvents) > print fp.ActiveDocument > > class PageExEvents: > def __init__(self): > print 'PageExEvents' > def OnActivate(self): > print 'OnActivate' > > class PageEvents: > def __init__(self): > print 'PageEvents' > def onclick(self): > print 'onclick' > > t1=None > t2=None > fp=DispatchWithEvents("FrontPage.Application", FrontPageEvents) > > while not msvcrt.kbhit(): > pythoncom.PumpWaitingMessages() > time.sleep(.2) > msvcrt.getch() > Check the case of the onclick event. The method names are case-sensistive. Roger From Jim.Vickroy at noaa.gov Thu Aug 24 18:50:26 2006 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu, 24 Aug 2006 10:50:26 -0600 Subject: [python-win32] ADO memory leak? In-Reply-To: <42C7E766869C42408F0360B7BF0CBD9B014B615C@pnlmse27.pnl.gov> References: <42C7E766869C42408F0360B7BF0CBD9B014B615C@pnlmse27.pnl.gov> Message-ID: <44EDD8D2.2040701@noaa.gov> I have a "fairly" simple test script that appears to exhibit a memory leak when using ADO to insert rows in a SQL Server database via a persistent connection. Memory requirements monotonically increase with time (apparently in 4k increments). I'm using python 2.4.1, win32com (pywin32 build 209), and MS Windows XP with all current updates. Has anyone else seen this behavior? Any thoughts about where the problem may be? Thanks, -- jv P.S. Earlier tests showed that: * simply maintaining a persistent connection (for 24 hours) is not the cause * maintaining an active connection and the insert command object are not the cause -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060824/c9a91b8f/attachment.html From timr at probo.com Thu Aug 24 20:28:16 2006 From: timr at probo.com (Tim Roberts) Date: Thu, 24 Aug 2006 11:28:16 -0700 Subject: [python-win32] ADO memory leak? In-Reply-To: <44EDD8D2.2040701@noaa.gov> References: <42C7E766869C42408F0360B7BF0CBD9B014B615C@pnlmse27.pnl.gov> <44EDD8D2.2040701@noaa.gov> Message-ID: <44EDEFC0.4050204@probo.com> Jim Vickroy wrote: > I have a "fairly" simple test script that appears to exhibit a memory > leak when using ADO to insert rows in a SQL Server database via a > persistent connection. > > Memory requirements monotonically increase with time (apparently in 4k > increments). > > I'm using python 2.4.1, win32com (pywin32 build 209), and MS Windows > XP with all current updates. > > Has anyone else seen this behavior? > > Any thoughts about where the problem may be? There are a large number of Google hits for "ado memory leak". Few of them will probably help you, but they might provide some clues. One good suggestion is to use a tool like PerfMon to monitor your memory use in a more detailed way; Task Manager sometimes takes shortcuts such that the memory use isn't really what it says it is. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Jim.Vickroy at noaa.gov Thu Aug 24 22:03:18 2006 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu, 24 Aug 2006 14:03:18 -0600 Subject: [python-win32] ADO memory leak? In-Reply-To: <44EDEFC0.4050204@probo.com> References: <42C7E766869C42408F0360B7BF0CBD9B014B615C@pnlmse27.pnl.gov> <44EDD8D2.2040701@noaa.gov> <44EDEFC0.4050204@probo.com> Message-ID: <44EE0606.3060907@noaa.gov> Tim Roberts wrote: >Jim Vickroy wrote: > > > >>I have a "fairly" simple test script that appears to exhibit a memory >>leak when using ADO to insert rows in a SQL Server database via a >>persistent connection. >> >>Memory requirements monotonically increase with time (apparently in 4k >>increments). >> >>I'm using python 2.4.1, win32com (pywin32 build 209), and MS Windows >>XP with all current updates. >> >>Has anyone else seen this behavior? >> >>Any thoughts about where the problem may be? >> >> > > >There are a large number of Google hits for "ado memory leak". Few of >them will probably help you, but they might provide some clues. > >One good suggestion is to use a tool like PerfMon to monitor your memory >use in a more detailed way; Task Manager sometimes takes shortcuts such >that the memory use isn't really what it says it is. > > > Thanks Tim. Prior to posting, I did try Google (should have mentioned that) and found a fair amount of anecdotal postings but nothing as concrete as I had hoped for. Perhaps I should give it another try though; I may have missed something. I did not think to try PerfMon so I will give that a look as I am not familiar with it. Despite any shortcuts Task Manager employs, there clearly is a memory leak that is significant over a period of days and the memory requirement of the application steadily increases. -- jv -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060824/62cf0314/attachment.htm From rwupole at msn.com Thu Aug 24 23:31:10 2006 From: rwupole at msn.com (Roger Upole) Date: Thu, 24 Aug 2006 17:31:10 -0400 Subject: [python-win32] Re: ADO memory leak? Message-ID: Jim Vickroy wrote: >I have a "fairly" simple test script that appears to exhibit a memory > leak when using ADO to insert rows in a SQL Server database via a > persistent connection. > > Memory requirements monotonically increase with time (apparently in 4k > increments). > > I'm using python 2.4.1, win32com (pywin32 build 209), and MS Windows XP > with all current updates. > > Has anyone else seen this behavior? > > Any thoughts about where the problem may be? > > Thanks, > -- jv > > P.S. > Earlier tests showed that: > > * simply maintaining a persistent connection (for 24 hours) is not > the cause > * maintaining an active connection and the insert command object are > not the cause > Does the script print anything, and are you running from pythonwin or python.exe ? Pythonwin accumulates output indefinitely, whereas python.exe eventually starts discarding it once you exceed the output buffer size of the console window. Could you post the script that demonstrates the problem ? I'll try to set it up to run for a while in debug mode to see if any problems show up with python refcounts or COM interface refcounts. Roger From guillaume.dauguet at mpsa.com Fri Aug 25 09:17:20 2006 From: guillaume.dauguet at mpsa.com (guillaume.dauguet at mpsa.com) Date: Fri, 25 Aug 2006 09:17:20 +0200 Subject: [python-win32] Problem with python-win32 Message-ID: Hi, I'm an engineer from France and I use PythonWin very often. I Have one question please : I'd like to run a function from a library included in the "Tools=>COM Browser=>Registered Type Librairies" menu. This library is called "Bibioth?que de pilotage de Scandiag" and I'd like to run from this library the function called "Telechargement" from "ISScandiagOCX". Just below is the source code in Visual basic just as an example so that you can get more easily what I try to explain you : Private Sub CommandButton1_Click() Dim MonObjet As ScandiagOCX Dim result As Integer Set MonObjet = New ScandiagOCX result = MonObjet.Telechargement("C:\Scandiag\Files\edc16.can", 1, 1, 1) Set MonObjet = Nothing End Sub Actually, I'd like to do the same in python. I tried already : import win32com.client ob = win32com.client.Dispatch("The.ProgID") ob.Telechargement() But actually, I don't know which arguments I need to use with the dispatch command. Therefore, what I want you to explain me please is how to determine the "Prog ID". Is it a number, a string?? Thanks a lot in advance for your help, Guillaume DAUGUET PSA - La Garenne-Colombes DPTA/DPMO/CCEE/MPVI/SVLG T?l : (+33) 1.56.47.33.90 Fax : (+33) 1.56.47.30.74 E-mail : guillaume.dauguet at mpsa.com From johan.lindvall at gmail.com Fri Aug 25 10:18:20 2006 From: johan.lindvall at gmail.com (Johan Lindvall) Date: Fri, 25 Aug 2006 10:18:20 +0200 Subject: [python-win32] Memory Consumption when running Python COM Script Message-ID: Hi, We are having performance problems when running python COM Scripts. The app starts it own internal scripting engine and if we use VBScript, everything is fine. If we use PythonScript, the app consumes large amounts of memory (up to 3 GB) and the crashes because it runs out of memory. This is the (simplified) PythonScript: ===================================== counter = 0 for AnObject in OurApp.Array(): counter = counter + AnObject.Value() ===================================== The corresponding VBScript: ===================================== for each AnObject in OurApp.Array() counter = counter + AnObject.Value() next ===================================== This is the (simplified) C++ COM Code: ===================================== VARIANT COurApp::Array() { HRESULT hr; SAFEARRAY * pSa; pSa = SafeArrayCreateVector(VT_VARIANT, 0, 100000); LPVARIANT psadata = NULL; hr = SafeArrayAccessData(pSa, (void**)&psadata); if (FAILED(hr)) { SafeArrayDestroy(pSa); } LPDISPATCH t = GetIDispatch(FALSE); for (unsigned i = 0; i < 100000; ++i) { psadata[i].pdispVal = t; psadata[i].vt = VT_DISPATCH; t->AddRef(); } hr = SafeArrayUnaccessData(pSa); if (FAILED(hr)) { SafeArrayDestroy(pSa); } VARIANT rgvar; VariantInit(&rgvar); V_VT(&rgvar) = VT_ARRAY|VT_VARIANT; V_ARRAY(&rgvar) = pSa; return rgvar; } float COurObject::Value() { return rand(); } ========================================== The returned Array can in some cases be very large. For this example, VBScript uses 1,5 Megs and Python uses about 500 Megs of RAM. I have set breakpoint on malloc and free in the runtime library and have observed that Python calls these functions frequently, which I suspect is part of the problem. What can we do to optimise our application / script? Any hints / pointers are much appreciated. Thanks. -- /Johan. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060825/536b08ba/attachment.html From johan.lindvall at gmail.com Fri Aug 25 12:12:00 2006 From: johan.lindvall at gmail.com (Johan Lindvall) Date: Fri, 25 Aug 2006 12:12:00 +0200 Subject: [python-win32] Unexpected exception in gateway method 'AddTypeLib' with own Active Script Host Message-ID: Hi, We are sometimes getting the error below when running a Python script in our app. We are calling AddTypeLib on the IActiveScript interface. It always works with VB-scripts and sometimes fails with Python. What could be the problem? =============================================== pythoncom error: Unexpected exception in gateway method 'AddTypeLib' Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 332, in *InvokeEx* return self.*invokeex*(dispid, lcid, wFlags, args, kwargs, serviceProvider) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 588, in *invokeex* return func(*args) File "C:\Python24\Lib\site-packages\win32comext\axscript\client\framework.py", line 688, in AddTypeLib gencache.EnsureModule(uuid, self.lcid, major, minor, bForDemand = 1) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 520, in EnsureModule module = MakeModuleForTypelib(typelibCLSID, lcid, major, minor, progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 290, in MakeModuleForTypelib return GetModuleForTypelib(typelibCLSID, lcid, major, minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 258, in GetModuleForTypelib mod = _GetModule(modName) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 629, in _GetModule mod = _*import*_(mod_name) exceptions.ImportError: No module named E6F09C5E-5E59-4AC2-B3DE-0A5554BDB9AEx2673x9x4 pythoncom error: Unexpected gateway error Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 332, in *InvokeEx* return self.*invokeex*(dispid, lcid, wFlags, args, kwargs, serviceProvider) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 588, in *invokeex* return func(*args) File "C:\Python24\Lib\site-packages\win32comext\axscript\client\framework.py", line 688, in AddTypeLib gencache.EnsureModule(uuid, self.lcid, major, minor, bForDemand = 1) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 520, in EnsureModule module = MakeModuleForTypelib(typelibCLSID, lcid, major, minor, progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 290, in MakeModuleForTypelib return GetModuleForTypelib(typelibCLSID, lcid, major, minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 258, in GetModuleForTypelib mod = _GetModule(modName) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 629, in _GetModule mod = _*import*_(mod_name) exceptions.ImportError: No module named E6F09C5E-5E59-4AC2-B3DE-0A5554BDB9AEx2673x9x4 ===================================================== Thanks -- /Johan. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060825/ffb1a7be/attachment.htm From Jim.Vickroy at noaa.gov Fri Aug 25 17:43:13 2006 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri, 25 Aug 2006 09:43:13 -0600 Subject: [python-win32] ADO memory leak? In-Reply-To: References: Message-ID: <44EF1A91.4030107@noaa.gov> Roger, Attached are 2 scripts (ado-mem-test-04.py, ado-mem-test-05.py) for testing possible ADO memory leak problems. ado-mem-test-04.py appears to exhibit a steady increase in memory requirements with time; ado-mem-test-05.py does not appear to exhibit this behavior. The primary difference between the two scripts is that -04 changes its insert value each time via a prepared statement parameter while -05 simply uses the database table column default value (NULL) for each insert. I apologize for the length (~65 lines) of each script. Thanks for taking a look at this. -- jv P.S. The scripts have always been run using python.exe rather than pythonwin, and my observations on memory usage come from the Windows Task Manager. Roger Upole wrote: >Jim Vickroy wrote: > > >>I have a "fairly" simple test script that appears to exhibit a memory >>leak when using ADO to insert rows in a SQL Server database via a >>persistent connection. >> >>Memory requirements monotonically increase with time (apparently in 4k >>increments). >> >>I'm using python 2.4.1, win32com (pywin32 build 209), and MS Windows XP >>with all current updates. >> >>Has anyone else seen this behavior? >> >>Any thoughts about where the problem may be? >> >>Thanks, >>-- jv >> >>P.S. >>Earlier tests showed that: >> >> * simply maintaining a persistent connection (for 24 hours) is not >> the cause >> * maintaining an active connection and the insert command object are >> not the cause >> >> >> > >Does the script print anything, and are you running from pythonwin or >python.exe ? Pythonwin accumulates output indefinitely, whereas >python.exe eventually starts discarding it once you exceed the output >buffer size of the console window. > >Could you post the script that demonstrates the problem ? >I'll try to set it up to run for a while in debug mode to see if >any problems show up with python refcounts or COM interface >refcounts. > > Roger > >_______________________________________________ >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: http://mail.python.org/pipermail/python-win32/attachments/20060825/8612c8e2/attachment.htm -------------- next part -------------- A non-text attachment was scrubbed... Name: ado-mem--test-05.py Type: application/x-python Size: 2944 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060825/8612c8e2/attachment.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: ado-mem--test-04.py Type: application/x-python Size: 3040 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060825/8612c8e2/attachment-0001.bin From Jim.Vickroy at noaa.gov Fri Aug 25 17:59:41 2006 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri, 25 Aug 2006 09:59:41 -0600 Subject: [python-win32] Problem with python-win32 In-Reply-To: References: Message-ID: <44EF1E6D.6040305@noaa.gov> guillaume.dauguet at mpsa.com wrote: > > >Hi, > >I'm an engineer from France and I use PythonWin very often. I Have one >question please : I'd like to run a function from a library included in the >"Tools=>COM Browser=>Registered Type Librairies" menu. This library is >called "Bibioth?que de pilotage de Scandiag" and I'd like to run from this >library the function called "Telechargement" from "ISScandiagOCX". >Just below is the source code in Visual basic just as an example so that >you can get more easily what I try to explain you : > >Private Sub CommandButton1_Click() >Dim MonObjet As ScandiagOCX >Dim result As Integer >Set MonObjet = New ScandiagOCX >result = MonObjet.Telechargement("C:\Scandiag\Files\edc16.can", 1, 1, 1) >Set MonObjet = Nothing >End Sub >Actually, I'd like to do the same in python. > >I tried already : > >import win32com.client >ob = win32com.client.Dispatch("The.ProgID") >ob.Telechargement() > >But actually, I don't know which arguments I need to use with the dispatch >command. >Therefore, what I want you to explain me please is how to determine the >"Prog ID". Is it a number, a string?? > > >Thanks a lot in advance for your help, > > >Guillaume DAUGUET >PSA - La Garenne-Colombes >DPTA/DPMO/CCEE/MPVI/SVLG >T?l : (+33) 1.56.47.33.90 >Fax : (+33) 1.56.47.30.74 >E-mail : guillaume.dauguet at mpsa.com > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > Hello Guillaume, I will tell you what I know (but I am not knowledgeable about this): The Dispatch parameter is most likely a string. For example: * Dispatch('Excel.Application') * Dispatch('InternetExplorer.Application') I have no advice to offer on determining what the string is for your particular application. -- jv -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060825/cdf10d05/attachment.html From rwupole at msn.com Fri Aug 25 18:39:31 2006 From: rwupole at msn.com (Roger Upole) Date: Fri, 25 Aug 2006 12:39:31 -0400 Subject: [python-win32] Re: ADO memory leak? Message-ID: Looks like there's a refcount leak in the date conversion somewhere. Distilled down some more, if you change the last few lines of the script to parameter = command.Parameters.Item('@%s' % column.Name) for x in xrange(10000): parameter.Value = datetime.datetime.now() the total refcount increases by ~100k every time you run it. Now that we know where it is, shouldn't be too difficult to fix it. I'll take a close look at the C++ date conversion code tomorrow. Roger From timr at probo.com Fri Aug 25 19:16:53 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 25 Aug 2006 10:16:53 -0700 Subject: [python-win32] Problem with python-win32 In-Reply-To: <44EF1E6D.6040305@noaa.gov> References: <44EF1E6D.6040305@noaa.gov> Message-ID: <44EF3085.1060507@probo.com> Jim Vickroy wrote: > guillaume.dauguet at mpsa.com wrote: > >> >>Hi, >> >>I'm an engineer from France and I use PythonWin very often. I Have one >>question please : I'd like to run a function from a library included in the >>"Tools=>COM Browser=>Registered Type Librairies" menu. This library is >>called "Bibioth?que de pilotage de Scandiag" and I'd like to run from this >>library the function called "Telechargement" from "ISScandiagOCX". >>Just below is the source code in Visual basic just as an example so that >>you can get more easily what I try to explain you : >> >>Private Sub CommandButton1_Click() >>Dim MonObjet As ScandiagOCX >>Dim result As Integer >>Set MonObjet = New ScandiagOCX >>result = MonObjet.Telechargement("C:\Scandiag\Files\edc16.can", 1, 1, 1) >>Set MonObjet = Nothing >>End Sub >>Actually, I'd like to do the same in python. >> >>I tried already : >> >>import win32com.client >>ob = win32com.client.Dispatch("The.ProgID") >>ob.Telechargement() >> >>But actually, I don't know which arguments I need to use with the dispatch >>command. >>Therefore, what I want you to explain me please is how to determine the >>"Prog ID". Is it a number, a string?? >> > Hello Guillaume, > > I will tell you what I know (but I am not knowledgeable about this): > > The Dispatch parameter is most likely a string. For example: > > * Dispatch('Excel.Application') > * Dispatch('InternetExplorer.Application') > > I have no advice to offer on determining what the string is for your > particular application. You can see this in the VB application. import win32com.client ob = win32com.client.Dispatch( "ScandiagOCX" ) ob.Telechargement( ... ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mc at mclaveau.com Fri Aug 25 20:33:00 2006 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 25 Aug 2006 20:33:00 +0200 Subject: [python-win32] Problem with python-win32 References: <44EF1E6D.6040305@noaa.gov> Message-ID: <000b01c6c874$e6a01450$0701a8c0@PORTABLES> Bonjour ! Le ProgID est une cha?ne de caract?res. A chaque ProgID est associ? un CLSID (cha?ne de chiffres et lettres entre accolades). Perso, je trouve les ProgID avec Regedit, dans HKEY_CLASSES_ROOT\CLSID\...\ProgID (o? ... est le CLSID) Le CLSID peut ?tre affich? avec VB (et sans doute aussi le ProgID). Sinon, il existe des utilitaires pour cela. Bon courage. @-salutations -- Michel Claveau From shahmed at sfwmd.gov Fri Aug 25 22:49:22 2006 From: shahmed at sfwmd.gov (Ahmed, Shakir) Date: Fri, 25 Aug 2006 16:49:22 -0400 Subject: [python-win32] Shape file field update problem Message-ID: <14A2A120D369B6469BB154B2D2DC34D2057B3ECE@EXCHVS01.ad.sfwmd.gov> HI, I generated this python script from Arc GIS Model, tried to run from python win but getting error. I am trying to update a text field from a date filed data. Any help is highly appreciated. ======================================================================== ==== add_field.py # Created on: Wed Aug 23 2006 04:57:34 PM # (generated by ArcGIS/ModelBuilder) # ------------------------------------------------------------------------ -- # Import system modules import sys, string, os, win32com.client # Create the Geoprocessor object gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1") # Load required toolboxes... gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx") #set a default workspace gp.workspace = "V:/data/tst/shp" # Calculating the fields to the date as a text field gp.calculatefield_management("br_er_primary.shp", "LEGAL_CDT", "[APP_NO]") #the above line works fine gp.calculatefield_management("br_er_primary.shp", "FINAL_CDT", "FORMAT([final_acti],'mm/dd/yyyy')") # this above line is not working getting the following error. ======================================================================== ==== The error I am getting is as follows: ------------------------------------------------------------------------ Traceback (most recent call last): File "V:\data\tst\add_field.py", line 31, in ? gp.calculatefield_management("br_er_primary.shp", "FINAL_CDT", "FORMAT([final_acti],'mm/dd/yyyy')") File "", line 2, in calculatefield_management com_error: (-2147467259, 'Unspecified error', None, None) ------------------------------------------------------------------------ - Thanks in advance. Shakir From gagsl-p32 at yahoo.com.ar Fri Aug 25 23:53:50 2006 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 25 Aug 2006 18:53:50 -0300 Subject: [python-win32] Shape file field update problem In-Reply-To: <14A2A120D369B6469BB154B2D2DC34D2057B3ECE@EXCHVS01.ad.sfwmd .gov> References: <14A2A120D369B6469BB154B2D2DC34D2057B3ECE@EXCHVS01.ad.sfwmd.gov> Message-ID: <7.0.1.0.0.20060825184252.04eaec60@yahoo.com.ar> At Friday 25/8/2006 17:49, Ahmed, Shakir wrote: >I generated this python script from Arc GIS Model, tried to run from >python win but getting error. I am trying to update a text field from a >date filed data. Any help is highly appreciated. > > ># Calculating the fields to the date as a text field >gp.calculatefield_management("br_er_primary.shp", "LEGAL_CDT", >"[APP_NO]") >#the above line works fine >gp.calculatefield_management("br_er_primary.shp", "FINAL_CDT", >"FORMAT([final_acti],'mm/dd/yyyy')") ># this above line is not working getting the following error. > > File "", line 2, in >calculatefield_management >com_error: (-2147467259, 'Unspecified error', None, None) Since the first call to calculatefield_management succeeds with the same argument types, I think this is not related to Python nor the Pythonwin wrapper. Check the docs for that function or contact the vendor. Gabriel Genellina Softlab SRL __________________________________________________ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas From mhammond at skippinet.com.au Sat Aug 26 09:10:07 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 26 Aug 2006 17:10:07 +1000 Subject: [python-win32] Unexpected exception in gateway method 'AddTypeLib'with own Active Script Host In-Reply-To: Message-ID: <05b701c6c8de$a9fec9a0$050a0a0a@enfoldsystems.local> Could you try executing win32com\client\makepy.py as a script (eg, from a cmd-prompt), then select the typelib from the list that will be displayed, and see if it works there? According to the traceback, win32com believes it successfully generated the file, but then failed to locate it. Mark. -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Johan Lindvall Sent: Friday, 25 August 2006 8:12 PM To: Python-win32 at python.org Subject: [python-win32] Unexpected exception in gateway method 'AddTypeLib'with own Active Script Host Hi, We are sometimes getting the error below when running a Python script in our app. We are calling AddTypeLib on the IActiveScript interface. It always works with VB-scripts and sometimes fails with Python. What could be the problem? =============================================== pythoncom error: Unexpected exception in gateway method 'AddTypeLib' Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 332, in InvokeEx return self.invokeex(dispid, lcid, wFlags, args, kwargs, serviceProvider) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 588, in invokeex return func(*args) File "C:\Python24\Lib\site-packages\win32comext\axscript\client\framework.py", line 688, in AddTypeLib gencache.EnsureModule(uuid, self.lcid, major, minor, bForDemand = 1) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 520, in EnsureModule module = MakeModuleForTypelib(typelibCLSID, lcid, major, minor, progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 290, in MakeModuleForTypelib return GetModuleForTypelib(typelibCLSID, lcid, major, minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 258, in GetModuleForTypelib mod = _GetModule(modName) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 629, in _GetModule mod = _import_(mod_name) exceptions.ImportError: No module named E6F09C5E-5E59-4AC2-B3DE-0A5554BDB9AEx2673x9x4 pythoncom error: Unexpected gateway error Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 332, in InvokeEx return self.invokeex(dispid, lcid, wFlags, args, kwargs, serviceProvider) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 588, in invokeex return func(*args) File "C:\Python24\Lib\site-packages\win32comext\axscript\client\framework.py", line 688, in AddTypeLib gencache.EnsureModule(uuid, self.lcid, major, minor, bForDemand = 1) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 520, in EnsureModule module = MakeModuleForTypelib(typelibCLSID, lcid, major, minor, progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 290, in MakeModuleForTypelib return GetModuleForTypelib(typelibCLSID, lcid, major, minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 258, in GetModuleForTypelib mod = _GetModule(modName) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 629, in _GetModule mod = _import_(mod_name) exceptions.ImportError: No module named E6F09C5E-5E59-4AC2-B3DE-0A5554BDB9AEx2673x9x4 ===================================================== Thanks -- /Johan. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060826/3c24659b/attachment.htm From mhammond at skippinet.com.au Sat Aug 26 10:11:31 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 26 Aug 2006 18:11:31 +1000 Subject: [python-win32] ADO memory leak? In-Reply-To: Message-ID: <05db01c6c8e7$3f516fa0$050a0a0a@enfoldsystems.local> > the total refcount increases by ~100k every time you run it. > Now that we know where it is, shouldn't be too difficult > to fix it. I'll take a close look at the C++ date conversion > code tomorrow. Thanks Roger! I've reproduced the leak in the test suite (there were no tests for a 'datatime package' object before :( and identified the leak. I may not check it in today though, but wanted to make sure you didn't spend any more time on it! Thanks, Mark From johan.lindvall at gmail.com Mon Aug 28 08:22:28 2006 From: johan.lindvall at gmail.com (Johan Lindvall) Date: Mon, 28 Aug 2006 08:22:28 +0200 Subject: [python-win32] Unexpected exception in gateway method 'AddTypeLib'with own Active Script Host In-Reply-To: <05b701c6c8de$a9fec9a0$050a0a0a@enfoldsystems.local> References: <05b701c6c8de$a9fec9a0$050a0a0a@enfoldsystems.local> Message-ID: On 8/26/06, Mark Hammond wrote: > > Could you try executing win32com\client\makepy.py as a script (eg, from a cmd-prompt), then select the typelib from the list that will be displayed, and see if it works there? According to the traceback, win32com believes it successfully generated the file, but then failed to locate it. Makepy.py works and generates code for the complete typelib (including all methods). The generated python file is placed in win32com\gen_py. By method code I mean code like this: def Exit(self): """Exits the application""" return self._oleobj_.InvokeTypes(58, LCID, 1, (24, 0), (),) With AddTypeLib, the partial code for the typelib is placed in a subdirectory of win32com\gen_py.With partial I mean that there is no code generated for the methods. If i delete the generated files and call AddTypeLib, it always fails. If I call it when there is generated typelib data available, it works. Thanks -- /Johan. From johan.lindvall at gmail.com Mon Aug 28 08:52:45 2006 From: johan.lindvall at gmail.com (Johan Lindvall) Date: Mon, 28 Aug 2006 08:52:45 +0200 Subject: [python-win32] Memory Consumption when running Python COM Script In-Reply-To: References: Message-ID: > I have set breakpoint on malloc and free in the runtime library and have > observed that Python calls these functions frequently, which I suspect is > part of the problem. I have investigated this further and found that python appears to compile the Value call for each loop iteration (dynamic.py, row 300). The compiled python objects are somehow kept during the lifetime of the script. Is this correct? Is is possible to use early binding (with the code generated from makepy) in a self-hosted python script? Thanks -- /Johan. From mhammond at skippinet.com.au Mon Aug 28 10:23:18 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 28 Aug 2006 18:23:18 +1000 Subject: [python-win32] Memory Consumption when running Python COM Script In-Reply-To: Message-ID: <0a0a01c6ca7b$37f921e0$050a0a0a@enfoldsystems.local> > I have investigated this further and found that python appears to > compile the Value call for each loop iteration (dynamic.py, row 300). > The compiled python objects are somehow kept during the lifetime of > the script. Is this correct? That is not expected. _make_method_ stores a copy of the method in self._builtMethods_ (line 309). A further __getattr__ for that name should locate it. You may have found a 'bug' (or maybe it should be called an un-optimization) when the default method name is used though - what is the callstack? > Is is possible to use early binding (with the code generated from > makepy) in a self-hosted python script? I'm not sure what you mean by 'self-hosted'. If you mean py2exe, then that tool supports a 'typelibs' attribute which can package and use makepy generated files. Google might help you there, but sadly the examples and docs are a little light at the moment. Mark From aeindor at FORSK.com Mon Aug 28 11:48:35 2006 From: aeindor at FORSK.com (Amir Ein Dor) Date: Mon, 28 Aug 2006 11:48:35 +0200 Subject: [python-win32] I do not manage to call methods in automated objects since InvokeTypes() fails Message-ID: Dear python-win32 volunteers (I resent this mail because before I was not a subscriber) I was hopping to manage to introduce python into our product, starting with testing utilities and then who knows ... But I am blocked with the following: I am trying to write a client application that uses our com server (automated) interface. Usually VB scripts or C++ programs provide these client applications. I use early binding by running makepy. I manage to access all propertied, yet do not manage to call methods. The InvokeTypes() fails: For example, if I call Obj.Item(7) I get: File "C:\Python24\lib\site-packages\win32com\gen_py\A9ADC630-3FE3-11D0-935B-0 00000000000x0x1x0.py", line 206, in Item ret = self._oleobj_.InvokeTypes(5, LCID, 2, (9, 0), ((3, 1),),iIdx) com_error: (-2147352562, 'Invalid number of parameters.', None, None) yet if I call y = Obj[7] I pass by the standard method _NewEnum() and I manage to get my object. def _NewEnum(self): iid = '{1DA961EB-FB92-484C-84F4-F39BA9370C86}' par = self._oleobj_.InvokeTypes(-4, LCID , 2, (13,10),()) return win32com.client.util.WrapEnum(par,iid) In this case, InvokeTypes() seems to succeed. Do you have any idea of what is wrong? I tried to switch from (9,0) (3,1) being a DISPATCH return value, to (13,0) being a IUNKNOWEN returen value ... but no good. I have very little time left now, if I don't solve this problem, I will have to do my tests in VB script (yack) Please help Thanks in advanced Amir Amir Ein-Dor Senior Engineer Tel: +33 (0)562 745 027 www.forsk.com PS an other information that may help: I tried to switch to late binding by removing the A9ADC630-3FE3-11D0-935B-000000000000x0x1x0.py File. In this case, the methode Item() was called, yet with my c++ Debugger I could see that the VARIANT variable had a VT_ERROR type. From johan.lindvall at gmail.com Mon Aug 28 11:52:50 2006 From: johan.lindvall at gmail.com (Johan Lindvall) Date: Mon, 28 Aug 2006 11:52:50 +0200 Subject: [python-win32] Memory Consumption when running Python COM Script In-Reply-To: <0a0a01c6ca7b$37f921e0$050a0a0a@enfoldsystems.local> References: <0a0a01c6ca7b$37f921e0$050a0a0a@enfoldsystems.local> Message-ID: > That is not expected. _make_method_ stores a copy of the method in > self._builtMethods_ (line 309). A further __getattr__ for that name should > locate it. You may have found a 'bug' (or maybe it should be called an > un-optimization) when the default method name is used though - what is the > callstack? I've set a breakpoint on PyParser_ParseStringFlagsFilename. It gets called for every iteration of the loop, with the same arguments. For each call, the process memory usage grows by 4-5 K. PyTokenizer_FromString PyParse_ParseStringFlagsFileName Py_CompileStringFlags builtin_compile PyCFunction_Call PyEval_EvalFrame PyEval_EvalCodeEx The arguments for PyParse_ParseStringFlagsFileName are: s = "def AttValue(self, Attribut=pythoncom.Missing):..return self._ApplyTypes_(1, 2, (12, 0),((9, 1),), 'AttValue', None, Attribut....)." filename = ">" This appears to come from line 300 in dynamic.py. > > Is is possible to use early binding (with the code generated from > > makepy) in a self-hosted python script? > > I'm not sure what you mean by 'self-hosted'. If you mean py2exe, then that > tool supports a 'typelibs' attribute which can package and use makepy > generated files. Google might help you there, but sadly the examples and > docs are a little light at the moment. I mean a self hosted script, running through an inproc ActiveScript python engine. This is related to the other question I have with AddTypeLib. The function doesn't seem to generate any python Code for the actual methods. I would like to use the complete typelib information (with method code) in a python script. I am not really sure how to debug the python com code. I have tried enabling the debug output in dynamic.py, but I am only getting incomplete information. -- /Johan. From johan.lindvall at gmail.com Mon Aug 28 12:23:10 2006 From: johan.lindvall at gmail.com (Johan Lindvall) Date: Mon, 28 Aug 2006 12:23:10 +0200 Subject: [python-win32] PythonScript, unloading the Python engine Message-ID: Hi, Is it possible to (forcibly) unload the python engine after executing a python script? I would like to have the Dlls unloaded after Release in the following code: #define WINVER 0x400 #define _WIN32_WINNT 0x400 #include #include #include int main(int argc, char* argv[]) { CoInitializeEx(0, COINIT_APARTMENTTHREADED); GUID clsid; HRESULT hr = CLSIDFromProgID( L"Python", &clsid ); IUnknown* tmp = 0; if (S_OK == hr) hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IActiveScript, (void **)&tmp); if (tmp) tmp->Release(); // python still loaded at this point? return 0; } Thanks -- /Johan. From mhammond at skippinet.com.au Mon Aug 28 14:17:06 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 28 Aug 2006 22:17:06 +1000 Subject: [python-win32] Memory Consumption when running Python COM Script In-Reply-To: Message-ID: <0a9001c6ca9b$e1442900$050a0a0a@enfoldsystems.local> > > That is not expected. _make_method_ stores a copy of the method in > > self._builtMethods_ (line 309). A further __getattr__ for > that name should > > locate it. You may have found a 'bug' (or maybe it should > be called an > > un-optimization) when the default method name is used > though - what is the > > callstack? > > I've set a breakpoint on PyParser_ParseStringFlagsFilename. It gets > called for every iteration of the loop, with the same arguments. For > each call, the process memory usage grows by 4-5 K. That's unfortunate. It may be something specific to the AXScript support, and I can't repro that using a 'normal' dynamic Dispatch object. I ran out of time to try and repro something similar with IE. > > > Is is possible to use early binding (with the code generated from > > > makepy) in a self-hosted python script? > > > > I'm not sure what you mean by 'self-hosted'. If you mean > py2exe, then that > > tool supports a 'typelibs' attribute which can package and > use makepy > > generated files. Google might help you there, but sadly > the examples and > > docs are a little light at the moment. > > I mean a self hosted script, running through an inproc ActiveScript > python engine. > > This is related to the other question I have with AddTypeLib. The > function doesn't seem to generate any python Code for the actual > methods. I would like to use the complete typelib information (with > method code) in a python script. The intent is that all wrapper objects will be generated "on demand", as the objects are referenced. Running 'makepy.py -d' does the same thing, as does the various 'bForDemand' params used internally. Mark From johan.lindvall at gmail.com Mon Aug 28 14:18:30 2006 From: johan.lindvall at gmail.com (Johan Lindvall) Date: Mon, 28 Aug 2006 14:18:30 +0200 Subject: [python-win32] Unexpected exception in gateway method 'AddTypeLib'with own Active Script Host In-Reply-To: <05b701c6c8de$a9fec9a0$050a0a0a@enfoldsystems.local> References: <05b701c6c8de$a9fec9a0$050a0a0a@enfoldsystems.local> Message-ID: The error was in our code. IActiveScriptSite::GetLCID returned garbage (even though we used the sample provided by Microsoft). Regards, -- /Johan. From mhammond at skippinet.com.au Mon Aug 28 14:25:34 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 28 Aug 2006 22:25:34 +1000 Subject: [python-win32] PythonScript, unloading the Python engine In-Reply-To: Message-ID: <0a9701c6ca9d$1032aab0$050a0a0a@enfoldsystems.local> > Hi, > > Is it possible to (forcibly) unload the python engine after executing > a python script? Nope - Python has no facility for unloading extension modules, which means that repeated Inits and Terms in the same process tends to be problematic - and as a result we don't finalize at all. We used to, but it didn't release anywhere near everything and the pain was worse than the gain. Mark From mhammond at skippinet.com.au Mon Aug 28 14:27:17 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 28 Aug 2006 22:27:17 +1000 Subject: [python-win32] I do not manage to call methods in automated objectssince InvokeTypes() fails In-Reply-To: Message-ID: <0a9a01c6ca9d$4d7f4360$050a0a0a@enfoldsystems.local> > I am trying to write a client application that uses our com server > (automated) interface. > Usually VB scripts or C++ programs provide these client applications. > I use early binding by running makepy. > I manage to access all propertied, yet do not manage to call methods. > The InvokeTypes() fails: > > For example, if I call > Obj.Item(7) > I get: Is it possible you are looking for SetItem()? Mark -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 1780 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060828/6cbbbcfd/attachment.bin From mcgooly at yahoo.com Mon Aug 28 15:55:26 2006 From: mcgooly at yahoo.com (Brad Posthumus) Date: Mon, 28 Aug 2006 06:55:26 -0700 (PDT) Subject: [python-win32] Shape file field update problem Message-ID: <20060828135526.4649.qmail@web50908.mail.yahoo.com> The CalculateField method uses VBScript, which does not support the FORMAT command. Try doing a search for "VBScript" and "FORMAT" to find an alternative method of formatting the date in a text field. As mentioned before this is not a Python issue. For future ArcGIS scripting questions, you will be better off posting to the ESRI forums: http://forums.esri.com/forums.asp?c=93. Brad Posthumus From richard-liao at 163.com Mon Aug 28 17:43:49 2006 From: richard-liao at 163.com (Richard Liao) Date: Mon, 28 Aug 2006 23:43:49 +0800 Subject: [python-win32] IE HTML DOM events Message-ID: <44F30F3A.033DF2.00726> Hi, I have a win32com application need to get IE HTML DOM events. I searched web for a few days, and I have found 4 methods to approach that. Sorry about this long text, because I want to give more hint. 1. method 1 #---------------------------------------------------------------------- # method 1 # Make an instant of DocEvents(subclass of HTMLDocumentEvents2) # It will take a long time(about tens of seconds) to generate / compile # 3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py in directory gen_py # when execute code 'EnsureModule(...)' if this file did not exist. #---------------------------------------------------------------------- from win32com.client import gencache, Dispatch import time docmod = gencache.EnsureModule('{3050F1C5-98B5-11CF-BB82-00AA00BDCE0B}', 0, 4, 0) class DocEvents(docmod.HTMLDocumentEvents2): def __init__(self, doc): docmod.HTMLDocumentEvents2.__init__(self, doc) def Ononclick(self, event): print 'onclick' ev = gencache.EnsureDispatch(event) elem = ev.srcElement print 'tagName' , elem.tagName print 'id' , elem.id print 'innerText' , elem.innerText print 'clientX' , ev.clientX print 'clientY' , ev.clientY print 'body text' , doc.body.createTextRange().text ie = Dispatch("InternetExplorer.Application") ie.Navigate('http://www.google.com') ie.Visible = 1 while ie.Busy: time.sleep(0.1) doc = ie.Document d = DocEvents(doc) #---------------------------------------------------------------------- # end of method 1 #---------------------------------------------------------------------- #---------------------------------------------------------------------- # output of method 1 #---------------------------------------------------------------------- """ onclick tagName B id innerText Web clientX 172 clientY 182 body textpythoncom error: Python error invoking COM method. Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 285, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 290, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 588, in _invokeex_ return func(*args) File "D:\project\python\Test\ie-event-method-1.py", line 29, in Ononclick print 'body text' , doc.body.createTextRange().text File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 454, in __getattr__ raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) exceptions.AttributeError: '' object has no attribute 'createTextRange' """ #---------------------------------------------------------------------- # end of output 1 #---------------------------------------------------------------------- 2. method 2 #---------------------------------------------------------------------- # method 2 # Dispatch ie.Document with DocEvents(subclass of HTMLDocumentEvents2) # It will take a long time(about tens of seconds) to generate / compile # 3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py in directory gen_py # when execute code 'EnsureModule(...)' if this file did not exist. #---------------------------------------------------------------------- from win32com.client import gencache, Dispatch, DispatchWithEvents import time docmod = gencache.EnsureModule('{3050F1C5-98B5-11CF-BB82-00AA00BDCE0B}' ,0 ,4, 0) class DocEvents(docmod.HTMLDocumentEvents2): def Ononclick(self): print 'onclick' ev = doc.parentWindow.event elem = ev.srcElement print 'tagName' , elem.tagName print 'id' , elem.id print 'innerText' , elem.innerText print 'clientX' , ev.clientX print 'clientY' , ev.clientY print 'body text' , doc.body.createTextRange().text ie = Dispatch('InternetExplorer.Application') ie.Visible = 1 ie.Navigate('http://www.google.com') while ie.Busy: time.sleep(0.1) doc = ie.Document d = DispatchWithEvents(doc, DocEvents) #---------------------------------------------------------------------- # end of code 2 #---------------------------------------------------------------------- #---------------------------------------------------------------------- # output of method 2 #---------------------------------------------------------------------- """ onclick tagName B id innerText Web clientX 171 clientY 176 body textpythoncom error: Python error invoking COM method. Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 285, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 290, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 588, in _invokeex_ return func(*args) File "D:\project\python\Test\ie-event-method-2.py", line 27, in Ononclick print 'body text' , doc.body.createTextRange().text File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 454, in __getattr__ raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) exceptions.AttributeError: '' object has no attribute 'createTextRange' """ #---------------------------------------------------------------------- # end of output 2 #---------------------------------------------------------------------- 3. method 3 #---------------------------------------------------------------------- # method 3 # Use WithEvents(not a subclass of HTMLDocumentEvents2) # This method will also take a long time to generate / compile # 3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py in directory gen_py # when execute code 'WithEvents(...)' if this file did not exist. #---------------------------------------------------------------------- from win32com.client import Dispatch, WithEvents import time class DocEvents: def Ononclick(self): print 'onclick' ev = doc.parentWindow.event elem = ev.srcElement print 'tagName' , elem.tagName print 'id' , elem.id print 'innerText' , elem.innerText print 'clientX' , ev.clientX print 'clientY' , ev.clientY print 'body text' , doc.body.createTextRange().text ie = Dispatch("InternetExplorer.Application") ie.Visible = 1 ie.Navigate('http://www.google.com') while ie.Busy: time.sleep(0.1) doc = ie.Document d = WithEvents(doc, DocEvents) #---------------------------------------------------------------------- # end of code 3 #---------------------------------------------------------------------- #---------------------------------------------------------------------- # output of method 3 (when this code run first time, # ie, 3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py *NOT* exist) #---------------------------------------------------------------------- """ onclick tagName B id innerText Web clientX 168 clientY 182 body text Personalized Home | Sign in Web Images VideoNew! News Maps more ?Books Froogle Groups even more ? Advanced Search Preferences Language Tools Advertising Programs - Business Solutions - About Google Make Google Your Homepage! ?2006 Google """ #---------------------------------------------------------------------- # end of output 3 # (3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py *NOT* exist) #---------------------------------------------------------------------- #---------------------------------------------------------------------- # output of method 3 (when this code run another time, # ie, 3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py *DO* exist) #---------------------------------------------------------------------- """ onclick tagName B id innerText Web clientX 172 clientY 182 body textpythoncom error: Python error invoking COM method. Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 285, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 290, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 588, in _invokeex_ return func(*args) File "D:\project\python\Test\ie-event-method-3.py", line 24, in Ononclick print 'body text' , doc.body.createTextRange().text File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 454, in __getattr__ raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) exceptions.AttributeError: '' object has no attribute 'createTextRange' """ #---------------------------------------------------------------------- # end of output 3 # (3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py *DO* exist) #---------------------------------------------------------------------- 4. method 4 #---------------------------------------------------------------------- # method 4 # Try to use attachEvent, but never worked #---------------------------------------------------------------------- from win32com.client import Dispatch import time class DocEvents: def Ononclick(self): print 'onclick' ev = doc.parentWindow.event elem = ev.srcElement print 'tagName' , elem.tagName print 'id' , elem.id print 'innerText' , elem.innerText print 'clientX' , ev.clientX print 'clientY' , ev.clientY print 'body text' , doc.body.createTextRange().text ie = Dispatch("InternetExplorer.Application") ie.Visible = 1 ie.Navigate('http://www.google.com') while ie.Busy: time.sleep(0.1) doc = ie.Document #doc.attachEvent('onclick',DocEvents.Ononclick) doc.attachEvent('onclick',DocEvents) #---------------------------------------------------------------------- # end of code 4 #---------------------------------------------------------------------- #---------------------------------------------------------------------- # output of method 4 #---------------------------------------------------------------------- """ Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "D:\project\python\Test\ie-event-method-4.py", line 31, in ? doc.attachEvent('onclick',DocEvents) File "C:\Python24\lib\site-packages\win32com\gen_py\3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py", line 9518, in attachEvent , pdisp) ValueError: argument is not a COM object """ #---------------------------------------------------------------------- # end of output 4 #---------------------------------------------------------------------- 5. method 5 #---------------------------------------------------------------------- # method 5 # Don't handle DOM events, always works right # when 3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py not exist #---------------------------------------------------------------------- from win32com.client import Dispatch import time ie = Dispatch("InternetExplorer.Application") ie.Visible = 1 ie.Navigate('http://www.google.com') while ie.Busy: time.sleep(0.1) doc = ie.Document print doc.body.createTextRange().text #---------------------------------------------------------------------- # end of code 5 #---------------------------------------------------------------------- #---------------------------------------------------------------------- # output of method 5 # (3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py not exist) #---------------------------------------------------------------------- """ Personalized Home | Sign in Web Images VideoNew! News Maps more ?Books Froogle Groups even more ? Advanced Search Preferences Language Tools Advertising Programs - Business Solutions - About Google Make Google Your Homepage! ?2006 Google """ #---------------------------------------------------------------------- # end of output 5 # (3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py not exist) #---------------------------------------------------------------------- #---------------------------------------------------------------------- # output of method 5 # (3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py DO exist) #---------------------------------------------------------------------- """ Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "D:\project\python\Test\ie-event-method-5.py", line 19, in ? print doc.body.createTextRange().text File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 454, in __getattr__ raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) AttributeError: '' object has no attribute 'createTextRange' """ #---------------------------------------------------------------------- # end of output 5 # (3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py DO exist) #---------------------------------------------------------------------- method 1,2,3,5 can work, not method 4. My result is: method 1,2 works right when try 'elem.tagName', 'elem.id', 'elem.innerText', 'ev.clientX', but never works when try 'doc.body.createTextRange()' whether file '3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py' exist. *** method 3 works right when '3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py' do NOT exist ***, but works like method 1,2 when file '3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py' exist. method 4 never get works, just I think may be works. method 5 can always works when file '3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py' NOT exist, but never works when file '3050F1C5-98B5-11CF-BB82-00AA00BDCE0Bx0x4x0.py' DO exist. These code run under: Windows XP SP2 Internet Explorer 6.0.2900.2180.xpsp_sp2_rtm.040803-2158 PythonWin 2.4.3 (#69, Apr 11 2006, 15:32:42) [MSC v.1310 32 bit (Intel)] on win32. pywin32 build 209 My question: It looks like that: 'doc.body.createTextRange()' never works right, whenever makepy.py generate {3050F1C5-98B5-11CF-BB82-00AA00BDCE0B} python wrapper before run these code, Noticed that in method 3, 'd = WithEvents(doc, DocEvents)' will generate this wrapper, but works right at first time when this wrapper not generate before. But works wrong when this wrapper already exist. I don't know why this wrapper effect method 5, since method 5 never handle {3050F1C5-98B5-11CF-BB82-00AA00BDCE0B}. Method 1,2 always generate this wrapper file, and never works right whether this wrapper exist. And I notice that, when generate this wrapper file, my application memory consumption will grow up to 180MB, and 60MB when do not generate it. Any advice will be appreciated. Thanks, Richard From richard-liao at 163.com Mon Aug 28 17:52:49 2006 From: richard-liao at 163.com (Richard Liao) Date: Mon, 28 Aug 2006 23:52:49 +0800 Subject: [python-win32] IE HTML DOM events Message-ID: <44F31155.034016.32331> Source files can be found in attachment. Richard -------------- next part -------------- A non-text attachment was scrubbed... Name: ie-event-method-5.py Type: application/octet-stream Size: 2544 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060828/98c1224f/attachment.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: ie-event-method-1.py Type: application/octet-stream Size: 2903 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060828/98c1224f/attachment-0001.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: ie-event-method-2.py Type: application/octet-stream Size: 2830 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060828/98c1224f/attachment-0002.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: ie-event-method-3.py Type: application/octet-stream Size: 3697 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060828/98c1224f/attachment-0003.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: ie-event-method-4.py Type: application/octet-stream Size: 1904 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060828/98c1224f/attachment-0004.obj From torerik81 at gmail.com Tue Aug 29 14:36:41 2006 From: torerik81 at gmail.com (=?ISO-8859-1?Q?Tor_Erik_S=F8nvisen?=) Date: Tue, 29 Aug 2006 14:36:41 +0200 Subject: [python-win32] Measuring cpu, memory and bandwith used by an application Message-ID: <44F434D9.8040109@gmail.com> Given a process id (or some other identificator), is it possible to monitor resource usage of that process only? From Jim.Vickroy at noaa.gov Tue Aug 29 17:36:22 2006 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue, 29 Aug 2006 09:36:22 -0600 Subject: [python-win32] Measuring cpu, memory and bandwith used by an application In-Reply-To: <44F434D9.8040109@gmail.com> References: <44F434D9.8040109@gmail.com> Message-ID: <44F45EF6.6020308@noaa.gov> Tor Erik S?nvisen wrote: >Given a process id (or some other identificator), is it possible to >monitor resource usage of that process only? >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > Hello Tor, Are you familiar with the Performance Monitor (perfmon)? If not, that may fit your needs. -- jv From tim.golden at viacom-outdoor.co.uk Tue Aug 29 18:16:20 2006 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue, 29 Aug 2006 17:16:20 +0100 Subject: [python-win32] Measuring cpu, memory and bandwith used by an application Message-ID: [Tor Erik S?nvisen] | Given a process id (or some other identificator), is it possible to | monitor resource usage of that process only? Sorry, very quick answer. You can do this sort of thing fairly easily with WMI. If you Google around for Wmi process monitoring, you'll probably find VBS examples which will be quite easy to port to Python. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From rwupole at msn.com Thu Aug 31 00:00:44 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 30 Aug 2006 18:00:44 -0400 Subject: [python-win32] Re: IE HTML DOM events Message-ID: At a guess, there's some kind of oddity with the type information. If you use a dynamic dispatch for the body, it seems to work in the -1 example. Changing the last 2 lines of the Ononclick event code to body=win32com.client.dynamic.Dispatch(doc.body) print 'body text' , body.createTextRange().text gives the expected result. Roger From richard-liao at 163.com Thu Aug 31 07:07:52 2006 From: richard-liao at 163.com (richard-liao) Date: Thu, 31 Aug 2006 13:07:52 +0800 Subject: [python-win32] IE HTML DOM events Message-ID: <44F6723F.040260.30641> Roger Upole Your advice is very useful, now these codes work as good as I expect it to be. Thanks a lot. Richard From bendra at gmail.com Thu Aug 31 23:43:07 2006 From: bendra at gmail.com (Bend) Date: Fri, 1 Sep 2006 09:43:07 +1200 Subject: [python-win32] Question: Finding the "owner" Of A Process Message-ID: <96dd15190608311443j49a520d2l6608c13efc961d19@mail.gmail.com> Hi John I had the same problem recently except I'm using windows XP home but it should work the same. The trick is that you cannot access the method directly by calling it as for some reason process.GetOwner is an integer 0 (perhaps the return code of the method or something). What you have to do is use the execMethod_ function. so your code would look something like this: for proc in procs: result = proc.execMethod_('GetOwner') print "%s's owner is %s" % (proc.Name, result.User) And similar replacements with the other calls to GetOwner. execMethod_ returns an object with two feilds User and domain. Hope this is what you were looking for -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060901/8002f34e/attachment.html