From mc at mclaveau.com Tue Mar 1 00:18:14 2011 From: mc at mclaveau.com (Michel Claveau) Date: Tue, 1 Mar 2011 00:18:14 +0100 Subject: [python-win32] [ANN] pywin32 build 216 released. In-Reply-To: <4D6C1911.5010209@skippinet.com.au> References: <4D6A3826.7020106@skippinet.com.au> <9D6FE5C2371A4297A8FE81ECE0C95B8A@MCI1330> <4D6B3E7C.4080701@gmail.com> <59AD9B91E48B42B5B94DA321C122F903@MCI1330> <4D6C1911.5010209@skippinet.com.au> Message-ID: <30529BA761A74CC2AE476FEA200B6C99@MCI1330> Re-re-re...! I found!!! The problem is linked to this line: import win32ui If I comment it (or delete), the problem disappears. If I de-comment, the problem come back. As I can replace win32ui, the problem is solved for me. But, if you want that I try some other things, I am available for you. @-salutations (and sorry for my crappy english) -- Michel Claveau From mc at mclaveau.com Tue Mar 1 01:02:17 2011 From: mc at mclaveau.com (Michel Claveau) Date: Tue, 1 Mar 2011 01:02:17 +0100 Subject: [python-win32] [ANN] pywin32 build 216 released. In-Reply-To: <30529BA761A74CC2AE476FEA200B6C99@MCI1330> References: <4D6A3826.7020106@skippinet.com.au><9D6FE5C2371A4297A8FE81ECE0C95B8A@MCI1330><4D6B3E7C.4080701@gmail.com><59AD9B91E48B42B5B94DA321C122F903@MCI1330><4D6C1911.5010209@skippinet.com.au> <30529BA761A74CC2AE476FEA200B6C99@MCI1330> Message-ID: <120C72FA6CCC4D69A371770BC20D6205@MCI1330> Re-re... etc. I have the same problem with ietoolbar.py (in C:\Python26\Lib\site-packages\win32com\demos) good night (here, it is late...) -- Michel Claveau From rupole at hotmail.com Tue Mar 1 01:11:16 2011 From: rupole at hotmail.com (Roger Upole) Date: Mon, 28 Feb 2011 19:11:16 -0500 Subject: [python-win32] Problem with win32print.SetPrinter References: <1298888553.2645.29.camel@cacko> Message-ID: I think this is dependent on the printer driver. Some use the paper size defined by the the form, and others use the PaperSize member. Roger "Tefnet Developers" wrote in message news:1298888553.2645.29.camel at cacko... > Hi, > > I am adding some printers connection as a user with > win32print.AddPrinterConnection(). > > Afterwards I want to set paper size to A4 (I have no idea why Polish > Windows XP sets it to Letter by default) with this example code: > > ================================================================== > import win32print > import win32con > import win32gui > import pywintypes > > printer = r'\\drukarki\kp01' > > handle = win32print.OpenPrinter(printer, {'DesiredAccess': > win32print.PRINTER_ACCESS_USE}) > > devmodeSize=win32print.DocumentProperties(0, handle, printer, None, > None, 0) > devmode = pywintypes.DEVMODEType(devmodeSize - > pywintypes.DEVMODEType().Size) > win32print.DocumentProperties(0, handle, printer, devmode, devmode, > win32con.DM_IN_BUFFER | win32con.DM_OUT_BUFFER) > > print 'FormName before: %s' % devmode.FormName > print 'PaperSize before: %s' % devmode.PaperSize > > devmode.FormName = "A4" > devmode.PaperSize = win32con.DMPAPER_A4 > devmode.Fields = devmode.Fields | win32con.DM_FORMNAME | > win32con.DM_PAPERSIZE > > print 'FormName set: %s' % devmode.FormName > print 'PaperSize set: %s' % devmode.PaperSize > > info = win32print.GetPrinter(handle, 9) > info["pDevMode"] = devmode > win32print.SetPrinter(handle, 9, info, 0) > > devmodeSize=win32print.DocumentProperties(0, handle, printer, None, > None, 0) > devmode = pywintypes.DEVMODEType(devmodeSize - > pywintypes.DEVMODEType().Size) > win32print.DocumentProperties(0, handle, printer, devmode, devmode, > win32con.DM_IN_BUFFER | win32con.DM_OUT_BUFFER) > > print 'FormName after: %s' % devmode.FormName > print 'PaperSize after: %s' % devmode.PaperSize > > win32print.ClosePrinter(handle) > > win32gui.SendMessageTimeout(win32con.HWND_BROADCAST, > win32con.WM_DEVMODECHANGE, 0, 0, 0, 2000) > ================================================================== > > The output looks like this: > ================================================================== > FormName before: A4 > PaperSize before: 1 > FormName set: A4 > PaperSize set: 9 > FormName after: A4 > PaperSize after: 1 > ================================================================== > > So, as you can see - FormName changes, but PaperSize does not. > Am I doing something wrong here? I've spent a lot of time trying to > solve it, yet came up with nothing. > > Do you have any suggestions? > > Thanks, > Filip Zyzniewski > Tefnet From Andrew.MacIntyre at acma.gov.au Tue Mar 1 01:14:41 2011 From: Andrew.MacIntyre at acma.gov.au (Andrew MacIntyre) Date: Tue, 1 Mar 2011 11:14:41 +1100 Subject: [python-win32] Python Excel - 2 workbooks affect each other [SEC=UNCLASSIFIED] In-Reply-To: <000301cbd752$696751a0$1022a8c0@ipkgatersleben.de> References: <000301cbd752$696751a0$1022a8c0@ipkgatersleben.de> Message-ID: [apologies for top post] I'm far from an expert, or even experienced, in Excel however the term "paste" rings bells. Behind the scenes, material in the clipboard has lots of metadata and a selection copied from one open workbook includes the references to that workbook so when you paste it Excel includes those references and effectively links the pasted to cells to the pasted from cells. If you must use paste, then you will probably need to use "paste special" and select "values" - this should break the references back to the original source. If you carefully look at the "formula" of a pasted cell, you might see how the source workbook & worksheet are identified - I know that this sort of thing is visible when using the "function wizard" with such Excel functions as VLOOKUP. -------------------------> "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/ From: python-win32-bounces+andrew.macintyre=acma.gov.au at python.org [mailto:python-win32-bounces+andrew.macintyre=acma.gov.au at python.org] On Behalf Of Stefanie L?ck Sent: Tuesday, 1 March 2011 1:19 AM To: python-win32 at python.org Subject: [python-win32] Python Excel - 2 workbooks affect each other Hello! I have a strange excel behaviour if 2 workbooks are open. I'm trying to create an excel workbook with a bar chart from some data which comes from my wxPython program. If I paste the data into my program from any source except another excel file, everything works as expected. But if I copy the values from a source excel workbook into my program and then try to create a new excel workbook with a chart, the new workbook takes the data of the chart from the source workbook and not from the sheet I specified. This happens only if the data of the source workbook are still selected from the copy before, if I click into another cell, my new created workbook will use the data of its sheet which I specified. Does anybody know what this could be? In my code I clearly specify to use the data of my new created worksheet. The name of the source workbook sheet is completely different. Looks like excel ignore it and use the currently selected data of any workbook. Is there a way to specify the Workbook and Worksheet, which I want to use? Any help would be appreciated! Thanks, Stefanie NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -------------- next part -------------- An HTML attachment was scrubbed... URL: From smokefloat at gmail.com Tue Mar 1 01:25:43 2011 From: smokefloat at gmail.com (David Hutto) Date: Mon, 28 Feb 2011 19:25:43 -0500 Subject: [python-win32] Python Excel - 2 workbooks affect each other [SEC=UNCLASSIFIED] In-Reply-To: References: <000301cbd752$696751a0$1022a8c0@ipkgatersleben.de> Message-ID: On Mon, Feb 28, 2011 at 7:14 PM, Andrew MacIntyre wrote: > [apologies for top post] > > > > I?m far from an expert, or even experienced, in Excel however the term > ?paste? rings bells.? Behind the scenes, material in the clipboard has lots > of metadata and a selection copied from one open workbook includes the I'm not an expert on excel either, but isn't excel a file that can be read in and parsed for tags? > references to that workbook so when you paste it Excel includes those > references and effectively links the pasted to cells to the pasted from > cells.? If you must use paste, then you will probably need to use ?paste > special? and select ?values? ? this should break the references back to the > original source. > > > > If you carefully look at the ?formula? of a pasted cell, you might see how > the source workbook & worksheet are identified ? I know that this sort of > thing is visible when using the ?function wizard? with such Excel functions > as VLOOKUP. > > > > -------------------------> "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/ > > > > From: python-win32-bounces+andrew.macintyre=acma.gov.au at python.org > [mailto:python-win32-bounces+andrew.macintyre=acma.gov.au at python.org] On > Behalf Of Stefanie L?ck > Sent: Tuesday, 1 March 2011 1:19 AM > To: python-win32 at python.org > Subject: [python-win32] Python Excel - 2 workbooks affect each other > > > > Hello! > > > > I have a strange excel behaviour if 2 workbooks are open. I?m trying to > create an excel workbook with a bar chart from some data which comes from my > wxPython program. If I paste the data into my program from any source except > another excel file, everything works as expected. But if I copy the values > from a source excel workbook into my program and then try to create a new > excel workbook with a chart, the new workbook takes the data of the chart > from the source workbook and not from the sheet I specified. This happens > only if the data of the source workbook are still selected from the copy > before, if I click into another cell, my new created workbook will use the > data of its sheet which I specified. > > > > Does anybody know what this could be? In my code I clearly specify to use > the data of my new created worksheet. The name of the source workbook sheet > is completely different. Looks like excel ignore it and use the currently > selected data of any workbook. Is there a way to specify the Workbook and > Worksheet, which I want to use? > > > > Any help would be appreciated! > > Thanks, > > Stefanie > > NOTICE: This email message is for the sole use of the intended recipient(s) > and may contain confidential and privileged information. Any unauthorized > review, use, disclosure or distribution is prohibited. If you are not the > intended recipient, please contact the sender by reply email and destroy all > copies of the original message. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- According to theoretical physics, the division of spatial intervals as the universe evolves gives rise to the fact that in another timeline, your interdimensional counterpart received helpful advice from me...so be eternally pleased for them. From orasnita at gmail.com Tue Mar 1 08:44:35 2011 From: orasnita at gmail.com (Octavian Rasnita) Date: Tue, 1 Mar 2011 09:44:35 +0200 Subject: [python-win32] Possible future direction for PyGUI on Win32 References: <4D696319.8080803@canterbury.ac.nz><96FB0913B4C9465A8B1AB3EF8359AF63@teddy> <4D6C1E4C.4090803@canterbury.ac.nz> Message-ID: From: "Greg Ewing" > Octavian Rasnita wrote: >> From: "Greg Ewing" >> >>> No, if I go this way, I would probably stop maintaining >>> the current implementation. >> >> Oh, in that case imho I think this is a very bad idea. > > Can you elaborate on exactly what is bad about it, and > suggest an alternative? Windows Forms - based apps have a few disadvantages: - First, the most important, and with no solution is that Win32 GUI widgets are much fast responsive than Windows Forms, and it is annoying to use Windows Forms - based apps with the keyboard; - Second, it is harder to create executables that include the support for DotNet, because it is not sure that DotNet is available. The package should be either very big and include DotNet, or it should detect if it is not present and offer the possibility of downloading it from the web, but some computers are not connected to the internet...; - Windows Forms offer very many accessibility features for screen readers, however this GUI is *always* less accessible than the standard Win32 widgets for those who need to use a screen reader. - I think there are solutions for making Windows Forms - based apps already, and they can be used if somebody prefers to use this GUI, so it wouldn't be a good idea to dupplicate it and offer the same interface. > > The standard Windows GUI API is severely crippled compared > to what is available natively in Cocoa and Gtk. The only > alternatives I see at the moment are: > > * Allow Windows to hold back the development of PyGUI on > all the other platforms. > > * Implement the missing functionality on Windows in pure > Python -- a lot of work, and probably not practical for > something complex such as a rich text or HTML widget. > > * Rely on a third party library to supply the missing > functionality on Windows. > > -- > Greg I don't know which of these ways would be the most simple to implement, but it is true that it will be more difficult, because I've seen how these problems were solved in other GUIs like wxWIDGETS and SWT. wxWIDGETS offers custom widgets for those which are not offered by the standard Win32 API, but most of them are badly made with no corresponding accessibility features, and if those widgets are used in an application, they could steal the focus or make other problems that make the whole application not accessible for those who use a screen reader. So a better solution than the one offered by wxWIDGETS would mean much more work. In SWT, as far as I know, those widgets which are not offered by the Win32 API are not offered at all, but I am not sure, so others who may know more can comment. But if this is true, this is not an extraordinary solution either. However, I don't know if the focus should be to offer all the possible widget types under all platforms, because now there are more and more platforms considered, like different kind of PDAs and mobile phones, and it would probably be very hard or impossible to offer a GUI that can do everything everywhere. Octavian From mail at timgolden.me.uk Tue Mar 1 11:05:09 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 01 Mar 2011 10:05:09 +0000 Subject: [python-win32] Possible future direction for PyGUI on Win32 In-Reply-To: <4D6B6D73.3080701@timgolden.me.uk> References: <4D696319.8080803@canterbury.ac.nz> <4D6B6D73.3080701@timgolden.me.uk> Message-ID: <4D6CC4D5.8060100@timgolden.me.uk> On 28/02/2011 09:40, Tim Golden wrote: > Well, the last Svn commit was 4 weeks ago, by "barton_c", and Python27 > "support" (ie switches") were added 2 months ago. Looks like "Barton_C" > needs to do some advertising. I'll see if I can contact him/her through > sf. Got this reply from Barton, who's not subscribed to this list: """ Using the current state of the art, I freely mix wxPython, MS Framework 2.0 (others are hooking to .NET 4.0) and ctypes in full GUI apps and drivers. The current challenge for me is getting the whole thing working (together) on Ubuntu Maverick (10.10). I have brought the PythonDotNet project up to python27 compatibility, but have not published the binaries yet. """ TJG From smokefloat at gmail.com Tue Mar 1 11:14:24 2011 From: smokefloat at gmail.com (David Hutto) Date: Tue, 1 Mar 2011 05:14:24 -0500 Subject: [python-win32] Possible future direction for PyGUI on Win32 In-Reply-To: <4D6CC4D5.8060100@timgolden.me.uk> References: <4D696319.8080803@canterbury.ac.nz> <4D6B6D73.3080701@timgolden.me.uk> <4D6CC4D5.8060100@timgolden.me.uk> Message-ID: On Tue, Mar 1, 2011 at 5:05 AM, Tim Golden wrote: > On 28/02/2011 09:40, Tim Golden wrote: >> >> Well, the last Svn commit was 4 weeks ago, by "barton_c", and Python27 >> "support" (ie switches") were added 2 months ago. Looks like "Barton_C" >> needs to do some advertising. I'll see if I can contact him/her through >> sf. > > Got this reply from Barton, who's not subscribed to this list: since when is being subscribed a prerequisite to commenting? > > """ > Using the current state of the art, I freely mix wxPython, MS Framework 2.0 > (others are hooking to .NET 4.0) and ctypes in full GUI apps and drivers. > The current challenge for me is getting the whole thing working (together) > on Ubuntu Maverick (10.10). > I have brought the PythonDotNet project up to python27 compatibility, but > have not published the binaries yet. > > """ > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- According to theoretical physics, the division of spatial intervals as the universe evolves gives rise to the fact that in another timeline, your interdimensional counterpart received helpful advice from me...so be eternally pleased for them. From developers at tefnet.pl Tue Mar 1 11:19:02 2011 From: developers at tefnet.pl (Tefnet Developers) Date: Tue, 01 Mar 2011 11:19:02 +0100 Subject: [python-win32] Problem with win32print.SetPrinter In-Reply-To: References: <1298888553.2645.29.camel@cacko> Message-ID: <1298974742.7642.1.camel@cacko> Dnia 2011-02-28, pon o godzinie 19:11 -0500, Roger Upole pisze: > I think this is dependent on the printer driver. > Some use the paper size defined by the the form, > and others use the PaperSize member. The driver used is the generic postscript driver (MS Publisher Imagesetter) provided with Windows. My problem is that changing paper size in the default printer preferences UI changes both members of devmode. Changing the way I do it (as shown before) does not change the paper size in preferences UI - and that's exactly what I need to change. I guess that if both fields are affected by the UI then I should also change both to achieve the desired effect, right? bye, Filip Zyzniewski Tefnet From mail at timgolden.me.uk Tue Mar 1 11:19:46 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 01 Mar 2011 10:19:46 +0000 Subject: [python-win32] Possible future direction for PyGUI on Win32 In-Reply-To: References: <4D696319.8080803@canterbury.ac.nz> <4D6B6D73.3080701@timgolden.me.uk> <4D6CC4D5.8060100@timgolden.me.uk> Message-ID: <4D6CC842.6020408@timgolden.me.uk> On 01/03/2011 10:14, David Hutto wrote: > On Tue, Mar 1, 2011 at 5:05 AM, Tim Golden wrote: >> On 28/02/2011 09:40, Tim Golden wrote: >>> >>> Well, the last Svn commit was 4 weeks ago, by "barton_c", and Python27 >>> "support" (ie switches") were added 2 months ago. Looks like "Barton_C" >>> needs to do some advertising. I'll see if I can contact him/her through >>> sf. >> >> Got this reply from Barton, who's not subscribed to this list: > > since when is being subscribed a prerequisite to commenting? FWIW, I meant: "... and who had therefore not seen this discussion" but, as a matter of fact, if a non-subscriber posts to this list, the post is held in a moderator's queue and has to be released explicitly. I've given him the information about this list, of which he was unaware so he can decide for himself whether to post or subscribe or whatever... TJG From fuzzyman at gmail.com Tue Mar 1 14:21:32 2011 From: fuzzyman at gmail.com (Michael Foord) Date: Tue, 1 Mar 2011 13:21:32 +0000 Subject: [python-win32] Possible future direction for PyGUI on Win32 In-Reply-To: References: <4D696319.8080803@canterbury.ac.nz> <96FB0913B4C9465A8B1AB3EF8359AF63@teddy> <4D6C1E4C.4090803@canterbury.ac.nz> Message-ID: On 1 March 2011 07:44, Octavian Rasnita wrote: > From: "Greg Ewing" > >> Octavian Rasnita wrote: >> >>> From: "Greg Ewing" >>> >>> No, if I go this way, I would probably stop maintaining >>>> the current implementation. >>>> >>> >>> Oh, in that case imho I think this is a very bad idea. >>> >> >> Can you elaborate on exactly what is bad about it, and >> suggest an alternative? >> > > Windows Forms - based apps have a few disadvantages: > - First, the most important, and with no solution is that Win32 GUI widgets > are much fast responsive than Windows Forms, I've written (quite large) desktop Windows Forms applications with .NET and just not found this to be the case - even when written with IronPython which isn't the fastest .NET language there is. > and it is annoying to use Windows Forms - based apps with the keyboard; > This need not be the case. You just need to set tab order and provide shortcuts. > - Second, it is harder to create executables that include the support for > DotNet, because it is not sure that DotNet is available. .NET is pretty ubiquitous these days - see other emails on the topic. > The package should be either very big and include DotNet, Definitely not. > or it should detect if it is not present and offer the possibility of > downloading it from the web, but some computers are not connected to the > internet...; > Installers can detect this and provide a link. > - Windows Forms offer very many accessibility features for screen readers, > however this GUI is *always* less accessible than the standard Win32 widgets > for those who need to use a screen reader. > Evidence for this? > - I think there are solutions for making Windows Forms - based apps > already, and they can be used if somebody prefers to use this GUI, so it > wouldn't be a good idea to dupplicate it and offer the same interface. > > The point is for writing *cross platform* applications that just happen to use Windows Forms on Windows. All the best, Michael Foord > > >> The standard Windows GUI API is severely crippled compared >> to what is available natively in Cocoa and Gtk. The only >> alternatives I see at the moment are: >> >> * Allow Windows to hold back the development of PyGUI on >> all the other platforms. >> >> * Implement the missing functionality on Windows in pure >> Python -- a lot of work, and probably not practical for >> something complex such as a rich text or HTML widget. >> >> * Rely on a third party library to supply the missing >> functionality on Windows. >> >> -- >> Greg >> > > > > I don't know which of these ways would be the most simple to implement, but > it is true that it will be more difficult, because I've seen how these > problems were solved in other GUIs like wxWIDGETS and SWT. > > wxWIDGETS offers custom widgets for those which are not offered by the > standard Win32 API, but most of them are badly made with no corresponding > accessibility features, and if those widgets are used in an application, > they could steal the focus or make other problems that make the whole > application not accessible for those who use a screen reader. > So a better solution than the one offered by wxWIDGETS would mean much more > work. > > In SWT, as far as I know, those widgets which are not offered by the Win32 > API are not offered at all, but I am not sure, so others who may know more > can comment. But if this is true, this is not an extraordinary solution > either. > > However, I don't know if the focus should be to offer all the possible > widget types under all platforms, because now there are more and more > platforms considered, like different kind of PDAs and mobile phones, and it > would probably be very hard or impossible to offer a GUI that can do > everything everywhere. > > Octavian > > > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- http://www.voidspace.org.uk/ May you do good and not evil May you find forgiveness for yourself and forgive others May you share freely, never taking more than you give. -- the sqlite blessing http://www.sqlite.org/different.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From roche.maxime at creativeinfinity.fr Tue Mar 1 12:38:53 2011 From: roche.maxime at creativeinfinity.fr (Creative iNFiNiTY) Date: Tue, 1 Mar 2011 12:38:53 +0100 Subject: [python-win32] (again) get Window Title encoding In-Reply-To: <4D6C1A64.8060506@gmail.com> References: <2917B8BC-F174-4B93-BCFE-5409980E8212@creativeinfinity.fr> <4D6C1A64.8060506@gmail.com> Message-ID: Hello, i wan't to decode the title to utf-8 'mbcs' encoding doesn't help me sometimes the browser surf on russian, japanese, chinese language and i couldn't decode if i don't know the encoding..... thanks for your help Roche Maxime Le 28 f?vr. 2011 ? 22:57, Mark Hammond a ?crit : > You might find the 'mbcs' encoding is what you are after? > > Cheers, > > Mark > > On 28/02/2011 11:22 PM, Creative iNFiNiTY wrote: >> here is some code to get the window title: >> >> hwnd = win32gui.GetForegroundWindow() >> # we want the desktop window >> objid = pyAA.Constants.OBJID_WINDOW >> # get the object >> ao = pyAA.AccessibleObjectFromWindow(hwnd, objid) >> pr= ao.GetProcessAndThreadID() >> processes = win32process.EnumProcesses() >> for pid in processes: >> if pid in pr: >> handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS,False, pid) >> processactif=win32process.GetModuleFileNameEx(handle, 0) >> >> WindowTitle=ao.Name >> another code: >> importwin32gui >> w=win32gui >> w.GetWindowText (w.GetForegroundWindow()) >> >> * >> * >> and i need to get the encoding of the title for internalisation purpose, >> does anyone know how to get it ? >> the automatic charset recognition in python ," chardet" don't work for >> every charset, >> if i can take it by the process that will be great. >> Thanks >> >> Roche Maxime >> Creative iNFiNiTY >> >> >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 > From mhammond at skippinet.com.au Tue Mar 1 23:34:11 2011 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 02 Mar 2011 09:34:11 +1100 Subject: [python-win32] (again) get Window Title encoding In-Reply-To: References: <2917B8BC-F174-4B93-BCFE-5409980E8212@creativeinfinity.fr> <4D6C1A64.8060506@gmail.com> Message-ID: <4D6D7463.4070103@skippinet.com.au> On 1/03/2011 10:38 PM, Creative iNFiNiTY wrote: > Hello, > i wan't to decode the title to utf-8 > 'mbcs' encoding doesn't help me > sometimes the browser surf on russian, japanese, chinese language > and i couldn't decode if i don't know the encoding..... > thanks for your help You can't decode the title to utf8 - what you need to do is decode the title *from* whatever encoding it is in, then encode it to utf8. So something like window_title.decode('mbcs').encode('utf-8') should work in most cases. HTH, Mark From rupole at hotmail.com Wed Mar 2 00:11:50 2011 From: rupole at hotmail.com (Roger Upole) Date: Tue, 1 Mar 2011 18:11:50 -0500 Subject: [python-win32] Problem with win32print.SetPrinter References: <1298888553.2645.29.camel@cacko> <1298974742.7642.1.camel@cacko> Message-ID: "Tefnet Developers" wrote in message news:1298974742.7642.1.camel at cacko... > Dnia 2011-02-28, pon o godzinie 19:11 -0500, Roger Upole pisze: >> I think this is dependent on the printer driver. >> Some use the paper size defined by the the form, >> and others use the PaperSize member. > > The driver used is the generic postscript driver (MS Publisher > Imagesetter) provided with Windows. > > My problem is that changing paper size in the default printer > preferences UI changes both members of devmode. > > Changing the way I do it (as shown before) does not change the paper > size in preferences UI - and that's exactly what I need to change. > > I guess that if both fields are affected by the UI then I should also > change both to achieve the desired effect, right? > > bye, > Filip Zyzniewski > Tefnet Try adding a second GetPrinter immediately after the SetPrinter, and see if the returned devmode has the expected values. Roger From timr at probo.com Wed Mar 2 00:30:54 2011 From: timr at probo.com (Tim Roberts) Date: Tue, 1 Mar 2011 15:30:54 -0800 Subject: [python-win32] Problem with win32print.SetPrinter In-Reply-To: References: <1298888553.2645.29.camel@cacko> <1298974742.7642.1.camel@cacko> Message-ID: <4D6D81AE.6000208@probo.com> Roger Upole wrote: > "Tefnet Developers" wrote in message > news:1298974742.7642.1.camel at cacko... >> >> The driver used is the generic postscript driver (MS Publisher >> Imagesetter) provided with Windows. >> >> My problem is that changing paper size in the default printer >> preferences UI changes both members of devmode. >> >> Changing the way I do it (as shown before) does not change the paper >> size in preferences UI - and that's exactly what I need to change. >> >> I guess that if both fields are affected by the UI then I should also >> change both to achieve the desired effect, right? >> >> bye, >> Filip Zyzniewski >> Tefnet > Try adding a second GetPrinter immediately after the SetPrinter, > and see if the returned devmode has the expected values. This kind of thing is very tricky in Windows -- much trickier than it should be -- and I've been doing Windows programming for a very, very long time. I have a wxPython application that I use to print envelopes through my Dell 3100 laser printer. The printer has a "multi-purpose tray" that I keep stocked with #10 envelopes. It's very convenient, and since my handwriting it terrible, the people I write to appreciate it as well. Recently, I upgraded from Python 2.5 to Python 2.7, and suddenly my envelope application stopped working. It would print in portrait mode on the normal paper stock, instead of selecting the envelopes in the multi-purpose tray. It required two or three hours of fairly intense hacking before I figured out a recipe to make it work again. If I had not previously been a GDI driver developer, I doubt that I could have figured out the DEVMODE magic that was required. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From lueck at ipk-gatersleben.de Wed Mar 2 12:38:54 2011 From: lueck at ipk-gatersleben.de (=?iso-8859-1?Q?Stefanie_L=FCck?=) Date: Wed, 2 Mar 2011 12:38:54 +0100 Subject: [python-win32] Python Excel - 2 workbooks affect each other[SEC=UNCLASSIFIED] In-Reply-To: References: <000301cbd752$696751a0$1022a8c0@ipkgatersleben.de> Message-ID: <000001cbd8ce$692a17e0$1022a8c0@ipkgatersleben.de> Hello! Thanks for the answers and pointing me to paste/copy references of Excel! I solved the problem by adding self.xlApp.CutCopyMode = False into my excel code just after I call self.xlApp = Dispatch ('Excel.Application'). I still don?t know how Excel keep the reference from coping data into another program, save the data from the clipboard in a text (!) file, writing the proceeded data from a text file into a new created Excel workbook But anyway, I solved it :-) Thanks and kind regards, Stefanie _____ Von: python-win32-bounces+lueck=ipk-gatersleben.de at python.org [mailto:python-win32-bounces+lueck=ipk-gatersleben.de at python.org] Im Auftrag von Andrew MacIntyre Gesendet: Dienstag, 1. M?rz 2011 01:15 An: python-win32 at python.org Betreff: Re: [python-win32] Python Excel - 2 workbooks affect each other[SEC=UNCLASSIFIED] [apologies for top post] I?m far from an expert, or even experienced, in Excel however the term ?paste? rings bells. Behind the scenes, material in the clipboard has lots of metadata and a selection copied from one open workbook includes the references to that workbook so when you paste it Excel includes those references and effectively links the pasted to cells to the pasted from cells. If you must use paste, then you will probably need to use ?paste special? and select ?values? ? this should break the references back to the original source. If you carefully look at the ?formula? of a pasted cell, you might see how the source workbook & worksheet are identified ? I know that this sort of thing is visible when using the ?function wizard? with such Excel functions as VLOOKUP. -------------------------> "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/ From: python-win32-bounces+andrew.macintyre=acma.gov.au at python.org [mailto:python-win32-bounces+andrew.macintyre=acma.gov.au at python.org] On Behalf Of Stefanie L?ck Sent: Tuesday, 1 March 2011 1:19 AM To: python-win32 at python.org Subject: [python-win32] Python Excel - 2 workbooks affect each other Hello! I have a strange excel behaviour if 2 workbooks are open. I?m trying to create an excel workbook with a bar chart from some data which comes from my wxPython program. If I paste the data into my program from any source except another excel file, everything works as expected. But if I copy the values from a source excel workbook into my program and then try to create a new excel workbook with a chart, the new workbook takes the data of the chart from the source workbook and not from the sheet I specified. This happens only if the data of the source workbook are still selected from the copy before, if I click into another cell, my new created workbook will use the data of its sheet which I specified. Does anybody know what this could be? In my code I clearly specify to use the data of my new created worksheet. The name of the source workbook sheet is completely different. Looks like excel ignore it and use the currently selected data of any workbook. Is there a way to specify the Workbook and Worksheet, which I want to use? Any help would be appreciated! Thanks, Stefanie NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -------------- next part -------------- An HTML attachment was scrubbed... URL: From aahz at pythoncraft.com Wed Mar 2 17:19:07 2011 From: aahz at pythoncraft.com (Aahz) Date: Wed, 2 Mar 2011 08:19:07 -0800 Subject: [python-win32] Problem with msvcr90.dll In-Reply-To: <1296576717.10017.75.camel@cacko> References: <1296474888.4858.21.camel@cacko> <4D474953.3010409@gmail.com> <1296576717.10017.75.camel@cacko> Message-ID: <20110302161907.GA25182@panix.com> On Tue, Feb 01, 2011, Tefnet Developers wrote: > > $ make pytest.exe > i586-mingw32msvc-gcc -I./include -I./include/python -Wall -pedantic > -std=c99 -c -o pytest.o pytest.c > i586-mingw32msvc-gcc -L./lib -o pytest.exe pytest.o -lmingw32 -lpython26 > rm pytest.o > > The output looks like this: > > C:\>pytest > Traceback (most recent call last): > File "", line 3, in > File "C:\Python26\lib\site-packages\win32\lib\pywintypes.py", line > 124, in > __import_pywin32_system_module__("pywintypes", globals()) > File "C:\Python26\lib\site-packages\win32\lib\pywintypes.py", line 64, > in __import_pywin32_system_module__ > import _win32sysloader > ImportError: DLL load failed: The specified module could not be found What happens if you use VC++ 2008 Express? (Yes, that "should" not change anything, but I've seen people report all kinds of weird problems with mingw.) -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Programming language design is not a rational science. Most reasoning about it is at best rationalization of gut feelings, and at worst plain wrong." --GvR, python-ideas, 2009-03-01 From skippy.hammond at gmail.com Wed Mar 2 23:25:55 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 03 Mar 2011 09:25:55 +1100 Subject: [python-win32] Problem with msvcr90.dll In-Reply-To: <1296576717.10017.75.camel@cacko> References: <1296474888.4858.21.camel@cacko> <4D474953.3010409@gmail.com> <1296576717.10017.75.camel@cacko> Message-ID: <4D6EC3F3.8020902@gmail.com> On 2/02/2011 3:11 AM, Tefnet Developers wrote: > Dnia 2011-02-01, wto o godzinie 10:44 +1100, Mark Hammond pisze: >> This stuff is painful and poorly documented. Is it possible the code >> which triggers the failing import is on a different thread than the one >> which loaded Python? If so, I suspect the magic done by Python in >> dl_nt.c may not be kicking in, which is supposed to ensure all python >> modules are loaded using the "activation context" defined by pythonxx.dll. > > The smallest piece of program that shows the problem: > > $ cat pytest.c > #include > > > int main(void) { > Py_Initialize(); > PyRun_SimpleString( > "import traceback \n" > "try:\n" > " import pywintypes\n" > "except:\n" > " traceback.print_exc()\n" > ); > } > > $ make pytest.exe > i586-mingw32msvc-gcc -I./include -I./include/python -Wall -pedantic > -std=c99 -c -o pytest.o pytest.c > > i586-mingw32msvc-gcc -L./lib -o pytest.exe pytest.o -lmingw32 -lpython26 > rm pytest.o What happens if you give that executable a manifest referencing the CRT? Note that things changed since pywin32 build 214 - now (almost) none of the pywin32 pyd files have a manifest at all, meaning they can be loaded correctly by Python itself in all cases - but the thing that loads Python *must* have a manifest - ie, python.exe needs (and has) one, as does the DLL which loads Python COM objects. It gets even more complicated if Python is loaded via LoadLibrary - you can check the source to pythoncomloader in the pywin32 repo for more details (the short version is that the same hacks that Python itself does WRT "activation contexts" needs to be done...) Aahz's suggestion is a good one - you should use the VC compiler as your "baseline", then try and get mingw going one you have initial success with VC. HTH, Mark From timr at probo.com Wed Mar 2 23:30:42 2011 From: timr at probo.com (Tim Roberts) Date: Wed, 2 Mar 2011 14:30:42 -0800 Subject: [python-win32] Problem with msvcr90.dll In-Reply-To: <4D6EC3F3.8020902@gmail.com> References: <1296474888.4858.21.camel@cacko> <4D474953.3010409@gmail.com> <1296576717.10017.75.camel@cacko> <4D6EC3F3.8020902@gmail.com> Message-ID: <4D6EC512.7060307@probo.com> Mark Hammond wrote: > > What happens if you give that executable a manifest referencing the CRT? > Note that things changed since pywin32 build 214 - now (almost) none > of the pywin32 pyd files have a manifest at all, meaning they can be > loaded correctly by Python itself in all cases - but the thing that > loads Python *must* have a manifest - ie, python.exe needs (and has) > one, as does the DLL which loads Python COM objects. It gets even more > complicated if Python is loaded via LoadLibrary - you can check the > source to pythoncomloader in the pywin32 repo for more details (the > short version is that the same hacks that Python itself does WRT > "activation contexts" needs to be done...) Let us HOPE that Python quickly migrates to Visual Studio 2010, in which the team has wisely decided to abandon the side-by-side stuff altogether and go back to a simpler way of life, where having the files in \Windows\System32 is enough for everyone. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From vernondcole at gmail.com Thu Mar 3 06:15:10 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Wed, 2 Mar 2011 22:15:10 -0700 Subject: [python-win32] Possible trouble with pywin23-216 on python 3.2 Message-ID: Attempting to install using the binary installer, the installer gets to "postinstall script finished", but the display window says: v v v v v v v v Copied pythoncom32.dll to C:\Windows\system32\pythoncom32.dll Copied pythoncomloader32.dll to C:\Windows\system32\pythoncomloader32.dll Copied pywintypes32.dll to C:\Windows\system32\pywintypes32.dll FAILED to register the Python COM objects -> Software\Python\PythonCore\3.2\Help[None]=None -> Software\Python\PythonCore\3.2\Help\Pythonwin Reference[None]='C:\\Python32\\Lib\\site-packages\\PyWin32.chm' Pythonwin has been registered in context menu Shortcut for Pythonwin created Shortcut to documentation created Traceback (most recent call last): File "", line 372, in install File "", line 170, in RegisterCOMObjects File "C:\Python32\lib\site-packages\win32com\server\register.py", line 47 except win32api.error, (code, fn, msg): ^ SyntaxError: invalid syntax Traceback (most recent call last): File "", line 604, in File "", line 471, in install File "C:\Python32\lib\site-packages\win32com\client\__init__.py", line 424 except pythoncom.com_error, details: ^ SyntaxError: invalid syntax ^ ^ ^ ^ ^ ^ When the adodbapi test is run, it gives: v v v v v v C:\hg\adodbapi\testP3k>c:\python32\python.exe testadodbapi.py Traceback (most recent call last): File "testadodbapi.py", line 28, in import win32com.client File "c:\python32\lib\site-packages\win32com\client\__init__.py", line 424 except pythoncom.com_error, details: ^ SyntaxError: invalid syntax ^ ^ ^ ^ ^ ^ ^ ^ ^ Which sounds oddly familiar. This is on Windows Vista Home Basic. -- Vernon -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Thu Mar 3 08:10:22 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 03 Mar 2011 18:10:22 +1100 Subject: [python-win32] Possible trouble with pywin23-216 on python 3.2 In-Reply-To: References: Message-ID: <4D6F3EDE.5090908@gmail.com> On 3/03/2011 4:15 PM, Vernon Cole wrote: > Attempting to install using the binary installer, the installer gets to > "postinstall script finished", but the display window says: > v v v v v v v v > Copied pythoncom32.dll to C:\Windows\system32\pythoncom32.dll > Copied pythoncomloader32.dll to C:\Windows\system32\pythoncomloader32.dll > Copied pywintypes32.dll to C:\Windows\system32\pywintypes32.dll > FAILED to register the Python COM objects > -> Software\Python\PythonCore\3.2\Help[None]=None > -> Software\Python\PythonCore\3.2\Help\Pythonwin > Reference[None]='C:\\Python32\\Lib\\site-packages\\PyWin32.chm' > Pythonwin has been registered in context menu > Shortcut for Pythonwin created > Shortcut to documentation created > Traceback (most recent call last): > File "", line 372, in install > File "", line 170, in RegisterCOMObjects > File "C:\Python32\lib\site-packages\win32com\server\register.py", line 47 > except win32api.error, (code, fn, msg): > ^ > SyntaxError: invalid syntax > Traceback (most recent call last): > File "", line 604, in > File "", line 471, in install > File "C:\Python32\lib\site-packages\win32com\client\__init__.py", > line 424 > except pythoncom.com_error, details: > ^ > SyntaxError: invalid syntax > ^ ^ ^ ^ ^ ^ > > When the adodbapi test is run, it gives: > v v v v v v > C:\hg\adodbapi\testP3k>c:\python32\python.exe testadodbapi.py > Traceback (most recent call last): > File "testadodbapi.py", line 28, in > import win32com.client > File "c:\python32\lib\site-packages\win32com\client\__init__.py", > line 424 > except pythoncom.com_error, details: > ^ > SyntaxError: invalid syntax > ^ ^ ^ ^ ^ ^ ^ ^ ^ > Which sounds oddly familiar. > This is on Windows Vista Home Basic. *sob* - I tested 3.2 with a 64bit build and didn't perform a test install of the 3.2 32bit exe. The 64bit one is fine and I don't understand how that could have happened - in theory the 2 builds share the same .py files - but it has happened :( I'll check 3.1 tomorrow and try to determine what went wrong in the build process, then put up new builds where necessary... Thanks, Mark From mail at timgolden.me.uk Thu Mar 3 09:50:49 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 03 Mar 2011 08:50:49 +0000 Subject: [python-win32] Possible trouble with pywin23-216 on python 3.2 In-Reply-To: References: Message-ID: <4D6F5669.5000907@timgolden.me.uk> """ Re: [python-win32] Possible trouble with pywin23-216 on python 3.2 """ Aha! There's your problem: you're trying to install pywin23. Don't know why you didn't spot it yourself... ;) TJG From vernondcole at gmail.com Thu Mar 3 14:12:02 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Thu, 3 Mar 2011 06:12:02 -0700 Subject: [python-win32] Possible trouble with pywin23-216 on python 3.2 In-Reply-To: <4D6F5669.5000907@timgolden.me.uk> References: <4D6F5669.5000907@timgolden.me.uk> Message-ID: Smarta.... (err) (umm) Thanks Tim, I'll try that. -- Vernon On Mar 3, 2011 1:50 AM, "Tim Golden" wrote: > """ > Re: [python-win32] Possible trouble with pywin23-216 on python 3.2 > """ > > Aha! There's your problem: you're trying to install pywin23. > Don't know why you didn't spot it yourself... ;) > > > TJG -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.ewing at canterbury.ac.nz Thu Mar 3 21:33:23 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Fri, 04 Mar 2011 09:33:23 +1300 Subject: [python-win32] Possible trouble with pywin23-216 on python 3.2 In-Reply-To: <4D6F5669.5000907@timgolden.me.uk> References: <4D6F5669.5000907@timgolden.me.uk> Message-ID: <4D6FFB13.9060307@canterbury.ac.nz> Tim Golden wrote: > """ > Re: [python-win32] Possible trouble with pywin23-216 on python 3.2 > """ > > Aha! There's your problem: you're trying to install pywin23. Unless of course you're using one of those rare machines based on Intel's little-known 23-bit architecture. (There was a typo early on in the design phase that wasn't spotted until an embarrassingly late stage of the development process. They hijacked the time machine and tried to cover it up, but a few prototype machines slipped through.) -- Greg From greg.ewing at canterbury.ac.nz Fri Mar 4 03:31:36 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Fri, 04 Mar 2011 15:31:36 +1300 Subject: [python-win32] Fonts behaving differently with Py3/216 Message-ID: <4D704F08.8010104@canterbury.ac.nz> I recently tried running PyGUI on Python 3 using pywin32 build 216, and a couple of things are not working quite the same way as they were with Python 2 and build 213. 1) The default font used for control labels etc. is slightly smaller. 2) When I calculate the width of a piece of text using DC.GetTextExtent() I get a value that is too small, and doesn't match the actual size of the text as it is drawn. Anyone have any idea what might have changed, and what I can do about it? -- Greg From skippy.hammond at gmail.com Fri Mar 4 04:37:30 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 04 Mar 2011 14:37:30 +1100 Subject: [python-win32] Fonts behaving differently with Py3/216 In-Reply-To: <4D704F08.8010104@canterbury.ac.nz> References: <4D704F08.8010104@canterbury.ac.nz> Message-ID: <4D705E7A.7090507@gmail.com> On 4/03/2011 1:31 PM, Greg Ewing wrote: > I recently tried running PyGUI on Python 3 using > pywin32 build 216, and a couple of things are > not working quite the same way as they were with > Python 2 and build 213. > > 1) The default font used for control labels etc. > is slightly smaller. > > 2) When I calculate the width of a piece of text > using DC.GetTextExtent() I get a value that is > too small, and doesn't match the actual size of > the text as it is drawn. > > Anyone have any idea what might have changed, > and what I can do about it? What version of python and how many bits? I'm guessing you tried 3.2, which means you must have used the 64bit version (as the 32 bit version of pywin32 appears to have 2.x syntax .py files). Assuming you've been using 32bit builds on 2.x, I guess that could point to a bug in the 64bit port of pywin32? The only other thing I can think if is the manifest changes - windows uses the manifest of the "owning hmodule" for some things (notably the version of the "common controls" used), which is why the winxpgui module exists. It seems unlikely, but I wonder if those changes have told windows to put things in some kind of compatibility mode. Cheers, Mark From greg.ewing at canterbury.ac.nz Fri Mar 4 05:26:44 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Fri, 04 Mar 2011 17:26:44 +1300 Subject: [python-win32] Fonts behaving differently with Py3/216 In-Reply-To: <4D705E7A.7090507@gmail.com> References: <4D704F08.8010104@canterbury.ac.nz> <4D705E7A.7090507@gmail.com> Message-ID: <4D706A04.6040706@canterbury.ac.nz> Mark Hammond wrote: > What version of python and how many bits? I'm guessing you tried 3.2, > which means you must have used the 64bit version No, it's 3.1, and 32 bit. It can't be 64, because the machine I'm running it on can't handle that. (And it's definitely not 23 bit either. :-) > The only other thing I can think if is the manifest changes - windows > uses the manifest of the "owning hmodule" for some things I don't really know anything about these manifest things. Is there some tool I can use to examine them and see whether anything is different? -- Greg From mhammond at skippinet.com.au Fri Mar 4 05:30:56 2011 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 04 Mar 2011 15:30:56 +1100 Subject: [python-win32] Fonts behaving differently with Py3/216 In-Reply-To: <4D706A04.6040706@canterbury.ac.nz> References: <4D704F08.8010104@canterbury.ac.nz> <4D705E7A.7090507@gmail.com> <4D706A04.6040706@canterbury.ac.nz> Message-ID: <4D706B00.4080500@skippinet.com.au> On 4/03/2011 3:26 PM, Greg Ewing wrote: > Mark Hammond wrote: > >> What version of python and how many bits? I'm guessing you tried 3.2, >> which means you must have used the 64bit version > > No, it's 3.1, and 32 bit. It can't be 64, because the > machine I'm running it on can't handle that. (And it's > definitely not 23 bit either. :-) Interesting - I'm really confused how the 32 bit version for 3.2 failed to build correctly! >> The only other thing I can think if is the manifest changes - windows >> uses the manifest of the "owning hmodule" for some things > > I don't really know anything about these manifest things. > Is there some tool I can use to examine them and see > whether anything is different? The Windows SDK (and I assume VC - haven't checked) comes with a "manifest tool" - mt.exe. The syntax is fairly obscure, but it allows you to extract, change and add manifests (but not remove them AFAIK). Note the manifest ID for DLLs is 2 - so the command to extract would be something like: mt.exe -inputresource:path\to\whatever.pyd;#2 -out:out.txt HTH, Mark From ladymcse2000 at gmail.com Fri Mar 4 08:46:04 2011 From: ladymcse2000 at gmail.com (Becky Mcquilling) Date: Thu, 3 Mar 2011 23:46:04 -0800 Subject: [python-win32] Mapping Drives in Python Message-ID: Hi: Hoping you guys can help out a python noob here. I have a list of machines that I am backing up flat files from to one central machine. I need to: a) Map Drives and b) run robocopy I am iterating through a text file that has the share names and the and directory that I want to be created: count = 0 alphabet = 'klmnopqrstuv' today = datetime.date.today() backup_servers = {} f = open('c:/test/backup_shares.txt') for line in f: backup_server = line.split(',') backup_servers[ backup_server[0]]=backup_server[1] for i, v in backup_servers.items(): backup_shares = i archive_dir = v.strip() archive_dir += str(today) drive_letter = alphabet[count] count += 1 The above creates a dictionary and I iterate through that. backup_shares = '\\server_name\c$' for example and archive_dir is the directory on the local machine that I will create with a timestamp to backup the files to on the local machine example "d:\backup_dir\03-03-2011\files What I want to do is map a drive, which is why the alphabet string. I iterate through that and then get k first backup dir, etc. I'm not sure what method to call to map a drive or how the best way to call robocopy is. I don't have the choice of using IronPython. I have the win32 modules. And this works: win32net.NetUseAdd(None,1,{'remote':r'\\server_name\c$','local':'K:'}) However, I want to use the variable backup_server and insert the drive_letter variable in the script snippet, but I haven't been able to make that work. Any suggestions? Also, suggestions and examples on calling robocopy? Thanks so much! Becky -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Fri Mar 4 09:50:29 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Fri, 4 Mar 2011 01:50:29 -0700 Subject: [python-win32] Fonts behaving differently with Py3/216 In-Reply-To: <4D705E7A.7090507@gmail.com> References: <4D704F08.8010104@canterbury.ac.nz> <4D705E7A.7090507@gmail.com> Message-ID: On Thu, Mar 3, 2011 at 8:37 PM, Mark Hammond wrote: [...] > > the 32 bit version of pywin32 appears to have 2.x syntax .py files). [...] No, not completely 2.x syntax, only "except SomeError, e" so if you get lucky, some modules might import okay. ? The version of setup.py that I use in the stand-alone version of adodbapi runs pretty much the standard fixer set. (I provided a version of it to Greg for PyGUI, too.) But the pywin32 version of setup.py uses a smaller, hard coded list of fixers. We had to add the "raise" fixer for adodbapi. I suspect that we need to add the "except" fixer as well. v v v v except Converts except X, T to except X as T. ^ ^ ^ ^ -- Vernon P.S.? I actually _did_ work on a 24 bit computer once (the Harris Datacraft) but 23 bits is, as mathematicians have discovered, an odd number. From vernondcole at gmail.com Fri Mar 4 10:17:53 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Fri, 4 Mar 2011 02:17:53 -0700 Subject: [python-win32] Mapping Drives in Python In-Reply-To: References: Message-ID: I've never used robocopy -- never heard about it until your post -- but it sounded funny to me that it should need to use drive letter mappings. Microsoft has been moving away from them since MS DOS days. Sure enough, this shiny new command line utility can be used with server share names as well as drive letters. I tried typing "robocopy /?" on my Vista machine, and I get this: v v v v v Usage :: ROBOCOPY source destination [file [file]...] [options] source :: Source Directory (drive:\path or \\server\share\path). destination :: Destination Dir (drive:\path or \\server\share\path). file :: File(s) to copy (names/wildcards: default is "*.*"). ^ ^ ^ ^ ^ Note the "or \\server\share\path" in that help text. That would be the way to go. Use server names, not drive letters. Remember that Python uses the backslash as an escape character in string literals, so it takes some work to make a Windows server name. A double backslash becomes one backslash, so to get two you need to type four. "\\\\someserver\\someshare\\somepath". It's easier to use the "raw string" feature by putting an "r" before the opening quote. r"\\someserver\someshare\somepath" in Python. -- Vernon Cole On Fri, Mar 4, 2011 at 12:46 AM, Becky Mcquilling wrote: > Hi: > Hoping you guys can help out a python noob here. > I have a list of machines that I am backing up flat files from to one > central machine. ?I need to: > a) ?Map Drives and b) run robocopy > I am iterating through a text file that has the share names and the and > directory that I want to be created: > > count = 0 > alphabet = 'klmnopqrstuv' > today = datetime.date.today() > backup_servers = {} > f = open('c:/test/backup_shares.txt') > for line in f: > ?? ?backup_server = line.split(',') > ?? ?backup_servers[ backup_server[0]]=backup_server[1] > for i, v in backup_servers.items(): > ?? ?backup_shares = i > ?? ?archive_dir = v.strip() > ?? ?archive_dir += str(today) > ?? ?drive_letter = alphabet[count] > ?? ?count += 1 > > The above creates a dictionary and I iterate through that. > backup_shares = '\\server_name\c$' for example and archive_dir is the > directory on the local machine that I will create with a timestamp to backup > the files to on the local machine example "d:\backup_dir\03-03-2011\files > What I want to do is map a drive, which is why the alphabet string. ?I > iterate through that and then get k first backup dir, etc. > I'm not sure what method to call to map a drive or how the best way to call > robocopy is. ?I don't have the choice of using IronPython. ?I have the win32 > modules. > And this works: > ?win32net.NetUseAdd(None,1,{'remote':r'\\server_name\c$','local':'K:'}) > However, I want to use the variable backup_server and insert the > drive_letter variable in the script snippet, but I haven't been able to make > that work. ?Any suggestions? > Also, suggestions and examples on calling robocopy? > Thanks so much! > Becky > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From mc at mclaveau.com Fri Mar 4 11:23:37 2011 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 4 Mar 2011 11:23:37 +0100 Subject: [python-win32] [ANN] pywin32 build 216 released. In-Reply-To: <4D6C1911.5010209@skippinet.com.au> References: <4D6A3826.7020106@skippinet.com.au> <9D6FE5C2371A4297A8FE81ECE0C95B8A@MCI1330> <4D6B3E7C.4080701@gmail.com> <59AD9B91E48B42B5B94DA321C122F903@MCI1330> <4D6C1911.5010209@skippinet.com.au> Message-ID: <2F0BB46DEE7E4FAB86CCCD9107A11003@MCI1330> Hi! > Could you also please try "wscript.exe win32com\test\testInterp.vbs" This is OK. BUT, if I add this line: import win32ui in the script C:\Python26\Lib\site-packages\win32com\servers\interp.py the test give the (allways same) error. I tried on : Python 2.6.5 with Windows 7 32 bits Python 2.7 with Windows 7 64 bits (& Python/Pywin 32 bits) The problem seems really linked to win32ui... @-salutations -- Michel Claveau From ayaskanta.swain at altair.com Fri Mar 4 12:59:03 2011 From: ayaskanta.swain at altair.com (Ayaskanta Swain) Date: Fri, 4 Mar 2011 17:29:03 +0530 Subject: [python-win32] How to read the target of a Windows Shortcut Message-ID: <21581D39FA3BDF40904D75AF9653CE260608A4D4@blrex.prog.altair.com> Hi, I want to know the target path of a windows shortcut. How do i read the short cut & retrieve the actual target path it is pointing to? I searched the internet & all the documents I found there refer to use Win32com.shell or win32com.client module but was not satisfied with the solutions given there. I don't want to create a new shortcut or update an existing one. What I want is to read the target location from an existing shortcut. The shortcut can be anywhere in my computer & not necessarily on desktop. For example - C:\temp\my_shortcut.lnk which is pointing to D:\john\temp\myfile.txt file. Here i can pass the shortcut path "C:\temp\my_shortcut.lnk" to my python script & then i want to retrieve the target file's path from that shortcut. Is there anything equivalent of os.readlink(symlink) which is used on Unix systems? Is there any way to do that using win32com.shell modules? The following code works if the target file exists & hence returns me the absolute path of the target, but fails if the shortcut is broken i.e if the target file has been removed. In the later case this code creates a target file of zero (0) size with the same path. This is bad .I want to detect the broken shortcut case. shell = win32com.client.Dispatch("WScript.Shell") shortcut = shell.CreateShortCut(absolutepath) Any help to solve this issue will be highly appreciated. Regards Ayaskant Bangalore -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Fri Mar 4 13:00:21 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 04 Mar 2011 12:00:21 +0000 Subject: [python-win32] How to read the target of a Windows Shortcut In-Reply-To: <21581D39FA3BDF40904D75AF9653CE260608A4D4@blrex.prog.altair.com> References: <21581D39FA3BDF40904D75AF9653CE260608A4D4@blrex.prog.altair.com> Message-ID: <4D70D455.7080403@timgolden.me.uk> On 04/03/2011 11:59, Ayaskanta Swain wrote: > Hi, > > I want to know the target path of a windows shortcut. How do i read the > short cut & retrieve the actual target path it is pointing to? I > searched the internet & all the documents I found there refer to use > Win32com.shell or win32com.client module but was not satisfied with the > solutions given there. Well I don't know if this was one of the solutions with which you were "not satisfied", but it does at least have the merit of working: http://timgolden.me.uk/python/win32_how_do_i/read-a-shortcut.html TJG From ayaskanta.swain at altair.com Fri Mar 4 13:27:10 2011 From: ayaskanta.swain at altair.com (Ayaskanta Swain) Date: Fri, 4 Mar 2011 17:57:10 +0530 Subject: [python-win32] How to read the target of a Windows Shortcut In-Reply-To: <4D70D455.7080403@timgolden.me.uk> References: <21581D39FA3BDF40904D75AF9653CE260608A4D4@blrex.prog.altair.com> <4D70D455.7080403@timgolden.me.uk> Message-ID: <21581D39FA3BDF40904D75AF9653CE260608A4F0@blrex.prog.altair.com> Hi, Thank you for sending me the link. I tried it by copying the "shortcut_target(filename)" function into my script. But it does the same thing as I had mentioned in my previous e-mail. i.e It returns me the target path correctly if the target exists physically in my hard disk, but behaves in a wrongful manner if I delete the target keeping the shortcut intact (Broken shortcut). In that case it creates an empty file (0 size) with the same name as that of the existing target & creates it at the same physical location where the target was existing before. Looks like a bug in this function. I want to see it fail in that case or return something lie NONE , but it still returns me the target path. Thanks Ayaskant- -----Original Message----- From: python-win32-bounces+ayaskanta.swain=altair.com at python.org [mailto:python-win32-bounces+ayaskanta.swain=altair.com at python.org] On Behalf Of Tim Golden Sent: Friday, March 04, 2011 5:30 PM Cc: python-win32 at python.org Subject: Re: [python-win32] How to read the target of a Windows Shortcut On 04/03/2011 11:59, Ayaskanta Swain wrote: > Hi, > > I want to know the target path of a windows shortcut. How do i read the > short cut & retrieve the actual target path it is pointing to? I > searched the internet & all the documents I found there refer to use > Win32com.shell or win32com.client module but was not satisfied with the > solutions given there. Well I don't know if this was one of the solutions with which you were "not satisfied", but it does at least have the merit of working: http://timgolden.me.uk/python/win32_how_do_i/read-a-shortcut.html 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 smokefloat at gmail.com Fri Mar 4 13:58:07 2011 From: smokefloat at gmail.com (David Hutto) Date: Fri, 4 Mar 2011 07:58:07 -0500 Subject: [python-win32] How to read the target of a Windows Shortcut In-Reply-To: <21581D39FA3BDF40904D75AF9653CE260608A4F0@blrex.prog.altair.com> References: <21581D39FA3BDF40904D75AF9653CE260608A4D4@blrex.prog.altair.com> <4D70D455.7080403@timgolden.me.uk> <21581D39FA3BDF40904D75AF9653CE260608A4F0@blrex.prog.altair.com> Message-ID: On Fri, Mar 4, 2011 at 7:27 AM, Ayaskanta Swain wrote: > Hi, > > > > Thank you for sending me the link. I tried it by copying the > ?shortcut_target(filename)? function into my script. But it does the same > thing as I had mentioned in my previous e-mail. i.e It returns me the target > path correctly if the target exists physically in my hard disk, but behaves > in a wrongful manner if I delete the target keeping the shortcut intact > (Broken shortcut). In that case it creates an empty file (0 size) with the > same name as that of the existing target & creates it at the same physical > location where the target was existing before. Looks like a bug in this > function. try: open file except: file doesn't exist or something of the such. > > > > I want to see it fail in that case or return something lie NONE , but it > still returns me the target path. > > > > Thanks > > Ayaskant- > > > > -----Original Message----- > From: python-win32-bounces+ayaskanta.swain=altair.com at python.org > [mailto:python-win32-bounces+ayaskanta.swain=altair.com at python.org] On > Behalf Of Tim Golden > Sent: Friday, March 04, 2011 5:30 PM > Cc: python-win32 at python.org > Subject: Re: [python-win32] How to read the target of a Windows Shortcut > > > > On 04/03/2011 11:59, Ayaskanta Swain wrote: > >> Hi, > >> > >> I want to know the target path of a windows shortcut. How do i read the > >> short cut & retrieve the actual target path it is pointing to? I > >> searched the internet & all the documents I found there refer to use > >> Win32com.shell or win32com.client module but was not satisfied with the > >> solutions given there. > > > > Well I don't know if this was one of the solutions with which > > you were "not satisfied", but it does at least have the merit > > of working: > > > > ?? http://timgolden.me.uk/python/win32_how_do_i/read-a-shortcut.html > > > > TJG > > _______________________________________________ > > 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 > > -- According to theoretical physics, the division of spatial intervals as the universe evolves gives rise to the fact that in another timeline, your interdimensional counterpart received helpful advice from me...so be eternally pleased for them. From smokefloat at gmail.com Fri Mar 4 13:59:42 2011 From: smokefloat at gmail.com (David Hutto) Date: Fri, 4 Mar 2011 07:59:42 -0500 Subject: [python-win32] How to read the target of a Windows Shortcut In-Reply-To: References: <21581D39FA3BDF40904D75AF9653CE260608A4D4@blrex.prog.altair.com> <4D70D455.7080403@timgolden.me.uk> <21581D39FA3BDF40904D75AF9653CE260608A4F0@blrex.prog.altair.com> Message-ID: On Fri, Mar 4, 2011 at 7:58 AM, David Hutto wrote: > On Fri, Mar 4, 2011 at 7:27 AM, Ayaskanta Swain > wrote: >> Hi, >> >> >> >> Thank you for sending me the link. I tried it by copying the >> ?shortcut_target(filename)? function into my script. But it does the same >> thing as I had mentioned in my previous e-mail. i.e It returns me the target >> path correctly if the target exists physically in my hard disk, but behaves >> in a wrongful manner if I delete the target keeping the shortcut intact >> (Broken shortcut). In that case it creates an empty file (0 size) with the >> same name as that of the existing target & creates it at the same physical >> location where the target was existing before. Looks like a bug in this >> function. > > try: > ?open file > > except: > ?file doesn't exist > > or something of the such. in other words, try to fix what it does, stop the creation of the file IF it doesn't exist. I'm trying to give the homework explanations, instead of pseudo code, just like the grandmaster peers. >> >> >> >> I want to see it fail in that case or return something lie NONE , but it >> still returns me the target path. >> >> >> >> Thanks >> >> Ayaskant- >> >> >> >> -----Original Message----- >> From: python-win32-bounces+ayaskanta.swain=altair.com at python.org >> [mailto:python-win32-bounces+ayaskanta.swain=altair.com at python.org] On >> Behalf Of Tim Golden >> Sent: Friday, March 04, 2011 5:30 PM >> Cc: python-win32 at python.org >> Subject: Re: [python-win32] How to read the target of a Windows Shortcut >> >> >> >> On 04/03/2011 11:59, Ayaskanta Swain wrote: >> >>> Hi, >> >>> >> >>> I want to know the target path of a windows shortcut. How do i read the >> >>> short cut & retrieve the actual target path it is pointing to? I >> >>> searched the internet & all the documents I found there refer to use >> >>> Win32com.shell or win32com.client module but was not satisfied with the >> >>> solutions given there. >> >> >> >> Well I don't know if this was one of the solutions with which >> >> you were "not satisfied", but it does at least have the merit >> >> of working: >> >> >> >> ?? http://timgolden.me.uk/python/win32_how_do_i/read-a-shortcut.html >> >> >> >> TJG >> >> _______________________________________________ >> >> 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 >> >> > > > > -- > According to theoretical physics, the division of spatial intervals as > the universe evolves gives rise to the fact that in another timeline, > your interdimensional counterpart received helpful advice from me...so > be eternally pleased for them. > -- According to theoretical physics, the division of spatial intervals as the universe evolves gives rise to the fact that in another timeline, your interdimensional counterpart received helpful advice from me...so be eternally pleased for them. From ayaskanta.swain at altair.com Fri Mar 4 15:29:32 2011 From: ayaskanta.swain at altair.com (Ayaskanta Swain) Date: Fri, 4 Mar 2011 19:59:32 +0530 Subject: [python-win32] How to read the target of a Windows Shortcut In-Reply-To: References: <21581D39FA3BDF40904D75AF9653CE260608A4D4@blrex.prog.altair.com><4D70D455.7080403@timgolden.me.uk><21581D39FA3BDF40904D75AF9653CE260608A4F0@blrex.prog.altair.com> Message-ID: <21581D39FA3BDF40904D75AF9653CE260608A564@blrex.prog.altair.com> Hi David, Yes I need to do some thing like you have suggested. Will try to open the link & catch the exception in case of any error. Though it's a indirect way but I am quite optimistic that it will work for me. Thanks Ayaskant- -----Original Message----- From: David Hutto [mailto:smokefloat at gmail.com] Sent: Friday, March 04, 2011 6:30 PM To: Ayaskanta Swain Cc: Tim Golden; python-win32 at python.org Subject: Re: [python-win32] How to read the target of a Windows Shortcut On Fri, Mar 4, 2011 at 7:58 AM, David Hutto wrote: > On Fri, Mar 4, 2011 at 7:27 AM, Ayaskanta Swain > wrote: >> Hi, >> >> >> >> Thank you for sending me the link. I tried it by copying the >> "shortcut_target(filename)" function into my script. But it does the same >> thing as I had mentioned in my previous e-mail. i.e It returns me the target >> path correctly if the target exists physically in my hard disk, but behaves >> in a wrongful manner if I delete the target keeping the shortcut intact >> (Broken shortcut). In that case it creates an empty file (0 size) with the >> same name as that of the existing target & creates it at the same physical >> location where the target was existing before. Looks like a bug in this >> function. > > try: > open file > > except: > file doesn't exist > > or something of the such. in other words, try to fix what it does, stop the creation of the file IF it doesn't exist. I'm trying to give the homework explanations, instead of pseudo code, just like the grandmaster peers. >> >> >> >> I want to see it fail in that case or return something lie NONE , but it >> still returns me the target path. >> >> >> >> Thanks >> >> Ayaskant- >> >> >> >> -----Original Message----- >> From: python-win32-bounces+ayaskanta.swain=altair.com at python.org >> [mailto:python-win32-bounces+ayaskanta.swain=altair.com at python.org] On >> Behalf Of Tim Golden >> Sent: Friday, March 04, 2011 5:30 PM >> Cc: python-win32 at python.org >> Subject: Re: [python-win32] How to read the target of a Windows Shortcut >> >> >> >> On 04/03/2011 11:59, Ayaskanta Swain wrote: >> >>> Hi, >> >>> >> >>> I want to know the target path of a windows shortcut. How do i read the >> >>> short cut & retrieve the actual target path it is pointing to? I >> >>> searched the internet & all the documents I found there refer to use >> >>> Win32com.shell or win32com.client module but was not satisfied with the >> >>> solutions given there. >> >> >> >> Well I don't know if this was one of the solutions with which >> >> you were "not satisfied", but it does at least have the merit >> >> of working: >> >> >> >> http://timgolden.me.uk/python/win32_how_do_i/read-a-shortcut.html >> >> >> >> TJG >> >> _______________________________________________ >> >> 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 >> >> > > > > -- > According to theoretical physics, the division of spatial intervals as > the universe evolves gives rise to the fact that in another timeline, > your interdimensional counterpart received helpful advice from me...so > be eternally pleased for them. > -- According to theoretical physics, the division of spatial intervals as the universe evolves gives rise to the fact that in another timeline, your interdimensional counterpart received helpful advice from me...so be eternally pleased for them. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Fri Mar 4 15:31:28 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 04 Mar 2011 14:31:28 +0000 Subject: [python-win32] How to read the target of a Windows Shortcut In-Reply-To: <21581D39FA3BDF40904D75AF9653CE260608A4F0@blrex.prog.altair.com> References: <21581D39FA3BDF40904D75AF9653CE260608A4D4@blrex.prog.altair.com> <4D70D455.7080403@timgolden.me.uk> <21581D39FA3BDF40904D75AF9653CE260608A4F0@blrex.prog.altair.com> Message-ID: <4D70F7C0.5000504@timgolden.me.uk> On 04/03/2011 12:27, Ayaskanta Swain wrote: > Thank you for sending me the link. I tried it by copying the > ?shortcut_target(filename)? function into my script. But it does the > same thing as I had mentioned in my previous e-mail. i.e It returns me > the target path correctly if the target exists physically in my hard > disk, but behaves in a wrongful manner if I delete the target keeping > the shortcut intact (Broken shortcut). In that case it creates an empty > file (0 size) with the same name as that of the existing target & > creates it at the same physical location where the target was existing > before. Looks like a bug in this function. Well I'm not seeing that behaviour at all. Is it possible that something else in your code is having this effect? I'm on Win7 x64 Python 2.6.6 pywin32 216 import os, sys import glob import pythoncom from win32com.shell import shell, shellcon def shortcut_target (filename): link = pythoncom.CoCreateInstance ( shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink ) link.QueryInterface (pythoncom.IID_IPersistFile).Load (filename) # # GetPath returns the name and a WIN32_FIND_DATA structure # which we're ignoring. The parameter indicates whether # shortname, UNC or the "raw path" are to be # returned. Bizarrely, the docs indicate that the # flags can be combined. # name, _ = link.GetPath (shell.SLGP_UNCPRIORITY) return name if __name__ == '__main__': # # Create a dummy file # import tempfile filepath = tempfile.mktemp () with open (filepath, "wb") as f: f.write ("abcdef") # # Create a shortcut on the desktop to the file # shortcut = pythoncom.CoCreateInstance ( shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink ) shortcut.SetPath (filepath) shortcut_path = os.path.join (shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0), "test.link") shortcut.QueryInterface (pythoncom.IID_IPersistFile).Save (shortcut_path, 0) # # Check that the shortcut target is the file # and that the file exists # assert os.path.exists (filepath) assert shortcut_target (shortcut_path).lower () == filepath.lower () # # Remove the target file # os.unlink (filepath) assert not os.path.exists (filepath) # # Check that the shortcut target is the file # and that the file no longer exists # assert shortcut_target (shortcut_path).lower () == filepath.lower () assert not os.path.exists (filepath) TJG From smokefloat at gmail.com Fri Mar 4 15:40:54 2011 From: smokefloat at gmail.com (David Hutto) Date: Fri, 4 Mar 2011 09:40:54 -0500 Subject: [python-win32] How to read the target of a Windows Shortcut In-Reply-To: <21581D39FA3BDF40904D75AF9653CE260608A564@blrex.prog.altair.com> References: <21581D39FA3BDF40904D75AF9653CE260608A4D4@blrex.prog.altair.com> <4D70D455.7080403@timgolden.me.uk> <21581D39FA3BDF40904D75AF9653CE260608A4F0@blrex.prog.altair.com> <21581D39FA3BDF40904D75AF9653CE260608A564@blrex.prog.altair.com> Message-ID: I probably forgot to include my sig, which means listen all of us like a hive queen instead of like a bullish king. -- According to theoretical physics, the division of spatial intervals as the universe evolves gives rise to the fact that in another timeline, your interdimensional counterpart received helpful advice from me...so be eternally pleased for them. From ayaskanta.swain at altair.com Fri Mar 4 17:39:05 2011 From: ayaskanta.swain at altair.com (Ayaskanta Swain) Date: Fri, 4 Mar 2011 22:09:05 +0530 Subject: [python-win32] How to read the target of a Windows Shortcut In-Reply-To: <4D70F7C0.5000504@timgolden.me.uk> References: <21581D39FA3BDF40904D75AF9653CE260608A4D4@blrex.prog.altair.com><4D70D455.7080403@timgolden.me.uk><21581D39FA3BDF40904D75AF9653CE260608A4F0@blrex.prog.altair.com> <4D70F7C0.5000504@timgolden.me.uk> Message-ID: <21581D39FA3BDF40904D75AF9653CE260608A59F@blrex.prog.altair.com> Well, Here is how I have implemented in my script. Please take a look & let me know whether I am doing something wrong. Mine is a Windows-XP(SP3), 32-bit system. # Reads the windows shortcut & returns the target path def shortcut_target (shortcutfile): link = pythoncom.CoCreateInstance ( shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink ) link.QueryInterface (pythoncom.IID_IPersistFile).Load (shortcutfile) target_path, _ = link.GetPath (shell.SLGP_UNCPRIORITY) return target_path #############################Main####################################### ## linkpath = sys.argv[1] #Read the target of the windows shortcut target_of_link = shortcut_target(linkpath) print 'Target = ' + target_of_link I run the script like this C:\Documents and Settings\pbsadmin>python filelinkscript.py "C:\temp\myfile.lnk" Here myfile.lnk is a link to a file C:\stage\myfile.txt Thanks Ayaskant- -----Original Message----- From: python-win32-bounces+ayaskanta.swain=altair.com at python.org [mailto:python-win32-bounces+ayaskanta.swain=altair.com at python.org] On Behalf Of Tim Golden Sent: Friday, March 04, 2011 8:01 PM Cc: python-win32 at python.org Subject: Re: [python-win32] How to read the target of a Windows Shortcut On 04/03/2011 12:27, Ayaskanta Swain wrote: > Thank you for sending me the link. I tried it by copying the > "shortcut_target(filename)" function into my script. But it does the > same thing as I had mentioned in my previous e-mail. i.e It returns me > the target path correctly if the target exists physically in my hard > disk, but behaves in a wrongful manner if I delete the target keeping > the shortcut intact (Broken shortcut). In that case it creates an empty > file (0 size) with the same name as that of the existing target & > creates it at the same physical location where the target was existing > before. Looks like a bug in this function. Well I'm not seeing that behaviour at all. Is it possible that something else in your code is having this effect? I'm on Win7 x64 Python 2.6.6 pywin32 216 import os, sys import glob import pythoncom from win32com.shell import shell, shellcon def shortcut_target (filename): link = pythoncom.CoCreateInstance ( shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink ) link.QueryInterface (pythoncom.IID_IPersistFile).Load (filename) # # GetPath returns the name and a WIN32_FIND_DATA structure # which we're ignoring. The parameter indicates whether # shortname, UNC or the "raw path" are to be # returned. Bizarrely, the docs indicate that the # flags can be combined. # name, _ = link.GetPath (shell.SLGP_UNCPRIORITY) return name if __name__ == '__main__': # # Create a dummy file # import tempfile filepath = tempfile.mktemp () with open (filepath, "wb") as f: f.write ("abcdef") # # Create a shortcut on the desktop to the file # shortcut = pythoncom.CoCreateInstance ( shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink ) shortcut.SetPath (filepath) shortcut_path = os.path.join (shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0), "test.link") shortcut.QueryInterface (pythoncom.IID_IPersistFile).Save (shortcut_path, 0) # # Check that the shortcut target is the file # and that the file exists # assert os.path.exists (filepath) assert shortcut_target (shortcut_path).lower () == filepath.lower () # # Remove the target file # os.unlink (filepath) assert not os.path.exists (filepath) # # Check that the shortcut target is the file # and that the file no longer exists # assert shortcut_target (shortcut_path).lower () == filepath.lower () assert not os.path.exists (filepath) 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 ghostility at gmail.com Fri Mar 4 18:24:42 2011 From: ghostility at gmail.com (Ghostly) Date: Fri, 04 Mar 2011 18:24:42 +0100 Subject: [python-win32] print file byte contents distribution Message-ID: <20110304182439.B639.5FE01CF9@gmail.com> Hi, As I don't see any CLI tool other then hex editor, I thought on writing small script that will display byte distribution from file content So I thought on this: ----------------------------- counter = {} for bytes in open('c:\\temp\\bin.dat', "rb").read(): counter[bytes] = counter.get(bytes, 0) + 1 print counter ----------------------------- It works fine, but as I need to parse large file data, I thought to ask if someone knows a better way of doing this Thanks From timr at probo.com Fri Mar 4 19:55:23 2011 From: timr at probo.com (Tim Roberts) Date: Fri, 4 Mar 2011 10:55:23 -0800 Subject: [python-win32] Fonts behaving differently with Py3/216 In-Reply-To: <4D704F08.8010104@canterbury.ac.nz> References: <4D704F08.8010104@canterbury.ac.nz> Message-ID: <4D71359B.6050504@probo.com> Greg Ewing wrote: > I recently tried running PyGUI on Python 3 using > pywin32 build 216, and a couple of things are > not working quite the same way as they were with > Python 2 and build 213. > > 1) The default font used for control labels etc. > is slightly smaller. > > 2) When I calculate the width of a piece of text > using DC.GetTextExtent() I get a value that is > too small, and doesn't match the actual size of > the text as it is drawn. > > Anyone have any idea what might have changed, > and what I can do about it? Are you running this on a different computer? The default font and the size of a "dialog unit" is based on the dots-per-inch resolution of the monitor on that computer. If you have a machine with a big screen where the user has chosen a different resolution, that will affect the size of everything in a dialog. This is the same problem we used to refer to as "small fonts / large fonts". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From vernondcole at gmail.com Fri Mar 4 21:20:03 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Fri, 4 Mar 2011 13:20:03 -0700 Subject: [python-win32] print file byte contents distribution In-Reply-To: <20110304182439.B639.5FE01CF9@gmail.com> References: <20110304182439.B639.5FE01CF9@gmail.com> Message-ID: What a nifty script! I love it! Here's my version. I tested using a 800 KByte image file and it runs in a blink. Dictionary access in Python is very fast. counter = {} for bytes in open('c:\\temp\\16.jpg', "rb").read(): try: counter[bytes] += 1 except KeyError: counter[bytes] = 1 for key in sorted(counter.keys()): print '%s: %d,' % (repr(key),counter[key]), print -- Vernon From timr at probo.com Fri Mar 4 22:06:17 2011 From: timr at probo.com (Tim Roberts) Date: Fri, 4 Mar 2011 13:06:17 -0800 Subject: [python-win32] print file byte contents distribution In-Reply-To: References: <20110304182439.B639.5FE01CF9@gmail.com> Message-ID: <4D715449.9050501@probo.com> Vernon Cole wrote: > What a nifty script! I love it! > Here's my version. I tested using a 800 KByte image file and it runs > in a blink. Dictionary access in Python is very fast. > > counter = {} > > for bytes in open('c:\\temp\\16.jpg', "rb").read(): > try: > counter[bytes] += 1 > except KeyError: > counter[bytes] = 1 > > for key in sorted(counter.keys()): > print '%s: %d,' % (repr(key),counter[key]), > print > Since the size of the universe is small and known in advance, a list would be faster yet: counter = [0]*256 for bytes in open('c:\\temp\\16.jpg', "rb").read(): counter[ord(bytes)] += 1 for key,cnt in enumerate(counter): print '%d: %d,' % (key,cnt), -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ghostility at gmail.com Fri Mar 4 22:31:37 2011 From: ghostility at gmail.com (Ghostly) Date: Fri, 04 Mar 2011 22:31:37 +0100 Subject: [python-win32] print file byte contents distribution Message-ID: <20110304223134.B641.5FE01CF9@gmail.com> Thanks guys for your input As I need this for larger files (couple of tens even hundrets of MB) I tested your suggestion and it seems that dict method is fastest. I ended with this: ---------------------------- import sys try: counter = {} for bytes in open(sys.argv[1], "rb").read(): try: counter[bytes] += 1 except KeyError: counter[bytes] = 1 peak = max(counter.values()) for key in sorted(counter.keys()): print '%02x: %08d %s' % (ord(key), counter[key], '-' * (66 * counter[key]/peak)) except Exception, e: print e ---------------------------- Cheers From timr at probo.com Fri Mar 4 22:46:56 2011 From: timr at probo.com (Tim Roberts) Date: Fri, 4 Mar 2011 13:46:56 -0800 Subject: [python-win32] print file byte contents distribution In-Reply-To: <20110304223134.B641.5FE01CF9@gmail.com> References: <20110304223134.B641.5FE01CF9@gmail.com> Message-ID: <4D715DD0.4060608@probo.com> Ghostly wrote: > Thanks guys for your input > > As I need this for larger files (couple of tens even hundrets of MB) I > tested your suggestion and it seems that dict method is fastest. I decided to find out, so I ran "timeit" on both schemes using a 2MB file. The two methods are within 1% of each other -- sometimes the dict is slightly faster, sometimes the list is slightly faster. Thus, for all practical purposes, they are identical. I'm surprised. That means you should use the one that makes sense to you. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Sat Mar 5 01:18:47 2011 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 05 Mar 2011 11:18:47 +1100 Subject: [python-win32] Possible trouble with pywin23-216 on python 3.2 In-Reply-To: References: Message-ID: <4D718167.8060207@skippinet.com.au> The Python 3.2 32-bit build was the only one affected and I've uploaded a 216.1 build for this version only. It is identical to the 216 builds except for the build ID and the conversion of all files to py3k syntax. What went wrong? I was incorrect the other day about the 32bit and 64bit versions sharing the same .py files - they do share the same "source" files obviously, but the build process copies them to a different directory for each build (the "build" directory). The hacks I have in the build process for the 2to3 conversion do the conversion in-place in the build directory - which is error prone. I'm fairly confident the problem was that I interrupted the build while 3.2 32-bits was being generated and while the 2to3 conversion was happening. When I restarted the build, the logic which checks if files need copying determined that the build directory was up-to-date - even though the py3k conversion process wasn't complete. As a result, that build directory was left alone with some pre-converted files. Sadly, it isn't trivial to fix this in distutils, so I am just going to need to be more careful when making future releases. I *usually* am good about nuking the entire build tree and rebuilding the world before release, but now that I do that on a VM, a full build takes many hours to complete. I took a shortcut and paid the price :) Cheers, Mark From greg.ewing at canterbury.ac.nz Sat Mar 5 01:35:05 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 05 Mar 2011 13:35:05 +1300 Subject: [python-win32] Fonts behaving differently with Py3/216 In-Reply-To: <4D71359B.6050504@probo.com> References: <4D704F08.8010104@canterbury.ac.nz> <4D71359B.6050504@probo.com> Message-ID: <4D718539.7060007@canterbury.ac.nz> Tim Roberts wrote: > Are you running this on a different computer? No, it's the same computer. I can run 2.x and 3.x versions of the same test side by side, and the 2.x one has normal sized text whereas the 3.x one has tiny text. Oddly, it only seems to affect text drawn by the standard win32 controls. Text that I draw myself using GDI+ comes out the same size in both cases. So it looks like GDI and GDI+ are doing different things with the fonts, somehow. -- Greg From jdmain at comcast.net Sat Mar 5 15:06:11 2011 From: jdmain at comcast.net (J.D. Main) Date: Sat, 05 Mar 2011 07:06:11 -0700 Subject: [python-win32] Classic ASP in IIS with Python - 500 Server Error Message-ID: <4D724353.2458.1DE06958@jdmain.comcast.net> An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Sat Mar 5 17:48:18 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Sat, 5 Mar 2011 09:48:18 -0700 Subject: [python-win32] Possible trouble with pywin23-216 on python 3.2 In-Reply-To: <4D718167.8060207@skippinet.com.au> References: <4D718167.8060207@skippinet.com.au> Message-ID: I ran across this problem myself awhile back, and it seems to be common enough that they added a feature to distutils to handle it. I have added a copy of my setup.cfg to CVS, which contains: [build] force=1 [bdist_wininst] user_access_control=auto With "force=1", it should theoretically clean out the build directory on every run. -- Vernon On Fri, Mar 4, 2011 at 5:18 PM, Mark Hammond wrote: > The Python 3.2 32-bit build was the only one affected and I've uploaded a > 216.1 build for this version only. ?It is identical to the 216 builds except > for the build ID and the conversion of all files to py3k syntax. > > What went wrong? ?I was incorrect the other day about the 32bit and 64bit > versions sharing the same .py files - they do share the same "source" files > obviously, but the build process copies them to a different directory for > each build (the "build" directory). ?The hacks I have in the build process > for the 2to3 conversion do the conversion in-place in the build directory - > which is error prone. ?I'm fairly confident the problem was that I > interrupted the build while 3.2 32-bits was being generated and while the > 2to3 conversion was happening. ?When I restarted the build, the logic which > checks if files need copying determined that the build directory was > up-to-date - even though the py3k conversion process wasn't complete. ?As a > result, that build directory was left alone with some pre-converted files. > > Sadly, it isn't trivial to fix this in distutils, so I am just going to need > to be more careful when making future releases. ?I *usually* am good about > nuking the entire build tree and rebuilding the world before release, but > now that I do that on a VM, a full build takes many hours to complete. ?I > took a shortcut and paid the price :) > > Cheers, > > Mark > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From greg.ewing at canterbury.ac.nz Sun Mar 6 05:07:37 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sun, 06 Mar 2011 17:07:37 +1300 Subject: [python-win32] Fonts behaving differently - The plot thickens a bit In-Reply-To: <4D706B00.4080500@skippinet.com.au> References: <4D704F08.8010104@canterbury.ac.nz> <4D705E7A.7090507@gmail.com> <4D706A04.6040706@canterbury.ac.nz> <4D706B00.4080500@skippinet.com.au> Message-ID: <4D730889.6090307@canterbury.ac.nz> I think I've narrowed down what's going on with the font sizes a bit more. It has to do with the interperetation of the nHeight parameter to CreateFont. It appears that you can specify the height using either a positive or negative number. One is taken to include the font's internal leading, and the other isn't. What seems to have happened is that somewhere between builds 212 and 216 of pywin32, the behaviour of these two cases has *swapped over*. In my 2.x installation, which is using either 212 or 213 (I'm not exactly sure which at the moment) if I ask for "Tahoma" with height +11 it comes out with ascent = 11, descent = 2; whereas height -11 gives ascent = 9, descent = 2. But under 3.x with build 216, it's the other way around: height +11 gives ascent = 9, -11 gives ascent = 11. If I'm interpreting the MS docs correctly, then the new behaviour is correct and the old one is wrong. Was there a bug relating to this fixed at some point? Also, is there a version number somewhere in pywin32 that I can check at run time to work around this? -- Greg From skippy.hammond at gmail.com Sun Mar 6 06:42:25 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sun, 06 Mar 2011 16:42:25 +1100 Subject: [python-win32] Fonts behaving differently - The plot thickens a bit In-Reply-To: <4D730889.6090307@canterbury.ac.nz> References: <4D704F08.8010104@canterbury.ac.nz> <4D705E7A.7090507@gmail.com> <4D706A04.6040706@canterbury.ac.nz> <4D706B00.4080500@skippinet.com.au> <4D730889.6090307@canterbury.ac.nz> Message-ID: <4D731EC1.4060902@gmail.com> On 6/03/2011 3:07 PM, Greg Ewing wrote: > I think I've narrowed down what's going on with the font > sizes a bit more. It has to do with the interperetation > of the nHeight parameter to CreateFont. > > It appears that you can specify the height using either > a positive or negative number. One is taken to include > the font's internal leading, and the other isn't. > > What seems to have happened is that somewhere between > builds 212 and 216 of pywin32, the behaviour of these > two cases has *swapped over*. > > In my 2.x installation, which is using either 212 or > 213 (I'm not exactly sure which at the moment) if I > ask for "Tahoma" with height +11 it comes out with > ascent = 11, descent = 2; whereas height -11 gives > ascent = 9, descent = 2. > > But under 3.x with build 216, it's the other way around: > height +11 gives ascent = 9, -11 gives ascent = 11. > > If I'm interpreting the MS docs correctly, then the new > behaviour is correct and the old one is wrong. Was there > a bug relating to this fixed at some point? Not that I can find - I guess you mean in win32gui? win32gui has not changed since build 214, and the log shows nothing related back to 212. > Also, is there a version number somewhere in pywin32 that > I can check at run time to work around this? There is only pywin32.version.txt installed into site-packages - you should look for the value before the first dot without assuming how many dots follow... Mark From mhammond at skippinet.com.au Sun Mar 6 07:05:11 2011 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 06 Mar 2011 17:05:11 +1100 Subject: [python-win32] Conversion to Mercurial is done Message-ID: <4D732417.6010800@skippinet.com.au> I've converted the CVS repository to a Mercurial (hg) and after a few tweaks and re-conversions, it seems to have done a good job. It is purely a coincidence that this finally happened on the same week Python itself flicked the Mercurial switch :). I'd like to encourage everyone with an interest in this to grab a clone and have a play - note that you can make a clone, make some local test commits, then throw the clone away without pushing back to sourceforge. Some notes: * People not familiar with hg should read the hg book at http://hgbook.red-bean.com/ and any other tutorials they can find. The model is significantly different to CVS and SVN (but somewhat similar to Bazaar and Git) * The hg repo is at sourceforge and all developers who had CVS access should have mercurial "push" access. You can browse the repo via the normal sourceforge web interface. The pywin32 sourceforge page with the configuration information is at https://sourceforge.net/scm/?type=hg&group_id=78018 * I've disabled access to CVS for all developers - the CVS repo still exists and can be re-enabled should some serious issue be found, but eventually it will be removed completely from the project (and probably make the raw repo available for download via sourceforge) * I'm still battling the hg hook for sending emails as changes are pushed, but think I have that working. I'll make a trivial commit in the next few minutes to test that out, but note that in the worst case, commit email may not appear for a day or few. * You should enable the "eol" extension for Mercurial to ensure you get Windows line endings. Eventually I hope to have a hg server-side hook to reject changes which screw up the line-endings, but I've failed to make that happen so far. Note that support for Windows line-endings is a recent mercurial feature and may have rough edges. Before committing to your local repo, please check that 'hg diff' isn't marking a change in every line in one of the changed files - it is does, please hold off the commit and contact me. * I can recommend the "Tortoise HG" tool for Windows - it allows you to disable the "shell extensions", but you still wind up with normal command-line hg plus a nice GUI tool you can invoke if desired. * Sourceforge hg seems a little slow, especially fetching the full repo. Fetching incremental updates should be better, but if there are performance issues related to sourceforge, we can look at hosting the master repo elsewhere. * Although it should not be necessary, I reserve the right to nuke the hg repo and start again with the CVS conversion. This will only be done over the next week or 2, and only if someone notices a significant problem in the conversion and I would need to "back-port" any hg changes into CVS. If this did happen, you would be unable to update any existing clones you made - you would have to start again into a clean local tree. Please let me know how you go! Thanks, Mark From vernondcole at gmail.com Sun Mar 6 08:49:47 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Sun, 6 Mar 2011 00:49:47 -0700 Subject: [python-win32] Conversion to Mercurial is done In-Reply-To: <4D732417.6010800@skippinet.com.au> References: <4D732417.6010800@skippinet.com.au> Message-ID: Working fine here. Here's a sample for anyone who has not tried sourceforge hg before. I have PuTTY loaded on this machine, and already have my ssh keys set up on sourceforge -- just like with CVS. Mercurial is loaded using the binary installer. And, I actually remembered to load my sourceforge keys into Pagent before I started. ;-) In order to get read/write access, I used the ssh:// url as documented on the page Mark referenced. https://sourceforge.net/scm/?type=hg&group_id=78018 If your are reading a rich text (html) version of this, my input below is highlighted in yellow. Don't copy this exactly, you will need to use your own username where I have "kf7xm". I keep my mercurial trees in a C:\hg folder. YMMV I had the usual "The server's host key is not cached in the registry" problem. Solved by running a quick plink command to the server in question: C:\hg>plink kf7xm at pywin32.hg.sourceforge.net ls The server's host key is not cached in the registry. You have no guarantee that the server is the computer you think it is. The server's rsa2 key fingerprint is: ssh-rsa 2048 86:7b:1b:12:85:35:8a:b7:98:b6:d2:97:5e:96:58:1d If you trust this host, enter "y" to add the key to PuTTY's cache and carry on connecting. If you want to carry on connecting just once, without adding the key to the cache, enter "n". If you do not trust this host, press Return to abandon the connection. Store key in cache? (y/n) y Welcome to *.hg.sourceforge.net C:\hg>hg clone ssh://kf7xm at pywin32.hg.sourceforge.net/hgroot/pywin32/pywin32 destination directory: pywin32 requesting all changes adding changesets adding manifests adding file changes added 4100 changesets with 9863 changes to 1831 files (+1 heads) updating to branch default 1545 files updated, 0 files merged, 0 files removed, 0 files unresolved C:\hg>cd pywin32 C:\hg>dir -- Vernon On Sat, Mar 5, 2011 at 11:05 PM, Mark Hammond wrote: > I've converted the CVS repository to a Mercurial (hg) and after a few tweaks [...] -------------- next part -------------- An HTML attachment was scrubbed... URL: From jdmain at comcast.net Sun Mar 6 19:58:41 2011 From: jdmain at comcast.net (J.D. Main) Date: Sun, 06 Mar 2011 11:58:41 -0700 Subject: [python-win32] Repost: Classic ASP in IIS with Python - 500 Server Error Message-ID: <4D73D961.3287.4189A6@jdmain.comcast.net> An HTML attachment was scrubbed... URL: From rupole at hotmail.com Sun Mar 6 20:56:34 2011 From: rupole at hotmail.com (Roger Upole) Date: Sun, 6 Mar 2011 14:56:34 -0500 Subject: [python-win32] Fonts behaving differently - The plot thickens a bit References: <4D704F08.8010104@canterbury.ac.nz><4D705E7A.7090507@gmail.com> <4D706A04.6040706@canterbury.ac.nz><4D706B00.4080500@skippinet.com.au><4D730889.6090307@canterbury.ac.nz> <4D731EC1.4060902@gmail.com> Message-ID: Mark Hammond wrote: news:4D731EC1.4060902 at gmail.com... > On 6/03/2011 3:07 PM, Greg Ewing wrote: >> I think I've narrowed down what's going on with the font >> sizes a bit more. It has to do with the interperetation >> of the nHeight parameter to CreateFont. >> >> It appears that you can specify the height using either >> a positive or negative number. One is taken to include >> the font's internal leading, and the other isn't. >> >> What seems to have happened is that somewhere between >> builds 212 and 216 of pywin32, the behaviour of these >> two cases has *swapped over*. >> >> In my 2.x installation, which is using either 212 or >> 213 (I'm not exactly sure which at the moment) if I >> ask for "Tahoma" with height +11 it comes out with >> ascent = 11, descent = 2; whereas height -11 gives >> ascent = 9, descent = 2. >> >> But under 3.x with build 216, it's the other way around: >> height +11 gives ascent = 9, -11 gives ascent = 11. >> >> If I'm interpreting the MS docs correctly, then the new >> behaviour is correct and the old one is wrong. Was there >> a bug relating to this fixed at some point? > > Not that I can find - I guess you mean in win32gui? win32gui has not > changed since build 214, and the log shows nothing related back to 212. The conversion in win32ui has changed since 212. At one time it was negating the height that was passed in: if (PyInt_Check (v)) pLF->lfHeight = -PyInt_AsLong(v); I looked at it 2 or 3 times before I noticed the minus sign. >> Also, is there a version number somewhere in pywin32 that >> I can check at run time to work around this? > > There is only pywin32.version.txt installed into site-packages - you > should look for the value before the first dot without assuming how many > dots follow... > > Mark You can also extract the version embedded in the pyd's using win32api.GetFileVersionInfo. Roger From rupole at hotmail.com Sun Mar 6 21:18:47 2011 From: rupole at hotmail.com (Roger Upole) Date: Sun, 6 Mar 2011 15:18:47 -0500 Subject: [python-win32] Repost: Classic ASP in IIS with Python - 500 ServerError References: <4D73D961.3287.4189A6@jdmain.comcast.net> Message-ID: J.D. Main wrote: > (repost of previous message apparently HTML'd by my mailer...sorry) > > Hello, > I have been hunting for a solution to this one for some time. I've > already tried all the easy stuff. I have IIS 5 on a WinXP Pro machine. > I recently posted this to the Python WEB sig - apparently not many windows > users on that > list. > I can run python scripts as CGI but not as ASP. All I get is: > > HTTP/1.1 500 Server Error > (nothing else - no other errors or explanation - seriously) > > I have tried: > > 1. Reinstalling Python (v2.7 from ActiveState) > 2. Reinstalling IIS > 3. Running pyscript.py from "site-packages\win32comext\axscript\client" > 4. I have "friendly errors" turned off in IE > 5. ASP does work with VB Scripts > > Here is the most basic ASP page I'm trying to run: > > <%@LANGUAGE=Python%> > > > <% > response.write("Hello World!") > %> > > > > Does anybody have any ideas? This is really getting annoying and I can't > find a solution. Other people have complained of this and I've seen no > solution. > > Thanks. > J.D. Try registering it in debug mode, by passing --debug to pyscript.py. The trace collector in Pythonwin should show any error msgs generated by Python (assuming it gets as far as loading Python). Roger From greg.ewing at canterbury.ac.nz Sun Mar 6 22:51:34 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Mon, 07 Mar 2011 10:51:34 +1300 Subject: [python-win32] Fonts behaving differently - The plot thickens a bit In-Reply-To: References: <4D704F08.8010104@canterbury.ac.nz> <4D705E7A.7090507@gmail.com> <4D706A04.6040706@canterbury.ac.nz> <4D706B00.4080500@skippinet.com.au> <4D730889.6090307@canterbury.ac.nz> <4D731EC1.4060902@gmail.com> Message-ID: <4D7401E6.2070103@canterbury.ac.nz> Roger Upole wrote: > The conversion in win32ui has changed since 212. At one time it > was negating the height that was passed in: > > if (PyInt_Check (v)) > pLF->lfHeight = -PyInt_AsLong(v); Ah, that explains it all! > You can also extract the version embedded in the pyd's using > win32api.GetFileVersionInfo. That sounds great, thanks. Do you happen to know exactly which version the change was made in, so I can get the version test right? -- Greg From rupole at hotmail.com Sun Mar 6 23:23:44 2011 From: rupole at hotmail.com (Roger Upole) Date: Sun, 6 Mar 2011 17:23:44 -0500 Subject: [python-win32] Fonts behaving differently - The plot thickensa bit References: <4D704F08.8010104@canterbury.ac.nz> <4D705E7A.7090507@gmail.com><4D706A04.6040706@canterbury.ac.nz> <4D706B00.4080500@skippinet.com.au><4D730889.6090307@canterbury.ac.nz> <4D731EC1.4060902@gmail.com> <4D7401E6.2070103@canterbury.ac.nz> Message-ID: "Greg Ewing" wrote in message news:4D7401E6.2070103 at canterbury.ac.nz... > Roger Upole wrote: > >> The conversion in win32ui has changed since 212. At one time it >> was negating the height that was passed in: >> >> if (PyInt_Check (v)) >> pLF->lfHeight = -PyInt_AsLong(v); > > Ah, that explains it all! > >> You can also extract the version embedded in the pyd's using >> win32api.GetFileVersionInfo. > > That sounds great, thanks. > > Do you happen to know exactly which version the change was > made in, so I can get the version test right? > > -- > Greg 213 was the first build without the negation. Roger From rupole at hotmail.com Mon Mar 7 01:58:42 2011 From: rupole at hotmail.com (Roger Upole) Date: Sun, 6 Mar 2011 19:58:42 -0500 Subject: [python-win32] Repost: Classic ASP in IIS with Python - 500 ServerError Message-ID: "Roger Upole" wrote in message news:... > J.D. Main wrote: >> (repost of previous message apparently HTML'd by my mailer...sorry) >> >> Hello, >> I have been hunting for a solution to this one for some time. I've >> already tried all the easy stuff. I have IIS 5 on a WinXP Pro machine. >> I recently posted this to the Python WEB sig - apparently not many windows >> users on that >> list. >> I can run python scripts as CGI but not as ASP. All I get is: >> >> HTTP/1.1 500 Server Error >> (nothing else - no other errors or explanation - seriously) >> >> I have tried: >> >> 1. Reinstalling Python (v2.7 from ActiveState) >> 2. Reinstalling IIS >> 3. Running pyscript.py from "site-packages\win32comext\axscript\client" >> 4. I have "friendly errors" turned off in IE >> 5. ASP does work with VB Scripts >> >> Here is the most basic ASP page I'm trying to run: >> >> <%@LANGUAGE=Python%> >> >> >> <% >> response.write("Hello World!") >> %> >> >> >> >> Does anybody have any ideas? This is really getting annoying and I can't >> find a solution. Other people have complained of this and I've seen no >> solution. >> >> Thanks. >> J.D. > > Try registering it in debug mode, by passing --debug to pyscript.py. > The trace collector in Pythonwin should show any error msgs > generated by Python (assuming it gets as far as loading Python). > > Roger > Just noticed the lowercase "response". Python is case sensitive, try Response.Write instead. Roger From jdmain at comcast.net Mon Mar 7 19:29:50 2011 From: jdmain at comcast.net (jdmain at comcast.net) Date: Mon, 7 Mar 2011 18:29:50 +0000 (UTC) Subject: [python-win32] Repost: Classic ASP in IIS with Python - 500 ServerError In-Reply-To: Message-ID: <1845513182.679612.1299522590343.JavaMail.root@sz0093a.emeryville.ca.mail.comcast.net> Thanks for the tip Roger. I did try the Respone.Write (capital R and W) - no difference) I did this: pyscript.py --debug It said registered in debug mode. Now what?? Is there a log or something that would get created if python were ever invoked by ASP? It seem like Python is just not getting called at all.? The strange thing is this used to work on my PC.? Now that I actually have a project that could use classic ASP and Python, I can't make it work.? Bummer. I do have other alternatives but I wanted to use ASP specifically for the session variable support.? These behave just like globals and can be pass around from ASP script to ASP script.? Very handy... Best Regards, J.D. Try registering it in debug mode, by passing --debug to pyscript.py. The trace collector in Pythonwin should show any error msgs generated by Python (assuming it gets as far as loading Python). ?? ? ? ? ? Roger -------------- next part -------------- An HTML attachment was scrubbed... URL: From rupole at hotmail.com Tue Mar 8 04:30:30 2011 From: rupole at hotmail.com (Roger Upole) Date: Mon, 7 Mar 2011 22:30:30 -0500 Subject: [python-win32] Repost: Classic ASP in IIS with Python -500 ServerError References: <1845513182.679612.1299522590343.JavaMail.root@sz0093a.emeryville.ca.mail.comcast.net> Message-ID: jdmain at comcast.net wrote > Now what? Is there a log or something that would get created if python were ever invoked by ASP? Open Pythonwin and select Tools->Trace collector debugging tool This will show a window that displays any debug output. Roger From python at bdurham.com Tue Mar 8 16:15:13 2011 From: python at bdurham.com (python at bdurham.com) Date: Tue, 08 Mar 2011 10:15:13 -0500 Subject: [python-win32] Detect new/changed file in a folder Message-ID: <1299597313.18613.1427463489@webmail.messagingengine.com> I'm looking for advice on ways to have a script detect new or changed files in a specific folder. The easy way is to simply poll every second and to sleep between polling cycles. Is there a win32 technique that works from XP forward that might be a better choice? And/or are there issues with a simple polling technique that I should be aware of? Thank you, Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Mar 8 16:29:36 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 08 Mar 2011 15:29:36 +0000 Subject: [python-win32] Detect new/changed file in a folder In-Reply-To: <1299597313.18613.1427463489@webmail.messagingengine.com> References: <1299597313.18613.1427463489@webmail.messagingengine.com> Message-ID: <4D764B60.8050400@timgolden.me.uk> On 08/03/2011 15:15, python at bdurham.com wrote: > I'm looking for advice on ways to have a script detect new or changed > files in a specific folder. The easy way is to simply poll every > second and to sleep between polling cycles. Is there a win32 > technique that works from XP forward that might be a better choice? > And/or are there issues with a simple polling technique that I should > be aware of? Brian Curtin's just written about this very subject: http://blog.briancurtin.com/2011/02/18/the-five-year-project-net-filesystemwatcher-clone-for-python/ http://pypi.python.org/pypi/watcher/ TJG From brian.curtin at gmail.com Tue Mar 8 16:36:29 2011 From: brian.curtin at gmail.com (Brian Curtin) Date: Tue, 8 Mar 2011 09:36:29 -0600 Subject: [python-win32] Detect new/changed file in a folder In-Reply-To: <4D764B60.8050400@timgolden.me.uk> References: <1299597313.18613.1427463489@webmail.messagingengine.com> <4D764B60.8050400@timgolden.me.uk> Message-ID: On Tue, Mar 8, 2011 at 09:29, Tim Golden wrote: > On 08/03/2011 15:15, python at bdurham.com wrote: > >> I'm looking for advice on ways to have a script detect new or changed >> files in a specific folder. The easy way is to simply poll every >> second and to sleep between polling cycles. Is there a win32 >> technique that works from XP forward that might be a better choice? >> And/or are there issues with a simple polling technique that I should >> be aware of? >> > > Brian Curtin's just written about this very subject: > > > > http://blog.briancurtin.com/2011/02/18/the-five-year-project-net-filesystemwatcher-clone-for-python/ > > http://pypi.python.org/pypi/watcher/ > > TJG Thanks for the plug :) I should also note that watcher now supports Python 2 and 3. -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at bdurham.com Tue Mar 8 16:54:32 2011 From: python at bdurham.com (python at bdurham.com) Date: Tue, 08 Mar 2011 10:54:32 -0500 Subject: [python-win32] Detect new/changed file in a folder In-Reply-To: <4D764B60.8050400@timgolden.me.uk> References: <1299597313.18613.1427463489@webmail.messagingengine.com> <4D764B60.8050400@timgolden.me.uk> Message-ID: <1299599672.31670.1427478421@webmail.messagingengine.com> Tim, Ben and Brian, Thank you all for your posts - excellent information(!!!). You have all answered my question. Cheers, Malcolm From graham.bloice at trihedral.com Wed Mar 9 17:40:02 2011 From: graham.bloice at trihedral.com (Graham Bloice) Date: Wed, 09 Mar 2011 16:40:02 +0000 Subject: [python-win32] Missing adsi.pyd, pwin32-216 Message-ID: <4D77AD62.8000208@trihedral.com> The dll adsi.pyd is missing from the 216 build for Python 3.2. I've checked both the 32 and 64 bit variants and it's missing from both. -- Regards, Graham Bloice -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Thu Mar 10 12:29:13 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 10 Mar 2011 11:29:13 +0000 Subject: [python-win32] Missing adsi.pyd, pwin32-216 In-Reply-To: <4D77AD62.8000208@trihedral.com> References: <4D77AD62.8000208@trihedral.com> Message-ID: <4D78B609.5080501@timgolden.me.uk> On 09/03/2011 16:40, Graham Bloice wrote: > The dll adsi.pyd is missing from the 216 build for Python 3.2. I've > checked both the 32 and 64 bit variants and it's missing from both. Roger Upole can obviously speak for himself, but in a email conversation I had with him a while back, he said that they hadn't been able to build it because of an issue with the version of SWIG they were using (or something). IOW, even if you were to build pywin32 yourself, it still won't be there: it's not just a distribution issue. TJG From mail at timgolden.me.uk Thu Mar 10 12:30:53 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 10 Mar 2011 11:30:53 +0000 Subject: [python-win32] Missing adsi.pyd, pwin32-216 In-Reply-To: <4D78B609.5080501@timgolden.me.uk> References: <4D77AD62.8000208@trihedral.com> <4D78B609.5080501@timgolden.me.uk> Message-ID: <4D78B66D.9080701@timgolden.me.uk> On 10/03/2011 11:29, Tim Golden wrote: > On 09/03/2011 16:40, Graham Bloice wrote: >> The dll adsi.pyd is missing from the 216 build for Python 3.2. I've >> checked both the 32 and 64 bit variants and it's missing from both. > > Roger Upole can obviously speak for himself, but in a email > conversation I had with him a while back, he said that they hadn't > been able to build it because of an issue with the version > of SWIG they were using (or something). IOW, even if you were > to build pywin32 yourself, it still won't be there: it's not just > a distribution issue. And, to clarify, I mean that it couldn't be built under Python 3.x; ie adsi should be present in all Python 2.x builds and won't be present in any python 3.x build. TJG From inf200640 at ucf.edu.cu Thu Mar 10 18:59:29 2011 From: inf200640 at ucf.edu.cu (inf200640 at ucf.edu.cu) Date: Thu, 10 Mar 2011 12:59:29 -0500 (EST) Subject: [python-win32] Win32_NTLogEvent access denied exception Message-ID: <2361.10.14.18.36.1299779969.squirrel@correo> Hello list, I'm having problems recieving local wmi events from Win32_NTLogEvent class. It turns out that I want to know which user starts or stops services. I set a watcher for that propose and it raises the following exception: x_access_denied: I have done the same with other classes and everything works just fine. The script is running from the system's administration account. Do I need to provide extra privileges in con = wmi.WMI()? Could anyone help me figure out what is happening, please? Thanks a lot for your assistance, Silvia --- Free the Cuban Five! http://www.injusticia.cubaweb.cu/ http://www.antiterroristas.cu/ From timr at probo.com Thu Mar 10 19:24:09 2011 From: timr at probo.com (Tim Roberts) Date: Thu, 10 Mar 2011 10:24:09 -0800 Subject: [python-win32] Win32_NTLogEvent access denied exception In-Reply-To: <2361.10.14.18.36.1299779969.squirrel@correo> References: <2361.10.14.18.36.1299779969.squirrel@correo> Message-ID: <4D791749.5050302@probo.com> inf200640 at ucf.edu.cu wrote: > I'm having problems recieving local wmi events from Win32_NTLogEvent class. It turns > out that I want to know which user starts or stops services. I set a watcher for that > propose and it raises the following exception: > > x_access_denied: pci\xf3n.', (0, u'SWbemServicesEx', u'Acceso denegado ', None, 0, -2147217405), > None)> > > I have done the same with other classes and everything works just fine. > > The script is running from the system's administration account. Do I need to provide > extra privileges in con = wmi.WMI()? > > Could anyone help me figure out what is happening, please? Did you look at the documentation? http://msdn.microsoft.com/en-us/library/aa394226.aspx The very first paragraph says: An application must have SeSecurityPrivilege to receive events from the security event log, otherwise "Access Denied" is returned to the application. -2147217405 is 0x80041003, which is WBEM_E_ACCESS_DENIED, just like it says. It takes a surprising amount of code to acquire a privilege. Here is some Python code that shows how to do it: http://windows-privesc-check.googlecode.com/svn-history/r10/trunk/windows-privesc-check.py Check "get_extra_privs" about half-way through. You can simplify it a little bit, since you are looking for exactly one privilege. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mail at timgolden.me.uk Thu Mar 10 19:46:47 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 10 Mar 2011 18:46:47 +0000 Subject: [python-win32] Win32_NTLogEvent access denied exception In-Reply-To: <4D791749.5050302@probo.com> References: <2361.10.14.18.36.1299779969.squirrel@correo> <4D791749.5050302@probo.com> Message-ID: <4D791C97.5000207@timgolden.me.uk> On 10/03/2011 6:24 PM, Tim Roberts wrote: > inf200640 at ucf.edu.cu wrote: >> I'm having problems recieving local wmi events from Win32_NTLogEvent class. It turns >> out that I want to know which user starts or stops services. I set a watcher for that >> propose and it raises the following exception: >> >> x_access_denied:> pci\xf3n.', (0, u'SWbemServicesEx', u'Acceso denegado ', None, 0, -2147217405), >> None)> >> >> I have done the same with other classes and everything works just fine. >> >> The script is running from the system's administration account. Do I need to provide >> extra privileges in con = wmi.WMI()? >> >> Could anyone help me figure out what is happening, please? > > Did you look at the documentation? > http://msdn.microsoft.com/en-us/library/aa394226.aspx > The very first paragraph says: > > An application must have SeSecurityPrivilege to receive events from > the security event log, otherwise "Access Denied" is returned to the > application. > > -2147217405 is 0x80041003, which is WBEM_E_ACCESS_DENIED, just like it says. > > It takes a surprising amount of code to acquire a privilege. Here is > some Python code that shows how to do it: Well, I think I can help out on three fronts here: 1) For WMI purposes, acquiring a privilege is as simple as adding a clause to the WMI moniker. Using the wmi module, it's even easier: c = wmi.WMI (privileges=["security"]) 2) On W7, at least, in a non-elevated command prompt, this wasn't enough to let me capture eventlog events: I had to run it in an elevated command prompt. 3) If you did want to apply the priv to the whole process you were in (as per the code Tim R pointed to) you might do worse than use my winsys package: from winsys import security with security.change_privileges (["security"]): # do stuff http://timgolden.me.uk/python/winsys/security.html#security.change_privileges However, I don't believe that's necessary here... TJG From rupole at hotmail.com Thu Mar 10 23:37:42 2011 From: rupole at hotmail.com (Roger Upole) Date: Thu, 10 Mar 2011 17:37:42 -0500 Subject: [python-win32] Missing adsi.pyd, pwin32-216 References: <4D77AD62.8000208@trihedral.com> <4D78B609.5080501@timgolden.me.uk> <4D78B66D.9080701@timgolden.me.uk> Message-ID: "Tim Golden" wrote in message news:4D78B66D.9080701 at timgolden.me.uk... > On 10/03/2011 11:29, Tim Golden wrote: >> On 09/03/2011 16:40, Graham Bloice wrote: >>> The dll adsi.pyd is missing from the 216 build for Python 3.2. I've >>> checked both the 32 and 64 bit variants and it's missing from both. >> >> Roger Upole can obviously speak for himself, but in a email >> conversation I had with him a while back, he said that they hadn't >> been able to build it because of an issue with the version >> of SWIG they were using (or something). IOW, even if you were >> to build pywin32 yourself, it still won't be there: it's not just >> a distribution issue. > > And, to clarify, I mean that it couldn't be built under Python 3.x; > ie adsi should be present in all Python 2.x builds and won't be > present in any python 3.x build. > > TJG That sums it up pretty well. Here's the longer version: The SWIG in Pywin32 had been customised to accomodate COM objects that inherit from another interface. Somewhere along the line, the source code has been lost, so when I ported SWIG to Python 3, I had to start from a clean source tree. It should be possible to reverse engineer the custom code from the output generated for Python 2, but nobody's had time to do so yet. Roger From rupole at hotmail.com Sat Mar 12 01:54:01 2011 From: rupole at hotmail.com (Roger Upole) Date: Fri, 11 Mar 2011 19:54:01 -0500 Subject: [python-win32] Conversion to Mercurial is done References: <4D732417.6010800@skippinet.com.au> Message-ID: "Vernon Cole" wrote in message news:AANLkTingKzzUt4KPzJUqa5DRT2iJiyS50pQtc6WA6aPb at mail.gmail.com... > Working fine here. Here's a sample for anyone who has not tried sourceforge > hg before. > I have PuTTY loaded on this machine, and already have my ssh keys set up on > sourceforge -- just like with CVS. > Mercurial is loaded using the binary installer. > And, I actually remembered to load my sourceforge keys into Pagent before I > started. ;-) > > In order to get read/write access, I used the ssh:// url as documented on > the page Mark referenced. > https://sourceforge.net/scm/?type=hg&group_id=78018 > > If your are reading a rich text (html) version of this, my input below > is highlighted > in yellow. > Don't copy this exactly, you will need to use your own username where I have > "kf7xm". > I keep my mercurial trees in a C:\hg folder. YMMV > > I had the usual "The server's host key is not cached in the registry" > problem. > Solved by running a quick plink command to the server in question: > > > C:\hg>plink kf7xm at pywin32.hg.sourceforge.net ls > The server's host key is not cached in the registry. You > have no guarantee that the server is the computer you > think it is. > The server's rsa2 key fingerprint is: > ssh-rsa 2048 86:7b:1b:12:85:35:8a:b7:98:b6:d2:97:5e:96:58:1d > If you trust this host, enter "y" to add the key to > PuTTY's cache and carry on connecting. > If you want to carry on connecting just once, without > adding the key to the cache, enter "n". > If you do not trust this host, press Return to abandon the > connection. > Store key in cache? (y/n) y > > Welcome to *.hg.sourceforge.net > > C:\hg>hg clone ssh://kf7xm at pywin32.hg.sourceforge.net/hgroot/pywin32/pywin32 > destination directory: pywin32 > requesting all changes > adding changesets > adding manifests > adding file changes > added 4100 changesets with 9863 changes to 1831 files (+1 heads) > updating to branch default > 1545 files updated, 0 files merged, 0 files removed, 0 files unresolved > > C:\hg>cd pywin32 > C:\hg>dir > > -- > Vernon > > On Sat, Mar 5, 2011 at 11:05 PM, Mark Hammond > wrote: >> I've converted the CVS repository to a Mercurial (hg) and after a few > tweaks [...] > Thanks for the tips. I just got around to trying out the Mercurial repository, and this was a big help. While I was installing TortoiseHg so that I could pull down the Pywin32 source, I discovered that it uses Pywin32 ! Roger From rupole at hotmail.com Sat Mar 12 02:16:38 2011 From: rupole at hotmail.com (Roger Upole) Date: Fri, 11 Mar 2011 20:16:38 -0500 Subject: [python-win32] Missing adsi.pyd, pwin32-216 References: <4D77AD62.8000208@trihedral.com> <4D78B609.5080501@timgolden.me.uk><4D78B66D.9080701@timgolden.me.uk> Message-ID: "Roger Upole" wrote in message news:ilbjrn$f6k$1 at dough.gmane.org... > > "Tim Golden" wrote in message news:4D78B66D.9080701 at timgolden.me.uk... >> On 10/03/2011 11:29, Tim Golden wrote: >>> On 09/03/2011 16:40, Graham Bloice wrote: >>>> The dll adsi.pyd is missing from the 216 build for Python 3.2. I've >>>> checked both the 32 and 64 bit variants and it's missing from both. >>> >>> Roger Upole can obviously speak for himself, but in a email >>> conversation I had with him a while back, he said that they hadn't >>> been able to build it because of an issue with the version >>> of SWIG they were using (or something). IOW, even if you were >>> to build pywin32 yourself, it still won't be there: it's not just >>> a distribution issue. >> >> And, to clarify, I mean that it couldn't be built under Python 3.x; >> ie adsi should be present in all Python 2.x builds and won't be >> present in any python 3.x build. >> >> TJG > > That sums it up pretty well. > > Here's the longer version: > The SWIG in Pywin32 had been customised to accomodate > COM objects that inherit from another interface. Somewhere > along the line, the source code has been lost, so when I ported > SWIG to Python 3, I had to start from a clean source tree. > > It should be possible to reverse engineer the custom code from > the output generated for Python 2, but nobody's had time to > do so yet. > > Roger I took a look at this some more, and was able to get adsi built for python 3.1 using the module (adsi.cpp) as generated by the Py3k port of swig, and the interfaces (PyIADs****.cpp) as generated by the Python2 version of Swig, with just a few manual modifications. If anybody needs adsi for Py3k really badly, we could "un-swig" it temporarily. On an ironic note, I was going to see how much work it would take to duplicate the lost custom code in our Py3k port of swig, but I seem to have lost the source code somehow .... Roger From linjunhalida at gmail.com Mon Mar 14 01:19:08 2011 From: linjunhalida at gmail.com (=?UTF-8?B?5py65qKw5ZSv54mp5Li75LmJIDogbGluanVuaGFsaWRh?=) Date: Mon, 14 Mar 2011 08:19:08 +0800 Subject: [python-win32] [adodbapi]cannot query date type? any example please? Message-ID: hello, is there any example for adodbapi? (more then testcase ship with installer) need to filter query result by time, but got error: >>> adodbapi.version 'adodbapi v2.4.0' Background.mdb has this table t: create table t (data string, t date); here is the code: import adodbapi, win32com import adodbapi.ado_consts as adc import datetime, time def main(): filename = u"c:/workspace/Background.mdb" connect_string = u'DRIVER={Microsoft Access Driver (*.mdb)};DBQ=%s;' % filename conn = adodbapi.connect(connect_string) cursor = conn.cursor() v = datetime.datetime(2010, 12, 27, 11, 40, 1) s = u'select t from t ' cursor.execute(s) out = cursor.fetchall() for row in out: print row s = u'select t from t where t between ? and ?' cursor.execute(s, (v, v)) out = cursor.fetchall() for row in out: print row if __name__=="__main__": main() here is the error: adodbapi.adodbapi.DataError: Converting Parameter p0: adDBTimeStamp, None <- datetime.datetime(2010, 12, 27, 11, 40, 1) thanks for your help! From linjunhalida at gmail.com Mon Mar 14 02:15:14 2011 From: linjunhalida at gmail.com (=?UTF-8?B?5py65qKw5ZSv54mp5Li75LmJIDogbGluanVuaGFsaWRh?=) Date: Mon, 14 Mar 2011 09:15:14 +0800 Subject: [python-win32] [adodbapi]cannot query date type? any example please? In-Reply-To: References: Message-ID: OK, got it. use this method: sql = 'select * from t where t between #%s# and #%s#' % (t1.strftime('%m/%d/%Y %I:%M:%S %p'), t1.strftime('%m/%d/%Y %I:%M:%S %p')) ugly but works... 2011/3/14 ?????? : linjunhalida : > hello, is there any example for adodbapi? (more then testcase ship > with installer) > need to filter query result by time, but got error: > >>>> adodbapi.version > 'adodbapi v2.4.0' > > Background.mdb has this table t: > create table t (data string, t date); > > here is the code: > > import adodbapi, win32com > import adodbapi.ado_consts as adc > import datetime, time > > def main(): > ? ?filename = u"c:/workspace/Background.mdb" > ? ?connect_string = u'DRIVER={Microsoft Access Driver > (*.mdb)};DBQ=%s;' % filename > > ? ?conn = adodbapi.connect(connect_string) > ? ?cursor = conn.cursor() > > ? ?v = datetime.datetime(2010, 12, 27, 11, 40, 1) > > ? ?s = u'select t from t ' > ? ?cursor.execute(s) > > ? ?out = cursor.fetchall() > ? ?for row in out: print row > > ? ?s = u'select t from t where t between ? and ?' > ? ?cursor.execute(s, (v, v)) > > ? ?out = cursor.fetchall() > ? ?for row in out: print row > > > if __name__=="__main__": > ? ?main() > > here is the error: > > adodbapi.adodbapi.DataError: Converting Parameter p0: adDBTimeStamp, > None <- datetime.datetime(2010, 12, 27, 11, 40, 1) > > > thanks for your help! > From greg.ewing at canterbury.ac.nz Mon Mar 14 07:27:48 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Mon, 14 Mar 2011 19:27:48 +1300 Subject: [python-win32] GetScrollInfo and SetScrollInfo method signatures? Message-ID: <4D7DB564.8090103@canterbury.ac.nz> According to the pywin32 docs, PyCWnd.GetScrollInfo and PyCWnd.SetScrollInfo have the following signatures: int = GetScrollInfo(nBar, mask) int = SetScrollInfo(nBar, redraw) Surely these can't be right? Shouldn't there be a SCROLLINFO struct involved there somewhere? -- Greg From rupole at hotmail.com Mon Mar 14 09:19:39 2011 From: rupole at hotmail.com (Roger Upole) Date: Mon, 14 Mar 2011 04:19:39 -0400 Subject: [python-win32] GetScrollInfo and SetScrollInfo method signatures? References: <4D7DB564.8090103@canterbury.ac.nz> Message-ID: "Greg Ewing" wrote in message news:4D7DB564.8090103 at canterbury.ac.nz... > According to the pywin32 docs, PyCWnd.GetScrollInfo and > PyCWnd.SetScrollInfo have the following signatures: > > int = GetScrollInfo(nBar, mask) > int = SetScrollInfo(nBar, redraw) > > Surely these can't be right? Shouldn't there be a > SCROLLINFO struct involved there somewhere? > > -- > Greg Yep, the docs are wrong for these. The second arg to SetScrollInfo is a tuple to be parsed into the struct, and redraw is 3rd. The args are correct for GetScrollInfo, but the return value is a SCROLLINFO tuple, not an int. Roger From mail at timgolden.me.uk Mon Mar 14 10:07:49 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 14 Mar 2011 09:07:49 +0000 Subject: [python-win32] Missing adsi.pyd, pwin32-216 In-Reply-To: References: <4D77AD62.8000208@trihedral.com> <4D78B609.5080501@timgolden.me.uk><4D78B66D.9080701@timgolden.me.uk> Message-ID: <4D7DDAE5.3080407@timgolden.me.uk> On 12/03/2011 01:16, Roger Upole wrote: > I took a look at this some more, and was able to get adsi built > for python 3.1 using the module (adsi.cpp) as generated by the Py3k port > of swig, and the interfaces (PyIADs****.cpp) as generated by the > Python2 version of Swig, with just a few manual modifications. > If anybody needs adsi for Py3k really badly, we could "un-swig" it > temporarily. Well, I don't know about "really badly" but at the moment a Py3K port of my active_directory module is basically stalled as I have to decide whether to: revert to IDispatch-only objects; roll my own interface to the IADs objects; or try to fix the pywin32 adsi module. None of them is trivial so a leg-up in the shape of a working adsi would help move that forward. Thanks TJG From bwillmarth at gmail.com Fri Mar 18 01:13:28 2011 From: bwillmarth at gmail.com (Blake Willmarth) Date: Thu, 17 Mar 2011 20:13:28 -0400 Subject: [python-win32] Clicking an li tag in Internet Explorer Message-ID: Hello, I am having trouble navigating the MS documentation to find out how to click an
  • element. I only have the class attribute name as the identifying feature:
  • The one hope I had was ie.Document.getElementsByTagName("li") but this seems to be only getting tags. Any pointers would be really appreciated. Thanks, Blake -------------- next part -------------- An HTML attachment was scrubbed... URL: From bwillmarth at gmail.com Fri Mar 18 01:39:22 2011 From: bwillmarth at gmail.com (Blake Willmarth) Date: Thu, 17 Mar 2011 20:39:22 -0400 Subject: [python-win32] Clicking an li tag in Internet Explorer In-Reply-To: References: Message-ID: I was wrong about them being links, the method does work as intended and I was able to click the correct one using the className attribute: liTags = ie.Document.getElementsByTagName("li") for i in range(liTags.Length): if liTags[i].className == "NextEnabled": liTags[i].Click() Sorry. On Thu, Mar 17, 2011 at 8:13 PM, Blake Willmarth wrote: > Hello, > > I am having trouble navigating the MS documentation to find out how to > click an
  • element. I only have the class attribute name as the > identifying feature:
  • > > The one hope I had was ie.Document.getElementsByTagName("li") but this > seems to be only getting tags. > > Any pointers would be really appreciated. > > Thanks, > Blake > -------------- next part -------------- An HTML attachment was scrubbed... URL: From python-win32 at recluse.demon.co.uk Fri Mar 18 19:47:38 2011 From: python-win32 at recluse.demon.co.uk (nobody) Date: Fri, 18 Mar 2011 18:47:38 +0000 Subject: [python-win32] Event problems in Excel 2007/Windows 7/Python 2.6 Message-ID: <4D83A8CA.6060804@recluse.demon.co.uk> I have Excel 2007 on Windows7 on a twin CPU machine and am trying to get events to fire from the COM objects in win32com examples. Specifically, when I load the excelAddin.py example, all looks good and the Python menu item appears on the menubar (ribbon) but clicking on it does nothing. Trying the excelRTDserver.py example has similar problem - the time comes up when I enter the formula in Excel and a bit of judicious logging shows the Update function called like clockwork (;-) but the SignalExcel() function has no effect - the time in Excel does not tick and RefreshData is never called. I messed about with trying to capture the Excel callback object thread and using CoInitialise and CoGetInterfaceAndReleaseStream to get a reference to it on the Excel original (COM) thread but this all had no effect (either through my incompetence or failure of the approach to fix the problem). If I change the formula in Excel to have a different timer period then it updates the time once when I hit Enter then sits there unchanging again. The Heartbeats are called (by Excel) and responded to as usual. I tried to use the win32 timer example in place of the python Thread timers but this just caused Excel to call ServerTerminate() on me so I have obviously done something it finds offensive - I just get NA in Excel after that. I added the C:\Python26 directory and subdirs to the Trusted Locations in Excel, and also the parent directory where I have my examples stored, but to no avail. Is anyone aware of some extra security or policy setting I need enabled for these events to start working ? Was I barking up the wrong tree with trying to get back to the calling thread or is this at the heart of the problem and I just failed to implement it properly ? There are examples of using the calling thread in other examples but they are on the client side - the one that uses internet explorer seems to work fine for me. My ultimate goal is to link Excel to remote python processes using STOMP on ActiveMQ. I can send STOMP messages from Excel via Python into my ActiveMQ pipe with ease, and do 'synchronous' receives, using win32com magic, and I can make the Excel async receives work after a fashion by polling in a loop which includes DoEvents but this is not very satisfactory - I really want to generate events from a Python COM object on a message receive and use the RTD mechanism or something WithEvents of my own devising, but I cannot make this work. Any idea what has become broken in Excel/Windows/Python 2.6 ? Thanks Rick From rsyring at inteli-com.com Fri Mar 18 22:28:35 2011 From: rsyring at inteli-com.com (Randy Syring) Date: Fri, 18 Mar 2011 17:28:35 -0400 Subject: [python-win32] Backup up Windows ACLs Message-ID: <4D83CE83.6050409@inteli-com.com> I'm working on a backup solution using the ZFS file system. The idea is somewhat like rdiff-backup, except that the backup tool doesn't need to worry about versioning, compressiong, or deduplicating the files. ZFS will handle compression and deduplication. rsnapshot will handle versioning. The issue I am running into is that I am not sure how to copy files from windows to the Linux and preserve ACLs. I am thinking about building a client for windows machines in python that would be responsible for copying the files to the backup server's "staging" area. It would need to A) use an rsync like protocal so only deltas get sent over the network B) use VSS for hot-backups and C) preserve ACL info on the backed up files. I have good leads on A & B, but not sure about C, hence this email. Obviously, it would be ideal if something like this already existed, but I am not aware of anything. rdiff-backup is close, but I just don't need all the extra versioning stuff it does. Thoughts or suggestions appreciated. -- -------------------------------------- Randy Syring Intelicom Direct: 502-276-0459 Office: 502-212-9913 For the wages of sin is death, but the free gift of God is eternal life in Christ Jesus our Lord (Rom 6:23) From mail at timgolden.me.uk Fri Mar 18 22:34:49 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 18 Mar 2011 21:34:49 +0000 Subject: [python-win32] Backup up Windows ACLs In-Reply-To: <4D83CE83.6050409@inteli-com.com> References: <4D83CE83.6050409@inteli-com.com> Message-ID: <4D83CFF9.5010303@timgolden.me.uk> On 18/03/2011 9:28 PM, Randy Syring wrote: > The issue I am running into is that I am not sure how to copy files from > windows to the Linux and preserve ACLs. I assume that you only want to preserve them as metadata, not to map them somehow to whatever security model obtains on the Linux disk? The only kind of thing I can come up with (hand-wavingly) is to convert the SD of each file to its equivalent SDDL and then to track that along with the file. I was going to suggest stuffing it in an ADS but presumably that wouldn't survive the journey to Linux either. No doubt you could contrive some kind of parallel metadata/database which could hold the info... The additional complication with ACLs (especially when it comes to restoring them) is coping with the levels of inheritance and override. TJG From mail at timgolden.me.uk Fri Mar 18 23:21:03 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 18 Mar 2011 22:21:03 +0000 Subject: [python-win32] Backup up Windows ACLs In-Reply-To: <4D83CFF9.5010303@timgolden.me.uk> References: <4D83CE83.6050409@inteli-com.com> <4D83CFF9.5010303@timgolden.me.uk> Message-ID: <4D83DACF.3070207@timgolden.me.uk> On 18/03/2011 9:34 PM, Tim Golden wrote: > On 18/03/2011 9:28 PM, Randy Syring wrote: >> The issue I am running into is that I am not sure how to copy files from >> windows to the Linux and preserve ACLs. > > I assume that you only want to preserve them as metadata, not > to map them somehow to whatever security model obtains on the > Linux disk? > > The only kind of thing I can come up with (hand-wavingly) is to > convert the SD of each file to its equivalent SDDL and then to > track that along with the file. I was going to suggest stuffing > it in an ADS but presumably that wouldn't survive the journey > to Linux either. No doubt you could contrive some kind of > parallel metadata/database which could hold the info... ... or even (slightly wild-eyed thought) including the SDDL as a segment in the backed-up filename, suitably escaped. Semi-tested proof of concept: import os, sys import win32security import win32file if not os.path.exists ("c:/temp/sddl"): os.mkdir ("c:/temp/sddl") for dirpath, dirnames, filenames in os.walk ("c:/temp"): for filename in filenames: print filename sd = win32security.GetFileSecurity ( os.path.join (dirpath, filename), win32security.DACL_SECURITY_INFORMATION ) sddl = win32security.ConvertSecurityDescriptorToStringSecurityDescriptor ( sd, win32security.SDDL_REVISION_1, win32security.DACL_SECURITY_INFORMATION ) print sddl base, ext = os.path.splitext (filename) win32file.CopyFile ( os.path.join (dirpath, filename), os.path.join ("c:/temp/sddl", base + "." + sddl.replace (":", "#") + ext), 1 ) break TJG From rsyring at inteli-com.com Fri Mar 18 23:33:41 2011 From: rsyring at inteli-com.com (Randy Syring) Date: Fri, 18 Mar 2011 18:33:41 -0400 Subject: [python-win32] Backup up Windows ACLs In-Reply-To: <4D83CFF9.5010303@timgolden.me.uk> References: <4D83CE83.6050409@inteli-com.com> <4D83CFF9.5010303@timgolden.me.uk> Message-ID: <4D83DDC5.90603@inteli-com.com> On 03/18/2011 05:34 PM, Tim Golden wrote: > On 18/03/2011 9:28 PM, Randy Syring wrote: >> The issue I am running into is that I am not sure how to copy files from >> windows to the Linux and preserve ACLs. > > I assume that you only want to preserve them as metadata, not > to map them somehow to whatever security model obtains on the > Linux disk? Correct. > > The only kind of thing I can come up with (hand-wavingly) is to > convert the SD of each file to its equivalent SDDL and then to > track that along with the file. I was going to suggest stuffing > it in an ADS but presumably that wouldn't survive the journey > to Linux either. No doubt you could contrive some kind of > parallel metadata/database which could hold the info... Ok, I read up on my accronyms. Is there anything in the windows python landscape that implements SD <=> SDDL or would be a building block to doing so? Looks like the following might fit the bill: http://code.google.com/p/pysddl/source/browse/trunk/sddl.py/sddl.py I'm also wondering what the best method would be for creating this information and sending it to the backup server. Should I create a temp file every time I do backups, send the file to the server, then delete the file. Or should I cache the info somewhere. Any suggestions? > > The additional complication with ACLs (especially when it comes > to restoring them) is coping with the levels of inheritance and > override. > Dully noted. Any advice or code examples that might help with this? -------------------------------------- Randy Syring Intelicom Direct: 502-276-0459 Office: 502-212-9913 For the wages of sin is death, but the free gift of God is eternal life in Christ Jesus our Lord (Rom 6:23) From btimby at gmail.com Sat Mar 19 01:21:11 2011 From: btimby at gmail.com (Ben Timby) Date: Fri, 18 Mar 2011 20:21:11 -0400 Subject: [python-win32] Backup up Windows ACLs In-Reply-To: <4D83CE83.6050409@inteli-com.com> References: <4D83CE83.6050409@inteli-com.com> Message-ID: On Fri, Mar 18, 2011 at 5:28 PM, Randy Syring wrote: > I'm working on a backup solution using the ZFS file system. ?The idea is > somewhat like rdiff-backup, except that the backup tool doesn't need to > worry about versioning, compressiong, or deduplicating the files. ?ZFS will > handle compression and deduplication. ?rsnapshot will handle versioning. > > The issue I am running into is that I am not sure how to copy files from > windows to the Linux and preserve ACLs. ?I am thinking about building a > client for windows machines in python that would be responsible for copying > the files to the backup server's "staging" area. ?It would need to A) use an > rsync like protocal so only deltas get sent over the network B) use VSS for > hot-backups and C) preserve ACL info on the backed up files. ?I have good > leads on A & B, but not sure about C, hence this email. > > Obviously, it would be ideal if something like this already existed, but I > am not aware of anything. ?rdiff-backup is close, but I just don't need all > the extra versioning stuff it does. I would suggest looking at Samba. This would help you solve two problems. 1. Transporting files to the Linux server. 2. The ACL issue, you can use extended ACL support, which, when integrated with a Windows domain, can map UID/GID to objects in the domain. Winbind allows this by mapping Windows objects to UID/GID on the Linux machine through the magic of nsswitch. Extended acls are then managed Linux-side using setfacl and getfacl. I have set this up using the ext3 file system, so I am not sure about ZFS support. I know that samba supports extended ACLs on Solaris ZFS, but could not find a definitive answer either way when using ZFS on Linux. Worth a look though. Another possiblity is to look for an archive format that supports the meta data you want. For example on Linux tar contains all the modes and other file meta data needed to restore the files. If there is not an existing similar archive format you can use on Windows, then you can "extend" one by appending a .catalog file that contains the pickled file meta data. Then a simple python module can create the .catalog file and then create the archive using the regular tool appending the .catalog to it. Restoring would be equally simple by extracting the files and then restoring the meta data (and deleting the .catalog file). From rsyring at inteli-com.com Sat Mar 19 02:31:07 2011 From: rsyring at inteli-com.com (Randy Syring) Date: Fri, 18 Mar 2011 21:31:07 -0400 Subject: [python-win32] Backup up Windows ACLs In-Reply-To: <4D83DACF.3070207@timgolden.me.uk> References: <4D83CE83.6050409@inteli-com.com> <4D83CFF9.5010303@timgolden.me.uk> <4D83DACF.3070207@timgolden.me.uk> Message-ID: <4D84075B.4000506@inteli-com.com> On 03/18/2011 06:21 PM, Tim Golden wrote: > ... or even (slightly wild-eyed thought) including the SDDL as > a segment in the backed-up filename, suitably escaped. Semi-tested > proof of concept: I don't think I would head that route. Using an rsync like protocol, every time permissions changed, the file would be re-sent b/c the file name would be different. Better, I think, to include it some other way. -------------------------------------- Randy Syring Intelicom Direct: 502-276-0459 Office: 502-212-9913 For the wages of sin is death, but the free gift of God is eternal life in Christ Jesus our Lord (Rom 6:23) From rsyring at inteli-com.com Sat Mar 19 02:40:17 2011 From: rsyring at inteli-com.com (Randy Syring) Date: Fri, 18 Mar 2011 21:40:17 -0400 Subject: [python-win32] Backup up Windows ACLs In-Reply-To: References: <4D83CE83.6050409@inteli-com.com> Message-ID: <4D840981.5000900@inteli-com.com> On 03/18/2011 08:21 PM, Ben Timby wrote: > I would suggest looking at Samba. This would help you solve two problems. > > 1. Transporting files to the Linux server. > 2. The ACL issue, you can use extended ACL support, which, when > integrated with a Windows domain, can map UID/GID to objects in the > domain. Winbind allows this by mapping Windows objects to UID/GID on > the Linux machine through the magic of nsswitch. It might help w/ the ACL issue. It looks like posix ACLs lose some fidelity, but with ZFS and NFS v4 ACLs, there is a much greater precision. However, this would defeat some of what I am looking for b/c I want to transfer files w/ rsync. Just doing a copy to network share might feasibly keep the ACLs, but, I think, would send all files over the network. > Another possiblity is to look for an archive format that supports the > meta data you want. For example on Linux tar contains all the modes > and other file meta data needed to restore the files. If there is not > an existing similar archive format you can use on Windows, then you > can "extend" one by appending a .catalog file that contains the > pickled file meta data. Then a simple python module can create the > .catalog file and then create the archive using the regular tool > appending the .catalog to it. Restoring would be equally simple by > extracting the files and then restoring the meta data (and deleting > the .catalog file). A possibility, but I want to only send deltas over the network. So I won't be packaging/zipping files. I guess, I could keep a data store of flat files of some kind with ACL information. Each backup operation would go through directories, re-create the flat file with ACL info, then backup the actual files in that directory, backup the file with ACL info, then repeat. -------------------------------------- Randy Syring Intelicom Direct: 502-276-0459 Office: 502-212-9913 For the wages of sin is death, but the free gift of God is eternal life in Christ Jesus our Lord (Rom 6:23) From btimby at gmail.com Sat Mar 19 02:50:50 2011 From: btimby at gmail.com (Ben Timby) Date: Fri, 18 Mar 2011 21:50:50 -0400 Subject: [python-win32] Backup up Windows ACLs In-Reply-To: <4D840981.5000900@inteli-com.com> References: <4D83CE83.6050409@inteli-com.com> <4D840981.5000900@inteli-com.com> Message-ID: On Fri, Mar 18, 2011 at 9:40 PM, Randy Syring wrote: > > On 03/18/2011 08:21 PM, Ben Timby wrote: >> >> I would suggest looking at Samba. This would help you solve two problems. >> >> 1. Transporting files to the Linux server. >> 2. The ACL issue, you can use extended ACL support, which, when >> integrated with a Windows domain, can map UID/GID to objects in the >> domain. Winbind allows this by mapping Windows objects to UID/GID on >> the Linux machine through the magic of nsswitch. > > It might help w/ the ACL issue. ?It looks like posix ACLs lose some > fidelity, but with ZFS and NFS v4 ACLs, there is a much greater precision. > ?However, this would defeat some of what I am looking for b/c I want to > transfer files w/ rsync. ?Just doing a copy to network share might feasibly > keep the ACLs, but, I think, would send all files over the network. rsync syncs to a directory as well as it syncs to a remote server. Just use rsync to sync to the network drive, and samba will transfer only the diff. You will see some reads as rsync calculates the checksums of each file to calculate the diff though. Of course it only does this if the file's date changed, so most compares will be fast timestamp compares only. In the case where a file actually changes, a network read (via samba) will happen so that rsync can calculate each block's checksum for the comparison. >> Another possiblity is to look for an archive format that supports the >> meta data you want. For example on Linux tar contains all the modes >> and other file meta data needed to restore the files. If there is not >> an existing similar archive format you can use on Windows, then you >> can "extend" one by appending a .catalog file that contains the >> pickled file meta data. Then a simple python module can create the >> .catalog file and then create the archive using the regular tool >> appending the .catalog to it. Restoring would be equally simple by >> extracting the files and then restoring the meta data (and deleting >> the .catalog file). > > A possibility, but I want to only send deltas over the network. ?So I won't > be packaging/zipping files. > > I guess, I could keep a data store of flat files of some kind with ACL > information. ?Each backup operation would go through directories, re-create > the flat file with ACL info, then backup the actual files in that directory, > backup the file with ACL info, then repeat. Archive does not necessarily mean compress. Also, one big file deltas just as easily as a bunch of small ones. The storage will be more compact as you don't waste block sized chunks on small files. The flip side, with the rsync approach, just create the ACL file and let rsync sync it. For a restore, sync back and then apply the ACLs. Either option has it's merits, I think you have quite a few possibilities now. From greg.ewing at canterbury.ac.nz Sat Mar 19 06:31:03 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sat, 19 Mar 2011 18:31:03 +1300 Subject: [python-win32] ANN: PyGUI 2.4 Message-ID: <4D843F97.1010008@canterbury.ac.nz> PyGUI 2.4 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ Highlights of this release: * Python 3 Compatible on MacOSX and Windows. * ScrollableView has been overhauled on Windows and should now work with all builds of pywin32 as far as I know. What is PyGUI? -------------- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing greg.ewing at canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ From mail at timgolden.me.uk Sat Mar 19 08:13:58 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Sat, 19 Mar 2011 07:13:58 +0000 Subject: [python-win32] Backup up Windows ACLs In-Reply-To: <4D83DDC5.90603@inteli-com.com> References: <4D83CE83.6050409@inteli-com.com> <4D83CFF9.5010303@timgolden.me.uk> <4D83DDC5.90603@inteli-com.com> Message-ID: <4D8457B6.8060509@timgolden.me.uk> On 18/03/2011 10:33 PM, Randy Syring wrote: > Ok, I read up on my accronyms. Is there anything in the windows python > landscape that implements SD<=> SDDL or would be a building block to > doing so? See my slightly later post for an example. [Tim Golden] >> The additional complication with ACLs (especially when it comes >> to restoring them) is coping with the levels of inheritance and >> override. >> > Dully noted. Any advice or code examples that might help with this? Not much: * Use Backup (for reading) and Restore (for writing) privileges to get/set the permissions. They're intended for your very use case. * The standard SetSecurityInfo handles the inheritance for you IIRC but also -- helpfully -- ignores it when you try to set a permission which is already inherited. I haven't looked at this recently but I'm fairly sure that's what I remember. This means that you might just be able to run down the tree restoring files and applying security willy-nilly and get away with it. One obvious issue is mapping SIDs, if you're restoring onto a system which wasn't the originator, or if accounts have been removed since then... TJG From jjmmma at gmail.com Sat Mar 19 15:01:17 2011 From: jjmmma at gmail.com (=?UTF-8?B?6aas5ZCJ6LuN?=) Date: Sat, 19 Mar 2011 22:01:17 +0800 Subject: [python-win32] [pygtk] ANN: PyGUI 2.4 In-Reply-To: <4D843F97.1010008@canterbury.ac.nz> References: <4D843F97.1010008@canterbury.ac.nz> Message-ID: excellent work. that's what i'm seeking for. BRs, Kimi ???? On Sat, Mar 19, 2011 at 1:31 PM, Greg Ewing wrote: > PyGUI 2.4 is available: > > http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ > > Highlights of this release: > > * Python 3 Compatible on MacOSX and Windows. > > * ScrollableView has been overhauled on Windows and should now > work with all builds of pywin32 as far as I know. > > > What is PyGUI? > -------------- > > PyGUI is a cross-platform GUI toolkit designed to be lightweight > and have a highly Pythonic API. > > -- > Gregory Ewing > greg.ewing at canterbury.ac.nz > http://www.cosc.canterbury.ac.nz/greg.ewing/ > _______________________________________________ > pygtk mailing list pygtk at daa.com.au > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://faq.pygtk.org/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: From barton at bcdesignswell.com Sun Mar 20 21:04:43 2011 From: barton at bcdesignswell.com (Barton) Date: Sun, 20 Mar 2011 13:04:43 -0700 Subject: [python-win32] Possible future direction for PyGUI on Win32 Message-ID: <4D865DDB.7010701@bcdesignswell.com> Ok, I'm in. (I am a win32 guy, but am beginning to like the platform less and less) I now successfully mix and match freely on GTK and Windows using wxPython + PythonDotNet + Mono or .NET in full GUI apps. It sound like this discussion is not necessarily 100% win32, or is it? Some comments on GUI performance: The ONLY time that I've seen .NET react noticeably slowly was under Ipy. I got into the .Net connector project because I wanted to learn C# on an interesting project. I find Tim's use of the technology to be spot on. I don't plan on switching from python + wx to .NET/Mono, but it sure is nice to be able to pull components from where ever they live! On 02/27/2011 08:08 AM, Benjamin Aranguren wrote:On Tue, Mar 1, 2011 at 5:05 AM, Tim Golden> wrote: >/ On 28/02/2011 09:40, Tim Golden wrote: />>/ />>/ Well, the last Svn commit was 4 weeks ago, by "barton_c", and Python27 />>/ "support" (ie switches") were added 2 months ago. Looks like "Barton_C" />>/ needs to do some advertising. I'll see if I can contact him/her through />>/ sf. />/ />/ Got this reply from Barton, who's not subscribed to this list: / since when is being subscribed a prerequisite to commenting? >/ />/ """ />/ Using the current state of the art, I freely mix wxPython, MS Framework 2.0 />/ (others are hooking to .NET 4.0) and ctypes in full GUI apps and drivers. />/ The current challenge for me is getting the whole thing working (together) />/ on Ubuntu Maverick (10.10). />/ I have brought the PythonDotNet project up to python27 compatibility, but />/ have not published the binaries yet. />/ />/ """ / From agn82kv at gmail.com Mon Mar 21 10:32:02 2011 From: agn82kv at gmail.com (agnel varghese) Date: Mon, 21 Mar 2011 15:02:02 +0530 Subject: [python-win32] ImportError: No module named win32com.shell Message-ID: Hi , I am trying to control a GUI based application through one python script .Getting below error while running it.Any ideas how to resolve it ImportError: No module named win32com.shell Thanks, Agnel. $ pythonw ssc.py scanlist -v Traceback (most recent call last): File "ssc.py", line 52, in import SSCConfig File "c:\ssc_auto\lib\SSCConfig.py", line 103, in import PathFinder File "c:\ssc_auto\lib\PathFinder.py", line 11, in from win32com.shell import shellcon, shell ImportError: No module named win32com.shell ngwc-aaa at cavium-wireless /cygdrive/c/ssc_auto $ -------------- next part -------------- An HTML attachment was scrubbed... URL: From agn82kv at gmail.com Mon Mar 21 11:16:27 2011 From: agn82kv at gmail.com (agnel varghese) Date: Mon, 21 Mar 2011 15:46:27 +0530 Subject: [python-win32] ImportError: No module named win32com.shell In-Reply-To: References: Message-ID: Hi , I am trying to control a GUI based application through one python script .Getting below error while running it.Any ideas how to resolve it ImportError: No module named win32com.shell Thanks, Agnel. $ pythonw ssc.py scanlist -v Traceback (most recent call last): File "ssc.py", line 52, in import SSCConfig File "c:\ssc_auto\lib\SSCConfig.py" > > , line 103, in > import PathFinder > File "c:\ssc_auto\lib\PathFinder.py", line 11, in > from win32com.shell import shellcon, shell > ImportError: No module named win32com.shell > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nabil.servais at gmail.com Mon Mar 21 12:05:28 2011 From: nabil.servais at gmail.com (Nabil Servais) Date: Mon, 21 Mar 2011 12:05:28 +0100 Subject: [python-win32] DLL load failed Message-ID: Hello, I packaged an application for windows with py2exe, and when I launch the executable I have some this errors : Traceback (most recent call last): File "logon.py", line 5, in File "eole\option.pyo", line 4, in File "eole\reg.pyo", line 9, in File "eole\os_type.pyo", line 4, in File "win32api.pyo", line 12, in File "win32api.pyo", line 10, in __load ImportError: DLL load failed: The specified procedure could not be found. I use python 2.6 and pywin32-216 on Windows XP SP3, the application was coded first with python 2.5. From mail at timgolden.me.uk Mon Mar 21 15:07:12 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 21 Mar 2011 14:07:12 +0000 Subject: [python-win32] ImportError: No module named win32com.shell In-Reply-To: References: Message-ID: <4D875B90.30602@timgolden.me.uk> On 21/03/2011 10:16, agnel varghese wrote: > Hi , > > I am trying to control a GUI based application through one python script > .Getting below error while running it.Any ideas how to resolve it > ImportError: No module named win32com.shell You want to install the pywin32 extensions: http://sourceforge.net/projects/pywin32/files/ TJG From mdriscoll at co.marshall.ia.us Tue Mar 22 16:54:09 2011 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Tue, 22 Mar 2011 10:54:09 -0500 Subject: [python-win32] Catching Send To in Office Message-ID: <4D88C621.3070306@co.marshall.ia.us> Hi, Does anyone know of a way to catch the "Send To Mail Recipient" in Microsoft Word or Excel? I want to redirect that to our web mail somehow. I'm going to need to do that with the right-click context menu that appears when people right-click a file too. Any ideas would be great. Even if I have to use VBA (ugh) instead of Python. Thanks a lot! I'm on Windows XP with Office 2003 using Python 2.5 or 2.6 - Mike From timr at probo.com Tue Mar 22 17:44:54 2011 From: timr at probo.com (Tim Roberts) Date: Tue, 22 Mar 2011 09:44:54 -0700 Subject: [python-win32] Catching Send To in Office In-Reply-To: <4D88C621.3070306@co.marshall.ia.us> References: <4D88C621.3070306@co.marshall.ia.us> Message-ID: <4D88D206.3010407@probo.com> Mike Driscoll wrote: > Does anyone know of a way to catch the "Send To Mail Recipient" in > Microsoft Word or Excel? I want to redirect that to our web mail > somehow. Well, let's brainstorm for a moment. That link fires up the "default mail provider" for your computer, which in found in the registry. Theoretically, you ought to be able to rewrite that key to a browser command that brings up your webmail page, or to an application that does the same thing. Check HKCU\Software\Clients\Mail or HKLM\Software\Clients\Mail. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From tony at tony.gen.nz Wed Mar 23 03:02:02 2011 From: tony at tony.gen.nz (Tony Wallace) Date: Wed, 23 Mar 2011 15:02:02 +1300 Subject: [python-win32] Getting Started Message-ID: Hi everyone I am trying to develop a python application for the windows platform. As such occasionally I do need to interact with the operating system. I am using windows XP. I have in the past tried to use python tools with windows, but for some reason that escapes me, they all seem to require ancient versions of Microsofts C compiler, which I don't have. Am I doing something wrong? Is there somewhere I can get this? When I was programming in foxpro I could "DECLARE" an external reference to the operating system and then "CALL" the required functions. Does Python support simply calling Win32 functions? I have spent a bit of time trying to do something that should be relatively simple and I am getting frustrated at my lack of progress. Tony -------------- next part -------------- An HTML attachment was scrubbed... URL: From Andrew.MacIntyre at acma.gov.au Wed Mar 23 04:13:18 2011 From: Andrew.MacIntyre at acma.gov.au (Andrew MacIntyre) Date: Wed, 23 Mar 2011 14:13:18 +1100 Subject: [python-win32] Getting Started [SEC=PERSONAL] In-Reply-To: References: Message-ID: PythonWin (http://starship.python.net/~skippy/win32/) wraps a lot of the Windows API. ctypes (http://python.net/crew/theller/ctypes/), included with Python 2.5 and later (http://docs.python.org/library/ctypes.html), provides foreign function support. comtypes (http://starship.python.net/crew/theller/comtypes/) builds on ctypes to access COM. -------------------------> "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/ From: python-win32-bounces+andrew.macintyre=acma.gov.au at python.org [mailto:python-win32-bounces+andrew.macintyre=acma.gov.au at python.org] On Behalf Of Tony Wallace Sent: Wednesday, 23 March 2011 1:02 PM To: python-win32 at python.org Subject: [python-win32] Getting Started Hi everyone I am trying to develop a python application for the windows platform. As such occasionally I do need to interact with the operating system. I am using windows XP. I have in the past tried to use python tools with windows, but for some reason that escapes me, they all seem to require ancient versions of Microsofts C compiler, which I don't have. Am I doing something wrong? Is there somewhere I can get this? When I was programming in foxpro I could "DECLARE" an external reference to the operating system and then "CALL" the required functions. Does Python support simply calling Win32 functions? I have spent a bit of time trying to do something that should be relatively simple and I am getting frustrated at my lack of progress. Tony NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdriscoll at co.marshall.ia.us Wed Mar 23 14:59:52 2011 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Wed, 23 Mar 2011 08:59:52 -0500 Subject: [python-win32] Catching Send To in Office In-Reply-To: <4D88D206.3010407@probo.com> References: <4D88C621.3070306@co.marshall.ia.us> <4D88D206.3010407@probo.com> Message-ID: <4D89FCD8.5090802@co.marshall.ia.us> On 1:59 PM, Tim Roberts wrote: > Mike Driscoll wrote: >> Does anyone know of a way to catch the "Send To Mail Recipient" in >> Microsoft Word or Excel? I want to redirect that to our web mail >> somehow. > Well, let's brainstorm for a moment. That link fires up the "default > mail provider" for your computer, which in found in the registry. > Theoretically, you ought to be able to rewrite that key to a browser > command that brings up your webmail page, or to an application that does > the same thing. Check HKCU\Software\Clients\Mail or > HKLM\Software\Clients\Mail. > Well, on my PC "HKLM\Software\Clients\Mail" is set to MS Outlook, but "HKCU\Software\Clients\Mail" is set to Thunderbird. If I right-click a file on my file system and send to to "Mail Recipient", it goes to Thunderbird. The Registry just has the name of the program in the keys, but nothing else. If I try to use the Send To inside MS Word, I get an error dialog that says the following: "Word could not load the e-mail envelope. This could be caused by a network connection problem or a problem with your Office installation." - Mike From luca at vulcanoweb.it Wed Mar 23 15:51:03 2011 From: luca at vulcanoweb.it (Luca) Date: Wed, 23 Mar 2011 15:51:03 +0100 Subject: [python-win32] Set html in outlook mail Message-ID: <014601cbe969$bb9e9040$32dbb0c0$@vulcanoweb.it> Hi everybody, I?m trying to send an email via outlook and everything works fine with the following code: obj = win32com.client.Dispatch("Outlook.Application") for mail in Lmail: newMail = obj.CreateItem(0) newMail.To = mail newMail.Subject = "Title" newMail.Body = "CIAO" newMail.Send() Now I have to send an htm mail instead than normal plain text but I can?t find anything to do that. I tried something as newMail.Html = "CIAO" but Html is not a property of COM object. How can I do that? thanks LUCA ZACCHETTI Corso Dante, 61 23801 Calolziocorte LC 0341 631058 348 3042711 luca at vulcanoweb.it www.vulcanos.it Avvertenze ai sensi del D.Lgs. n.196/2003 Le informazioni contenute in questo messaggio di posta elettronica e/o files allegati, sono da considerarsi strettamente riservati ed il loro utilizzo ? consentito esclusivamente al destinatario del messaggio, per le finalit? indicate nello stesso. Costituisce violazione ai principi dettati dal D.Lgs. 196/2003: trattenere il messaggio stesso oltre il tempo necessario, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo od utilizzarlo per finalit? diverse. Ricordiamo che in ogni momento potrete richiederci la sospensione da parte nostra dell'impiego dei vostri dati, ad esclusione delle comunicazioni effettuate in esecuzione di obblighi di legge. Chi dovesse ricevere questo messaggio per errore ? tenuto ad informare il mittente ed a rimuoverlo definitivamente da ogni supporto elettronico o cartaceo. -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Wed Mar 23 16:53:11 2011 From: vernondcole at gmail.com (Vernon Cole) Date: Wed, 23 Mar 2011 09:53:11 -0600 Subject: [python-win32] Catching Send To in Office In-Reply-To: <4D89FCD8.5090802@co.marshall.ia.us> References: <4D88C621.3070306@co.marshall.ia.us> <4D88D206.3010407@probo.com> <4D89FCD8.5090802@co.marshall.ia.us> Message-ID: One of the executives where I used to work actually made use of the ?send to" feature in Word. The resulting bloat that appeared was appalling, and IIRC the recipient had to have Word installed to read the mail, when she finally imported it. Perhaps later versions of Word do a better job. Our answer was to teach the user to send e-mail using a mail agent, not his word processor. YMMV. -- Vernon On Wed, Mar 23, 2011 at 7:59 AM, Mike Driscoll wrote: > On 1:59 PM, Tim Roberts wrote: >> >> Mike Driscoll wrote: >>> >>> Does anyone know of a way to catch the "Send To Mail Recipient" in >>> Microsoft Word or Excel? I want to redirect that to our web mail >>> somehow. >> >> Well, let's brainstorm for a moment. ?That link fires up the "default >> mail provider" for your computer, which in found in the registry. >> Theoretically, you ought to be able to rewrite that key to a browser >> command that brings up your webmail page, or to an application that does >> the same thing. ?Check HKCU\Software\Clients\Mail or >> HKLM\Software\Clients\Mail. >> > > Well, on my PC ?"HKLM\Software\Clients\Mail" is set to MS Outlook, but > "HKCU\Software\Clients\Mail" is set to Thunderbird. If I right-click a file > on my file system and send to to "Mail Recipient", it goes to Thunderbird. > The Registry just has the name of the program in the keys, but nothing else. > > If I try to use the Send To inside MS Word, I get an error dialog that says > the following: > > "Word could not load the e-mail envelope. This could be caused by a network > connection problem or a problem with your Office installation." > > - Mike > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From mdriscoll at co.marshall.ia.us Wed Mar 23 16:55:55 2011 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Wed, 23 Mar 2011 10:55:55 -0500 Subject: [python-win32] Catching Send To in Office In-Reply-To: References: <4D88C621.3070306@co.marshall.ia.us> <4D88D206.3010407@probo.com> <4D89FCD8.5090802@co.marshall.ia.us> Message-ID: <4D8A180B.9000709@co.marshall.ia.us> Hi Vernon, On 3/23/2011 10:53 AM, Vernon Cole wrote: > One of the executives where I used to work actually made use of the > ?send to" feature in Word. The resulting bloat that appeared was > appalling, and IIRC the recipient had to have Word installed to read > the mail, when she finally imported it. Perhaps later versions of Word > do a better job. Our answer was to teach the user to send e-mail > using a mail agent, not his word processor. YMMV. > -- > Vernon Yeah, we've tried to do that for several years. They've been using Zimbra Web mail for at least 3 years, but we still have users that claim they can't live without this ability. So I'm supposed to look into it. - Mike From luca at vulcanoweb.it Wed Mar 23 15:42:03 2011 From: luca at vulcanoweb.it (Luca) Date: Wed, 23 Mar 2011 15:42:03 +0100 Subject: [python-win32] Set html in outlook mail Message-ID: <012f01cbe968$79826390$6c872ab0$@vulcanoweb.it> Hi everybody, I?m trying to send an email via outlook and everything works fine with the following code: obj = win32com.client.Dispatch("Outlook.Application") for mail in Lmail: newMail = obj.CreateItem(0) newMail.To = mail newMail.Subject = "Title" newMail.Body = "CIAO" newMail.Send() Now I have to send an htm mail instead than normal plain text but I can?t find anything to do that. I tried something as newMail.Html = "CIAO" but Html is not a property of COM object. How can I do that? thanks LUCA ZACCHETTI Corso Dante, 61 23801 Calolziocorte LC 0341 631058 348 3042711 luca at vulcanoweb.it www.vulcanos.it Avvertenze ai sensi del D.Lgs. n.196/2003 Le informazioni contenute in questo messaggio di posta elettronica e/o files allegati, sono da considerarsi strettamente riservati ed il loro utilizzo ? consentito esclusivamente al destinatario del messaggio, per le finalit? indicate nello stesso. Costituisce violazione ai principi dettati dal D.Lgs. 196/2003: trattenere il messaggio stesso oltre il tempo necessario, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo od utilizzarlo per finalit? diverse. Ricordiamo che in ogni momento potrete richiederci la sospensione da parte nostra dell'impiego dei vostri dati, ad esclusione delle comunicazioni effettuate in esecuzione di obblighi di legge. Chi dovesse ricevere questo messaggio per errore ? tenuto ad informare il mittente ed a rimuoverlo definitivamente da ogni supporto elettronico o cartaceo. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Mar 23 17:26:43 2011 From: timr at probo.com (Tim Roberts) Date: Wed, 23 Mar 2011 09:26:43 -0700 Subject: [python-win32] Set html in outlook mail In-Reply-To: <014601cbe969$bb9e9040$32dbb0c0$@vulcanoweb.it> References: <014601cbe969$bb9e9040$32dbb0c0$@vulcanoweb.it> Message-ID: <4D8A1F43.7080703@probo.com> Luca wrote: > > Hi everybody, I?m trying to send an email via outlook and everything > works fine with the following code: > > > > obj = win32com.client.Dispatch(/"Outlook.Application"/) > > formail inLmail: > > newMail = obj.CreateItem(0) > > newMail.To = mail > > newMail.Subject = /"_Title_"/ > > newMail.Body = /"_CIAO_"/ > > newMail.Send() > > > > Now I have to send an htm mail instead than normal plain text but I > can?t find anything to do that. > Add: import win32con newMail.BodyFormat = win32con.olFormatHTML newMail.HTMLBody = "CIAO!" All I did was go to the MSDN page on the CreateItem method of the Outlook.Application object. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Mar 23 17:28:19 2011 From: timr at probo.com (Tim Roberts) Date: Wed, 23 Mar 2011 09:28:19 -0700 Subject: [python-win32] Getting Started In-Reply-To: References: Message-ID: <4D8A1FA3.9010904@probo.com> Tony Wallace wrote: > > I am trying to develop a python application for the windows platform. > As such occasionally I do need to interact with the operating system. > I am using windows XP. > > I have in the past tried to use python tools with windows, but for > some reason that escapes me, they all seem to require ancient versions > of Microsofts C compiler, which I don't have. > > Am I doing something wrong? Is there somewhere I can get this? When > I was programming in foxpro I could "DECLARE" an external reference to > the operating system and then "CALL" the required functions. Does > Python support simply calling Win32 functions? > > I have spent a bit of time trying to do something that should be > relatively simple and I am getting frustrated at my lack of progress. I'm curious to know what you've tried. The fact that you posted to the [python-win32] list suggests that you already know about the PyWin32 package, which adds virtually complete access to the Win32 API. Are there APIs you need that weren't present? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From anthony.seward at ieee.org Wed Mar 23 17:38:09 2011 From: anthony.seward at ieee.org (Tony Seward) Date: Wed, 23 Mar 2011 10:38:09 -0600 Subject: [python-win32] can't import dde module after importing win32ui Message-ID: <1300898289.2808.8.camel@florete.mza.com> I'm having problems importing the dde module. I get the following results when I'm in the python interpreter Python 3.1.3 (r313:86834, Nov 27 2010, 17:20:37) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import win32ui >>> import dde Traceback (most recent call last): File "", line 1, in ImportError: This must be an MFC application - try loading win32ui first >>> I'm on Windows 7 64-bit, using 64-bit pywin32 release 216. I have tried Python 3.1, Python 2.7 and Python 2.6. What am I missing? Tony From timr at probo.com Wed Mar 23 23:08:29 2011 From: timr at probo.com (Tim Roberts) Date: Wed, 23 Mar 2011 15:08:29 -0700 Subject: [python-win32] Getting Started In-Reply-To: References: <4D8A1FA3.9010904@probo.com> Message-ID: <4D8A6F5D.9070306@probo.com> Tony Wallace wrote: > > This is what happens when I try and install pywin32: > ... > error: Python was built with Visual Studio 2003; > extensions must be built with a compiler than can generate compatible > binaries. > Visual Studio 2003 was not found on this system. If you have Cygwin > installed, > you can try compiling with MingW32, by passing "-c mingw32" to setup.py. > > Am I doing something wrong? Is there a specific reason you need to build it from source? I've been using Python on Windows for at least a dozen years, and I've never used anything other than the installer. It's much more convenient, less error-prone, plus I get the added benefit of an uninstaller. Any time I have the choice in a Python module, I fetch a pre-built installer. If you do need to build from source, then you either need to upgrade to a more recent Python (version 2.6 is now built with Visual Studio 2008) or go find VS2003. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Mar 23 23:48:49 2011 From: timr at probo.com (Tim Roberts) Date: Wed, 23 Mar 2011 15:48:49 -0700 Subject: [python-win32] Getting Started In-Reply-To: References: <4D8A1FA3.9010904@probo.com> <4D8A6F5D.9070306@probo.com> Message-ID: <4D8A78D1.6040904@probo.com> Tony Wallace wrote: > I have no reason to build from source. Where do I get this > precompiled installation? http://sourceforge.net/projects/pywin32/files/pywin32/Build216/ If I read your messages right, you are running Python 2.5, so you want pywin32-216.win32-py2.5.exe. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From cappy2112 at gmail.com Thu Mar 24 01:46:53 2011 From: cappy2112 at gmail.com (Tony Cappellini) Date: Wed, 23 Mar 2011 17:46:53 -0700 Subject: [python-win32] Catching Send To in Office Message-ID: Message: 1 Date: Wed, 23 Mar 2011 08:59:52 -0500 From: Mike Driscoll Cc: Python-Win32 List Subject: Re: [python-win32] Catching Send To in Office Message-ID: <4D89FCD8.5090802 at co.marshall.ia.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed On 1:59 PM, Tim Roberts wrote: > Mike Driscoll wrote: >> Does anyone know of a way to catch the "Send To Mail Recipient" in >> Microsoft Word or Excel? I want to redirect that to our web mail >> somehow. > Well, let's brainstorm for a moment. That link fires up the "default > mail provider" for your computer, which in found in the registry. > Theoretically, you ought to be able to rewrite that key to a browser > command that brings up your webmail page, or to an application that does > the same thing. Check HKCU\Software\Clients\Mail or > HKLM\Software\Clients\Mail. > Mike, If I've understood you correctly ... Why not just create a new sendto shortcut which points to your application, and copy it to the SendTo directory? I've created custom sendtos before, and it's quite convenient to make sendtos for other systems. You then just right click and send entire directories across the network like this. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mc at mclaveau.com Thu Mar 24 07:48:39 2011 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 24 Mar 2011 07:48:39 +0100 Subject: [python-win32] can't import dde module after importing win32ui In-Reply-To: <1300898289.2808.8.camel@florete.mza.com> References: <1300898289.2808.8.camel@florete.mza.com> Message-ID: Hi! I have also/another problem with win32ui in 216 version: on several COM's servers, if the line import win32ui is present, servers can not be contacted. If I comment the line, no more problem. Uncomment, problem is coming back. Waiting a solution, I come back to 214. @-salutations -- Michel Claveau From mdriscoll at co.marshall.ia.us Thu Mar 24 14:04:16 2011 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Thu, 24 Mar 2011 08:04:16 -0500 Subject: [python-win32] Catching Send To in Office In-Reply-To: References: Message-ID: <4D8B4150.9010407@co.marshall.ia.us> Hi Tony, On 1:59 PM, Tony Cappellini wrote: > > > On 1:59 PM, Tim Roberts wrote: > > Mike Driscoll wrote: > >> Does anyone know of a way to catch the "Send To Mail Recipient" in > >> Microsoft Word or Excel? I want to redirect that to our web mail > >> somehow. > > Well, let's brainstorm for a moment. That link fires up the "default > > mail provider" for your computer, which in found in the registry. > > Theoretically, you ought to be able to rewrite that key to a browser > > command that brings up your webmail page, or to an application that does > > the same thing. Check HKCU\Software\Clients\Mail or > > HKLM\Software\Clients\Mail. > > > > Mike, > > If I've understood you correctly ... > Why not just create a new sendto shortcut which points to your > application, > and copy it to the SendTo directory? > > I've created custom sendtos before, and it's quite convenient to make > sendtos for other systems. > You then just right click and send entire directories across the > network like this. > > > > I think I know how to do the Send To right-click stuff now (thanks to the guys on this list and on wxPython IRC), the problem is catching the Send To inside MS Word, Excel, etc. They are not using the same process. Maybe I need to create my own VBA junk in them that does it for me. I'm going to try using procmon to try to see what Word is doing. If anyone has any ideas, that would be great. Thanks! - Mike From cappy2112 at gmail.com Thu Mar 24 15:14:21 2011 From: cappy2112 at gmail.com (Tony Cappellini) Date: Thu, 24 Mar 2011 07:14:21 -0700 Subject: [python-win32] Catching Send To in Office In-Reply-To: <4D8B4150.9010407@co.marshall.ia.us> References: <4D8B4150.9010407@co.marshall.ia.us> Message-ID: When you launch Word and Excel, you can manipulate them via COM and try to intercept, which is a pain but at least you can control them from Python. You may be able to intercept SendTo this way. If you launch Word with your own template file (.dot) it may be possible to embed a Word macro in the template that helps you to intercept sendTo. On Thu, Mar 24, 2011 at 6:04 AM, Mike Driscoll wrote: > Hi Tony, > > > On 1:59 PM, Tony Cappellini wrote: > >> >> >> On 1:59 PM, Tim Roberts wrote: >> > Mike Driscoll wrote: >> >> Does anyone know of a way to catch the "Send To Mail Recipient" in >> >> Microsoft Word or Excel? I want to redirect that to our web mail >> >> somehow. >> > Well, let's brainstorm for a moment. That link fires up the "default >> > mail provider" for your computer, which in found in the registry. >> > Theoretically, you ought to be able to rewrite that key to a browser >> > command that brings up your webmail page, or to an application that does >> > the same thing. Check HKCU\Software\Clients\Mail or >> > HKLM\Software\Clients\Mail. >> > >> >> Mike, >> >> If I've understood you correctly ... >> Why not just create a new sendto shortcut which points to your >> application, >> and copy it to the SendTo directory? >> >> I've created custom sendtos before, and it's quite convenient to make >> sendtos for other systems. >> You then just right click and send entire directories across the network >> like this. >> >> >> >> >> > I think I know how to do the Send To right-click stuff now (thanks to the > guys on this list and on wxPython IRC), the problem is catching the Send To > inside MS Word, Excel, etc. They are not using the same process. Maybe I > need to create my own VBA junk in them that does it for me. I'm going to try > using procmon to try to see what Word is doing. If anyone has any ideas, > that would be great. Thanks! > > - Mike > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mc at mclaveau.com Thu Mar 24 15:20:11 2011 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 24 Mar 2011 15:20:11 +0100 Subject: [python-win32] Catching Send To in Office In-Reply-To: <4D8B4150.9010407@co.marshall.ia.us> References: <4D8B4150.9010407@co.marshall.ia.us> Message-ID: Hi! Sorry, I do not really undestand english. But if you want initiate "Send to mail" in MS-Word, you can use some thing like: w=win32com.client.Dispatch('Word.Application') ... w.ActiveDocument.SendMail() If you want tha sevral fields (Object, Destinataire...) are filled, you must go by another way (MAPI ou CDO). See also : http://support.microsoft.com/?scid=kb;fr;238114 @-salutations -- Michel Claveau And sorry for my bad english From chris at kateandchris.net Thu Mar 24 14:49:45 2011 From: chris at kateandchris.net (Chris Lambacher) Date: Thu, 24 Mar 2011 09:49:45 -0400 Subject: [python-win32] ActiveX Script & Classic ASP bug with args passed from VBScript Message-ID: Hi, I am trying to port a classic ASP application to Python with a mid-point step where we use the Python in ASP. As part of this, we are calling into Python from VBScript and finding that some parameters end up becoming Null after a function call. Some digging turned up an old bug against Python the language: http://bugs.python.org/issue1156179 which was closed as invalid since the issue is really a pywin32 bug, but as far as I can tell it was never forwarded on to the pywin32 bug tracker. I have created a bug on the pywin32 bug tracker ( https://sourceforge.net/tracker/?func=detail&aid=3238774&group_id=78018&atid=551954 ) and am willing to look into fixing it, but I need some guidance about how to go about solving this bug. Any assistance someone can provide would be very welcome. -Chris -- Christopher Lambacher chris at kateandchris.net From adrienlina at gmail.com Thu Mar 24 17:57:58 2011 From: adrienlina at gmail.com (Adrien LINA) Date: Thu, 24 Mar 2011 17:57:58 +0100 Subject: [python-win32] iTunes COM using Python win32 Message-ID: Hello, I came across the same problem as you. I googled my problem and i found the answer, when you create a playlist, it is 'only' an IITPlaylist. In opposition with the IITUserPlaylist, you are unable to use the method "Addtrack(the_track)". This is why you need to 'populate' it, using the instance "win32com.client.CastTo(the_playlist, 'IITUserPlaylist')" Here is my test code, in case I was unclear ^^ import win32com.client iTunes = win32com.client.gencache.EnsureDispatch("iTunes.Application") library = iTunes.LibraryPlaylist tracks = library.Tracks nouvelle_playlist = iTunes.CreatePlaylist('test') nouvelle_playlist = iTunes.CreatePlaylist('Deselected Albums') nouvelle_playlist = win32com.client.CastTo(nouvelle_playlist, 'IITUserPlaylist') third_track=tracks[100] nouvelle_playlist.AddTrack(third_track) nouvelle_playlist.PlayFirstTrack() Glad I helped. -------------- next part -------------- An HTML attachment was scrubbed... URL: From chris at kateandchris.net Thu Mar 24 20:21:06 2011 From: chris at kateandchris.net (Chris Lambacher) Date: Thu, 24 Mar 2011 15:21:06 -0400 Subject: [python-win32] ActiveX Script & Classic ASP bug with args passed from VBScript In-Reply-To: References: Message-ID: Further information: It looks like this is a general COM issue, not just an ActiveX Script issue. If I do the test with a registered Python COM object, I get the same results from VBScript. The bug has been updated with this new information. -Chris On Thu, Mar 24, 2011 at 9:49 AM, Chris Lambacher wrote: > Hi, > > I am trying to port a classic ASP application to Python with a > mid-point step where we use the Python in ASP. As part of this, we are > calling into Python from VBScript and finding that some parameters end > up becoming Null after a function call. > > Some digging turned up an old bug against Python the language: > http://bugs.python.org/issue1156179 which was closed as invalid since > the issue is really a pywin32 bug, but as far as I can tell it was > never forwarded on to the pywin32 bug tracker. I have created a bug on > the pywin32 bug tracker ( > https://sourceforge.net/tracker/?func=detail&aid=3238774&group_id=78018&atid=551954 > ) and am willing to look into fixing it, but I need some guidance > about how to go about solving this bug. > > Any assistance someone can provide would be very welcome. > > -Chris > > -- > Christopher Lambacher > chris at kateandchris.net > -- Christopher Lambacher chris at kateandchris.net From breamoreboy at yahoo.co.uk Fri Mar 25 15:28:54 2011 From: breamoreboy at yahoo.co.uk (Blockheads Oi Oi) Date: Fri, 25 Mar 2011 14:28:54 +0000 Subject: [python-win32] Clear the interactive screen Message-ID: Hi all, my take on a way to achieve this, and apologies if someone has posted a better method that I don't know about:- from SendKeys import SendKeys def cls(): SendKeys("^a{BS}~~", 0) # adjust to your needs I've tried to setup my own config file using ALT-R to call this and have failed dismally, managing to clear my code window(s) amongst other things. How do I correctly go about this? I've also changed interact.py in accordance with http://code.activestate.com/lists/python-list/168244/. Is there any reason why this couldn't be part of the standard file? Cheers. Mark Lawrence. From mdriscoll at co.marshall.ia.us Fri Mar 25 19:19:48 2011 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Fri, 25 Mar 2011 13:19:48 -0500 Subject: [python-win32] WMI and Terminal Services Message-ID: <4D8CDCC4.3030506@co.marshall.ia.us> Hi, I am looking for a way to query the client name parameter from Terminal Services. I have been testing several scripts I've found that use either win32com.client or win32ts, but they are giving me weird errors on Windows 7 64-bit. I get this traceback: Traceback (most recent call last): File "\\server\loginscript$\getTSInfo.py", line 10, in ? for objItem in colItems: File "\\server\loginscript$\Python24\lib\site-packages\win32com\client\util. py", line 84, in next return _get_good_object_(self._iter_.next(), resultCLSID = self.resultCLSID) pywintypes.com_error: (-2147217392, 'OLE error 0x80041010', None, None) When I run this: objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator") objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2") colItems = objSWbemServices.ExecQuery("Select * from Win32_TSClientSetting") for objItem in colItems: # this is line 10 # code snipped If I try running this code instead: server = win32ts.WTSOpenServer(".") print "server info >> ", print server print "-" * 80 for s in win32ts.WTSEnumerateSessions(server, 1): if s['State'] == win32ts.WTSActive: print s session = s I get this: Traceback (most recent call last): File "\\debianis\loginscript$\getTSInfo.py", line 34, in ? for s in win32ts.WTSEnumerateSessions(server, 1): pywintypes.error: (5, 'WTSEnumerateSessions', 'Access is denied.') I'm assuming that this must be an incorrect way of accessing Telnet information on 64-bit Windows since it works on 32-bit. I never did figure out how to return the client name though except via the "os" module, like this: os.getenv("CLIENTNAME") Is there a way to get it and other Terminal Services session information via these methods or WMI? Thanks! -- Mike Driscoll Applications Specialist From mail at timgolden.me.uk Fri Mar 25 22:46:07 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 25 Mar 2011 21:46:07 +0000 Subject: [python-win32] WMI and Terminal Services In-Reply-To: <4D8CDCC4.3030506@co.marshall.ia.us> References: <4D8CDCC4.3030506@co.marshall.ia.us> Message-ID: <4D8D0D1F.3030706@timgolden.me.uk> On 25/03/2011 6:19 PM, Mike Driscoll wrote: > Hi, > > I am looking for a way to query the client name parameter from Terminal > Services. I have been testing several scripts I've found that use either > win32com.client or win32ts, but they are giving me weird errors on > Windows 7 64-bit. > > I get this traceback: > > > > Traceback (most recent call last): > File "\\server\loginscript$\getTSInfo.py", line 10, in ? > for objItem in colItems: > File > "\\server\loginscript$\Python24\lib\site-packages\win32com\client\util. > py", line 84, in next > return _get_good_object_(self._iter_.next(), resultCLSID = > self.resultCLSID) > > pywintypes.com_error: (-2147217392, 'OLE error 0x80041010', None, None) > Try this instead (using my wmi module 'cos I'm lazy): import wmi # # Note the namespace # c = wmi.wmi (namespace="cimv2/TerminalServices") for i in c.Win32_TSClientSetting (): print i TJG From Marc-Andre.Belzile at autodesk.com Fri Mar 25 23:51:25 2011 From: Marc-Andre.Belzile at autodesk.com (Marc-Andre Belzile) Date: Fri, 25 Mar 2011 22:51:25 +0000 Subject: [python-win32] GetRefTypeOfImplType problem Message-ID: Hi, I'm trying to get the base interface typeinfo with pythoncom.GetRefTypeOfImplType but it's always returning the typeinfo of the IDispatch interface. Does the code below seem wrong ? Thank you for your help. -mab def log_base_interface( tlb ): n = tlb.GetTypeInfoCount() for i in range(n): iface_ti = tlb.GetTypeInfo( i ) iface_attr = iface_ti.GetTypeAttr() if iface_attr[5] == pythoncom.TKIND_DISPATCH: print '>>>>> Base interfaces for %s' % (iface_ti.GetDocumentation(-1)[0]) for i in range(iface_attr[8]): flags = iface_ti.GetImplTypeFlags(i) refType = iface_ti.GetRefTypeInfo(iface_ti.GetRefTypeOfImplType(i)) refAttr = refType.GetTypeAttr() print refType.GetDocumentation(-1)[0] output: >>>>> Base interfaces for SIObject IDispatch >>>>> Base interfaces for Application IDispatch >>>>> Base interfaces for SIObjectCollection IDispatch >>>>> Base interfaces for LightRig IDispatch etc... My interfaces are all defined like this: [ uuid(231B4BC1-4F8E-11d4-ACDC-0090275802BF), helpstring("LightRig interface"), object, // specifies a COM interface (default is RPC interface) local, // interface to define is not remote dual, // identifies an IDispatch interface that exposes directly through the VTBL pointer_default(unique) // this option is only instructing midl that we may have functions with embedded pointers-pointers. Otherwise it is ignored by idl. ] interface LightRig : Null { // properties [propget, id(1), helpstring("property Light")] HRESULT Light([out, retval] Light** ); }; -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Sun Mar 27 08:46:08 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sun, 27 Mar 2011 17:46:08 +1100 Subject: [python-win32] DLL load failed In-Reply-To: References: Message-ID: <4D8EDD30.1030907@gmail.com> If the py2exe app was created on a later OS (eg, vista, 7), look for any DLLs py2exe has packaged up with should not be there. HTH, Mark On 21/03/2011 10:05 PM, Nabil Servais wrote: > Hello, > > I packaged an application for windows with py2exe, and when I launch > the executable I have some this errors : > > Traceback (most recent call last): > File "logon.py", line 5, in > File "eole\option.pyo", line 4, in > File "eole\reg.pyo", line 9, in > File "eole\os_type.pyo", line 4, in > File "win32api.pyo", line 12, in > File "win32api.pyo", line 10, in __load > > ImportError: DLL load failed: The specified procedure could not be found. > > I use python 2.6 and pywin32-216 on Windows XP SP3, the application > was coded first with python 2.5. > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From skippy.hammond at gmail.com Sun Mar 27 08:53:04 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sun, 27 Mar 2011 17:53:04 +1100 Subject: [python-win32] Clear the interactive screen In-Reply-To: References: Message-ID: <4D8EDED0.5090502@gmail.com> Try something like: from pywin.framework import interact interact.edit.currentView.SetSel(0, -1) interact.edit.currentView.Clear() HTH, Mark On 26/03/2011 1:28 AM, Blockheads Oi Oi wrote: > Hi all, > > my take on a way to achieve this, and apologies if someone has posted a > better method that I don't know about:- > > from SendKeys import SendKeys > def cls(): > SendKeys("^a{BS}~~", 0) # adjust to your needs > > I've tried to setup my own config file using ALT-R to call this and have > failed dismally, managing to clear my code window(s) amongst other > things. How do I correctly go about this? > > I've also changed interact.py in accordance with > http://code.activestate.com/lists/python-list/168244/. Is there any > reason why this couldn't be part of the standard file? > > Cheers. > > Mark Lawrence. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From amauryfa at gmail.com Mon Mar 28 11:49:13 2011 From: amauryfa at gmail.com (Amaury Forgeot d'Arc) Date: Mon, 28 Mar 2011 11:49:13 +0200 Subject: [python-win32] pywin32-specific version of SWIG Message-ID: Hi, pywin32 comes with a modified version of SWIG, but only in a binary form. To adapt pywin32 for PyPy, I need to so some modifications in swig.exe. (around the MAKE_PYCOM_CTOR macro) How is swig.exe built? Is the source code available somewhere? -- Amaury Forgeot d'Arc From mdriscoll at co.marshall.ia.us Mon Mar 28 16:16:54 2011 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Mon, 28 Mar 2011 09:16:54 -0500 Subject: [python-win32] WMI and Terminal Services In-Reply-To: <4D8D0D1F.3030706@timgolden.me.uk> References: <4D8CDCC4.3030506@co.marshall.ia.us> <4D8D0D1F.3030706@timgolden.me.uk> Message-ID: <4D909856.7070109@co.marshall.ia.us> On 1:59 PM, Tim Golden wrote: > On 25/03/2011 6:19 PM, Mike Driscoll wrote: >> Hi, >> >> I am looking for a way to query the client name parameter from Terminal >> Services. I have been testing several scripts I've found that use either >> win32com.client or win32ts, but they are giving me weird errors on >> Windows 7 64-bit. >> >> I get this traceback: >> >> >> >> Traceback (most recent call last): >> File "\\server\loginscript$\getTSInfo.py", line 10, in ? >> for objItem in colItems: >> File >> "\\server\loginscript$\Python24\lib\site-packages\win32com\client\util. >> py", line 84, in next >> return _get_good_object_(self._iter_.next(), resultCLSID = >> self.resultCLSID) >> >> pywintypes.com_error: (-2147217392, 'OLE error 0x80041010', None, None) >> > > Try this instead (using my wmi module 'cos I'm lazy): > > > import wmi > > # > # Note the namespace > # > c = wmi.wmi (namespace="cimv2/TerminalServices") > for i in c.Win32_TSClientSetting (): > print i > > > > TJG > That codes run just fine. I don't know if that's the info my colleague needs or not, but thanks a lot! - Mike From mail at timgolden.me.uk Mon Mar 28 16:19:16 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 28 Mar 2011 15:19:16 +0100 Subject: [python-win32] WMI and Terminal Services In-Reply-To: <4D909856.7070109@co.marshall.ia.us> References: <4D8CDCC4.3030506@co.marshall.ia.us> <4D8D0D1F.3030706@timgolden.me.uk> <4D909856.7070109@co.marshall.ia.us> Message-ID: <4D9098E4.2090309@timgolden.me.uk> On 28/03/2011 15:16, Mike Driscoll wrote: > On 1:59 PM, Tim Golden wrote: >> On 25/03/2011 6:19 PM, Mike Driscoll wrote: >>> Hi, >>> >>> I am looking for a way to query the client name parameter from Terminal >>> Services. I have been testing several scripts I've found that use either >>> win32com.client or win32ts, but they are giving me weird errors on >>> Windows 7 64-bit. >>> >>> I get this traceback: >>> >>> >>> >>> Traceback (most recent call last): >>> File "\\server\loginscript$\getTSInfo.py", line 10, in ? >>> for objItem in colItems: >>> File >>> "\\server\loginscript$\Python24\lib\site-packages\win32com\client\util. >>> py", line 84, in next >>> return _get_good_object_(self._iter_.next(), resultCLSID = >>> self.resultCLSID) >>> >>> pywintypes.com_error: (-2147217392, 'OLE error 0x80041010', None, None) >>> >> >> Try this instead (using my wmi module 'cos I'm lazy): >> >> >> import wmi >> >> # >> # Note the namespace >> # >> c = wmi.wmi (namespace="cimv2/TerminalServices") >> for i in c.Win32_TSClientSetting (): >> print i >> >> >> >> TJG >> > > That codes run just fine. I don't know if that's the info my colleague > needs or not, but thanks a lot! Well there, I'm afraid, I'm unable to help :) TJG From greg.ewing at canterbury.ac.nz Mon Mar 28 23:03:25 2011 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Tue, 29 Mar 2011 10:03:25 +1300 Subject: [python-win32] PyGUI Window Always Starts Behind Others Message-ID: <4D90F79D.6090405@canterbury.ac.nz> A PyGUI user has reported a problem on Windows XP whereby an application's window is not on top when it starts up. Apparently launching it with with pythonw doesn't entirely fix the problem, but making it a py2exe application does. Anyone here have any idea what might be causing this? Is there something I should do when creating a window to make sure it appears on top? -------- Original Message -------- Subject: Re: [Pygui] Window Always Starts Behind Others Date: Mon, 28 Mar 2011 10:17:10 -0400 From: Mark Melvin To: Greg Ewing CC: pygui at python.org References: <4D8CDE4A.9080001 at inteli-com.com> <4D8D331D.4080103 at canterbury.ac.nz> On Fri, Mar 25, 2011 at 8:28 PM, Greg Ewing > wrote: Mark Melvin wrote: I'm on Windows XP - 32-bit using the latest PyGUI. How are you launching the app? If you're not doing so already, try running it with pythonw.exe rather than python.exe, or give it a .pyw extension and double click. -- Greg Hi Greg, I was indeed launching as a console app, and I even had "console" in my py2exe setup. I've changed to using the 'windows' version of the launcher and it seems to have fixed the issue of the GUI launching behind almost every other window and being hidden from view entirely. However, it still pops up behind the console window I launch it from, and the py2exe'd executable version of the application pops up behind the Windows Explorer window from which I launched it. I checked a py2exe'd app I wrote that uses wxPython, and it always pops up on top when launched. Could there be a small issue on Windows with this in PyGUI? Regards, Mark. From anthony.atkins at gmail.com Tue Mar 29 14:40:43 2011 From: anthony.atkins at gmail.com (Anthony Atkins) Date: Tue, 29 Mar 2011 08:40:43 -0400 Subject: [python-win32] Connection to Oracle DB via TNSNames file Message-ID: I'm using Python 2.6 and would like to be able to connect to an oracle database that utilizes TNSNames file. I can't seem to get the connection script correct. Would someone please help me. I'd really like to not have to load additional libraries since I'm developing a tool within another piece of software and I doubt if other individuals will be able to download additional libraries. thanks, -------------- next part -------------- An HTML attachment was scrubbed... URL: From amauryfa at gmail.com Tue Mar 29 14:54:17 2011 From: amauryfa at gmail.com (Amaury Forgeot d'Arc) Date: Tue, 29 Mar 2011 14:54:17 +0200 Subject: [python-win32] Connection to Oracle DB via TNSNames file In-Reply-To: References: Message-ID: Hi, 2011/3/29 Anthony Atkins : > I'm using Python 2.6 and would like to be able to connect to an oracle > database that utilizes TNSNames file. I can't seem to get the connection > script correct. ?Would someone please help me. ?I'd really like to not have > to load additional libraries since I'm developing a tool within another > piece of software and I doubt if other individuals will be able to download > additional?libraries. What did you try so far? Did you use odbc to connect to Oracle? -- Amaury Forgeot d'Arc From wolfgang at rohdewald.de Wed Mar 30 01:51:08 2011 From: wolfgang at rohdewald.de (Wolfgang Rohdewald) Date: Wed, 30 Mar 2011 01:51:08 +0200 Subject: [python-win32] pyconfig.h: conflicting definitions for ssize_t Message-ID: <201103300151.08942.wolfgang@rohdewald.de> compiling pykde on windows with msvc2010 on a 32bit Windows 7: sipdnssdpart0.cpp R:\include\msvc\sys/types.h(52) : error C2371: 'ssize_t' : redefinition; different basic types c:\python27\include\pyconfig.h(201) : see declaration of 'ssize_t' I can fix this by defining ssize_t as long in pyconfig.h or as int in kdewin/include/msvc/sys/types.h the original files from windows define SSIZE_T as long so to me this seems like a bug in pyconfig.h, it should say typedef _W64 long ssize_t Python27\include\pyconfig.h says (same in Python32): #ifdef MS_WIN64 typedef __int64 ssize_t; #else typedef _W64 int ssize_t; #endif while kdewin/include/msvc/sys/types.h says: typedef SSIZE_T ssize_t; SSIZE_T is defined in Microsoft SDKs/Windows/v7.0A/Include/BaseTsd.h: typedef LONG_PTR SSIZE_T, *PSSIZE_T; and LONG_PTR from same directory, intsafe.h: #if (__midl > 501) typedef [public] __int3264 LONG_PTR; #else #ifdef _WIN64 typedef __int64 LONG_PTR; #else typedef _W64 long LONG_PTR; #endif // WIN64 #endif // (__midl > 501) for __midl see http://msdn.microsoft.com/en-us/library/aa367301(v=vs.85).aspx -- Wolfgang From timr at probo.com Wed Mar 30 02:01:25 2011 From: timr at probo.com (Tim Roberts) Date: Tue, 29 Mar 2011 17:01:25 -0700 Subject: [python-win32] pyconfig.h: conflicting definitions for ssize_t In-Reply-To: <201103300151.08942.wolfgang@rohdewald.de> References: <201103300151.08942.wolfgang@rohdewald.de> Message-ID: <4D9272D5.7020805@probo.com> Wolfgang Rohdewald wrote: > compiling pykde on windows with msvc2010 on a 32bit Windows 7: > > sipdnssdpart0.cpp > R:\include\msvc\sys/types.h(52) : error C2371: 'ssize_t' : redefinition; different basic types > c:\python27\include\pyconfig.h(201) : see declaration of 'ssize_t' > > I can fix this by defining ssize_t as long in pyconfig.h or > as int in kdewin/include/msvc/sys/types.h > > the original files from windows define SSIZE_T as long so to > me this seems like a bug in pyconfig.h, it should say > typedef _W64 long ssize_t > > > Python27\include\pyconfig.h says (same in Python32): > > #ifdef MS_WIN64 > typedef __int64 ssize_t; > #else > typedef _W64 int ssize_t; > #endif > > while kdewin/include/msvc/sys/types.h says: > > typedef SSIZE_T ssize_t; I agree with your conclusion. However, this isn't a Python-Win32 issue. You need to file a bug report against Python itself. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From wolfgang at rohdewald.de Wed Mar 30 02:14:11 2011 From: wolfgang at rohdewald.de (Wolfgang Rohdewald) Date: Wed, 30 Mar 2011 02:14:11 +0200 Subject: [python-win32] pyconfig.h: conflicting definitions for ssize_t In-Reply-To: <4D9272D5.7020805@probo.com> References: <201103300151.08942.wolfgang@rohdewald.de> <4D9272D5.7020805@probo.com> Message-ID: <201103300214.12083.wolfgang@rohdewald.de> On Mittwoch 30 M?rz 2011, Tim Roberts wrote: > Wolfgang Rohdewald wrote: > > compiling pykde on windows with msvc2010 on a 32bit Windows > > 7: > > > > sipdnssdpart0.cpp > > R:\include\msvc\sys/types.h(52) : error C2371: 'ssize_t' : > > redefinition; different basic types > > > > c:\python27\include\pyconfig.h(201) : see > > declaration of 'ssize_t' > > > > I can fix this by defining ssize_t as long in pyconfig.h or > > as int in kdewin/include/msvc/sys/types.h > > > > the original files from windows define SSIZE_T as long so to > > me this seems like a bug in pyconfig.h, it should say > > typedef _W64 long ssize_t > > > > > > Python27\include\pyconfig.h says (same in Python32): > > > > #ifdef MS_WIN64 > > typedef __int64 ssize_t; > > #else > > typedef _W64 int ssize_t; > > #endif > > > > while kdewin/include/msvc/sys/types.h says: > > > > typedef SSIZE_T ssize_t; > > I agree with your conclusion. However, this isn't a > Python-Win32 issue. You need to file a bug report against > Python itself. done: http://bugs.python.org/issue11717 -- Wolfgang From mhammond at skippinet.com.au Wed Mar 30 14:03:40 2011 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 30 Mar 2011 23:03:40 +1100 Subject: [python-win32] pyconfig.h: conflicting definitions for ssize_t In-Reply-To: <4D9272D5.7020805@probo.com> References: <201103300151.08942.wolfgang@rohdewald.de> <4D9272D5.7020805@probo.com> Message-ID: <4D931C1C.5090204@skippinet.com.au> On 30/03/2011 11:01 AM, Tim Roberts wrote: > Wolfgang Rohdewald wrote: > I agree with your conclusion. However, this isn't a Python-Win32 > issue. You need to file a bug report against Python itself. it would be good to know exactly what vs2008 says about this - if it uses 'int' we will need to take more care - but yeah - please report this at bugs.python.org, add mhammond to the "nosy" list and I'll help ensure it gets fixed... Cheers, Mark From wolfgang at rohdewald.de Wed Mar 30 14:53:05 2011 From: wolfgang at rohdewald.de (Wolfgang Rohdewald) Date: Wed, 30 Mar 2011 14:53:05 +0200 Subject: [python-win32] pyconfig.h: conflicting definitions for ssize_t In-Reply-To: <4D931C1C.5090204@skippinet.com.au> References: <201103300151.08942.wolfgang@rohdewald.de> <4D9272D5.7020805@probo.com> <4D931C1C.5090204@skippinet.com.au> Message-ID: <201103301453.05368.wolfgang@rohdewald.de> On Mittwoch 30 M?rz 2011, Mark Hammond wrote: > On 30/03/2011 11:01 AM, Tim Roberts wrote: > > Wolfgang Rohdewald wrote: > > I agree with your conclusion. However, this isn't a > > Python-Win32 issue. You need to file a bug report against > > Python itself. > > it would be good to know exactly what vs2008 says about this - I am afraid I don't have vs2008 and I don't really want to put it on a machine where vs2010 is already running. > if it uses 'int' we will need to take more care - but yeah - > please report this at bugs.python.org http://bugs.python.org/issue11717 there are already a few comments > add mhammond to the "nosy" list done > and I'll help ensure it gets fixed... that would be great! -- Wolfgang From breamoreboy at yahoo.co.uk Wed Mar 30 17:41:21 2011 From: breamoreboy at yahoo.co.uk (Blockheads Oi Oi) Date: Wed, 30 Mar 2011 16:41:21 +0100 Subject: [python-win32] Clear the interactive screen In-Reply-To: <4D8EDED0.5090502@gmail.com> References: <4D8EDED0.5090502@gmail.com> Message-ID: On 27/03/2011 07:53, Mark Hammond wrote: > Try something like: > > from pywin.framework import interact > interact.edit.currentView.SetSel(0, -1) > interact.edit.currentView.Clear() Try the above three lines from the interactive prompt and nothing that I can see happens. Try the last two lines on a single line with the ; separator and the screen is cleared, I'm sorry but I don't understand this. > > HTH, > > Mark > > On 26/03/2011 1:28 AM, Blockheads Oi Oi wrote: >> Hi all, >> >> my take on a way to achieve this, and apologies if someone has posted a >> better method that I don't know about:- >> >> from SendKeys import SendKeys >> def cls(): >> SendKeys("^a{BS}~~", 0) # adjust to your needs >> >> I've tried to setup my own config file using ALT-R to call this and have >> failed dismally, managing to clear my code window(s) amongst other >> things. How do I correctly go about this? I've tried wrapping the interact lines from above into a cls function in my own bare bones config file based on the data in the pywin32 help Keyboard Bindings section. Screws everything. What steps are needed to get what I and others have asked for in the past, i.e. clear the interactive screen, run the program/module under test, resort to normal? I observe that the Ctrl-R and Shift-Ctrl-R key combinations are not available in the default config file (presumably to keep bozos like myself away from them? :). So do we have to resort to (shock, horror, probe) doing things manually? >> >> I've also changed interact.py in accordance with >> http://code.activestate.com/lists/python-list/168244/. Is there any >> reason why this couldn't be part of the standard file? >> >> Cheers. >> >> Mark Lawrence. >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 From timr at probo.com Wed Mar 30 18:43:40 2011 From: timr at probo.com (Tim Roberts) Date: Wed, 30 Mar 2011 09:43:40 -0700 Subject: [python-win32] pyconfig.h: conflicting definitions for ssize_t In-Reply-To: <4D931C1C.5090204@skippinet.com.au> References: <201103300151.08942.wolfgang@rohdewald.de> <4D9272D5.7020805@probo.com> <4D931C1C.5090204@skippinet.com.au> Message-ID: <4D935DBC.1010502@probo.com> Mark Hammond wrote: > On 30/03/2011 11:01 AM, Tim Roberts wrote: >> Wolfgang Rohdewald wrote: >> I agree with your conclusion. However, this isn't a Python-Win32 >> issue. You need to file a bug report against Python itself. > it would be good to know exactly what vs2008 says about this - if it > uses 'int' we will need to take more care - but yeah - please report > this at bugs.python.org, add mhammond to the "nosy" list and I'll help > ensure it gets fixed... Actually, on closer examination, it may be a bit difficult to sell this. The Microsoft compilers do not define this symbol at all. The SDK defines SSIZE_T (as a long). Nothing defines ssize_t. So, the conflict only occurs because the KDE include files do this: typedef SSIZE_T ssize_t; We (and KDE) are more or less assuming that Microsoft intended their SSIZE_T to be the same as the relatively common ssize_t. Python defined their symbol independently of the SDK, which is also reasonable. In the end, I'm not sure you can point to either KDE or Python as being "at fault" here. The warning can be fixed by changing one or the other, but I don't know how one would establish which one was "right". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jmelloy at gmail.com Wed Mar 30 19:49:24 2011 From: jmelloy at gmail.com (Jeffrey Melloy) Date: Wed, 30 Mar 2011 10:49:24 -0700 Subject: [python-win32] win32pdhutil failing on counters with a "/" Message-ID: My script to parse perfmon data is working correctly, however, when I have a counter name with "/" in it, it seems to throw an error in GetFormattedData. Has anyone seen this before? import win32pdhutil machine = "\\\\seaweb001p" object = "Memory" counters, instances = win32pdh.EnumObjectItems(None, machine, object, 500) if instances == []: instances = [None] for cnt in counters: for inst in instances: try: x = win32pdhutil.GetPerformanceAttributes(object = object, counter = cnt, instance = inst, machine=machine, format=win32pdh.PDH_FMT_DOUBLE) print cnt, inst, x except Exception, e: print cnt, inst, e Page Faults/sec None (-1073738810, 'GetFormattedCounterValue', 'The data is not valid.') Available Bytes None 1669623808.0 Committed Bytes None 2364002304.0 Commit Limit None 8408195072.0 Write Copies/sec None (-1073738810, 'GetFormattedCounterValue', 'The data is not valid.') Transition Faults/sec None (-1073738810, 'GetFormattedCounterValue', 'The data is not valid.') Cache Faults/sec None (-1073738810, 'GetFormattedCounterValue', 'The data is not valid.') Demand Zero Faults/sec None (-1073738810, 'GetFormattedCounterValue', 'The data is not valid.') Pages/sec None (-1073738810, 'GetFormattedCounterValue', 'The data is not valid.') Pages Input/sec None (-1073738810, 'GetFormattedCounterValue', 'The data is not valid.') Page Reads/sec None (-1073738810, 'GetFormattedCounterValue', 'The data is not valid.') Pages Output/sec None (-1073738810, 'GetFormattedCounterValue', 'The data is not valid.') Pool Paged Bytes None 81498112.0 Pool Nonpaged Bytes None 55918592.0 Page Writes/sec None (-1073738810, 'GetFormattedCounterValue', 'The data is not valid.') Pool Paged Allocs None 184892.0 Pool Nonpaged Allocs None 197360.0 Free System Page Table Entries None 75581.0 Cache Bytes None 134574080.0 Cache Bytes Peak None 201498624.0 Pool Paged Resident Bytes None 80728064.0 System Code Total Bytes None 1404928.0 System Code Resident Bytes None 229376.0 System Driver Total Bytes None 2408448.0 System Driver Resident Bytes None 2473984.0 System Cache Resident Bytes None 51142656.0 % Committed Bytes In Use None 28.1006458552 Available KBytes None 1632276.0 Available MBytes None 1594.0 Transition Pages RePurposed/sec None (-1073738810, 'GetFormattedCounterValue', 'The data is not valid.') From timr at probo.com Wed Mar 30 20:02:45 2011 From: timr at probo.com (Tim Roberts) Date: Wed, 30 Mar 2011 11:02:45 -0700 Subject: [python-win32] win32pdhutil failing on counters with a "/" In-Reply-To: References: Message-ID: <4D937045.9030104@probo.com> Jeffrey Melloy wrote: > My script to parse perfmon data is working correctly, however, when I > have a counter name with "/" in it, it seems to throw an error in > GetFormattedData. > > Has anyone seen this before? Do you get this every time, or only the first time you run it? There was one message that theorized that the "per second" values don't work until it has two samples to compute a delta, although that person's own reply seemed to refute that theory. What versions? Your script worked perfectly for me (after I imported win32pdh). XP SP3, Python 2.6, Python-Win32 214. Is this a local machine, or are you reading remotely? C:\tmp>x.py Page Faults/sec None 637.858235343 Available Bytes None 295763968.0 Committed Bytes None 798822400.0 Commit Limit None 2579103744.0 Write Copies/sec None 4.93029575603 Transition Faults/sec None 222.822945424 Cache Faults/sec None 163.402800234 Demand Zero Faults/sec None 325.280604849 Pages/sec None 29.7574040842 Pages Input/sec None 28.8193516955 Page Reads/sec None 4.76493920886 Pages Output/sec None 0.9380523089 Pool Paged Bytes None 91000832.0 Pool Nonpaged Bytes None 37187584.0 Page Writes/sec None 0.058643184963 Pool Paged Allocs None 94845.0 Pool Nonpaged Allocs None 71529.0 Free System Page Table Entries None 210438.0 Cache Bytes None 177729536.0 Cache Bytes Peak None 255340544.0 Pool Paged Resident Bytes None 73687040.0 System Code Total Bytes None 933888.0 System Code Resident Bytes None 307200.0 System Driver Total Bytes None 9097216.0 System Driver Resident Bytes None 1380352.0 System Cache Resident Bytes None 102354944.0 % Committed Bytes In Use None 30.9728680693 Available KBytes None 288832.0 Available MBytes None 282.0 C:\tmp> -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jmelloy at gmail.com Wed Mar 30 20:07:52 2011 From: jmelloy at gmail.com (Jeffrey Melloy) Date: Wed, 30 Mar 2011 11:07:52 -0700 Subject: [python-win32] win32pdhutil failing on counters with a "/" In-Reply-To: <4D937045.9030104@probo.com> References: <4D937045.9030104@probo.com> Message-ID: It gives that error every time. My script runs through these in a loop. I'm using Windows 7, Python 2.6, and I updated to build 216 of py-win32 this morning. (Though is there a good way to get what version you're using from Python? __version__ isn't there.) I get that if I'm working remotely or locally. On Wed, Mar 30, 2011 at 11:02 AM, Tim Roberts wrote: > Jeffrey Melloy wrote: >> My script to parse perfmon data is working correctly, however, when I >> have a counter name with "/" in it, it seems to throw an error in >> GetFormattedData. >> >> Has anyone seen this before? > > Do you get this every time, or only the first time you run it? ?There > was one message that theorized that the "per second" values don't work > until it has two samples to compute a delta, although that person's own > reply seemed to refute that theory. > > What versions? ?Your script worked perfectly for me (after I imported > win32pdh). ?XP SP3, Python 2.6, Python-Win32 214. ?Is this a local > machine, or are you reading remotely? > > C:\tmp>x.py > Page Faults/sec None 637.858235343 > Available Bytes None 295763968.0 > Committed Bytes None 798822400.0 > Commit Limit None 2579103744.0 > Write Copies/sec None 4.93029575603 > Transition Faults/sec None 222.822945424 > Cache Faults/sec None 163.402800234 > Demand Zero Faults/sec None 325.280604849 > Pages/sec None 29.7574040842 > Pages Input/sec None 28.8193516955 > Page Reads/sec None 4.76493920886 > Pages Output/sec None 0.9380523089 > Pool Paged Bytes None 91000832.0 > Pool Nonpaged Bytes None 37187584.0 > Page Writes/sec None 0.058643184963 > Pool Paged Allocs None 94845.0 > Pool Nonpaged Allocs None 71529.0 > Free System Page Table Entries None 210438.0 > Cache Bytes None 177729536.0 > Cache Bytes Peak None 255340544.0 > Pool Paged Resident Bytes None 73687040.0 > System Code Total Bytes None 933888.0 > System Code Resident Bytes None 307200.0 > System Driver Total Bytes None 9097216.0 > System Driver Resident Bytes None 1380352.0 > System Cache Resident Bytes None 102354944.0 > % Committed Bytes In Use None 30.9728680693 > Available KBytes None 288832.0 > Available MBytes None 282.0 > > C:\tmp> > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From jmelloy at gmail.com Wed Mar 30 20:29:52 2011 From: jmelloy at gmail.com (Jeffrey Melloy) Date: Wed, 30 Mar 2011 11:29:52 -0700 Subject: [python-win32] win32pdhutil failing on counters with a "/" In-Reply-To: References: <4D937045.9030104@probo.com> Message-ID: Duplicating the function and calling CollectQueryData seems to fix it. XP must interpolate the time-series data differently than Windows 7. On Wed, Mar 30, 2011 at 11:07 AM, Jeffrey Melloy wrote: > It gives that error every time. ?My script runs through these in a loop. > > I'm using Windows 7, Python 2.6, and I updated to build 216 of > py-win32 this morning. ?(Though is there a good way to get what > version you're using from Python? __version__ isn't there.) > > I get that if I'm working remotely or locally. > > On Wed, Mar 30, 2011 at 11:02 AM, Tim Roberts wrote: >> Jeffrey Melloy wrote: >>> My script to parse perfmon data is working correctly, however, when I >>> have a counter name with "/" in it, it seems to throw an error in >>> GetFormattedData. >>> >>> Has anyone seen this before? >> >> Do you get this every time, or only the first time you run it? ?There >> was one message that theorized that the "per second" values don't work >> until it has two samples to compute a delta, although that person's own >> reply seemed to refute that theory. >> >> What versions? ?Your script worked perfectly for me (after I imported >> win32pdh). ?XP SP3, Python 2.6, Python-Win32 214. ?Is this a local >> machine, or are you reading remotely? >> >> C:\tmp>x.py >> Page Faults/sec None 637.858235343 >> Available Bytes None 295763968.0 >> Committed Bytes None 798822400.0 >> Commit Limit None 2579103744.0 >> Write Copies/sec None 4.93029575603 >> Transition Faults/sec None 222.822945424 >> Cache Faults/sec None 163.402800234 >> Demand Zero Faults/sec None 325.280604849 >> Pages/sec None 29.7574040842 >> Pages Input/sec None 28.8193516955 >> Page Reads/sec None 4.76493920886 >> Pages Output/sec None 0.9380523089 >> Pool Paged Bytes None 91000832.0 >> Pool Nonpaged Bytes None 37187584.0 >> Page Writes/sec None 0.058643184963 >> Pool Paged Allocs None 94845.0 >> Pool Nonpaged Allocs None 71529.0 >> Free System Page Table Entries None 210438.0 >> Cache Bytes None 177729536.0 >> Cache Bytes Peak None 255340544.0 >> Pool Paged Resident Bytes None 73687040.0 >> System Code Total Bytes None 933888.0 >> System Code Resident Bytes None 307200.0 >> System Driver Total Bytes None 9097216.0 >> System Driver Resident Bytes None 1380352.0 >> System Cache Resident Bytes None 102354944.0 >> % Committed Bytes In Use None 30.9728680693 >> Available KBytes None 288832.0 >> Available MBytes None 282.0 >> >> C:\tmp> >> >> -- >> Tim Roberts, timr at probo.com >> Providenza & Boekelheide, Inc. >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> > From reckoner at gmail.com Thu Mar 31 01:05:54 2011 From: reckoner at gmail.com (reckoner) Date: Wed, 30 Mar 2011 16:05:54 -0700 Subject: [python-win32] Using Flexible Win32 message pump to monitor window open/close for all application? In-Reply-To: References: Message-ID: <4D93B752.3090200@gmail.com> Hi, I have been looking at the following recipe: Recipe 82236: Flexible Win32 message pump using MsgWaitForMultipleObjects (Python) http://code.activestate.com/recipes/82236-flexible-win32-message-pump-using-msgwaitformultip Which is listed in the Python cookbook, second edition. Is it possible to use this to monitor the open/close of different windows? Basically, I would like to trigger an action for a specific window or handle when that window class or handle opens/closes. Can this recipe help with that? Any ideas on getting started with this? Thanks! From timr at probo.com Thu Mar 31 01:17:01 2011 From: timr at probo.com (Tim Roberts) Date: Wed, 30 Mar 2011 16:17:01 -0700 Subject: [python-win32] Using Flexible Win32 message pump to monitor window open/close for all application? In-Reply-To: <4D93B752.3090200@gmail.com> References: <4D93B752.3090200@gmail.com> Message-ID: <4D93B9ED.9010402@probo.com> reckoner wrote: > Which is listed in the Python cookbook, second edition. Is it possible > to use this to monitor the open/close of different windows? Basically, I > would like to trigger an action for a specific window or handle when > that window class or handle opens/closes. Can this recipe help with > that? Any ideas on getting started with this? Do you mean a window in another application? That requires installing a Windows hook, and a Windows hook callback must reside in a DLL (so that DLL can be injected into the other process), which cannot be done in Python. There is the pyHook package, but I don't know if it is still being developed. http://www.cs.unc.edu/Research/assist/developer.shtml -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jiawei.h.li at gmail.com Thu Mar 31 07:04:07 2011 From: jiawei.h.li at gmail.com (Jiawei Li) Date: Thu, 31 Mar 2011 00:04:07 -0500 Subject: [python-win32] EnsureDispatch throwing fatal error Message-ID: I am running the following line of code: iTunes = win32com.client.gencache.EnsureDispatch('iTunes.Application') This results in this error: Traceback (most recent call last): File "Helper.py", line 154, in File "win32com\client\gencache.pyo", line 529, in EnsureDispatch File "win32com\client\__init__.pyo", line 95, in Dispatch File "win32com\client\dynamic.pyo", line 104, in _GetGoodDispatchAndUserName File "win32com\client\dynamic.pyo", line 84, in _GetGoodDispatch pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) This is being run on a Windows 7 64-bit machine with Python 2.6, py2exe-0.6.9, and pywin32-214. Does anyone know the meaning of this cryptic error? -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Thu Mar 31 09:31:41 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 31 Mar 2011 08:31:41 +0100 Subject: [python-win32] EnsureDispatch throwing fatal error In-Reply-To: References: Message-ID: <4D942DDD.8070300@timgolden.me.uk> On 31/03/2011 06:04, Jiawei Li wrote: > I am running the following line of code: > > iTunes = win32com.client.gencache.EnsureDispatch('iTunes.Application') > > This results in this error: > > Traceback (most recent call last): > File "Helper.py", line 154, in > File "win32com\client\gencache.pyo", line 529, in > EnsureDispatch > File "win32com\client\__init__.pyo", line 95, in Dispatch > File "win32com\client\dynamic.pyo", line 104, in > _GetGoodDispatchAndUserName > File "win32com\client\dynamic.pyo", line 84, in > _GetGoodDispatch > pywintypes.com_error: (-2147221005, 'Invalid class string', > None, None) > > This is being run on a Windows 7 64-bit machine with Python 2.6, > py2exe-0.6.9, and pywin32-214. > > Does anyone know the meaning of this cryptic error? Well it's surely not that cryptic, is it? "Invalid class string" suggests that the class string you're using ("iTunes.Application") is invalid. Is the iTunes s/w installed on this machine? TJG From mail at timgolden.me.uk Thu Mar 31 10:24:00 2011 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 31 Mar 2011 09:24:00 +0100 Subject: [python-win32] py3k branch on pywin32 hg repo Message-ID: <4D943A20.6010201@timgolden.me.uk> I note that the pywin32 hg repo has a py3k branch. AFAICT, this is an artefact leftover from CVS days and not a current focus of work? If I'm right, it might be worth marking it as closed (hg commit --close-branch) to avoid confusion. TJG From jiawei.h.li at gmail.com Thu Mar 31 12:29:04 2011 From: jiawei.h.li at gmail.com (Jiawei Li) Date: Thu, 31 Mar 2011 05:29:04 -0500 Subject: [python-win32] EnsureDispatch throwing fatal error In-Reply-To: <4D942DDD.8070300@timgolden.me.uk> References: <4D942DDD.8070300@timgolden.me.uk> Message-ID: iTunes is installed. On Thu, Mar 31, 2011 at 2:31 AM, Tim Golden wrote: > On 31/03/2011 06:04, Jiawei Li wrote: > >> I am running the following line of code: >> >> iTunes = win32com.client.gencache.EnsureDispatch('iTunes.Application') >> >> This results in this error: >> >> Traceback (most recent call last): >> File "Helper.py", line 154, in >> File "win32com\client\gencache.pyo", line 529, in >> EnsureDispatch >> File "win32com\client\__init__.pyo", line 95, in Dispatch >> File "win32com\client\dynamic.pyo", line 104, in >> _GetGoodDispatchAndUserName >> File "win32com\client\dynamic.pyo", line 84, in >> _GetGoodDispatch >> pywintypes.com_error: (-2147221005, 'Invalid class string', >> None, None) >> >> This is being run on a Windows 7 64-bit machine with Python 2.6, >> py2exe-0.6.9, and pywin32-214. >> >> Does anyone know the meaning of this cryptic error? >> > > Well it's surely not that cryptic, is it? > > "Invalid class string" suggests that the class string you're > using ("iTunes.Application") is invalid. Is the iTunes s/w > installed on this machine? > > 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 skippy.hammond at gmail.com Thu Mar 31 12:53:46 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 31 Mar 2011 21:53:46 +1100 Subject: [python-win32] Clear the interactive screen In-Reply-To: References: <4D8EDED0.5090502@gmail.com> Message-ID: <4D945D3A.6000301@gmail.com> On 31/03/2011 2:41 AM, Blockheads Oi Oi wrote: > On 27/03/2011 07:53, Mark Hammond wrote: >> Try something like: >> >> from pywin.framework import interact >> interact.edit.currentView.SetSel(0, -1) >> interact.edit.currentView.Clear() > > Try the above three lines from the interactive prompt and nothing that I > can see happens. That is because line 2 selects all text in the window - but doing this interactively resets this. The last line clears the selection - and interactively there is no selection to remove. > Try the last two lines on a single line with the ; > separator and the screen is cleared, I'm sorry but I don't understand this. Hope that explains it. > > I've tried wrapping the interact lines from above into a cls function I'm not sure what a cls function is. > in > my own bare bones config file based on the data in the pywin32 help > Keyboard Bindings section. Screws everything. Screws what? > What steps are needed to > get what I and others have asked for in the past, i.e. clear the > interactive screen, run the program/module under test, resort to normal? What exactly did you try? How exactly did it not work? > I observe that the Ctrl-R and Shift-Ctrl-R key combinations are not > available in the default config file (presumably to keep bozos like > myself away from them? :). So do we have to resort to (shock, horror, > probe) doing things manually? They should be - I use the default config and Ctrl+R works fine for me. >>> I've also changed interact.py in accordance with >>> http://code.activestate.com/lists/python-list/168244/. Is there any >>> reason why this couldn't be part of the standard file? I don't follow that list - was it ever posted to sourceforge? Cheers, Mark From skippy.hammond at gmail.com Thu Mar 31 13:06:44 2011 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 31 Mar 2011 22:06:44 +1100 Subject: [python-win32] py3k branch on pywin32 hg repo In-Reply-To: <4D943A20.6010201@timgolden.me.uk> References: <4D943A20.6010201@timgolden.me.uk> Message-ID: <4D946044.6000206@gmail.com> On 31/03/2011 7:24 PM, Tim Golden wrote: > I note that the pywin32 hg repo has a py3k branch. AFAICT, this > is an artefact leftover from CVS days and not a current focus > of work? > > If I'm right, it might be worth marking it as closed > (hg commit --close-branch) to avoid confusion. Done, thanks! (That was the only branch I bothered to migrate from CVS and I forgot to close it after the migration...) Thanks, Mark From palla74 at gmail.com Thu Mar 31 14:41:42 2011 From: palla74 at gmail.com (Palla) Date: Thu, 31 Mar 2011 14:41:42 +0200 Subject: [python-win32] EuroPython 2011: call for paper is ending - Please spread the word! Message-ID: Hi all members, I'm Francesco and I am writing on behalf of "Python Italia APS", a no-profit association promoting EuroPython conference. (www.europython.eu) Europython End of Call for Presentations is April 6th. I'd like to ask to you to forward this mail to anyone that you feel may be interested. We're looking for proposals on every aspects of Python: programming from novice to advanced levels, applications and frameworks, or how you have been involved in introducing Python into your organisation. **First-time speakers are especially welcome**; EuroPython is a community conference and we are eager to hear about your experience. If you have friends or colleagues who have something valuable to contribute, twist their arms to tell us about it! Presenting at EuroPython ------------------------ We will accept a broad range of presentations, from reports on academic and commercial projects to tutorials and case studies. As long as the presentation is interesting and potentially useful to the Python community, it will be considered for inclusion in the programme. Can you show the conference-goers something new and useful? Can you show attendees how to: use a module? Explore a Python language feature? Package an application? If so, consider submitting a talk. Talks and hands-on trainings ---------------------------- There are two different kind of presentations that you can give as a speaker at EuroPython: * **Regular talk**. These are standard "talk with slides", allocated in slots of 45, 60 or 90 minutes, depending on your preference and scheduling constraints. A Q&A session is held at the end of the talk. * **Hands-on training**. These are advanced training sessions for a smaller audience (10-20 people), to dive into the subject with all details. These sessions are 4-hours long, and audience will be strongly encouraged to bring a laptop to experiment. They should be prepared with less slides and more source code. If possible, trainers will also give a short "teaser talk" of 30 minutes the day before the training, to tease delegates into attending the training. In the talk submission form, we assume that you intend to give a regular talk on the subject, but you will be asked if you are available for also doing a hands-on training on the very same subject. Speakers that will give a hands-on training are rewarded with a **free entrance** to EuroPython to compensate for the longer preparation required, and might also be eligible for a speaking fee (which we cannot confirm at the moment). Topics and goals ---------------- Specific topics for EuroPython presentations include, but are not limited to: - Core Python - Other implementations: Jython, IronPython, PyPy, and Stackless - Python libraries and extensions - Python 3.x migration - Databases - Documentation - GUI Programming - Game Programming - Network Programming - Open Source Python projects - Packaging Issues - Programming Tools - Project Best Practices - Embedding and Extending - Science and Math - Web-based Systems Presentation goals usually are some of the following: - Introduce audience to a new topic they are unaware of - Introduce audience to new developments on a well-known topic - Show audience real-world usage scenarios for a specific topic (case study) - Dig into advanced and relatively-unknown details on a topic - Compare different options in the market on a topic Community-based talk voting --------------------------- This year, for the first time in EuroPython history, the talk voting process is fully public. Every partecipant gains the right to vote for talks submitted during the Call For Papers, as soon as they commit to their presence at the conference by buying a ticket. See all the details in the talk voting[1] page. Contacts -------- For any further question, feel free to contact the organizers at info at pycon.it. Thank you! [1]: http://ep2011.europython.eu/talk-voting -- ->PALLA -------------- next part -------------- An HTML attachment was scrubbed... URL: From reckoner at gmail.com Thu Mar 31 15:14:34 2011 From: reckoner at gmail.com (reckoner) Date: Thu, 31 Mar 2011 06:14:34 -0700 Subject: [python-win32] Using Flexible Win32 message pump to monitor window open/close for all application? In-Reply-To: References: Message-ID: <4D947E3A.1080109@gmail.com> > ------------------------------ > > Message: 3 > Date: Wed, 30 Mar 2011 16:17:01 -0700 > From: Tim Roberts > To: Python-Win32 List > Subject: Re: [python-win32] Using Flexible Win32 message pump to > monitor window open/close for all application? > Message-ID:<4D93B9ED.9010402 at probo.com> > Content-Type: text/plain; charset="ISO-8859-1" > > reckoner wrote: >> Which is listed in the Python cookbook, second edition. Is it possible >> to use this to monitor the open/close of different windows? Basically, I >> would like to trigger an action for a specific window or handle when >> that window class or handle opens/closes. Can this recipe help with >> that? Any ideas on getting started with this? > > Do you mean a window in another application? That requires installing a > Windows hook, and a Windows hook callback must reside in a DLL (so that > DLL can be injected into the other process), which cannot be done in > Python. There is the pyHook package, but I don't know if it is still > being developed. > > http://www.cs.unc.edu/Research/assist/developer.shtml > Thanks your reply. I'm guessing from your response that the cookbook recipe can only deal with open/close events that it throws itself. So far, the only way I have found to monitor window open/close events is the Active Accessibility (AA) layer via pyAA. The problem is that AA is really dated and is theoretically supposed to be superseded by the UI automation layer, but there are no similar Python bindings for that (and it relies on the .NET framework ). Here is the link for a description of pyAA: http://web.archive.org/web/20080510165211/mindtrove.info/articles/gui-automation-with-pyaa/ Thanks! From breamoreboy at yahoo.co.uk Thu Mar 31 16:24:39 2011 From: breamoreboy at yahoo.co.uk (Blockheads Oi Oi) Date: Thu, 31 Mar 2011 15:24:39 +0100 Subject: [python-win32] Clear the interactive screen In-Reply-To: <4D945D3A.6000301@gmail.com> References: <4D8EDED0.5090502@gmail.com> <4D945D3A.6000301@gmail.com> Message-ID: On 31/03/2011 11:53, Mark Hammond wrote: > On 31/03/2011 2:41 AM, Blockheads Oi Oi wrote: >> On 27/03/2011 07:53, Mark Hammond wrote: >>> Try something like: >>> >>> from pywin.framework import interact >>> interact.edit.currentView.SetSel(0, -1) >>> interact.edit.currentView.Clear() >> >> Try the above three lines from the interactive prompt and nothing that I >> can see happens. > > That is because line 2 selects all text in the window - but doing this > interactively resets this. The last line clears the selection - and > interactively there is no selection to remove. > >> Try the last two lines on a single line with the ; >> separator and the screen is cleared, I'm sorry but I don't understand >> this. > > Hope that explains it. >> >> I've tried wrapping the interact lines from above into a cls function > > I'm not sure what a cls function is. My function to clear the screen, sorry I should have been explicit, it's given below. > >> in >> my own bare bones config file based on the data in the pywin32 help >> Keyboard Bindings section. Screws everything. > > Screws what? > >> What steps are needed to >> get what I and others have asked for in the past, i.e. clear the >> interactive screen, run the program/module under test, resort to normal? > > What exactly did you try? How exactly did it not work? This is what I set up. c:\Python27\Lib\site-packages\pythonwin\pywin>type mine.cfg [General] BasedOn = Default [Keys:Interactive] Alt+C = cls [Extensions] def cls(editor_window, event): from pywin.framework import interact interact.edit.currentView.SetSel(0, -1) interact.edit.currentView.Clear() This will clear the screen but there's no interactive prompt. Then type any command you like and nothing happens,no errors, no output, zilch. But you can select what you've typed with Ctrl-A and copy it with Ctrl-C, which is exactly what I've done with the following three lines. help(set) a = 1.0 this is junk > >> I observe that the Ctrl-R and Shift-Ctrl-R key combinations are not >> available in the default config file (presumably to keep bozos like >> myself away from them? :). So do we have to resort to (shock, horror, >> probe) doing things manually? > > They should be - I use the default config and Ctrl+R works fine for me. > Ctrl-R or Ctrl-Shift-R work fine for me but they're not in the default config *FILE* as per:- c:\Python27\Lib\site-packages\pythonwin\pywin>grep -i Ctrl default.cfg Ctrl+W = ViewWhitespace Ctrl+Shift+8 = ViewWhitespace # The MSVC default key def. Ctrl+Shift+F = ViewFixedFont Ctrl+Space = <> Ctrl+F3 = AutoFindNext Ctrl+F2 = ToggleBookmark Ctrl+G = GotoLine Ctrl+T = <> Ctrl+Up = <> Ctrl+Down = <> Ctrl+Enter = ProcessEnter # When docked, the Ctrl+Tab and Shift+Ctrl+Tab keys dont work as expected. Ctrl+Tab = MDINext Ctrl+Shift+Tab = MDIPrev >>>> I've also changed interact.py in accordance with >>>> http://code.activestate.com/lists/python-list/168244/. Is there any >>>> reason why this couldn't be part of the standard file? > > I don't follow that list - was it ever posted to sourceforge? The above URL refers to http://sourceforge.net/tracker/?func=detail&aid=2813056&group_id=78018&atid=551956). You checked in the changes at 2010-08-27 07:37:51 UTC :) > > Cheers, > > Mark Regards. Mark L. From timr at probo.com Thu Mar 31 19:18:09 2011 From: timr at probo.com (Tim Roberts) Date: Thu, 31 Mar 2011 10:18:09 -0700 Subject: [python-win32] EnsureDispatch throwing fatal error In-Reply-To: References: <4D942DDD.8070300@timgolden.me.uk> Message-ID: <4D94B751.1020700@probo.com> Jiawei Li wrote: > iTunes is installed. iTunes is a 64-bit application. Unless they also registered a 32-bit proxy, a 64-bit COM object cannot be used in a 32-bit process. If you need this, it may be time to consider loading a 64-bit Python. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jiawei.h.li at gmail.com Thu Mar 31 20:08:55 2011 From: jiawei.h.li at gmail.com (Jiawei Li) Date: Thu, 31 Mar 2011 13:08:55 -0500 Subject: [python-win32] EnsureDispatch throwing fatal error In-Reply-To: <4D94B751.1020700@probo.com> References: <4D942DDD.8070300@timgolden.me.uk> <4D94B751.1020700@probo.com> Message-ID: Ah, I see. So likewise, I just need to run a 64-bit version of py2exe? On Thu, Mar 31, 2011 at 12:18 PM, Tim Roberts wrote: > Jiawei Li wrote: > > iTunes is installed. > > iTunes is a 64-bit application. Unless they also registered a 32-bit > proxy, a 64-bit COM object cannot be used in a 32-bit process. > > If you need this, it may be time to consider loading a 64-bit Python. > > -- > 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 timr at probo.com Thu Mar 31 20:18:10 2011 From: timr at probo.com (Tim Roberts) Date: Thu, 31 Mar 2011 11:18:10 -0700 Subject: [python-win32] EnsureDispatch throwing fatal error In-Reply-To: References: <4D942DDD.8070300@timgolden.me.uk> <4D94B751.1020700@probo.com> Message-ID: <4D94C562.7050800@probo.com> Jiawei Li wrote: > Ah, I see. > So likewise, I just need to run a 64-bit version of py2exe? Since I have not personally tried running iTunes on a 64-bit system, I can't give you 100% confidence, but based on the error message, I am guessing that will solve your problem, yes. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc.