From admin at genesisware.de Thu Feb 4 00:57:26 2010 From: admin at genesisware.de (Stefan George) Date: Thu, 4 Feb 2010 00:57:26 +0100 Subject: [python-win32] How to check a Checkbutton Message-ID: <000001caa52c$a34df620$e9e9e260$@de> Good morning PyWin32-users, It is me again and I hope you can help me again: I have the handle of a checkbox and would like to get the state of the checkbox (true/false) and I want to check it/uncheck it. I have searched on the web but didn't find any help. Thank you very much, Stefan George -------------- next part -------------- An HTML attachment was scrubbed... URL: From Eli.Sandler at vanadium-soft.com Thu Feb 4 11:48:30 2010 From: Eli.Sandler at vanadium-soft.com (Eli Sandler) Date: Thu, 4 Feb 2010 12:48:30 +0200 Subject: [python-win32] unusual network load when querying a remote registry over wmi Message-ID: Hi, I have a curious problem. I use Tim Golden?s module for WMI, and I use the ?StdRegProv? to query a remote registry over WMI. I get an unusual network load for this procedure. Using a packet capture, I saw that each new query contains all the previous ones. Do I use the module in a wrong way? Did anyone else encounter this problem? Here is the code: def _tt( server, user, password ): import win32con import win32com import wmi oDispatch = win32com.Dispatch("WbemScripting.SWbemLocator") remote_connection = oDispatch.ConnectServer( server, 'root\\default', user, password, '', '', 0, None ) oReg = wmi._wmi_object( remote_connection.Get( 'StdRegProv' ) ) hive = win32con.HKEY_LOCAL_MACHINE key = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall" return_value = {} result = oReg.EnumKey( hive, key ) if result[0] != 0: print "Couldn't enumerate sub keys for:",key return subkeys = result[1] for subkey in subkeys: result = oReg.GetStringValue( hive, key+'\\'+subkey, "DisplayName" ) if result[0] != 0: print "Error geting 'DisplayName' for:",key+'\\'+subkey continue name = result[1] if name is not None and len(name) > 0: result = oReg.GetStringValue( hive, key+'\\'+subkey, "DisplayVersion" ) if result[0] != 0: ver = "" else: ver = result[1] result = oReg.GetStringValue( hive, key+'\\'+subkey, "Publisher" ) if result[0] != 0: pub = "" else: pub = result[1] return_value[name] = (ver, pub) return return_value Thanks in advance. -- Eliyahu Sandler Software Engineer Vanadium Software Ltd. www.vanadium-soft.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Thu Feb 4 12:23:07 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 04 Feb 2010 11:23:07 +0000 Subject: [python-win32] unusual network load when querying a remote registry over wmi In-Reply-To: References: Message-ID: <4B6AAE1B.2000405@timgolden.me.uk> On 04/02/2010 10:48, Eli Sandler wrote: > I have a curious problem. I use Tim Golden?s module for WMI, and I use the > ?StdRegProv? to query a remote registry over WMI. I get an unusual network load > for this procedure. > Using a packet capture, I saw that each new query contains all the previous ones. > Do I use the module in a wrong way? > Did anyone else encounter this problem? Well I can simplify things for you slightly at the beginning: import wmi oReg = wmi.WMI (server, namespace="default", user=user, password=password).StdRegProv Also you might perhaps simplify your code by using tuple unpacking and by exploiting the fact that in Python anything empty evaluates to False including 0, None and "": import wmi server = "BLAH" user = password = "" oReg = wmi.WMI (server, namespace="default", user=user, password=password).StdRegProv result, subkeys = oReg.EnumKey( hive, key ) if result: print "Couldn't..." return for subkey in subkeys: result, name = oReg.GetStringValue( hive, key+'\\'+subkey, "DisplayName" ) if result: print "Couldn't get display name..." continue result, ver = oReg.GetStringValue( hive, key+'\\'+subkey, "DisplayVersion" ) if result: ver = "" result, publisher = oReg.GetStringValue( hive, key+'\\'+subkey, "DisplayVersion" ) if result: publisher = "" # ... etc. Obviously more refactoring could be done to drop the common code into functions etc. But I'm sure you knew that. However I can't see any particular reason why each new query should contain all the previous ones. Can you show an example of your network trace? TJG From Eli.Sandler at vanadium-soft.com Thu Feb 4 13:10:37 2010 From: Eli.Sandler at vanadium-soft.com (Eli Sandler) Date: Thu, 4 Feb 2010 14:10:37 +0200 Subject: [python-win32] unusual network load when querying a remote registry over wmi References: <4B6AAE1B.2000405@timgolden.me.uk> Message-ID: > However I can't see any particular reason why each new query should > contain > all the previous ones. Can you show an example of your network trace? > > TJG Here a sample of the captured stream, from somewhere at the relative beginning. %...... ......'`.......=.W................5.....#M..Y.........User ....... ...S.t.d.R.e.g.P.r.o.v.User............G.e.t.S.t.r.i.n.g.V.a.l.u.e.............{...{...MEOW.........s...M...K.$...E:........K.$....K...xV4.C.....EXCHANGE-SER..ROOT\Default................................................... ..........................*...........C....................o...|....__PARAMETERS..abstract....................hDefKey..uint32................... ........3....IN................... ........3...Z...........ID...............)... ............Z........................uint32....................sSubKeyName..string................... .............IN................... ........................ID...............)... ........z..............?.............string....................sValueName..string................... .............in................... ........................ID...............)... ........0............................string..SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\AddressBook..DisplayName..SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Branding..DisplayName..SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Connection Manager..DisplayName..SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\DirectAnimation..DisplayName..SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\DirectDrawEx..DisplayName..SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\DXM_Runtime..DisplayName..SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\F95DE19F-CF69-4b03-81B6-9EC050D20D3B..DisplayName ... As you can see the string at the end contains the previous strings. Any idea will be welcome. Eliyauh Sandler From timr at probo.com Thu Feb 4 19:29:59 2010 From: timr at probo.com (Tim Roberts) Date: Thu, 04 Feb 2010 10:29:59 -0800 Subject: [python-win32] How to check a Checkbutton In-Reply-To: <000001caa52c$a34df620$e9e9e260$@de> References: <000001caa52c$a34df620$e9e9e260$@de> Message-ID: <4B6B1227.2050908@probo.com> Stefan George wrote: > > > > It is me again and I hope you can help me again: > > > > I have the handle of a checkbox and would like to get the state of the > checkbox (true/false) and I want to check it/uncheck it. > > I have searched on the web but didn?t find any help. > How did you get the handle? At the lowest level, you get the current state by sending a BM_GETCHECK message to the window, and you set the state by sending a BM_SETCHECK message. MSDN describes the parameters you need to send. If you're doing raw API calls, you can use win32api.SendMessage to do it. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From bryan_berrett at kairosautonomi.com Fri Feb 5 05:48:47 2010 From: bryan_berrett at kairosautonomi.com (Bryan Berrett) Date: Thu, 04 Feb 2010 21:48:47 -0700 Subject: [python-win32] Concurrent Access to COM object from Python and VB6 Message-ID: <4B6BA32F.1060504@kairosautonomi.com> I have a number of programs written in VB6 that use an ActiveX control that allows access to a shared memory pool of variables. I successfully used the following code to hook into this and access the shared memory variables. The only problem is that when this program is active I can not launch any of my other programs that use the same ActiveX. They hang upon initialization. As soon as I terminate the Python process, the VB6 program will finish loading and functions as expected. I am not sure what I need to do in order for the Python program to not block access. If I start all the VB6 programs first and the Python program last, everything works and can access the shared memory variables. import win32com.client bewise = win32com.client.Dispatch('beWISE.Functions') varInt = beWISE.New_var_INTEGER('varInt') varInt.Value = 12345 varString = beWISE.New_var_STRING('varString') varString.Value = "New Variable" From mail at timgolden.me.uk Fri Feb 5 10:23:12 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 05 Feb 2010 09:23:12 +0000 Subject: [python-win32] unusual network load when querying a remote registry over wmi In-Reply-To: References: <4B6AAE1B.2000405@timgolden.me.uk> Message-ID: <4B6BE380.1070403@timgolden.me.uk> On 04/02/2010 12:10, Eli Sandler wrote: > Here a sample of the captured stream, from somewhere at the relative beginning. > > > %...... > ......'`.......=.W................5.....#M..Y.........User > ....... > ...S.t.d.R.e.g.P.r.o.v.User............G.e.t.S.t.r.i.n.g.V.a.l.u.e.............{...{...MEOW.........s...M...K.$...E:........K.$....K...xV4.C.....EXCHANGE-SER..ROOT\Default................................................... > ..........................*...........C....................o...|....__PARAMETERS..abstract....................hDefKey..uint32................... > ........3....IN................... > ........3...Z...........ID...............)... > ............Z........................uint32....................sSubKeyName..string................... > .............IN................... > ........................ID...............)... > ........z..............?.............string....................sValueName..string................... > .............in................... > ........................ID...............)... > ........0............................string..SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\AddressBook..DisplayName..SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Branding..DisplayName..SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Connection Manager..DisplayName..SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\DirectAnimation..DisplayName..SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\DirectDrawEx..DisplayName..SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\DXM_Runtime..DisplayName..SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\F95DE19F-CF69-4b03-81B6-9EC050D20D3B..DisplayName ... > > As you can see the string at the end contains the previous strings. I'm probably missing something obvious, but I can't see the duplication you mention. You're obviously seeing a list of registry key locations, each one naturally containing its own full path. But that's whad I'd expect at least. Have I misunderstood you? TJG From timr at probo.com Fri Feb 5 20:25:55 2010 From: timr at probo.com (Tim Roberts) Date: Fri, 05 Feb 2010 11:25:55 -0800 Subject: [python-win32] Concurrent Access to COM object from Python and VB6 In-Reply-To: <4B6BA32F.1060504@kairosautonomi.com> References: <4B6BA32F.1060504@kairosautonomi.com> Message-ID: <4B6C70C3.9020601@probo.com> Bryan Berrett wrote: > I have a number of programs written in VB6 that use an ActiveX control > that allows access to a shared memory pool of variables. I > successfully used the following code to hook into this and access the > shared memory variables. The only problem is that when this program is > active I can not launch any of my other programs that use the same > ActiveX. They hang upon initialization. As soon as I terminate the > Python process, the VB6 program will finish loading and functions as > expected. > I am not sure what I need to do in order for the Python program to not > block access. If I start all the VB6 programs first and the Python > program last, everything works and can access the shared memory > variables. I don't know why a COM object would behave like this. That's unusual. As an experiment, you could try deleting the object to see if that's enough to let the other apps run: del beWise However, since you have other object instances hanging around (the varInt and varString), I'm dubious that it will make much difference. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Eli.Sandler at vanadium-soft.com Sun Feb 7 09:31:17 2010 From: Eli.Sandler at vanadium-soft.com (Eli Sandler) Date: Sun, 7 Feb 2010 10:31:17 +0200 Subject: [python-win32] unusual network load when querying a remote registry over wmi References: <4B6AAE1B.2000405@timgolden.me.uk> <4B6BE380.1070403@timgolden.me.uk> Message-ID: I'm sorry that I have been misunderstood. As the conversation goes on (the for loop in the code) the list of keys in the query sent to the remote computers grows in length. I would expect that each query will contain only one key (the key I query about), but it seems to aggregate all the previous keys. The snippet of the conversation that I included is just one query (and it has all the previous query key strings in it, although in the code it just [code] result = oReg.GetStringValue( hive, key+'\\'+subkey, "DisplayVersion" ) [/code]). -- Eliyahu Sandler From chris.jesse at flightdataservices.com Thu Feb 11 19:18:00 2010 From: chris.jesse at flightdataservices.com (Chris Jesse) Date: Thu, 11 Feb 2010 18:18:00 +0000 (GMT) Subject: [python-win32] USB Insertion Extrinsic Event exists? In-Reply-To: <33218800.21265912027714.JavaMail.chris@jesse1c-laptop> Message-ID: <24642347.41265912274800.JavaMail.chris@jesse1c-laptop> Hi All, I currently have a little program which looks for new USB removable media to be inserted into a PC. It does so by polling (every 5 seconds) all the drives within Win32_DiskDrive() and queries to find the ones which PNPDeviceID has 'USBSTOR' within them and establishes that they are removable media (I'm not interested in USB HDDs) and whether they have a partition or not. This approach was used too on Linux for querying HAL - however DeviceKit has replaced HAL, and along with it brought the concept of listening to signals. Looking back at the python WMI docs, I've read about "Extrinsic Events" and the "watch_for" method. However, I'm having trouble working out whether there are any events for USB media insertion that I can wait for? I would like to move away from polling as it introduces delays when the user is expecting an immediate response. Can anyone guide me with how to write a little listener; if this is possible? Thanks in advance, Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Fri Feb 12 02:20:21 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 12 Feb 2010 12:20:21 +1100 Subject: [python-win32] USB Insertion Extrinsic Event exists? In-Reply-To: <24642347.41265912274800.JavaMail.chris@jesse1c-laptop> References: <24642347.41265912274800.JavaMail.chris@jesse1c-laptop> Message-ID: <4B74ACD5.1000909@gmail.com> The pywin32 demo in win32/Demos/win32gui_devicenotify.py should get you on the right track. HTH, Mark On 12/02/2010 5:18 AM, Chris Jesse wrote: > Hi All, > > I currently have a little program which looks for new USB removable > media to be inserted into a PC. It does so by polling (every 5 seconds) > all the drives within Win32_DiskDrive() and queries to find the ones > which PNPDeviceID has 'USBSTOR' within them and establishes that they > are removable media (I'm not interested in USB HDDs) and whether they > have a partition or not. > > This approach was used too on Linux for querying HAL - however DeviceKit > has replaced HAL, and along with it brought the concept of listening to > signals. Looking back at the python WMI docs, I've read about "Extrinsic > Events" and the "watch_for" method. However, I'm having trouble working > out whether there are any events for USB media insertion that I can wait > for? > > I would like to move away from polling as it introduces delays when the > user is expecting an immediate response. Can anyone guide me with how to > write a little listener; if this is possible? > > Thanks in advance, Chris > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From timr at probo.com Fri Feb 12 02:35:01 2010 From: timr at probo.com (Tim Roberts) Date: Thu, 11 Feb 2010 17:35:01 -0800 Subject: [python-win32] USB Insertion Extrinsic Event exists? Message-ID: <201002120135.o1C1Z1p12423@probo.probo.com> You wrote: > >... >I would like to move away from polling as it introduces delays when the >user is expecting an immediate response. Can anyone guide me with how to >write a little listener; if this is possible? Is this a windowed app? By calling RegisterDeviceNotification, you can ask to be notified via a WM_DEVICECHANGE message any time there is any change in state of any plug-and-play device. You would still have to do polling to find out whether the change was something you care about, but it would reduce the periodic polling. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jeffpeery at yahoo.com Fri Feb 12 06:32:03 2010 From: jeffpeery at yahoo.com (Jeff Peery) Date: Thu, 11 Feb 2010 21:32:03 -0800 (PST) Subject: [python-win32] permissions error Message-ID: <424347.83600.qm@web43143.mail.sp1.yahoo.com> Hello, I'm running on vista and I'm getting a permissions error from win32com. I attached a print screen displaying the error message. It appears win32com is trying to write a file and vista UAC is blocking it. Why is win32com trying to do this and how do I fix it? the only method I am using from win32com is "win32com.client.DispatchWithEvents()" to create a client of a windows OPC server. It works fine until I compile it and run it from the compiled executable and this message appears. ? thanks, Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: error_msg.jpg Type: image/pjpeg Size: 21232 bytes Desc: not available URL: From mail at timgolden.me.uk Fri Feb 12 09:56:44 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 12 Feb 2010 08:56:44 +0000 Subject: [python-win32] USB Insertion Extrinsic Event exists? In-Reply-To: <24642347.41265912274800.JavaMail.chris@jesse1c-laptop> References: <24642347.41265912274800.JavaMail.chris@jesse1c-laptop> Message-ID: <4B7517CC.1030004@timgolden.me.uk> On 11/02/2010 18:18, Chris Jesse wrote: > Hi All, > > I currently have a little program which looks for new USB removable media > to be inserted into a PC. It does so by polling (every 5 seconds) all > the drives within Win32_DiskDrive() and queries to find the ones which > PNPDeviceID has 'USBSTOR' within them and establishes that they are removable media > (I'm not interested in USB HDDs) and whether they have a partition or not. You've got two, perhaps three approaches you could take here. One is to use the WM_DEVICECHANGE windows message. I thought I had an example in my list of How-Tos but I see that I don't. Here's an old post illustratating a solution: http://mail.python.org/pipermail/python-list/2004-January/887363.html Using WMI you could look at either the Win32_VolumeChangeEvent or the Win32_DeviceChangeEvent. Both are extrinsic so are basically proxying the WM_DEVICECHANGE above; the first is a subclass of the second. import wmi c = wmi.WMI () print c.Win32_DeviceChangeEvent # schema info shows that it relies on WM_DEVICECHANGE watcher = c.Win32_DeviceChangeEvent () event = watcher () # inserts USB stick print event However, on my WinXP box I'm not getting much information beyond the fact of the event; not sure if that's because of some flaw in my code or merely because XP doesn't support very much more than that. I'll try to run some tests. At the worst, you'd only need to scan the list of devices / volumes when an event occurs... TJG From mail at timgolden.me.uk Fri Feb 12 10:41:19 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 12 Feb 2010 09:41:19 +0000 Subject: [python-win32] USB Insertion Extrinsic Event exists? In-Reply-To: <4B7517CC.1030004@timgolden.me.uk> References: <24642347.41265912274800.JavaMail.chris@jesse1c-laptop> <4B7517CC.1030004@timgolden.me.uk> Message-ID: <4B75223F.2030808@timgolden.me.uk> On 12/02/2010 08:56, Tim Golden wrote: [... snip ideas re WMI ...] To clarify, after a little Googling: it appears that altho' Win32_VolumeChangeEvent is exposed under WinXP it's effectively not implemented. Win32_DeviceChangeEvent doesn't return the device itself. Not sure what OS you're running on, so this may not be an issue. Still seems worth combining some sort of before-and-after scanning (especially given the small number of devices) with a change event. TJG From mail at timgolden.me.uk Fri Feb 12 12:25:17 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 12 Feb 2010 11:25:17 +0000 Subject: [python-win32] USB Insertion Extrinsic Event exists? In-Reply-To: <4B7517CC.1030004@timgolden.me.uk> References: <24642347.41265912274800.JavaMail.chris@jesse1c-laptop> <4B7517CC.1030004@timgolden.me.uk> Message-ID: <4B753A9D.6090804@timgolden.me.uk> On 12/02/2010 08:56, Tim Golden wrote: > You've got two, perhaps three approaches you could take here. One > is to use the WM_DEVICECHANGE windows message. I thought I had an > example in my list of How-Tos but I see that I don't. ... so I've now added it: http://timgolden.me.uk/python/win32_how_do_i/detect-device-insertion.html TJG From davea at ieee.org Fri Feb 12 12:26:04 2010 From: davea at ieee.org (Dave Angel) Date: Fri, 12 Feb 2010 06:26:04 -0500 Subject: [python-win32] permissions error In-Reply-To: <424347.83600.qm@web43143.mail.sp1.yahoo.com> References: <424347.83600.qm@web43143.mail.sp1.yahoo.com> Message-ID: <4B753ACC.5060107@ieee.org> Jeff Peery wrote: > Hello, > I'm running on vista and I'm getting a permissions error from win32com. I attached a print screen displaying the error message. It appears win32com is trying to write a file and vista UAC is blocking it. Why is win32com trying to do this and how do I fix it? the only method I am using from win32com is "win32com.client.DispatchWithEvents()" to create a client of a windows OPC server. It works fine until I compile it and run it from the compiled executable and this message appears. > > thanks, > Jeff > > > > > 1) please just use copy/paste from your console session. No need to waste bandwidth sending a hard-to-read image of the window. If you're not familiar with QuickEdit mode on DOS boxes, it's enabled as follows. Right-click on the title bar of a console, and choose Properties. In the Options tab, turn on QuickEdit mode. Now, to copy a rectangle of the DOS box to the clipboard, you do a selection with the mouse, then right click. 2) Are you running a 64bit version of Vista? And exactly what version of Python are you using? (print sys.version). 3) What do you mean by "compile" and "compiled executable"? I can't answer your problem, but maybe I can make life a little easier for those who could. DaveA From chris.jesse at flightdataservices.com Fri Feb 12 16:52:27 2010 From: chris.jesse at flightdataservices.com (Chris Jesse) Date: Fri, 12 Feb 2010 15:52:27 +0000 (GMT) Subject: [python-win32] USB Insertion Extrinsic Event exists? In-Reply-To: <3879334.131265987689244.JavaMail.chris@jesse1c-laptop> Message-ID: <31264084.151265989946401.JavaMail.chris@jesse1c-laptop> Hi TJG, Thanks for your very helpful reply and code snippet. I'm happy that there seems to be a way to do this in windows. The application is multi-threaded with the MainThread being a wxPython MainLoop which monitors for events such as Shutdown (QUERY_END_SESSION) etc. It has to be the MainThread in order to receive the events. Is it possible that the Win32_VolumeChangeEvent or Win32_DeviceChangeEvent events can be detected a seperate thread? The example "detect-device-insertion" uses an infinate loop win32gui.PumpMessages() for WM_DEVICECHANGE. We can't use this as our MainThread as it's already in the wx MainLoop(). Operating system wise, we have to support Ubuntu (hense the DeviceKit), Windows XP, Vista and 7. Scanning the list of devices isn't such a problem as we do it already; but of course the less we have to do the better! Thanks everyone for your help. Chris Jesse Software Architect Flight Data Services 189-199 West Street, Fareham, PO16 0EN, UK Tel: +44 (0) 1329 223663 Fax: +44 (0) 1329 223664 http://www.flightdataservices.com Registered in England, No 4041206, Address: 14 Brookmeadow, Fareham, PO15 5JH ----- Original Message ----- From: "Tim Golden" To: python-win32 at python.org Sent: Friday, 12 February, 2010 08:56:44 GMT +00:00 GMT Britain, Ireland, Portugal Subject: Re: [python-win32] USB Insertion Extrinsic Event exists? On 11/02/2010 18:18, Chris Jesse wrote: > Hi All, > > I currently have a little program which looks for new USB removable media > to be inserted into a PC. It does so by polling (every 5 seconds) all > the drives within Win32_DiskDrive() and queries to find the ones which > PNPDeviceID has 'USBSTOR' within them and establishes that they are removable media > (I'm not interested in USB HDDs) and whether they have a partition or not. You've got two, perhaps three approaches you could take here. One is to use the WM_DEVICECHANGE windows message. I thought I had an example in my list of How-Tos but I see that I don't. Here's an old post illustratating a solution: http://mail.python.org/pipermail/python-list/2004-January/887363.html Using WMI you could look at either the Win32_VolumeChangeEvent or the Win32_DeviceChangeEvent. Both are extrinsic so are basically proxying the WM_DEVICECHANGE above; the first is a subclass of the second. import wmi c = wmi.WMI () print c.Win32_DeviceChangeEvent # schema info shows that it relies on WM_DEVICECHANGE watcher = c.Win32_DeviceChangeEvent () event = watcher () # inserts USB stick print event However, on my WinXP box I'm not getting much information beyond the fact of the event; not sure if that's because of some flaw in my code or merely because XP doesn't support very much more than that. I'll try to run some tests. At the worst, you'd only need to scan the list of devices / volumes when an event occurs... TJG _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Fri Feb 12 17:23:53 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 12 Feb 2010 16:23:53 +0000 Subject: [python-win32] USB Insertion Extrinsic Event exists? In-Reply-To: <31264084.151265989946401.JavaMail.chris@jesse1c-laptop> References: <31264084.151265989946401.JavaMail.chris@jesse1c-laptop> Message-ID: <4B758099.8000401@timgolden.me.uk> On 12/02/2010 15:52, Chris Jesse wrote: > Hi TJG, > > Thanks for your very helpful reply and code snippet. > I'm happy that there seems to be a way to do this in windows. > The application is multi-threaded with the MainThread being a wxPython > MainLoop which monitors for events such as Shutdown (QUERY_END_SESSION) etc. > It has to be the MainThread in order to receive the events. > Is it possible that the Win32_VolumeChangeEvent or Win32_DeviceChangeEvent > events can be detected a seperate thread? The example > "detect-device-insertion" uses an infinate loop win32gui.PumpMessages() > for WM_DEVICECHANGE. We can't use this as our MainThread as it's > already in the wx MainLoop(). It's certainly possible to receive WMI events in a thread. There's a fairly relevant example here: http://timgolden.me.uk/python/wmi/cookbook.html#monitor-multiple-machines-for-power-events It should be possible to adapt the PumpMessages loop into a wxPython main loop but I'm not a wxPython person so you'd have to look around or ask over there on the wx mailing list. TJG From aahz at pythoncraft.com Fri Feb 12 18:21:30 2010 From: aahz at pythoncraft.com (Aahz) Date: Fri, 12 Feb 2010 09:21:30 -0800 Subject: [python-win32] USB Insertion Extrinsic Event exists? In-Reply-To: <4B753A9D.6090804@timgolden.me.uk> References: <24642347.41265912274800.JavaMail.chris@jesse1c-laptop> <4B7517CC.1030004@timgolden.me.uk> <4B753A9D.6090804@timgolden.me.uk> Message-ID: <20100212172130.GA23057@panix.com> On Fri, Feb 12, 2010, Tim Golden wrote: > On 12/02/2010 08:56, Tim Golden wrote: >> >> You've got two, perhaps three approaches you could take here. One >> is to use the WM_DEVICECHANGE windows message. I thought I had an >> example in my list of How-Tos but I see that I don't. > > ... so I've now added it: > > http://timgolden.me.uk/python/win32_how_do_i/detect-device-insertion.html Thanks! -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "At Resolver we've found it useful to short-circuit any doubt and just refer to comments in code as 'lies'. :-)" From timr at probo.com Fri Feb 12 19:37:38 2010 From: timr at probo.com (Tim Roberts) Date: Fri, 12 Feb 2010 10:37:38 -0800 Subject: [python-win32] permissions error In-Reply-To: <4B753ACC.5060107@ieee.org> References: <424347.83600.qm@web43143.mail.sp1.yahoo.com> <4B753ACC.5060107@ieee.org> Message-ID: <4B759FF2.2050409@probo.com> Dave Angel wrote: > 2) Are you running a 64bit version of Vista? Yes, he is. The path "Program Files (x86)" is prima facie evidence of this. He's running 32-bit Python on a 64-bit system. And that's just fine. > 3) What do you mean by "compile" and "compiled executable"? It means he has used something like "py2exe" to turn his Python code into an executable. This is a real problem, and one that pywin32 probably needs to address. On Vista and beyond, the "Program Files" directories are not writable by non-elevated programs. The win32com-generated wrappers need to go somewhere else, like "Local Settings\Temp" or "Local Settings\Apps". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From chris.jesse at flightdataservices.com Fri Feb 12 17:58:57 2010 From: chris.jesse at flightdataservices.com (Chris Jesse) Date: Fri, 12 Feb 2010 16:58:57 +0000 (GMT) Subject: [python-win32] USB Insertion Extrinsic Event exists? In-Reply-To: <17148192.231265993627965.JavaMail.chris@jesse1c-laptop> Message-ID: <12087451.251265993937190.JavaMail.chris@jesse1c-laptop> So it turns out that my description of the task was lacking in one simple, but critical, observation. We use removable media, usually a compact flash card, plugged into a USB adapter drive. The events get triggered for my pen drive, but when the compact flash card is inserted I get nothing - probably because the device is already plugged in. There's an interesting document attached which shows some potential C++ code; but I'm in a little out of my depth here - "help"! Regards, Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: usb-detection.pdf Type: application/pdf Size: 80418 bytes Desc: not available URL: From m.echavarriagregory at umiami.edu Sat Feb 13 01:22:24 2010 From: m.echavarriagregory at umiami.edu (Echavarria Gregory, Maria Angelica) Date: Fri, 12 Feb 2010 19:22:24 -0500 Subject: [python-win32] MemoryError: can I use more? Message-ID: <2E95F75EDC25D54999387A1E2E6EF6274378DA2BA1@MBX02.cgcent.miami.edu> Dear group: I am developing a program using Python 2.5.4 in windows 32 OS. The amount of data it works with is huge. I have managed to keep memory footprint low, but have found that, independent of the physical RAM of the machine, python always gives the MemoryError message when it has occupied exactly only 2.2 GB. I have tested this in 4 different machines, all with memory of 3 to 4 GB... I'm amazed. Could any of you please help me to figure out how to change that limit? I typed help(MemoryError) and it is a class itself, but that help told me nothing I can use... Thanks, Angelica. From greg.antal at ata-e.com Sat Feb 13 01:58:33 2010 From: greg.antal at ata-e.com (Greg Antal) Date: Fri, 12 Feb 2010 16:58:33 -0800 Subject: [python-win32] MemoryError: can I use more? In-Reply-To: <2E95F75EDC25D54999387A1E2E6EF6274378DA2BA1@MBX02.cgcent.miami.edu> References: <2E95F75EDC25D54999387A1E2E6EF6274378DA2BA1@MBX02.cgcent.miami.edu> Message-ID: <4B75F939.3000603@ata-e.com> Dear Angelica: 2.2 GB is essentially the largest integer you express with 32 bits (2^31), and therefore the largest quantity of memory for which you can define an address. There are some tricks that really sophisticated programmers can do that let you use more than that, but I don't know how to do it. If you want to access more memory, you have to go to a 64-bit machine and operating system. - Greg Antal Gregory W. Antal Senior Technical Advisor ATA Engineering, Inc. 11995 El Camino Real, Suite 200 San Diego, CA 92130 www.ata-e.com greg.antal at ata-e.com 858-480-2072 (Phone) 858-792-8932 (Fax) Echavarria Gregory, Maria Angelica wrote, On 2/12/2010 4:22 PM: > Dear group: > > I am developing a program using Python 2.5.4 in windows 32 OS. The amount of data it works with is huge. I have managed to keep memory footprint low, but have found that, independent of the physical RAM of the machine, python always gives the MemoryError message when it has occupied exactly only 2.2 GB. I have tested this in 4 different machines, all with memory of 3 to 4 GB... I'm amazed. > > Could any of you please help me to figure out how to change that limit? I typed help(MemoryError) and it is a class itself, but that help told me nothing I can use... > > Thanks, > Angelica. > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From jeffpeery at yahoo.com Sat Feb 13 04:08:34 2010 From: jeffpeery at yahoo.com (Jeff Peery) Date: Fri, 12 Feb 2010 19:08:34 -0800 (PST) Subject: [python-win32] permissions error In-Reply-To: <4B759FF2.2050409@probo.com> Message-ID: <403475.22853.qm@web43137.mail.sp1.yahoo.com> hello, yes, I am using 64 bit vista. and I am using py2exe to distribute my app. At the moment I'm dead in the water unti lI resolve this issue. Does anyone know of a quick fix? ? thanks, Jeff --- On Fri, 2/12/10, Tim Roberts wrote: From: Tim Roberts Subject: Re: [python-win32] permissions error To: "Python-Win32 List" Date: Friday, February 12, 2010, 10:37 AM Dave Angel wrote: > 2) Are you running a 64bit version of Vista? Yes, he is.? The path "Program Files (x86)" is prima facie evidence of this.? He's running 32-bit Python on a 64-bit system.? And that's just fine. > 3) What do you mean by "compile" and "compiled executable"? It means he has used something like "py2exe" to turn his Python code into an executable. This is a real problem, and one that pywin32 probably needs to address. On Vista and beyond, the "Program Files" directories are not writable by non-elevated programs.? The win32com-generated wrappers need to go somewhere else, like "Local Settings\Temp" or "Local Settings\Apps". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From glenbot at gmail.com Sat Feb 13 05:32:23 2010 From: glenbot at gmail.com (Glen Zangirolami) Date: Fri, 12 Feb 2010 22:32:23 -0600 Subject: [python-win32] Compile error on MySQL-Python with Mingw (python 2.6) Message-ID: I am having an issue compiling mysql-python on windows 7 using Mingw32. This is my first time compiling it with Mingw32 and not using Microsoft Visual Studio compilers. I have gotten pretty far using tutorials on the net but hit a road block. *Setup*: Windows 7 Ultimate Python 2.6 MySQL-python-1.2.3c1 mysql-essential-5.1.43-win32 MinGW-5.1.6 *What I have done so far*: * Installed MySQL with the source files * Placed the pydistutils.cfg in C:\Python26\Lib\distutils with the following in it: [build] compiler=mingw32 * Put the following in my path C:\Python26\;C:\Python26\Scripts\; C:\Program Files\MySQL\MySQL Server 5.1\bin\; C:\MinGW\bin\; * Updated the site.cfg file in mysql python to mysql version 5.1 from 5.0 so it pulls the correct registry key registry_key = SOFTWARE\MySQL AB\MySQL Server 5.1 *The error:* * running install running bdist_egg running egg_info writing MySQL_python.egg-info\PKG-INFO writing top-level names to MySQL_python.egg-info\top_level.txt writing dependency_links to MySQL_python.egg-info\dependency_links.txt reading manifest file 'MySQL_python.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'MySQL_python.egg-info\SOURCES.txt' installing library code to build\bdist.win32\egg running install_lib running build_py creating build creating build\lib.win32-2.6 copying _mysql_exceptions.py -> build\lib.win32-2.6 creating build\lib.win32-2.6\MySQLdb copying MySQLdb\__init__.py -> build\lib.win32-2.6\MySQLdb copying MySQLdb\converters.py -> build\lib.win32-2.6\MySQLdb copying MySQLdb\connections.py -> build\lib.win32-2.6\MySQLdb copying MySQLdb\cursors.py -> build\lib.win32-2.6\MySQLdb copying MySQLdb\release.py -> build\lib.win32-2.6\MySQLdb copying MySQLdb\times.py -> build\lib.win32-2.6\MySQLdb creating build\lib.win32-2.6\MySQLdb\constants copying MySQLdb\constants\__init__.py -> build\lib.win32-2.6\MySQLdb\constants copying MySQLdb\constants\CR.py -> build\lib.win32-2.6\MySQLdb\constants copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-2.6\MySQLdb\constants copying MySQLdb\constants\ER.py -> build\lib.win32-2.6\MySQLdb\constants copying MySQLdb\constants\FLAG.py -> build\lib.win32-2.6\MySQLdb\constants copying MySQLdb\constants\REFRESH.py -> build\lib.win32-2.6\MySQLdb\constants copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.6\MySQLdb\constants running build_ext building '_mysql' extension creating build\temp.win32-2.6 creating build\temp.win32-2.6\Release C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Dversion_info=(1,2,3,'gamma',1) -D__version__=1.2.3c1 "-IC:\Program File s\MySQL\MySQL Server 5.1\include" -IC:\Python26\include -IC:\Python26\PC -c _mysql.c -o build\temp.win32-2.6\Release\_mys ql.o /Zl gcc: /Zl: No such file or directory In file included from _mysql.c:34: C:/Program Files/MySQL/MySQL Server 5.1/include/config-win.h:160:1: warning: "isnan" redefined In file included from C:/Python26/include/pyport.h:235, from C:/Python26/include/Python.h:58, from pymemcompat.h:10, from _mysql.c:29: C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/math.h:411:1: warning: this is the location of the previous def inition In file included from _mysql.c:34: C:/Program Files/MySQL/MySQL Server 5.1/include/config-win.h:171:1: warning: "SIZEOF_OFF_T" redefined In file included from C:/Python26/include/Python.h:8, from pymemcompat.h:10, from _mysql.c:29: C:/Python26/include/pyconfig.h:361:1: warning: this is the location of the previous definition In file included from _mysql.c:34: C:/Program Files/MySQL/MySQL Server 5.1/include/config-win.h:203:1: warning: "finite" redefined C:/Program Files/MySQL/MySQL Server 5.1/include/config-win.h:161:1: warning: this is the location of the previous definit ion C:/Program Files/MySQL/MySQL Server 5.1/include/config-win.h:269:1: warning: "HAVE_STDDEF_H" redefined In file included from C:/Python26/include/Python.h:8, from pymemcompat.h:10, from _mysql.c:29: C:/Python26/include/pyconfig.h:647:1: warning: this is the location of the previous definition error: command 'gcc' failed with exit status 1 * * * I checked the source code and tried to remove all the errors where it said it was "redefined" but ended up with even more problems. Any ideas what could be wrong? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffpeery at yahoo.com Sat Feb 13 06:37:34 2010 From: jeffpeery at yahoo.com (Jeff Peery) Date: Fri, 12 Feb 2010 21:37:34 -0800 (PST) Subject: [python-win32] permissions error In-Reply-To: <796c415c1002121924v47a09768n38cfd273497c0a7@mail.gmail.com> Message-ID: <844422.4777.qm@web43145.mail.sp1.yahoo.com> hi, yes I can personally do that on my computer but?it is not a good solution for my users to?require an administrator to grant acces every time they want to launch the software. So I will need a more permanent fix. ? Is it a significant task to redirect these files to the application data folder or program data folder? ? thanks, Jeff --- On Fri, 2/12/10, Preston Landers wrote: From: Preston Landers Subject: Re: [python-win32] permissions error To: "Jeff Peery" Date: Friday, February 12, 2010, 7:24 PM Have you tried manually granting a write permission for your user to that directory?? -Preston On Fri, Feb 12, 2010 at 9:08 PM, Jeff Peery wrote: hello, yes, I am using 64 bit vista. and I am using py2exe to distribute my app. At the moment I'm dead in the water unti lI resolve this issue. Does anyone know of a quick fix? ? thanks, Jeff --- On Fri, 2/12/10, Tim Roberts wrote: From: Tim Roberts Subject: Re: [python-win32] permissions error To: "Python-Win32 List" Date: Friday, February 12, 2010, 10:37 AM Dave Angel wrote: > 2) Are you running a 64bit version of Vista? Yes, he is.? The path "Program Files (x86)" is prima facie evidence of this.? He's running 32-bit Python on a 64-bit system.? And that's just fine. > 3) What do you mean by "compile" and "compiled executable"? It means he has used something like "py2exe" to turn his Python code into an executable. This is a real problem, and one that pywin32 probably needs to address. On Vista and beyond, the "Program Files" directories are not writable by non-elevated programs.? The win32com-generated wrappers need to go somewhere else, like "Local Settings\Temp" or "Local Settings\Apps". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffpeery at yahoo.com Sat Feb 13 08:27:19 2010 From: jeffpeery at yahoo.com (Jeff Peery) Date: Fri, 12 Feb 2010 23:27:19 -0800 (PST) Subject: [python-win32] permissions error In-Reply-To: <796c415c1002122230x61734347s8856ba0b03df077e@mail.gmail.com> Message-ID: <700263.80127.qm@web43136.mail.sp1.yahoo.com> Ok thanks, I will look into that. ? I was looking around in the win32com.client.__init__.py and it appears that if I delete the folder win32com.client.gen_py then it is created dynamically in the the user/appdata/temp folder when the program launches. Which is good because the user doesn't need?to be an admin for the app to write in the appdata folder. I tested this by freezing (py2exe)? my app and installed it on my computer and it lauches up and starts running ok. I checked to confirm that the gen_py file was created in the appdata folder and it was. This is good. However I tried to use the features of the app that call win32com.client.DispatchWithEvents and now it crashes with this error: ? Exception exceptions.AttributeError: AttributeError("'' object has no attribute '_olecp'",) in > ignored ? It appears that the win32com client I created doesn't have the attribute '_olecp'. '_olecp' is an attribute in the script within the users/appdata/temp/gen_py folder. Why would I get this error? ? Again with the win32com/client/gen_py folder deleted the cache (is that the correct word?) is created in the appdata/temp/gen_py folder. My UN-frozen App appears to work under this condition and uses the cached file in the appdata/temp/gen_py folder an no longer the win32/client/gen_py folder. I checked by printing a 'hello world' from this file. ? why not the frozen app? ? thank you in advance, Jeff --- On Fri, 2/12/10, Preston Landers wrote: From: Preston Landers Subject: Re: [python-win32] permissions error To: "Jeff Peery" Date: Friday, February 12, 2010, 10:30 PM I don't know if this will work but one workaround may be to set a registry key: HKLM\\SOFTWARE\\Python\\PythonCore\\2.6\\PythonPath\\win32com The key is GenPath and the value would be a writable location.? See win32com/__init__.py SetupEnvironment(). You could also look at pre-generating the files in question with makepy.py and including those in the executable. I don't have much experience with packaging an app into the executable format. -Preston On Fri, Feb 12, 2010 at 11:37 PM, Jeff Peery wrote: hi, yes I can personally do that on my computer but?it is not a good solution for my users to?require an administrator to grant acces every time they want to launch the software. So I will need a more permanent fix. ? Is it a significant task to redirect these files to the application data folder or program data folder? ? thanks, Jeff --- On Fri, 2/12/10, Preston Landers wrote: From: Preston Landers Subject: Re: [python-win32] permissions error To: "Jeff Peery" Date: Friday, February 12, 2010, 7:24 PM Have you tried manually granting a write permission for your user to that directory?? -Preston On Fri, Feb 12, 2010 at 9:08 PM, Jeff Peery wrote: hello, yes, I am using 64 bit vista. and I am using py2exe to distribute my app. At the moment I'm dead in the water unti lI resolve this issue. Does anyone know of a quick fix? ? thanks, Jeff --- On Fri, 2/12/10, Tim Roberts wrote: From: Tim Roberts Subject: Re: [python-win32] permissions error To: "Python-Win32 List" Date: Friday, February 12, 2010, 10:37 AM Dave Angel wrote: > 2) Are you running a 64bit version of Vista? Yes, he is.? The path "Program Files (x86)" is prima facie evidence of this.? He's running 32-bit Python on a 64-bit system.? And that's just fine. > 3) What do you mean by "compile" and "compiled executable"? It means he has used something like "py2exe" to turn his Python code into an executable. This is a real problem, and one that pywin32 probably needs to address. On Vista and beyond, the "Program Files" directories are not writable by non-elevated programs.? The win32com-generated wrappers need to go somewhere else, like "Local Settings\Temp" or "Local Settings\Apps". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From cournape at gmail.com Sat Feb 13 09:27:55 2010 From: cournape at gmail.com (David Cournapeau) Date: Sat, 13 Feb 2010 17:27:55 +0900 Subject: [python-win32] Compile error on MySQL-Python with Mingw (python 2.6) In-Reply-To: References: Message-ID: <5b8d13221002130027y7eb731c4k786e99992c11afd7@mail.gmail.com> On Sat, Feb 13, 2010 at 1:32 PM, Glen Zangirolami wrote: > I checked the source code and tried to remove all the errors where it said > it was "redefined" but ended up with even more problems. > Any ideas what could be wrong? I don't know how to solve your exact problem, but the root of the problem seems to be the inclusion of VIsual Studio specific flag (/Zq), not the warnings. cheers, David From lynton.grice at logosworld.com Sat Feb 13 10:58:29 2010 From: lynton.grice at logosworld.com (Lynton Grice) Date: Sat, 13 Feb 2010 11:58:29 +0200 Subject: [python-win32] install_requires 'pywin32' problem? Message-ID: <000001caac93$1b11ecd0$5135c670$@grice@logosworld.com> Hey there, I hope someone can help me ;-) I have added "pywin32" as a dependency for a small library I created, but when it tries to download the "PYWIN32" dependency it dies Processing dependencies for LogosQueue==1.0.0 Searching for pywin32 Reading http://pypi.python.org/simple/pywin32/ Reading http://sf.net/projects/pywin32 Reading http://sourceforge.net/project/showfiles.php?group_id=78018 No local packages or download links found for pywin32 error: Could not find suitable distribution for Requirement.parse('pywin32') I have the latest version of "setuptools" installed, just scratching my head as to what could be wrong here? Any ideas? Lynton -------------- next part -------------- An HTML attachment was scrubbed... URL: From davea at ieee.org Sat Feb 13 12:52:16 2010 From: davea at ieee.org (Dave Angel) Date: Sat, 13 Feb 2010 06:52:16 -0500 Subject: [python-win32] MemoryError: can I use more? In-Reply-To: <4B75F939.3000603@ata-e.com> References: <2E95F75EDC25D54999387A1E2E6EF6274378DA2BA1@MBX02.cgcent.miami.edu> <4B75F939.3000603@ata-e.com> Message-ID: <4B769270.4000306@ieee.org> Greg Antal wrote: >
Dear > Angelica: > > 2.2 GB is essentially the largest integer you express with 32 bits > (2^31), and therefore the largest quantity of memory for which you can > define an address. There are some tricks that really sophisticated > programmers can do that let you use more than that, but I don't know > how to do it. If you want to access more memory, you have to go to a > 64-bit machine and operating system. > > - Greg Antal > > Gregory W. Antal > Senior Technical Advisor > ATA Engineering, Inc. > 11995 El Camino Real, Suite 200 > San Diego, CA 92130 > www.ata-e.com > > greg.antal at ata-e.com > 858-480-2072 (Phone) > 858-792-8932 (Fax) > > > > Echavarria Gregory, Maria Angelica wrote, On 2/12/2010 4:22 PM: >> Dear group: >> >> I am developing a program using Python 2.5.4 in windows 32 OS. The >> amount of data it works with is huge. I have managed to keep memory >> footprint low, but have found that, independent of the physical RAM >> of the machine, python always gives the MemoryError message when it >> has occupied exactly only 2.2 GB. I have tested this in 4 different >> machines, all with memory of 3 to 4 GB... I'm amazed. >> >> Could any of you please help me to figure out how to change that >> limit? I typed help(MemoryError) and it is a class itself, but that >> help told me nothing I can use... >> >> Thanks, >> Angelica. >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> > > It has little to do with physical RAM. You'd hit the same limits with 1gb of physical RAM, as long as you had a large enough swap file. There are two limits on an individual application, the amount of swap space, and the amount of address space. Swap space management depends on which "windows 32 OS" you're running, and how you have it configured. I will have to assume you mean one of Windows XP, Windows Vista, or Windows 7. And that swap space is shared among all the applications currently running. But I expect you're bumping into a virtual address space limitation. Even if you could have a 50gb swapfile, that would raise the number of large applications you could run (very slowly), but not the size of any one application. Your address space is 32 bits, or 4 gigabytes. Every pointer in your program, or in the system has to point to a unique place, so there are only 4 gigabytes of virtual space. By default Windows reserves the upper half of that for system DLL's, device stuff, and working space. It also reserves the bottom meg or so for mostly historical reasons, and to catch null pointer errors. So you only get 2gig of space for each process. Two ways of extending that. There's something called PAE (and AWE ), which allows you to read and write things "above" 4gb, but I don't know anything about how it may be accessible from Python. Certainly you couldn't store ordinary python objects there. Think of it as a (probably) fast disk partition with special read/write methods. But the one you might want is a boot.ini option that tells the OS to only reserve 1gb for itself, and leave 3gb for user space. But there are tradeoffs, including the need to modify an application's executable to take advantage of it. And the whole system may run substantially slower, even when your're extended app isn't running. See links: http://www.microsoft.com/whdc/system/platform/server/PAE/PAEmem.mspx http://blogs.technet.com/askperf/archive/2007/03/23/memory-management-demystifying-3gb.aspx Bottom line? If you really need more than 2gig of user space, probably you should go to a 64 bit OS. DaveA From mail at timgolden.me.uk Sat Feb 13 13:32:50 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Sat, 13 Feb 2010 12:32:50 +0000 Subject: [python-win32] USB Insertion Extrinsic Event exists? In-Reply-To: <12087451.251265993937190.JavaMail.chris@jesse1c-laptop> References: <12087451.251265993937190.JavaMail.chris@jesse1c-laptop> Message-ID: <4B769BF2.3040902@timgolden.me.uk> On 12/02/2010 16:58, Chris Jesse wrote: > So it turns out that my description of the task was lacking in one > simple, but critical, observation. We use removable media, usually a compact > flash card, plugged into a USB adapter drive. The events get triggered for > my pen drive, but when the compact flash card is inserted I get nothing - > probably because the device is already plugged in. OK; just tried it and I see what you mean. In my case, I'm using one of those card readers with four different-sized slots. It "pre-registers" as four drives so you don't get any further device change events. (I assume this is comparable to what you're doing...) All I can suggest is that you watch the Win32_DiskDrive instances with an InterfaceType of "USB" for a modification event and check whether the MediaLoaded has changed. Something like this: import wmi c = wmi.WMI () watcher = c.Win32_DiskDrive.watch_for (InterfaceType="USB") while True: try: disk = watcher (timeout_ms=10000) print disk except wmi.x_wmi_timed_out: pass If you know which device id will always be firing (eg the only slot I can use is PHYSICALDEVICE3 then you can build that into the query. > There's an interesting document attached which shows some potential >C++ code; but I'm in a little out of my depth here - "help"! About half of that is basically the code I posted here: http://local.timgolden.me.uk/python/win32_how_do_i/detect-device-insertion.html The other half deals with the case where you want to use this sort of technique but where you're in a service or otherwise don't have a top-level window. If the WMI stuff doesn't work for you and you need this kind of thing (and don't have/want a top-level window) then we can try to run something up on the basis of the article. TJG From aahz at pythoncraft.com Sat Feb 13 15:28:34 2010 From: aahz at pythoncraft.com (Aahz) Date: Sat, 13 Feb 2010 06:28:34 -0800 Subject: [python-win32] USB Insertion Extrinsic Event exists? In-Reply-To: <4B769BF2.3040902@timgolden.me.uk> References: <12087451.251265993937190.JavaMail.chris@jesse1c-laptop> <4B769BF2.3040902@timgolden.me.uk> Message-ID: <20100213142834.GA21746@panix.com> On Sat, Feb 13, 2010, Tim Golden wrote: > On 12/02/2010 16:58, Chris Jesse wrote: >> >> There's an interesting document attached which shows some potential >> C++ code; but I'm in a little out of my depth here - "help"! > > About half of that is basically the code I posted here: > > http://local.timgolden.me.uk/python/win32_how_do_i/detect-device-insertion.html > > The other half deals with the case where you want to use this sort > of technique but where you're in a service or otherwise don't have a > top-level window. If the WMI stuff doesn't work for you and you need > this kind of thing (and don't have/want a top-level window) then we > can try to run something up on the basis of the article. That's definitely true for my company (running as a service), so if it's not too much trouble for you, we'd definitely appreciate it. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "At Resolver we've found it useful to short-circuit any doubt and just refer to comments in code as 'lies'. :-)" From jeffpeery at yahoo.com Sat Feb 13 18:43:22 2010 From: jeffpeery at yahoo.com (Jeff Peery) Date: Sat, 13 Feb 2010 09:43:22 -0800 (PST) Subject: [python-win32] permissions error In-Reply-To: <796c415c1002122230x61734347s8856ba0b03df077e@mail.gmail.com> Message-ID: <9621.31243.qm@web43132.mail.sp1.yahoo.com> It works! ? FYI - the trick was to remove the gen_py folder from the win32com/client directory. Then I was also not including win32com in the 'packages' option in my setup.py. Including this solved my issues. I can now install on a machine and win32com will create the gen_py files in the appdata folder. ? thanks for those who offered advice, Jeff --- On Fri, 2/12/10, Preston Landers wrote: From: Preston Landers Subject: Re: [python-win32] permissions error To: "Jeff Peery" Date: Friday, February 12, 2010, 10:30 PM I don't know if this will work but one workaround may be to set a registry key: HKLM\\SOFTWARE\\Python\\PythonCore\\2.6\\PythonPath\\win32com The key is GenPath and the value would be a writable location.? See win32com/__init__.py SetupEnvironment(). You could also look at pre-generating the files in question with makepy.py and including those in the executable. I don't have much experience with packaging an app into the executable format. -Preston On Fri, Feb 12, 2010 at 11:37 PM, Jeff Peery wrote: hi, yes I can personally do that on my computer but?it is not a good solution for my users to?require an administrator to grant acces every time they want to launch the software. So I will need a more permanent fix. ? Is it a significant task to redirect these files to the application data folder or program data folder? ? thanks, Jeff --- On Fri, 2/12/10, Preston Landers wrote: From: Preston Landers Subject: Re: [python-win32] permissions error To: "Jeff Peery" Date: Friday, February 12, 2010, 7:24 PM Have you tried manually granting a write permission for your user to that directory?? -Preston On Fri, Feb 12, 2010 at 9:08 PM, Jeff Peery wrote: hello, yes, I am using 64 bit vista. and I am using py2exe to distribute my app. At the moment I'm dead in the water unti lI resolve this issue. Does anyone know of a quick fix? ? thanks, Jeff --- On Fri, 2/12/10, Tim Roberts wrote: From: Tim Roberts Subject: Re: [python-win32] permissions error To: "Python-Win32 List" Date: Friday, February 12, 2010, 10:37 AM Dave Angel wrote: > 2) Are you running a 64bit version of Vista? Yes, he is.? The path "Program Files (x86)" is prima facie evidence of this.? He's running 32-bit Python on a 64-bit system.? And that's just fine. > 3) What do you mean by "compile" and "compiled executable"? It means he has used something like "py2exe" to turn his Python code into an executable. This is a real problem, and one that pywin32 probably needs to address. On Vista and beyond, the "Program Files" directories are not writable by non-elevated programs.? The win32com-generated wrappers need to go somewhere else, like "Local Settings\Temp" or "Local Settings\Apps". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From glenbot at gmail.com Sun Feb 14 01:52:55 2010 From: glenbot at gmail.com (Glen Zangirolami) Date: Sat, 13 Feb 2010 18:52:55 -0600 Subject: [python-win32] Compile error on MySQL-Python with Mingw (python 2.6) In-Reply-To: <5b8d13221002130027y7eb731c4k786e99992c11afd7@mail.gmail.com> References: <5b8d13221002130027y7eb731c4k786e99992c11afd7@mail.gmail.com> Message-ID: > > VIsual Studio specific flag > (/Zq), not the warnings. I didn't see a flag for /Zq but I did see a flag /Zl. I removed it and it still throws the errors. I'll keep tryin'. Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Sun Feb 14 04:31:34 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sun, 14 Feb 2010 14:31:34 +1100 Subject: [python-win32] permissions error In-Reply-To: <424347.83600.qm@web43143.mail.sp1.yahoo.com> References: <424347.83600.qm@web43143.mail.sp1.yahoo.com> Message-ID: <4B776E96.6090505@gmail.com> On 12/02/2010 4:32 PM, Jeff Peery wrote: > Hello, > I'm running on vista and I'm getting a permissions error from win32com. > I attached a print screen displaying the error message. It appears > win32com is trying to write a file and vista UAC is blocking it. Why is > win32com trying to do this and how do I fix it? the only method I am > using from win32com is "win32com.client.DispatchWithEvents()" to create > a client of a windows OPC server. It works fine until I compile it and > run it from the compiled executable and this message appears. > thanks, > Jeff There are 2 general solutions to this: * Follow the instructions at http://www.py2exe.org/index.cgi/IncludingTypelibs to allow py2exe to include the pre-generated version of the makepy files you need at runtime. This saves work on each installed PC, and also avoids needing to have the typelibs included on each target PC (the usually will be available, but depending on a number of things, may not be) * Tell py2exe to avoid including anything in the win32com\gen_py folder. If no such folder exists as win32com initializes, it will use a folder under %TEMP% for this purpose - but if it does exist - even inside a read-only .zip file or in a read-only directory - it blindly tries to use it. As you are seeing, this will fail for stuff installed under "Program Files" - you need elevated permissions to write there. The first is the best general option - you don't have to rely on writing anything anywhere to achieve something which works (but it isn't clear you are using py2exe - so while that specific advice may not be applicable, the general idea is (ie, ship with a pre-populated win32com\gen_py folder) HTH, Mark From mail at timgolden.me.uk Sun Feb 14 10:41:01 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 14 Feb 2010 09:41:01 +0000 Subject: [python-win32] USB Insertion Extrinsic Event exists? In-Reply-To: <20100213142834.GA21746@panix.com> References: <12087451.251265993937190.JavaMail.chris@jesse1c-laptop> <4B769BF2.3040902@timgolden.me.uk> <20100213142834.GA21746@panix.com> Message-ID: <4B77C52D.6070406@timgolden.me.uk> On 13/02/2010 14:28, Aahz wrote: > On Sat, Feb 13, 2010, Tim Golden wrote: >> The other half deals with the case where you want to use this sort >> of technique but where you're in a service or otherwise don't have a >> top-level window. If the WMI stuff doesn't work for you and you need >> this kind of thing (and don't have/want a top-level window) then we >> can try to run something up on the basis of the article. > > That's definitely true for my company (running as a service), so if it's > not too much trouble for you, we'd definitely appreciate it. Just realised that pywin32 ships with an example of this. From my site-packages directory: win32\Demos\service\serviceEvents.py I haven't had the chance to try it out, but let is know if it does meet your case. TJG From glenbot at gmail.com Sun Feb 14 18:30:00 2010 From: glenbot at gmail.com (Glen Zangirolami) Date: Sun, 14 Feb 2010 11:30:00 -0600 Subject: [python-win32] Compile error on MySQL-Python with Mingw (python 2.6) In-Reply-To: References: <5b8d13221002130027y7eb731c4k786e99992c11afd7@mail.gmail.com> Message-ID: I ended up just installing Visual C++ 2008 and compiling it with --compile=msvc Worked perfect. Thanks for the help. On Sat, Feb 13, 2010 at 6:52 PM, Glen Zangirolami wrote: > VIsual Studio specific flag >> (/Zq), not the warnings. > > > I didn't see a flag for /Zq but I did see a flag /Zl. > I removed it and it still throws the errors. I'll keep tryin'. Thanks! > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ah.kode at gmail.com Mon Feb 15 10:25:59 2010 From: ah.kode at gmail.com (a h) Date: Mon, 15 Feb 2010 14:55:59 +0530 Subject: [python-win32] passing c structure into python function In-Reply-To: <4B4E1268.4040203@probo.com> References: <4B4E1268.4040203@probo.com> Message-ID: Hi thnks. i have used struct.unpack function for small c structure as the way Tim has suggested. i have an complex C structure, and passing this structure as a string and then using struct.unpack() is very tough job.and also i have pointers in my struct now. i want that i have structure say like struct emp { int id; ... { and i just pass this into python function by converting c structure into python PyObject and using PyObject_CallObject() i can pass this pyobject. In python script i want that i can simply print these values like def func(s): print s.id Is it possible to do this way?. and i dont know how to convert C structure into python object(PyObject). Please help me how do i achieve this thanks ah On Thu, Jan 14, 2010 at 12:05 AM, Tim Roberts wrote: > a h wrote: > > > > thanks for your response > > in the last piece of c code i want to know how do i pass structure > > into python function in c. I have tried to call a python function > > which takes string as parameter. > > > > i have passed string parameter as : > > const char *str_pArgs = "hello"; > > pArgs = PyTuple_New(1); > > pValue = PyString_FromString(str_pArgs); > > PyTuple_SetItem(pArgs, 0,pValue); > > pValue = PyObject_CallObject(pFunc, pArgs); > > > > similarly how do i convert this structure for python function argument. > > > > ->pArgs = e //******************logic to assign struct employee into > pArgs > > There are several ways to do this. If it were me, looking for the easy > way, I would just pass the structure as a string (by casting the address > of the struct to a (char *)), and unpack it with struct.unpack, as I > showed earlier. > > There are many other ways, however. You could create a tuple from the > struct elements, and pass the elements in their native types. You could > even go to the trouble of creating a dict or an object in your C code, > populate it, and return it. It depends on how often this will be used > and who is your audience. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From le.dahut at laposte.net Mon Feb 15 14:30:54 2010 From: le.dahut at laposte.net (le dahut) Date: Mon, 15 Feb 2010 14:30:54 +0100 Subject: [python-win32] pywin32 documentation wiki Message-ID: <4B794C8E.1070708@laposte.net> Hello, I've made some development around Windows services and logon events detection (using SCM and using SENS). I've spend a lot of time discovering how things work and trying to write them (with great help from people on this list !) I think that people may be interested by some examples and I would like to know : is there a place where I can write them ? From mail at timgolden.me.uk Mon Feb 15 14:59:55 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 15 Feb 2010 13:59:55 +0000 Subject: [python-win32] pywin32 documentation wiki In-Reply-To: <4B794C8E.1070708@laposte.net> References: <4B794C8E.1070708@laposte.net> Message-ID: <4B79535B.5050501@timgolden.me.uk> On 15/02/2010 13:30, le dahut wrote: > Hello, > > I've made some development around Windows services and logon events > detection (using SCM and using SENS). I've spend a lot of time > discovering how things work and trying to write them (with great help > from people on this list !) > > I think that people may be interested by some examples and I would like > to know : is there a place where I can write them ? We've kind of tried before and: not really. There's nothing to stop them going on the Python Wiki. For some reason I rarely go there myself, but I imagine people do, and at least it's Googleable under "site:python.org". I tend to put things on my own site (timgolden.me.uk/python) or to post them to my blog. Having seen the stuff you've been doing, I'd be very keen to see a write-up and examples. I'm perfectly happy to chuck them up on my site if you find no better place, but it's a manually-maintained set of static HTML so perhaps not the best... Wherever you end up putting them, I'm certainly ready to add a link to my "How-Do-I?" series to point there. Or start something new and see if it flies. TJG From ron.arts at neonova.nl Mon Feb 15 16:59:49 2010 From: ron.arts at neonova.nl (Ron Arts) Date: Mon, 15 Feb 2010 16:59:49 +0100 Subject: [python-win32] pywin32 documentation wiki In-Reply-To: <4B79535B.5050501@timgolden.me.uk> References: <4B794C8E.1070708@laposte.net> <4B79535B.5050501@timgolden.me.uk> Message-ID: <4B796F75.3070808@neonova.nl> Op 15-02-10 14:59, Tim Golden schreef: > On 15/02/2010 13:30, le dahut wrote: >> Hello, >> >> I've made some development around Windows services and logon events >> detection (using SCM and using SENS). I've spend a lot of time >> discovering how things work and trying to write them (with great help >> from people on this list !) >> >> I think that people may be interested by some examples and I would like >> to know : is there a place where I can write them ? > > We've kind of tried before and: not really. > > There's nothing to stop them going on the Python Wiki. For some > reason I rarely go there myself, but I imagine people do, and > at least it's Googleable under "site:python.org". > Yes, please put it on the Wiki. I'm pretty interested myself ;-) Ron -- NeoNova BV innovatieve internetoplossingen http://www.neonova.nl Science Park 140 1098 XG Amsterdam info: 020-5611300 servicedesk: 020-5611302 fax: 020-5611301 KvK Amsterdam 34151241 Op dit bericht is de volgende disclaimer van toepassing: http://www.neonova.nl/maildisclaimer From mail at timgolden.me.uk Mon Feb 15 17:09:06 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 15 Feb 2010 16:09:06 +0000 Subject: [python-win32] USB Insertion Extrinsic Event exists? In-Reply-To: <4B77C52D.6070406@timgolden.me.uk> References: <12087451.251265993937190.JavaMail.chris@jesse1c-laptop> <4B769BF2.3040902@timgolden.me.uk> <20100213142834.GA21746@panix.com> <4B77C52D.6070406@timgolden.me.uk> Message-ID: <4B7971A2.3030809@timgolden.me.uk> On 14/02/2010 09:41, Tim Golden wrote: > Just realised that pywin32 ships with an example of this. > From my site-packages directory: > > win32\Demos\service\serviceEvents.py > > I haven't had the chance to try it out, but let is know if it does > meet your case. Well I've given it a go and, naturally, it works ok. Except... As documented(ish) (look under Remarks): http://msdn.microsoft.com/en-us/library/aa363431%28VS.85%29.aspx It'll only handle DBT_DEVTYP_DEVICEINTERFACE or DBT_DEVTYP_HANDLE That wouldn't matter too much since the device interface event returns the name of the volume, which one can use to good effect. Except... The pywin32gui_struct library which parses the stuff coming back from the events assumes that the string is NUL-terminated. But it's a UTF16 Unicode string so it's "nul-terminated" after the first byte. I'll raise this as a bug on the pywin32 tracker, but meanwhile I'll try to get an example which works around it by parsing the header manually, as per the windows message example. Or I could monkey-patch the win32gui_struct module. Might be easier. TJG From mail at timgolden.me.uk Mon Feb 15 18:30:22 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 15 Feb 2010 17:30:22 +0000 Subject: [python-win32] USB Insertion Extrinsic Event exists? In-Reply-To: <4B7971A2.3030809@timgolden.me.uk> References: <12087451.251265993937190.JavaMail.chris@jesse1c-laptop> <4B769BF2.3040902@timgolden.me.uk> <20100213142834.GA21746@panix.com> <4B77C52D.6070406@timgolden.me.uk> <4B7971A2.3030809@timgolden.me.uk> Message-ID: <4B7984AE.1010901@timgolden.me.uk> OK; now added the service-based example to: http://timgolden.me.uk/python/win32_how_do_i/detect-device-insertion.html TJG From rsyring at inteli-com.com Mon Feb 15 20:07:58 2010 From: rsyring at inteli-com.com (Randy Syring) Date: Mon, 15 Feb 2010 14:07:58 -0500 Subject: [python-win32] Calling random Windows function? In-Reply-To: References: Message-ID: <4B799B8E.5040801@inteli-com.com> Roger Upole wrote: > > If you decide to use Volume Shadow Copy, I've wrapped some of the > IVss* interfaces for Python, enough to be able to backup selected files > from a volume. Bear in mind that if an application has a file open for > writing and is not VSS-aware, you may get the file in an inconsistent > state. > > Roger > Roger, Could you share that code or point me to a location where I could take a look at it? I would like to extend rdiff-backup to use VSS via a Python script and figure it would be better to just manage the volumes directly from Python if possible than to try and use command line tools. Thanks. -------------------------------------- Randy Syring Intelicom 502-644-4776 "Whether, then, you eat or drink or whatever you do, do all to the glory of God." 1 Cor 10:31 From timr at probo.com Mon Feb 15 23:14:55 2010 From: timr at probo.com (Tim Roberts) Date: Mon, 15 Feb 2010 14:14:55 -0800 Subject: [python-win32] passing c structure into python function In-Reply-To: References: <4B4E1268.4040203@probo.com> Message-ID: <4B79C75F.6010901@probo.com> a h wrote: > > thnks. i have used struct.unpack function for small c structure as the > way Tim has suggested. > i have an complex C structure, and passing this structure as a string > and then using struct.unpack() is very tough job.and also i have > pointers in my struct now. > > i want that i have structure say like > struct emp > { > int id; > ... > { > and i just pass this into python function by converting c structure > into python PyObject and using PyObject_CallObject() i can pass this > pyobject. > > In python script i want that i can simply print these values like > def func(s): > print s.id > > Is it possible to do this way?. Yes, it's possible to create an object in your C code, then add attributes to it one by one to match your structure, but the code to do so is rather tedious. In my opinion -- and it is only my opinion! -- you're better off using a Python wrapper to create and populate the object. Have you encountered the "swig" library? Swig can read C header files, and generate C and Python code that exposes the structures and function calls to Python. If you need to do this a lot, it might be worthwhile to learn about it. It is a difficult tool to learn, but once you get it, it's incredibly handy. Much of PyWin32 is automatically generated by swig (with careful tweaking). http://www.swig.org/Doc1.3/Python.html -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Andrew.MacIntyre at acma.gov.au Tue Feb 16 01:24:32 2010 From: Andrew.MacIntyre at acma.gov.au (Andrew MacIntyre) Date: Tue, 16 Feb 2010 11:24:32 +1100 Subject: [python-win32] passing c structure into python function [SEC=PERSONAL] In-Reply-To: <4B79C75F.6010901@probo.com> References: <4B4E1268.4040203@probo.com> <4B79C75F.6010901@probo.com> Message-ID: <7B01D7143C4AD54899EA079D4557562AFEF940@ACT01EXC02.internal.govt> > On Behalf Of Tim Roberts > > a h wrote: > > > > thnks. i have used struct.unpack function for small c structure as the > > way Tim has suggested. > > i have an complex C structure, and passing this structure as a string > > and then using struct.unpack() is very tough job.and also i have > > pointers in my struct now. > > > > i want that i have structure say like > > struct emp > > { > > int id; > > ... > > { > > and i just pass this into python function by converting c structure > > into python PyObject and using PyObject_CallObject() i can pass this > > pyobject. > > > > In python script i want that i can simply print these values like > > def func(s): > > print s.id > > > > Is it possible to do this way?. > > Yes, it's possible to create an object in your C code, then add > attributes to it one by one to match your structure, but the code to do > so is rather tedious. In my opinion -- and it is only my opinion! -- > you're better off using a Python wrapper to create and populate the object. > > Have you encountered the "swig" library? Swig can read C header files, > and generate C and Python code that exposes the structures and function > calls to Python. If you need to do this a lot, it might be worthwhile > to learn about it. It is a difficult tool to learn, but once you get > it, it's incredibly handy. Much of PyWin32 is automatically generated > by swig (with careful tweaking). > > http://www.swig.org/Doc1.3/Python.html Pyrex and Cython might also be useful alternatives for the OP's purpose. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre Operations Branch tel: +61 2 6219 5356 Communications Infrastructure Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: andrew.macintyre at acma.gov.au http://www.acma.gov.au/ If you have received this email in error, please notify the sender immediately and erase all copies of the email and any attachments to it. The information contained in this email and any attachments may be private, confidential and legally privileged or the subject of copyright. If you are not the addressee it may be illegal to review, disclose, use, forward, or distribute this email and/or its contents. Unless otherwise specified, the information in the email and any attachments is intended as a guide only and should not be relied upon as legal or technical advice or regarded as a substitute for legal or technical advice in individual cases. Opinions contained in this email or any of its attachments do not necessarily reflect the opinions of ACMA. From rwupole at msn.com Wed Feb 17 03:32:24 2010 From: rwupole at msn.com (Roger Upole) Date: Tue, 16 Feb 2010 21:32:24 -0500 Subject: [python-win32] Calling random Windows function? Message-ID: Randy Syring wrote: > Roger Upole wrote: >> >> If you decide to use Volume Shadow Copy, I've wrapped some of the >> IVss* interfaces for Python, enough to be able to backup selected files >> from a volume. Bear in mind that if an application has a file open for >> writing and is not VSS-aware, you may get the file in an inconsistent >> state. >> >> Roger >> > Roger, > > Could you share that code or point me to a location where I could take a > look at it? I would like to extend rdiff-backup to use VSS via a Python > script and figure it would be better to just manage the volumes directly > from Python if possible than to try and use command line tools. > > Thanks. > Souce and binaries (Python 3.1, 32-bit, XP) are attached. If you compile yourself, note that it needs to be built separately for WinXP due to changes in the interface layout. Roger -------------- next part -------------- A non-text attachment was scrubbed... Name: vsbackup_31.zip Type: application/octet-stream Size: 64083 bytes Desc: not available URL: From eduan at multenet.com Wed Feb 17 15:01:28 2010 From: eduan at multenet.com (Eduan Basson) Date: Wed, 17 Feb 2010 16:01:28 +0200 Subject: [python-win32] win32ras.Dial() timing out on Windows 7 Message-ID: <4B7BF6B8.4000500@multenet.com> Hi I'm experiencing problems with the win32ras.Dial() function in python, as installed with Activestate ActivePython 2.6.4.10-win32-x86. The behaviour is: 1. On Windows 2000 and XP, function works as expected, returning with a 0 errorcode as soon as the dial-up connection is made. 2. On Windows Vista and an un-updated copy of Windows 7RC1, the connection is made (as can be seen on the flashing LEDs on my modem and the ipconfig command), but the Windows API takes almost 40 seconds to realise this, which only then returns a 0 errorcode. 3. On that same Windows 7RC1, after running an update, as well as on a full Windows 7 installation, the connection is made (again according to the flashing LEDs on the modem and the ipconfig command), but after 60 seconds win32ras.Dial() still hasn't returned. If I send a win32ras.HangUp(), Dial returns with error 621, which is to be expected if you interrupt a Dial command. Has anybody else experienced something similar? Or does anybody use win32ras.Dial under Windows 7 without issues? Is there any known bug related to this? Thank you -- *Eduan Basson* From le.dahut at laposte.net Wed Feb 17 19:07:00 2010 From: le.dahut at laposte.net (le dahut) Date: Wed, 17 Feb 2010 19:07:00 +0100 Subject: [python-win32] pywin32 documentation wiki In-Reply-To: <4B794C8E.1070708@laposte.net> References: <4B794C8E.1070708@laposte.net> Message-ID: <4B7C3044.6070406@laposte.net> Hi, I've joined a file containing : * mytestservice_handlerex.py and : * mytestservice_isenslogon.py * isenslogon.py You can install them with command line (python.exe must be in your %PATH%) : 'mytestservice_isenslogon.py --interactive --startup=auto install' or 'mytestservice_handlerex.py --interactive --startup=auto install' Be aware that those 2 methods are asynchronous. This means that user may have its desktop (taskbar, etc.) ready while the service doesn't have finish its logon() method. For example, I use it to tune user environment (hide drives, disable control panel, etc.). After that explorer.exe must be killed and restarted for changes to take effect. A better way could be to modify userinit reg key to make it call an app that waits for the service to achieve its work and only then execute userinit.exe : HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\UserInit Tim, maybe you want to copy/paste those files and comments on your website ? Ron, I hope this will help you. Cheers, Klaas le dahut wrote : > > Hello, > > I've made some development around Windows services and logon events > detection (using SCM and using SENS). I've spend a lot of time > discovering how things work and trying to write them (with great help > from people on this list !) > > I think that people may be interested by some examples and I would like > to know : is there a place where I can write them ? > > From le.dahut at laposte.net Wed Feb 17 19:08:12 2010 From: le.dahut at laposte.net (le dahut) Date: Wed, 17 Feb 2010 19:08:12 +0100 Subject: [python-win32] pywin32 documentation wiki In-Reply-To: <4B7C3044.6070406@laposte.net> References: <4B794C8E.1070708@laposte.net> <4B7C3044.6070406@laposte.net> Message-ID: <4B7C308C.4060101@laposte.net> Oops, the file ... le dahut wrote : > Hi, > > I've joined a file containing : > * mytestservice_handlerex.py > and : > * mytestservice_isenslogon.py > * isenslogon.py > > You can install them with command line (python.exe must be in your > %PATH%) : > 'mytestservice_isenslogon.py --interactive --startup=auto install' > or > 'mytestservice_handlerex.py --interactive --startup=auto install' > > Be aware that those 2 methods are asynchronous. This means that user may > have its desktop (taskbar, etc.) ready while the service doesn't have > finish its logon() method. > > For example, I use it to tune user environment (hide drives, disable > control panel, etc.). After that explorer.exe must be killed and > restarted for changes to take effect. > > A better way could be to modify userinit reg key to make it call an app > that waits for the service to achieve its work and only then execute > userinit.exe : > HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\UserInit > > > > Tim, maybe you want to copy/paste those files and comments on your > website ? > > Ron, I hope this will help you. > > > > Cheers, > Klaas > > > > le dahut wrote : >> >> Hello, >> >> I've made some development around Windows services and logon events >> detection (using SCM and using SENS). I've spend a lot of time >> discovering how things work and trying to write them (with great help >> from people on this list !) >> >> I think that people may be interested by some examples and I would >> like to know : is there a place where I can write them ? >> >> > -------------- next part -------------- A non-text attachment was scrubbed... Name: session_event_demo_services.zip Type: application/x-zip-compressed Size: 4505 bytes Desc: not available URL: From Gregory.Roberts at usmint.treas.gov Wed Feb 17 20:00:23 2010 From: Gregory.Roberts at usmint.treas.gov (Roberts, Gregory (Contractor)) Date: Wed, 17 Feb 2010 14:00:23 -0500 Subject: [python-win32] Python Automation Question Message-ID: <2ABF676708495B4AB7162B8C1BC6185A04627803@WDCEXG06.usmint.etreas.gov> All, I hope this is the proper method of searching for help. Please excuse my etiquette if not correct. I maintain python automation scripts which are currently under development for generating ~15 excel reports each day and running macros on them, emailing, archiving, etc. The automation runs on a VM and is working smoothly except for with one report. It requires that the default printer on the VM is set to print to PDF and I am unsure of how to go about this. I have inherited the code after essentially writing the requirements and am excited to begin coding in Python. I would prefer not to have to contact the initial developer if at all possible and use this as a learning experience since again, I am maintaining the automation scripts. Any assistance would be extremely valuable. Cheers! -Greg -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Feb 17 23:43:20 2010 From: timr at probo.com (Tim Roberts) Date: Wed, 17 Feb 2010 14:43:20 -0800 Subject: [python-win32] Python Automation Question In-Reply-To: <2ABF676708495B4AB7162B8C1BC6185A04627803@WDCEXG06.usmint.etreas.gov> References: <2ABF676708495B4AB7162B8C1BC6185A04627803@WDCEXG06.usmint.etreas.gov> Message-ID: <4B7C7108.20600@probo.com> Roberts, Gregory (Contractor) wrote: > > The automation runs on a VM and is working smoothly except for with > one report. It requires that the default printer on the VM is set to > print to PDF and I am unsure of how to go about this. I have > inherited the code after essentially writing the requirements and am > excited to begin coding in Python. I would prefer not to have to > contact the initial developer if at all possible and use this as a > learning experience since again, I am maintaining the automation scripts. Well, at the risk of being flippant, it seems to me that the right thing to do is to change the default printer to print to PDF. By hand. Assuming you have Acrobat installed, go into Settings, Printers and Faxes, right-click on Adobe PDF and select "Set as Default Printer". It would be very unfriendly for you to have your script change the default printer. Users do not expect that. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From steven.james at gmail.com Thu Feb 18 03:48:30 2010 From: steven.james at gmail.com (Steven James) Date: Wed, 17 Feb 2010 21:48:30 -0500 Subject: [python-win32] Python Automation Question In-Reply-To: <4B7C7108.20600@probo.com> References: <2ABF676708495B4AB7162B8C1BC6185A04627803@WDCEXG06.usmint.etreas.gov> <4B7C7108.20600@probo.com> Message-ID: PDFCreator has a COM API...might be able to solve your problem a different way. If user-friendliness does not matter, try this knowledge base article: http://support.microsoft.com/kb/156212 It describes how to change the default printer (per user) through a registry setting. SJ On Wed, Feb 17, 2010 at 5:43 PM, Tim Roberts wrote: > Roberts, Gregory (Contractor) wrote: > > > > The automation runs on a VM and is working smoothly except for with > > one report. It requires that the default printer on the VM is set to > > print to PDF and I am unsure of how to go about this. I have > > inherited the code after essentially writing the requirements and am > > excited to begin coding in Python. I would prefer not to have to > > contact the initial developer if at all possible and use this as a > > learning experience since again, I am maintaining the automation scripts. > > Well, at the risk of being flippant, it seems to me that the right thing > to do is to change the default printer to print to PDF. By hand. > > Assuming you have Acrobat installed, go into Settings, Printers and > Faxes, right-click on Adobe PDF and select "Set as Default Printer". > > It would be very unfriendly for you to have your script change the > default printer. Users do not expect that. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mc at mclaveau.com Thu Feb 18 11:43:16 2010 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 18 Feb 2010 11:43:16 +0100 Subject: [python-win32] win32gui and SysListView32 Message-ID: Hi! I use a SysListView32 in a Window, for show a list of lists. It is very good, but I have two questions : - The size is limited to 9999 lines ; how define more? - I did not found how define alignment for columns (Left, Right, Center) ; have you a sample? Thanks in advance, and sorry for my approx english. -- Michel Claveau From tbrown at snapsurveys.com Thu Feb 18 13:12:14 2010 From: tbrown at snapsurveys.com (Tim Brown) Date: Thu, 18 Feb 2010 12:12:14 +0000 Subject: [python-win32] problems loading Windows services with pywin32 214 Message-ID: Hi, I'm using Python 2.5 and pywin32 build 212 to produce an application with services. The services load C++ DLLs, for example snap.pyd, to do some of the work. All working fine until a customer installed pywin32 build 214 then some of the services don't load, because some of the DLLs load others do not :( The error I get in the Windows Event Viewer looks like this Python could not import the service's module Traceback (most recent call last): ... import snap ImportError: DLL load failed: Invalid access to memory location. %2: %3 The DLLs load fine in PythonWin and if the .py file which includes the import is run from the command line. The .py file only fails if run by PythonService.exe. If there is someone out there who can say "yes that's because you have not done .... " that would be wonderful. Otherwise is there a list of the changes from build 212 which could break existing applications so that I can work out what I've got to change ? I hope this has all made some sense Thanks Tim. From rdahlstrom at directedge.com Thu Feb 18 13:09:59 2010 From: rdahlstrom at directedge.com (Dahlstrom, Roger) Date: Thu, 18 Feb 2010 07:09:59 -0500 Subject: [python-win32] Python Automation Question In-Reply-To: <4B7C7108.20600@probo.com> References: <2ABF676708495B4AB7162B8C1BC6185A04627803@WDCEXG06.usmint.etreas.gov> <4B7C7108.20600@probo.com> Message-ID: <70D9B06B9E99EE4E98E4893703ADA1411A45482324@EXCHANGE1.global.knight.com> >> -----Original Message----- >> From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto:python-win32- >> bounces+rdahlstrom=directedge.com at python.org] On Behalf Of Tim Roberts >> Sent: Wednesday, February 17, 2010 5:43 PM >> To: python-win32 at python.org >> Subject: Re: [python-win32] Python Automation Question >> >> Roberts, Gregory (Contractor) wrote: >> >> The automation runs on a VM and is working smoothly except for with >> one report. It requires that the default printer on the VM is set to >> print to PDF and I am unsure of how to go about this. I have >> inherited the code after essentially writing the requirements and am >> excited to begin coding in Python. I would prefer not to have to >> contact the initial developer if at all possible and use this as a >> learning experience since again, I am maintaining the automation scripts. > Well, at the risk of being flippant, it seems to me that the right thing > to do is to change the default printer to print to PDF. By hand. > > Assuming you have Acrobat installed, go into Settings, Printers and > Faxes, right-click on Adobe PDF and select "Set as Default Printer". > > It would be very unfriendly for you to have your script change the > default printer. Users do not expect that. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > The unfriendliness aside - if you are coding it yourself, why not make it behave properly and print to a specific printer? Or simply convert to a .pdf without sending it to a pdf printer? DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications. www.directedge.com From mail at timgolden.me.uk Thu Feb 18 14:47:45 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 18 Feb 2010 13:47:45 +0000 Subject: [python-win32] pywin32 documentation wiki In-Reply-To: <4B7C3044.6070406@laposte.net> References: <4B794C8E.1070708@laposte.net> <4B7C3044.6070406@laposte.net> Message-ID: <4B7D4501.6060001@timgolden.me.uk> Hi, "le dahut". (Sorry; how would you prefer to be addressed?) What would be really useful is one or two paragraphs outlining the problem you're solving with this solution :) I've more-or-less followed your posts here over the past year, and your code's quite readable so I can get an idea, but perhaps something along the lines of: The requirement: xxxx The problems: xxx The solution: xxx would be helpful. No need for too much text; just an outline on which to hang your different pieces of code. Thanks TJG From timr at probo.com Thu Feb 18 19:51:11 2010 From: timr at probo.com (Tim Roberts) Date: Thu, 18 Feb 2010 10:51:11 -0800 Subject: [python-win32] win32gui and SysListView32 In-Reply-To: References: Message-ID: <4B7D8C1F.8090509@probo.com> Michel Claveau wrote: > > I use a SysListView32 in a Window, for show a list of lists. > It is very good, but I have two questions : > - The size is limited to 9999 lines ; how define more? The number of items is limited only by available memory. I know of apps that have used more than 100,000 items. Why do you believe there is a 9,999 line limit? > - I did not found how define alignment for columns (Left, Right, > Center) ; have you a sample? You can do it when you add the column using LVM_INSERTCOLUMN, or you can do it afterwards by sending LVM_SETCOLUMN. You set the "fmt" member of the LVCOLUMN structure to LVCFMT_RIGHT or LVCFMT_CENTER. Be sure to set LVC_FMT in the "mask" member to indicate that you're changing the format. If you use LVM_SETCOLUMN, you should probably do an LVM_GETCOLUMN first, then modify the current settings. The leftmost column is ALWAYS left-justified. This cannot be changed. This seems like the hard way to write an application. Have you considered using a GUI framework like Tkinter or Qt or (my favorite) wxPython? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mc at mclaveau.com Fri Feb 19 08:12:43 2010 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 19 Feb 2010 08:12:43 +0100 Subject: [python-win32] win32gui and SysListView32 In-Reply-To: <4B7D8C1F.8090509@probo.com> References: <4B7D8C1F.8090509@probo.com> Message-ID: <1104CE55FBF149E69F26064C55346FF8@MCI1330> Hi, Tim! Thanks for your answer. >> - The size is limited to 9999 lines ; how define more? > The number of items is limited only by available memory You are right. I tried with 300 000 lines, without problem. I do not know I had a 9999 limit on my first tests... Sorry for trouble. Little info (for other readers): This code give more speed: win32gui.PostMessage(self.hwnd, win32con.WM_SETREDRAW,0,0) ...(preparation of data in show)... win32gui.PostMessage(self.hwnd, win32con.WM_SETREDRAW,1,0) win32gui.UpdateWindow(self.hwnd) >> - I did not found how define alignment for columns (Left, Right, Center) > "fmt" member of the LVCOLUMN ... If you use LVM_SETCOLUMN, you > should probably do an LVM_GETCOLUMN first. OK, it's run. Without LVM_GETCOLUMN first. But with win32gui.UpdateWindow after. Thank you very well & again :))) > The leftmost column is ALWAYS left-justified. This cannot be changed. In my W7, I can align the column 0 (leftmost) without problem. Perhaps because I insert it in last operation? > This seems like the hard way to write an application. Have you > considered using a GUI framework like Tkinter or Qt or (my favorite) > wxPython? I tried TK: limited. I tried wx: I let down, because several conflict's versions, and it is very complicated. Actually, I use Autoit like GUI, and Python's functions linked to UIobject and events (via COM) ; run OK, but not pythonic. Also I use IE like GUI, with PLUIE (http://ponx.org/ponx/guiescreens.htm) ; but it is not very fast. I think than a pure pywin32 is a good way to explore. Have a nice day. Michel Claveau From Gregory.Roberts at usmint.treas.gov Fri Feb 19 15:09:00 2010 From: Gregory.Roberts at usmint.treas.gov (Roberts, Gregory (Contractor)) Date: Fri, 19 Feb 2010 09:09:00 -0500 Subject: [python-win32] Python Automation Question In-Reply-To: References: Message-ID: <2ABF676708495B4AB7162B8C1BC6185A0462780E@WDCEXG06.usmint.etreas.gov> We have decided to oset the default printer in a macro which we must run on the excel report and hope that all will work on Monday when in production. I would like to find a python solution which I could refactor into the correct place. Again, my wits with Python still have not formed. Also... I am unable to dedicate to much time to this task for the time being. Thanks for the suggestions. I will try and think outside the box using them as guidance. Greg -----Original Message----- From: python-win32-bounces+gregory.roberts=usmint.treas.gov at python.org [mailto:python-win32-bounces+gregory.roberts=usmint.treas.gov at python.org ] On Behalf Of python-win32-request at python.org Sent: Friday, February 19, 2010 6:00 AM To: python-win32 at python.org Subject: python-win32 Digest, Vol 83, Issue 21 Send python-win32 mailing list submissions to python-win32 at python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-win32 or, via email, send a message with subject or body 'help' to python-win32-request at python.org You can reach the person managing the list at python-win32-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of python-win32 digest..." Today's Topics: 1. problems loading Windows services with pywin32 214 (Tim Brown) 2. Re: Python Automation Question (Dahlstrom, Roger) 3. Re: pywin32 documentation wiki (Tim Golden) 4. Re: win32gui and SysListView32 (Tim Roberts) 5. Re: win32gui and SysListView32 (Michel Claveau) ---------------------------------------------------------------------- Message: 1 Date: Thu, 18 Feb 2010 12:12:14 +0000 From: Tim Brown To: "'python-win32 at python.org'" Subject: [python-win32] problems loading Windows services with pywin32 214 Message-ID: Content-Type: text/plain; charset="us-ascii" Hi, I'm using Python 2.5 and pywin32 build 212 to produce an application with services. The services load C++ DLLs, for example snap.pyd, to do some of the work. All working fine until a customer installed pywin32 build 214 then some of the services don't load, because some of the DLLs load others do not :( The error I get in the Windows Event Viewer looks like this Python could not import the service's module Traceback (most recent call last): ... import snap ImportError: DLL load failed: Invalid access to memory location. %2: %3 The DLLs load fine in PythonWin and if the .py file which includes the import is run from the command line. The .py file only fails if run by PythonService.exe. If there is someone out there who can say "yes that's because you have not done .... " that would be wonderful. Otherwise is there a list of the changes from build 212 which could break existing applications so that I can work out what I've got to change ? I hope this has all made some sense Thanks Tim. ------------------------------ Python Automation Question DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications. www.directedge.com ------------------------------ Message: 3 Date: Thu, 18 Feb 2010 13:47:45 +0000 From: Tim Golden Cc: python-win32 at python.org Subject: Re: [python-win32] pywin32 documentation wiki Message-ID: <4B7D4501.6060001 at timgolden.me.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hi, "le dahut". (Sorry; how would you prefer to be addressed?) What would be really useful is one or two paragraphs outlining the problem you're solving with this solution :) I've more-or-less followed your posts here over the past year, and your code's quite readable so I can get an idea, but perhaps something along the lines of: The requirement: xxxx The problems: xxx The solution: xxx would be helpful. No need for too much text; just an outline on which to hang your different pieces of code. Thanks TJG ------------------------------ Message: 4 Date: Thu, 18 Feb 2010 10:51:11 -0800 From: Tim Roberts To: Python-Win32 List Subject: Re: [python-win32] win32gui and SysListView32 Message-ID: <4B7D8C1F.8090509 at probo.com> Content-Type: text/plain; charset=ISO-8859-1 Michel Claveau wrote: > > I use a SysListView32 in a Window, for show a list of lists. > It is very good, but I have two questions : > - The size is limited to 9999 lines ; how define more? The number of items is limited only by available memory. I know of apps that have used more than 100,000 items. Why do you believe there is a 9,999 line limit? > - I did not found how define alignment for columns (Left, Right, > Center) ; have you a sample? You can do it when you add the column using LVM_INSERTCOLUMN, or you can do it afterwards by sending LVM_SETCOLUMN. You set the "fmt" member of the LVCOLUMN structure to LVCFMT_RIGHT or LVCFMT_CENTER. Be sure to set LVC_FMT in the "mask" member to indicate that you're changing the format. If you use LVM_SETCOLUMN, you should probably do an LVM_GETCOLUMN first, then modify the current settings. The leftmost column is ALWAYS left-justified. This cannot be changed. This seems like the hard way to write an application. Have you considered using a GUI framework like Tkinter or Qt or (my favorite) wxPython? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. ------------------------------ Message: 5 Date: Fri, 19 Feb 2010 08:12:43 +0100 From: "Michel Claveau" To: "Python-Win32 List" Subject: Re: [python-win32] win32gui and SysListView32 Message-ID: <1104CE55FBF149E69F26064C55346FF8 at MCI1330> Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Hi, Tim! Thanks for your answer. >> - The size is limited to 9999 lines ; how define more? > The number of items is limited only by available memory You are right. I tried with 300 000 lines, without problem. I do not know I had a 9999 limit on my first tests... Sorry for trouble. Little info (for other readers): This code give more speed: win32gui.PostMessage(self.hwnd, win32con.WM_SETREDRAW,0,0) ...(preparation of data in show)... win32gui.PostMessage(self.hwnd, win32con.WM_SETREDRAW,1,0) win32gui.UpdateWindow(self.hwnd) >> - I did not found how define alignment for columns (Left, Right, Center) > "fmt" member of the LVCOLUMN ... If you use LVM_SETCOLUMN, you > should probably do an LVM_GETCOLUMN first. OK, it's run. Without LVM_GETCOLUMN first. But with win32gui.UpdateWindow after. Thank you very well & again :))) > The leftmost column is ALWAYS left-justified. This cannot be changed. In my W7, I can align the column 0 (leftmost) without problem. Perhaps because I insert it in last operation? > This seems like the hard way to write an application. Have you > considered using a GUI framework like Tkinter or Qt or (my favorite) > wxPython? I tried TK: limited. I tried wx: I let down, because several conflict's versions, and it is very complicated. Actually, I use Autoit like GUI, and Python's functions linked to UIobject and events (via COM) ; run OK, but not pythonic. Also I use IE like GUI, with PLUIE (http://ponx.org/ponx/guiescreens.htm) ; but it is not very fast. I think than a pure pywin32 is a good way to explore. Have a nice day. Michel Claveau ------------------------------ _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 End of python-win32 Digest, Vol 83, Issue 21 ******************************************** From le.dahut at laposte.net Fri Feb 19 16:24:30 2010 From: le.dahut at laposte.net (le dahut) Date: Fri, 19 Feb 2010 16:24:30 +0100 Subject: [python-win32] pywin32 documentation wiki In-Reply-To: <4B7D4501.6060001@timgolden.me.uk> References: <4B794C8E.1070708@laposte.net> <4B7C3044.6070406@laposte.net> <4B7D4501.6060001@timgolden.me.uk> Message-ID: <4B7EAD2E.4020909@laposte.net> "le dahut" (French) is an imaginary beast that has 2 legs shorter than the other 2. But the difference is between the right and the left legs, it's because this animal lives on mountainsides. This makes its movements easier but it would, however, always moving in the same direction on the same side. Goal : * catching Logon/Logoff/Lock/UnLock/StartScreenSaver/StopScreenSaver events Why ? * log those events (and maybe send them on a server) * do some actions at some events (execute commands, tune registry, connect printers, modify windows firewall rules, etc.) How ? * using HandlerEx (not Windows 2000 compatible) or * using ISensLogon (Windows 2000 compatible) and because Win XP firewall cannot filter outgoing connexions, it has been disabled and replaced with WipFW. We use it in a Samba Domain to configure workstations at user logon. At logon event the service reads a configuration stored on the PDC and get some rules to apply depending on : * the computer name * the user name and/or groups I don't know what details I could give about what to do with. I'm confident in people's imagination. Cheers, Klaas Tim Golden wrote : > > Hi, "le dahut". (Sorry; how would you prefer to be addressed?) > > What would be really useful is one or two paragraphs outlining > the problem you're solving with this solution :) I've more-or-less > followed your posts here over the past year, and your code's quite > readable so I can get an idea, but perhaps something along the lines > of: > > The requirement: xxxx > > The problems: xxx > > The solution: xxx > > would be helpful. No need for too much text; just an outline on > which to hang your different pieces of code. > > Thanks > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From stef.mientki at gmail.com Fri Feb 19 23:50:53 2010 From: stef.mientki at gmail.com (Stef Mientki) Date: Fri, 19 Feb 2010 23:50:53 +0100 Subject: [python-win32] hwnd of an application sometimes changes ?? Message-ID: <4B7F15CD.4070900@gmail.com> hello, I launch an (Delphi) application with subprocess.Popen ( Application, shell=False ) Then with a timer (100 msec), I'm trying to find the applications main window, by looking for the formclass self.App_hwnd = win32gui.FindWindow ( self.Application_Form_Class, self.Application_Caption ) so in the beginning, I'm getting hwnd =0, then after a while I get a nonzero hwnd, sometimes it's the correct one, sometimes not. In the latter case, looking for the hwnd for a second time, does return the correct hwnd. Any explanation / solution ? thanks, Stef Mientki -------------- next part -------------- An HTML attachment was scrubbed... URL: From c.steiner at pantherite.ch Sun Feb 21 15:21:40 2010 From: c.steiner at pantherite.ch (McBuell) Date: Sun, 21 Feb 2010 06:21:40 -0800 (PST) Subject: [python-win32] GetDIBits Troubles Message-ID: <27675967.post@talk.nabble.com> Hi there ! I know that GetDIBits is not part of the win32 module, but it seems for me the best matching forum for my question. I'm currently trying to capture a screenshot on a Windows XP machine. Although there are several other ways (ImageGrab of PIL, third party dlls etc.) I want to try to use the Win32 API to capture it. As input for my brain, I'm using a working c++ script, that calls some win32 apis. Although most of my script seems to work without problems, the final call to GetDIBits (of the venster.gdi module, which is the only module that includes GetDIBits as far as I know) fails (returns 0), without a meeningfull error message. So I'm stuck a little bit. Find attached my small script (as mentioned it uses venster which can be found here: http://venster.sourceforge.net/htdocs/index.html http://venster.sourceforge.net/htdocs/index.html ). Maybe one of you is able to track the error down. Any help is appreciated ! my script: http://old.nabble.com/file/p27675967/screenshot2.py screenshot2.py Greetings from Switzerland, Claude -- View this message in context: http://old.nabble.com/GetDIBits-Troubles-tp27675967p27675967.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From c.steiner at pantherite.ch Sun Feb 21 15:27:42 2010 From: c.steiner at pantherite.ch (McBuell) Date: Sun, 21 Feb 2010 06:27:42 -0800 (PST) Subject: [python-win32] Python Automation Question In-Reply-To: <2ABF676708495B4AB7162B8C1BC6185A0462780E@WDCEXG06.usmint.etreas.gov> References: <2ABF676708495B4AB7162B8C1BC6185A04627803@WDCEXG06.usmint.etreas.gov> <2ABF676708495B4AB7162B8C1BC6185A0462780E@WDCEXG06.usmint.etreas.gov> Message-ID: <27676028.post@talk.nabble.com> Hi ! just a few days ago, I've found the pywinauto module for python. This awsome little script helps pressing menus and/or other windows controls of other applications with only a few lines of python. So it should be possible for it to open the printer dialog box, and then choose the correct printer. Check it out at: http://sourceforge.net/projects/pywinauto/ http://sourceforge.net/projects/pywinauto/ Check also the example directory that comes with the installer, it is a quick way to get used to the needed syntax. Cheers Roberts, Gregory (Contractor) wrote: > > > We have decided to oset the default printer in a macro which we must run > on the excel report and hope that all will work on Monday when in > production. > > I would like to find a python solution which I could refactor into the > correct place. Again, my wits with Python still have not formed. > Also... I am unable to dedicate to much time to this task for the time > being. > > Thanks for the suggestions. I will try and think outside the box using > them as guidance. > > Greg > > > > > > > > > > > > > -----Original Message----- > From: python-win32-bounces+gregory.roberts=usmint.treas.gov at python.org > [mailto:python-win32-bounces+gregory.roberts=usmint.treas.gov at python.org > ] On Behalf Of python-win32-request at python.org > Sent: Friday, February 19, 2010 6:00 AM > To: python-win32 at python.org > Subject: python-win32 Digest, Vol 83, Issue 21 > > Send python-win32 mailing list submissions to > python-win32 at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-win32 > or, via email, send a message with subject or body 'help' to > python-win32-request at python.org > > You can reach the person managing the list at > python-win32-owner at python.org > > When replying, please edit your Subject line so it is more specific than > "Re: Contents of python-win32 digest..." > > > Today's Topics: > > 1. problems loading Windows services with pywin32 214 (Tim Brown) > 2. Re: Python Automation Question (Dahlstrom, Roger) > 3. Re: pywin32 documentation wiki (Tim Golden) > 4. Re: win32gui and SysListView32 (Tim Roberts) > 5. Re: win32gui and SysListView32 (Michel Claveau) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 18 Feb 2010 12:12:14 +0000 > From: Tim Brown > To: "'python-win32 at python.org'" > Subject: [python-win32] problems loading Windows services with pywin32 > 214 > Message-ID: > > > > > Content-Type: text/plain; charset="us-ascii" > > Hi, > I'm using Python 2.5 and pywin32 build 212 to produce an application > with services. > The services load C++ DLLs, for example snap.pyd, to do some of the > work. > All working fine until a customer installed pywin32 build 214 then some > of the services don't load, because some of the DLLs load others do not > :( > > The error I get in the Windows Event Viewer looks like this > > Python could not import the service's module Traceback (most recent call > last): > ... > import snap > ImportError: DLL load failed: Invalid access to memory location. %2: %3 > > The DLLs load fine in PythonWin and if the .py file which includes the > import is run from the command line. > The .py file only fails if run by PythonService.exe. > > If there is someone out there who can say "yes that's because you have > not done .... " > that would be wonderful. > Otherwise is there a list of the changes from build 212 which could > break existing applications so that I can work out what I've got to > change ? > > I hope this has all made some sense > > Thanks Tim. > > ------------------------------ > > Python Automation Question > > > DISCLAIMER: > This e-mail, and any attachments thereto, is intended only for use by > the addressee(s) named herein and may contain legally privileged and/or > confidential information. If you are not the intended recipient of this > e-mail, you are hereby notified that any dissemination, distribution or > copying of this e-mail, and any attachments thereto, is strictly > prohibited. If you have received this in error, please immediately > notify me and permanently delete the original and any copy of any e-mail > and any printout thereof. > E-mail transmission cannot be guaranteed to be secure or error-free. The > sender therefore does not accept liability for any errors or omissions > in the contents of this message which arise as a result of e-mail > transmission. > > NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Direct Edge ECN LLC may, at > its discretion, monitor and review the content of all e-mail > communications. > > www.directedge.com > > > ------------------------------ > > Message: 3 > Date: Thu, 18 Feb 2010 13:47:45 +0000 > From: Tim Golden > Cc: python-win32 at python.org > Subject: Re: [python-win32] pywin32 documentation wiki > Message-ID: <4B7D4501.6060001 at timgolden.me.uk> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Hi, "le dahut". (Sorry; how would you prefer to be addressed?) > > What would be really useful is one or two paragraphs outlining the > problem you're solving with this solution :) I've more-or-less followed > your posts here over the past year, and your code's quite readable so I > can get an idea, but perhaps something along the lines > of: > > The requirement: xxxx > > The problems: xxx > > The solution: xxx > > would be helpful. No need for too much text; just an outline on which to > hang your different pieces of code. > > Thanks > > TJG > > > ------------------------------ > > Message: 4 > Date: Thu, 18 Feb 2010 10:51:11 -0800 > From: Tim Roberts > To: Python-Win32 List > Subject: Re: [python-win32] win32gui and SysListView32 > Message-ID: <4B7D8C1F.8090509 at probo.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Michel Claveau wrote: >> >> I use a SysListView32 in a Window, for show a list of lists. >> It is very good, but I have two questions : >> - The size is limited to 9999 lines ; how define more? > > The number of items is limited only by available memory. I know of apps > that have used more than 100,000 items. Why do you believe there is a > 9,999 line limit? > > >> - I did not found how define alignment for columns (Left, Right, >> Center) ; have you a sample? > > You can do it when you add the column using LVM_INSERTCOLUMN, or you can > do it afterwards by sending LVM_SETCOLUMN. You set the "fmt" member of > the LVCOLUMN structure to LVCFMT_RIGHT or LVCFMT_CENTER. Be sure to set > LVC_FMT in the "mask" member to indicate that you're changing the > format. If you use LVM_SETCOLUMN, you should probably do an > LVM_GETCOLUMN first, then modify the current settings. > > The leftmost column is ALWAYS left-justified. This cannot be changed. > > This seems like the hard way to write an application. Have you > considered using a GUI framework like Tkinter or Qt or (my favorite) > wxPython? > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > > > ------------------------------ > > Message: 5 > Date: Fri, 19 Feb 2010 08:12:43 +0100 > From: "Michel Claveau" > To: "Python-Win32 List" > Subject: Re: [python-win32] win32gui and SysListView32 > Message-ID: <1104CE55FBF149E69F26064C55346FF8 at MCI1330> > Content-Type: text/plain; format=flowed; charset="iso-8859-1"; > reply-type=original > > Hi, Tim! > > Thanks for your answer. > > >>> - The size is limited to 9999 lines ; how define more? >> The number of items is limited only by available memory > > You are right. I tried with 300 000 lines, without problem. > I do not know I had a 9999 limit on my first tests... Sorry for > trouble. > > Little info (for other readers): > This code give more speed: > win32gui.PostMessage(self.hwnd, win32con.WM_SETREDRAW,0,0) > ...(preparation of data in show)... > win32gui.PostMessage(self.hwnd, win32con.WM_SETREDRAW,1,0) > win32gui.UpdateWindow(self.hwnd) > > >>> - I did not found how define alignment for columns (Left, Right, > Center) >> "fmt" member of the LVCOLUMN ... If you use LVM_SETCOLUMN, you >> should probably do an LVM_GETCOLUMN first. > > OK, it's run. Without LVM_GETCOLUMN first. But with > win32gui.UpdateWindow > after. > > Thank you very well & again :))) > > >> The leftmost column is ALWAYS left-justified. This cannot be changed. > > In my W7, I can align the column 0 (leftmost) without problem. Perhaps > because I insert it in last operation? > > >> This seems like the hard way to write an application. Have you >> considered using a GUI framework like Tkinter or Qt or (my favorite) >> wxPython? > > I tried TK: limited. > I tried wx: I let down, because several conflict's versions, and it is > very > complicated. > Actually, I use Autoit like GUI, and Python's functions linked to > UIobject > and events (via COM) ; run OK, but not pythonic. > Also I use IE like GUI, with PLUIE > (http://ponx.org/ponx/guiescreens.htm) ; > but it is not very fast. > > I think than a pure pywin32 is a good way to explore. > > Have a nice day. > > Michel Claveau > > > > > > ------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > End of python-win32 Digest, Vol 83, Issue 21 > ******************************************** > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- View this message in context: http://old.nabble.com/Python-Automation-Question-tp27630895p27676028.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From mdriscoll at co.marshall.ia.us Mon Feb 22 17:37:04 2010 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Mon, 22 Feb 2010 10:37:04 -0600 Subject: [python-win32] Python Automation Question In-Reply-To: <2ABF676708495B4AB7162B8C1BC6185A0462780E@WDCEXG06.usmint.etreas.gov> References: <2ABF676708495B4AB7162B8C1BC6185A0462780E@WDCEXG06.usmint.etreas.gov> Message-ID: <4B82B2B0.4050301@co.marshall.ia.us> Hi Greg, On 1:59 PM, Roberts, Gregory (Contractor) wrote: > We have decided to oset the default printer in a macro which we must run > on the excel report and hope that all will work on Monday when in > production. > > I would like to find a python solution which I could refactor into the > correct place. Again, my wits with Python still have not formed. > Also... I am unable to dedicate to much time to this task for the time > being. > > Thanks for the suggestions. I will try and think outside the box using > them as guidance. > > Greg > > > I'm not sure why the other PyWin32 guys didn't mention this, but you can do either of the following: import win32print win32print.SetDefaultPrinter('My Printer Name') import subprocess subprocess.call(r'rundll32 printui.dll PrintUIEntry /y /n\\UNC\path\to\printer') I have a couple of other tips here: http://www.blog.pythonlibrary.org/2010/02/14/python-windows-and-printers/ and Tim Golden's site has at least one other script based on printers: http://timgolden.me.uk/python/wmi/cookbook.html#show-print-jobs (although it has nothing to do with what you're doing). The other guys had good suggestions too though. -- *Mike Driscoll* Blog: http://blog.pythonlibrary.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Feb 22 20:23:57 2010 From: timr at probo.com (Tim Roberts) Date: Mon, 22 Feb 2010 11:23:57 -0800 Subject: [python-win32] GetDIBits Troubles In-Reply-To: <27675967.post@talk.nabble.com> References: <27675967.post@talk.nabble.com> Message-ID: <4B82D9CD.6080909@probo.com> McBuell wrote: > I know that GetDIBits is not part of the win32 module, but it seems for me > the best matching forum for my question. > > I'm currently trying to capture a screenshot on a Windows XP machine. > Although there are several other ways (ImageGrab of PIL, third party dlls > etc.) I want to try to use the Win32 API to capture it. > As input for my brain, I'm using a working c++ script, that calls some win32 > apis. > > Although most of my script seems to work without problems, the final call to > GetDIBits > (of the venster.gdi module, which is the only module that includes GetDIBits > as far as I know) > fails (returns 0), without a meeningfull error message. So I'm stuck a > little bit. > Odd. I traced your code in windbg through GetDIBits clear to the point where it calls into the kernel, and it has passed all the parameter validation. I don't see anything immediately wrong with this. The doc says that that the bitmap must not be selected into a DC at the time of the call, but the sample application doesn't follow that, and when I selected hbmOld back into memDC it didn't change anything. FWIW, you can replace venster.gdi.GetDIBits with ctypes.windll.gdi32.GetDIBits with the same results and use one less module. There are a couple of alternatives. After you do the BitBlt, you can call GetBitmapBits to make a copy of the bits. That's quicker than GetDIBits, and as long as you're running true color (which everyone is today), it's the same end result. Alternatively, you can call GetObject on the hbm, which returns a BITMAP structure. The bmBits member contains a pointer to the bits (which you'd still have to copy). -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From christophedeze at wanadoo.fr Wed Feb 24 19:59:38 2010 From: christophedeze at wanadoo.fr (Christophe Deze) Date: Wed, 24 Feb 2010 19:59:38 +0100 Subject: [python-win32] wmi error Message-ID: <4B85771A.60104@wanadoo.fr> Hello i'm looking for information about this error Traceback (most recent call last): File "Frame1.pyo", line 235, in run File "wmi.pyo", line 1267, in connect File "wmi.pyo", line 241, in handle_com_error x_wmi: it run from windows XP u'Non trouv\xe9 ' means object not found I think in my script line 235 is c= wmi.WMI(computer=self.ip, user=self.adm, password=self.admmdp) From timr at probo.com Wed Feb 24 20:18:22 2010 From: timr at probo.com (Tim Roberts) Date: Wed, 24 Feb 2010 11:18:22 -0800 Subject: [python-win32] wmi error In-Reply-To: <4B85771A.60104@wanadoo.fr> References: <4B85771A.60104@wanadoo.fr> Message-ID: <4B857B7E.8020902@probo.com> Christophe Deze wrote: > > i'm looking for information about this error > > Traceback (most recent call last): > File "Frame1.pyo", line 235, in run > File "wmi.pyo", line 1267, in connect > File "wmi.pyo", line 241, in handle_com_error > x_wmi: produite.", (0, u'SWbemLocator', u'Non trouv\xe9 ', None, 0, > -2147217406), None)> > > it run from windows XP > > u'Non trouv\xe9 ' means object not found I think Yes, -2147217406 is 0x80041002, which is WBEM_E_NOT_FOUND. > in my script line 235 is > > c= wmi.WMI(computer=self.ip, user=self.adm, password=self.admmdp) What did you pass for self.ip? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ulrich.mierendorff at gmx.net Wed Feb 24 22:43:34 2010 From: ulrich.mierendorff at gmx.net (Ulrich Mierendorff) Date: Wed, 24 Feb 2010 22:43:34 +0100 Subject: [python-win32] Dereferencing lParam pointer Message-ID: <4B859D86.9070002@gmx.net> Hi, I am doing some win32 programming with python and want to modify a statusbar of a window. In my code I use win32gui.SetWindowLong(statusbar_window, win32con.GWL_WNDPROC, mystatusbarproc) to set a custom window procedure. In "def mystatusbarproc(window, message, wParam, lParam)" I wait for the commctrl.SB_SETPARTS message: http://msdn.microsoft.com/en-us/library/bb760757%28VS.85%29.aspx The lParam parameter for this message is (according to the documentation) a "Pointer to an integer array". I thought, python would automatically dereference the pointer for me, so that I have a list, but print lParam returns values like "1236036" (the type is "int"). That looks like a memory address to me, but I am not sure. Is there a way to get the array/list? -Ulrich From timr at probo.com Thu Feb 25 00:01:45 2010 From: timr at probo.com (Tim Roberts) Date: Wed, 24 Feb 2010 15:01:45 -0800 Subject: [python-win32] Dereferencing lParam pointer In-Reply-To: <4B859D86.9070002@gmx.net> References: <4B859D86.9070002@gmx.net> Message-ID: <4B85AFD9.9040306@probo.com> Ulrich Mierendorff wrote: > > I am doing some win32 programming with python and want to modify a > statusbar of a window. In my code I use > win32gui.SetWindowLong(statusbar_window, win32con.GWL_WNDPROC, > mystatusbarproc) > to set a custom window procedure. > > In "def mystatusbarproc(window, message, wParam, lParam)" I wait for > the commctrl.SB_SETPARTS message: > http://msdn.microsoft.com/en-us/library/bb760757%28VS.85%29.aspx > > The lParam parameter for this message is (according to the > documentation) a "Pointer to an integer array". > I thought, python would automatically dereference the pointer for me, > so that I have a list... I'm wondering why would you expect that. Python doesn't know anything about specific window messages. A window message consists of a handle, a message number, and two integers. The interpretation of those two integers is entirely dependent on the message number. The wrapper just hands them off to you for interpretation. > ...but > print lParam > returns values like "1236036" (the type is "int"). > That looks like a memory address to me, Yes, that's 0x12DC44, which is in the heap. > but I am not sure. Is there a way to get the array/list? You will have to use a package like ctypes to do that. Something like this: lst = ctypes.cast(lParam, ctypes.POINTER(ctypes.c_int)) print lst[0] print lst[1] -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Thu Feb 25 03:03:59 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 25 Feb 2010 13:03:59 +1100 Subject: [python-win32] Dereferencing lParam pointer In-Reply-To: <4B85AFD9.9040306@probo.com> References: <4B859D86.9070002@gmx.net> <4B85AFD9.9040306@probo.com> Message-ID: <4B85DA8F.80007@gmail.com> On 25/02/2010 10:01 AM, Tim Roberts wrote: >> but I am not sure. Is there a way to get the array/list? > > You will have to use a package like ctypes to do that. Something like this: > > lst = ctypes.cast(lParam, ctypes.POINTER(ctypes.c_int)) > print lst[0] > print lst[1] Or use something like win32gui.PyGetMemory and the struct module (same result, different modules) HTH, Mark From christophedeze at wanadoo.fr Thu Feb 25 10:55:11 2010 From: christophedeze at wanadoo.fr (Christophe Deze) Date: Thu, 25 Feb 2010 10:55:11 +0100 Subject: [python-win32] wmi error In-Reply-To: <4B857B7E.8020902@probo.com> References: <4B85771A.60104@wanadoo.fr> <4B857B7E.8020902@probo.com> Message-ID: <4B8648FF.4020903@wanadoo.fr> Le 24/02/2010 20:18, Tim Roberts a ?crit : > Christophe Deze wrote: > >> i'm looking for information about this error >> >> Traceback (most recent call last): >> File "Frame1.pyo", line 235, in run >> File "wmi.pyo", line 1267, in connect >> File "wmi.pyo", line 241, in handle_com_error >> x_wmi:> produite.", (0, u'SWbemLocator', u'Non trouv\xe9 ', None, 0, >> -2147217406), None)> >> >> it run from windows XP >> >> u'Non trouv\xe9 ' means object not found I think >> > Yes, -2147217406 is 0x80041002, which is WBEM_E_NOT_FOUND. > > > >> in my script line 235 is >> >> c= wmi.WMI(computer=self.ip, user=self.adm, password=self.admmdp) >> > What did you pass for self.ip? > > it 's just an address IP 172.16.127.250 From mail at timgolden.me.uk Thu Feb 25 11:17:01 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 25 Feb 2010 10:17:01 +0000 Subject: [python-win32] wmi error In-Reply-To: <4B8648FF.4020903@wanadoo.fr> References: <4B85771A.60104@wanadoo.fr> <4B857B7E.8020902@probo.com> <4B8648FF.4020903@wanadoo.fr> Message-ID: <4B864E1D.4000306@timgolden.me.uk> On 25/02/2010 09:55, Christophe Deze wrote: > Le 24/02/2010 20:18, Tim Roberts a ?crit : >> Christophe Deze wrote: >> >>> i'm looking for information about this error >>> >>> Traceback (most recent call last): >>> File "Frame1.pyo", line 235, in run >>> File "wmi.pyo", line 1267, in connect >>> File "wmi.pyo", line 241, in handle_com_error >>> x_wmi:>> produite.", (0, u'SWbemLocator', u'Non trouv\xe9 ', None, 0, >>> -2147217406), None)> >>> >>> it run from windows XP >>> >>> u'Non trouv\xe9 ' means object not found I think >>> >> Yes, -2147217406 is 0x80041002, which is WBEM_E_NOT_FOUND. >> >> >> >>> in my script line 235 is >>> >>> c= wmi.WMI(computer=self.ip, user=self.adm, password=self.admmdp) >>> >> What did you pass for self.ip? >> >> > it 's just an address IP > > 172.16.127.250 Just to eliminate WMI as such, could you insert these lines before your line 235: import socket print self.ip socket.socket ().connect ((self.ip, 135)) In principle this should show if there's some network reachability issue at the DCOM level... TJG From ulrich.mierendorff at gmx.net Thu Feb 25 18:15:53 2010 From: ulrich.mierendorff at gmx.net (Ulrich Mierendorff) Date: Thu, 25 Feb 2010 18:15:53 +0100 Subject: [python-win32] Dereferencing lParam pointer In-Reply-To: <4B85DA8F.80007@gmail.com> References: <4B859D86.9070002@gmx.net> <4B85AFD9.9040306@probo.com> <4B85DA8F.80007@gmail.com> Message-ID: <4B86B049.7080102@gmx.net> Mark Hammond wrote: > On 25/02/2010 10:01 AM, Tim Roberts wrote: >>> but I am not sure. Is there a way to get the array/list? >> >> You will have to use a package like ctypes to do that. Something >> like this: >> >> lst = ctypes.cast(lParam, ctypes.POINTER(ctypes.c_int)) >> print lst[0] >> print lst[1] > > Or use something like win32gui.PyGetMemory and the struct module (same > result, different modules) Thanks! This also works. I am now using the following solution extr = '@' + 'l'*wParam bytes = struct.calcsize(extr) parts = win32gui.PyGetMemory(lParam, bytes) parts = list(struct.unpack(extr, parts)) -Ulrich From ulrich.mierendorff at gmx.net Thu Feb 25 18:17:01 2010 From: ulrich.mierendorff at gmx.net (Ulrich Mierendorff) Date: Thu, 25 Feb 2010 18:17:01 +0100 Subject: [python-win32] Dereferencing lParam pointer In-Reply-To: <4B85AFD9.9040306@probo.com> References: <4B859D86.9070002@gmx.net> <4B85AFD9.9040306@probo.com> Message-ID: <4B86B08D.5050003@gmx.net> Tim Roberts wrote: >> but I am not sure. Is there a way to get the array/list? >> > You will have to use a package like ctypes to do that. Something like this: > > lst = ctypes.cast(lParam, ctypes.POINTER(ctypes.c_int)) > print lst[0] > print lst[1] > > Thanks. This works! I was experimenting with ctypes before, but using different methods (the from_address function) and that resulted in crashes. But your solution works. -Ulrich From kxroberto at googlemail.com Thu Feb 25 20:47:42 2010 From: kxroberto at googlemail.com (Robert) Date: Thu, 25 Feb 2010 20:47:42 +0100 Subject: [python-win32] win32com IE OnBeforeNavigate2: How to Cancel? Message-ID: class MyWebBrowser(activex.Control, WebBrowserModule.WebBrowser): def OnBeforeNavigate2(self, pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel): ... Cancel is a simple Python bool. Unlike in MFC CHtmlView::OnBeforeNavigate2 I cannot send a value back by ref this way. How to cancel the navigation? Robert --------- This member function is called by the framework to cause an event to fire before a navigation occurs in the web browser. virtual void OnBeforeNavigate2( LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName, CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel ); From kxroberto at googlemail.com Thu Feb 25 21:02:16 2010 From: kxroberto at googlemail.com (Robert) Date: Thu, 25 Feb 2010 21:02:16 +0100 Subject: [python-win32] win32com IE OnBeforeNavigate2: How to Cancel? In-Reply-To: References: Message-ID: oh, found I have to return a 7-tuple with Cancel as last one return None, None, None, None, None, None, args.Cancel Robert wrote: > > > class MyWebBrowser(activex.Control, WebBrowserModule.WebBrowser): > def OnBeforeNavigate2(self, pDisp, URL, Flags, TargetFrameName, > PostData, Headers, Cancel): > ... > > > Cancel is a simple Python bool. Unlike in MFC > CHtmlView::OnBeforeNavigate2 I cannot send a value back by ref this way. > How to cancel the navigation? > > Robert > > > > > > > > --------- > This member function is called by the framework to cause an event to > fire before a navigation occurs in the web browser. > > virtual void OnBeforeNavigate2( > LPCTSTR lpszURL, > DWORD nFlags, > LPCTSTR lpszTargetFrameName, > CByteArray& baPostedData, > LPCTSTR lpszHeaders, > BOOL* pbCancel > ); From opticar at opticar.fr Fri Feb 26 14:12:03 2010 From: opticar at opticar.fr (OptiCar) Date: Fri, 26 Feb 2010 14:12:03 +0100 Subject: [python-win32] knowing "file accessed" and "file opened" Message-ID: <1267189923.18953.90.camel@localhost> ?Hello, i need to know when an updated file has been opened. is it possible to watch the "OPEN" and "ACCESS" event with an adaptation of the Tim Golden's script ? need to work on windows, does pywin32 can ? inotify is only for linux dazuko can catch on linux what can work on windows to see the file open and file access event ? Thanks Roche Maxime From petr at dlabal.cz Fri Feb 26 15:16:25 2010 From: petr at dlabal.cz (Petr Dlabal) Date: Fri, 26 Feb 2010 15:16:25 +0100 Subject: [python-win32] Win32 exception occurred releasing IUnknown Message-ID: <3d26fb441002260616n6f592823xcb8c91e591dacc45@mail.gmail.com> Hi, I'm trying to process large amount of autocad drawings by python script using DWGDirect library (but I think I already saw the same problem with original autocad automation with python). I'm trying to explode the block in drawing and this action leads to delete the original block from drawing. But the block object is still linked with python object: block = oDoc.ModelSpace.InsertBlock(....) block.Explode() #this operation exploding the block to its elements and removes the block from drawing ->Win32 exception occurred releasing IUnknown xxxx... I think it is not possible to change the way how the Explode() function work. Unfortunately, this exception frequently end by python crash and I cannot catch the exception by try...except. So, Is there any possibility to avoid this exception, or catch the exception? Thank you P. From christophedeze at wanadoo.fr Fri Feb 26 15:22:09 2010 From: christophedeze at wanadoo.fr (Christophe Deze) Date: Fri, 26 Feb 2010 15:22:09 +0100 Subject: [python-win32] wmi error In-Reply-To: <4B864E1D.4000306@timgolden.me.uk> References: <4B85771A.60104@wanadoo.fr> <4B857B7E.8020902@probo.com> <4B8648FF.4020903@wanadoo.fr> <4B864E1D.4000306@timgolden.me.uk> Message-ID: <4B87D911.8090306@wanadoo.fr> wmimgmt.msc launch correcty but an error occured, "impossible to connect, WMI not found" it wasn't a problem in my script but it was with XP that was a bit too much customized thanks Le 25/02/2010 11:17, Tim Golden a ?crit : > > On 25/02/2010 09:55, Christophe Deze wrote: >> Le 24/02/2010 20:18, Tim Roberts a ?crit : >>> Christophe Deze wrote: >>> >>>> i'm looking for information about this error >>>> >>>> Traceback (most recent call last): >>>> File "Frame1.pyo", line 235, in run >>>> File "wmi.pyo", line 1267, in connect >>>> File "wmi.pyo", line 241, in handle_com_error >>>> x_wmi:>>> produite.", (0, u'SWbemLocator', u'Non trouv\xe9 ', None, 0, >>>> -2147217406), None)> >>>> >>>> it run from windows XP >>>> >>>> u'Non trouv\xe9 ' means object not found I think >>>> >>> Yes, -2147217406 is 0x80041002, which is WBEM_E_NOT_FOUND. >>> >>> >>> >>>> in my script line 235 is >>>> >>>> c= wmi.WMI(computer=self.ip, user=self.adm, password=self.admmdp) >>>> >>> What did you pass for self.ip? >>> >>> >> it 's just an address IP >> >> 172.16.127.250 > > Just to eliminate WMI as such, could you insert these lines > before your line 235: > > > import socket > > print self.ip > socket.socket ().connect ((self.ip, 135)) > > > > In principle this should show if there's some network > reachability issue at the DCOM level... > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From mdriscoll at co.marshall.ia.us Fri Feb 26 16:22:07 2010 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Fri, 26 Feb 2010 09:22:07 -0600 Subject: [python-win32] How to query the peak commit charge Message-ID: <4B87E71F.2010007@co.marshall.ia.us> Hi, I have been tasked with trying to find a way to query the peak commit charge of our various workstations. It would be great if I could do it remotely, but logging is also a possibility. Unfortunately, my Google skills have failed me as I can't find anyone else who is doing this publicly. Do you guys have any hints for how best to approach this task? Here's the use case: We are using Sun Ray virtual desktops and are trying to figure out how much RAM each VM is using. We are trying to decide if we can shrink the allocated amount of RAM of if we should just upgrade the servers. Thanks, - Mike From timr at probo.com Fri Feb 26 18:52:56 2010 From: timr at probo.com (Tim Roberts) Date: Fri, 26 Feb 2010 09:52:56 -0800 Subject: [python-win32] knowing "file accessed" and "file opened" In-Reply-To: <1267189923.18953.90.camel@localhost> References: <1267189923.18953.90.camel@localhost> Message-ID: <4B880A78.2020102@probo.com> OptiCar wrote: > i need to know when an updated file has been opened. > is it possible to watch the "OPEN" and "ACCESS" event with an adaptation > of the Tim Golden's script ? > need to work on windows, does pywin32 can ? > inotify is only for linux > dazuko can catch on linux > what can work on windows to see the file open and file access event ? > There is simply no mechanism in Windows to provide this information. It requires either API hooking or a file system filter driver, both of which are well beyond the scope of this mailing list. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From aahz at pythoncraft.com Fri Feb 26 20:52:34 2010 From: aahz at pythoncraft.com (Aahz) Date: Fri, 26 Feb 2010 11:52:34 -0800 Subject: [python-win32] knowing "file accessed" and "file opened" In-Reply-To: <1267189923.18953.90.camel@localhost> References: <1267189923.18953.90.camel@localhost> Message-ID: <20100226195233.GA26764@panix.com> On Fri, Feb 26, 2010, OptiCar wrote: > > i need to know when an updated file has been opened. > is it possible to watch the "OPEN" and "ACCESS" event with an adaptation > of the Tim Golden's script ? > need to work on windows, does pywin32 can ? > inotify is only for linux > dazuko can catch on linux > what can work on windows to see the file open and file access event ? We're using ReadDirectoryChangesW to catch changes; I have no idea whether that would give the info you want. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Many customs in this life persist because they ease friction and promote productivity as a result of universal agreement, and whether they are precisely the optimal choices is much less important." --Henry Spencer From bryan_berrett at kairosautonomi.com Fri Feb 26 22:48:42 2010 From: bryan_berrett at kairosautonomi.com (Bryan Berrett) Date: Fri, 26 Feb 2010 14:48:42 -0700 Subject: [python-win32] Concurrent Access to COM object from Python and VB6 In-Reply-To: <4B6C70C3.9020601@probo.com> References: <4B6BA32F.1060504@kairosautonomi.com> <4B6C70C3.9020601@probo.com> Message-ID: <4B8841BA.8080108@kairosautonomi.com> Deleting the object and object instances allow the other applications to run. Any other thoughts? On 2/5/2010 12:25 PM, Tim Roberts wrote: > Bryan Berrett wrote: >> I have a number of programs written in VB6 that use an ActiveX control >> that allows access to a shared memory pool of variables. I >> successfully used the following code to hook into this and access the >> shared memory variables. The only problem is that when this program is >> active I can not launch any of my other programs that use the same >> ActiveX. They hang upon initialization. As soon as I terminate the >> Python process, the VB6 program will finish loading and functions as >> expected. >> I am not sure what I need to do in order for the Python program to not >> block access. If I start all the VB6 programs first and the Python >> program last, everything works and can access the shared memory >> variables. > > I don't know why a COM object would behave like this. That's unusual. > As an experiment, you could try deleting the object to see if that's > enough to let the other apps run: > del beWise > > However, since you have other object instances hanging around (the > varInt and varString), I'm dubious that it will make much difference. > From opticar at opticar.fr Fri Feb 26 14:06:15 2010 From: opticar at opticar.fr (OptiCar) Date: Fri, 26 Feb 2010 14:06:15 +0100 Subject: [python-win32] knowing "file accessed" and "file opened" In-Reply-To: <498F3ED2.8080000@timgolden.me.uk> Message-ID: <1267189575.18953.87.camel@localhost> Hello, i need to know when an updated file has been opened. is it possible to watch the "OPEN" and "ACCESS" event with an adaptation of the Tim Golden's script ? need to work on windows, does pywin32 can ? inotify is only for linux dazuko can catch on linux what can work on windows to see the file open and file access event ? Thanks Roche Maxime From timr at probo.com Sat Feb 27 00:03:18 2010 From: timr at probo.com (Tim Roberts) Date: Fri, 26 Feb 2010 15:03:18 -0800 Subject: [python-win32] Concurrent Access to COM object from Python and VB6 In-Reply-To: <4B8841BA.8080108@kairosautonomi.com> References: <4B6BA32F.1060504@kairosautonomi.com> <4B6C70C3.9020601@probo.com> <4B8841BA.8080108@kairosautonomi.com> Message-ID: <4B885336.3030306@probo.com> Bryan Berrett wrote: > Deleting the object and object instances allow the other applications > to run. > > Any other thoughts? No, I think you have your answer. You will have to delete the objects after every access. I would call this a design flaw in the COM object, but at least you have a solution. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Sat Feb 27 00:14:23 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sat, 27 Feb 2010 10:14:23 +1100 Subject: [python-win32] How to query the peak commit charge In-Reply-To: <4B87E71F.2010007@co.marshall.ia.us> References: <4B87E71F.2010007@co.marshall.ia.us> Message-ID: <4B8855CF.7000405@gmail.com> On 27/02/2010 2:22 AM, Mike Driscoll wrote: > Hi, > > I have been tasked with trying to find a way to query the peak commit > charge of our various workstations. It would be great if I could do it > remotely, but logging is also a possibility. Unfortunately, my Google > skills have failed me as I can't find anyone else who is doing this > publicly. Do you guys have any hints for how best to approach this task? > > Here's the use case: We are using Sun Ray virtual desktops and are > trying to figure out how much RAM each VM is using. We are trying to > decide if we can shrink the allocated amount of RAM of if we should just > upgrade the servers. Maybe look into the win32pdh/win32pdhutil modules? Mark From mail at timgolden.me.uk Sat Feb 27 11:04:05 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Sat, 27 Feb 2010 10:04:05 +0000 Subject: [python-win32] knowing "file accessed" and "file opened" In-Reply-To: <20100226195233.GA26764@panix.com> References: <1267189923.18953.90.camel@localhost> <20100226195233.GA26764@panix.com> Message-ID: <4B88EE15.3030503@timgolden.me.uk> On 26/02/2010 19:52, Aahz wrote: > On Fri, Feb 26, 2010, OptiCar wrote: >> >> i need to know when an updated file has been opened. >> is it possible to watch the "OPEN" and "ACCESS" event with an adaptation >> of the Tim Golden's script ? >> need to work on windows, does pywin32 can ? >> inotify is only for linux >> dazuko can catch on linux >> what can work on windows to see the file open and file access event ? > > We're using ReadDirectoryChangesW to catch changes; I have no idea > whether that would give the info you want. 'Fraid not; I assume that that is the "Tim Golden's script" the OP is referring to, but that only handles *updates* no opens/reads. As Tim R points out, there's really no way to do this in Windows without dropping down to the device-driver kind of level. TJG From rwupole at msn.com Sat Feb 27 12:28:52 2010 From: rwupole at msn.com (Roger Upole) Date: Sat, 27 Feb 2010 06:28:52 -0500 Subject: [python-win32] knowing "file accessed" and "file opened" Message-ID: OptiCar wrote: > Hello, > i need to know when an updated file has been opened. > is it possible to watch the "OPEN" and "ACCESS" event with an adaptation > of the Tim Golden's script ? > need to work on windows, does pywin32 can ? > inotify is only for linux > dazuko can catch on linux > what can work on windows to see the file open and file access event ? > > Thanks > > Roche Maxime > You can use the file's SACL to create an audit record in the event log whenever the file is accessed. \win32\Demos\security\set_file_audit.py has some sample code for SACL's. Roger From jan at janschneider.net Sun Feb 28 15:07:05 2010 From: jan at janschneider.net (Jan Schneider) Date: Sun, 28 Feb 2010 15:07:05 +0100 Subject: [python-win32] Catch system level events in python Message-ID: <201002281507.05287.jan@janschneider.net> Hi, i am developing a windows service using python-win32. Now I am searching for a possibility to get a notification when a user is trying to shutdown the system. In certain cases I need to cancel this shutdown, Does anyone knows how this could be done? Is it possible to catch system level events in python like in other programming languages as for example C#: http://mail.python.org/pipermail/python-win32/2008-January/006645.html Thanks, Jan