From bwmetz at att.com Mon May 1 23:44:32 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Mon, 1 May 2006 16:44:32 -0500 Subject: [python-win32] Python Programming on Win32 Book In-Reply-To: <4454D4E8.5010303@pennswoods.net> Message-ID: <01D5341D04A2E64AB9B345769047336701B5178D@OCCLUST01EVS1.ugd.att.com> Yeh, Mark's first book seems to be on backorder everywhere. I've been trying to get it for some time. B&N and Borders both don't have it and tell me backordered as well. Bobby -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Bill Burns Sent: Sunday, April 30, 2006 8:17 AM To: Mark Hammond Cc: Python-win32 at python.org Subject: Re: [python-win32] Python Programming on Win32 Book >>Is there going to be a 2nd Edition of your Python Programming on Win32 >>book? If so, when do you think it will be released? > > > I hope to have this complete this year, so released some time next year. Of > course, that means I need to *start* it this year. I've one or two people > lined up to help too (sadly I believe Andy will be too busy to contribute > second time around, but I'm yet to confirm that with him) Thanks for the info and good luck with the new book! I'm sure there's a lot of people eager to get it! I've just ordered the 1st edition from O'Reilly (it's on back-order). I can't wait a whole year for the new book :-) I guess I'll have two of your books in the future ;-) >>Regardless of a second book, do you recommend I purchase the book >>directly from O'Reilly? I've not checked other vendors (Amazon, Barnes & >>Noble, etc). I just want to make sure that the most amount for my >>purchase gets diverted to you :-) Maybe it doesn't matter who I buy from >>- but I thought I ask anyway! > > > Thanks for your consideration, but I've no idea how any of that works. > AFAIK I just get a few cents per copy sold regardless of who the retailer > is. A few cents, that blows! I'll have to help you out some other way :-) Thanks again - Mark! Bill _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From billburns at pennswoods.net Tue May 2 00:30:25 2006 From: billburns at pennswoods.net (Bill Burns) Date: Mon, 01 May 2006 18:30:25 -0400 Subject: [python-win32] Python Programming on Win32 Book In-Reply-To: <01D5341D04A2E64AB9B345769047336701B5178D@OCCLUST01EVS1.ugd.att.com> References: <01D5341D04A2E64AB9B345769047336701B5178D@OCCLUST01EVS1.ugd.att.com> Message-ID: <44568C01.9070505@pennswoods.net> Metz, Bobby W, WWCS wrote: > Yeh, Mark's first book seems to be on backorder everywhere. I've been > trying to get it for some time. B&N and Borders both don't have it and > tell me backordered as well. > I sent an email to O'Reilly earlier today. I asked them then they thought I might get the book - I'll let you know what they say. Bill From dprovins at tridentexploration.ca Tue May 2 00:16:28 2006 From: dprovins at tridentexploration.ca (Dean Allen Provins) Date: Mon, 01 May 2006 16:16:28 -0600 Subject: [python-win32] curses and _curses Message-ID: <445688BC.1050001@tridentexploration.ca> Hello: I just installed the 2.4 version of Python on a WinXP box. I then copied over my python code which runs under Linux. This code uses "curses.ascii" (isspace specifically). The Win version of the libraries has a curses directory and within it, the ascii.py module. Unfortunately, the __init__.py module in the curses directory expects to import "_curses" (as it does on Linux), and this is nowhere to be found in the Windows python install directory (it is part of a shared library under Linux). To get around the problem, I simply commented out the entire __init__.py module, but this provides only symptomatic relief. Any readers know why the "_curses" library is missing, or in other words, have I found an "error of omission"? Regards, Dean Confidentiality Notice: The information transmitted herein may contain confidential, proprietary and/or privileged material which belongs to Trident Exploration Corp. and its affiliates and is intended only for the addressee(s). Any unauthorized review, distribution or other use or the taking of any action in reliance upon this information is prohibited. If you received this email in error, please contact the sender or call (403) 770-1765 and delete this email and any copies. From sjmachin at lexicon.net Tue May 2 00:48:36 2006 From: sjmachin at lexicon.net (John Machin) Date: Tue, 02 May 2006 08:48:36 +1000 Subject: [python-win32] curses and _curses In-Reply-To: <445688BC.1050001@tridentexploration.ca> References: <445688BC.1050001@tridentexploration.ca> Message-ID: <44569044.8030802@lexicon.net> On 2/05/2006 8:16 AM, Dean Allen Provins wrote: > Hello: > > I just installed the 2.4 version of Python on a WinXP box. I then > copied over my python code which runs under Linux. This code uses > "curses.ascii" (isspace specifically). > > The Win version of the libraries has a curses directory and within it, > the ascii.py module. Unfortunately, the __init__.py module in the > curses directory expects to import "_curses" (as it does on Linux), and > this is nowhere to be found in the Windows python install directory (it > is part of a shared library under Linux). > > To get around the problem, I simply commented out the entire __init__.py > module, but this provides only symptomatic relief. > > Any readers know why the "_curses" library is missing, or in other > words, have I found an "error of omission"? > http://www.amk.ca/python/howto/curses/ "Nobody has made a Windows port" or words to that effect ... From billburns at pennswoods.net Tue May 2 01:07:53 2006 From: billburns at pennswoods.net (Bill Burns) Date: Mon, 01 May 2006 19:07:53 -0400 Subject: [python-win32] curses and _curses In-Reply-To: <44569044.8030802@lexicon.net> References: <445688BC.1050001@tridentexploration.ca> <44569044.8030802@lexicon.net> Message-ID: <445694C9.3050004@pennswoods.net> > On 2/05/2006 8:16 AM, Dean Allen Provins wrote: > >>Hello: >> >>I just installed the 2.4 version of Python on a WinXP box. I then >>copied over my python code which runs under Linux. This code uses >>"curses.ascii" (isspace specifically). >> >>The Win version of the libraries has a curses directory and within it, >>the ascii.py module. Unfortunately, the __init__.py module in the >>curses directory expects to import "_curses" (as it does on Linux), and >>this is nowhere to be found in the Windows python install directory (it >>is part of a shared library under Linux). >> >>To get around the problem, I simply commented out the entire __init__.py >>module, but this provides only symptomatic relief. >> >>Any readers know why the "_curses" library is missing, or in other >>words, have I found an "error of omission"? >> > > > http://www.amk.ca/python/howto/curses/ > > "Nobody has made a Windows port" or words to that effect ... Actually, I just found this.... but I've never tried it http://adamv.com/dev/python/curses/ but I believe John is partial right ;-), in the sense that, the Standard Python distribution doesn't supply curses for Windows. So you have *not* found an "error of omission". Google "Windows _curses" on comp.lang.python for more info and other possibilities. Bill From rwupole at msn.com Tue May 2 07:47:29 2006 From: rwupole at msn.com (Roger Upole) Date: Tue, 2 May 2006 01:47:29 -0400 Subject: [python-win32] curses and _curses Message-ID: Bill Burns wrote: >> On 2/05/2006 8:16 AM, Dean Allen Provins wrote: >> >>>Hello: >>> >>>I just installed the 2.4 version of Python on a WinXP box. I then >>>copied over my python code which runs under Linux. This code uses >>>"curses.ascii" (isspace specifically). >>> >>>The Win version of the libraries has a curses directory and within it, >>>the ascii.py module. Unfortunately, the __init__.py module in the >>>curses directory expects to import "_curses" (as it does on Linux), and >>>this is nowhere to be found in the Windows python install directory (it >>>is part of a shared library under Linux). >>> >>>To get around the problem, I simply commented out the entire __init__.py >>>module, but this provides only symptomatic relief. >>> >>>Any readers know why the "_curses" library is missing, or in other >>>words, have I found an "error of omission"? >>> >> >> >> http://www.amk.ca/python/howto/curses/ >> >> "Nobody has made a Windows port" or words to that effect ... > > Actually, I just found this.... but I've never tried it > > http://adamv.com/dev/python/curses/ > > but I believe John is partial right ;-), in the sense that, the Standard > Python distribution doesn't supply curses for Windows. > > So you have *not* found an "error of omission". > > Google "Windows _curses" on comp.lang.python for more info and other > possibilities. > > Bill Newer versions of Pywin32 come with a win32console module that allows you to create and interact with console windows. Roger From graemeglass at gmail.com Tue May 2 12:38:38 2006 From: graemeglass at gmail.com (Graeme Glass) Date: Tue, 2 May 2006 12:38:38 +0200 Subject: [python-win32] adding icon in an exe Message-ID: Greetings, Does anyone know of a way to add an icon to an existing .exe file on win32 platform using win32all package? Thanks. Graeme From dprovins at tridentexploration.ca Tue May 2 16:44:11 2006 From: dprovins at tridentexploration.ca (Dean Allen Provins) Date: Tue, 02 May 2006 08:44:11 -0600 Subject: [python-win32] curses and _curses In-Reply-To: References: Message-ID: <4457703B.5060908@tridentexploration.ca> Roger Upole wrote: > Bill Burns wrote: > >>>On 2/05/2006 8:16 AM, Dean Allen Provins wrote: >>> >>> >>>>Hello: >>>> >>>>I just installed the 2.4 version of Python on a WinXP box. I then >>>>copied over my python code which runs under Linux. This code uses >>>>"curses.ascii" (isspace specifically). >>>> >>>>The Win version of the libraries has a curses directory and within it, >>>>the ascii.py module. Unfortunately, the __init__.py module in the >>>>curses directory expects to import "_curses" (as it does on Linux), and >>>>this is nowhere to be found in the Windows python install directory (it >>>>is part of a shared library under Linux). >>>> >>>>To get around the problem, I simply commented out the entire __init__.py >>>>module, but this provides only symptomatic relief. >>>> >>>>Any readers know why the "_curses" library is missing, or in other >>>>words, have I found an "error of omission"? >>>> >>> >>> >>>http://www.amk.ca/python/howto/curses/ >>> >>>"Nobody has made a Windows port" or words to that effect ... >> >>Actually, I just found this.... but I've never tried it >> >>http://adamv.com/dev/python/curses/ >> >>but I believe John is partial right ;-), in the sense that, the Standard >>Python distribution doesn't supply curses for Windows. >> >>So you have *not* found an "error of omission". >> >>Google "Windows _curses" on comp.lang.python for more info and other >>possibilities. >> >>Bill > > > Newer versions of Pywin32 come with a win32console module that > allows you to create and interact with console windows. > > Roger John. Bill and Roger: Thanks for your responses. Fortunately, I don't need anything from the curses library except the "isspace" function in "curses.ascii". Since the module "_curses" isn't available in the WIN version, I've decided to copy the "ascii.py" module over to my collection of codes and transfer it to Windows, rather than try to import a surgically-altered version of the curses module (described above). This should simplify the installation on other WIN machines. This leaves printing under windows to be resolved, and the project will be done. Thanks again for your help. Regards, Dean Confidentiality Notice: The information transmitted herein may contain confidential, proprietary and/or privileged material which belongs to Trident Exploration Corp. and its affiliates and is intended only for the addressee(s). Any unauthorized review, distribution or other use or the taking of any action in reliance upon this information is prohibited. If you received this email in error, please contact the sender or call (403) 770-1765 and delete this email and any copies. From eugene at boardkulture.com Tue May 2 20:36:47 2006 From: eugene at boardkulture.com (EuGeNe) Date: Tue, 02 May 2006 20:36:47 +0200 Subject: [python-win32] Python Programming on Win32 Book In-Reply-To: <4453D271.5070704@pennswoods.net> References: <4453D271.5070704@pennswoods.net> Message-ID: http://dogbert.abebooks.com/servlet/BookDetailsPL?bi=715644772&searchurl=sts%3Dt%26y%3D0%26kn%3Dpython%2Bwin32%26x%3D0 Book prices are going the way gold is these days ... a precious book! EuGeNe Bill Burns wrote: > Mark, > > Is there going to be a 2nd Edition of your Python Programming on Win32 > book? If so, when do you think it will be released? > > Regardless of a second book, do you recommend I purchase the book > directly from O'Reilly? I've not checked other vendors (Amazon, Barnes & > Noble, etc). I just want to make sure that the most amount for my > purchase gets diverted to you :-) Maybe it doesn't matter who I buy from > - but I thought I ask anyway! > > Thanks, > > Bill From derobins at scs.uiuc.edu Tue May 2 21:25:07 2006 From: derobins at scs.uiuc.edu (Dana Robinson) Date: Tue, 2 May 2006 14:25:07 -0500 Subject: [python-win32] Python Programming on Win32 Book In-Reply-To: References: <4453D271.5070704@pennswoods.net> Message-ID: On Tue, 2 May 2006, EuGeNe wrote: > http://dogbert.abebooks.com/servlet/BookDetailsPL?bi=715644772&searchurl=sts%3Dt%26y%3D0%26kn%3Dpython%2Bwin32%26x%3D0 > > Book prices are going the way gold is these days ... a precious book! > > EuGeNe I asked O'Reilly about this and they said that they were printing up more copies. Dana From grickert at coldstorage.com Tue May 2 21:50:49 2006 From: grickert at coldstorage.com (Gerrat Rickert) Date: Tue, 2 May 2006 15:50:49 -0400 Subject: [python-win32] killProcName.py not working for processes under user SYSTEM Message-ID: I'm logged in as an administrator on my computer (actually a domain admin) and I can't seem to get the killProcName.py program (that came with Mark Hammond's python extensions) to kill ANY process owned by 'SYSTEM' (I've tried a few - eg. 'iPodService', 'Apache') I can open the windows task manager, right-click the process and do an 'End Process', and that kills it just fine, but I just get an error when I try it from Python: (5, 'OpenProcess', 'Access is denied.') [ it fails at: handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0,pids[0]) ] ...I can print the pid, and it corresponds to the expected PID in Windows Task Manager I'm running WinXP SP2 if that matters. ...when I check who I'm logged in as using (win32api.GetDomainName(), win32api.GetUserName()), it shows that I'm the domain admin that I expect. ...I've tried running the command prompt as various users (local admin, a power user), and I just can't get it to kill the process. Any Suggestions? Thanks, Gerrat Rickert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060502/8505b124/attachment.htm From sjmachin at lexicon.net Tue May 2 23:22:33 2006 From: sjmachin at lexicon.net (John Machin) Date: Wed, 03 May 2006 07:22:33 +1000 Subject: [python-win32] curses and _curses In-Reply-To: <4457703B.5060908@tridentexploration.ca> References: <4457703B.5060908@tridentexploration.ca> Message-ID: <4457CD99.3010508@lexicon.net> On 3/05/2006 12:44 AM, Dean Allen Provins wrote: > Roger Upole wrote: >> Bill Burns wrote: >> >>>> On 2/05/2006 8:16 AM, Dean Allen Provins wrote: >>>> >>>> >>>>> Hello: >>>>> >>>>> I just installed the 2.4 version of Python on a WinXP box. I then >>>>> copied over my python code which runs under Linux. This code uses >>>>> "curses.ascii" (isspace specifically). >>>>> >>>>> The Win version of the libraries has a curses directory and within it, >>>>> the ascii.py module. Unfortunately, the __init__.py module in the >>>>> curses directory expects to import "_curses" (as it does on Linux), and >>>>> this is nowhere to be found in the Windows python install directory (it >>>>> is part of a shared library under Linux). >>>>> >>>>> To get around the problem, I simply commented out the entire __init__.py >>>>> module, but this provides only symptomatic relief. >>>>> >>>>> Any readers know why the "_curses" library is missing, or in other >>>>> words, have I found an "error of omission"? >>>>> >>>> >>>> http://www.amk.ca/python/howto/curses/ >>>> >>>> "Nobody has made a Windows port" or words to that effect ... >>> Actually, I just found this.... but I've never tried it >>> >>> http://adamv.com/dev/python/curses/ >>> >>> but I believe John is partial right ;-), in the sense that, the Standard >>> Python distribution doesn't supply curses for Windows. >>> >>> So you have *not* found an "error of omission". >>> >>> Google "Windows _curses" on comp.lang.python for more info and other >>> possibilities. >>> >>> Bill >> >> Newer versions of Pywin32 come with a win32console module that >> allows you to create and interact with console windows. >> >> Roger > > John. Bill and Roger: > > Thanks for your responses. > > Fortunately, I don't need anything from the curses library except the > "isspace" function in "curses.ascii". Since the module "_curses" isn't > available in the WIN version, I've decided to copy the "ascii.py" module > over to my collection of codes and transfer it to Windows, rather than > try to import a surgically-altered version of the curses module > (described above). This should simplify the installation on other WIN > machines. > From curses/ascii.py: def isspace(c): return _ctoi(c) in (9, 10, 11, 12, 13, 32) Code reuse is great, but transporting and importing a whole irrelevant module to get a fugly ill-coded one-liner and a further unnecessary function call (_ctoi) qualifies for bogglement of the month [so far]. Try inserting this OS-independent one-liner in your code somewhere: def isspace(c): return c in (' ', '\t', '\n', '\r', '\f', '\v') It appears to work all the way back to Python 2.1 (see below). I could arc up the box with 1.5.2 on it and check it out for you if you truly rooly want a Python-version-agnostic function :-) C:\junk>\python21\python Python 2.1.3 (#35, Apr 8 2002, 17:47:50) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> def isspace(c): return c in (' ', '\t', '\n', '\r', '\f', '\v') ... >>> for x in (666, 1.23, 'a', 'z', 'fubar', ' ', '\t', '\n', '\r', '\f', '\v'): ... print repr(x), isspace(x) ... 666 0 1.23 0 'a' 0 'z' 0 'fubar' 0 ' ' 1 '\t' 1 '\n' 1 '\r' 1 '\x0c' 1 '\x0b' 1 >>> for x in (8, 9, 10, 11, 12, 13, 14, 31, 32, 33): ... print x, repr(chr(x)), isspace(chr(x)) ... 8 '\x08' 0 9 '\t' 1 10 '\n' 1 11 '\x0b' 1 12 '\x0c' 1 13 '\r' 1 14 '\x0e' 0 31 '\x1f' 0 32 ' ' 1 33 '!' 0 >>> HTH, John From grickert at coldstorage.com Wed May 3 00:06:44 2006 From: grickert at coldstorage.com (Gerrat Rickert) Date: Tue, 2 May 2006 18:06:44 -0400 Subject: [python-win32] killProcName.py not working for processes under user SYSTEM Message-ID: ...well, I couldn't get a pure vbscript program to kill these processes either, but I did find a utility that comes with winXP: taskkill; so this works like a charm: import os name = 'Apache.exe' os.system('taskkill /F /IM %s /T' % name) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060502/cd45f50f/attachment-0001.html From dprovins at tridentexploration.ca Wed May 3 00:38:20 2006 From: dprovins at tridentexploration.ca (Dean Allen Provins) Date: Tue, 02 May 2006 16:38:20 -0600 Subject: [python-win32] curses and _curses In-Reply-To: <4457CD99.3010508@lexicon.net> References: <4457703B.5060908@tridentexploration.ca> <4457CD99.3010508@lexicon.net> Message-ID: <4457DF5C.9070209@tridentexploration.ca> John Machin wrote: > On 3/05/2006 12:44 AM, Dean Allen Provins wrote: > >> Roger Upole wrote: >> >>> Bill Burns wrote: >>> >>>>> On 2/05/2006 8:16 AM, Dean Allen Provins wrote: >>>>> >>>>> >>>>>> Hello: >>>>>> >>>>>> I just installed the 2.4 version of Python on a WinXP box. I then >>>>>> copied over my python code which runs under Linux. This code uses >>>>>> "curses.ascii" (isspace specifically). >>>>>> >>>>>> The Win version of the libraries has a curses directory and within >>>>>> it, >>>>>> the ascii.py module. Unfortunately, the __init__.py module in the >>>>>> curses directory expects to import "_curses" (as it does on >>>>>> Linux), and >>>>>> this is nowhere to be found in the Windows python install >>>>>> directory (it >>>>>> is part of a shared library under Linux). >>>>>> >>>>>> To get around the problem, I simply commented out the entire >>>>>> __init__.py >>>>>> module, but this provides only symptomatic relief. >>>>>> >>>>>> Any readers know why the "_curses" library is missing, or in other >>>>>> words, have I found an "error of omission"? >>>>>> >>>>> >>>>> http://www.amk.ca/python/howto/curses/ >>>>> >>>>> "Nobody has made a Windows port" or words to that effect ... >>>> >>>> Actually, I just found this.... but I've never tried it >>>> >>>> http://adamv.com/dev/python/curses/ >>>> >>>> but I believe John is partial right ;-), in the sense that, the >>>> Standard Python distribution doesn't supply curses for Windows. >>>> >>>> So you have *not* found an "error of omission". >>>> >>>> Google "Windows _curses" on comp.lang.python for more info and other >>>> possibilities. >>>> >>>> Bill >>> >>> >>> Newer versions of Pywin32 come with a win32console module that >>> allows you to create and interact with console windows. >>> >>> Roger >> >> >> John. Bill and Roger: >> >> Thanks for your responses. >> >> Fortunately, I don't need anything from the curses library except the >> "isspace" function in "curses.ascii". Since the module "_curses" isn't >> available in the WIN version, I've decided to copy the "ascii.py" module >> over to my collection of codes and transfer it to Windows, rather than >> try to import a surgically-altered version of the curses module >> (described above). This should simplify the installation on other WIN >> machines. >> > > From curses/ascii.py: > > def isspace(c): return _ctoi(c) in (9, 10, 11, 12, 13, 32) > > Code reuse is great, but transporting and importing a whole irrelevant > module to get a fugly ill-coded one-liner and a further unnecessary > function call (_ctoi) qualifies for bogglement of the month [so far]. > > Try inserting this OS-independent one-liner in your code somewhere: > > def isspace(c): return c in (' ', '\t', '\n', '\r', '\f', '\v') > > It appears to work all the way back to Python 2.1 (see below). I could > arc up the box with 1.5.2 on it and check it out for you if you truly > rooly want a Python-version-agnostic function :-) > > C:\junk>\python21\python > Python 2.1.3 (#35, Apr 8 2002, 17:47:50) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. >>>> def isspace(c): return c in (' ', '\t', '\n', '\r', '\f', '\v') > ... >>>> for x in (666, 1.23, 'a', 'z', 'fubar', ' ', '\t', '\n', '\r', '\f', > '\v'): > ... print repr(x), isspace(x) > ... > 666 0 > 1.23 0 > 'a' 0 > 'z' 0 > 'fubar' 0 > ' ' 1 > '\t' 1 > '\n' 1 > '\r' 1 > '\x0c' 1 > '\x0b' 1 >>>> for x in (8, 9, 10, 11, 12, 13, 14, 31, 32, 33): > ... print x, repr(chr(x)), isspace(chr(x)) > ... > 8 '\x08' 0 > 9 '\t' 1 > 10 '\n' 1 > 11 '\x0b' 1 > 12 '\x0c' 1 > 13 '\r' 1 > 14 '\x0e' 0 > 31 '\x1f' 0 > 32 ' ' 1 > 33 '!' 0 >>>> > > HTH, > John Excellent idea. Thanks, Dean Confidentiality Notice: The information transmitted herein may contain confidential, proprietary and/or privileged material which belongs to Trident Exploration Corp. and its affiliates and is intended only for the addressee(s). Any unauthorized review, distribution or other use or the taking of any action in reliance upon this information is prohibited. If you received this email in error, please contact the sender or call (403) 770-1765 and delete this email and any copies. From mhammond at skippinet.com.au Wed May 3 00:54:35 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 3 May 2006 08:54:35 +1000 Subject: [python-win32] adding icon in an exe In-Reply-To: Message-ID: > Does anyone know of a way to add an icon to an existing .exe file on > win32 platform using win32all package? With some pain :( You need to put together the .ico structure yourself and use the BeginUpdateResource() etc win32 functions. The only working code I know (off the top of my head) is in py2exe - and sadly that implements it in C. However, if you understand C it should be possible to port to pure pywin32. The win32verstamp module may also help - it updates the 'version info' rather than the icon resources - but the principle is the same... Mark. From rwupole at msn.com Wed May 3 03:47:29 2006 From: rwupole at msn.com (Roger Upole) Date: Tue, 2 May 2006 21:47:29 -0400 Subject: [python-win32] Re: killProcName.py not working for processes under user SYSTEM Message-ID: You most likely need to enable the SE_DEBUG_NAME privilege. I imagine taskkill is doing that for you under the covers. hth Roger From billburns at pennswoods.net Wed May 3 03:57:14 2006 From: billburns at pennswoods.net (Bill Burns) Date: Tue, 02 May 2006 21:57:14 -0400 Subject: [python-win32] Python Programming on Win32 Book In-Reply-To: <44568C01.9070505@pennswoods.net> References: <01D5341D04A2E64AB9B345769047336701B5178D@OCCLUST01EVS1.ugd.att.com> <44568C01.9070505@pennswoods.net> Message-ID: <44580DFA.6000608@pennswoods.net> > Metz, Bobby W, WWCS wrote: > >>Yeh, Mark's first book seems to be on backorder everywhere. I've been >>trying to get it for some time. B&N and Borders both don't have it and >>tell me backordered as well. >> > > > I sent an email to O'Reilly earlier today. I asked them then they > thought I might get the book - I'll let you know what they say. > Bobby, Just to let you know... O'Reilly got back to me today. The book is shipping tomorrow. Bill From gagsl-p32 at yahoo.com.ar Wed May 3 00:04:08 2006 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 02 May 2006 19:04:08 -0300 Subject: [python-win32] select.poll() In-Reply-To: <20060430080455.41594.qmail@web31601.mail.mud.yahoo.com> References: <20060430080455.41594.qmail@web31601.mail.mud.yahoo.com> Message-ID: <7.0.1.0.0.20060502184526.04aa88a8@yahoo.com.ar> At Sunday 30/4/2006 05:04, Vahid Noroozi wrote: >i have a python program that use sellect.poll() to control some >sockets but in windows we doesn't have sellect.poll() You can use select.select() which is available on Windows too. asyncore.poll() is an example. >also how can i find information about WaitForMultipleEvent It's a Windows function, search msdn.microsoft.com. But you dont need it if you only have to poll sockets. Gabriel Genellina Softlab SRL __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ˇgratis! ˇAbrí tu cuenta ya! - http://correo.yahoo.com.ar From gagsl-p32 at yahoo.com.ar Wed May 3 00:33:39 2006 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 02 May 2006 19:33:39 -0300 Subject: [python-win32] killProcName.py not working for processes under user SYSTEM In-Reply-To: References: Message-ID: <7.0.1.0.0.20060502191922.04b1d4d0@yahoo.com.ar> At Tuesday 2/5/2006 16:50, Gerrat Rickert wrote: >I?m logged in as an administrator on my computer >(actually a domain admin) and I can?t seem to >get the killProcName.py program (that came with >Mark Hammond?s python extensions) to kill ANY >process owned by ?SYSTEM? (I?ve tried a few ? eg. ?iPodService?, ?Apache?) > >I can open the windows task manager, right-click >the process and do an ?End Process?, and that >kills it just fine, but I just get an error when I try it from Python: >(5, ?OpenProcess?, ?Access is denied.?) Thats because you, even as administrator, do not have enough privilege to grab the process handle. This is a common scenario for services running as Local System. See http://support.microsoft.com/kb/197155/en-us Gabriel Genellina Softlab SRL __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ?gratis! ?Abr? tu cuenta ya! - http://correo.yahoo.com.ar From ralf at brainbot.com Wed May 3 09:41:19 2006 From: ralf at brainbot.com (Ralf Schmitt) Date: Wed, 03 May 2006 09:41:19 +0200 Subject: [python-win32] adding icon in an exe In-Reply-To: References: Message-ID: <44585E9F.30302@brainbot.com> Mark Hammond schrieb: >> Does anyone know of a way to add an icon to an existing .exe file on >> win32 platform using win32all package? > > With some pain :( You need to put together the .ico structure yourself and > use the BeginUpdateResource() etc win32 functions. The only working code I > know (off the top of my head) is in py2exe - and sadly that implements it in > C. However, if you understand C it should be possible to port to pure > pywin32. > pyinstaller (http://pyinstaller.hpcf.upr.edu/cgi-bin/trac.cgi/wiki) has pure python code to set icons. Here is a link to the relevant file: http://pyinstaller.hpcf.upr.edu/cgi-bin/trac.cgi/file/trunk/icon.py - Ralf From graemeglass at gmail.com Wed May 3 10:11:22 2006 From: graemeglass at gmail.com (Graeme Glass) Date: Wed, 3 May 2006 10:11:22 +0200 Subject: [python-win32] adding icon in an exe In-Reply-To: <44585E9F.30302@brainbot.com> References: <44585E9F.30302@brainbot.com> Message-ID: Great, thanks to the both of you, very helpful!! I had found a interim work around, (not programmable, using GoRC and Resource Hacker) and so was not happy with it, this is of great help, thank you. Graeme On 5/3/06, Ralf Schmitt wrote: > Mark Hammond schrieb: > >> Does anyone know of a way to add an icon to an existing .exe file on > >> win32 platform using win32all package? > > > > With some pain :( You need to put together the .ico structure yourself and > > use the BeginUpdateResource() etc win32 functions. The only working code I > > know (off the top of my head) is in py2exe - and sadly that implements it in > > C. However, if you understand C it should be possible to port to pure > > pywin32. > > > > pyinstaller (http://pyinstaller.hpcf.upr.edu/cgi-bin/trac.cgi/wiki) has > pure python code to set icons. Here is a link to the relevant file: > http://pyinstaller.hpcf.upr.edu/cgi-bin/trac.cgi/file/trunk/icon.py > > - Ralf > > From robin at reportlab.com Wed May 3 11:32:45 2006 From: robin at reportlab.com (Robin Becker) Date: Wed, 03 May 2006 10:32:45 +0100 Subject: [python-win32] pythonwin 204 editor crash Message-ID: <445878BD.1070300@chamonix.reportlab.co.uk> I see the error below when trying to edit this file ------------------------------------------------- _flightClass = {'first':['A','F','G','P'], 'business':['C','D','I','J','Z'], 'economy':['B','E','H','K'] } class ItemMapping(dict): def __setattr__(self, name, value): self[name] = value def __getattr__(self, name): return self[name] ------------------------------------------------- If I put a comment before _flightClass or change the spacing so it looks better eg ------------------------------------------------- _flightClass = { 'first':['A','F','G','P'], 'business':['C','D','I','J','Z'], 'economy':['B','E','H','K'] } class ItemMapping(dict): def __setattr__(self, name, value): self[name] = value def __getattr__(self, name): return self[name] ------------------------------------------------- the crash doesn't happen. PythonWin 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2004 Mark Hammond (mhammond at skippinet.com.au) - see 'Help/About PythonWin' for further copyright information. >>> Traceback (most recent call last): File "C:\Python\Lib\site-packages\pythonwin\pywin\framework\editor\color\coloreditor.py", line 51, in OnInitialUpdate SyntEditViewParent.OnInitialUpdate(self) File "C:\Python\Lib\site-packages\pythonwin\pywin\scintilla\view.py", line 210, in OnInitialUpdate self.OnWinIniChange(None) File "C:\Python\Lib\site-packages\pythonwin\pywin\scintilla\view.py", line 223, in OnWinIniChange self.DoConfigChange() File "C:\Python\Lib\site-packages\pythonwin\pywin\framework\editor\color\coloreditor.py", line 162, in DoConfigChange ext.set_indentation_params(1) File "C:\Python\Lib\site-packages\pythonwin\pywin\idle\AutoIndent.py", line 140, in set_indentation_params i = self.guess_indent() File "C:\Python\Lib\site-packages\pythonwin\pywin\idle\AutoIndent.py", line 473, in guess_indent opener, indented = IndentSearcher(self.text, self.tabwidth).run() File "C:\Python\Lib\site-packages\pythonwin\pywin\idle\AutoIndent.py", line 546, in run _tokenize.tokenize(self.readline, self.tokeneater) File "c:\python\lib\tokenize.py", line 153, in tokenize tokenize_loop(readline, tokeneater) File "c:\python\lib\tokenize.py", line 159, in tokenize_loop for token_info in generate_tokens(readline): File "c:\python\lib\tokenize.py", line 229, in generate_tokens raise IndentationError( IndentationError: unindent does not match any outer indentation level win32ui: OnInitialUpdate() virtual handler (>) raised an exception Traceback (most recent call last): File "C:\Python\Lib\site-packages\pythonwin\pywin\framework\editor\color\coloreditor.py", line 51, in OnInitialUpdate SyntEditViewParent.OnInitialUpdate(self) File "C:\Python\Lib\site-packages\pythonwin\pywin\scintilla\view.py", line 210, in OnInitialUpdate self.OnWinIniChange(None) File "C:\Python\Lib\site-packages\pythonwin\pywin\scintilla\view.py", line 223, in OnWinIniChange self.DoConfigChange() File "C:\Python\Lib\site-packages\pythonwin\pywin\framework\editor\color\coloreditor.py", line 162, in DoConfigChange ext.set_indentation_params(1) File "C:\Python\Lib\site-packages\pythonwin\pywin\idle\AutoIndent.py", line 140, in set_indentation_params i = self.guess_indent() File "C:\Python\Lib\site-packages\pythonwin\pywin\idle\AutoIndent.py", line 473, in guess_indent opener, indented = IndentSearcher(self.text, self.tabwidth).run() File "C:\Python\Lib\site-packages\pythonwin\pywin\idle\AutoIndent.py", line 546, in run _tokenize.tokenize(self.readline, self.tokeneater) File "c:\python\lib\tokenize.py", line 153, in tokenize tokenize_loop(readline, tokeneater) File "c:\python\lib\tokenize.py", line 159, in tokenize_loop for token_info in generate_tokens(readline): File "c:\python\lib\tokenize.py", line 229, in generate_tokens raise IndentationError( IndentationError: unindent does not match any outer indentation level win32ui: OnInitialUpdate() virtual handler (>) raised an exception -- Robin Becker From stefan.rank at ofai.at Wed May 3 17:17:00 2006 From: stefan.rank at ofai.at (Stefan Rank) Date: Wed, 03 May 2006 17:17:00 +0200 Subject: [python-win32] dualview/extended desktop settings with win32api Message-ID: <4458C96C.5010306@ofai.at> Hi, I am trying to write scripts for changing the "extended desktop" settings in windows. More specifically: I'd like to have a script for toggling between "laptop-screen-only" and "extended-desktop-with-the-secondary-monitor-bottom-right-and- please-don't-forget-the-arrangement-every-time-I-open-the-display-settings... grmph". AFAICT I need the GDI function `ChangeDisplaySettingsEx` and `EnumDisplayDevices` and some others. (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/monitor_4zak.asp) win32api exposes ChangeDisplaySettings only. (and btw I am not sure how to use and manipulate the pyDEVMODE.Fields that EnumDisplaySettings returns, is there an example somewhere?). I wanted to ask if there is a chance that these api parts will get into pywin32? Or if I wanted to add them myself, is there something that I missed that prevents adding it (and related structures) to win32apimodule.cpp ? cheers, stefan From le.dahut at laposte.net Wed May 3 17:29:04 2006 From: le.dahut at laposte.net (le dahut) Date: Wed, 03 May 2006 17:29:04 +0200 Subject: [python-win32] python exe from dll Message-ID: <4458CC40.5020907@laposte.net> Hello, I've build a .dll with Dev-Cpp and a python app (compiled with py2exe). When I run the python app, everything works fine. But when I run it via the dll (Createprocess() or system("app.exe") have the same result) I get an "app.exe.log" file which indicates an "ImportError: No module named os". The dll and app.exe are in the same directory (c:\) Whats happening ? K. From graemeglass at gmail.com Thu May 4 11:33:05 2006 From: graemeglass at gmail.com (Graeme Glass) Date: Thu, 4 May 2006 11:33:05 +0200 Subject: [python-win32] adding icon in an exe In-Reply-To: References: <44585E9F.30302@brainbot.com> Message-ID: I seem to be running into some problems here, ( http://pyinstaller.hpcf.upr.edu/cgi-bin/trac.cgi/file/trunk/icon.py ) If I call CopyIcons_FromIco() or CopyIcons() using an .ico as source, the python script runs with no errors, it adds the icon to the exe but breaks the exe, i then get the error message "*** is not a valid win32 application" when i try run the exe in question. when using a compiled resource as the source, i get hsrc = win32api.LoadLibraryEx (srcpath, 0, LOAD_LIBRARY_AS_DATAFILE) error: (193, 'LoadLibraryEx', '%1 is not a valid Win32 application.') when running the python script. Am i doing something wrong? I am using python 2.4.3 pywin32 build 208, running on WinXP pro. Thanks, Graeme On 5/3/06, Graeme Glass wrote: > Great, thanks to the both of you, very helpful!! > I had found a interim work around, (not programmable, using GoRC and > Resource Hacker) and so was not happy with it, this is of great help, > thank you. > Graeme > > On 5/3/06, Ralf Schmitt wrote: > > Mark Hammond schrieb: > > >> Does anyone know of a way to add an icon to an existing .exe file on > > >> win32 platform using win32all package? > > > > > > With some pain :( You need to put together the .ico structure yourself and > > > use the BeginUpdateResource() etc win32 functions. The only working code I > > > know (off the top of my head) is in py2exe - and sadly that implements it in > > > C. However, if you understand C it should be possible to port to pure > > > pywin32. > > > > > > > pyinstaller (http://pyinstaller.hpcf.upr.edu/cgi-bin/trac.cgi/wiki) has > > pure python code to set icons. Here is a link to the relevant file: > > http://pyinstaller.hpcf.upr.edu/cgi-bin/trac.cgi/file/trunk/icon.py > > > > - Ralf > > > > > From rwupole at msn.com Thu May 4 12:17:23 2006 From: rwupole at msn.com (Roger Upole) Date: Thu, 4 May 2006 06:17:23 -0400 Subject: [python-win32] Re: dualview/extended desktop settings with win32api Message-ID: Stefan Rank wrote: > Hi, > > I am trying to write scripts for changing the "extended desktop" > settings in windows. > More specifically: I'd like to have a script for toggling between > "laptop-screen-only" and > "extended-desktop-with-the-secondary-monitor-bottom-right-and- > please-don't-forget-the-arrangement-every-time-I-open-the-display-settings... > grmph". > > AFAICT I need the GDI function `ChangeDisplaySettingsEx` and > `EnumDisplayDevices` and some others. > > (see > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/monitor_4zak.asp) > > win32api exposes ChangeDisplaySettings only. (and btw I am not sure how > to use and manipulate the pyDEVMODE.Fields that EnumDisplaySettings > returns, is there an example somewhere?). Fields is a bitmask indicating which members of the DEVMODE are significant for a particular operation. Use a bitwise or of win32con.DM_* flags. print_desktop.py in the demos directory uses it. > > I wanted to ask if there is a chance that these api parts will get into > pywin32? > Or if I wanted to add them myself, is there something that I missed that > prevents adding it (and related structures) to win32apimodule.cpp ? > These functions can certainly be added. It will take some extra work (the usual LoadLibrary/GetProcAddress thing) since many of them don't exist on WinNT. You can submit a feature request (or patch) on SourceForge: http://sourceforge.net/projects/pywin32/ Roger From mail at microcorp.co.za Thu May 4 13:18:43 2006 From: mail at microcorp.co.za (H J van Rooyen) Date: Thu, 4 May 2006 13:18:43 +0200 Subject: [python-win32] missing or broken dll Message-ID: <004a01c66f6c$819f7520$03000080@hendrik> Hi All, I am trying to get the serial port (com1 or com2) to work on a PC, using python. It works fine under Linux (/dev/ttys0) but under windoze 95 I am having no joy. Some background: When I use the standard distribution (not pywin) as downloaded, I find that there is no serial module, and also no fcntl module - (on Linux I used fcntl to make the port non blocking, which works fine). when I open com1 or com2 using the standard distribution I am able to send stuff out - I get nulls for every character - I know this because there is a datascope attached to the port - if I use the device manager to set the port up - it makes no difference - if I first set the port up using hyperterm, then I can transmit, but not receive - I know the hardware is working because I have another old DOS box running procomm attached, and using hyperterm I can chat to and fro... When I download and install the pywin stuff, then I am worse off - there is something wrong with the installation, and I am unable to work out what it is, as the error message I get is a bit cryptic - whenever the interpreter hits the statement: import win32file then I get the following exception: IDLE 1.1.3 ==== No Subprocess ==== >>> Traceback (most recent call last): File "E:\Python24\Tools\Scripts\junk1.py", line 1, in ? import win32file ImportError: DLL load failed: A device attached to the system is not functioning. >>> Now I have worked through the installation problems stuff on the Pywin site, and I can find no duplicate dlls. How do I figure out what it is that is missing or broken so that I can get it and install it? Is there a list of required files somewhere so that I can check? I am snookered... I would prefer to use the Linux OS exclusively, as I have had very little problems interfacing our device to the port - the interpreter is fast enough to handle a continuous stream of data at 38400 Baud without a hiccup - however - here in South Africa there are still a lot of machines out there running 95 and 98 - I assume (hopefully not incorrectly) that if it will run on 95 it will run on anything... Regards, - Hendrik van Rooyen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060504/6421606d/attachment.html From mhammond at skippinet.com.au Thu May 4 14:13:08 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 4 May 2006 22:13:08 +1000 Subject: [python-win32] missing or broken dll In-Reply-To: <004a01c66f6c$819f7520$03000080@hendrik> Message-ID: H J van Rooyen writes: > It works fine under Linux (/dev/ttys0) but under windoze 95 I am having no joy. ... > import win32file > >>> > Traceback (most recent call last): > File "E:\Python24\Tools\Scripts\junk1.py", line 1, in ? > import win32file > ImportError: DLL load failed: A device attached to the system is not functioning. > >>> Windows 95 hasn't been supported by pywin32 (or by Microsoft!) for a number of years. win32file still imports fine on Windows 98 though. Mark. From stefan.rank at ofai.at Thu May 4 15:56:31 2006 From: stefan.rank at ofai.at (Stefan Rank) Date: Thu, 04 May 2006 15:56:31 +0200 Subject: [python-win32] dualview/extended desktop settings with win32api In-Reply-To: References: Message-ID: <445A080F.7000608@ofai.at> on 04.05.2006 12:17 Roger Upole said the following: > Stefan Rank wrote: >> Hi, >> >> I am trying to write scripts for changing the "extended desktop" >> settings in windows. >> More specifically: I'd like to have a script for toggling between >> "laptop-screen-only" and >> "extended-desktop-with-the-secondary-monitor-bottom-right-and- >> please-don't-forget-the-arrangement-every-time-I-open-the-display-settings... >> grmph". >> >> AFAICT I need the GDI function `ChangeDisplaySettingsEx` and >> `EnumDisplayDevices` and some others. >> >> (see >> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/monitor_4zak.asp) >> >> win32api exposes ChangeDisplaySettings only. (and btw I am not sure how >> to use and manipulate the pyDEVMODE.Fields that EnumDisplaySettings >> returns, is there an example somewhere?). > > Fields is a bitmask indicating which members of the DEVMODE > are significant for a particular operation. Use a bitwise or of win32con.DM_* > flags. print_desktop.py in the demos directory uses it. Thanks for the pointer. >> I wanted to ask if there is a chance that these api parts will get into >> pywin32? >> Or if I wanted to add them myself, is there something that I missed that >> prevents adding it (and related structures) to win32apimodule.cpp ? >> > > These functions can certainly be added. It will take some extra work > (the usual LoadLibrary/GetProcAddress thing) since many of them > don't exist on WinNT. You can submit a feature request (or patch) > on SourceForge: http://sourceforge.net/projects/pywin32/ > > Roger I started with a feature request (1481844) for now... cheers, stefan From ilya at afortio.kiev.ua Fri May 5 18:12:24 2006 From: ilya at afortio.kiev.ua (Ilya Bobir) Date: Fri, 05 May 2006 19:12:24 +0300 Subject: [python-win32] win32com. Python long to VARIANT conversion patch. Message-ID: <445B7968.4020700@afortio.kiev.ua> Hello. I'm new to this thread, so please excuse me if this already been discussed or have already been patched. While working with COM I've noticed that sometimes Python long values does not convert correctly to COM VARIANT (I assumed that VT_{I4,UI4,I8,UI8,BSTR} should be used). I was able to workaround this problem in my case, but later, after reading conversion source, I've came to conclusion that it is possible to write a better conversion for this case (long -> VARIANT). Here is goes. This source was not tested, not even been compiled, because I don't have set environment to build and test. This is a draft that, I believe, could be of some use to someone else. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: oleargs.cpp.patch Url: http://mail.python.org/pipermail/python-win32/attachments/20060505/1a01ae7b/attachment.pot From ilya at afortio.kiev.ua Fri May 5 19:01:19 2006 From: ilya at afortio.kiev.ua (Ilya Bobir) Date: Fri, 05 May 2006 20:01:19 +0300 Subject: [python-win32] win32com. Python long to VARIANT conversion patch. In-Reply-To: <445B7968.4020700@afortio.kiev.ua> References: <445B7968.4020700@afortio.kiev.ua> Message-ID: <445B84DF.3060100@afortio.kiev.ua> Ilya Bobir wrote: > Hello. > > I'm new to this thread, so please excuse me if this already been > discussed or have already been patched. > > While working with COM I've noticed that sometimes Python long values > does not convert correctly to COM VARIANT (I assumed that > VT_{I4,UI4,I8,UI8,BSTR} should be used). I was able to workaround this > problem in my case, but later, after reading conversion source, I've > came to conclusion that it is possible to write a better conversion for > this case (long -> VARIANT). Here is goes. > > This source was not tested, not even been compiled, because I don't have > set environment to build and test. This is a draft that, I believe, > could be of some use to someone else. > Reference counter should be decreased. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: oleargs.cpp.patch Url: http://mail.python.org/pipermail/python-win32/attachments/20060505/3cb7262d/attachment.asc From reidar.hagen at gmail.com Sat May 6 15:43:44 2006 From: reidar.hagen at gmail.com (reidar) Date: Sat, 06 May 2006 15:43:44 +0200 Subject: [python-win32] ImportError: No module named system Message-ID: Hi Sorry if this is me being ignorant. Error: PythonWin 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2004 Mark Hammond (mhammond at skippinet.com.au) - see 'Help/About PythonWin' for further copyright information. >>> import os >>> import system Traceback (most recent call last): File "", line 1, in ? ImportError: No module named system >>> This probably happended after installing NumArray; but I'm not sure. My installation is probably not the cleanest after un-installing/installing various Numeric / NumArray / SciPy etc. I've been trying to get a program using GTK/Glade/matplotlib/Python running on windows, however this error got me a little stumped. Anybody got any ideas what's happening / would find it interesting to troubleshoot? .. or should I just try removing / re-installing everything? regards Reidar Strand Hagen From simon.dahlbacka at gmail.com Sat May 6 17:04:15 2006 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Sat, 6 May 2006 18:04:15 +0300 Subject: [python-win32] ImportError: No module named system In-Reply-To: References: Message-ID: <57124720605060804m775ba01fu8cc7b204b679f792@mail.gmail.com> what's system, or did you intend to import sys ? On 5/6/06, reidar wrote: > > Hi > > Sorry if this is me being ignorant. > > Error: > > PythonWin 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] > on win32. > Portions Copyright 1994-2004 Mark Hammond (mhammond at skippinet.com.au) - > see 'Help/About PythonWin' for further copyright information. > >>> import os > >>> import system > Traceback (most recent call last): > File "", line 1, in ? > ImportError: No module named system > >>> > > This probably happended after installing NumArray; but I'm not sure. My > installation is probably not the cleanest after un-installing/installing > various Numeric / NumArray / SciPy etc. I've been trying to get a program > using GTK/Glade/matplotlib/Python running on windows, however this error > got me a little stumped. > > Anybody got any ideas what's happening / would find it interesting to > troubleshoot? .. or should I just try removing / re-installing everything? > > regards > Reidar Strand Hagen > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060506/9ee1069c/attachment.html From reidar.hagen at gmail.com Sat May 6 17:15:17 2006 From: reidar.hagen at gmail.com (reidar) Date: Sat, 06 May 2006 17:15:17 +0200 Subject: [python-win32] ImportError: No module named system In-Reply-To: References: Message-ID: Thanks for two direct replies I got. system is ofc a directory in the actual application. Having sat for too much time fiddling with third-party stuff my brain was fried :) On Sat, 06 May 2006 15:43:44 +0200, reidar wrote: > Hi > > Sorry if this is me being ignorant. > > Error: > > PythonWin 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] > on win32. > Portions Copyright 1994-2004 Mark Hammond (mhammond at skippinet.com.au) - > see 'Help/About PythonWin' for further copyright information. >>>> import os >>>> import system > Traceback (most recent call last): > File "", line 1, in ? > ImportError: No module named system >>>> > > This probably happended after installing NumArray; but I'm not sure. My > installation is probably not the cleanest after un-installing/installing > various Numeric / NumArray / SciPy etc. I've been trying to get a > program using GTK/Glade/matplotlib/Python running on windows, however > this error got me a little stumped. > > Anybody got any ideas what's happening / would find it interesting to > troubleshoot? .. or should I just try removing / re-installing > everything? > > regards > Reidar Strand Hagen -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ From mhammond at skippinet.com.au Sun May 7 01:57:34 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 7 May 2006 09:57:34 +1000 Subject: [python-win32] win32com. Python long to VARIANT conversion patch. In-Reply-To: <445B7968.4020700@afortio.kiev.ua> Message-ID: > I'm new to this thread, so please excuse me if this already been > discussed or have already been patched. > > While working with COM I've noticed that sometimes Python long values > does not convert correctly to COM VARIANT (I assumed that > VT_{I4,UI4,I8,UI8,BSTR} should be used). Can you give me an example of code which causes a bad conversion? Cheers, Mark From mc at mclaveau.com Mon May 8 09:10:20 2006 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 8 May 2006 09:10:20 +0200 Subject: [python-win32] Problem to call COM-dynamic-server References: Message-ID: <004201c6726e$7cda2d00$0701a8c0@PORTABLES> Hello, all ! I have a problem, when I "dispatch" a dynamic server (writed with Pywin32). When I call an instance method (with points in the name), the server receive, like wFlags, pythoncom.DISPATCH_PROPERTYGET, instead of pythoncom.DISPATCH_METHOD. For the call of a property of a class, it's OK (good call, answer OK). But, for a method, it's bad. (the type of the called-object is , and the Python call ask a property). Here, a traceback : pythoncom error: Python error invoking COM method. exceptions.TypeError: Objects of type 'instancemethod' can not be converted to a COM VARIANT Traceback (most recent call last): File "D:\dev\python\Ponxwscript.py", line 45, in ? vret=px.word___version() File "C:\Python24\lib\site-packages\win32com\client\dynamic.py", line 491, in __getattr__ raise pythoncom.com_error, details pywintypes.com_error: (-2147352567, "Une exception s'est produite.", (0, 'Python COM Server Internal Error', "Unexpected Python Error: exceptions.TypeError: Obj ects of type 'instancemethod' can not be converted to a COM VARIANT", None, 0, - 2147467259), None) I had try to force the return of a value (in the server). Result : Traceback (most recent call last): File "D:\dev\python\Ponxwscript.py", line 45, in ? vret=px.word___version() TypeError: 'unicode' object is not callable I had, also, try dispatch, dispatchEx, .dynamic.Dispatch, etc. Same result. I hope that my English will have been comprehensible. An idea? Thanks by advance. Michel Claveau From mhammond at skippinet.com.au Mon May 8 11:27:26 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 8 May 2006 19:27:26 +1000 Subject: [python-win32] Problem to call COM-dynamic-server In-Reply-To: <004201c6726e$7cda2d00$0701a8c0@PORTABLES> Message-ID: I'm afraid that without working code I can only guess... > Here, a traceback : > > pythoncom error: Python error invoking COM method. > > exceptions.TypeError: Objects of type 'instancemethod' can not be > converted > to a > COM VARIANT > Traceback (most recent call last): > File "D:\dev\python\Ponxwscript.py", line 45, in ? > vret=px.word___version() > File > "C:\Python24\lib\site-packages\win32com\client\dynamic.py", line 491, > in > __getattr__ > raise pythoncom.com_error, details > pywintypes.com_error: (-2147352567, "Une exception s'est produite.", (0, > 'Python > COM Server Internal Error', "Unexpected Python Error: > exceptions.TypeError: > Obj > ects of type 'instancemethod' can not be converted to a COM > VARIANT", None, > 0, - > 2147467259), None) That looks like your COM server has a method with the same name as a property. > Traceback (most recent call last): > File "D:\dev\python\Ponxwscript.py", line 45, in ? > vret=px.word___version() > TypeError: 'unicode' object is not callable That simply means that px.word___version is already unicode, but you are trying to call it. > I hope that my English will have been comprehensible. Yep - but I'm afraid you haven't provided enough technical context though (at least for my time-starved email life :) Please post the complete source for the *smallest possible* server and client that demonstrates your problem... Mark From mc at mclaveau.com Mon May 8 12:00:55 2006 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 8 May 2006 12:00:55 +0200 Subject: [python-win32] Problem to call COM-dynamic-server References: Message-ID: <000401c67286$4edf77d0$0701a8c0@PORTABLES> Re-Hi! >>> Please post the complete source for the *smallest possible* server and >>> client that demonstrates your problem... OK. But my original source has more than 7000 lines. That will take a certain time (that is added to my work). For info, the call of the instance-methods run correctly with ObjectPal(Paradox), but not with Python, nor with VBscript/JScript. With later (a few days) Michel Claveau From mhammond at skippinet.com.au Mon May 8 14:25:44 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 8 May 2006 22:25:44 +1000 Subject: [python-win32] Problem to call COM-dynamic-server In-Reply-To: <000401c67286$4edf77d0$0701a8c0@PORTABLES> Message-ID: > >>> Please post the complete source for the *smallest possible* > >>> server and client that demonstrates your problem... > > OK. > But my original source has more than 7000 lines. > That will take a certain time (that is added to my work). Welcome to my world! :) > For info, the call of the instance-methods run correctly with > ObjectPal(Paradox), but not with Python, nor with VBscript/JScript. That implies a problem distinguishing between a property and method - try googling for _FlagAsMethod and/or ERRORS_BAD_CONTEXT - both can be found in win32com.client.dynamic Cheers, Mark From mli at deform.com Mon May 8 15:38:32 2006 From: mli at deform.com (Michael Li) Date: Mon, 08 May 2006 09:38:32 -0400 Subject: [python-win32] how to only accept local computer requests In-Reply-To: References: Message-ID: <445F49D8.6080709@deform.com> Hi, I have a python server with twisted framework running 24x7. I want to have a config file to setup accepting local computer requests or remote computer requests. If the config file exists, it only accepts local computer request, does not accept requests from other computers. If the config file does not exist, it accepts requests from any computers. Is there any easy way to do it ? Best regards. Michael Li ========== This email message and any attachments are for the sole use of the intended recipients and may contain proprietary and/or confidential information which may be privileged or otherwise protected from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipients, please contact the sender by reply email and destroy the original message and any copies of the message as well as any attachments to the original message. From gagsl-p32 at yahoo.com.ar Mon May 8 22:36:11 2006 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 08 May 2006 17:36:11 -0300 Subject: [python-win32] how to only accept local computer requests In-Reply-To: <445F49D8.6080709@deform.com> References: <445F49D8.6080709@deform.com> Message-ID: <7.0.1.0.0.20060508172915.038883c8@yahoo.com.ar> At Monday 8/5/2006 10:38, Michael Li wrote: >I have a python server with twisted framework running >24x7. I want to have a config file to setup accepting local >computer requests or remote computer requests. >If the config file exists, it only accepts local computer >request, does not accept requests from other computers. >If the config file does not exist, it accepts requests >from any computers. >Is there any easy way to do it ? To see if the config file exists, use os.path.isfile(filename) To enable only local connections to your server, see the Twisted documentation. Gabriel Genellina Softlab SRL _________________________________________________________ Horóscopos, Salud y belleza, Chistes, Consejos de amor: el contenido más divertido para tu celular está en Yahoo! Móvil. Obtenelo en http://movil.yahoo.com.ar From durumdara at mailpont.hu Tue May 9 15:03:24 2006 From: durumdara at mailpont.hu (Christian Stooker) Date: Tue, 09 May 2006 15:03:24 +0200 Subject: [python-win32] Why I get wrong filetime values with win32 api (FindFilesW) ? Message-ID: <4460931C.20605@mailpont.hu> Hi ! I need to get filelists from many HDD-s with more props. of files. I used FindFilesW to get these informations. But I have a problems with it. When I used Find_Data tuple, and it's atime,ctime,mtime props, I get wrong result. I have hungarian Windows (XP), so little time diff. I have. These method I use to get local time: timeval=localtime(int(pytime)) pv=strftime('%Y.%m.%d %H:%M:%S',timeval) pytime is a PyTime object that I get from the tuple. When I use it, it is shows 2 hours lesser than normal file time (Total Commander, File explorer). Example: it shows 18:54, but I have 20:54. When I modify the getting proc the time informations to: pytime=localtime(os.path.getctime(afile)) I get good result. What I do wrong ? Please help me: dd From sidnei at awkly.org Tue May 9 16:50:41 2006 From: sidnei at awkly.org (Sidnei da Silva) Date: Tue, 9 May 2006 11:50:41 -0300 Subject: [python-win32] Getting localized account name from RID Message-ID: <20060509145041.GA4614@cotia> I need to get the localized account name for "BUILTIN\Users", which afaict maps to ntsecuritycon.DOMAIN_ALIAS_RID_USERS. But, given that, how do I get from the RID to the SID? (or to the account name which is what I want anyway). I've found the following article, but my C is not good enough to parse that. http://support.microsoft.com/default.aspx?kbid=157234 -- Sidnei da Silva Enfold Systems http://enfoldsystems.com Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214 From mhammond at skippinet.com.au Wed May 10 03:51:12 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 10 May 2006 11:51:12 +1000 Subject: [python-win32] Getting localized account name from RID In-Reply-To: <20060509145041.GA4614@cotia> Message-ID: Hi Sid, > I need to get the localized account name for "BUILTIN\Users", which > afaict maps to ntsecuritycon.DOMAIN_ALIAS_RID_USERS. But, given that, > how do I get from the RID to the SID? (or to the account name which is > what I want anyway). > > I've found the following article, but my C is not good enough to parse > that. > http://support.microsoft.com/default.aspx?kbid=157234 As you are trying to work with some code of mine that is broken on non-English systems, I figured I should do my bit :) Below is a port of that KB article to Python. If cvs on sourceforge wasn't giving me trouble, it would already be checked in as win32\Demos\security\localized_names.py Cheers, Mark. # A Python port of the MS knowledge base article Q157234 # "How to deal with localized and renamed user and group names" # http://support.microsoft.com/default.aspx?kbid=157234 import sys from win32net import NetUserModalsGet from win32security import LookupAccountSid import pywintypes from ntsecuritycon import * def LookupAliasFromRid(TargetComputer, Rid): # Sid is the same regardless of machine, since the well-known # BUILTIN domain is referenced. sid = pywintypes.SID() sid.Initialize(SECURITY_NT_AUTHORITY, 2) for i, r in enumerate((SECURITY_BUILTIN_DOMAIN_RID, Rid)): sid.SetSubAuthority(i, r) name, domain, typ = LookupAccountSid(TargetComputer, sid) return name def LookupUserGroupFromRid(TargetComputer, Rid): # get the account domain Sid on the target machine # note: if you were looking up multiple sids based on the same # account domain, only need to call this once. umi2 = NetUserModalsGet(TargetComputer, 2) domain_sid = umi2['domain_id'] SubAuthorityCount = domain_sid.GetSubAuthorityCount() # create and init new sid with acct domain Sid + acct Rid sid = pywintypes.SID() sid.Initialize(domain_sid.GetSidIdentifierAuthority(), SubAuthorityCount+1) # copy existing subauthorities from account domain Sid into # new Sid for i in range(SubAuthorityCount): sid.SetSubAuthority(i, domain_sid.GetSubAuthority(i)) # append Rid to new Sid sid.SetSubAuthority(SubAuthorityCount, Rid) name, domain, typ = LookupAccountSid(TargetComputer, sid) return name def main(): if len(sys.argv) == 2: targetComputer = sys.argv[1] else: targetComputer = None name = LookupUserGroupFromRid(targetComputer, DOMAIN_USER_RID_ADMIN) print "'Administrator' user name = %s" % (name,) name = LookupAliasFromRid(targetComputer, DOMAIN_ALIAS_RID_ADMINS) print "'Administrators' local group/alias name = %s" % (name,) if __name__=='__main__': main() From mhammond at skippinet.com.au Wed May 10 04:11:48 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 10 May 2006 12:11:48 +1000 Subject: [python-win32] Why I get wrong filetime values with win32 api(FindFilesW) ? In-Reply-To: <4460931C.20605@mailpont.hu> Message-ID: > I need to get filelists from many HDD-s with more props. of files. > I used FindFilesW to get these informations. > > But I have a problems with it. > When I used Find_Data tuple, and it's atime,ctime,mtime props, I get > wrong result. > > I have hungarian Windows (XP), so little time diff. I have. > > These method I use to get local time: > > timeval=localtime(int(pytime)) > pv=strftime('%Y.%m.%d %H:%M:%S',timeval) > > pytime is a PyTime object that I get from the tuple. I'm guessing it is related to the GMT offset. The MSDN docs for the FILETIME structure say: Furthermore, FAT records times on disk in local time. However, NTFS records times on disk in UTC. For more information ... Otherwise I'm afraid I have no idea... Mark From mc at mclaveau.com Wed May 10 07:40:18 2006 From: mc at mclaveau.com (Michel Claveau) Date: Wed, 10 May 2006 07:40:18 +0200 Subject: [python-win32] Problem to call COM-dynamic-server ; resolved References: Message-ID: <000d01c673f4$39f611c0$0701a8c0@PORTABLES> Hi! (*sorry, but translate with Babelfish help*, because my english is too bad) I finally solved my problem, by intercepting/modifying several things on the server side. However, several information could be useful for you: - The calls with multiple points are refused by Python. example: objcom.bib.klass.meth(x... give an error. I circumvented the problem by replacing the point by triple quotation mark (. => ___) intercepted by the server, at the time of the call, and before treatment. - Some languages convert all the calls (properties, functions, methods) in capital letters. It is necessary to adapt consequently the server. - the mechanics of the double call: 1) property (DISPATCH_PROPERTYGET; wFlags=2) => error, non-exist 2) then, method/function (DISPATCH_METHOD; wFlags=1) called at the second call run only with some languages (include Python). VBscript, Jscript, AutoIt, etc. work differently: wFlags is worth 3 (DISPATCH_PROPERTYGET + DISPATCH_METHOD). it is necessary to adapt the server for that. - the type of instance-method is types.MethodType (I had made an error on this aspect). @-salutations -- Michel Claveau From billburns at pennswoods.net Thu May 11 04:46:48 2006 From: billburns at pennswoods.net (Bill Burns) Date: Wed, 10 May 2006 22:46:48 -0400 Subject: [python-win32] Outlook Addin Help Message-ID: <4462A598.7040009@pennswoods.net> Hello, I've created an addin derived from the example in the ..\win32com\demos directory (outlookAddin.py). I've also taken a look at the source code for the SpamBayes addin. The addin works, but I get an error from Outlook when I close Outlook and then *immediately* try and restart it. The error from Outlook is "The operation failed." If I wait for a few seconds (after closing Outlook) and then restart it; I don't get the error message. I believe that Outlook is trying to "clean-up" the mess I've made in the addin and is not going to restart until it has done so :-) I've probably made some newbie mistakes. I'm not that good at this stuff, just yet! I'm using Office Outlook 2003 (11.5608.5606), no service packs. I get the error on Windows 2000 Pro SP4 and WinXP SP2. I'm using Python 2.4.3 and Pywin32 build 208. I didn't know if was appropriate to paste the entire piece of code to the list, so I've pasted it here: http://rafb.net/paste/results/ub5zwn45.html I'd appreciate any help!! Thanks, Bill From durumdara at mailpont.hu Thu May 11 09:47:54 2006 From: durumdara at mailpont.hu (Christian Stooker) Date: Thu, 11 May 2006 09:47:54 +0200 Subject: [python-win32] Why I get wrong filetime values with win32 api(FindFilesW) ? In-Reply-To: References: Message-ID: <4462EC2A.3040303@mailpont.hu> Mark Hammond ?rta: > I'm guessing it is related to the GMT offset. The MSDN docs for the > FILETIME structure say: > > Furthermore, FAT records times on disk in local time. However, > NTFS records times on disk in UTC. For more information ... > > Otherwise I'm afraid I have no idea... > > Mark > > Hi ! As I say: interesting, because os.get*time functions get good result for the files. #################################################### import os,sys,win32file,win32api,time uFiles=win32file.FindFilesW(os.path.join(os.getcwd(),'*')) for uFile in uFiles: fullfn=os.path.join(os.getcwd(),uFile[8]) #fullfn=win32api.GetShortPathName(fullfn) #print [fullfn] if os.path.isfile(fullfn): print [fullfn] w32modtime=uFile[3] osmodtime=os.path.getmtime(fullfn) print "pw32",int(w32modtime) print "pyos",osmodtime print "pw32",time.asctime((time.localtime(int(w32modtime)))) print "pyos",time.asctime((time.localtime(osmodtime))) #################################################### Commandline: C:\Python24\python.exe g:\TESTFI~1.PY Workingdirectory: g:\ Timeout: 0 ms [u'g:\\AH.odt'] pw32 1137145550 pyos 1137152750 pw32 Fri Jan 13 10:45:50 2006 pyos Fri Jan 13 12:45:50 2006 [u'g:\\Depeche Lyrics.odt'] pw32 1143800308 pyos 1143807508 pw32 Fri Mar 31 12:18:28 2006 pyos Fri Mar 31 14:18:28 2006 [u'g:\\KFJ.xcf'] pw32 1145886140 pyos 1145893340 pw32 Mon Apr 24 15:42:20 2006 pyos Mon Apr 24 17:42:20 2006 [u'g:\\KFJ.jpg'] pw32 1145886156 pyos 1145893356 pw32 Mon Apr 24 15:42:36 2006 pyos Mon Apr 24 17:42:36 2006 [u'g:\\KFJ2.xcf'] pw32 1145886504 pyos 1145893704 pw32 Mon Apr 24 15:48:24 2006 pyos Mon Apr 24 17:48:24 2006 [u'g:\\KFJ2.jpg'] pw32 1145886530 pyos 1145893730 pw32 Mon Apr 24 15:48:50 2006 pyos Mon Apr 24 17:48:50 2006 [u'g:\\Megasztar.odt'] pw32 1146226088 pyos 1146233288 pw32 Fri Apr 28 14:08:08 2006 pyos Fri Apr 28 16:08:08 2006 [u'g:\\fastpython.html'] pw32 1147008590 pyos 1147015790 pw32 Sun May 07 15:29:50 2006 pyos Sun May 07 17:29:50 2006 [u'g:\\PerformanceTips.htm'] pw32 1147008540 pyos 1147015740 pw32 Sun May 07 15:29:00 2006 pyos Sun May 07 17:29:00 2006 [u'g:\\[wxPython-users] How to force GenericDirCtrl to show hidden and system files and dirs.html'] pw32 1147089932 pyos 1147097132 pw32 Mon May 08 14:05:32 2006 pyos Mon May 08 16:05:32 2006 [u'g:\\000372.html'] pw32 1143205264 pyos 1143212464 pw32 Fri Mar 24 14:01:04 2006 pyos Fri Mar 24 16:01:04 2006 [u'g:\\example1.html'] pw32 1143635508 pyos 1143642708 pw32 Wed Mar 29 14:31:48 2006 pyos Wed Mar 29 16:31:48 2006 [u'g:\\gml-tr.html'] pw32 1143462646 pyos 1143469846 pw32 Mon Mar 27 14:30:46 2006 pyos Mon Mar 27 16:30:46 2006 [u'g:\\index.php.htm'] pw32 1143205404 pyos 1143212604 pw32 Fri Mar 24 14:03:24 2006 pyos Fri Mar 24 16:03:24 2006 [u'g:\\tlprenderManual.html'] pw32 1143635836 pyos 1143643036 pw32 Wed Mar 29 14:37:16 2006 pyos Wed Mar 29 16:37:16 2006 [u'g:\\usage.html'] pw32 1145880100 pyos 1145887300 pw32 Mon Apr 24 14:01:40 2006 pyos Mon Apr 24 16:01:40 2006 [u'g:\\testfiletimes.py'] pw32 1147326262 pyos 1147333462 pw32 Thu May 11 07:44:22 2006 pyos Thu May 11 09:44:22 2006 Process "Pyhton Interpeter" terminated, ExitCode: 00000000 #################################################### As you can see, the different is two hours. We are in GMT+01 timezone, and I use NTFS and WXP. I hope this help to find a bug, or get the solution. dd From andrew.markebo at comhem.se Thu May 11 12:03:29 2006 From: andrew.markebo at comhem.se (Andrew Markebo) Date: Thu, 11 May 2006 12:03:29 +0200 Subject: [python-win32] Loading a and running from a dll runtime? Message-ID: Hello! My question is... Is it possible to load and execute the code in a dll from PythonWin? I have found the function LoadLibrary, but how do I check the contents, and so on in the dll? Or should I use swig or similar? /Andy -- Remember don't look at the palm, look into it! From p.f.moore at gmail.com Thu May 11 12:25:41 2006 From: p.f.moore at gmail.com (Paul Moore) Date: Thu, 11 May 2006 11:25:41 +0100 Subject: [python-win32] Loading a and running from a dll runtime? In-Reply-To: References: Message-ID: <79990c6b0605110325w550bf137r9fa3dd950d6542cf@mail.gmail.com> On 5/11/06, Andrew Markebo wrote: > My question is... Is it possible to load and execute the code in a dll > from PythonWin? > > I have found the function LoadLibrary, but how do I check the > contents, and so on in the dll? I don't think this is possible within pywin32 (I'm sure Mark will correct me if I'm wrong!) > Or should I use swig or similar? To do this at runtime, you might look at ctypes (which is at http://starship.python.net/crew/theller/ctypes/, or if you wait for Python 2.5, it will be in the standard library). Swig allows you to build a wrapper around a DLL (pyrex can be used in a similar manner), and is more of a "compile-time" approach. Hope this helps. Paul. From sjmachin at lexicon.net Thu May 11 12:35:19 2006 From: sjmachin at lexicon.net (John Machin) Date: Thu, 11 May 2006 20:35:19 +1000 Subject: [python-win32] Why I get wrong filetime values with win32 api(FindFilesW) ? In-Reply-To: <4462EC2A.3040303@mailpont.hu> References: <4462EC2A.3040303@mailpont.hu> Message-ID: <44631367.3050608@lexicon.net> On 11/05/2006 5:47 PM, Christian Stooker wrote: > Mark Hammond ?rta: >> I'm guessing it is related to the GMT offset. The MSDN docs for the >> FILETIME structure say: >> >> Furthermore, FAT records times on disk in local time. However, >> NTFS records times on disk in UTC. For more information ... >> >> Otherwise I'm afraid I have no idea... >> >> Mark >> >> > > Hi ! > > As I say: interesting, because os.get*time functions get good result for > the files. [snip] > > As you can see, the different is two hours. > We are in GMT+01 timezone, Call me crazy, but the Brits are on summer time (UTC+1) and you should be on CEST (Central Europe Summer Time) (UTC+2). Check this out: http://www.timeanddate.com/worldclock/city.html?n=50 > and I use NTFS and WXP. > Here's what I got with your code, with NTFS, in eastern Australia (UTC+10), local time is after 8 p.m. C:\junk\winfiletime>winfiletime.py [u'C:\\junk\\winfiletime\\winfiletime.py'] pw32 1147306617 pyos 1147342617 pw32 Thu May 11 10:16:57 2006 pyos Thu May 11 20:16:57 2006 As expected. From stefan.rank at ofai.at Thu May 11 13:05:21 2006 From: stefan.rank at ofai.at (Stefan Rank) Date: Thu, 11 May 2006 13:05:21 +0200 Subject: [python-win32] dualview/extended desktop settings with win32api In-Reply-To: <445A080F.7000608@ofai.at> References: <445A080F.7000608@ofai.at> Message-ID: <44631A71.50504@ofai.at> on 04.05.2006 15:56 Stefan Rank said the following: > on 04.05.2006 12:17 Roger Upole said the following: >> Stefan Rank wrote: >>> AFAICT I need the GDI function `ChangeDisplaySettingsEx` and >>> `EnumDisplayDevices` and some others. >> These functions can certainly be added. It will take some extra work >> (the usual LoadLibrary/GetProcAddress thing) since many of them >> don't exist on WinNT. You can submit a feature request (or patch) >> on SourceForge: http://sourceforge.net/projects/pywin32/ >> >> Roger > > I started with a feature request (1481844) for now... And I followed up with a patch. see http://sourceforge.net/tracker/index.php?func=detail&aid=1481844&group_id=78018&atid=551957 But I did not do any tricks that depend on the windows version. See my comments in the tracker. I am not sure, and I can't test, if there needs to be some extra magic. cheers, stefan From mhammond at skippinet.com.au Thu May 11 14:53:47 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 11 May 2006 22:53:47 +1000 Subject: [python-win32] Outlook Addin Help In-Reply-To: <4462A598.7040009@pennswoods.net> Message-ID: > I've created an addin derived from the example in the ..\win32com\demos > directory (outlookAddin.py). I've also taken a look at the source code > for the SpamBayes addin. > > The addin works, but I get an error from Outlook when I close Outlook > and then *immediately* try and restart it. The error from Outlook > is "The operation failed." Outlook is fairly complicated ;) Depending on how it is configured, a mapisp32.exe, responsible for mail delivery, does hang around a few seconds after outlook terminates, and I recall problems restarting Outlook in this period even without a plugin loaded. Thus, I'm afraid I don't believe this is specific to Python (ie, I've no idea! :) If some evidence does convince me otherwise, I'd then start looking at what pythoncom._GetGatewayCount() and/or _GetInterfaceCount() returns as the plugin terminates and ensure they are both zero before looking deeper (spambayes has never managed zero here - IIRC it is the gateway count that is always 2). Cheers, Mark From billburns at pennswoods.net Thu May 11 16:05:46 2006 From: billburns at pennswoods.net (billburns at pennswoods.net) Date: Thu, 11 May 2006 10:05:46 -0400 Subject: [python-win32] Outlook Addin Help In-Reply-To: References: Message-ID: <1147356346.446344ba7397e@webmail.pennswoods.net> [Bill] I've created an addin derived from the example in the ..\win32com\demos directory (outlookAddin.py). I've also taken a look at the source code for the SpamBayes addin. The addin works, but I get an error from Outlook when I close Outlook and then *immediately* try and restart it. The error from Outlook is "The operation failed." [Mark] Outlook is fairly complicated ;) Depending on how it is configured, a mapisp32.exe, responsible for mail delivery, does hang around a few seconds after outlook terminates, and I recall problems restarting Outlook in this period even without a plugin loaded. Thus, I'm afraid I don't believe this is specific to Python (ie, I've no idea! :) If some evidence does convince me otherwise, I'd then start looking at what pythoncom._GetGatewayCount() and/or _GetInterfaceCount() returns as the plugin terminates and ensure they are both zero before looking deeper (spambayes has never managed zero here - IIRC it is the gateway count that is always 2). Mark, Thank you for the information! I've changed "OnDisconnection()" to look like this, def OnDisconnection(self, mode, custom): self.application = None self.activeExplorer = None print "Gateway Count: ", pythoncom._GetGatewayCount() print "Interface Count: ", pythoncom._GetInterfaceCount() and the Trace Collector output is, Object with win32trace dispatcher created (object=None) Gateway Count: 2 Interface Count: 4 Is there something I should try to get the Interface Count down to zero? Thanks again for your help!! Bill From billburns at pennswoods.net Thu May 11 19:24:17 2006 From: billburns at pennswoods.net (billburns at pennswoods.net) Date: Thu, 11 May 2006 13:24:17 -0400 Subject: [python-win32] Outlook Addin Help In-Reply-To: <1147356346.446344ba7397e@webmail.pennswoods.net> References: <1147356346.446344ba7397e@webmail.pennswoods.net> Message-ID: <1147368257.4463734154a3a@webmail.pennswoods.net> [Bill] I've created an addin derived from the example in the ..\win32com\demos directory (outlookAddin.py). I've also taken a look at the source code for the SpamBayes addin. The addin works, but I get an error from Outlook when I close Outlook and then *immediately* try and restart it. The error from Outlook is "The operation failed." [Mark] Outlook is fairly complicated ;) Depending on how it is configured, a mapisp32.exe, responsible for mail delivery, does hang around a few seconds after outlook terminates, and I recall problems restarting Outlook in this period even without a plugin loaded. Thus, I'm afraid I don't believe this is specific to Python (ie, I've no idea! :) If some evidence does convince me otherwise, I'd then start looking at what pythoncom._GetGatewayCount() and/or _GetInterfaceCount() returns as the plugin terminates and ensure they are both zero before looking deeper (spambayes has never managed zero here - IIRC it is the gateway count that is always 2). [Bill] I've changed "OnDisconnection()" to look like this, def OnDisconnection(self, mode, custom): self.application = None self.activeExplorer = None print "Gateway Count: ", pythoncom._GetGatewayCount() print "Interface Count: ", pythoncom._GetInterfaceCount() and the Trace Collector output is, Object with win32trace dispatcher created (object=None) Gateway Count: 2 Interface Count: 4 Is there something I should try to get the Interface Count down to zero? Mark, You've pushed me in the right direction -> the interface count. I've done some digging and I'm getting closer :-) I've gone from a count of 4 down to 2. I guess I need to make sure that I'm releasing certain objects within the addin. I added a Close() method to the ButtonEvent which sets self.application and self.activeExplorer to None. I'll keep at it and work on it later tonight. Thanks again, Bill From timr at probo.com Thu May 11 18:43:28 2006 From: timr at probo.com (Tim Roberts) Date: Thu, 11 May 2006 09:43:28 -0700 Subject: [python-win32] Why I get wrong filetime values with win32 api(FindFilesW) ? In-Reply-To: References: Message-ID: <446369B0.8030605@probo.com> On Thu, 11 May 2006 09:47:54 +0200, Christian Stooker wrote: >Hi ! > >As I say: interesting, because os.get*time functions get good result for >the files. > > They BOTH return good results. They just use different time bases. >#################################################### >import os,sys,win32file,win32api,time > >uFiles=win32file.FindFilesW(os.path.join(os.getcwd(),'*')) > >for uFile in uFiles: > fullfn=os.path.join(os.getcwd(),uFile[8]) > #fullfn=win32api.GetShortPathName(fullfn) > #print [fullfn] > if os.path.isfile(fullfn): > print [fullfn] > w32modtime=uFile[3] > osmodtime=os.path.getmtime(fullfn) > print "pw32",int(w32modtime) > print "pyos",osmodtime > print "pw32",time.asctime((time.localtime(int(w32modtime)))) > print "pyos",time.asctime((time.localtime(osmodtime))) >#################################################### > ... > >As you can see, the different is two hours. >We are in GMT+01 timezone, and I use NTFS and WXP. > You are in CET, right? That's nominally GMT+01, but you are currently in summer time, which makes it GMT+02. >I hope this help to find a bug, or get the solution. > > Mark told you the answer. This is not a bug. os.path.getmtime returns your local time, and the FindFiles API returns GMT. If you need to compare the two, you will have to subtract your timezone offset: print "pw32",time.asctime(time.localtime(int(w32modtime)-time.altzone)) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From andrew.markebo at comhem.se Fri May 12 00:34:16 2006 From: andrew.markebo at comhem.se (Andrew Markebo) Date: Fri, 12 May 2006 00:34:16 +0200 Subject: [python-win32] Loading a and running from a dll runtime? In-Reply-To: <79990c6b0605110325w550bf137r9fa3dd950d6542cf@mail.gmail.com> (Paul Moore's message of "Thu, 11 May 2006 11:25:41 +0100") References: <79990c6b0605110325w550bf137r9fa3dd950d6542cf@mail.gmail.com> Message-ID: /------------------------------ | |> Or should I use swig or similar? | | To do this at runtime, you might look at ctypes (which is at | http://starship.python.net/crew/theller/ctypes/, or if you wait for | Python 2.5, it will be in the standard library). I tried to use Ctypes talking to LabVIEW earlier, but there were some complexities that couldn't be solved, and well swig works because it is loading the same dll all of the time | | Swig allows you to build a wrapper around a DLL (pyrex can be used in | a similar manner), and is more of a "compile-time" approach. /Andy -- My eyes, they rest on a beaut.., ehm.. some code I am debugging. From mhammond at skippinet.com.au Fri May 12 00:46:33 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 12 May 2006 08:46:33 +1000 Subject: [python-win32] Outlook Addin Help In-Reply-To: <1147356346.446344ba7397e@webmail.pennswoods.net> Message-ID: > Object with win32trace dispatcher created (object=None) > Gateway Count: 2 > Interface Count: 4 > > Is there something I should try to get the Interface Count down to zero? In Spambayes, I previously tried everything I could think of to locate them. I guess additional analysis is necessary to determine exactly what objects they are before we can determine how to kill them. Mark From billburns at pennswoods.net Fri May 12 16:33:09 2006 From: billburns at pennswoods.net (Bill Burns) Date: Fri, 12 May 2006 10:33:09 -0400 Subject: [python-win32] Outlook Addin Help In-Reply-To: References: Message-ID: <44649CA5.6050107@pennswoods.net> >>Object with win32trace dispatcher created (object=None) >>Gateway Count: 2 >>Interface Count: 4 >> >>Is there something I should try to get the Interface Count down to zero? > > > In Spambayes, I previously tried everything I could think of to locate them. > I guess additional analysis is necessary to determine exactly what objects > they are before we can determine how to kill them. I was able to kill some of the objects by adding this code to the ButtonEvent, def Close(self): self.application = None self.activeExplorer = None self.close() now I get the following output: Object with win32trace dispatcher created (object=None) Gateway Count: 1 Interface Count: 1 I'll keep "tooling" around with it.... Bill From bwmetz at att.com Fri May 12 17:16:03 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Fri, 12 May 2006 10:16:03 -0500 Subject: [python-win32] Outlook Addin Help In-Reply-To: <44649CA5.6050107@pennswoods.net> Message-ID: <01D5341D04A2E64AB9B345769047336701C56C55@OCCLUST01EVS1.ugd.att.com> Do you by chance still have a reference to the MAPI namespace open or maybe some folder or item you referenced during execution? -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Bill Burns Sent: Friday, May 12, 2006 7:33 AM To: Mark Hammond Cc: python-win32 at python.org Subject: Re: [python-win32] Outlook Addin Help >>Object with win32trace dispatcher created (object=None) >>Gateway Count: 2 >>Interface Count: 4 >> >>Is there something I should try to get the Interface Count down to zero? > > > In Spambayes, I previously tried everything I could think of to locate them. > I guess additional analysis is necessary to determine exactly what objects > they are before we can determine how to kill them. I was able to kill some of the objects by adding this code to the ButtonEvent, def Close(self): self.application = None self.activeExplorer = None self.close() now I get the following output: Object with win32trace dispatcher created (object=None) Gateway Count: 1 Interface Count: 1 I'll keep "tooling" around with it.... Bill _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From billburns at pennswoods.net Fri May 12 18:33:56 2006 From: billburns at pennswoods.net (Bill Burns) Date: Fri, 12 May 2006 12:33:56 -0400 Subject: [python-win32] Outlook Addin Help In-Reply-To: <01D5341D04A2E64AB9B345769047336701C56C55@OCCLUST01EVS1.ugd.att.com> References: <01D5341D04A2E64AB9B345769047336701C56C55@OCCLUST01EVS1.ugd.att.com> Message-ID: <4464B8F4.70906@pennswoods.net> [Bobby] > Do you by chance still have a reference to the MAPI namespace open or > maybe some folder or item you referenced during execution? Maybe, I'm still getting the hang of this Windows programming thing :-) I do have references to -> the CurrentFolder, Sent Mail Folder and SentMail Items and I don't believe I'm explicitly closing/releasing or deleting these references anywhere in my code. Most of my addin is virtually the same as outlookAddin.py (...\site-packages\win32com\demos\outlookAddin.py) *but* my ButtonEvent looks like this: class ButtonEvent: def Init(self, application, activeExplorer): self.application = application self.activeExplorer = activeExplorer def Close(self): self.application = None self.activeExplorer = None self.close() def OnClick(self, button, cancel): locale.setlocale(locale.LC_NUMERIC, "C") # Get the ID of the folder we're currently in. currentFolder = self.activeExplorer.CurrentFolder currentFolderID = \ currentFolder.Parent.StoreID, currentFolder.EntryID # Get the ID of the 'Sent Items' folder. sentFolder = \ self.application.Session.GetDefaultFolder(constants.olFolderSentMail) sentFolderID = sentFolder.Parent.StoreID, sentFolder.EntryID # If we're in the 'Sent Items'... if currentFolderID[1] == sentFolderID[1]: self.getSentEmailInfo() else: # We're not in 'Sent Items'. self.folderError() def getSentEmailInfo(self): sentMailItem = self.activeExplorer.Selection.Item(1) try: To = sentMailItem.To CC = sentMailItem.CC BCC = sentMailItem.BCC Subject = sentMailItem.Subject Body = sentMailItem.Body except: # Don't forget to change this. print "Error retrieving infomation from the Sent mail item!" self.createMailMessage(To, CC, BCC, Subject, Body) def createMailMessage(self, To, CC, BCC, Subject, Body): # There's usually a 'download' link in the body of the # email, if we find it, we'll use it. site = re.findall("http://.*", Body) if site: link = site[0].strip("\r") + "/addendum" else: link = "" mailMessage = self.application.CreateItem(constants.olMailItem) mailMessage.To = To mailMessage.CC = CC mailMessage.BCC = BCC if "RE:" in Subject: mailMessage.Subject = Subject else: mailMessage.Subject = "RE: " + Subject mailMessage.Body = \ "A new addendum has been issued for this project.\n\n%s" % link #~ mailMessage.Save() mailMessage.Display() def folderError(self): errMsg = \ "You must be in the 'Sent Items' Folder to use this tool!" win32api.MessageBox(0, errMsg, 'Folder Error', win32con.MB_ICONEXCLAMATION) I guess I'll try and delete some of these folder and mail objects and see what happens. Thanks, Bill From bwmetz at att.com Fri May 12 21:25:13 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Fri, 12 May 2006 14:25:13 -0500 Subject: [python-win32] Outlook Addin Help In-Reply-To: <4464B8F4.70906@pennswoods.net> Message-ID: <01D5341D04A2E64AB9B345769047336701C57002@OCCLUST01EVS1.ugd.att.com> I honestly can't remember if folder references in VB were required to be released, or should I say Microsoft "suggested" it. It's thankfully been way TOO LONG since I last touched VB and Outlook to remember, but I definitely remember the MAPI namespace references had to be set to Nothing. VB would look something like this. outlookApp = CreateObject("Outlook.Application") olNameSpace = outlookApp.GetNameSpace("MAPI") olActiveExplorer = outlookApp.ActiveExplorer Based on your code snippet below, I don't know if your referencing the MAPI namespace. It may not be required if you're just referencing current and default folders using ActiveExplorer. Sorry man, I just don't remember enough about it. I only dabbled as it was. Hope this helps. Bobby -----Original Message----- From: Bill Burns [mailto:billburns at pennswoods.net] Sent: Friday, May 12, 2006 9:34 AM To: Metz, Bobby W, WWCS Cc: Mark Hammond; python-win32 at python.org Subject: Re: [python-win32] Outlook Addin Help [Bobby] > Do you by chance still have a reference to the MAPI namespace open or > maybe some folder or item you referenced during execution? Maybe, I'm still getting the hang of this Windows programming thing :-) I do have references to -> the CurrentFolder, Sent Mail Folder and SentMail Items and I don't believe I'm explicitly closing/releasing or deleting these references anywhere in my code. Most of my addin is virtually the same as outlookAddin.py (...\site-packages\win32com\demos\outlookAddin.py) *but* my ButtonEvent looks like this: class ButtonEvent: def Init(self, application, activeExplorer): self.application = application self.activeExplorer = activeExplorer def Close(self): self.application = None self.activeExplorer = None self.close() def OnClick(self, button, cancel): locale.setlocale(locale.LC_NUMERIC, "C") # Get the ID of the folder we're currently in. currentFolder = self.activeExplorer.CurrentFolder currentFolderID = \ currentFolder.Parent.StoreID, currentFolder.EntryID # Get the ID of the 'Sent Items' folder. sentFolder = \ self.application.Session.GetDefaultFolder(constants.olFolderSentMail) sentFolderID = sentFolder.Parent.StoreID, sentFolder.EntryID # If we're in the 'Sent Items'... if currentFolderID[1] == sentFolderID[1]: self.getSentEmailInfo() else: # We're not in 'Sent Items'. self.folderError() def getSentEmailInfo(self): sentMailItem = self.activeExplorer.Selection.Item(1) try: To = sentMailItem.To CC = sentMailItem.CC BCC = sentMailItem.BCC Subject = sentMailItem.Subject Body = sentMailItem.Body except: # Don't forget to change this. print "Error retrieving infomation from the Sent mail item!" self.createMailMessage(To, CC, BCC, Subject, Body) def createMailMessage(self, To, CC, BCC, Subject, Body): # There's usually a 'download' link in the body of the # email, if we find it, we'll use it. site = re.findall("http://.*", Body) if site: link = site[0].strip("\r") + "/addendum" else: link = "" mailMessage = self.application.CreateItem(constants.olMailItem) mailMessage.To = To mailMessage.CC = CC mailMessage.BCC = BCC if "RE:" in Subject: mailMessage.Subject = Subject else: mailMessage.Subject = "RE: " + Subject mailMessage.Body = \ "A new addendum has been issued for this project.\n\n%s" % link #~ mailMessage.Save() mailMessage.Display() def folderError(self): errMsg = \ "You must be in the 'Sent Items' Folder to use this tool!" win32api.MessageBox(0, errMsg, 'Folder Error', win32con.MB_ICONEXCLAMATION) I guess I'll try and delete some of these folder and mail objects and see what happens. Thanks, Bill From billburns at pennswoods.net Fri May 12 23:12:17 2006 From: billburns at pennswoods.net (Bill Burns) Date: Fri, 12 May 2006 17:12:17 -0400 Subject: [python-win32] Outlook Addin Help In-Reply-To: <01D5341D04A2E64AB9B345769047336701C57002@OCCLUST01EVS1.ugd.att.com> References: <01D5341D04A2E64AB9B345769047336701C57002@OCCLUST01EVS1.ugd.att.com> Message-ID: <4464FA31.90708@pennswoods.net> Bobby wrote: > I honestly can't remember if folder references in VB were required to be released, or should I say Microsoft "suggested" it. It's thankfully been way TOO LONG since I last touched VB and Outlook to remember, but I definitely remember the MAPI namespace references had to be set to Nothing. VB would look something like this. > > outlookApp = CreateObject("Outlook.Application") > olNameSpace = outlookApp.GetNameSpace("MAPI") > olActiveExplorer = outlookApp.ActiveExplorer > > Based on your code snippet below, I don't know if your referencing the MAPI namespace. It may not be required if you're just referencing current and default folders using ActiveExplorer. Sorry man, I just don't remember enough about it. I only dabbled as it was. Hope this helps. > Bobby, I think the problem is with the ActiveExplorer object(s). When I get them "released" or set to None, then Outlook is happy to shutdown immediately (even when *other* interfaces are still referenced). If the ActiveExplorer object(s) are still referenced, then Outlook stays in memory (apparently to do some clean up). So, I'm looking into releasing the ActiveExplorer objects (well, all of the objects, but especially the ActiveExplorer), then I think I'll have the problem solved (fingers crossed). Thank you! Bill From bbine at freesurf.fr Sun May 14 18:08:46 2006 From: bbine at freesurf.fr (Bertrand Bine) Date: Sun, 14 May 2006 18:08:46 +0200 Subject: [python-win32] Fenetre en avant plan (Tkinter) Message-ID: <4467560E.601@freesurf.fr> Quelqu'un pourrait il m'indiquer comment conserver une fen?tre en avant plan avec Tkinter (sous Windows) ? A d?faut, d?terminer l'?v?nement de recouvrement partiel ou total d'une fen?tre Tk par une autre fen?tre (disparition de la Visibilit? ?), me serait utile.... Merci d'avance de votre aide. Bertrand. From bbine at freesurf.fr Sun May 14 19:26:47 2006 From: bbine at freesurf.fr (Bertrand Bine) Date: Sun, 14 May 2006 19:26:47 +0200 Subject: [python-win32] Keeping a Tkinter window above all other Message-ID: <44676857.1050507@freesurf.fr> Could someone tell me how to keep a Tkinter windows above all others (under Windows) ? Being able to intercept the unvisibility of Tk windows when it occurs would certainly be usefull... Thanks for your help Bertrand. From unclejamil at gmail.com Mon May 15 02:54:26 2006 From: unclejamil at gmail.com (Jamil Edgemir) Date: Sun, 14 May 2006 20:54:26 -0400 Subject: [python-win32] Control IE with COM: how to get at drop down menus? Message-ID: <5009b2270605141754v358c81aif06643840d75b62d@mail.gmail.com> Hi, I have used PAMIE to automate IE and click on some buttons. That works great. Now what I want to do is use 'Select All' from the drop down 'Edit' menu of Explorer, 'Copy' and then get at the clipboard text. I just don't know how to get at the menus. Does anyone know how to do this using PAMIE or win32com? I've googled like crazy and can't seem to find anything on it. -j -- ------------------------------------------------------------- Jamil Egdemir unclejamil at gmail.com http://grad.physics.sunysb.edu/~jamil (631) 338-3170 (cell) ------------------------------------------------------------- From bwmetz at att.com Mon May 15 18:17:29 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Mon, 15 May 2006 11:17:29 -0500 Subject: [python-win32] Keeping a Tkinter window above all other In-Reply-To: <44676857.1050507@freesurf.fr> Message-ID: <01D5341D04A2E64AB9B345769047336701C577D5@OCCLUST01EVS1.ugd.att.com> Bertrand, This is somewhat easy to google for, but you come up with many hints and pieces of the puzzle. At least when I searched for this awhile back there was no one answer that held all the pieces to the puzzle. So, below is what I learned along between google and just trial/error. There's two ways to do it. Note, the redrawing of the window may not do exactly what you expect...it is tkinter after all. Just replace below with the name of your toplevel window. Tkinter way ------------------------ .wm_attributes("-topmost", 1) # Make sure window remains on top of all others .focus() # Set focus to window win32com way ------------------------ import win32ui, win32con, win32gui hwnd = int(eval(.wm_frame())) # Get the window info from the window manager win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE) Some things to note if your "topmost" window will be a child window of another Tkinter window. If you open a child window and set it as "topmost", e.g. the IE or Firefox Help-->About windows, then minimize the entire application to the taskbar, the methods below won't force the child window above the parent window on restoral from minimization if you select the main window icon in the Windows taskbar. I work around this by disabling the parent window so it's still visible but it ignores user clicks. .wm_attributes("-disabled", 1) # Disable parent so user has to use child I also never could figure out how to get the Windows taskbar to not show an icon for the "topmost" child window. The transient() call was supposed to do this I thought but in practice it doesn't work for me. Perhaps someone else on the list knows the answer. .transient() # Make it a transient of the parent If you're making your primary app window "topmost" then these concerns are moot but thought I'd mention them. Bobby -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Bertrand Bine Sent: Sunday, May 14, 2006 10:27 AM To: python-win32 at python.org Subject: [python-win32] Keeping a Tkinter window above all other Could someone tell me how to keep a Tkinter windows above all others (under Windows) ? Being able to intercept the unvisibility of Tk windows when it occurs would certainly be usefull... Thanks for your help Bertrand. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Wed May 17 03:00:08 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 17 May 2006 11:00:08 +1000 Subject: [python-win32] Outlook Addin Help In-Reply-To: <4464FA31.90708@pennswoods.net> Message-ID: > I think the problem is with the ActiveExplorer object(s). When I get > them "released" or set to None, then Outlook is happy to shutdown > immediately (even when *other* interfaces are still referenced). If the > ActiveExplorer object(s) are still referenced, then Outlook stays in > memory (apparently to do some clean up). > > So, I'm looking into releasing the ActiveExplorer objects (well, all of > the objects, but especially the ActiveExplorer), then I think I'll have > the problem solved (fingers crossed). Hi Bill, How did you end up going with this? Do you have an updated version of the sample plugin that does not demonstrate the original problem? Thanks, Mark From billburns at pennswoods.net Wed May 17 05:23:12 2006 From: billburns at pennswoods.net (Bill Burns) Date: Tue, 16 May 2006 23:23:12 -0400 Subject: [python-win32] Outlook Addin Help In-Reply-To: References: Message-ID: <446A9720.7010706@pennswoods.net> >>I think the problem is with the ActiveExplorer object(s). When I get >>them "released" or set to None, then Outlook is happy to shutdown >>immediately (even when *other* interfaces are still referenced). If the >>ActiveExplorer object(s) are still referenced, then Outlook stays in >>memory (apparently to do some clean up). >> >>So, I'm looking into releasing the ActiveExplorer objects (well, all of >>the objects, but especially the ActiveExplorer), then I think I'll have >>the problem solved (fingers crossed). > > > Hi Bill, > > How did you end up going with this? Do you have an updated version of the > sample plugin that does not demonstrate the original problem? > Mark, Yes, I have fixed the original problem. I would have got back to the list sooner, but I've been real busy lately :-). It was definitely the ActiveExplorer object that was making Outlook hang around in memory. I tried killing every *other* object and nothing changed until I killed the ActiveExplorer. My current code has a Gateway count of 1 and an Interface count of 1. When I shutdown Outlook, it closes immediately. The entire piece of code is below. I've used the code in the demos directory (..\site-packages\win32com\demos\outlookAddin.py) as a basis for my code. Keep in mind - I'm still learning, so if you see something that smells, let me know :-) Thank you for your help! Bill import sys import os import re # Per comments in SpamBayes Outlook addin.py, # I've added this here and in two other spots. import locale locale.setlocale(locale.LC_NUMERIC, "C") import win32api import win32con from win32com import universal from win32com.server.exception import COMException from win32com.client import gencache, DispatchWithEvents import winerror import pythoncom from win32com.client import constants # Support for COM objects we use. gencache.EnsureModule('{00062FFF-0000-0000-C000-000000000046}', 0, 9, 0, bForDemand=True) # Outlook 9 gencache.EnsureModule('{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}', 0, 2, 1, bForDemand=True) # Office 9 # The TLB defining the interfaces we implement universal.RegisterInterfaces('{AC0714F2-3D04-11D1-AE7D-00A0C90F26F4}', 0, 1, 0, ["_IDTExtensibility2"]) class ButtonEvent: def Init(self, application): self.application = application self.activeExplorer = None def Close(self): self.application = None self.activeExplorer = None self.close() def OnClick(self, button, cancel): locale.setlocale(locale.LC_NUMERIC, "C") if self.activeExplorer is None: self.activeExplorer = self.application.ActiveExplorer() # Get the ID of the folder we're currently in. currentFolder = self.activeExplorer.CurrentFolder currentFolderID = currentFolder.Parent.StoreID, currentFolder.EntryID # Get the ID of the 'Sent Items' folder. sentFolder = self.application.Session.GetDefaultFolder(constants.olFolderSentMail) sentFolderID = sentFolder.Parent.StoreID, sentFolder.EntryID # If we're in the 'Sent Items' folder... if currentFolderID[1] == sentFolderID[1]: self.getSentEmailInfo() else: # not in the 'Sent Items' folder. self.folderError() def getSentEmailInfo(self): # Grab all of the fields from the currently # selected sent mail item. sentMailItem = self.activeExplorer.Selection.Item(1) try: To = sentMailItem.To CC = sentMailItem.CC BCC = sentMailItem.BCC Subject = sentMailItem.Subject Body = sentMailItem.Body except: # Don't forget to change this. print "Hit an error in getSentEmailInfo()" # Better kill the ActiveExplorer or Outlook # will hang on shutdown. self.activeExplorer = None self.createMailMessage(To, CC, BCC, Subject, Body) def createMailMessage(self, To, CC, BCC, Subject, Body): # Create the new mail message.... # # There's usually a 'download' link in the body of the # 'Invitation to Bid', if we find it, we'll use it. site = re.findall("http://.*", Body) if site: # Our link is top-level, let's create a new link # that points right to the addendum directory. link = site[0].strip("\r") + "/addendum" else: link = "" mailMessage = self.application.CreateItem(constants.olMailItem) mailMessage.To = To mailMessage.CC = CC mailMessage.BCC = BCC if "RE:" in Subject: mailMessage.Subject = Subject else: mailMessage.Subject = "RE: " + Subject mailMessage.Body = "A new addendum has been issued for this project.\n\n%s" % (link) mailMessage.Display() # Kill the ActiveExplorer. self.activeExplorer = None def folderError(self): errMsg = "You must be in the 'Sent Items' Folder to use this tool!" win32api.MessageBox(0, errMsg, 'Folder Error', win32con.MB_ICONEXCLAMATION) # Kill the ActiveExplorer. self.activeExplorer = None class OutlookAddin: _com_interfaces_ = ['_IDTExtensibility2'] _public_methods_ = [] _reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER _reg_clsid_ = "{B61B8A3D-041E-4d82-908B-1503681A55B3}" _reg_progid_ = "InvitationHelper.OutlookAddin" _reg_policy_spec_ = "win32com.server.policy.EventHandlerPolicy" def __init__(self): self.application = None def OnConnection(self, application, connectMode, addin, custom): locale.setlocale(locale.LC_NUMERIC, "C") self.application = application # ActiveExplorer may be none when started without a UI (eg, WinCE synchronisation) activeExplorer = application.ActiveExplorer() if activeExplorer is not None: bars = activeExplorer.CommandBars toolbar = bars.Item("Standard") item = toolbar.Controls.Add(Type=constants.msoControlButton, Temporary=True) # Hook events for the item item = self.toolbarButton = DispatchWithEvents(item, ButtonEvent) item.Caption="Invitation Helper" item.TooltipText = "Creates a new email from a\n" \ "previously sent 'Invitation to Bid'." item.Enabled = True item.Init(self.application) self.item = item def OnDisconnection(self, mode, custom): self.item.Close() self.application = None print "Gateway Count: ", pythoncom._GetGatewayCount() print "Interface Count: ", pythoncom._GetInterfaceCount() def OnAddInsUpdate(self, custom): pass def OnStartupComplete(self, custom): pass def OnBeginShutdown(self, custom): pass def RegisterAddin(klass): import _winreg key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Outlook\\Addins") subkey = _winreg.CreateKey(key, klass._reg_progid_) _winreg.SetValueEx(subkey, "CommandLineSafe", 0, _winreg.REG_DWORD, 0) _winreg.SetValueEx(subkey, "LoadBehavior", 0, _winreg.REG_DWORD, 3) _winreg.SetValueEx(subkey, "Description", 0, _winreg.REG_SZ, "Invitation to Bid Tool") _winreg.SetValueEx(subkey, "FriendlyName", 0, _winreg.REG_SZ, "Invitation Helper") def UnregisterAddin(klass): import _winreg try: _winreg.DeleteKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Outlook\\Addins\\" + klass._reg_progid_) except WindowsError: pass if __name__ == '__main__': import win32com.server.register win32com.server.register.UseCommandLine(OutlookAddin) if "--unregister" in sys.argv: UnregisterAddin(OutlookAddin) else: RegisterAddin(OutlookAddin) From rwupole at msn.com Wed May 17 16:15:37 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 17 May 2006 10:15:37 -0400 Subject: [python-win32] Re: Building pywin32 with the free MS toolkit References: <79990c6b0604171454s77c0bda5qdc11f8f719811c59@mail.gmail.com> Message-ID: Mark Hammond wrote: >> On 4/17/06, Paul Moore wrote: >> > On 4/16/06, Paul Moore wrote: >> > > I tried building one for myself, but I'm missing some critical >> > > dependencies (dsound.h?) >> > >> > I'm assuming this is from the DirectX SDK, which I'm in the process of >> > downloading now to try it out. Are there any other downloads I should >> > get in order to build pywin32? (I have the platform SDK - the setup.py >> > doesn't mention any others as still being needed, but then again, it >> > didn't mention the DirectX one either...) >> >> Looks like atlbase.h is needed in win32netuse and win32netuser. That's >> annoying, as it's not freely available, as far as I know. >> >> It's possible taht ATL isn't actually needed, though - commenting the >> includes out results in a successful compile. The link fails with an >> odd error, though - > > Removing atlbase.h just meant that advapi32.lib needed to be added to the > link command-line - presumably the ATL headers automatically caused that to > happen. I've just checked in a fix for that and removed that header. > Mark, it appears this checkin got lost somewhere in SF's upgrade shuffle. A clean checkout from the new CVS host doesn't show these changes any more. Could you commit those again ? Roger From bwmetz at att.com Thu May 18 02:14:11 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Wed, 17 May 2006 19:14:11 -0500 Subject: [python-win32] PythonCOM & Windows Firewall Message-ID: <01D5341D04A2E64AB9B345769047336701CB667D@OCCLUST01EVS1.ugd.att.com> Anyone out there ever attempted to use win32com to register applications with Windows Firewall as allowed applications for incoming TCP/UDP connections? Was going to try my hand at this and wondered, if so, that anyone who had already might share some tips. I'm working this so that a non-standard net app we use can get through the XP SP2 firewall without hands on admin assistance. In case no one has tried but are interested, here's the MSDN article I'm going to be working from. http://msdn.microsoft.com/security/productinfo/XPSP2/networkprotection/firewall_devimp.aspx Regards, Bobby From rwupole at msn.com Thu May 18 04:06:30 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 17 May 2006 22:06:30 -0400 Subject: [python-win32] Re: PythonCOM & Windows Firewall Message-ID: I've used it to list firewall exceptions, and it wasn't too much more work to add an application: import win32com.client fw=win32com.client.gencache.EnsureDispatch('HNetCfg.FwMgr',0) apps=fw.LocalPolicy.CurrentProfile.AuthorizedApplications for app in apps: print app.Name, app.ProcessImageFileName newapp=win32com.client.Dispatch('HNetCfg.FwAuthorizedApplication') newapp.Name='python_d.exe' newapp.ProcessImageFileName='j:\\python24\\python_d.exe' newapp.Enabled=True apps.Add(newapp) hth Roger From bwmetz at att.com Thu May 18 09:46:01 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Thu, 18 May 2006 02:46:01 -0500 Subject: [python-win32] PythonCOM & Windows Firewall In-Reply-To: <000901c67a1f$af3d8fe0$0100a8c0@rupole> Message-ID: <01D5341D04A2E64AB9B345769047336701CB66E7@OCCLUST01EVS1.ugd.att.com> Roger, thanks for the code. I'll give it a try. Having read a bunch of the documentation though, I'm concerned it may not work as some of our users won't have admin rights. I was hoping this would provide them the Zone Alarm type prompt so that non-admin could approve the listening app upon execution. If all else fails it gives me a starter for checking for existing exceptions. Here's to hoping!!! Bobby -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Roger Upole Sent: Wednesday, May 17, 2006 7:07 PM To: python-win32 at python.org Subject: [python-win32] Re: PythonCOM & Windows Firewall I've used it to list firewall exceptions, and it wasn't too much more work to add an application: import win32com.client fw=win32com.client.gencache.EnsureDispatch('HNetCfg.FwMgr',0) apps=fw.LocalPolicy.CurrentProfile.AuthorizedApplications for app in apps: print app.Name, app.ProcessImageFileName newapp=win32com.client.Dispatch('HNetCfg.FwAuthorizedApplication') newapp.Name='python_d.exe' newapp.ProcessImageFileName='j:\\python24\\python_d.exe' newapp.Enabled=True apps.Add(newapp) hth Roger _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Thu May 18 09:49:48 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 18 May 2006 17:49:48 +1000 Subject: [python-win32] Building pywin32 with the free MS toolkit In-Reply-To: Message-ID: > Mark, it appears this checkin got lost somewhere in SF's upgrade > shuffle. A clean checkout from the new CVS host doesn't show > these changes any more. Could you commit those again ? Oops - it looks like the previous commit failed and I didn't notice! It *is* checked in now (and I checked it worked :) Cheers, Mark. From pfraser at spatialmedia.com Thu May 18 10:38:30 2006 From: pfraser at spatialmedia.com (Peter Fraser) Date: Thu, 18 May 2006 20:38:30 +1200 Subject: [python-win32] PythonWin hangs and pins CPU -and a Python Way question Message-ID: <446C3286.70106@spatialmedia.com> I have a specific PythonWin IDE problem -and a very general, but possibly misguided question: 1. When I start PythonWin, I get no interactive shell and when I try to do anything -PythonWin seems to go into some kind of loop, and grinds my machine to a halt. I have sometimes seen references re unable to save a file, when trying to execute a script -but rarely get that far. PythonWin has run fine on this (XP)machine -it just started doing this one day after a failed debug session. I have uninstalled both PythonWin and Python -and reinstalled to no avail. I get the problem with both 208 and 203 -and against Python 2.4.2 and 2.4.3. Given the fact that this behaviour survives a complete reinstall, is there perhaps something in the registry that might be relevant? 2. General I'm pretty new to Python, and surprised to find that of all the various Python IDE's only PythonWin works in such a way to take, IMHO proper advantage of Python's dynamic nature. Is PythonWin really unique in that both execution of scripts, and the interactive shell share the same session (there may be a better term than session -context?) I like Komodo for example, but the best it can do is allow you to "interact", in break mode only. Once you script has completed that session is gone. I want to create manipulate, inspect and generally muck about with a set of objects, running scripts against them, debugging and poking at them interactively. I realise you can always execfile manually from a shell but I guess I am expecting the IDE to do this for me when I hit run -and to interact with the debugger when doing so. I suspect PythonWin can only do this because it goes to the trouble of providing its own shell, but I'm guessing here. Is this just not how development tends to go in Python? Or am I missing something fundamental? -thanks for any help on either point Pete F From mark.m.mcmahon at gmail.com Thu May 18 17:03:23 2006 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Thu, 18 May 2006 11:03:23 -0400 Subject: [python-win32] Control IE with COM: how to get at drop down menus? In-Reply-To: <5009b2270605141754v358c81aif06643840d75b62d@mail.gmail.com> References: <5009b2270605141754v358c81aif06643840d75b62d@mail.gmail.com> Message-ID: <71b6302c0605180803v50a82e28y2c814f812a9094b6@mail.gmail.com> Hi Jamil, I have a couple of suggestions... You could look at my package "pywinauto", but that is probably overkill for your problem - and it doesn't deal nicely with IE menu's (as they do not expose their text easily). I would suggest that you look at SendKeys (google for SendKeys/Python). That would allow you to easily send keystrokes to IE. (you would just have to ensure that it is the foreground application - or set it as the foreground application before sending the keystrokes). Thanks Mark On 5/14/06, Jamil Edgemir wrote: > Hi, > > I have used PAMIE to automate IE and click on some buttons. That > works great. Now what I want to do is use 'Select All' from the drop > down 'Edit' menu of Explorer, 'Copy' and then get at the clipboard > text. I just don't know how to get at the menus. > > Does anyone know how to do this using PAMIE or win32com? I've googled > like crazy and can't seem to find anything on it. > > -j > > -- > ------------------------------------------------------------- > Jamil Egdemir > unclejamil at gmail.com > http://grad.physics.sunysb.edu/~jamil > (631) 338-3170 (cell) > ------------------------------------------------------------- > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From yi.codeplayer at gmail.com Fri May 19 19:36:12 2006 From: yi.codeplayer at gmail.com (yi huang) Date: Sat, 20 May 2006 01:36:12 +0800 Subject: [python-win32] I can not find VkKeyScan in win32api module , is it missed? Message-ID: Is it missed, or just in another module ? Can i get visual keycode without VkKeyScan ? How? Thanks. -- http://codeplayer.blogbus.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060520/5a88c293/attachment.htm From jpaulofarias at gmail.com Sat May 20 17:47:16 2006 From: jpaulofarias at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Paulo_Fernandes_Farias?=) Date: Sat, 20 May 2006 12:47:16 -0300 Subject: [python-win32] Getting the text out of a listbox from another process Message-ID: Hi! Is there a way to get the text of the items in a listbox running in another application? I've tried to send LB_GETITEMDATA message to the listbox and it returns the addresses of the text (I think). How do I get the text? I've tried win32gui.PyGetString(addr) but it does not works. Thanks for the help! -- JP From jpaulofarias at gmail.com Sun May 21 02:05:51 2006 From: jpaulofarias at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Paulo_Fernandes_Farias?=) Date: Sat, 20 May 2006 21:05:51 -0300 Subject: [python-win32] Rewriting my previous question.... Message-ID: Hi! I'll rewrite my previous question... How do I get data from another process using win32gui.SendMessage() when it needs some pointers to fill in the data? I know it is more likely possible cause winspector can show the text from some messages like LVM_SETITEMTEXTA where the user uses a pointer to a structure to pass in the text to set on a SysListView32 item. How do I do that with win32 extensions? -- JP From jpaulofarias at gmail.com Sun May 21 19:45:02 2006 From: jpaulofarias at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Paulo_Fernandes_Farias?=) Date: Sun, 21 May 2006 14:45:02 -0300 Subject: [python-win32] Getting the text out of a listbox from another process Message-ID: Hi! I've found the code bellow does what I want. Anyway to do it with ctypes / win32 extensions? #define WIN32_LEAN_AND_MEAN #include #include #include int main(void) { HWND hwnd=FindWindow(NULL, "Stealing Program's Memory: ListView"); HWND listview=FindWindowEx(hwnd, NULL, "SysListView32", NULL); int count=(int)SendMessage(listview, LVM_GETITEMCOUNT, 0, 0); int i; LVITEM lvi, *_lvi; char item[512], subitem[512]; char *_item, *_subitem; unsigned long pid; HANDLE process; GetWindowThreadProcessId(listview, &pid); process=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ| PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, pid); _lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE); _item=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT, PAGE_READWRITE); _subitem=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT, PAGE_READWRITE); lvi.cchTextMax=512; for(i=0; i -- JP From mhammond at skippinet.com.au Mon May 22 01:45:26 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 22 May 2006 09:45:26 +1000 Subject: [python-win32] Rewriting my previous question.... In-Reply-To: Message-ID: > I'll rewrite my previous question... > > How do I get data from another process using win32gui.SendMessage() > when it needs some pointers to fill in the data? It appears your previous mails indicated how to do that. Unfortunately, some of those functions are not exposed via pywin32. Cheers, Mark From mark.m.mcmahon at gmail.com Mon May 22 15:19:25 2006 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Mon, 22 May 2006 09:19:25 -0400 Subject: [python-win32] Rewriting my previous question.... In-Reply-To: References: Message-ID: <71b6302c0605220619k34ac8d58re4417339d294c7d2@mail.gmail.com> Hi JP, On 5/20/06, Jo?o Paulo Fernandes Farias wrote: > Hi! > > I'll rewrite my previous question... > > How do I get data from another process using win32gui.SendMessage() > when it needs some pointers to fill in the data? > > I know it is more likely possible cause winspector can show the text > from some messages like LVM_SETITEMTEXTA where the user uses a pointer > to a structure to pass in the text to set on a SysListView32 item. You mentioned that ctypes might be OK? If you download pywinauto then you should be able to cut and paste the code you need :-) Look into pywinauto\controls\common_controls.py (if you need ListView as your code snipped seems to suggest). I have wrapped the equivalent C code that you showed previously. Hope that helps, Mark > > How do I do that with win32 extensions? > > -- > JP > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From bwmetz at att.com Mon May 22 18:42:20 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Mon, 22 May 2006 11:42:20 -0500 Subject: [python-win32] PythonCOM & Windows Firewall Message-ID: <01D5341D04A2E64AB9B345769047336701D0FA0B@OCCLUST01EVS1.ugd.att.com> Again, thanks to Roger to the perfect tip. As I feared, non-admins don't get prompted to "allow" an app that's requesting access or I'm doing something wrong. But, this did lead me to write a couple of quick routines for detecting the FW condition for the users and providing a nice little notification so they know to contact the Help Desk for assistance. Also thought I'd share these to save someone else the time down the road. Note, the first function should theoretically detect Windows XP of any flavor running SP2 or later. Only time will tell...it's based on VB code to detect XP Prof with SP2. Modify as needed. I use them in tandem since SP2 is the only XP with FW enabled by default. I won't vouch for the FW detection in pre-SP2 or any other version using the ICF as I don't have a test machine at the moment to try it. import win32com.client import pythoncom # Using Python to detect if XP Firewall is enabled. def is_WinXP_FW_Enabled(): try: XPFW = win32com.client.gencache.EnsureDispatch('HNetCfg.FwMgr',0) XPFW_Policy = XPFW.LocalPolicy.CurrentProfile except pythoncom.com_error: # Can't dispatch or access the FW COM instance. return False else: return XPFW_policy.FirewallEnabled # Using Python to detect if XP SP 2 is installed. def is_WinXP_SP2(): try: objWMIService = win32com.client.GetObject("winmgmts:") objOS = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem WHERE Caption LIKE 'Microsoft Windows XP%' AND ServicePackMajorVersion >= 2") if objOS.Count != 0: # objOS.Count on Win2000 is invalid (raises com_error) return True except pythoncom.com_error: # Can't access WMI so default to False. # Maybe add some fancier error handling later. return False else: # No COM errors but not Win XP return False Bobby -----Original Message----- From: Metz, Bobby W, WWCS Sent: Thursday, May 18, 2006 12:46 AM To: 'Roger Upole'; python-win32 at python.org Subject: RE: [python-win32] Re: PythonCOM & Windows Firewall Roger, thanks for the code. I'll give it a try. Having read a bunch of the documentation though, I'm concerned it may not work as some of our users won't have admin rights. I was hoping this would provide them the Zone Alarm type prompt so that non-admin could approve the listening app upon execution. If all else fails it gives me a starter for checking for existing exceptions. Here's to hoping!!! Bobby -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Roger Upole Sent: Wednesday, May 17, 2006 7:07 PM To: python-win32 at python.org Subject: [python-win32] Re: PythonCOM & Windows Firewall I've used it to list firewall exceptions, and it wasn't too much more work to add an application: import win32com.client fw=win32com.client.gencache.EnsureDispatch('HNetCfg.FwMgr',0) apps=fw.LocalPolicy.CurrentProfile.AuthorizedApplications for app in apps: print app.Name, app.ProcessImageFileName newapp=win32com.client.Dispatch('HNetCfg.FwAuthorizedApplication') newapp.Name='python_d.exe' newapp.ProcessImageFileName='j:\\python24\\python_d.exe' newapp.Enabled=True apps.Add(newapp) hth Roger _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From bbine at freesurf.fr Mon May 22 18:54:22 2006 From: bbine at freesurf.fr (Bertrand Bine) Date: Mon, 22 May 2006 18:54:22 +0200 Subject: [python-win32] Keeping a Tkinter window above all other In-Reply-To: <01D5341D04A2E64AB9B345769047336701C577D5@OCCLUST01EVS1.ugd.att.com> References: <01D5341D04A2E64AB9B345769047336701C577D5@OCCLUST01EVS1.ugd.att.com> Message-ID: <4471ECBE.6040108@freesurf.fr> Metz, Bobby W, WWCS a ?crit : >Bertrand, > This is somewhat easy to google for, but you come up with many >hints and pieces of the puzzle. At least when I searched for this >awhile back there was no one answer that held all the pieces to the >puzzle. So, below is what I learned along between google and just >trial/error. > There's two ways to do it. Note, the redrawing of the window >may not do exactly what you expect...it is tkinter after all. Just >replace below with the name of your toplevel window. > >Tkinter way >------------------------ >.wm_attributes("-topmost", 1) # Make sure window remains on >top of all others >.focus() # Set focus to window > >win32com way >------------------------ >import win32ui, win32con, win32gui >hwnd = int(eval(.wm_frame())) # Get the window info from the >window manager >win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, 0, 0, 0, 0, >win32con.SWP_NOMOVE | win32con.SWP_NOSIZE) > > Some things to note if your "topmost" window will be a child >window of another Tkinter window. If you open a child window and set it >as "topmost", e.g. the IE or Firefox Help-->About windows, then minimize >the entire application to the taskbar, the methods below won't force the >child window above the parent window on restoral from minimization if >you select the main window icon in the Windows taskbar. I work around >this by disabling the parent window so it's still visible but it ignores >user clicks. > >.wm_attributes("-disabled", 1) # Disable parent so >user has to use child > > I also never could figure out how to get the Windows taskbar to >not show an icon for the "topmost" child window. The transient() call >was supposed to do this I thought but in practice it doesn't work for >me. Perhaps someone else on the list knows the answer. > >.transient() # Make it a >transient of the parent > >If you're making your primary app window "topmost" then these concerns >are moot but thought I'd mention them. > >Bobby > >-----Original Message----- >From: python-win32-bounces at python.org >[mailto:python-win32-bounces at python.org]On Behalf Of Bertrand Bine >Sent: Sunday, May 14, 2006 10:27 AM >To: python-win32 at python.org >Subject: [python-win32] Keeping a Tkinter window above all other > > >Could someone tell me how to keep a Tkinter windows above all others >(under Windows) ? > >Being able to intercept the unvisibility of Tk windows when it occurs >would certainly be usefull... > >Thanks for your help > >Bertrand. > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > > Thanks, that is exactly what I looked for. It works fine. From davidnicolson1 at hotmail.com Tue May 23 14:45:03 2006 From: davidnicolson1 at hotmail.com (David Nicolson) Date: Tue, 23 May 2006 22:45:03 +1000 Subject: [python-win32] Python COM and IUnknown Message-ID: Hi, I have a win32com application that dispatches a COM object, using late or early binding and with events using win32com.client.WithEvents. The application that is dispatched to sends an event when it is quitting, leaving time for the client to disconnect from the COM server. When this event is received, the del statement is run on both the COM and events object. The problem is that the reference count in Python of these objects, and the GatewayCount and InterfaceCount returned from pythoncom remain above 0. After months of trial and error I sought out a solution leveraging ctypes. This email on the ctypes mailing list looked as if it would be possible to reduce the COM reference count, circumventing the connection between Python reference counts and COM reference counts. http://sourceforge.net/mailarchive/message.php?msg_id=5094807 Since that email the ctypes.com module has been moved to a separate project, titled comtypes. The IUnknown object did not have a from_address attribute in the comtypes module though. Any suggestions or help would be appreciated. Thanks, Dave From durumdara at gmail.com Wed May 24 16:14:34 2006 From: durumdara at gmail.com (DurumDara) Date: Wed, 24 May 2006 16:14:34 +0200 Subject: [python-win32] Try to got short path for files - but got error... Message-ID: <44746A4A.8090908@gmail.com> Hi ! I wrote to Python list, but nobody answer to my problem. I copy these mails to this body. So: I need to optimize my disk hasher code. I need to make quick code, and I see that FSUM make better speed than python sha/md5 with py2exe. But I need to "transport" filenames to FSUM. I got errors with unicode file names. See my unicode test file name: UFN=u'%s\\xA\xff'%os.getcwd() I want to get an universal code the convert (unicode) long path to short path. Here are my tryings: Hi ! Ahhh... That is not working in my notebook... See the log of the program: ########################################### Commandline: C:\Python24\python.exe C:\SPEEDT~1\Module1.py Workingdirectory: C:\speedtest Timeout: 0 ms SlavaSoft Optimizing Checksum Utility - fsum 2.51 Implemented using SlavaSoft QuickHash Library Copyright (C) SlavaSoft Inc. 1999-2004. All rights reserved. ====================================== C:\speedtest\fsum.exe -sha1 -DC:\SPEEDT~1 XA02BB~1 Output ; SlavaSoft Optimizing Checksum Utility - fsum 2.51 ; ; Generated on 05/15/06 at 17:28:36 ; NOT FOUND ***** xAy Process "Pyhton Interpeter" terminated, ExitCode: 00000000 ########################################### It is interesting. In my working machine the code of my shortpath routine generating xAy result as short filename. In my notebook (as you see) it is generate XA02BB~1 file name. This filename not found by FSUM.exe. If I open it as: f=open(shortfilepath,'r') print f.read() it is working from Python, show the file content good. Hmmmm..... Is Windows doesn't have compatible way of file reading ??? (In this notebook I see any interesting things too. Some file copied from CD - I got invalid times for them. When I copy them to my working machine, everything is ok. Windows not compatible itself... :-((( Both of machines have WXP, same updates in them, and NTFS used. What is different ? I don't know) Hi: dd DurumDara ?rta: > John Machin ?rta: > >> Looks like you need a GetShortPathNameW() but it's not implemented. >> Raise it as an issue on the pywin32 sourceforge bug register. >> Tell Mark >> I sent you :-) >> Another thought: try using ctypes. >> > > Hi ! > > It seems to be I found a solution. A little tricky, but it is > working: > ##################################################################### > import sys,os > from sys import argv as sysargv > > UFN=u'%s\\xA\xff'%os.getcwd() > if os.path.exists(UFN): > os.remove(UFN) > > f=open(UFN,'w') > f.write('%s\n'%('='*80)) > f.close() > > from ctypes import windll, create_unicode_buffer, sizeof, WinError > buf=create_unicode_buffer(512) > if windll.kernel32.GetShortPathNameW(UFN,buf,sizeof(buf)): > fname=buf.value > #import win32api > #dfn=win32api.GetShortPathName(name) > #print dfn > else: > raise > shortpath,filename=os.path.split(fname) > > import win32file > filedatas=win32file.FindFilesW(fname) > fd=filedatas[0] > shortfilename=fd[9] or fd[8] > > shortfilepath=os.path.join(shortpath,shortfilename) > > print [UFN] > print shortfilepath > > f=open(shortfilepath,'r') > print f.read() > > sys.exit() > > But I don't understand: why the shortpathw not convert the > filename too (like dir) ? > > > Thanx for help: > dd > John Machin ?rta: > According to my reading of the source, the function you have called > expects an 8-bit string. > ==== > static PyObject * > PyGetShortPathName(PyObject * self, PyObject * args) > { > char *path; > if (!PyArg_ParseTuple(args, "s:GetShortPathName", &path)) > ==== > If it is given Unicode, PyArg_ParseTuple will attempt to encode it > using the default encoding (ascii). Splat. > > Looks like you need a GetShortPathNameW() but it's not implemented. > Raise it as an issue on the pywin32 sourceforge bug register. Tell > Mark > I sent you :-) > > It may be possible to fake up your default encoding to say cp1252 BUT > take the advice of anyone who screams "Don't do that!" and in any > case > this wouldn't help you with a Russian, Chinese, etc etc filename. > > Another thought: try using ctypes. > Hi ! I trying with that, but I get error, because the result is unicode too... :-((( from ctypes import windll, create_unicode_buffer, sizeof, WinError buf=create_unicode_buffer(512) if windll.kernel32.GetShortPathNameW(UFN,buf,sizeof(buf)): name=buf.value print [name] ###################################################### Commandline: C:\Python24\python.exe G:\SPEEDT~1\Module1.py Workingdirectory: G:\speedtest Timeout: 0 ms [u'G:\\SPEEDT~1\\xA\xff'] Process "Pyhton Interpeter" terminated, ExitCode: 00000000 ###################################################### Can I do anything with this unicoded filename ? My code must be universal ! Thanx for help: dd From bwmetz at att.com Wed May 24 20:32:54 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Wed, 24 May 2006 13:32:54 -0500 Subject: [python-win32] Try to got short path for files - but got error... In-Reply-To: <44746A4A.8090908@gmail.com> Message-ID: <01D5341D04A2E64AB9B345769047336701D37412@OCCLUST01EVS1.ugd.att.com> Why the insistence on short file names? Did you try encapsulating your filenames in quotes when passing to FSUM? C:\speedtest\fsum.exe -sha1 -D"C:\SPEEDTEST" "this is my test file" Another workaround to try if GetShortPathNameW() is truly not available would be to use "dir". This is kludgy but will work if all your machines are using WinXP or 2000 I believe. For example, if I create a test file with contents "Hello World"... >>> import os, re >>> dirname = "c:\\speedtest" >>> longname = "This is Hello World.txt" >>> return_vals = os.popen('dir /x "' + dirname + '\\' + longname + '"').read() >>> shortname = re.findall("\s+(\S+)\s+" + longname, return_vals) >>> shortname ['THISIS~1.TXT'] Here's the DOS output: C:\speedtest>dir /x Volume in drive C has no label. Volume Serial Number is DC19-FC42 Directory of C:\speedtest 05/24/2006 11:17 AM . 05/24/2006 11:17 AM .. 05/24/2006 11:17 AM 14 THISIS~1.TXT This is Hello World.txt 1 File(s) 14 bytes 2 Dir(s) 71,964,741,632 bytes free Like I said, bit of a kludge, but it would work. Doing a similar op on the c:\ directory would product the shortname of speedtest. Bobby -----Original Message----- From: python-win32-bounces+bwmetz=att.com at python.org [mailto:python-win32-bounces+bwmetz=att.com at python.org] On Behalf Of DurumDara Sent: Wednesday, May 24, 2006 7:15 AM To: python-win32 at python.org Subject: [python-win32] Try to got short path for files - but got error... Hi ! I wrote to Python list, but nobody answer to my problem. I copy these mails to this body. So: I need to optimize my disk hasher code. I need to make quick code, and I see that FSUM make better speed than python sha/md5 with py2exe. But I need to "transport" filenames to FSUM. I got errors with unicode file names. See my unicode test file name: UFN=u'%s\\xA\xff'%os.getcwd() I want to get an universal code the convert (unicode) long path to short path. Here are my tryings: Hi ! Ahhh... That is not working in my notebook... See the log of the program: ########################################### Commandline: C:\Python24\python.exe C:\SPEEDT~1\Module1.py Workingdirectory: C:\speedtest Timeout: 0 ms SlavaSoft Optimizing Checksum Utility - fsum 2.51 Implemented using SlavaSoft QuickHash Library Copyright (C) SlavaSoft Inc. 1999-2004. All rights reserved. ====================================== C:\speedtest\fsum.exe -sha1 -DC:\SPEEDT~1 XA02BB~1 Output ; SlavaSoft Optimizing Checksum Utility - fsum 2.51 ; ; Generated on 05/15/06 at 17:28:36 ; NOT FOUND ***** xAy Process "Pyhton Interpeter" terminated, ExitCode: 00000000 ########################################### It is interesting. In my working machine the code of my shortpath routine generating xAy result as short filename. In my notebook (as you see) it is generate XA02BB~1 file name. This filename not found by FSUM.exe. If I open it as: f=open(shortfilepath,'r') print f.read() it is working from Python, show the file content good. Hmmmm..... Is Windows doesn't have compatible way of file reading ??? (In this notebook I see any interesting things too. Some file copied from CD - I got invalid times for them. When I copy them to my working machine, everything is ok. Windows not compatible itself... :-((( Both of machines have WXP, same updates in them, and NTFS used. What is different ? I don't know) Hi: dd DurumDara ?rta: > John Machin ?rta: > >> Looks like you need a GetShortPathNameW() but it's not implemented. >> Raise it as an issue on the pywin32 sourceforge bug register. >> Tell Mark >> I sent you :-) >> Another thought: try using ctypes. >> > > Hi ! > > It seems to be I found a solution. A little tricky, but it is > working: > ##################################################################### > import sys,os > from sys import argv as sysargv > > UFN=u'%s\\xA\xff'%os.getcwd() > if os.path.exists(UFN): > os.remove(UFN) > > f=open(UFN,'w') > f.write('%s\n'%('='*80)) > f.close() > > from ctypes import windll, create_unicode_buffer, sizeof, WinError > buf=create_unicode_buffer(512) > if windll.kernel32.GetShortPathNameW(UFN,buf,sizeof(buf)): > fname=buf.value > #import win32api > #dfn=win32api.GetShortPathName(name) > #print dfn > else: > raise > shortpath,filename=os.path.split(fname) > > import win32file > filedatas=win32file.FindFilesW(fname) > fd=filedatas[0] > shortfilename=fd[9] or fd[8] > > shortfilepath=os.path.join(shortpath,shortfilename) > > print [UFN] > print shortfilepath > > f=open(shortfilepath,'r') > print f.read() > > sys.exit() > > But I don't understand: why the shortpathw not convert the > filename too (like dir) ? > > > Thanx for help: > dd > John Machin ?rta: > According to my reading of the source, the function you have called > expects an 8-bit string. > ==== > static PyObject * > PyGetShortPathName(PyObject * self, PyObject * args) > { > char *path; > if (!PyArg_ParseTuple(args, "s:GetShortPathName", &path)) > ==== > If it is given Unicode, PyArg_ParseTuple will attempt to encode it > using the default encoding (ascii). Splat. > > Looks like you need a GetShortPathNameW() but it's not implemented. > Raise it as an issue on the pywin32 sourceforge bug register. Tell > Mark > I sent you :-) > > It may be possible to fake up your default encoding to say cp1252 BUT > take the advice of anyone who screams "Don't do that!" and in any > case > this wouldn't help you with a Russian, Chinese, etc etc filename. > > Another thought: try using ctypes. > Hi ! I trying with that, but I get error, because the result is unicode too... :-((( from ctypes import windll, create_unicode_buffer, sizeof, WinError buf=create_unicode_buffer(512) if windll.kernel32.GetShortPathNameW(UFN,buf,sizeof(buf)): name=buf.value print [name] ###################################################### Commandline: C:\Python24\python.exe G:\SPEEDT~1\Module1.py Workingdirectory: G:\speedtest Timeout: 0 ms [u'G:\\SPEEDT~1\\xA\xff'] Process "Pyhton Interpeter" terminated, ExitCode: 00000000 ###################################################### Can I do anything with this unicoded filename ? My code must be universal ! Thanx for help: dd _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Thu May 25 01:02:52 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 25 May 2006 09:02:52 +1000 Subject: [python-win32] Try to got short path for files - but got error... In-Reply-To: <44746A4A.8090908@gmail.com> Message-ID: I'm afraid your message isn't very clear. You should try and copy the smallest possible code that demonstrates your problem, exactly as Bobby did in his reply. > > I got errors with unicode file names. See my unicode test file name: > UFN=u'%s\\xA\xff'%os.getcwd() Is that what you mean? You have a literal backslash, followed by 'xa', followed by unicode char ff. Eg: >>> u'%s\\xA\xff'%os.getcwd() u'c:\\src\\xA\xff' >>> The 'xA' is *not* a unicode char in your example. > I want to get an universal code the convert (unicode) long path to short > path. There is no way you can do that. Windows allocates the short name for a file as it is created. That short name is not guaranteed to be the same on 2 different machines. The only way to get the short name is to ask Windows for it. > >> Looks like you need a GetShortPathNameW() but it's not implemented. > >> Raise it as an issue on the pywin32 sourceforge bug register. > >> Tell Mark > >> I sent you :-) > >> Another thought: try using ctypes. Note that Windows uses MBCS encoding - so you can use win32api.GetShortPathName(filename).decode('mbcs') to get the unicode filename. That only works if the unicode characters are all in your current codepage, but that is usually the case. GetShortPathName does need upgrading to accept a unicode object and in that case call GetShortPathNameW. Cheers, Mark From bwmetz at att.com Thu May 25 03:01:07 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Wed, 24 May 2006 20:01:07 -0500 Subject: [python-win32] Try to got short path for files - but goterror... In-Reply-To: Message-ID: <01D5341D04A2E64AB9B345769047336701D3776B@OCCLUST01EVS1.ugd.att.com> FYI, looking around a bit on Google it appears this question has been posted before without a clear answer...in fact, lots of places without clear answers. One guy went so far as to "cheat" as he put and used WSH. But that's not much better than my "cheat". So, aside from Mark's short code request, I'd suggest spending some more time with Google. Mark, Do you know if it's possible to get all the usual "right-click" file properties using win32com or ctypes? I know Windows presents short names via properties, but wasn't sure that's exposed via either. I googled this but didn't see a clear direction after the first 50 hits. May be a bad search on my part. Bobby -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Mark Hammond Sent: Wednesday, May 24, 2006 4:03 PM To: DurumDara; python-win32 at python.org Subject: Re: [python-win32] Try to got short path for files - but goterror... I'm afraid your message isn't very clear. You should try and copy the smallest possible code that demonstrates your problem, exactly as Bobby did in his reply. > > I got errors with unicode file names. See my unicode test file name: > UFN=u'%s\\xA\xff'%os.getcwd() Is that what you mean? You have a literal backslash, followed by 'xa', followed by unicode char ff. Eg: >>> u'%s\\xA\xff'%os.getcwd() u'c:\\src\\xA\xff' >>> The 'xA' is *not* a unicode char in your example. > I want to get an universal code the convert (unicode) long path to short > path. There is no way you can do that. Windows allocates the short name for a file as it is created. That short name is not guaranteed to be the same on 2 different machines. The only way to get the short name is to ask Windows for it. > >> Looks like you need a GetShortPathNameW() but it's not implemented. > >> Raise it as an issue on the pywin32 sourceforge bug register. > >> Tell Mark > >> I sent you :-) > >> Another thought: try using ctypes. Note that Windows uses MBCS encoding - so you can use win32api.GetShortPathName(filename).decode('mbcs') to get the unicode filename. That only works if the unicode characters are all in your current codepage, but that is usually the case. GetShortPathName does need upgrading to accept a unicode object and in that case call GetShortPathNameW. Cheers, Mark _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Thu May 25 03:15:28 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 25 May 2006 11:15:28 +1000 Subject: [python-win32] Try to got short path for files - but goterror... In-Reply-To: <01D5341D04A2E64AB9B345769047336701D3776B@OCCLUST01EVS1.ugd.att.com> Message-ID: > Mark, > Do you know if it's possible to get all the usual "right-click" > file properties using win32com or ctypes? I know Windows presents short > names via properties, but wasn't sure that's exposed via either. I > googled this but didn't see a clear direction after the first 50 hits. > May be a bad search on my part. I believe all properties can be fetched fine, including 'extended' properties via COM. But I've lost the context here - 'clear direction' for what exactly? eg, I created a long filename c:\temp\Copyright someone.txt and: >>> win32api.GetShortPathName(u"c:\\temp\\\xa9opyright someone.txt".encode("mbcs")) 'c:\\temp\\OPYRIG~1.TXT' >>> open('c:\\temp\\OPYRIG~1.TXT') >>> It also dawned on me that the "short name" of a file should never contain unicode characters! That seems to be demonstrated above... Mark From rwupole at msn.com Thu May 25 09:08:10 2006 From: rwupole at msn.com (Roger Upole) Date: Thu, 25 May 2006 03:08:10 -0400 Subject: [python-win32] Re: Try to got short path for files - but got error... Message-ID: One thing to bear in mind is that short path names won't always be available. You can disable them on NTFS systems. Roger From luc.saffre at gmx.net Thu May 25 11:02:37 2006 From: luc.saffre at gmx.net (Luc Saffre) Date: Thu, 25 May 2006 12:02:37 +0300 Subject: [python-win32] Getting pywin32 build number In-Reply-To: <94a776e70510280829q1c7550a3wf78cac4121fb04d8@mail.gmail.com> References: <94a776e70510271442y60a05b5bt8778d33898282524@mail.gmail.com> <94a776e70510280829q1c7550a3wf78cac4121fb04d8@mail.gmail.com> Message-ID: <447572AD.2050600@gmx.net> I support Justin's request: the pywin32.version.txt has been a big step forward, but it is still not easy to get this information (in a reliable way) from within user code. Python packages usually provide a __version__ variable in their __init__.py. http://www.python.org/~jeremy/weblog/030924.html http://www.python.org/dev/peps/pep-0314/ It is true that pywin32 has a lot of modules, so you must use some trick to avoid having to update each __init__.py manually before a release. Luc On 28.10.2005 18:29, Justin Johnson wrote: > Would you be opposed to introducing a variable with the version number > so it can be accessed more conveniently? > > On 10/27/05, *Mark Hammond* > wrote: > > Nope, that's it - or you could use win32apiGetFileVersionInfo to > check a specific DLL/.pyd. > > Mark. > > -----Original Message----- > *From:* python-win32-bounces at python.org > > [mailto:python-win32-bounces at python.org > ]*On Behalf Of *Justin > Johnson > *Sent:* Friday, 28 October 2005 7:43 AM > *To:* python-win32 at python.org > *Subject:* [python-win32] Getting pywin32 build number > > Is the build number for pywin32 (win32all) available anywhere > other than pywin32.version.txt sitting in site-packages? I want > to raise an exception if the wrong version is installed. I can > read this file if needed, but it seems like there should already > be a variable or function for getting this. > > Thanks, > Justin > From bwmetz at att.com Thu May 25 12:12:29 2006 From: bwmetz at att.com (Metz, Bobby W, WWCS) Date: Thu, 25 May 2006 05:12:29 -0500 Subject: [python-win32] Try to got short path for files - but goterror... In-Reply-To: Message-ID: <01D5341D04A2E64AB9B345769047336701D377B1@OCCLUST01EVS1.ugd.att.com> Mark, Thanks for that. I didn't read an earlier entry from the submitter close enough. Someone else had told them that GetShortPathName wasn't supported but I didn't pay attention to the W at the end...could have saved myself a couple of posts if I had. I'll chalk my "lack of clear direction" up to this as well...I was excluding GetShortPathName in my search due to comment below. >> Looks like you need a GetShortPathNameW() but it's not implemented. >> Raise it as an issue on the pywin32 sourceforge bug register. >> Tell Mark >> I sent you :-) Thanks, Bobby -----Original Message----- From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: Wednesday, May 24, 2006 6:15 PM To: Metz, Bobby W, WWCS; DurumDara; python-win32 at python.org Subject: RE: [python-win32] Try to got short path for files - but goterror... > Mark, > Do you know if it's possible to get all the usual "right-click" > file properties using win32com or ctypes? I know Windows presents short > names via properties, but wasn't sure that's exposed via either. I > googled this but didn't see a clear direction after the first 50 hits. > May be a bad search on my part. I believe all properties can be fetched fine, including 'extended' properties via COM. But I've lost the context here - 'clear direction' for what exactly? eg, I created a long filename c:\temp\Copyright someone.txt and: >>> win32api.GetShortPathName(u"c:\\temp\\\xa9opyright someone.txt".encode("mbcs")) 'c:\\temp\\OPYRIG~1.TXT' >>> open('c:\\temp\\OPYRIG~1.TXT') >>> It also dawned on me that the "short name" of a file should never contain unicode characters! That seems to be demonstrated above... Mark From sjmachin at lexicon.net Thu May 25 12:27:40 2006 From: sjmachin at lexicon.net (John Machin) Date: Thu, 25 May 2006 20:27:40 +1000 Subject: [python-win32] Try to got short path for files - but goterror... In-Reply-To: <01D5341D04A2E64AB9B345769047336701D377B1@OCCLUST01EVS1.ugd.att.com> References: <01D5341D04A2E64AB9B345769047336701D377B1@OCCLUST01EVS1.ugd.att.com> Message-ID: <4475869C.4080007@lexicon.net> On 25/05/2006 8:12 PM, Metz, Bobby W, WWCS wrote: > Mark, > Thanks for that. I didn't read an earlier entry from the > submitter close enough. Someone else had told them that > GetShortPathName wasn't supported but I didn't pay attention to the W at > the end...could have saved myself a couple of posts if I had. I'll > chalk my "lack of clear direction" up to this as well...I was excluding > GetShortPathName in my search due to comment below. > >>> Looks like you need a GetShortPathNameW() but it's not > implemented. >>> Raise it as an issue on the pywin32 sourceforge bug register. >>> Tell Mark >>> I sent you :-) > Oh boy am I glad that's been sorted out. It was in danger of becoming "Hysterically Confused Thread of the Month" :-) Cheers, "Someone else" From mhammond at skippinet.com.au Thu May 25 14:32:32 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 25 May 2006 22:32:32 +1000 Subject: [python-win32] Getting pywin32 build number In-Reply-To: <447572AD.2050600@gmx.net> Message-ID: > I support Justin's request: the pywin32.version.txt has been a big step > forward, but it is still not easy to get this information (in a reliable > way) from within user code. Python packages usually provide a > __version__ variable in their __init__.py. pywin32 has a few __init__.py files, and I'm reluctant to introduce a process that means many files need to be checked into CVS during the build/release process due to this. I'm not sure the pain that would cost me with each release is worth the pain it saves the few people who really need to fetch this programatically. After all, Pythonwin itself just locates this .txt file as that was simpler than anything more intrusive. > It is true that pywin32 has a lot of modules, so you must use some trick > to avoid having to update each __init__.py manually before a release. I'm open to patches that meet this compromise... Cheers, Mark From jpaulofarias at gmail.com Thu May 25 15:10:47 2006 From: jpaulofarias at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Paulo_Fernandes_Farias?=) Date: Thu, 25 May 2006 10:10:47 -0300 Subject: [python-win32] Getting the text out of a TVirtualStringTree Message-ID: Hi there! I've managed to get the text out of a SysListView32 and from a SysTreeView32. I've made a C extension for it. :-P Now I need to get the text out of a TVirtualStringTree, but that seems more difficult than other controls cause it is not a windows control, but a custom control. Anyone has any tips for that? -- JP From mark.m.mcmahon at gmail.com Thu May 25 19:31:49 2006 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Thu, 25 May 2006 13:31:49 -0400 Subject: [python-win32] 0.3.5 Moved to Metaclass control wrapping (and some mini fixes) Message-ID: <71b6302c0605251031v4f731469w90cb8156ec28b97d@mail.gmail.com> Hi, 0.3.5 release of pywinauto is now available. pywinauto is a set of open-source (LGPL) modules for using Python as a GUI automation 'driver' for Windows NT based Operating Systems (NT/W2K/XP). SourceForge project page: http://sourceforge.net/projects/pywinauto Download from SourceForge http://sourceforge.net/project/showfiles.php?group_id=157379 Here is the list of changes from 0.3.4: 0.3.5 Moved to Metaclass control wrapping ------------------------------------------------------------------ 24-May-2006 * Moved to a metaclass implementation of control finding. This removes some cyclic importing that had to be worked around and other then metaclass magic makes the code a bit simpler. * Some of the sample files would not run - so I updated them so they would (Thanks to Stefaan Himpe for pointing this out) * Disabled saving application data (it was still being saved in Application.RecordMatch() even if the rest of the application data code is disabled. This was causing what appeared to be a memory leak where pywinauto would keep grabbing more and more memory (especially for controls that contain a lot of information). Thanks to Frank Martinez for leading me to this). * Added ListViewWrapper.GetItemRect() to enable retrieving the rectangle for a particular item in the listview. * Removed references to _ctrl() method within pywinauto as it was raising a DeprecationWarning internally even if the user was not using it. If you want to follow this project then please sign up to the mailing list: https://lists.sourceforge.net/mailman/listinfo/pywinauto-users Thanks Mark -------------------------------------------- Mark Mc Mahon Manchester, NH 03110, USA

pywinauto 0.3.5 Simple Windows GUI automation with Python. (25-May-06) From B.P.S.Thurin at city.ac.uk Thu May 25 20:43:40 2006 From: B.P.S.Thurin at city.ac.uk (B.P.S.Thurin at city.ac.uk) Date: 25 May 2006 19:43:40 +0100 Subject: [python-win32] deviceiocontrol string format Message-ID: Dear All, I am new to python win32, and i cannot figure out how to format the data string for deviceiocontrol code with win32file. I have the following c struct in my driver file: typedef struct _WRITE_DEVICE_DATA_INPARAMS { UCHAR ucMemorySpace; // 0: I/O Space, 1: Mem Space. ULONG ulPhysicalAddress; // Dword-aligned offset to write to. ULONG ulItemSize; // 1: Byte, 2: Word, 4: Dword. ULONG ulItemCount; // Number of bytes, words or dwords. union{ UCHAR vucDataBuf[1]; USHORT vusDataBuf[1]; ULONG vulDataBuf[1]; }data; }WRITE_DEVICE_DATA_INPARAMS, *PWRITE_DEVICE_DATA_INPARAMS; I tried to format my data string like this: data=struct.pack('BLLLH',2,1020,2,1,0) but got the following error: OverflowError: long int too large to convert to int Apparentely the error is coming from 1020. However it is define as ulong for both case the c struct and the python struct.pack. Thanks in advance for your help Regards Brice From luc.saffre at gmx.net Fri May 26 01:12:01 2006 From: luc.saffre at gmx.net (Luc Saffre) Date: Fri, 26 May 2006 02:12:01 +0300 Subject: [python-win32] Getting pywin32 build number In-Reply-To: References: Message-ID: <447639C1.2000504@gmx.net> On 25.05.2006 15:32, Mark Hammond wrote: > I'm open to patches that meet this compromise... I am just thinking aloud... mkdir win32 echo '__version__="209"' > win32/__init__.py echo 'File win32/__init__.py contains the version number' \ > pywin32.version.txt Afterwards it isn't even necessary afaics to add to each __init__.py a line "from win32 import __version__". I'd rather consider moving most win32xxx packages to win32.xxx. For backward compatibility you would need a win32xxx package that does something like "from win32.xxx import *" (this wouldn't work in fact, but maybe there is a solution for this). Because the reason why you have a problem with versioning at all is that you have no top-level module. (Again, I am just thinking aloud.) Luc From derobins at scs.uiuc.edu Fri May 26 01:27:54 2006 From: derobins at scs.uiuc.edu (Dana Robinson) Date: Thu, 25 May 2006 18:27:54 -0500 Subject: [python-win32] Method is actually a property" Message-ID: Hello, I'm trying to use a COM object that has a function with a signature like this: HRESULT put_Foo(int i, DOUBLE val); The code generated by makepy includes this: # The method Foo is actually a property, but must be used as a method to correctly pass the arguments def Foo(self, i=defaultNamedNotOptArg): """property Foo""" return self._oleobj_.InvokeTypes(30, LCID, 2, (4, 0), ((3, 1),),i) How do I set this? If I try to call Foo(0, 1.0) it (obviously) complains about an incorrect number of arguments. How do I pass it the double? Thanks, Dana From sjmachin at lexicon.net Fri May 26 02:07:37 2006 From: sjmachin at lexicon.net (John Machin) Date: Fri, 26 May 2006 10:07:37 +1000 Subject: [python-win32] deviceiocontrol string format In-Reply-To: References: Message-ID: <447646C9.60501@lexicon.net> On 26/05/2006 4:43 AM, B.P.S.Thurin at city.ac.uk wrote: > Dear All, > > I am new to python win32, and i cannot figure out how to format the data > string for deviceiocontrol code with win32file. > > I have the following c struct in my driver file: > typedef struct _WRITE_DEVICE_DATA_INPARAMS > { > UCHAR ucMemorySpace; // 0: I/O Space, 1: Mem Space. > ULONG ulPhysicalAddress; // Dword-aligned offset to write to. > ULONG ulItemSize; // 1: Byte, 2: Word, 4: Dword. > ULONG ulItemCount; // Number of bytes, words or dwords. > > union{ > UCHAR vucDataBuf[1]; > USHORT vusDataBuf[1]; > ULONG vulDataBuf[1]; > }data; > > }WRITE_DEVICE_DATA_INPARAMS, *PWRITE_DEVICE_DATA_INPARAMS; > > I tried to format my data string like this: > data=struct.pack('BLLLH',2,1020,2,1,0) > > but got the following error: > OverflowError: long int too large to convert to int It would help if you showed the code that you actually executed and the traceback. There is no problem with the above pack call: Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import struct >>> data=struct.pack('BLLLH',2,1020,2,1,0) >>> data '\x02\x00\x00\x00\xfc\x03\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x00\x00' >>> hex(1020) '0x3fc' Perhaps you meant that the error is coming from deviceiocontrol. You will notice that the first item is padded out with 3 bytes of \x00 so that the 2nd item is aligned on a 32-bit boundary. This may be the cause of your problem. The error that you got is consistent with something trying to convert (positive) 0xFC000000L to a *signed* 32-bit integer. Why signed, I don't know. What does &(mystruct.ulPhysicalAddress) - &(mystruct.ucMemorySpace) [warning: my C is a little rusty!] give you in C (using the compiler used for the driver)? If the answer is 1, you need to lose the padding; read the fine print at the end of the struct.pack manual section. Note that the default alignment used is according to the C compiler used to compile Python (Microsoft), which may differ from the alignment used by the compiler used for the driver (gcc?). If the answer is 4, then the problem is not with your usage of struct.pack. > > Apparentely the error is coming from 1020. However it is define as ulong > for both case the c struct and the python struct.pack. > HTH, John From derobins at scs.uiuc.edu Fri May 26 02:24:28 2006 From: derobins at scs.uiuc.edu (Dana Robinson) Date: Thu, 25 May 2006 19:24:28 -0500 Subject: [python-win32] Fixed - Method is actually a property Message-ID: I found the solution to my own problem. I didn't realize that makepy would make me a set function with a Set prefix. D From mhammond at skippinet.com.au Fri May 26 06:12:24 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 26 May 2006 14:12:24 +1000 Subject: [python-win32] Try to got short path for files - but goterror... In-Reply-To: <4475869C.4080007@lexicon.net> Message-ID: > On 25/05/2006 8:12 PM, Metz, Bobby W, WWCS wrote: > > Mark, > > Thanks for that. I didn't read an earlier entry from the > > submitter close enough. Someone else had told them that > > GetShortPathName wasn't supported but I didn't pay attention to the W at > > the end...could have saved myself a couple of posts if I had. I'll > > chalk my "lack of clear direction" up to this as well...I was excluding > > GetShortPathName in my search due to comment below. > > > >>> Looks like you need a GetShortPathNameW() but it's not > > implemented. > >>> Raise it as an issue on the pywin32 sourceforge bug register. > >>> Tell Mark > >>> I sent you :-) > > > > Oh boy am I glad that's been sorted out. It was in danger of becoming > "Hysterically Confused Thread of the Month" :-) Hi John! I'm surprised you didn't chastise me until I produced a better example that fully demonstrates the obscure corners in this area . For example, the open() builtin (plus many other related functions) natively support Unicode strings and calls the unicode versions of the underlying Microsoft C runtime functions. The following demonstrates this, and doesn't rely on an already existing file: >>> open(u"c:\\temp\\\xa9opyright someone.txt", "w").write('hello there!') >>> win32api.GetShortPathName(u"c:\\temp\\\xa9opyright someone.txt".encode("mbcs")) 'c:\\temp\\OPYRIG~1.TXT' >>> open('c:\\temp\\OPYRIG~1.TXT').read() 'hello there!' >>> In this example, pywin32 is the 'weak-link' in the Unicode story - and that doesn't sound like something we can let stand - so I just checked in a change that if win32api.GetShortPathName() is passed unicode, it calls GetShortPathNameW and returns a unicode object. So in the next build, you will see: >>> win32api.GetShortPathName(u"c:\\temp\\\xa9opyright someone.txt") u'c:\\temp\\OPYRIG~1.TXT' Cheers, Mark From timr at probo.com Fri May 26 20:46:49 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 26 May 2006 11:46:49 -0700 Subject: [python-win32] deviceiocontrol string format In-Reply-To: References: Message-ID: <44774D19.4020002@probo.com> On 25 May 2006 19:43:40 +0100, B.P.S.Thurin at city.ac.uk wrote: >I am new to python win32, and i cannot figure out how to format the data >string for deviceiocontrol code with win32file. > >I have the following c struct in my driver file: >typedef struct _WRITE_DEVICE_DATA_INPARAMS >{ > UCHAR ucMemorySpace; // 0: I/O Space, 1: Mem Space. > ULONG ulPhysicalAddress; // Dword-aligned offset to write to. > ULONG ulItemSize; // 1: Byte, 2: Word, 4: Dword. > ULONG ulItemCount; // Number of bytes, words or dwords. > > union{ > UCHAR vucDataBuf[1]; > USHORT vusDataBuf[1]; > ULONG vulDataBuf[1]; > }data; > >}WRITE_DEVICE_DATA_INPARAMS, *PWRITE_DEVICE_DATA_INPARAMS; > > This is not a good design, because it leaves open the question of padding. Unless you have overridden the normal #pragma pack, there will be three bytes of padding between "ucMemorySpace" and "ulPhysicalAddress". If you should happen to use different packing in your driver and your app, disaster will ensue. You should probably just make MemorySpace a ULONG so there is no possibility for confusion. If ulPhysicalAddress is an offset, you should call it "ulOffset". The term "physical address" has a very specific meaning in Windows, and 32-bit is not enough to hold a real physical address. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From durumdara at gmail.com Mon May 29 13:01:31 2006 From: durumdara at gmail.com (DurumDara) Date: Mon, 29 May 2006 13:01:31 +0200 Subject: [python-win32] Try to got short path for files - but got error... In-Reply-To: References: Message-ID: <447AD48B.5000307@gmail.com> Mark Hammond ?rta: > I'm afraid your message isn't very clear. You should try and copy the > smallest possible code that demonstrates your problem, exactly as Bobby did > in his reply. > Hi everybody ! The short path project is continue... I answer in this email to all question ! First of all: I needed a utility that can create sha1/md5 checksums for disk (every files, and totals). I wrote this program in python, and compiled with py2exe. The working method is based on os.listdir, and normal file operations. But the customer (the main user) reported many bugs in this application. All of them caused by non-english characters (unicode things, os and code page dependent words). We use this app. in Central Europe, so we got disks with many langs (english, hungarian, czeh, slovenian, russian, etc.). Every of the encodings are different. Interesting: I found in my hun. os HDD a russian folder with russian chars, because I installed a russian software formerly. The os/os.path modules not working good with these filenames. In this point I subst. them with win32file/api. FindFilesW working good, and it is eating everything - special chars, unicode range, etc. My code working stable ! Wow ! I thought: this is victory ! But: I must reorganize my code, because the customer need better speed for this app. Ok. I thinking about profiling, and optimizing (now also). I see: the most time usage is in sha/md5 calculator, and in disk operations. With these exps. I downloaded FSUM program. Everything is good with this - I see, that it's performance better than native py code. But when I tested with unicode libraries, I got error. I need to start this program with input paramteres. But this is "DOS area", special characters are not working - I need to convert them. One chance for this the MS specific short paths. So I tried this with many method. See this code. This is demonstrate my problem. I remark to better understanding. ################################################################################ import os,sys,win32file,win32api,subprocess # Making of special directory with unicode chars dirname=u'LongDirxA\xff' if not os.path.exists(dirname): os.makedirs(dirname) # This is the special filename UFN=u'%s\\%s\\LongFilexA\xff.txt'%(os.getcwd(),'%s') UFN=UFN%(dirname) # The file content writing to later test (reload with py) content=str(range(40)) f=open(UFN,'w') f.write(content) f.close() # Show info print "Original filename" print [UFN] # Simple way - but this is not working. See later def W32APIShortPathName(UFileName): return win32api.GetShortPathName(UFileName) # Use Ctypes. Better, but... def WinCTypesSPNW(UFileName): from ctypes import windll, create_unicode_buffer, sizeof, WinError buf=create_unicode_buffer(512) if windll.kernel32.GetShortPathNameW(UFileName,buf,sizeof(buf)): return buf.value else: raise Exception,'SPW convert error !' # Special way. Use FindFilesW to convert to short path def SplitAndFind(UFileName): Tags=[] drive,path=os.path.splitdrive(UFileName) drives=drive+'\\' while 1: if UFileName==drives: break filedatas=win32file.FindFilesW(UFileName) fd=filedatas[0] shorttag=fd[9] or fd[8] Tags.append(shorttag) split=os.path.split(UFileName) if len(split)<2: break UPath,UFile=split UFileName=UPath Tags.append(drive) Tags.reverse() return "\\".join(Tags) # Test functions _funcs=[W32APIShortPathName, WinCTypesSPNW, SplitAndFind] # Converter def ConvertFileNameToShortName(UFileName): r=[] # With every of these funcs. for func in _funcs: # try to convert, and get result/error fnstr=str(func) try: shortfn=func(UFileName) exc=None except Exception,v: shortfn=None exc=v r.append([func,shortfn,exc]) return r # The tester def TestShortsAndLongs(UFileName): # Convert all of them shorts=ConvertFileNameToShortName(UFN) print "Try to use FSUM without shortfilename" try: # Try to forward params to FSUM spath,sfn=os.path.split(UFileName) cmd=['%s\\fsum.exe'%os.getcwd(),'-sha1','-D"%s"'%spath,sfn] #print cmd po=subprocess.Popen(cmd,stdout=subprocess.PIPE) output=po.communicate()[0] print "Output",output except Exception,v: print v print # Same thing, but with converted filenames print "Try to use FSUM with shortfilenames" for func,shortfn,exc in shorts: print "\n",func if shortfn: print shortfn spath,sfn=os.path.split(shortfn) cmd=['%s\\fsum.exe'%os.getcwd(),'-sha1','-D%s'%spath,sfn] #print cmd po=subprocess.Popen(cmd,stdout=subprocess.PIPE) output=po.communicate()[0] print "Output",output con=open(shortfn,'r').read() print con else: print "Error:",exc TestShortsAndLongs(UFN) ################################################################################ That was the code. Simple. The result (sorry for hungarian windows messages): ================================================================================ Commandline: C:\Python24\python.exe C:\SPEEDT~1\fsumunic\UNITOS~1.PY Workingdirectory: C:\speedtest\fsumunic Timeout: 0 ms SlavaSoft Optimizing Checksum Utility - fsum 2.51 Implemented using SlavaSoft QuickHash Library Copyright (C) SlavaSoft Inc. 1999-2004. All rights reserved. SlavaSoft Optimizing Checksum Utility - fsum 2.51 Implemented using SlavaSoft QuickHash Library Copyright (C) SlavaSoft Inc. 1999-2004. All rights reserved. Original filename [u'C:\\speedtest\\fsumunic\\LongDirxA\xff\\LongFilexA\xff.txt'] Try to use FSUM without shortfilename 'ascii' codec can't encode character u'\xff' in position 72: ordinal not in range(128) Try to use FSUM with shortfilenames Error: 'ascii' codec can't encode character u'\xff' in position 31: ordinal not in range(128) C:\SPEEDT~1\fsumunic\LONGDI~1\LONGFI~1.TXT Output ; SlavaSoft Optimizing Checksum Utility - fsum 2.51 ; ; Generated on 05/26/06 at 19:00:12 ; NOT FOUND ***** LongFilexAy.txt [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39] C:\SPEEDT~1\fsumunic\LONGDI~1\LONGFI~1.TXT Output ; SlavaSoft Optimizing Checksum Utility - fsum 2.51 ; ; Generated on 05/26/06 at 19:00:12 ; NOT FOUND ***** LongFilexAy.txt [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39] Process "Pyhton Interpeter" terminated, ExitCode: 00000000 ================================================================================ Then I try to see dir command's output: ================================================================================ c:\speedtest\fsumunic>dir LONGDI~1 A meghajt?ban (C) l?v? k?tet Christ. A k?tet sorozatsz?ma: 2CC1-B5AE c:\speedtest\fsumunic\LONGDI~1 tartalma: 2006.05.26. 18:30

. 2006.05.26. 18:30 .. 2006.05.26. 19:00 150 LongFilexAy.txt 1 f?jl 150 b?jt 2 k?nyvt?r 1 013 125 120 b?jt szabad c:\speedtest\fsumunic>dir /x LONGDI~1\ A meghajt?ban (C) l?v? k?tet Christ. A k?tet sorozatsz?ma: 2CC1-B5AE c:\speedtest\fsumunic\LONGDI~1 tartalma: 2006.05.26. 18:30 . 2006.05.26. 18:30 .. 2006.05.26. 19:00 150 LONGFI~1.TXT LongFilexAy.txt 1 f?jl 150 b?jt 2 k?nyvt?r 1 013 125 120 b?jt szabad c:\speedtest\fsumunic> ================================================================================ Ok, files are good. :-) Try to make by hand: ================================================================================ c:\speedtest\fsumunic>C:\\speedtest\\fsumunic\\fsum.exe -sha1 -DC:\SPEEDT~1\fsum unic\LONGDI~1 LONGFI~1.TXT SlavaSoft Optimizing Checksum Utility - fsum 2.51 Implemented using SlavaSoft QuickHash Library Copyright (C) SlavaSoft Inc. 1999-2004. All rights reserved. ; SlavaSoft Optimizing Checksum Utility - fsum 2.51 ; ; Generated on 05/26/06 at 19:08:41 ; NOT FOUND ***** LongFilexAy.txt c:\speedtest\fsumunic> ================================================================================ Try to make by hand without file spec -> all file: ================================================================================ c:\speedtest\fsumunic>fsum -sha1 -Dlongdi~1 * SlavaSoft Optimizing Checksum Utility - fsum 2.51 Implemented using SlavaSoft QuickHash Library Copyright (C) SlavaSoft Inc. 1999-2004. All rights reserved. ; SlavaSoft Optimizing Checksum Utility - fsum 2.51 ; ; Generated on 05/28/06 at 14:55:31 ; NOT FOUND ***** LongFilexAy.txt ================================================================================ Test with secondary file to test working: ================================================================================ c:\speedtest\fsumunic>fsum -sha1 -Dlongdi~1 * SlavaSoft Optimizing Checksum Utility - fsum 2.51 Implemented using SlavaSoft QuickHash Library Copyright (C) SlavaSoft Inc. 1999-2004. All rights reserved. ; SlavaSoft Optimizing Checksum Utility - fsum 2.51 ; ; Generated on 05/28/06 at 14:56:32 ; NOT FOUND ***** LongFilexAy.txt 4b964d5dd7113e0683c4c0c252f4dd26cea26506 ?SHA1*test.xxx c:\speedtest\fsumunic> ================================================================================ So as you see, the FSUM cannot working with unicode and shortpath based files. That was the first story. I answer here to your questions: 1.) >One thing to bear in mind is that short path names >won't always be available. You can disable them >on NTFS systems. Thank you for this info. I don't want to use a function based on non-stable (or disable) method... 2.) >Another workaround to try if GetShortPathNameW() is truly not available would be to use "dir". This is kludgy but will work if all your machines are using WinXP or 2000 I believe. For example, if I create a test file with contents "Hello World"... > import os, re > dirname = "c:\\speedtest" > longname = "This is Hello World.txt" > return_vals = os.popen('dir /x "' + dirname + '\\' + longname + '"').read() > shortname = re.findall("\s+(\S+)\s+" + longname, return_vals) > shortname This is not working with special chars (non-english chars). I hope this message clearer than previous. Ok, I found the error in FSUM, but the question is remaining in opened state, because every of the solutions are little complex, chaotic, or not speeding up my code. The main question - the parameterizing of subprocess (wroted by another developer) with unicode filenames, and the short path "misery"... Thanx for help, thanx for answers ! dd From durumdara at gmail.com Mon May 29 17:46:43 2006 From: durumdara at gmail.com (DurumDara) Date: Mon, 29 May 2006 17:46:43 +0200 Subject: [python-win32] Try to got short path for files - but got error... Message-ID: <447B1763.70507@gmail.com> Hi ! I wrote to Python list, but nobody answer to my problem. I copy these mails to this body. So: I need to optimize my disk hasher code. I need to make quick code, and I see that FSUM make better speed than python sha/md5 with py2exe. But I need to "transport" filenames to FSUM. I got errors with unicode file names. See my unicode test file name: UFN=u'%s\\xA\xff'%os.getcwd() I want to get an universal code the convert (unicode) long path to short path. Here are my tryings: Hi ! Ahhh... That is not working in my notebook... See the log of the program: ########################################### Commandline: C:\Python24\python.exe C:\SPEEDT~1\Module1.py Workingdirectory: C:\speedtest Timeout: 0 ms SlavaSoft Optimizing Checksum Utility - fsum 2.51 Implemented using SlavaSoft QuickHash Library Copyright (C) SlavaSoft Inc. 1999-2004. All rights reserved. ====================================== C:\speedtest\fsum.exe -sha1 -DC:\SPEEDT~1 XA02BB~1 Output ; SlavaSoft Optimizing Checksum Utility - fsum 2.51 ; ; Generated on 05/15/06 at 17:28:36 ; NOT FOUND ***** xAy Process "Pyhton Interpeter" terminated, ExitCode: 00000000 ########################################### It is interesting. In my working machine the code of my shortpath routine generating xAy result as short filename. In my notebook (as you see) it is generate XA02BB~1 file name. This filename not found by FSUM.exe. If I open it as: f=open(shortfilepath,'r') print f.read() it is working from Python, show the file content good. Hmmmm..... Is Windows doesn't have compatible way of file reading ??? (In this notebook I see any interesting things too. Some file copied from CD - I got invalid times for them. When I copy them to my working machine, everything is ok. Windows not compatible itself... :-((( Both of machines have WXP, same updates in them, and NTFS used. What is different ? I don't know) Hi: dd DurumDara ?rta: > John Machin ?rta: > >> Looks like you need a GetShortPathNameW() but it's not implemented. >> Raise it as an issue on the pywin32 sourceforge bug register. >> Tell Mark >> I sent you :-) >> Another thought: try using ctypes. >> > > Hi ! > > It seems to be I found a solution. A little tricky, but it is > working: > ##################################################################### > import sys,os > from sys import argv as sysargv > > UFN=u'%s\\xA\xff'%os.getcwd() > if os.path.exists(UFN): > os.remove(UFN) > > f=open(UFN,'w') > f.write('%s\n'%('='*80)) > f.close() > > from ctypes import windll, create_unicode_buffer, sizeof, WinError > buf=create_unicode_buffer(512) > if windll.kernel32.GetShortPathNameW(UFN,buf,sizeof(buf)): > fname=buf.value > #import win32api > #dfn=win32api.GetShortPathName(name) > #print dfn > else: > raise > shortpath,filename=os.path.split(fname) > > import win32file > filedatas=win32file.FindFilesW(fname) > fd=filedatas[0] > shortfilename=fd[9] or fd[8] > > shortfilepath=os.path.join(shortpath,shortfilename) > > print [UFN] > print shortfilepath > > f=open(shortfilepath,'r') > print f.read() > > sys.exit() > > But I don't understand: why the shortpathw not convert the > filename too (like dir) ? > > > Thanx for help: > dd > John Machin ?rta: > According to my reading of the source, the function you have called > expects an 8-bit string. > ==== > static PyObject * > PyGetShortPathName(PyObject * self, PyObject * args) > { > char *path; > if (!PyArg_ParseTuple(args, "s:GetShortPathName", &path)) > ==== > If it is given Unicode, PyArg_ParseTuple will attempt to encode it > using the default encoding (ascii). Splat. > > Looks like you need a GetShortPathNameW() but it's not implemented. > Raise it as an issue on the pywin32 sourceforge bug register. Tell > Mark > I sent you :-) > > It may be possible to fake up your default encoding to say cp1252 BUT > take the advice of anyone who screams "Don't do that!" and in any > case > this wouldn't help you with a Russian, Chinese, etc etc filename. > > Another thought: try using ctypes. > Hi ! I trying with that, but I get error, because the result is unicode too... :-((( from ctypes import windll, create_unicode_buffer, sizeof, WinError buf=create_unicode_buffer(512) if windll.kernel32.GetShortPathNameW(UFN,buf,sizeof(buf)): name=buf.value print [name] ###################################################### Commandline: C:\Python24\python.exe G:\SPEEDT~1\Module1.py Workingdirectory: G:\speedtest Timeout: 0 ms [u'G:\\SPEEDT~1\\xA\xff'] Process "Pyhton Interpeter" terminated, ExitCode: 00000000 ###################################################### Can I do anything with this unicoded filename ? My code must be universal ! Thanx for help: dd From gagsl-p32 at yahoo.com.ar Mon May 29 19:14:40 2006 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 29 May 2006 14:14:40 -0300 Subject: [python-win32] Try to got short path for files - but got error... In-Reply-To: <447AD48B.5000307@gmail.com> References: <447AD48B.5000307@gmail.com> Message-ID: <7.0.1.0.0.20060529135121.03ae0078@yahoo.com.ar> At Monday 29/5/2006 08:01, DurumDara wrote: >Ok, I found the error in FSUM, but the question is remaining in opened >state, >because every of the solutions are little complex, chaotic, or not >speeding up >my code. >The main question - the parameterizing of subprocess (wroted by another >developer) >with unicode filenames, and the short path "misery"... I've checked the FSUM homepage and it says: - FSUM is *not* a DOS program, but a console program for Windows 95/98/Me/NT/2000/XP. So in principle you are not limited to short file names, you could pass it the LONG filename (perhaps enclosed in double quotes). - FSUM is just a wrapper around the QuickHash library. They provide a TypeLibrary and a standalone DLL. You should be able to use win32com or ctypes to access them. Gabriel Genellina Softlab SRL ___________________________________________________________ 1GB gratis, Antivirus y Antispam Correo Yahoo!, el mejor correo web del mundo http://correo.yahoo.com.ar