From rwupole at msn.com Wed Mar 1 06:03:08 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 1 Mar 2006 00:03:08 -0500 Subject: [python-win32] Re: list of child processes from pywin32 Message-ID: > Is there a way to get a list of all children of a process via pywin32? > > These would be all processes launched from calls like popen(), system() > and QProcess(). > > Alternatively, is there a way to get the total CPU time (user and > kernel) of all children of a python session? > Note that os.times() does not work on Windows and on Linux it only post > the children time when the children exit. You can do this with WMI: import win32com.client wmi=win32com.client.GetObject('winmgmts:') for p in wmi.InstancesOf('win32_process'): print p.Name, p.Properties_('ProcessId'), \ int(p.Properties_('UserModeTime').Value)+int(p.Properties_('KernelModeTime').Value) children=wmi.ExecQuery('Select * from win32_process where ParentProcessId=%s' %p.Properties_('ProcessId')) for child in children: print '\t',child.Name,child.Properties_('ProcessId'), \ int(child.Properties_('UserModeTime').Value)+int(child.Properties_('KernelModeTime').Value) hth Roger From rwupole at msn.com Wed Mar 1 07:08:36 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 1 Mar 2006 01:08:36 -0500 Subject: [python-win32] Re: Windows "Browse to" message Message-ID: vince at weaktight.com wrote: > When you open an html file or click on a link outside of a browser, it opens it > in your default browser. What I'd like to do is to catpure this message and > grab the URL text string to see where the browser is going. > > I was looking at PyHook, but I don't think it intercepts all windows messages, > and I'm not sure this is a windows message per se. > > Any suggestions? > > thanks For opening local files, there's a registered handler for the file type. Take a look at HKEY_CLASSES_ROOT\htmlfile\shell\open\command which specifies the program that will open the file. You might be able to substitute your own handler, which just logs the request and then passes it off to the original program. The handler for internet protocol is under HKEY_CLASSES_ROOT\HTTP\shell\open\command, although you'd probably also need to change all handlers that point to your web browser (https, ftp, etc) hth Roger From upadhyay at gmail.com Wed Mar 1 07:48:21 2006 From: upadhyay at gmail.com (Amit Upadhyay) Date: Wed, 1 Mar 2006 12:18:21 +0530 Subject: [python-win32] IE toolbar button in Python Message-ID: <349edb380602282248r387b9e91m9dafd8f600815069@mail.gmail.com> Hi, I am trying to add a button to the toolbar in IE, and have been following http://msdn.microsoft.com/workshop/browser/ext/tutorials/button.asp, I am new to python, can anyone tell me how would I go about creating the COM object that implements IOleCommandTarget? A newbie with this kind of programming. Thanks, -- Amit Upadhyay Blog: http://www.rootshell.be/~upadhyay +91-9867-359-701 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060301/932cb8d6/attachment.htm From rwupole at msn.com Wed Mar 1 09:05:14 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 1 Mar 2006 03:05:14 -0500 Subject: [python-win32] Re: IE toolbar button in Python Message-ID: Amit Upadhyay wrote: > Hi, > > I am trying to add a button to the toolbar in IE, and have been following > http://msdn.microsoft.com/workshop/browser/ext/tutorials/button.asp, I am > new to python, can anyone tell me how would I go about creating the COM > object that implements > IOleCommandTarget? > A newbie with this kind of programming. > > Thanks, > There's an IE toolbar button demo in CVS: http://cvs.sourceforge.net/viewcvs.py/pywin32/pywin32/com/win32com/demos/iebutton.py?rev=1.1&view=log Roger From upadhyay at gmail.com Wed Mar 1 11:12:27 2006 From: upadhyay at gmail.com (Amit Upadhyay) Date: Wed, 1 Mar 2006 15:42:27 +0530 Subject: [python-win32] IE toolbar button in Python In-Reply-To: <349edb380603010158g1799d3bex1daad9dac018b751@mail.gmail.com> References: <349edb380603010158g1799d3bex1daad9dac018b751@mail.gmail.com> Message-ID: <349edb380603010212g951558bm73602a7a5412e1bf@mail.gmail.com> On 3/1/06, Amit Upadhyay wrote: > > > I am using build 204, and am right now downloading 207, which is latest on > sf.net. Will I have to get the latest from CVS for it to work? I tried 207, and its working, or atleast I am not getting that perticular error. Now I am getting: Traceback (most recent call last): File "iebutton.py", line 37, in ? win32com.client.gencache.EnsureModule ('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}',0,1,1) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 393, in EnsureModule module = GetModuleForTypelib(typelibCLSID, lcid, major, minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 258, in GetModuleForTypelib mod = _GetModule(modName) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 629, in _GetModule mod = __import__(mod_name) File "c:\python24\lib\site-packages\win32com\gen_py\EAB22AC0- 30C1-11CF-A7EB-0000C05BAE0Bx0x1x1.py", line 813 """method InvokeContextMenuCommand""" return self._oleobj_.InvokeTypes(8, LCID, 1, (24, 0), ((8, 1),),strCommand ^ SyntaxError: invalid syntax I have tried deleting the content of gen_py before starting that script again. -- Amit Upadhyay Blog: http://www.rootshell.be/~upadhyay +91-9867-359-701 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060301/c1c739c5/attachment.htm From wccppp at gmail.com Wed Mar 1 11:17:34 2006 From: wccppp at gmail.com (wccppp) Date: Wed, 1 Mar 2006 00:17:34 -1000 Subject: [python-win32] COM - question about DynamicPolicy.py Message-ID: <87bd46aa0603010217l1f3e36aduacec076a0e565d82@mail.gmail.com> Hello group, I was reading Chapter 12 of Python Programming on Win32 and trying to mimic the sample code DynamicPolicy.py. I wanted to expose methods/properties defined in the module os. Here is what I did. I only made very minor changes to the original code. It seems the COM server was registered. At least there was no error message. But when I tried testing it with VBA, nothing worked. Python code: # DynamicPolicy.py -- A demonstration of dynamic policies in PythonCOM import os import pythoncom import pywintypes import winerror import types from win32com.server.exception import COMException def FixArgs(args): ( I maded no change to this funtion) class PythonModuleOs: _reg_progid_ = "pymodule.os" _reg_clsid_ = "{67C9267A-55EE-4B17-A556-4FA34F42EE3F}" _reg_policy_spec_ = "DynamicPolicy" def _dynamic_(self, name, lcid, wFlags, args): the only change i made with this function is I changed try: item = getattr(string, string.lower(name)) to try: item = getattr(os, os.listdir(name)) VBA code for testing: Public Sub TestCOMServer() Dim pym As Variant Set pym = CreateObject("pymodule.os") MsgBox pym.listdir("C:\Temp") End Sub I got an error message: "No such file or directory: 'listdir' Can someone show me what needs to be done in order to create a COM server to expose other python modules? Btw, I didn't copy & post the original code because I'm not sure if it is ok to do so. Thank you. Regards, - wcc -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060301/7217fd02/attachment.html From jeff at lfchosting.com Wed Mar 1 14:12:50 2006 From: jeff at lfchosting.com (Jeff Fisher) Date: Wed, 01 Mar 2006 07:12:50 -0600 Subject: [python-win32] Certificate Services in Windows. Message-ID: <44059DD2.50809@lfchosting.com> Hi all, Has anyone ever used Python to work with Certificate Services in Windows? I'm trying to figure out if it is possible to import a certificate into a specific Window's Certificate Store. Jeff -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: OpenPGP digital signature Url : http://mail.python.org/pipermail/python-win32/attachments/20060301/31d8cabf/attachment.pgp From rwupole at msn.com Wed Mar 1 15:38:18 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 1 Mar 2006 09:38:18 -0500 Subject: [python-win32] Re: IE toolbar button in Python Message-ID: Amit Upadhyay wrote: > I tried 207, and its working, or atleast I am not getting that perticular > error. > > Now I am getting: > > Traceback (most recent call last): > File "iebutton.py", line 37, in ? > win32com.client.gencache.EnsureModule > ('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}',0,1,1) > File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line > 393, in EnsureModule > module = GetModuleForTypelib(typelibCLSID, lcid, major, minor) > File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line > 258, in GetModuleForTypelib > mod = _GetModule(modName) > File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line > 629, in _GetModule > mod = __import__(mod_name) > File "c:\python24\lib\site-packages\win32com\gen_py\EAB22AC0- > 30C1-11CF-A7EB-0000C05BAE0Bx0x1x1.py", line 813 > """method InvokeContextMenuCommand""" > return self._oleobj_.InvokeTypes(8, LCID, 1, (24, 0), ((8, > 1),),strCommand > ^ > SyntaxError: invalid syntax > > I have tried deleting the content of gen_py before starting that script > again. There was a bug in early versions of Python 2.4 that caused bogus syntax errors to be raised. Upgrading to 2.4.2 should solve that. However, it looks like you'll have to build Pywin32 from CVS for the demo to work. Roger From rwupole at msn.com Wed Mar 1 16:30:45 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 1 Mar 2006 10:30:45 -0500 Subject: [python-win32] Re: COM - question about DynamicPolicy.py Message-ID: You should be able to just change string to os: item = getattr(os, string.lower(name)) Roger From mc at mclaveau.com Wed Mar 1 16:49:49 2006 From: mc at mclaveau.com (Michel Claveau) Date: Wed, 1 Mar 2006 16:49:49 +0100 Subject: [python-win32] IE toolbar button in Python References: <349edb380603010158g1799d3bex1daad9dac018b751@mail.gmail.com> <349edb380603010212g951558bm73602a7a5412e1bf@mail.gmail.com> Message-ID: <000c01c63d47$c77ce020$0701a8c0@PORTABLES> Hi! Search ietoolbar.py, in the directories of standard install of PyWin32. Run OK (for me). It's not the good answer to your question, but near. *sorry for my bad english* @-salutations Michel Claveau From rwupole at msn.com Wed Mar 1 17:07:01 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 1 Mar 2006 11:07:01 -0500 Subject: [python-win32] Re: Certificate Services in Windows. Message-ID: Jeff Fisher wrote: > Hi all, > > Has anyone ever used Python to work with Certificate Services in > Windows? I'm trying to figure out if it is possible to import a > certificate into a specific Window's Certificate Store. You can use CAPICOM, which is an automation interface to the cryptography and certificate APIs. I don't think it comes installed on most systems, but you can download it from MSDN. Roger From Jeff.Kelliher at Eirgrid.com Wed Mar 1 10:01:29 2006 From: Jeff.Kelliher at Eirgrid.com (Jeff.Kelliher at Eirgrid.com) Date: Wed, 1 Mar 2006 09:01:29 -0000 Subject: [python-win32] merge Message-ID: <135B2D893B14904F9883052174E1732802A70037@egnexc1.grid.ie> Hi, I hope you can help me. I've been using Python with Access and Excel in conjunction with some power system software for some time now. One thing I've been unable to do is merge a defined quantity of cells in Excel with Python - I can merge entire rows and columns but can't determine the correct syntax to merge say five cells etc. Can anyone help? Best Regards, Jeff _____ Jeff Kelliher Transmission Network Planning, PSDM ESB National Grid Tel : +353 01 7026813 Mailto:Jeff.Kelliher at Ngrid.ie ******************************************************************* This E-mail message (including any attachments) is confidential and intended solely for the use of the individual or entity to whom it is addressed. If you have received the message in error, please notify security at eirgrid.com. The message has been scanned for viruses. ESB National Grid. ******************************************************************* -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060301/c82dc176/attachment.html From wccppp at gmail.com Wed Mar 1 19:11:28 2006 From: wccppp at gmail.com (wccppp) Date: Wed, 1 Mar 2006 08:11:28 -1000 Subject: [python-win32] COM - question about DynamicPolicy.py In-Reply-To: References: Message-ID: <87bd46aa0603011011r61fd07a2i7170a2afd979fb8f@mail.gmail.com> That solved the problem. And I think I got what is the "name" parameter is for now. Thank you so much Roger! - wcc On 3/1/06, Roger Upole wrote: > > You should be able to just change string to os: > item = getattr(os, string.lower(name)) > > Roger > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- Regards, - wcc -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060301/9bd5a0f7/attachment.html From vince at weaktight.com Wed Mar 1 23:46:11 2006 From: vince at weaktight.com (vince at weaktight.com) Date: Wed, 01 Mar 2006 17:46:11 -0500 Subject: [python-win32] Python-win32 Digest, Vol 36, Issue 1 In-Reply-To: References: Message-ID: <20060301174611.h7mhiezb9c48g088@webmail.weaktight.com> > vince at weaktight.com wrote: >> When you open an html file or click on a link outside of a browser, >> it opens it >> in your default browser. What I'd like to do is to catpure this message and >> grab the URL text string to see where the browser is going. >> >> I was looking at PyHook, but I don't think it intercepts all windows >> messages, >> and I'm not sure this is a windows message per se. >> >> Any suggestions? >> >> thanks > > For opening local files, there's a registered handler for the file type. > Take a look at HKEY_CLASSES_ROOT\htmlfile\shell\open\command > which specifies the program that will open the file. You might be able > to substitute your own handler, which just logs the request and then > passes it off to the original program. The handler for internet protocol is > under HKEY_CLASSES_ROOT\HTTP\shell\open\command, > although you'd probably also need to change all handlers that point > to your web browser (https, ftp, etc) > > hth > Roger Good idea. I tried this, however, modifying that key makes browsers unhappy as they think they're no longer the default browser. If this were a one-off solution, this would be good enough, but it needs to be transparent enough to keep the user happy. Perhaps I could catch the actual HTTP network request... that sounds scary though. From trent at oliphant.org Thu Mar 2 00:07:37 2006 From: trent at oliphant.org (Trent Oliphant) Date: Wed, 01 Mar 2006 16:07:37 -0700 Subject: [python-win32] merge In-Reply-To: <135B2D893B14904F9883052174E1732802A70037@egnexc1.grid.ie> References: <135B2D893B14904F9883052174E1732802A70037@egnexc1.grid.ie> Message-ID: <44062939.5040300@oliphant.org> You have to make sure you select a range first. (There may be other ways to do it, but I use "Range(Cells(row, column), Cells(row, column))") Then there are 2 ways you can do it using the Merge() and UnMerge() methods or setting the MergeCells Property to True or False >>> from win32com.client import Dispatch >>> ex = Dispatch("Excel.Application") >>> ws = ex.ActiveSheet #or any other way to get the sheet >>> myRange = ws.Range(ws.Cells(1,1),ws.Cells(1,5)) >>> myRange.MergeCells False >>> myRange.MergeCells = True >>> myRange.MergeCells True >>> myRange.MergeCells = False >>> myRange.MergeCells False >>> myRange.Merge() >>> myRange.MergeCells True >>> myRange.UnMerge() >>> myRange.MergeCells False It is a bit different than the VBA Syntax, the way I found out how to do it was by running makepy on the library and then was able to use the code completion to see what was available. (That is how I have learned most things about pywin) Trent Oliphant Jeff.Kelliher at Eirgrid.com wrote: > Hi, > > I hope you can help me. > > I've been using Python with Access and Excel in conjunction with some > power system software for some time now. > > One thing I've been unable to do is merge a defined quantity of cells in > Excel with Python - I can merge entire rows and columns but can't > determine the correct syntax to merge say five cells etc. > > Can anyone help? > > Best Regards, > > Jeff > ------------------------------------------------------------------------ > Jeff Kelliher > Transmission Network Planning, PSDM > ESB National Grid > Tel : +353 01 7026813 > Mailto:Jeff.Kelliher at Ngrid.ie > > > > ******************************************************************* > This E-mail message (including any attachments) is confidential and > intended solely for the use of the individual or entity to whom > it is addressed. If you have received the message in error, please > notify security at eirgrid.com. > > The message has been scanned for viruses. ESB National Grid. > ******************************************************************* > > > ------------------------------------------------------------------------ > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > ------------------------------------------------------------------------ > > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.1.375 / Virus Database: 268.1.1/271 - Release Date: 2/28/2006 From jeff at lfchosting.com Thu Mar 2 14:29:32 2006 From: jeff at lfchosting.com (Jeff Fisher) Date: Thu, 02 Mar 2006 07:29:32 -0600 Subject: [python-win32] Certificate Services in Windows. In-Reply-To: References: Message-ID: <4406F33C.2000307@lfchosting.com> > You can use CAPICOM, which is an automation interface > to the cryptography and certificate APIs. I don't think it > comes installed on most systems, but you can download > it from MSDN. Works great. CAPICOM is exactly what I needed. Now if only I could use ADSI to set SSLCertHash in IIS but that seems to be impossible thanks to a error in the schema :) Jeff -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: OpenPGP digital signature Url : http://mail.python.org/pipermail/python-win32/attachments/20060302/f294b1cb/attachment.pgp From wsande at tropicnetworks.com Thu Mar 2 15:06:37 2006 From: wsande at tropicnetworks.com (Warren Sande) Date: Thu, 2 Mar 2006 09:06:37 -0500 Subject: [python-win32] Closing COM object (e.g. Excel) when Python app dies Message-ID: <326102A034C9E04C9CA9D03488C769F80143815B@exchange.tropicnetworks.com> have a PythonCard app that opens up an Excel spreadsheet using the win32com module. I started doing this in Perl, then recently switched to Python (and PythonCard), which I am just learning. In Perl, I found the following code snippet which I used in my app: ---------------------- # use existing instance if Excel is already running eval {$ex = Win32::OLE->GetActiveObject('Excel.Application')}; die "Excel not installed" if $@; unless (defined $ex) { $ex = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}) or die "Oops, cannot start Excel"; $ex->{Visible} = 1; } # Note the destructor specified on the Win32::OLE->new method. # It ensures that Excel will shutdown properly even if the Perl program dies. ---------------------- I would like to be able to do the same in Python, but don't know if it is supported, and can't find or figure out the syntax if it is. I know this is not really a PythonCard question, but I'm hoping that other PythonCard users are working with win32com and might be able to help me out. My code to open the excel object is simply this: ---------------------- import win32com as wc ... self.xl = wc.Dispatch("Excel.Application") self.xl.Visible = 1 ... self.xl.Quit() ---------------------- Warren Sande -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060302/b6e14725/attachment.html From mli at deform.com Thu Mar 2 22:13:18 2006 From: mli at deform.com (Michael Li) Date: Thu, 02 Mar 2006 16:13:18 -0500 Subject: [python-win32] how to open a file with associated application ? In-Reply-To: <20060301174611.h7mhiezb9c48g088@webmail.weaktight.com> References: <20060301174611.h7mhiezb9c48g088@webmail.weaktight.com> Message-ID: <44075FEE.6040007@deform.com> hi, In Windows, there is a default way to open a file, like double click test.txt file, then Notepad will open the test.txt, double click test.doc, then MS-Word will open the test.doc. If I want to open a specific file, test.KEY, with my application, how do I do it ? The suffix ".KEY" is fixed. More specific, I have a file test.KEY in C:\DEFORM3D\PROBLEM\test.KEY my application is in C:\DEFORM3D\V6_0\DEF_GUI3.EXE, when double-click C:\DEFORM3D\PROBLEM\test.KEY, I want to open it like : C:\DEFORM3D\V6_0\DEF_GUI3.EXE -m pre -d C:\DEFORM3D\PROBLEM -i test -f test.KEY Can anyone point me a direction ? I believe that I have to write a python script to register something first. Is there any workable scripts I can borrow ? 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 mrmaple at gmail.com Thu Mar 2 23:13:28 2006 From: mrmaple at gmail.com (James Carroll) Date: Thu, 2 Mar 2006 17:13:28 -0500 Subject: [python-win32] how to open a file with associated application ? In-Reply-To: <44075FEE.6040007@deform.com> References: <20060301174611.h7mhiezb9c48g088@webmail.weaktight.com> <44075FEE.6040007@deform.com> Message-ID: Hi Michael, Try this: import os os.startfile(r"C:\DEFORM3D\PROBLEM\test.KEY") -Jim On 3/2/06, Michael Li wrote: > hi, > > In Windows, there is a default way to open a file, > like double click test.txt file, then Notepad will > open the test.txt, double click test.doc, then > MS-Word will open the test.doc. > > If I want to open a specific file, test.KEY, > with my application, how do I do it ? > The suffix ".KEY" is fixed. > More specific, I have a file test.KEY in > C:\DEFORM3D\PROBLEM\test.KEY > my application is in C:\DEFORM3D\V6_0\DEF_GUI3.EXE, > > when double-click C:\DEFORM3D\PROBLEM\test.KEY, > I want to open it like : > C:\DEFORM3D\V6_0\DEF_GUI3.EXE -m pre -d C:\DEFORM3D\PROBLEM -i test -f > test.KEY > > Can anyone point me a direction ? > > I believe that I have to write a python script to register > something first. Is there any workable scripts I can borrow ? > > > > 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. > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From Jeff.Quandt at bhmi.com Thu Mar 2 23:42:39 2006 From: Jeff.Quandt at bhmi.com (Jeff Quandt) Date: Thu, 2 Mar 2006 16:42:39 -0600 Subject: [python-win32] ReadEventLog doesn't return, CPU usage increases Message-ID: This is running Python 2.3 on windows 2003/windows xp. I have written a script to display and filter the Win32 event log in a scrolling list to the command line (it also does some summary tasks). It uses the win32evtlog.ReadEventLog to seek or scan the event log based on filter parameters. It is supposed to run until the user kills it, so there are repeated calls to ReadEventLog. The problem is that after the script has run from some time (usually several hours), the call to ReadEventLog seems to hang and the CPU usage increases dramatically (from nil to 30-50%). The script does not exit this stage, and has to be broken manually with Ctrl-C. I've tried closing and reopening the event log handle after it has been open for an hour. I've added explicit calls to the garbage collector. Neither helped at all. I realize that this is an API call, so it may not be a python issue. But I have seen this type of behavior on other scripts (not event loggers), but they were test/debug tools and weren't important enough to track down the issue. Any help would be appreciated. code example: def OpenLog( self ): # #open event log # self.mHandle = win32evtlog.OpenEventLog( self.mComputer , self.mLogType ) if not self.mHandle: raise ValueError, "invalid handle" self.mLogOpenTmst = time.time() def CloseLog( self ): win32evtlog.CloseEventLog( self.mHandle ) def ReadLog( self ): self.mFlags = win32evtlog.EVENTLOG_FORWARDS_READ|win32evtlog.EVENTLOG_SEEK_READ vEventScon = win32evtlog.ReadEventLog( self.mHandle , self.mFlags , self.mLogOffset ) # # if not found, try again in 5 seconds # if not vEventScon: # # If we've had the log open for more than 1 hour, dump it and reopen # if ( time.time() > (self.mLogOpenTmst + 3600) ): self.CloseLog() self.OpenLog() time.sleep( 5 ) return bOk # # snip... # manipulate event records here # # # main # OpenLog Ok = 1 while Ok: Ok = ReadLog() CloseLog() -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060302/ee811f53/attachment.html From ralf at brainbot.com Thu Mar 2 23:47:38 2006 From: ralf at brainbot.com (Ralf Schmitt) Date: Thu, 02 Mar 2006 23:47:38 +0100 Subject: [python-win32] how to open a file with associated application ? In-Reply-To: <44075FEE.6040007@deform.com> References: <20060301174611.h7mhiezb9c48g088@webmail.weaktight.com> <44075FEE.6040007@deform.com> Message-ID: <4407760A.2040000@brainbot.com> Michael Li schrieb: > hi, > > In Windows, there is a default way to open a file, > like double click test.txt file, then Notepad will > open the test.txt, double click test.doc, then > MS-Word will open the test.doc. > > If I want to open a specific file, test.KEY, > with my application, how do I do it ? > The suffix ".KEY" is fixed. > More specific, I have a file test.KEY in > C:\DEFORM3D\PROBLEM\test.KEY > my application is in C:\DEFORM3D\V6_0\DEF_GUI3.EXE, > > You have to modify some registry values. The Inno Setup FAQ http://www.jrsoftware.org/isfaq.php#assoc describes how: [Registry] Root: HKCR; Subkey: ".myp"; ValueType: string; ValueName: ""; ValueData: "MyProgramFile"; Flags: uninsdeletevalue ".myp" is the extension we're associating. "MyProgramFile" is the internal name for the file type as stored in the registry. Make sure you use a unique name for this so you don't inadvertently overwrite another application's registry key. Root: HKCR; Subkey: "MyProgramFile"; ValueType: string; ValueName: ""; ValueData: "My Program File"; Flags: uninsdeletekey "My Program File" above is the name for the file type as shown in Explorer. Root: HKCR; Subkey: "MyProgramFile\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\MYPROG.EXE,0" "DefaultIcon" is the registry key that specifies the filename containing the icon to associate with the file type. ",0" tells Explorer to use the first icon from MYPROG.EXE. (",1" would mean the second icon.) Root: HKCR; Subkey: "MyProgramFile\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\MYPROG.EXE"" ""%1""" "shell\open\command" is the registry key that specifies the program to execute when a file of the type is double-clicked in Explorer. The surrounding quotes are in the command line so it handles long filenames correctly. One can of course modify the same registry values using a python program. From timr at probo.com Thu Mar 2 23:57:47 2006 From: timr at probo.com (Tim Roberts) Date: Thu, 02 Mar 2006 14:57:47 -0800 Subject: [python-win32] how to open a file with associated application? In-Reply-To: References: Message-ID: <4407786B.8020301@probo.com> On Thu, 02 Mar 2006 16:13:18 -0500, Michael Li wrote: >In Windows, there is a default way to open a file, >like double click test.txt file, then Notepad will >open the test.txt, double click test.doc, then >MS-Word will open the test.doc. > >If I want to open a specific file, test.KEY, >with my application, how do I do it ? >The suffix ".KEY" is fixed. >More specific, I have a file test.KEY in >C:\DEFORM3D\PROBLEM\test.KEY >my application is in C:\DEFORM3D\V6_0\DEF_GUI3.EXE, > >when double-click C:\DEFORM3D\PROBLEM\test.KEY, >I want to open it like : >C:\DEFORM3D\V6_0\DEF_GUI3.EXE -m pre -d C:\DEFORM3D\PROBLEM -i test -f >test.KEY > >Can anyone point me a direction ? > >I believe that I have to write a python script to register >something first. Is there any workable scripts I can borrow ? > You can do it from a command line like this: assoc .key=MyDefGuiApplication ftype MyDefGuiApplication=c:\deform3d\v6_0\def_gui3.exe -m pre -d c:\deform3d\problem -i test -f %1 If you really need to do this from Python, you can also create the registry keys by hand. In this key: HKEY_CLASSES_ROOT\.key set the default value (the one with no name) to "MyDefGuiApplication". Then, create this key: HKEY_CLASSES_ROOT\MyDefGuiApplication\Shell\Open\Command and set the default value to the command I showed above, of type REG_EXPAND_SZ. You can use whatever name you want for "MyDefGuiApplication". It's just the link between the extension and the command line. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Fri Mar 3 01:25:40 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 3 Mar 2006 11:25:40 +1100 Subject: [python-win32] ReadEventLog doesn't return, CPU usage increases In-Reply-To: Message-ID: > The problem is that after the script has run from some time (usually several > hours), the call to ReadEventLog seems to hang and the CPU usage increases > dramatically (from nil to 30-50%). The script does not exit this stage, > and has to be broken manually with Ctrl-C. There is the possibility of an infinite loop in the python implementation of ReadEventLog should the API function not behave as expected. In summary, this function handles a case when the evtlog record is large, when Windows tells us the buffer is too small and also tells us the size necessary. We have no protection in the code for Windows continually returning this value without actually increasing the size necessary. If you don't have a C compiler available, I could send you an instrumented .pyd file that dumped to stdout each time this loop executed. It would generate *lots* of noise, but would demonstrate if the problem is that loop, or inside Windows itself. If the latter, then I'm afraid I have no advice. Mark From rwupole at msn.com Fri Mar 3 03:51:17 2006 From: rwupole at msn.com (Roger Upole) Date: Thu, 2 Mar 2006 21:51:17 -0500 Subject: [python-win32] Re: Windows "Browse to" message Message-ID: >> vince at weaktight.com wrote: >>> When you open an html file or click on a link outside of a browser, >>> it opens it >>> in your default browser. What I'd like to do is to catpure this message and >>> grab the URL text string to see where the browser is going. >>> >>> I was looking at PyHook, but I don't think it intercepts all windows >>> messages, >>> and I'm not sure this is a windows message per se. >>> >>> Any suggestions? >>> >>> thanks >> >> For opening local files, there's a registered handler for the file type. >> Take a look at HKEY_CLASSES_ROOT\htmlfile\shell\open\command >> which specifies the program that will open the file. You might be able >> to substitute your own handler, which just logs the request and then >> passes it off to the original program. The handler for internet protocol is >> under HKEY_CLASSES_ROOT\HTTP\shell\open\command, >> although you'd probably also need to change all handlers that point >> to your web browser (https, ftp, etc) >> >> hth >> Roger > > Good idea. > > I tried this, however, modifying that key makes browsers unhappy as they think > they're no longer the default browser. If this were a one-off solution, this > would be good enough, but it needs to be transparent enough to keep the user > happy. > > Perhaps I could catch the actual HTTP network request... that sounds scary > though In IE, you can disable checking that it's the default browser. (don't know about other browsers, though) In the case of opening a local html file, there will be no network request. hth Roger . From mrmaple at gmail.com Fri Mar 3 22:03:53 2006 From: mrmaple at gmail.com (James Carroll) Date: Fri, 3 Mar 2006 16:03:53 -0500 Subject: [python-win32] py2exe problem with makepy Message-ID: Hi, I've got python 2.4.2 & pythonwin 207 & py2exe 0.6.4 (I also tried 0.6.3) The other day I tried to run makepy on Excel.Application and got a strange error... today I am getting something similar trying to py2exe something that I've had luck with before. I'm getting the following error: running py2exe *** generate typelib stubs *** Traceback (most recent call last): File "C:\jimc\prj\bright\scripts\vsEdit\setup.py", line 69, in ? windows=[vsEdit]) File "C:\Python24\lib\distutils\core.py", line 149, in setup dist.run_commands() File "C:\Python24\lib\distutils\dist.py", line 946, in run_commands self.run_command(cmd) File "C:\Python24\lib\distutils\dist.py", line 966, in run_command cmd_obj.run() File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line 218, in run self._run() File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line 249, in _run self.typelibs) File "C:\Python24\Lib\site-packages\py2exe\build_exe.py", line 1494, in collec t_win32com_genpy makepy.GenerateFromTypeLibSpec(info, bForDemand = False) File "C:\Python24\Lib\site-packages\win32com\client\makepy.py", line 273, in G enerateFromTypeLibSpec gencache.AddModuleToCache(info.clsid, info.lcid, info.major, info.minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 550, in AddModuleToCache mod = _GetModule(fname) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 629, in _GetModule mod = __import__(mod_name) File "C:\jimc\prj\bright\scripts\vsEdit\build\bdist.win32\winexe\temp\win32com \gen_py\565783C6-CB41-11D1-8B02-00600806D9B6x0x1x2.py", line 1484 class ISWbemRefreshableItem(DispatchBaseClass): ^ SyntaxError: invalid syntax I've looked at the offending file, and it looks just fine to me (I don't know what the synatx error is.) Are there any quick fixes I can try? Thanks, -jim From mc at mclaveau.com Sat Mar 4 08:01:27 2006 From: mc at mclaveau.com (Michel Claveau) Date: Sat, 4 Mar 2006 08:01:27 +0100 Subject: [python-win32] Thanks ; Merci References: Message-ID: <001c01c63f59$791f4710$0701a8c0@PORTABLES> Hi, all! Salut ? tous ! I have adapted, and have just played with "ietoolbar.py". And it run well; with IE, but also with the windows-explorer. I can call any Python, my librairies, my softwares, etc etc. I am filled with enthusiasm. Python + PyWin32 (& PythonCom) + Windows, it is fan-tas-tic! Thank you, THANK YOU, THANK YOU VERY MUCH, at all guys who gave us these tools. Je viens d'adapter, et de jouer avec "ietoolbar.py". Et ?a marche bien ; avec IE, mais aussi avec l'explorateur de Windows. Je peux appeler tout Python, mes librairies, mes logiciels, etc. etc. Je suis enthousiasm?. Python + PyWin32 (& PythonCom) + Windows, c'est fan-tas-tique ! Merci, MERCI, MERCI BEAUCOUP, ? tous ceux qui nous ont donn? ces outils. *sorry for my bad (babelized) english* @-salutations Michel Claveau From bgailer at alum.rpi.edu Sun Mar 5 23:51:45 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Sun, 05 Mar 2006 14:51:45 -0800 Subject: [python-win32] Thanks ; Merci In-Reply-To: <001c01c63f59$791f4710$0701a8c0@PORTABLES> References: <001c01c63f59$791f4710$0701a8c0@PORTABLES> Message-ID: <440B6B81.9070603@alum.rpi.edu> > > There have been some references to "ietoolbar.py". I have searched in my pythonwin install and not found it. Where can I find it? From rwupole at msn.com Mon Mar 6 07:37:40 2006 From: rwupole at msn.com (Roger Upole) Date: Mon, 6 Mar 2006 01:37:40 -0500 Subject: [python-win32] Re: Thanks ; Merci Message-ID: Bob Gailer wrote: > There have been some references to "ietoolbar.py". I have searched in my pythonwin install and not found it. Where can I find > it? This is a recent addition, you can get it from CVS here: http://cvs.sourceforge.net/viewcvs.py/pywin32/pywin32/com/win32com/demos/ietoolbar.py?rev=1.1&view=log Roger From rwupole at msn.com Mon Mar 6 07:51:41 2006 From: rwupole at msn.com (Roger Upole) Date: Mon, 6 Mar 2006 01:51:41 -0500 Subject: [python-win32] Re: Closing COM object (e.g. Excel) when Python app dies Message-ID: Warren Sande wrote: > have a PythonCard app that opens up an Excel spreadsheet using the > win32com module. > > I started doing this in Perl, then recently switched to Python (and > PythonCard), which I am just learning. > > In Perl, I found the following code snippet which I used in my app: > > ---------------------- > # use existing instance if Excel is already running > eval {$ex = Win32::OLE->GetActiveObject('Excel.Application')}; > die "Excel not installed" if $@; > unless (defined $ex) { > $ex = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;}) > or die "Oops, cannot start Excel"; > $ex->{Visible} = 1; > } # Note the destructor specified on the Win32::OLE->new method. > # It ensures that Excel will shutdown properly even if the Perl > program dies. > ---------------------- > > I would like to be able to do the same in Python, but don't know if it > is supported, and can't find or figure out the syntax if it is. > > I know this is not really a PythonCard question, but I'm hoping that > other PythonCard users are working with win32com and might be able to > help me out. > > My code to open the excel object is simply this: > > ---------------------- > import win32com as wc > ... > > self.xl = wc.Dispatch("Excel.Application") > self.xl.Visible = 1 > ... > > self.xl.Quit() > ---------------------- You can add a __del__ method to your class: import win32com.client class xlautodestruct: def __init__(self): self.xl=win32com.client.Dispatch('Excel.Application') self.xl.Visible=1 def __del__(self): self.xl.Quit() hth Roger From arvidw at gmx.de Mon Mar 6 10:35:08 2006 From: arvidw at gmx.de (Lisan) Date: Mon, 6 Mar 2006 01:35:08 -0800 (PST) Subject: [python-win32] block any kind of popup's Message-ID: <3259014.post@talk.nabble.com> Hi, i want to write an office2pdf converter, that will scan a directory for incoming documents. Because I am a Linux only user python was a natural choice for the implementation language. Unfortunately I need to control the office tools to send a document to a virtual pdf/tiff printer (freepdf e.g.). My problem is, that a lot of documents are password protected and the converting process will bring up a dialog on the screen and waits for an input. This can be handled by using the haspassword function, at least i think so. But i see a general problem in popups, i dont want to login to the converting host each day to check wether there is a popup or not. I want to block popups, hence to converter will never stop and if it is possible i want to get the contents of the blocked popups (messageboxes etc.) Is there a sollution of this problem ? -- View this message in context: http://www.nabble.com/block-any-kind-of-popup%27s-t1232221.html#a3259014 Sent from the Python - python-win32 forum at Nabble.com. From robertjlane at gmail.com Mon Mar 6 18:33:13 2006 From: robertjlane at gmail.com (Rob Lane) Date: Mon, 6 Mar 2006 17:33:13 +0000 Subject: [python-win32] Query Message-ID: <19a516050603060933v6b49d42cq@mail.gmail.com> Hey, I am currently working on a final year project in college building a 3-D virtual model of a building in a python based program called Vizard. I have prepared a set of tutorials on powerpoint which i would like to access by clicking on various objects in the building. e.g. Click on a Window/Air Duct and then open a powerpoint presentation on the topic. I was wondering if there is python code which will let me launch my powerpoint presentations from with my virtual world. Any help would be greatly appreciated kind regards, Robert Lane Civil and Environmental Engineering IV UCC -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060306/a6743db3/attachment.htm From mrmaple at gmail.com Tue Mar 7 22:39:13 2006 From: mrmaple at gmail.com (James Carroll) Date: Tue, 7 Mar 2006 16:39:13 -0500 Subject: [python-win32] Creating users Message-ID: Hi I'm looking at maybe using: win32net.NetUserAdd(server, 1, d) to create user directories under Documents and Settings on the local machine, but don't know what they want for passwords. I also don't know if the users I want to create already have an account on their campus domain controller. Is there a way to add the user given just the username, and have it do the right thing (use the domain controller's account or a local account if that doesn't exist) most of the time? I'm also having trouble with info = win32net.NetUserGetInfo(server, userName, 3) No matter what username I give it, it can't find that user. Also, Enumerating users always returns an empty set, even though I have about 6 users set up on my machine. Could I have a broken install? Thanks, -Jim From rwupole at msn.com Wed Mar 8 05:03:50 2006 From: rwupole at msn.com (Roger Upole) Date: Tue, 7 Mar 2006 23:03:50 -0500 Subject: [python-win32] Re: Query Message-ID: Rob Lane wrote: > Hey, > > I am currently working on a final year project in college building a 3-D > virtual model of a building in a python based program called Vizard. I have > prepared a set of tutorials on powerpoint which i would like to access by > clicking on various objects in the building. e.g. Click on a Window/Air Duct > and then open a powerpoint presentation on the topic. > > I was wondering if there is python code which will let me launch my > powerpoint presentations from with my virtual world. > > Any help would be greatly appreciated > > kind regards, > > Robert Lane You can automate Powerpoint with COM: import win32com.client pp=win32com.client.gencache.EnsureDispatch('powerpoint.application',0) pp.Visible=1 pr=pp.Presentations.Open('somefile.ppt') hth Roger From rwupole at msn.com Wed Mar 8 13:54:25 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 8 Mar 2006 07:54:25 -0500 Subject: [python-win32] Re: Creating users Message-ID: James Carroll wrote: > Hi I'm looking at maybe using: > > win32net.NetUserAdd(server, 1, d) > > to create user directories under Documents and Settings on the local > machine, but don't know what they want for passwords. I also don't > know if the users I want to create already have an account on their > campus domain controller. NetUserAdd actually creates a new user, rather than creating a profile. The profile, which is what's stored in Documents and Settings, will be created (or copied from a server in the case of a roaming profile) when the account is first logged on . You can specify the location using the 'profile' member of USER_INFO_3 or 4. > > Is there a way to add the user given just the username, and have it do > the right thing (use the domain controller's account or a local > account if that doesn't exist) most of the time? > > I'm also having trouble with > info = win32net.NetUserGetInfo(server, userName, 3) > No matter what username I give it, it can't find that user. Are you sure you're specifying the correct server ? Use None to mean the local machine. Also, how are you specifying the username ? eg a bare username, NT-style 'domain\username', Active Directory syntax 'username at domain' etc. > > Also, Enumerating users always returns an empty set, even though I > have about 6 users set up on my machine. > NetUserEnum is a little tricky to use, can you post your code ? hth Roger From mrmaple at gmail.com Wed Mar 8 14:27:21 2006 From: mrmaple at gmail.com (James Carroll) Date: Wed, 8 Mar 2006 08:27:21 -0500 Subject: [python-win32] Creating users In-Reply-To: References: Message-ID: > The profile, which is what's stored in Documents and Settings, will > be created (or copied from a server in the case of a roaming profile) > when the account is first logged on . Thanks Roger, since my goal is to copy something into the profile directories, then I am going to have to wait until after they log in. > > Also, Enumerating users always returns an empty set, even though I > > have about 6 users set up on my machine. > > NetUserEnum is a little tricky to use, can you post your code ? > I'm using the code in the Demo directory: win32netdemo.py I think I found the reason though, in one post I googled, someone said tthat the enumeration only lists users that had been created with the NetUserAdd function. -Jim From mcgooly at yahoo.com Wed Mar 8 15:08:21 2006 From: mcgooly at yahoo.com (Brad Posthumus) Date: Wed, 8 Mar 2006 14:08:21 +0000 (GMT) Subject: [python-win32] DispatchWithEvents and ADO Message-ID: <20060308140821.27448.qmail@web50914.mail.yahoo.com> I'm having difficulty understanding exactly how DispatchWithEvents operates. I need to execute SQL statements on tables in an Oracle database (using ADO) and it runs fine when using Dispatch. However when I include DispatchWithEvents both the Execute() and Close() methods no longer work for my Dispatch object, with a "Member not found" error appearing. Why does Execute and Close work with Dispatch by itself but not when DispatchWithEvents is added? What I find interesting is that both the ConnectComplete and ExecuteComplete functions appear to fire in my events class, even though my error appears in the Execute() statement. We've noticed that Python can get ahead of the execution of the SQL statements, such as adding a new field and then attempting to calculate its value for the records before Oracle has finished created it. Is using DispatchWithEvents and waiting for the ExecuteComplete (with pythoncom.PumpWaitingMessage) the right solution? CODE: ----------------- from win32com.client import Dispatch, DispatchWithEvents class clsAdoEvents: def OnWillConnect(self, str, user, pw, opt, sts, cn): pass def OnConnectComplete(self, error, status, connection): print "Connection complete" def OnExecuteComplete(self, lngRecordsAffected, pError, adStatus, pCommand, pRecordset, pConnection): print "Statement executed" objAdoConnection= Dispatch('ADODB.Connection') objAdoConnectionEvents= DispatchWithEvents(objAdoConnection, clsAdoEvents) objAdoConnection.ConnectionString = "Provider=MSDAORA;Password=pwd;User ID=user;Data Source=server" objAdoConnection.Open() objAdoConnection.Execute("UPDATE streams SET test=99") objAdoConnection.Close() del objAdoConnection --------------------- OUTPUT: --------------------- Connection complete Statement executed Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\bposthumus\programming\Python\PythonExamples\sqlWithEvents.py", line 17, in ? objAdoConnection.Execute("UPDATE streams SET test=99") File "C:\Python24\lib\site-packages\win32com\gen_py\2A75196C-D9EB-4129-B803-931327F72D5Cx0x2x8.py", line 2064, in Execute , RecordsAffected, Options) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_( com_error: (-2147352567, 'Exception occurred.', (0, None, 'Member not found.', None, 0, -2147352573), None) -------------------- ___________________________________________________________ Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com From timr at probo.com Wed Mar 8 18:53:09 2006 From: timr at probo.com (Tim Roberts) Date: Wed, 08 Mar 2006 09:53:09 -0800 Subject: [python-win32] Creating users In-Reply-To: References: Message-ID: <440F1A05.7050501@probo.com> On Tue, 7 Mar 2006 16:39:13 -0500, "James Carroll" wrote: >Hi I'm looking at maybe using: > > win32net.NetUserAdd(server, 1, d) > >to create user directories under Documents and Settings on the local >machine, but don't know what they want for passwords. I also don't >know if the users I want to create already have an account on their >campus domain controller. > >Is there a way to add the user given just the username, and have it do >the right thing (use the domain controller's account or a local >account if that doesn't exist) most of the time? > >I'm also having trouble with > info = win32net.NetUserGetInfo(server, userName, 3) >No matter what username I give it, it can't find that user. > >Also, Enumerating users always returns an empty set, even though I >have about 6 users set up on my machine. > >Could I have a broken install? > > I doubt it. The most obvious question is, are you running as an administrator? Or, if you are trying to fetch from a domain controller, are you a domain administrator? Unprivileged users cannot access user information. >>> import win32net >>> from pprint import pprint >>> i = win32net.NetUserEnum('',0,0) >>> pprint(i) ([{'name': u'ACTUser'}, {'name': u'Administrator'}, {'name': u'ASPNET'}, {'name': u'Guest'}, {'name': u'HelpAssistant'}, {'name': u'SQLDebugger'}, {'name': u'SUPPORT_38898898'}, {'name': u'timr'}, {'name': u'VUSR_TIMR2'}], 9, 0) >>> By the way, I don't believe that NetUserAdd will actually create profile directories. It creates the user names and remembers their information, but in my experience, the profile directory does not get created until the user actually logs in for the first time. This is, of course, a bit inconvenient if you want to pre-populate their desktop. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mrmaple at gmail.com Wed Mar 8 18:58:15 2006 From: mrmaple at gmail.com (James Carroll) Date: Wed, 8 Mar 2006 12:58:15 -0500 Subject: [python-win32] Creating users In-Reply-To: <440F1A05.7050501@probo.com> References: <440F1A05.7050501@probo.com> Message-ID: > >>> i = win32net.NetUserEnum('',0,0) That's It! I was thinking the third parameter would give me more information if it was a bigger number (I copied a 3 from the win32netdemo.py) but just having a 0 there gives me all the users I was hoping for. Thanks, -Jim From timr at probo.com Wed Mar 8 19:13:13 2006 From: timr at probo.com (Tim Roberts) Date: Wed, 08 Mar 2006 10:13:13 -0800 Subject: [python-win32] Creating users In-Reply-To: References: <440F1A05.7050501@probo.com> Message-ID: <440F1EB9.7010803@probo.com> James Carroll wrote: >>>>>i = win32net.NetUserEnum('',0,0) >>>>> >>>>> > >That's It! > >I was thinking the third parameter would give me more information if >it was a bigger number (I copied a 3 from the win32netdemo.py) but >just having a 0 there gives me all the users I was hoping for. > > MSDN is your friend here. It is the SECOND parameter to NetUserEnum that identifies how much information to return. The THIRD parameter is a set of filters that restricts the list of users to return. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060308/ae23526d/attachment.htm From rwupole at msn.com Wed Mar 8 21:09:19 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 8 Mar 2006 15:09:19 -0500 Subject: [python-win32] Re: Creating users Message-ID: James Carroll wrote: >> The profile, which is what's stored in Documents and Settings, will >> be created (or copied from a server in the case of a roaming profile) >> when the account is first logged on . > > Thanks Roger, since my goal is to copy something into the profile > directories, then I am going to have to wait until after they log in. > In that case, you can place files in the Default User profile, and they'll get copied into new profiles as they are created. Alternately, you can put them in the All Users profile, and everyone will share the same copy. Roger From peter.gunnarsson at gmail.com Wed Mar 8 22:26:54 2006 From: peter.gunnarsson at gmail.com (Peter Gunnarsson) Date: Wed, 8 Mar 2006 22:26:54 +0100 Subject: [python-win32] Using COM to automate Powerpoint w/ password protection Message-ID: <914b7b10603081326i7effa690qf2b5b1023ea4ace9@mail.gmail.com> Hi, I'm using pythoncom and win32com to automate Powerpoint via COM. It works like charm until I try to open a password protected file. My program is supposed to run as a service in the background and will stop if a password dialog appear. How can I prevent the password dialog from showing? For VB, MSDN writes: "To avoid the dialog box, provide a value for the *Password* argument when calling the *Open* method." This sounds nice but how do I provide a password to the application.Presentations.Open method in python? The method I'm using only got four parameters like this: open(filename, readonly, , ) Is there an other way to call this method so that I can provide custom parameters such as password? BR, Peter Gunnarsson -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060308/d4c5b12f/attachment.html From mrmaple at gmail.com Wed Mar 8 22:38:32 2006 From: mrmaple at gmail.com (James Carroll) Date: Wed, 8 Mar 2006 16:38:32 -0500 Subject: [python-win32] Creating users In-Reply-To: References: Message-ID: > In that case, you can place files in the Default User profile, > and they'll get copied into new profiles as they are created. > Alternately, you can put them in the All Users profile, and > everyone will share the same copy. Thanks Roger, I've got one more question for you if I haven't bugged you too much today. I'm getting the list of usernames of active users, but the next thing I need is that user's APPDATA directory. APPDATA=C:\Documents and Settings\username\Application Data I'm tempted to get the APPDATA directory for the current user, and the username, and do a replace on the username directory, but If there's a more foolproof way of knowing what the APPDATA directory will be for that user, I'd sleep better. Do you know of a better way? Thanks again, -Jim From mhammond at skippinet.com.au Thu Mar 9 00:06:00 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 9 Mar 2006 10:06:00 +1100 Subject: [python-win32] DispatchWithEvents and ADO In-Reply-To: <20060308140821.27448.qmail@web50914.mail.yahoo.com> Message-ID: > include DispatchWithEvents both the Execute() and > Close() methods no longer work for my Dispatch object, > with a "Member not found" error appearing. Why does > Execute and Close work with Dispatch by itself but not > when DispatchWithEvents is added? > > What I find interesting is that both the > ConnectComplete and ExecuteComplete functions appear > to fire in my events class, even though my error > appears in the Execute() statement. In that case, it may be that ADO is expecting your events to always handle certain methods - ie, when ADO itself tries to find an event handler you have not implemented, it will see the DISP_E_MEMBER_NOT_FOUND error (raised by Python, as the function doesn't exist on the object). It may be then returning that error back to you. Enabling "debug mode" for event handlers is tricky - you probably could open the makepy generated file and locate the function in the events class: > > We've noticed that Python can get ahead of the > execution of the SQL statements, such as adding a new > field and then attempting to calculate its value for > the records before Oracle has finished created it. Is > using DispatchWithEvents and waiting for the > ExecuteComplete (with pythoncom.PumpWaitingMessage) > the right solution? > > CODE: > ----------------- > from win32com.client import Dispatch, > DispatchWithEvents > > class clsAdoEvents: > def OnWillConnect(self, str, user, pw, opt, sts, > cn): > pass > def OnConnectComplete(self, error, status, > connection): > print "Connection complete" > def OnExecuteComplete(self, lngRecordsAffected, > pError, adStatus, pCommand, pRecordset, pConnection): > print "Statement executed" > > objAdoConnection= Dispatch('ADODB.Connection') > objAdoConnectionEvents= > DispatchWithEvents(objAdoConnection, clsAdoEvents) > > objAdoConnection.ConnectionString = > "Provider=MSDAORA;Password=pwd;User ID=user;Data > Source=server" > > objAdoConnection.Open() > objAdoConnection.Execute("UPDATE streams SET test=99") > objAdoConnection.Close() > > del objAdoConnection > --------------------- > > > OUTPUT: > --------------------- > Connection complete > Statement executed > Traceback (most recent call last): > File > "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", > line 310, in RunScript > exec codeObject in __main__.__dict__ > File > "C:\bposthumus\programming\Python\PythonExamples\sqlWithEvents.py", > line 17, in ? > objAdoConnection.Execute("UPDATE streams SET > test=99") > File > "C:\Python24\lib\site-packages\win32com\gen_py\2A75196C-D9EB-4129- > B803-931327F72D5Cx0x2x8.py", > line 2064, in Execute > , RecordsAffected, Options) > File > "C:\Python24\Lib\site-packages\win32com\client\__init__.py", > line 446, in _ApplyTypes_ > return self._get_good_object_( > com_error: (-2147352567, 'Exception occurred.', (0, > None, 'Member not found.', None, 0, -2147352573), > None) > -------------------- > > > > > > > ___________________________________________________________ > Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide > with voicemail http://uk.messenger.yahoo.com > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From mhammond at skippinet.com.au Thu Mar 9 00:45:22 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 9 Mar 2006 10:45:22 +1100 Subject: [python-win32] DispatchWithEvents and ADO In-Reply-To: Message-ID: Oops - that last mail snuck away from me! Enabling "debug mode" for event handlers is tricky - you probably could open the makepy generated file and locate the function in the events class: def _query_interface_(self, iid): import win32com.server.util if iid==self.CLSID_Sink: return win32com.server.util.wrap(self) to pass True as a second arg to "wrap" - that should enable standard COM server debugging, which should spew output to Pythonwin's Tools -> Remote Trace Collector. You should see the "member not found" errors reflected there. Adding all necessary methods until that output is (mainly) silent may avoid the error - but as mentioned in the first email, this is speculation that ADO is getting upset about the event handler not having all methods implemented. > > We've noticed that Python can get ahead of the > > execution of the SQL statements, such as adding a new > > field and then attempting to calculate its value for > > the records before Oracle has finished created it. Is > > using DispatchWithEvents and waiting for the > > ExecuteComplete (with pythoncom.PumpWaitingMessage) > > the right solution? I'm afraid I'm not sure exactly what you are asking here. By Python getting ahead, I assume you really just mean that ADO is getting ahead (and therefore would when called from any language). If ADO is working somehow asynchronously, then the solution to that probably lies inside ADO itself rather than in Python. Cheers, Mark From bgailer at alum.rpi.edu Thu Mar 9 01:05:03 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Wed, 08 Mar 2006 16:05:03 -0800 Subject: [python-win32] IE toolbar button in Python In-Reply-To: References: Message-ID: <440F712F.2030807@alum.rpi.edu> Roger Upole wrote: > > There's an IE toolbar button demo in CVS: > http://cvs.sourceforge.net/viewcvs.py/pywin32/pywin32/com/win32com/demos/iebutton.py?rev=1.1&view=log > I looked at this, but can't figure out what to do with it. Are there any instructions? What seems apparant is that it creates a COM server. But then what? From mhammond at skippinet.com.au Thu Mar 9 02:33:19 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 9 Mar 2006 12:33:19 +1100 Subject: [python-win32] IE toolbar button in Python In-Reply-To: <440F712F.2030807@alum.rpi.edu> Message-ID: > Roger Upole wrote: > > > > There's an IE toolbar button demo in CVS: > > > http://cvs.sourceforge.net/viewcvs.py/pywin32/pywin32/com/win32com > /demos/iebutton.py?rev=1.1&view=log > > > I looked at this, but can't figure out what to do with it. Are there any > instructions? What seems apparant is that it creates a COM server. But > then what? Yes, it is very unclear. I just checked in a new version with the following docstring: """ This sample implements a simple IE Button COM server with access to the IWebBrowser2 interface. To demonstrate: * Execute this script to register the server. * Open Pythonwin's Tools -> Trace Collector Debugging Tool, so you can see the output of 'print' statements in this demo. * Open a new IE instance. The toolbar should have a new "scissors" icon, with tooltip text "IE Button" - this is our new button - click it. * Switch back to the Pythonwin window - you should see: IOleCommandTarget::Exec called. This is the button being clicked. Extending this to do something more useful is left as an excercise. Contribtions to this sample to make it a little "friendlier" welcome! """ (Note that I also added an 'import win32traceutil' for the above to be true - you will need to add it too, or just grab the new copy) I'm also fairly sure it will not work until I release a new pywin32 - I'll do that soon! Cheers, Mark From rwupole at msn.com Thu Mar 9 03:01:18 2006 From: rwupole at msn.com (Roger Upole) Date: Wed, 8 Mar 2006 21:01:18 -0500 Subject: [python-win32] Re: Creating users Message-ID: James Carroll wrote: > I've got one more question for you if I haven't bugged you too much > today. I'm getting the list of usernames of active users, but the > next thing I need is that user's APPDATA directory. > > APPDATA=C:\Documents and Settings\username\Application Data > > I'm tempted to get the APPDATA directory for the current user, and the > username, and do a replace on the username directory, but If there's a > more foolproof way of knowing what the APPDATA directory will be for > that user, I'd sleep better. > > Do you know of a better way? > > Thanks again, > -Jim That's not going to be 100% reliable. You can have a profile for a local user and a domain user with the same name. One of them ends up as username.machinename or username.domain, depending on which profile was created first. Plus you might have to deal with roaming profiles. You could probably create a logon script. That way you'll have the exact directory available. And it will ensure that any new users created in the future will obtain whatever files are needed when they log in. Roger From mc at mclaveau.com Thu Mar 9 07:24:52 2006 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 9 Mar 2006 07:24:52 +0100 Subject: [python-win32] IE toolbar button in Python References: <440F712F.2030807@alum.rpi.edu> Message-ID: <002001c64342$3131fd20$0701a8c0@PORTABLES> Hi! *Attempt to translaste at bottom of the message* Bonjour ! J'ai d?couvert, il y a quelques jours IEtoolbar dans mon installation de PyWin32 (la derni?re ?) ; ?a a bien fonctionn? du premier coup. J'ai adapt? l'exemple, en changeant la taille, le style, et le nombre, des boutons. J'ai mis mes propres routines, et cr?? mon propre CLSID. Tout fonctionne tr?s bien. J'ai d?couvert que cela fonctionne avec IE, mais aussi avec l'explorateur de windows, et avec le Poste-de-travail (et les dossiers du bureau). On a acc?s ? tout l'int?rieur de IE (pilotage par COM), ce qui permet d'automatiser la navigation, ou la r?cup?ration d'informations. Par contre, je ne sais pas encore r?cup?rer le r?sultat d'un "drag-and-drop", d'un "copier/coller", ou d'une s?lection. Bref, c'est un outil tr?s int?ressant, qui poss?de un potentiel appr?ciable. -------Try--translate--with--Babelfish------------- Hello! I discovered, IEtoolbar a few days ago in my installation of PyWin32 (the last?) ; that functioned well of the first blow. I adapted the example, by changing the size, the style, and numbers, of the buttons. I put my own routines, and created my own CLSID. All functions very well. I discovered that that functions with IE, but also with the windows-explorer, and workstation (and directories of the office). We has access to all the interior of IE (piloting by COM), which makes it possible to automate navigation, or the recovery of information. On the other hand, I do not know yet read the result of a "drag-and-drop", a "copy/paste", or a selection. In short, it is a very interesting tool, which has an appreciable potential. @+ Michel Claveau From upadhyay at gmail.com Thu Mar 9 14:15:13 2006 From: upadhyay at gmail.com (Amit Upadhyay) Date: Thu, 9 Mar 2006 18:45:13 +0530 Subject: [python-win32] IE toolbar button in Python In-Reply-To: References: <440F712F.2030807@alum.rpi.edu> Message-ID: <349edb380603090515k23315904h90ca33a10d828a49@mail.gmail.com> On 3/9/06, Mark Hammond wrote: > > (Note that I also added an 'import win32traceutil' for the above to be > true - you will need to add it too, or just grab the new copy) > > I'm also fairly sure it will not work until I release a new pywin32 - I'll > do that soon! Hi Mark, I am getting providing default stub for GetSite > in traceutil, and then IE is crashing. Am using win32 build 207, python 2.4.2. -- Amit Upadhyay Blog: http://www.rootshell.be/~upadhyay +91-9867-359-701 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060309/424ae735/attachment.html From mcgooly at yahoo.com Thu Mar 9 17:38:17 2006 From: mcgooly at yahoo.com (Brad Posthumus) Date: Thu, 9 Mar 2006 16:38:17 +0000 (GMT) Subject: [python-win32] DispatchWithEvents and ADO In-Reply-To: Message-ID: <20060309163817.43567.qmail@web50910.mail.yahoo.com> --- Mark Hammond wrote: > In that case, it may be that ADO is expecting your > events to always handle > certain methods - ie, when ADO itself tries to find > an event handler you > have not implemented, it will see the > DISP_E_MEMBER_NOT_FOUND error (raised > by Python, as the function doesn't exist on the > object). It may be then > returning that error back to you. You are absolutely right, I didn't have all of the required event handlers set up. While debugging in PythonWin I found withinin __init__.py the lines: def __getattr__(self, attr): args=self._prop_map_get_.get(attr) "args" was producing "None" which in turn created the error message. I checked the value of "attr" and it was looking for "OnWillExecute". So I included that as well as "OnDisconnect" in the event handler class and now it works perfectly. CODE: ---------- from win32com.client import Dispatch, DispatchWithEvents class clsAdoEvents: def OnWillConnect(self, str, user, pw, opt, sts, cn): pass def OnConnectComplete(self, pError, adStatus, pConnection): print "Connection complete" def OnDisconnect(self, adStatus, pConnection): print "Disconnection complete" def OnWillExecute(self, Source, CursorType, LockType, Options, adStatus, pCommand, pRecordset, pConnection): pass def OnExecuteComplete(self, lngRecordsAffected, pError, adStatus, pCommand, pRecordset, pConnection): print "Statement executed" objAdoConnection= Dispatch('ADODB.Connection') objAdoConnectionEvents= DispatchWithEvents(objAdoConnection, clsAdoEvents) objAdoConnection.ConnectionString = "Provider=MSDAORA;Password=pwd;User ID=user;Data Source=server" objAdoConnection.Open() objAdoConnection.Execute("UPDATE streams SET test=25") objAdoConnection.Close() del objAdoConnection ----------- ___________________________________________________________ NEW Yahoo! Cars - sell your car and browse thousands of new and used cars online! http://uk.cars.yahoo.com/ From le.dahut at laposte.net Thu Mar 9 17:56:08 2006 From: le.dahut at laposte.net (le dahut) Date: Thu, 09 Mar 2006 17:56:08 +0100 Subject: [python-win32] export registry keys Message-ID: <44105E28.3090207@laposte.net> Hello, What is the best way to export/import a part of windows registry into original .reg files (according to the os type). Code must run on both 98 and XP ? K. From mcgooly at yahoo.com Thu Mar 9 18:34:49 2006 From: mcgooly at yahoo.com (Brad Posthumus) Date: Thu, 9 Mar 2006 17:34:49 +0000 (GMT) Subject: [python-win32] DispatchWithEvents and ADO In-Reply-To: Message-ID: <20060309173449.97468.qmail@web50911.mail.yahoo.com> --- Mark Hammond wrote: > Oops - that last mail snuck away from me! > > Enabling "debug mode" for event handlers is tricky - > you probably > could open the makepy generated file and locate the > function in the events > class: > > def _query_interface_(self, iid): > import win32com.server.util > if iid==self.CLSID_Sink: return > win32com.server.util.wrap(self) > > to pass True as a second arg to "wrap" - that should > enable standard COM > server debugging, which should spew output to > Pythonwin's Tools -> Remote > Trace Collector. You should see the "member not > found" errors reflected > there. Adding all necessary methods until that > output is (mainly) silent > may avoid the error - but as mentioned in the first > email, this is > speculation that ADO is getting upset about the > event handler not having all > methods implemented. Your debugging advice sounds like its worth investigating, perhaps beyond my technical expertise but that's how you learn (I hope). It's amazing how much useful functionality it out there that I simply haven't tested yet. > I'm afraid I'm not sure exactly what you are asking > here. By Python getting > ahead, I assume you really just mean that ADO is > getting ahead (and > therefore would when called from any language). If > ADO is working somehow > asynchronously, then the solution to that probably > lies inside ADO itself > rather than in Python. I agree, it would be nice if ADO took care of this on its side but unfortunately it doesn't seem to be the case. We've been using Sleep commands to after each AdoConnection.Execute statement but that's a terribly weak work-around, hence my investigation into DispatchWithEvents. By the way Mark, I (and likely most others) appreciate the fact you take the time out to help us out on this mailing list. It's great to get Win32Com advice from the actual developer. ___________________________________________________________ Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com From timr at probo.com Thu Mar 9 19:17:51 2006 From: timr at probo.com (Tim Roberts) Date: Thu, 09 Mar 2006 10:17:51 -0800 Subject: [python-win32] Python-win32 Digest, Vol 36, Issue 11 In-Reply-To: References: Message-ID: <4410714F.9060401@probo.com> James Carroll wrote: >>> I've got one more question for you if I haven't bugged you too much >>> today. I'm getting the list of usernames of active users, but the >>> next thing I need is that user's APPDATA directory. >>> >>> APPDATA=C:\Documents and Settings\username\Application Data >>> >>> I'm tempted to get the APPDATA directory for the current user, and the >>> username, and do a replace on the username directory, but If there's a >>> more foolproof way of knowing what the APPDATA directory will be for >>> that user, I'd sleep better. >> >> How tricky are you willing to get? If you use win32net.NetUserGetInfo, you can fetch the "user_id" value for the user name. If you then search in the registry in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ProfileList, one of the subkeys of that key will be a SID that ends in that user ID (for example, for user ID 1234, you might find S-1-5-21-3939404041-4142424343-4444454546-1234). The "ProfileImagePath" value within that key points to their profile directory. You can guess that "Application Data" will be inside there. Or, for an even more precise answer, you can use that SID to look into their user registry hive. Using that exact example: HKEY_USERS\ S-1-5-21-S-1-5-21-3939404041-4142424343-4444454546-1234\ Software\ Microsoft\ Windows\ CurrentVersion\ Explorer\ Shell\ The "AppData" value within that key is, really and truly, the exact path to their "Application Data" folder. Of course, you'll have to be an administrator to read that key. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ajassal at gmail.com Thu Mar 9 21:20:42 2006 From: ajassal at gmail.com (Amrit Jassal) Date: Thu, 9 Mar 2006 12:20:42 -0800 Subject: [python-win32] Casting to a specific interface Message-ID: <12657e140603091220q66f840b0s87b13d7109fa8b13@mail.gmail.com> I have a fairly basic question. I am trying to map a PyIUnknown interface to a specific (in this case IMAPIStatus) interface. How do I do that? Here is what I have: import mapi, ... tab = self.session.GetStatusTable(0) rows = mapi.HrQueryAllRows(tab, (PR_ENTRYID, PR_RESOURCE_TYPE), # columns to retrieve None, # all rows None, # any sort order is fine 0) # any # of results is fine for row in rows: (eid_tag, eid), (res_tag, res_name) = row if res_tag == PR_RESOURCE_TYPE and res_name == 37: # MAPI_SPOOLER stat = self.session.OpenEntry(eid, None, mapi.MAPI_DEFERRED_ERRORS) stat.FlushQueues(None, None, 0x10) # FLUSH_NO_UI FlushQueues() obviously requires a IMAPIStatus interface. The documentation for OpenEntry() states that passing NULL should give me the correct interface type. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060309/9dbf8582/attachment.htm From mhammond at skippinet.com.au Thu Mar 9 22:43:01 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 10 Mar 2006 08:43:01 +1100 Subject: [python-win32] IE toolbar button in Python In-Reply-To: <349edb380603090515k23315904h90ca33a10d828a49@mail.gmail.com> Message-ID: > in traceutil, and then IE is crashing. Ahh, yes, it all comes back to me now - that is the problem that means you must wait for build 208 :( I'll try and do that early next week (I'm away for the weekend!) Mark From mhammond at skippinet.com.au Fri Mar 10 00:03:25 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 10 Mar 2006 10:03:25 +1100 Subject: [python-win32] Casting to a specific interface In-Reply-To: <12657e140603091220q66f840b0s87b13d7109fa8b13@mail.gmail.com> Message-ID: I'm afraid IMAPIStatus isn't exposed via pywin32 - depending on your patience, I could probably get it done within a week or so, maybe even in time for build 208 :) Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Amrit Jassal Sent: Friday, 10 March 2006 7:21 AM To: Python-win32 at python.org Subject: [python-win32] Casting to a specific interface I have a fairly basic question. I am trying to map a PyIUnknown interface to a specific (in this case IMAPIStatus) interface. How do I do that? Here is what I have: import mapi, ... tab = self.session.GetStatusTable(0) rows = mapi.HrQueryAllRows(tab, (PR_ENTRYID, PR_RESOURCE_TYPE), # columns to retrieve None, # all rows None, # any sort order is fine 0) # any # of results is fine for row in rows: (eid_tag, eid), (res_tag, res_name) = row if res_tag == PR_RESOURCE_TYPE and res_name == 37: # MAPI_SPOOLER stat = self.session.OpenEntry(eid, None, mapi.MAPI_DEFERRED_ERRORS) stat.FlushQueues(None, None, 0x10) # FLUSH_NO_UI FlushQueues() obviously requires a IMAPIStatus interface. The documentation for OpenEntry() states that passing NULL should give me the correct interface type. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060310/d891e32d/attachment-0001.htm From timr at probo.com Fri Mar 10 01:00:22 2006 From: timr at probo.com (Tim Roberts) Date: Thu, 09 Mar 2006 16:00:22 -0800 Subject: [python-win32] export registry keys In-Reply-To: References: Message-ID: <4410C196.4060402@probo.com> On Thu, 09 Mar 2006 17:56:08 +0100, le dahut wrote: >What is the best way to export/import a part of windows registry into >original .reg files (according to the os type). Code must run on both 98 >and XP ? > If you can find a copy of the Windows 2000 Resource Kit (and it may be downloadable from Microsoft), you can use the regdmp and regini tools to do that. Regini is built-in to XP, but both tools work on 98 as well (95, even). The file format is similar, but not identical, to a stock regedit script. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mrmaple at gmail.com Fri Mar 10 04:45:55 2006 From: mrmaple at gmail.com (James Carroll) Date: Thu, 9 Mar 2006 22:45:55 -0500 Subject: [python-win32] Python-win32 Digest, Vol 36, Issue 11 In-Reply-To: <4410714F.9060401@probo.com> References: <4410714F.9060401@probo.com> Message-ID: > >>> APPDATA=C:\Documents and Settings\username\Application Data > >>> > >>> I'm tempted to get the APPDATA directory for the current user, and the > >>> username, and do a replace on the username directory, but If there's a > >>> more foolproof way of knowing what the APPDATA directory will be for > >>> that user, I'd sleep better. > > How tricky are you willing to get? Thanks Tim, That was wicked tricky. This is valuable to know though, I envy your insight. I was giving my app's user a choice of user names just to try to figure out the profile directory, but for this purpose I'm changing my strategy to simply let them choose from a list of directories under Documents and Settings instead. Fewer hoops to jump through, and they're very similar to the actual user names, and no ambiguity as to if that user exists locally _and_ as member of a domain. (at least the ambiguity is pushed out to the user to ponder.) > If you use win32net.NetUserGetInfo, you can fetch the "user_id" value > for the user name. If you then search in the registry in > HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ProfileList, one of the > subkeys of that key will be a SID that ends in that user ID (for > example, for user ID 1234, you might find > S-1-5-21-3939404041-4142424343-4444454546-1234). The "ProfileImagePath" > value within that key points to their profile directory. You can guess > that "Application Data" will be inside there. > > Or, for an even more precise answer, you can use that SID to look into > their user registry hive. Using that exact example: > HKEY_USERS\ > S-1-5-21-S-1-5-21-3939404041-4142424343-4444454546-1234\ > Software\ > Microsoft\ > Windows\ > CurrentVersion\ > Explorer\ > Shell\ > The "AppData" value within that key is, really and truly, the exact path > to their "Application Data" folder. > You da man, Tim. -Jim From ajassal at gmail.com Fri Mar 10 07:44:45 2006 From: ajassal at gmail.com (Amrit Jassal) Date: Thu, 9 Mar 2006 22:44:45 -0800 Subject: [python-win32] Casting to a specific interface In-Reply-To: References: <12657e140603091220q66f840b0s87b13d7109fa8b13@mail.gmail.com> Message-ID: <12657e140603092244o153ddadaie35dcb2dd927e8bd@mail.gmail.com> Mark That would be great. Thanks a lot. On 3/9/06, Mark Hammond wrote: > > I'm afraid IMAPIStatus isn't exposed via pywin32 - depending on your > patience, I could probably get it done within a week or so, maybe even in > time for build 208 :) > > Mark > > -----Original Message----- > *From:* python-win32-bounces at python.org [mailto: > python-win32-bounces at python.org]*On Behalf Of *Amrit Jassal > *Sent:* Friday, 10 March 2006 7:21 AM > *To:* Python-win32 at python.org > *Subject:* [python-win32] Casting to a specific interface > > I have a fairly basic question. > I am trying to map a PyIUnknown interface to a specific (in this case > IMAPIStatus) interface. How do I do that? > > Here is what I have: > > import mapi, ... > > tab = self.session.GetStatusTable(0) > rows = mapi.HrQueryAllRows(tab, > (PR_ENTRYID, PR_RESOURCE_TYPE), # > columns to retrieve > None, # all rows > None, # any sort order is > fine > 0) # any # of results is > fine > for row in rows: > (eid_tag, eid), (res_tag, res_name) = row > if res_tag == PR_RESOURCE_TYPE and res_name == 37: # > MAPI_SPOOLER > stat = self.session.OpenEntry(eid, None, > mapi.MAPI_DEFERRED_ERRORS) > stat.FlushQueues(None, None, 0x10) # FLUSH_NO_UI > > FlushQueues() obviously requires a IMAPIStatus interface. The > documentation for OpenEntry() states that passing NULL should give me the > correct interface type. > > Thanks > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060309/300ff23b/attachment.html From le.dahut at laposte.net Fri Mar 10 09:29:07 2006 From: le.dahut at laposte.net (le dahut) Date: Fri, 10 Mar 2006 09:29:07 +0100 Subject: [python-win32] export registry keys In-Reply-To: <4410C196.4060402@probo.com> References: <4410C196.4060402@probo.com> Message-ID: <441138D3.5070808@laposte.net> I was thinking about win32api.RegSaveKey or _winreg.SaveKey but on XP it must be preceded by a privilege modification and they don't save regular .reg files but internal reg format ... My app will be py2exeded and used by hundreds of people so I can install Resource Kits or other stuff, it must be done with python and/or internal windows commands. Someone has an idea ? (otherwise I'll use "reg export" under XP and regedit /E with 98 but it seems very barbarian isn't it ;-) ) K. Tim Roberts a ?crit : > On Thu, 09 Mar 2006 17:56:08 +0100, le dahut wrote: > >> What is the best way to export/import a part of windows registry into >> original .reg files (according to the os type). Code must run on both 98 >> and XP ? >> > > If you can find a copy of the Windows 2000 Resource Kit (and it may be > downloadable from Microsoft), you can use the regdmp and regini tools to > do that. Regini is built-in to XP, but both tools work on 98 as well > (95, even). The file format is similar, but not identical, to a stock > regedit script. > From timr at probo.com Fri Mar 10 18:04:44 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 10 Mar 2006 09:04:44 -0800 Subject: [python-win32] Python-win32 Digest, Vol 36, Issue 11 In-Reply-To: References: <4410714F.9060401@probo.com> Message-ID: <4411B1AC.9000804@probo.com> James Carroll wrote: >>>>>APPDATA=C:\Documents and Settings\username\Application Data >>>>> >>>>>I'm tempted to get the APPDATA directory for the current user, and the >>>>>username, and do a replace on the username directory, but If there's a >>>>>more foolproof way of knowing what the APPDATA directory will be for >>>>>that user, I'd sleep better. >>>>> >>>>> >>How tricky are you willing to get? >> >> > >Thanks Tim, That was wicked tricky. This is valuable to know though, >I envy your insight. > >I was giving my app's user a choice of user names just to try to >figure out the profile directory, but for this purpose I'm changing my >strategy to simply let them choose from a list of directories under >Documents and Settings instead. Fewer hoops to jump through, and >they're very similar to the actual user names, and no ambiguity as to >if that user exists locally _and_ as member of a domain. (at least >the ambiguity is pushed out to the user to ponder.) > > That's not entirely reliable. One of my partners, a man who HATES spaces in file names, used the "tweakui" utility to rename all of the special directories, so he doesn't even HAVE a "Documents and Settings" folder. His "application data" directory is something like "c:\apps\data". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mrmaple at gmail.com Fri Mar 10 18:48:28 2006 From: mrmaple at gmail.com (James Carroll) Date: Fri, 10 Mar 2006 12:48:28 -0500 Subject: [python-win32] Python-win32 Digest, Vol 36, Issue 11 In-Reply-To: <4411B1AC.9000804@probo.com> References: <4410714F.9060401@probo.com> <4411B1AC.9000804@probo.com> Message-ID: > > > >I'm changing my > >strategy to simply let them choose from a list of directories under > >Documents and Settings instead. > > That's not entirely reliable. One of my partners, a man who HATES > spaces in file names, used the "tweakui" utility to rename all of the > special directories, so he doesn't even HAVE a "Documents and Settings" > folder. His "application data" directory is something like "c:\apps\data". > Cool, I might just do that myself. My "My Documents" directory is C:\jimc and I really like it like that. As long as his ALLUSERSPROFILE is right, then my code should work: allUsersAppData = os.environ["ALLUSERSPROFILE"] # dns = Documents and Settigns usually dns = os.path.join(allUsersAppData, "..") (root, subdirs, files) = os.walk(dns).next() dlg = wx.lib.dialogs.MultipleChoiceDialog(self, "Choose the user's profile directory" "Migrate settings for a user", subdirs, (200,200)) Whadayathink? -Jim From timr at probo.com Fri Mar 10 18:52:14 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 10 Mar 2006 09:52:14 -0800 Subject: [python-win32] export registry keys In-Reply-To: References: Message-ID: <4411BCCE.9090003@probo.com> On Fri, 10 Mar 2006 09:29:07 +0100, le dahut wrote: >I was thinking about win32api.RegSaveKey or _winreg.SaveKey but on XP it >must be preceded by a privilege modification and they don't save regular >.reg files but internal reg format ... >My app will be py2exeded and used by hundreds of people so I can install >Resource Kits or other stuff, it must be done with python and/or >internal windows commands. > > If you're going to do it from Python, then you don't have to worry about using the standard regedit format. There are a couple of registry class wrappers for Python that turn a registry key into a Python object tree. You could fetch the key and pprint it to a file, then eval it later to restore it. >Someone has an idea ? (otherwise I'll use "reg export" under XP and >regedit /E with 98 but it seems very barbarian isn't it ;-) ) > Why is it barbarian? It's called "using the tools at your disposal". By the way, "regedit /E" works perfectly well on XP, so you could use the same scheme everywhere. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mrmaple at gmail.com Fri Mar 10 20:14:30 2006 From: mrmaple at gmail.com (James Carroll) Date: Fri, 10 Mar 2006 14:14:30 -0500 Subject: [python-win32] CoInitialize not called? Message-ID: Hi, I have a multi-threaded wxPython App that examines shortcuts using the function below. The first time my thread runs that opens hundreds of links and looks for my target exe everything is fine. The second time I get the following error: Unhandled exception in thread started by Traceback (most recent call last): File "C:\jimc\prj\bright\scripts\multiUser\searchLinksJob.py", line 54, in Run self.fileChecker.CheckFile(file) File "C:\jimc\prj\bright\scripts\multiUser\UserAppFrame.py", line 47, in CheckFile (linkName, target, startIn, description) = wintools.ReadShortcut(file) File "C:\jimc\prj\bright\scripts\multiUser\wintools.py", line 77, in ReadShortcut sh = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink) pywintypes.com_error: (-2147221008, 'CoInitialize has not been called.', None, None) Script terminated. Should I just call CoInitialize myself randomly? Thanks, -Jim def ReadShortcut(linkFileName): import pythoncom from win32com.shell import shell # Get the shell interface. sh = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink) # Get an IPersist interface persist = sh.QueryInterface(pythoncom.IID_IPersistFile) try: persist.Load(linkFileName) except pywintypes.com_error: pass target = sh.GetPath(shell.SLGP_SHORTPATH)[0] arguments = sh.GetArguments() description = sh.GetDescription() startIn = sh.GetWorkingDirectory() return (linkFileName, target, startIn, description) # From rwupole at msn.com Mon Mar 13 12:52:17 2006 From: rwupole at msn.com (Roger Upole) Date: Mon, 13 Mar 2006 06:52:17 -0500 Subject: [python-win32] CoInitialize not called? Message-ID: You need to call CoInitialize in each thread created. It gets executed automatically once when pythoncom is imported the first time. hth Roger From me at phillatwood.name Sun Mar 12 23:19:01 2006 From: me at phillatwood.name (Phill Atwood) Date: Sun, 12 Mar 2006 17:19:01 -0500 Subject: [python-win32] driving MS Access from python Message-ID: <44149E55.1000403@phillatwood.name> Need to programatically reproduce some activities a user does in MS Access. Need to open a mdb file. Run some queries. Look at some tables. So far import win32com.client a = win32com.client.Dispatch("Access.Application") a.Visible = 1 db = a.OpenCurrentDatabase(filename) Which seems to work so far. But now I need to run 2 of 3 named queries. Then switch to the Tables view and collect the info that has now populated the tables and extract them into python code. I having a hard time scaring up appropriate docs on the MS Access win32com API for this. I've been looking for VBA style docs or anything but I'm still so far just sniffing the corners... Any help is appreciated. Phill From tim.golden at viacom-outdoor.co.uk Mon Mar 13 17:45:19 2006 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon, 13 Mar 2006 16:45:19 -0000 Subject: [python-win32] driving MS Access from python Message-ID: <9A28C052FF32734DACB0A288A3533991044D261E@vogbs009.gb.vo.local> [Phill Atwood] | | Need to programatically reproduce some activities a user does | in MS Access. | Need to open a mdb file. Run some queries. Look at some tables. [...] | I having a hard time scaring up appropriate docs on | the MS Access win32com API for this. I've been | looking for VBA style docs or anything but I'm still so | far just sniffing the corners... I don't use Access myself, bu do I take it you've already seen this? http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11 /html/actocOMMap_HV01049589.asp My usual first port of call is to google for site:msdn.microsoft.com object model Often Googling for Delphi examples works quite well as they are in a similar position to Pythoneers (they like their language/environment, but want to do things with MS software) but have been around longer. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From eric.powell at srs.gov Mon Mar 13 18:04:35 2006 From: eric.powell at srs.gov (eric.powell at srs.gov) Date: Mon, 13 Mar 2006 12:04:35 -0500 Subject: [python-win32] driving MS Access from python In-Reply-To: <44149E55.1000403@phillatwood.name> Message-ID: I would suggest using ADO (Microsoft Active X Data Objects) for this. Much cleaner (and more flexible) than trying to use the Access executable. import win32com.client, string #Establish the ADO DB Connection class fields: def __init__(self, dbpath, tblName): self.dbpath = dbpath self.tblName=tblName def add(self, sqlstatement): conn = win32com.client.Dispatch(r'ADODB.Connection') DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' + self.dbpath + ';' conn.Open(DSN) #Query the recordset - should be in module with establishing connection stuff rs = win32com.client.Dispatch(r'ADODB.Recordset') print sqlstatement try: rs.Open(sqlstatement, conn,1 ,3) except: print 'DB Error' conn.Close() #Update 1 record in the database. Fieldlist is a list of tuples consisting of (Name, Value) def update(self, attdata, fieldlist, wherecl): conn = win32com.client.Dispatch(r'ADODB.Connection') DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' + self.dbpath + ';' conn.Open(DSN) rs = win32com.client.Dispatch(r'ADODB.Recordset') rs_name = 'UPDATE ' + self.tblName + ' SET ' listlen = len(attdata) print 'List is ' + str(listlen) + " items long" for index in range (0,listlen): field = attdata[index] ftype = fieldlist[index][1] #Add function to de-capitalize string, if string.capitalize(ftype[0:7]) == 'Varchar': try: data = '"' + str(field[1]) + '"' except: data = '"' + field[1] + '"' elif string.capitalize(ftype[0:4]) == "Date": try: data = '#' + str(field[1]) + '#' except: data = '#' + field[1] + '#' else: data = field[1] if index == 0: rs_name = rs_name + self.tblName+ '.' + field[0] + ' = ' + data else: try: rs_name = rs_name + ', ' + self.tblName+ '.' + field[0] + ' = ' + data except: print 'Error in data type match, debug data follows: ' print rs_name print self.tblName print field[0] print data rs_name = rs_name + ' ' + wherecl + ';' rs.Open(rs_name, conn,1 ,3) conn.Close() This script: 1) Opens a database conenction 2) Allows execution of an append query (supplied as a SQL string) 3) Allows exceution of an update query. Other sources on info: MSDN query on ADO There is an ADO / Python page out there (check google) but I can't remember the URL. HTH, Eric Eric B. Powell BSRI Electronic Aids (803)208-6207 Phill Atwood Sent by: python-win32-bounces at python.org 03/12/2006 05:19 PM To python-win32 at python.org cc Subject [python-win32] driving MS Access from python Need to programatically reproduce some activities a user does in MS Access. Need to open a mdb file. Run some queries. Look at some tables. So far import win32com.client a = win32com.client.Dispatch("Access.Application") a.Visible = 1 db = a.OpenCurrentDatabase(filename) Which seems to work so far. But now I need to run 2 of 3 named queries. Then switch to the Tables view and collect the info that has now populated the tables and extract them into python code. I having a hard time scaring up appropriate docs on the MS Access win32com API for this. I've been looking for VBA style docs or anything but I'm still so far just sniffing the corners... Any help is appreciated. Phill _______________________________________________ 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/20060313/d9784512/attachment.html From timr at probo.com Mon Mar 13 19:16:39 2006 From: timr at probo.com (Tim Roberts) Date: Mon, 13 Mar 2006 10:16:39 -0800 Subject: [python-win32] application data In-Reply-To: References: Message-ID: <4415B707.10003@probo.com> On Fri, 10 Mar 2006 12:48:28 -0500, "James Carroll" wrote: >Cool, I might just do that myself. My "My Documents" directory is >C:\jimc and I really like it like that. > >As long as his ALLUSERSPROFILE is right, then my code should work: > > allUsersAppData = os.environ["ALLUSERSPROFILE"] > # dns = Documents and Settigns usually > dns = os.path.join(allUsersAppData, "..") > (root, subdirs, files) = os.walk(dns).next() > > dlg = wx.lib.dialogs.MultipleChoiceDialog(self, > "Choose the user's profile directory" > "Migrate settings for a user", subdirs, (200,200)) > >Whadayathink? > No, that's no better. In many corporate environments, your personal profile lives on a net share, while the "All Users" profile is always on the local hard disk. The only reliable way is to whack through the registry. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mvleugel at michielvleugel.com Mon Mar 13 19:14:47 2006 From: mvleugel at michielvleugel.com (Michiel Vleugel) Date: Mon, 13 Mar 2006 19:14:47 +0100 Subject: [python-win32] Resize a control? How? Message-ID: <000f01c646ca$0343c930$4701a8c0@michiel> Hello, I'm having a tough time resizing a control using the win32gui/win32con etc. extensions. I can override the onsize method of a control by doing: self.HookMessage (self.OnSize, win32con.WM_SIZE) Then on the OnSize I can get the size of the control using GetClientSize() So far so good. But how on eatrh can I set new widths and heights of a control? Do I have to re-create the control using CreateWindow? Isn't there another way? Cheers, Michael Vleugel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060313/0503788e/attachment.html From mrmaple at gmail.com Mon Mar 13 20:33:29 2006 From: mrmaple at gmail.com (James Carroll) Date: Mon, 13 Mar 2006 14:33:29 -0500 Subject: [python-win32] application data In-Reply-To: <4415B707.10003@probo.com> References: <4415B707.10003@probo.com> Message-ID: > > dlg = wx.lib.dialogs.MultipleChoiceDialog(self, > > "Choose the user's profile directory" > > "Migrate settings for a user", subdirs, (200,200)) > > > >Whadayathink? > > No, that's no better. In many corporate environments, your personal > profile lives on a net share, while the "All Users" profile is always on > the local hard disk. > I actually realized that soon after I sent my email. Och! Registry whacking, here I come. (Actually, I'm going to keep with the current hard drive technique for a while, since this tool is just for interal techs to save them some time, I'll wait until we actualy have the problem once or twice. I'm also not fond of writing code that I can't test thoroughly, and I don't have roaming profiles set up.) -Jim From me at phillatwood.name Mon Mar 13 21:28:58 2006 From: me at phillatwood.name (Phill Atwood) Date: Mon, 13 Mar 2006 15:28:58 -0500 Subject: [python-win32] driving MS Access from python In-Reply-To: References: Message-ID: <4415D60A.2080401@phillatwood.name> Eric, Thanks. This seems like a good idea. I noticed also ADOdb for Python. Would this work do you know? Since I'm doing win/ms access I think I'll need to use mxodbc but I don't know how to install that on Windows. In your example below it is not clear (to me) how to get the dimensions of the recordset and navigate thru (eg. print) all the resultant fields. Is there something similar to the ADOdb for Python while not cursor.EOF: print cursor.fields cursor.MoveNext() cursor.close() eric.powell at srs.gov wrote: > > I would suggest using ADO (Microsoft Active X Data Objects) for this. > Much cleaner (and more flexible) than trying to use the Access > executable. > > import win32com.client, string > > #Establish the ADO DB Connection > class fields: > def __init__(self, dbpath, tblName): > self.dbpath = dbpath > self.tblName=tblName > def add(self, sqlstatement): > conn = win32com.client.Dispatch(r'ADODB.Connection') > DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' + > self.dbpath + ';' > conn.Open(DSN) > > #Query the recordset - should be in module with establishing > connection stuff > rs = win32com.client.Dispatch(r'ADODB.Recordset') > print sqlstatement > try: > rs.Open(sqlstatement, conn,1 ,3) > except: > print 'DB Error' > > conn.Close() > #Update 1 record in the database. Fieldlist is a list of tuples > consisting of (Name, Value) > def update(self, attdata, fieldlist, wherecl): > conn = win32com.client.Dispatch(r'ADODB.Connection') > DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' + > self.dbpath + ';' > conn.Open(DSN) > > rs = win32com.client.Dispatch(r'ADODB.Recordset') > rs_name = 'UPDATE ' + self.tblName + ' SET ' > > listlen = len(attdata) > print 'List is ' + str(listlen) + " items long" > for index in range (0,listlen): > field = attdata[index] > ftype = fieldlist[index][1] > #Add function to de-capitalize string, > if string.capitalize(ftype[0:7]) == 'Varchar': > try: > data = '"' + str(field[1]) + '"' > except: > data = '"' + field[1] + '"' > elif string.capitalize(ftype[0:4]) == "Date": > try: > data = '#' + str(field[1]) + '#' > except: > data = '#' + field[1] + '#' > else: > data = field[1] > > if index == 0: > rs_name = rs_name + self.tblName+ '.' + field[0] + ' = > ' + data > else: > try: > rs_name = rs_name + ', ' + self.tblName+ '.' + > field[0] + ' = ' + data > except: > print 'Error in data type match, debug data > follows: ' > print rs_name > print self.tblName > print field[0] > print data > rs_name = rs_name + ' ' + wherecl + ';' > rs.Open(rs_name, conn,1 ,3) > conn.Close() > > This script: > > 1) Opens a database conenction > 2) Allows execution of an append query (supplied as a SQL string) > 3) Allows exceution of an update query. > > Other sources on info: > > MSDN query on ADO > > There is an ADO / Python page out there (check google) but I can't > remember the URL. > > HTH, > > Eric > > Eric B. Powell > BSRI > Electronic Aids > (803)208-6207 > > > > *Phill Atwood * > Sent by: python-win32-bounces at python.org > > 03/12/2006 05:19 PM > > > To > python-win32 at python.org > cc > > Subject > [python-win32] driving MS Access from python > > > > > > > > > > > > Need to programatically reproduce some activities a user does in MS > Access. > Need to open a mdb file. Run some queries. Look at some tables. > > So far > > import win32com.client > a = win32com.client.Dispatch("Access.Application") > a.Visible = 1 > db = a.OpenCurrentDatabase(filename) > > Which seems to work so far. But now I need to run 2 of 3 named > queries. Then switch > to the Tables view and collect the info that has now populated the > tables and extract them > into python code. I having a hard time scaring up appropriate docs on > the MS Access > win32com API for this. I've been looking for VBA style docs or anything > but I'm still so > far just sniffing the corners... > > Any help is appreciated. > > Phill > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From eric.powell at srs.gov Mon Mar 13 21:42:51 2006 From: eric.powell at srs.gov (eric.powell at srs.gov) Date: Mon, 13 Mar 2006 15:42:51 -0500 Subject: [python-win32] driving MS Access from python In-Reply-To: <4415D60A.2080401@phillatwood.name> Message-ID: Exactly. Once you set up the iDispatch to point to the ADODB object library, you can then use the ADO methods and objects. One advantage of ADO is that it SHOULD be installed as part of Windows (I think...I have never run into a case where is wasn't, anyone on the list want to correct me on this????), so things should work out of the box (so to speak). To get the dimensions of the recordset you could use the Fields and Rows count count methods in ADO Open Connection stuff... rs = win32com.client.Dispatch(r'ADODB.Recordset') rs.Open(sqlstatement, conn,1 ,3) FC = rs.Fields.Count RC = rs.Rows.Count Further for navigating between rows, you have: rs.MoveFirst rs.MoveLast rs.MoveNext rs.MovePrevious ???? (I think you can iterate backward). To get the value of a given field, descend through the Recordset->Fields->Item() chain as follows: val = rs.Fields.Item(1).Value Where the iterator in item can be either an ineteger or a fieldname: val = rs.Fields.Item("Fred").Value ADO can also access/fire an existing action query or return the records from a stored query. More info: http://www.w3schools.com/ado/default.asp http://www.mayukhbose.com/python/ado/ado-python.php HTH, Eric Eric B. Powell BSRI Electronic Aids (803)208-6207 Phill Atwood 03/13/2006 03:28 PM To eric.powell at srs.gov cc python-win32 at python.org Subject Re: [python-win32] driving MS Access from python Eric, Thanks. This seems like a good idea. I noticed also ADOdb for Python. Would this work do you know? Since I'm doing win/ms access I think I'll need to use mxodbc but I don't know how to install that on Windows. In your example below it is not clear (to me) how to get the dimensions of the recordset and navigate thru (eg. print) all the resultant fields. Is there something similar to the ADOdb for Python while not cursor.EOF: print cursor.fields cursor.MoveNext() cursor.close() eric.powell at srs.gov wrote: > > I would suggest using ADO (Microsoft Active X Data Objects) for this. > Much cleaner (and more flexible) than trying to use the Access > executable. > > import win32com.client, string > > #Establish the ADO DB Connection > class fields: > def __init__(self, dbpath, tblName): > self.dbpath = dbpath > self.tblName=tblName > def add(self, sqlstatement): > conn = win32com.client.Dispatch(r'ADODB.Connection') > DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' + > self.dbpath + ';' > conn.Open(DSN) > > #Query the recordset - should be in module with establishing > connection stuff > rs = win32com.client.Dispatch(r'ADODB.Recordset') > print sqlstatement > try: > rs.Open(sqlstatement, conn,1 ,3) > except: > print 'DB Error' > > conn.Close() > #Update 1 record in the database. Fieldlist is a list of tuples > consisting of (Name, Value) > def update(self, attdata, fieldlist, wherecl): > conn = win32com.client.Dispatch(r'ADODB.Connection') > DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' + > self.dbpath + ';' > conn.Open(DSN) > > rs = win32com.client.Dispatch(r'ADODB.Recordset') > rs_name = 'UPDATE ' + self.tblName + ' SET ' > > listlen = len(attdata) > print 'List is ' + str(listlen) + " items long" > for index in range (0,listlen): > field = attdata[index] > ftype = fieldlist[index][1] > #Add function to de-capitalize string, > if string.capitalize(ftype[0:7]) == 'Varchar': > try: > data = '"' + str(field[1]) + '"' > except: > data = '"' + field[1] + '"' > elif string.capitalize(ftype[0:4]) == "Date": > try: > data = '#' + str(field[1]) + '#' > except: > data = '#' + field[1] + '#' > else: > data = field[1] > > if index == 0: > rs_name = rs_name + self.tblName+ '.' + field[0] + ' = > ' + data > else: > try: > rs_name = rs_name + ', ' + self.tblName+ '.' + > field[0] + ' = ' + data > except: > print 'Error in data type match, debug data > follows: ' > print rs_name > print self.tblName > print field[0] > print data > rs_name = rs_name + ' ' + wherecl + ';' > rs.Open(rs_name, conn,1 ,3) > conn.Close() > > This script: > > 1) Opens a database conenction > 2) Allows execution of an append query (supplied as a SQL string) > 3) Allows exceution of an update query. > > Other sources on info: > > MSDN query on ADO > > There is an ADO / Python page out there (check google) but I can't > remember the URL. > > HTH, > > Eric > > Eric B. Powell > BSRI > Electronic Aids > (803)208-6207 > > > > *Phill Atwood * > Sent by: python-win32-bounces at python.org > > 03/12/2006 05:19 PM > > > To > python-win32 at python.org > cc > > Subject > [python-win32] driving MS Access from python > > > > > > > > > > > > Need to programatically reproduce some activities a user does in MS > Access. > Need to open a mdb file. Run some queries. Look at some tables. > > So far > > import win32com.client > a = win32com.client.Dispatch("Access.Application") > a.Visible = 1 > db = a.OpenCurrentDatabase(filename) > > Which seems to work so far. But now I need to run 2 of 3 named > queries. Then switch > to the Tables view and collect the info that has now populated the > tables and extract them > into python code. I having a hard time scaring up appropriate docs on > the MS Access > win32com API for this. I've been looking for VBA style docs or anything > but I'm still so > far just sniffing the corners... > > Any help is appreciated. > > Phill > > _______________________________________________ > 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/20060313/1b63aa8a/attachment.html From mhammond at skippinet.com.au Mon Mar 13 22:39:32 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 14 Mar 2006 08:39:32 +1100 Subject: [python-win32] Resize a control? How? In-Reply-To: <000f01c646ca$0343c930$4701a8c0@michiel> Message-ID: > But how on eatrh can I set new widths and heights of a control? Do I have > to re-create the control using CreateWindow? Isn't there another way? MoveWindow is the call you are after. Mark From me at phillatwood.name Mon Mar 13 22:47:09 2006 From: me at phillatwood.name (Phill Atwood) Date: Mon, 13 Mar 2006 16:47:09 -0500 Subject: [python-win32] MS Access query error In-Reply-To: <4415D60A.2080401@phillatwood.name> References: <4415D60A.2080401@phillatwood.name> Message-ID: <4415E85D.2000005@phillatwood.name> I'm trying to get at some data in MS Access. This long query updates a table. I'm wondering if this query is failing. Anyways, when I run dbpath = os.getcwd() + "\\Test (2).mdb" conn = win32com.client.Dispatch(r'ADODB.Connection') DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' + dbpath + ';' conn.Open(DSN) rs = win32com.client.Dispatch(r'ADODB.Recordset') sqlstatement = 'UPDATE [Acute avian (liquids)] INNER JOIN (([Label info] INNER JOIN [User selection] ON [Label info].Crop = [User selection].[Select Crop]) INNER JOIN [Acute mammal (liquids)] ON [Label info].[AI Code] = [Acute mammal (liquids)].[AI Code]) ON ([Acute avian (liquids)].[AI Code] = [Acute mammal (liquids)].[AI Code]) AND ([Acute avian (liquids)].Group = [Acute mammal (liquids)].Group) SET [Acute avian (liquids)].[Application rate -kg per ha] = [Label info]![AI rate - kg per ha], [Acute mammal (liquids)].[Application rate -kg per ha] = [Label info]![AI rate - kg per ha] WHERE ((([Label info].[Application detail])="Ground spray"));' print sqlstatement rs.Open(sqlstatement, conn) print "rs.RecordCount = " + rs.RecordCount I get the error [snip...] intypes.com_error: (-2147352567, 'Exception occurred.', (0, 'ADODB.Recordset', 'Operation is not allowed when the object is closed.', 'C:\\WINDOWS\\HELP\\ADO270.CHM', 1240653, -2146824584), None) on the very last statement. I'm still new to this stuff and trying to get my head around it. I need to be able to duplicate this query which works fine by hand in Access. Any help is appreciated. Thanks, Phill From fumanchu at amor.org Mon Mar 13 23:02:10 2006 From: fumanchu at amor.org (Robert Brewer) Date: Mon, 13 Mar 2006 14:02:10 -0800 Subject: [python-win32] MS Access query error Message-ID: <435DF58A933BA74397B42CDEB8145A869DA971@ex9.hostedexchange.local> Phill Atwood wrote: > intypes.com_error: (-2147352567, 'Exception occurred.', (0, > 'ADODB.Recordset', 'Operation is not allowed when the object is > closed.', 'C:\\WINDOWS\\HELP\\ADO270.CHM', 1240653, > -2146824584), None) IIRC, you need to set Cursorlocation before calling Recordcount. Google for more info. adUseClient = 3 rs.Cursorlocation = adUseClient Robert Brewer System Architect Amor Ministries fumanchu at amor.org From timr at probo.com Mon Mar 13 23:38:22 2006 From: timr at probo.com (Tim Roberts) Date: Mon, 13 Mar 2006 14:38:22 -0800 Subject: [python-win32] driving MS Access from python In-Reply-To: References: Message-ID: <4415F45E.6030406@probo.com> On Mon, 13 Mar 2006 15:28:58 -0500, Phill Atwood wrote: >Thanks. This seems like a good idea. I noticed also ADOdb for Python. >Would this work do you know? Since I'm doing win/ms access I think I'll >need to use mxodbc but I don't know how to install that on Windows. > >In your example below it is not clear (to me) how to get the dimensions >of the recordset and navigate thru (eg. print) all the resultant >fields. Is there something similar to the ADOdb for >Python > One of the issues with Access is that there are an "embarrassment of riches" of methods to get to an Access database on Windows. You have ODBC directly, mxodbc, Jet, DAO, Jet via ADODB, ODBC via ADODB, DAO via ADODB. ADODB is a very good way of doing it. One of the advantages is that the same code works for Postgres or MySQL; you just change the connection string (although that's mostly true for ODBC, too). Plus, by creating an ADOX.Catalog object, you can stroll through the metadata as well. You can fetch the list of tables, and the fields within the tables, and so on. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From me at phillatwood.name Tue Mar 14 00:04:53 2006 From: me at phillatwood.name (Phill Atwood) Date: Mon, 13 Mar 2006 18:04:53 -0500 Subject: [python-win32] driving MS Access from python In-Reply-To: <4415F45E.6030406@probo.com> References: <4415F45E.6030406@probo.com> Message-ID: <4415FA95.9040309@phillatwood.name> Tim, Thanks. I've downloaded and installed adodb for Python. But I guess I need to install mxODBC as well. But I'm not quite understanding the docs I'm reading on how to do this. It seems very complex.... Phill Tim Roberts wrote: > On Mon, 13 Mar 2006 15:28:58 -0500, Phill Atwood > wrote: > > >> Thanks. This seems like a good idea. I noticed also ADOdb for Python. >> Would this work do you know? Since I'm doing win/ms access I think I'll >> need to use mxodbc but I don't know how to install that on Windows. >> >> In your example below it is not clear (to me) how to get the dimensions >> of the recordset and navigate thru (eg. print) all the resultant >> fields. Is there something similar to the ADOdb for >> Python >> >> > > > One of the issues with Access is that there are an "embarrassment of > riches" of methods to get to an Access database on Windows. You have > ODBC directly, mxodbc, Jet, DAO, Jet via ADODB, ODBC via ADODB, DAO via > ADODB. > > ADODB is a very good way of doing it. One of the advantages is that the > same code works for Postgres or MySQL; you just change the connection > string (although that's mostly true for ODBC, too). Plus, by creating > an ADOX.Catalog object, you can stroll through the metadata as well. > You can fetch the list of tables, and the fields within the tables, and > so on. > > From sjmachin at lexicon.net Tue Mar 14 00:19:46 2006 From: sjmachin at lexicon.net (John Machin) Date: Tue, 14 Mar 2006 10:19:46 +1100 Subject: [python-win32] driving MS Access from python In-Reply-To: <4415FA95.9040309@phillatwood.name> References: <4415F45E.6030406@probo.com> <4415FA95.9040309@phillatwood.name> Message-ID: <4415FE12.8030502@lexicon.net> On 14/03/2006 10:04 AM, Phill Atwood wrote: > Tim, > > Thanks. I've downloaded and installed adodb for Python. But I guess I > need to install mxODBC as well. But I'm not quite understanding the > docs I'm reading on how to do this. It seems very complex.... > > Phill > Phill, Sorry, you've lost me ... I thought "this" (installing mxODBC) was as simple as downloading the two installers ("base" and "commercial") that match the version of Python that you are using, and running them. What docs are you reading? Cheers, John From trentm at ActiveState.com Tue Mar 14 00:20:18 2006 From: trentm at ActiveState.com (Trent Mick) Date: Mon, 13 Mar 2006 15:20:18 -0800 Subject: [python-win32] Fwd: Re: [Python-Dev] Still looking for volunteer to run Windows buildbot Message-ID: <20060313232018.GB11592@activestate.com> Does anybody know of a way to programmatically check if a particular Windows box has a soundcard installed and configured? Background: I'm running a Windows buildbot for Python and the test suite fails on test_winsound.py because the box doesn't have a sound card setup. (The "Sound" Control Panel items says there are "No Playback Devices" for Sound Playback.) TIA, Trent ----- Forwarded message from "\"Martin v. L?wis\"" ----- Date: Mon, 13 Mar 2006 23:57:34 +0100 From: "Martin v. L?wis" To: Trent Mick Cc: python-dev at python.org, Thomas Heller Subject: Re: [Python-Dev] Still looking for volunteer to run Windows buildbot Trent Mick wrote: > I do have a sound card in that box, however, the "Sounds and Multimedia > Properties" dialog (off Control Panel) says that there are "No Playback > Devices" for Sound Playback. So I guess that is it. Maybe the sound card > in that box is not hooked up. Grrr. I certainly don't care about the > sound card for that box but I don't want the test suite to keep > reporting a spurious failure. Now, if there was a reliable check whether a soundcard is present, that check could be run as a prerequisite, then raising TestSkipped if no soundcard is present. Regards, Martin ----- End forwarded message ----- -- Trent Mick TrentM at ActiveState.com From timr at probo.com Tue Mar 14 00:20:11 2006 From: timr at probo.com (Tim Roberts) Date: Mon, 13 Mar 2006 15:20:11 -0800 Subject: [python-win32] driving MS Access from python In-Reply-To: <4415FA95.9040309@phillatwood.name> References: <4415F45E.6030406@probo.com> <4415FA95.9040309@phillatwood.name> Message-ID: <4415FE2B.3020600@probo.com> Phill Atwood wrote: > > Thanks. I've downloaded and installed adodb for Python. But I guess I > need to install mxODBC as well. But I'm not quite understanding the > docs I'm reading on how to do this. It seems very complex.... No, you don't need mxODBC, although I'm curious to know what led you to believe that. Go do a google search for "adodb connection strings", and you find several samples. Here's a simple sample that I used to access an Access database. Note that I have connection strings for either the Jet OLEDB driver, or the Access ODBC driver. This opens a "table" recordset (the rs.Open function). import os import win32com.client conn = win32com.client.Dispatch("ADODB.Connection") # Either way works: one is the Jet OLEDB driver, the other is the # Access ODBC driver. OLEDB is probably better. db = r"c:\dev\54nsdc\Volunteer.mdb" DSN="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + db #DSN="Driver={Microsoft Access Driver (*.mdb)};DBQ=" + db conn.Open(DSN) rs = win32com.client.Dispatch("ADODB.Recordset") rs.Open( "[Committees]", conn, 1, 3 ) print rs.Fields.Count, " fields found:" for x in range(rs.Fields.Count): print rs.Fields.Item(x).Name, print rs.Fields.Item(x).Type, print rs.Fields.Item(x).DefinedSize, print rs.Fields.Item(x).Value To execute a generic SQL statement, you create an ADODB.Command object and connect it to the Connection: cmd = win32com.client.Dispatch("ADODB.Command") cmd.ActiveConnection = conn cmd.CommandText = "SELECT COUNT(*) FROM committees;" rs = cmd.Execute[0] Now rs is a recordset. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060313/e91d9dde/attachment.html From me at phillatwood.name Tue Mar 14 00:54:07 2006 From: me at phillatwood.name (Phill Atwood) Date: Mon, 13 Mar 2006 18:54:07 -0500 Subject: [python-win32] driving MS Access from python In-Reply-To: <4415FE2B.3020600@probo.com> References: <4415F45E.6030406@probo.com> <4415FA95.9040309@phillatwood.name> <4415FE2B.3020600@probo.com> Message-ID: <4416061F.80904@phillatwood.name> > No, you don't need mxODBC, although I'm curious to know what led you > to believe that. http://phplens.com/lens/adodb/adodb-py-docs.htm#databases I guess maybe this link was referring to PHP ... Well, painfully I'm making some progress. And I appreciate your help in this. I think my previous problem was because I was doing rs.Open(sqlstmt) instead of: rs.Open(sqlstmt, conn) > To execute a generic SQL statement, you create an ADODB.Command object > and connect it to the Connection: > > cmd = win32com.client.Dispatch("ADODB.Command") > cmd.ActiveConnection = conn > cmd.CommandText = "SELECT COUNT(*) FROM committees;" > rs = cmd.Execute[0] > > > Now rs is a recordset. Now, I've got your above example working. Almost. For me rs = cmd.Execute[0] failed with TypeError: unsubscriptable object However, trying this variation: (rs, result) = cmd.Execute() did work. Problem is when I then try data = rs.GetRows() I get Traceback (most recent call last): File "", line 1, in -toplevel- data = rs.GetRows() File "C:\Python24\lib\site-packages\win32com\gen_py\2A75196C-D9EB-4129-B803-931327F72D5Cx0x2x8.py", line 2333, in GetRows , Start, Fields) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_( com_error: (-2147352567, 'Exception occurred.', (0, 'ADODB.Recordset', 'Operation is not allowed when the object is closed.', 'C:\\WINDOWS\\HELP\\ADO270.CHM', 1240653, -2146824584), None) I feel so tantillizingly close... Phill From me at phillatwood.name Tue Mar 14 01:19:21 2006 From: me at phillatwood.name (Phill Atwood) Date: Mon, 13 Mar 2006 19:19:21 -0500 Subject: [python-win32] driving MS Access from python In-Reply-To: <4415FE12.8030502@lexicon.net> References: <4415F45E.6030406@probo.com> <4415FA95.9040309@phillatwood.name> <4415FE12.8030502@lexicon.net> Message-ID: <44160C09.4090402@phillatwood.name> > > Sorry, you've lost me ... I thought "this" (installing mxODBC) was as > simple as downloading the two installers ("base" and "commercial") > that match the version of Python that you are using, and running them. > What docs are you reading? http://phplens.com/lens/adodb/adodb-py-docs.htm#databases I guess this is more PHP oriented... I'm not sure what you are referring to when you say 'two installers "base" and "commercial"'. I downloaded the adodb zip file and followed the instructions to python setup.py install it. Which is what I did. According to someone else this is all I need do... Thanks for your input. Phill From timr at probo.com Tue Mar 14 01:26:56 2006 From: timr at probo.com (Tim Roberts) Date: Mon, 13 Mar 2006 16:26:56 -0800 Subject: [python-win32] driving MS Access from python In-Reply-To: <4416061F.80904@phillatwood.name> References: <4415F45E.6030406@probo.com> <4415FA95.9040309@phillatwood.name> <4415FE2B.3020600@probo.com> <4416061F.80904@phillatwood.name> Message-ID: <44160DD0.7090605@probo.com> Phill Atwood wrote: > > Well, painfully I'm making some progress. And I appreciate your help > in this. I think my previous problem was because I was doing > > rs.Open(sqlstmt) > instead of: > rs.Open(sqlstmt, conn) > >> To execute a generic SQL statement, you create an ADODB.Command >> object and connect it to the Connection: >> >> cmd = win32com.client.Dispatch("ADODB.Command") >> cmd.ActiveConnection = conn >> cmd.CommandText = "SELECT COUNT(*) FROM committees;" >> rs = cmd.Execute[0] >> >> >> Now rs is a recordset. > > > Now, I've got your above example working. Almost. For me > > rs = cmd.Execute[0] > failed with > TypeError: unsubscriptable object Duh, yes, I typed this from my code instead of cutting and pasting. rs = cmd.Execute()[0] is what I meant, which does the same as what you have. > Problem is when I then try > > data = rs.GetRows() > > I get > > Traceback (most recent call last): > File "", line 1, in -toplevel- > data = rs.GetRows() > File > "C:\Python24\lib\site-packages\win32com\gen_py\2A75196C-D9EB-4129-B803-931327F72D5Cx0x2x8.py", > line 2333, in GetRows > , Start, Fields) > File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", > line 446, in _ApplyTypes_ > return self._get_good_object_( > com_error: (-2147352567, 'Exception occurred.', (0, 'ADODB.Recordset', > 'Operation is not allowed when the object is closed.', > 'C:\\WINDOWS\\HELP\\ADO270.CHM', 1240653, -2146824584), None) I'm not sure why you'd use GetRows. while not rs.EOF: print rs.Fields("FieldName1") rs.MoveNext() I often write a small wrapper around the recordset which turns it into a generator, because inevitably, on the first round, I forget the MoveNext and get an infinite loop: def Recordset(cmd, sql): cmd.CommandText = sql rs = cmd.Execute()[0] while not rs.EOF: yield rs rs.MoveNext() for row in Recordset( cmd, "SELECT FieldName1 FROM MyTable" ): print rs.Fields("FieldName1") -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rwupole at msn.com Tue Mar 14 01:51:47 2006 From: rwupole at msn.com (Roger Upole) Date: Mon, 13 Mar 2006 19:51:47 -0500 Subject: [python-win32] Re: [Python-Dev] Still looking for volunteer to Message-ID: Trent Mick wrote: > Does anybody know of a way to programmatically check if a particular > Windows box has a soundcard installed and configured? > > Background: > I'm running a Windows buildbot for Python and the test suite fails on > test_winsound.py because the box doesn't have a sound card setup. (The > "Sound" Control Panel items says there are "No Playback Devices" for > Sound Playback.) WMI can list sound devices. import win32com.client wmi=win32com.client.GetObject('winmgmts:') scs=wmi.InstancesOf('win32_sounddevice') for sc in scs: print sc.Properties_('Name'), sc.Properties_('Status') You might also have to check one of the other properties to make sure the device is actually operating, I don't have a non-functional device to test with. Roger From sjmachin at lexicon.net Tue Mar 14 01:54:38 2006 From: sjmachin at lexicon.net (John Machin) Date: Tue, 14 Mar 2006 11:54:38 +1100 Subject: [python-win32] driving MS Access from python In-Reply-To: <44160C09.4090402@phillatwood.name> References: <4415F45E.6030406@probo.com> <4415FA95.9040309@phillatwood.name> <4415FE12.8030502@lexicon.net> <44160C09.4090402@phillatwood.name> Message-ID: <4416144E.7030200@lexicon.net> On 14/03/2006 11:19 AM, Phill Atwood wrote: > >> >> Sorry, you've lost me ... I thought "this" (installing mxODBC) was as >> simple as downloading the two installers ("base" and "commercial") >> that match the version of Python that you are using, and running them. >> What docs are you reading? > > http://phplens.com/lens/adodb/adodb-py-docs.htm#databases > > I guess this is more PHP oriented... > > I'm not sure what you are referring to when you say 'two installers > "base" and "commercial"'. You wrote "But I guess I need to install mxODBC as well. But I'm not quite understanding the docs I'm reading on how to do this." I.e. IMHO the only reasonable construction was that you were asking how to install mxODBC. That's what I replied to. You need to install mx base to get the date/time stuff, and mx commercial to get mxODBC. From me at phillatwood.name Tue Mar 14 02:13:04 2006 From: me at phillatwood.name (Phill Atwood) Date: Mon, 13 Mar 2006 20:13:04 -0500 Subject: [python-win32] driving MS Access from python In-Reply-To: <44160DD0.7090605@probo.com> References: <4415F45E.6030406@probo.com> <4415FA95.9040309@phillatwood.name> <4415FE2B.3020600@probo.com> <4416061F.80904@phillatwood.name> <44160DD0.7090605@probo.com> Message-ID: <441618A0.6010107@phillatwood.name> > while not rs.EOF: > print rs.Fields("FieldName1") > rs.MoveNext() > > This isn't working for me either. Same error about error: (-2147352567, 'Exception occurred.', (0, 'ADODB.Recordset', 'Operation is not allowed when the object is closed.', 'C:\\WINDOWS\\HELP\\ADO270.CHM', 1240653, -2146824584), None) >>> the object being closed. I'm not sure why it thinks that. If I print rs it describes an instance etc. and my result value from (rs, result) is 35 which is exactly the number of records updated by the query. Could it have something to do with the fact that the query updates another table? Do I need to look at that table? Is that why rs is empty or closed. Bizarre. Phill From timr at probo.com Tue Mar 14 02:26:01 2006 From: timr at probo.com (Tim Roberts) Date: Mon, 13 Mar 2006 17:26:01 -0800 Subject: [python-win32] driving MS Access from python In-Reply-To: <441618A0.6010107@phillatwood.name> References: <4415F45E.6030406@probo.com> <4415FA95.9040309@phillatwood.name> <4415FE2B.3020600@probo.com> <4416061F.80904@phillatwood.name> <44160DD0.7090605@probo.com> <441618A0.6010107@phillatwood.name> Message-ID: <44161BA9.3050504@probo.com> Phill Atwood wrote: > >> while not rs.EOF: >> print rs.Fields("FieldName1") >> rs.MoveNext() > > > This isn't working for me either. Same error about > > error: (-2147352567, 'Exception occurred.', (0, 'ADODB.Recordset', > 'Operation is not allowed when the object is closed.', > 'C:\\WINDOWS\\HELP\\ADO270.CHM', 1240653, -2146824584), None) > >>> > > the object being closed. I'm not sure why it thinks that. If I print > rs it describes an instance etc. and my result value from (rs, > result) is 35 which is exactly the number of records updated by the > query. Could it have something to do with the fact that the query > updates another table? Do I need to look at that table? Is that why > rs is empty or closed. Bizarre. Well, yes, of course. Action queries (UPDATE, DELETE, INSERT) don't return a recordset. Only SELECT queries do. If all you're trying to do is an UPDATE, then just do the Execute() and you're done. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From le.dahut at laposte.net Tue Mar 14 10:58:39 2006 From: le.dahut at laposte.net (le dahut) Date: Tue, 14 Mar 2006 10:58:39 +0100 Subject: [python-win32] export registry keys In-Reply-To: <4411BCCE.9090003@probo.com> References: <4411BCCE.9090003@probo.com> Message-ID: <441693CF.106@laposte.net> Hello, Tim Roberts a ?crit : > On Fri, 10 Mar 2006 09:29:07 +0100, le dahut wrote: > >> I was thinking about win32api.RegSaveKey or _winreg.SaveKey but on XP it >> must be preceded by a privilege modification and they don't save regular >> .reg files but internal reg format ... >> My app will be py2exeded and used by hundreds of people so I can install >> Resource Kits or other stuff, it must be done with python and/or >> internal windows commands. >> >> > > If you're going to do it from Python, then you don't have to worry about > using the standard regedit format. There are a couple of registry class > wrappers for Python that turn a registry key into a Python object tree. mmhmm very interesting, could you tell me more about those classes ? > You could fetch the key and pprint it to a file, then eval it later to > restore it. > >> Someone has an idea ? (otherwise I'll use "reg export" under XP and >> regedit /E with 98 but it seems very barbarian isn't it ;-) ) >> > > Why is it barbarian? It's called "using the tools at your disposal". It opens a DOS prompt when the 'regedit' command is launched ... for a wx app it looks not clean... maybe you know a way to hide this behavior ? > > By the way, "regedit /E" works perfectly well on XP, so you could use > the same scheme everywhere. > Thanks, K. From Ola.Rylow at hiq.se Tue Mar 14 14:37:05 2006 From: Ola.Rylow at hiq.se (Ola Rylow) Date: Tue, 14 Mar 2006 14:37:05 +0100 Subject: [python-win32] Reading a UInt32 array from LabVIEW Message-ID: <4336B5C3DC33A74FA393F4F88152F4EC5DA131@hiqqbexc001.sto.hiq.se> I'm accessing LabVIEW through the ActiveX interface and I'm having a problem with reading a UInt32 array. The code used is: inParams = ["Numeric", "Numeric 2", "Numeric 3", "Array"] inValues = [9,8,7, ()] retval = viReference.Call(inParams, inValues) where "Array" is output and the rest is input. I've also used an empty list instead of tuple in inValues. The GetControlValue method does not work neither. If I change the Array to contain SInt32 elements everything will work fine! So how do I extract an UInt32 array? Can anyone help, please. BR Ola This is the error I get: C:\Python24\lib\site-packages\win32com\client\__init__.py:480: RuntimeWarning: tp_compare didn't return -1 or -2 for exception elif type(obj)==TupleType: Traceback (most recent call last): File "C:\AtletScripts\LabVIEW_test\scripts\ArrayOutTest.py", line 18, in ? retval = viReference.Call(inParams, inValues) File "C:\AtletScripts\LabVIEW_test\includes\LabVIEW71.py", line 1038, in Call , paramVals) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 449, in _ApplyTypes_ user, resultCLSID) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 467, in _get_good_object_ return _get_good_object_(obj, obUserName, resultCLSID) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 480, in _get_good_object_ elif type(obj)==TupleType: TypeError: The VARIANT type 0x13 is not supported for SAFEARRAYS -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060314/6882312b/attachment.htm From Gary.Scorby at harlandfs.com Tue Mar 14 16:47:35 2006 From: Gary.Scorby at harlandfs.com (Gary Scorby) Date: Tue, 14 Mar 2006 07:47:35 -0800 Subject: [python-win32] VB Com object problem Message-ID: I have a visual basic com object I am trying to use, so far unsuccessfully. I am happily VB ignorant but will do my best to describe the problem. >>> import win32com.client >>> biff = win32com.client.Dispatch("OBName.Main") >>> biff.LoggedIn 0 >>> biff.TelLogin("Login", "Password", -1, App) The "TelLogin" method is where things blow up. I need to send the following 4 required parameters- 1) Login ID 2) Password 3) A VB True, which they tell me is equivalent to -1 4) The VB App keyword which is suppose to identify the calling application, in this case Python. This is where things blow up. Below is a description from the vendor about the App keyword and how it is used. Looks very VB specific to me. I have been all over the web trying to find an equivalent of what to send in Python. I have had no luck. What in the name of Python, if anything, can I use in the 4th parameter? I have successfully used other VB com objects with Python, but never with an App requirement. Thanks for any assistance. Gary Scorby This is the description from the vendor- ----------------- The App object is a VB keyword. What we use it for in BPUTIL is to determine properties of the application that is sending the message. Here is how we use it. We define a global variable: Public myApp As Object (Object Data Type: Object variables are stored as 32-bit (4-byte) addresses that refer to objects. Using the Set statement, a variable declared as an Object can have any object reference assigned to it.) In the TelLogin routine we set myApp to the App object parameter passed to the routine: Public Sub TelLogin(sUsr As String, sPW As String, GetIni As Integer, oApp As Object, Optional sBank As String, Optional sSIP As String) Set myApp = oApp >From there on we can look at the 'App' properties such as: myApp.EXEName This property would tell us the executable name that BPUTIL is bound to. Here is a link to the App property: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vb98/ht ml/vbobjApp.asp ----------- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060314/ef5fe5ea/attachment.htm From timr at probo.com Tue Mar 14 18:55:17 2006 From: timr at probo.com (Tim Roberts) Date: Tue, 14 Mar 2006 09:55:17 -0800 Subject: [python-win32] export registry keys In-Reply-To: References: Message-ID: <44170385.8040806@probo.com> On Tue, 14 Mar 2006 10:58:39 +0100, le dahut wrote: > Tim Roberts a ?crit : > >>> >>> If you're going to do it from Python, then you don't have to worry about >>> using the standard regedit format. There are a couple of registry class >>> wrappers for Python that turn a registry key into a Python object tree. >> >> > >mmhmm very interesting, could you tell me more about those classes ? > > One good example is in the ActiveState Python cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/174627 >>>>> Someone has an idea ? (otherwise I'll use "reg export" under XP and >>>>> regedit /E with 98 but it seems very barbarian isn't it ;-) ) >>> >>> >>> >>> Why is it barbarian? It's called "using the tools at your disposal". >> >> > >It opens a DOS prompt when the 'regedit' command is launched ... for a >wx app it looks not clean... maybe you know a way to hide this behavior ? > > Are you using os.system to launch regedit? os.system always creates a DOS shell to execute the command. But regedit is a Windows application; it doesn't need the shell. You should be able to use any of the dozens of other process-launch choices. os.execl would work, but the subprocess module is probably a better choice. Just this should work: subprocess.Popen('regedit /E xxxx') -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Tue Mar 14 23:21:08 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 15 Mar 2006 09:21:08 +1100 Subject: [python-win32] Reading a UInt32 array from LabVIEW In-Reply-To: <4336B5C3DC33A74FA393F4F88152F4EC5DA131@hiqqbexc001.sto.hiq.se> Message-ID: > From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On > Behalf Of Ola Rylow > I'm accessing LabVIEW through the ActiveX interface and I'm having a problem with reading a UInt32 array. Support for VT_UI4 safe-arrays was added in pywin32 build 207, so you should try that. Note however that build 208, soon to be released, fixes a bug that caused large unsigned numbers to be converted to negative Python integers - so you probably will also want to grab build 208 as soon as it released. Mark From emlynj at gmail.com Wed Mar 15 17:38:22 2006 From: emlynj at gmail.com (Emlyn Jones) Date: Wed, 15 Mar 2006 16:38:22 +0000 Subject: [python-win32] Pythoncom error Message-ID: Hello, I'm stress testing an application I have written using the Python Asp bindings, on occasions I get an ASP 0147 error (Internal Server Error), In the IIS logs it manifests itself as a c0000005 trapable error. Having attatched a debugger I noticed this in the resulting logs.... ..snip.. Wed Mar 15 16:21:38.754 2006 (GMT+0): pythoncom error: Wed Mar 15 16:21:38.754 2006 (GMT+0): Unexpected exception in gateway method 'SetScriptSite'Wed Mar 15 16:21:38.754 2006 (GMT+0): Wed Mar 15 16:21:38.754 2006 (GMT+0): Wed Mar 15 16:21:38.764 2006 (GMT+0): Traceback (most recent call last): Wed Mar 15 16:21:38.764 2006 (GMT+0): File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 332, in _InvokeEx_ return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 588, in _invokeex_ return func(*args) File "C:\Python24\Lib\site-packages\win32comext\axscript\client\framework.py", line 560, in SetScriptSite self.debugManager.Close() File "C:\Python24\Lib\site-packages\win32comext\axscript\client\debug.py", line 89, in Close self.adb.CloseApp() File "C:\Python24\Lib\site-packages\win32comext\axdebug\adb.py", line 262, in CloseApp self.appEventConnection.Disconnect() File "C:\Python24\Lib\site-packages\win32com\client\connect.py", line 41, in Disconnect self.cp.Unadvise(self.cookie) Wed Mar 15 16:21:38.774 2006 (GMT+0): pywintypes.com_errorWed Mar 15 16:21:38.774 2006 (GMT+0): : Wed Mar 15 16:21:38.774 2006 (GMT+0): (-2147220992, 'CONNECT_E_NOCONNECTION', None, None)Wed Mar 15 16:21:38.774 2006 (GMT+0): ..snip.. I have to be honest, this means very little to me. Has anyone seen this before? It tends to happen when CPU% is high (>75%) but it doesn't happend every time it goes high. Some pointers has to how to go about solving this problem (maybe I should start with pointers as to what it actually means :-)) would get greatfully recieved. Cheers, Emlyn. From timr at probo.com Wed Mar 15 19:32:39 2006 From: timr at probo.com (Tim Roberts) Date: Wed, 15 Mar 2006 10:32:39 -0800 Subject: [python-win32] VB Com object problem In-Reply-To: References: Message-ID: <44185DC7.6060303@probo.com> On Tue, 14 Mar 2006 07:47:35 -0800, "Gary Scorby" wrote: >I have a visual basic com object I am trying to use, so far >unsuccessfully. I am happily VB ignorant but will do my best to >describe the problem. > > > >>>>>>> import win32com.client >>>>>>> biff = win32com.client.Dispatch("OBName.Main") >>>>>>> biff.LoggedIn >>>> >>>> >0 > > >>>>>>> biff.TelLogin("Login", "Password", -1, App) >>>> >>>> > >The "TelLogin" method is where things blow up. I need to send the >following 4 required parameters- >1) Login ID >2) Password >3) A VB True, which they tell me is equivalent to -1 >4) The VB App keyword which is suppose to identify the calling >application, in this case Python. This is where things blow up. > > This is an absolutely dreadful design decision on their part. It basically ensures that this component is Visual Basic ONLY. The App keyword returns a COM object, which implements several interfaces, including one that has an EXEName property. In order for you to provide the equivalent, you would have to create a COM server that implements the same interfaces. In a few minutes of Google searching, I was not able to find out which interfaces the App object supports. Without that, you cannot possibly hope to satisfy this function. (Actually, since their code is written in VB and uses the "Object" type, you could write a COM object using IDispatch and provide just that one property, but it's almost certainly more trouble than just using VB code.) >Below is a description from the vendor about the App keyword and how it >is used. Looks very VB specific to me. I have been all over the web >trying to find an equivalent of what to send in Python. I have had no >luck. What in the name of Python, if anything, can I use in the 4th >parameter? I have successfully used other VB com objects with Python, >but never with an App requirement. > > No. It was a stupid thing to do. If they wanted the executable name, they should have had you pass it in as a string parameter. As it is, you are stuck. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From aurora00 at gmail.com Wed Mar 15 19:54:57 2006 From: aurora00 at gmail.com (aurora) Date: Wed, 15 Mar 2006 10:54:57 -0800 Subject: [python-win32] GetKeyboardState - API not covered? Message-ID: I have great success with Python win so far. It is truely a better tool to program Microsoft API than Microsoft themselves. Today I stumbled on some API that doesn't seem to be supported by pywin32, e.g. GetKeyboardState. I wonder if the goal of pywin32 is to have a comprenhensive interface to win32 API, or if the API are implemented on as needed basis. What would be the process to add API support in that case? Thanks you, wy P.S. What is the official name of this project? pywin32? Python for Windows Extensions? I'm a little confused. From rays at blue-cove.com Wed Mar 15 22:16:17 2006 From: rays at blue-cove.com (Ray Schumacher) Date: Wed, 15 Mar 2006 13:16:17 -0800 Subject: [python-win32] [Python-Dev] Still looking for volunteer to In-Reply-To: References: Message-ID: <6.2.5.2.2.20060315131347.052bfa80@blue-cove.com> I wrote a little ditty to set Win volume, which will also check for what you want (attached) On my system, just running it prints: C:\projects\sound>PYTHON VOL.PY cbStruct 24 dwControlID 1 cChannels 1 cMultipleItems 0 cbDetails 4 paDetails c_ulong(32639) waveOutGetNumDevs= 1 mixerGetNumDevs 1 res: 0 wMid= 131133 wPid= 821793 vDriverVersion= 1852729687 szPname= ov Videum Wave Playback 4? ? dwFormats= 2162690 wChannels= 4 res 0 l: 0 r: 0 Ray At 04:51 PM 3/13/2006, Roger Upole wrote: >Trent Mick wrote: >> Does anybody know of a way to programmatically check if a particular >> Windows box has a soundcard installed and configured? >> >> Background: >> I'm running a Windows buildbot for Python and the test suite fails on >> test_winsound.py because the box doesn't have a sound card setup. (The >> "Sound" Control Panel items says there are "No Playback Devices" for >> Sound Playback.) > >WMI can list sound devices. > >import win32com.client >wmi=win32com.client.GetObject('winmgmts:') >scs=wmi.InstancesOf('win32_sounddevice') >for sc in scs: > print sc.Properties_('Name'), sc.Properties_('Status') > > >You might also have to check one of the other properties >to make sure the device is actually operating, I don't >have a non-functional device to test with. > > Roger > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- #!/usr/bin/env python #Boa:PyApp:main modules = {} import ctypes mixerSetControlDetails = ( ctypes.windll.winmm.mixerSetControlDetails) mixerGetControlDetails = ( ctypes.windll.winmm.mixerGetControlDetailsA) # Some constants MIXER_OBJECTF_MIXER = 0 # mmsystem.h VOLUME_CONTROL_ID = 0 # Same on all machines? SPEAKER_LINE_FADER_ID = 1 # "Identifier in OID value does not resolve to a positive integer" MINIMUM_VOLUME = 0 # fader control (MSDN Library) MAXIMUM_VOLUME = 65535 # fader control (MSDN Library) class MIXERCONTROLDETAILS(ctypes.Structure): _pack_ = 1 _fields_ = [('cbStruct', ctypes.c_ulong), ('dwControlID', ctypes.c_ulong), ('cChannels', ctypes.c_ulong), ('cMultipleItems', ctypes.c_ulong), ('cbDetails', ctypes.c_ulong), ('paDetails', ctypes.POINTER(ctypes.c_ulong))] def setVolume(volume): """Set the speaker volume on the 'Volume Control' mixer""" if not (MINIMUM_VOLUME <= volume <= MAXIMUM_VOLUME): raise ValueError, "Volume out of range" cd = MIXERCONTROLDETAILS(ctypes.sizeof(MIXERCONTROLDETAILS), SPEAKER_LINE_FADER_ID, 1, 0, ctypes.sizeof(ctypes.c_ulong), ctypes.pointer(ctypes.c_ulong(volume))) ret = mixerSetControlDetails(VOLUME_CONTROL_ID, ctypes.byref(cd), MIXER_OBJECTF_MIXER) if ret != 0: print WindowsError, "Error %d while setting volume" % ret ret = mixerGetControlDetails(VOLUME_CONTROL_ID, ctypes.byref(cd), MIXER_OBJECTF_MIXER) if ret != 0: print WindowsError, "Error %d while setting volume" % ret else: print 'cbStruct', cd.cbStruct print 'dwControlID', cd.dwControlID print 'cChannels', cd.cChannels print 'cMultipleItems', cd.cMultipleItems print 'cbDetails', cd.cbDetails print 'paDetails', cd.paDetails.contents return setVolume((2**16-1)/2) from ctypes import * from struct import * winmm= windll.winmm print print 'waveOutGetNumDevs=',winmm.waveOutGetNumDevs() print 'mixerGetNumDevs', winmm.mixerGetNumDevs() wvcps= ' '*52 print 'res:', winmm.waveOutGetDevCapsA(0,wvcps,len(wvcps)) res = unpack('IIL32cLI', wvcps) wMid=res[0] wPid=res[1] vDriverVersion=res[2] szPname=''.join(res[3:35]) dwFormats=res[35] wChannels=res[36] print 'wMid=',wMid print 'wPid=',wPid print 'vDriverVersion=',vDriverVersion print 'szPname=',szPname print 'dwFormats=',dwFormats print 'wChannels=',wChannels vol=c_ulong() print 'res', winmm.waveOutGetVolume(0, byref(vol)) print 'l:', vol.value & 0xffff, 'r:',vol.value >> 16 # left, right From mhammond at skippinet.com.au Wed Mar 15 23:56:48 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 16 Mar 2006 09:56:48 +1100 Subject: [python-win32] GetKeyboardState - API not covered? In-Reply-To: Message-ID: > I wonder if the goal of pywin32 is to have a comprenhensive interface to > win32 API, or if the API are implemented on as needed basis. Both :) I do try and keep it comprehensive (eg, by implementing a complete family of functions when possible), but the reality is that many API functions are not covered, and these are indeed added by someone as they need them. There are a couple of regular contributors that help me out (most notably Roger Upole - thanks Roger!) > What would be the process to add API support in that case? It depends :) In this case I just added that function, as it was simple and a fairly glaring omission. That doesn't help you though until build 208 comes out, or unless you grab pywin32 from sources and build a copy yourself... ... and if you do that, then the process would simply be to add the support yourself, them mail me (or upload to sourceforge) the patch. Once I get sick of checking in stuff from you that is generally good, I just give you CVS checkin permissions and everyone is happy :) > P.S. What is the official name of this project? pywin32? Python for > Windows Extensions? I'm a little confused. And yet more ambiguity - both! :) pywin32 is the short name, where as the "Python for Windows extensions" is far more descriptive to people not intimately familiar with our little universe. Certainly pywin32 is much easier to type ;) Cheers, Mark From mhammond at skippinet.com.au Thu Mar 16 00:07:06 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 16 Mar 2006 10:07:06 +1100 Subject: [python-win32] Pythoncom error In-Reply-To: Message-ID: > Hello, > I'm stress testing an application I have written using the Python Asp > bindings, on occasions I get an ASP 0147 error (Internal Server > Error), In the IIS logs it manifests itself as a c0000005 trapable > error. That sounds like an Access Violation is happening - which probably is *not* directly related to the error below: > File "C:\Python24\Lib\site-packages\win32comext\axdebug\adb.py", > line 262, in CloseApp > self.appEventConnection.Disconnect() > File "C:\Python24\Lib\site-packages\win32com\client\connect.py", > line 41, in Disconnect > self.cp.Unadvise(self.cookie) This error is specific to the debugger support. It would be safe to change line 262 of abd.py from: self.cp.Unadvise(self.cookie) to: try: self.cp.Unadvise(self.cookie) except pythoncom.com_error: pass That *should* get you into the debugger OK - but it probably does not get you much closer to the original error. Another thing to try: * Change to win32comext\axscript\client * execute "pyscript.py --debug" * Start Pythonwin, and open the Tools -> Remote Collector Debugging Tool * Restart your app. You should see *lots* of stuff being spewed to Pythonwin as your app runs. When you app finally dies, the tail of this log might be interesting - eg, any tracebacks being displayed, or any evidence of death *inside* Python etc. Mark From emlynj at gmail.com Thu Mar 16 12:14:55 2006 From: emlynj at gmail.com (Emlyn Jones) Date: Thu, 16 Mar 2006 11:14:55 +0000 Subject: [python-win32] Pythoncom error In-Reply-To: References: Message-ID: On 3/15/06, Mark Hammond wrote: > > Hello, > > I'm stress testing an application I have written using the Python Asp > > bindings, on occasions I get an ASP 0147 error (Internal Server > > Error), In the IIS logs it manifests itself as a c0000005 trapable > > error. > > That sounds like an Access Violation is happening - which probably is *not* > directly related to the error below: > > > File "C:\Python24\Lib\site-packages\win32comext\axdebug\adb.py", > > line 262, in CloseApp > > self.appEventConnection.Disconnect() > > File "C:\Python24\Lib\site-packages\win32com\client\connect.py", > > line 41, in Disconnect > > self.cp.Unadvise(self.cookie) > > This error is specific to the debugger support. It would be safe to change > line 262 of abd.py from: > > self.cp.Unadvise(self.cookie) > to: > try: > self.cp.Unadvise(self.cookie) > except pythoncom.com_error: > pass > > That *should* get you into the debugger OK - but it probably does not get > you much closer to the original error. > > Another thing to try: > * Change to win32comext\axscript\client > * execute "pyscript.py --debug" > * Start Pythonwin, and open the Tools -> Remote Collector Debugging Tool > * Restart your app. > > You should see *lots* of stuff being spewed to Pythonwin as your app runs. > When you app finally dies, the tail of this log might be interesting - eg, > any tracebacks being displayed, or any evidence of death *inside* Python > etc. > > Mark > Hi Mark, thanks for the reply. Here's the thing; I took your advice and kept an eye out for errors related to the debugger support and fixed them when I found them (often with a just quick try except clause as you suggested, I'll revisit them when I get time), there where three locations where the debugger code raised exceptions. After making those changes my application has become significantly more stable. Is it possible that the debugger support code is running all the time, even when a debugger is not attached? (Or that I am missing something and "accidently" running a debugger, IIS is still a bit of a mystery to me). How can I be 100% sure that the debug stuff is disabled? As an example, One thing I have noticed is that I now get "WARNING:Ignoring Keyboard Interrupt from scripting engine" and everything continues as normal, I'm think that producing that warning used to cause a raised exception and kill my app. Does any of this sound feasible? I'm still getting the original access violation (but I am seeing proper debugger output) so there is an issue in my C extension code but the difference in stability is siginificant. Cheers, Emlyn. From mhammond at skippinet.com.au Thu Mar 16 13:05:23 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 16 Mar 2006 23:05:23 +1100 Subject: [python-win32] Pythoncom error In-Reply-To: Message-ID: > Here's the thing; I took your advice and kept an eye out for errors > related to the debugger support and fixed them when I found them > (often with a just quick try except clause as you suggested, I'll > revisit them when I get time), Please do, and feed the changes you made back to me (even if I change them before adopting them) > there where three locations where the > debugger code raised exceptions. After making those changes my > application has become significantly more stable. Is it possible that > the debugger support code is running all the time, even when a > debugger is not attached? Yes, that is correct. See SetScriptSite in win32comext\axscript\client\framework.py - this code enables debugging support quite early on, and before it is actually requested. This could almost certainly be optimized (although the overhead of that, assuming it works correctly, should be low.) As you should see from that code, allowing self.debugManager to remain None should gracefully work without debugging support. Renaming the win32comext\axdebug directory away should cause that :) > "WARNING:Ignoring Keyboard Interrupt from scripting engine" and > everything continues as normal, I'm think that producing that warning > used to cause a raised exception and kill my app. Does any of this > sound feasible? Sure does! Sadly that "Ignoring..." message is worming around a very old problem I have with IIS and the "random" triggering of Ctrl+C signals that so far remains unexpained :( On the positive side, since adding that work-around (a number of years ago now), people have reported their problems caused by the lack of the work around vanished (ie, that message should be benign) Cheers, Mark From mkatshym+pythonwin32 at gmail.com Thu Mar 16 15:32:20 2006 From: mkatshym+pythonwin32 at gmail.com (Michael Katz-Hyman) Date: Thu, 16 Mar 2006 09:32:20 -0500 Subject: [python-win32] problem w/ outlook scripting In-Reply-To: References: Message-ID: I have the below script to play around with contact lists in outlook. When it runs, I get a popup in outlook asking me if i want to gve the script access, I say yes, it seesm to run okay, but no new distribution list in my contact folder is created. I have very similar VBA code which runs just fine as a macro and creates the list, any ideas? Thanks! -Michael import win32com.client import sys, os myOlApp = win32com.client.Dispatch("Outlook.Application") myNameSpace = myOlApp.GetNamespace("MAPI") myDistList = myOlApp.CreateItem( win32com.client.constants.olDistributionListItem ) myTempItem = myOlApp.CreateItem(win32com.client.constants.olMailItem) myRecipients = myTempItem.Recipients myDistList.DLName = "Test" myRecipients.Add("(Test Name) ghe at stimd.org") myRecipients.ResolveAll myDistList.AddMembers(myRecipients) myTempItem2 = myOlApp.CreateItem(win32com.client.constants.olMailItem) myRecipients2 = myTempItem2.Recipients myRecipients2.Add ("(Mr. Vlarg) vlarg at poop.org") myRecipients2.ResolveAll myDistList.AddMembers(myRecipients2) myTempItem3 = myOlApp.CreateItem(win32com.client.constants.olMailItem ) myRecipients3 = myTempItem3.Recipients myRecipients3.Add("ghe at stimd.org") myRecipients3.ResolveAll myDistList.RemoveMembers(myRecipients3) myDistList.Save myDistList.Display -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060316/c02b02ee/attachment.htm From fumanchu at amor.org Thu Mar 16 21:26:21 2006 From: fumanchu at amor.org (Robert Brewer) Date: Thu, 16 Mar 2006 12:26:21 -0800 Subject: [python-win32] NT Service not re-startable after reboot Message-ID: <435DF58A933BA74397B42CDEB8145A86B8D966@ex9.hostedexchange.local> I have a Python service (vmpro_pager.py) which worked fine when I wrote it a month ago. You can see the complete source code here: http://projects.amor.org/misc/browser/vmpro_pager.py It runs an SMTP proxy to clean up SMTP messages from a sender which is not compliant with the SMTP spec. Today, we found out that the service was not running, and had not been running for some time; my best guess is since the first reboot after the service was installed. Attempts to remove the service via "vmpro_pager.py remove" failed, complaining that no such service was installed. After manually deleting the appropriate registry keys, I am able to run "vmpro_pager.py install" with no problems. However, starting the service from Windows Service Manager fails with the message, "Windows could not start the Voicemail Pro Email Fixup service on Local Computer. For more information, review the System Event Log. If this is a non-Microsoft service, contact the service vendor, and refer to service-specific error code 1." The Event Log contains a single Error event with the Description: "The Voicemail Pro Email Fixup service terminated with service-specific error 1." The PYS_SERVICE_STARTED message from SvcDoRun is *not* in the Event Log. Running the service via "vmpro_pager.py debug", however, works perfectly. Although I'm certainly open to answers of the type, "here's your problem..." ;) I'd like to also where I can insert hooks to return an error code more-meaningful than "1" in the future. Robert Brewer System Architect Amor Ministries fumanchu at amor.org From mhammond at skippinet.com.au Thu Mar 16 23:04:04 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 17 Mar 2006 09:04:04 +1100 Subject: [python-win32] problem w/ outlook scripting In-Reply-To: Message-ID: Try ensuring all methods have parens - eg: > myDistList.Save > myDistList.Display May not have any effect without the trailing () to indicate a method call. Mark From mhammond at skippinet.com.au Thu Mar 16 23:18:28 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 17 Mar 2006 09:18:28 +1100 Subject: [python-win32] NT Service not re-startable after reboot In-Reply-To: <435DF58A933BA74397B42CDEB8145A86B8D966@ex9.hostedexchange.local> Message-ID: I'm afraid I've no idea. The first thing to check is that username configured to use the service, and check that the service does not rely on any network shares or similar. Most service problems relate to this (eg, trying to run a service from a mapped drive as the LocalSystem account doomed to failure. After that, I'd suggest importing win32traceutil early in your program and trying to determine if you module is being entered at all. However, that seems unlikely - once the service framework gets to the point it tries to import your module, it should also be at the point where it can correctly log any Python errors caused by the import and write them to the event log. Good luck! Mark > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of Robert Brewer > Sent: Friday, 17 March 2006 7:26 AM > To: python-win32 at python.org > Subject: [python-win32] NT Service not re-startable after reboot > > > I have a Python service (vmpro_pager.py) which worked fine when I wrote > it a month ago. You can see the complete source code here: > http://projects.amor.org/misc/browser/vmpro_pager.py It runs an SMTP > proxy to clean up SMTP messages from a sender which is not compliant > with the SMTP spec. Today, we found out that the service was not > running, and had not been running for some time; my best guess is since > the first reboot after the service was installed. > > Attempts to remove the service via "vmpro_pager.py remove" failed, > complaining that no such service was installed. After manually deleting > the appropriate registry keys, I am able to run "vmpro_pager.py install" > with no problems. However, starting the service from Windows Service > Manager fails with the message, "Windows could not start the Voicemail > Pro Email Fixup service on Local Computer. For more information, review > the System Event Log. If this is a non-Microsoft service, contact the > service vendor, and refer to service-specific error code 1." The Event > Log contains a single Error event with the Description: "The Voicemail > Pro Email Fixup service terminated with service-specific error 1." The > PYS_SERVICE_STARTED message from SvcDoRun is *not* in the Event Log. > > Running the service via "vmpro_pager.py debug", however, works > perfectly. > > Although I'm certainly open to answers of the type, "here's your > problem..." ;) I'd like to also where I can insert hooks to return an > error code more-meaningful than "1" in the future. > > > Robert Brewer > System Architect > Amor Ministries > fumanchu at amor.org > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From fumanchu at amor.org Fri Mar 17 00:53:14 2006 From: fumanchu at amor.org (Robert Brewer) Date: Thu, 16 Mar 2006 15:53:14 -0800 Subject: [python-win32] NT Service not re-startable after reboot Message-ID: <435DF58A933BA74397B42CDEB8145A86B8DE03@ex9.hostedexchange.local> FWIW, here's the output from win32\test\testall.py (I don't know if I should assume that all should pass or not). This is on a Win2k Server with Python 2.4.2 and pywin32 build 207: C:\Python24\Lib\site-packages\win32\test>python testall.py ............................................................E.....EExcep tion in thread Thread-3: Traceback (most recent call last): File "C:\Python24\lib\threading.py", line 442, in __bootstrap self.run() File "C:\Python24\lib\threading.py", line 422, in run self.__target(*self.__args, **self.__kwargs) File "C:\Python24\Lib\site-packages\win32\test\test_win32pipe.py", line 13, in _workerThread data = win32pipe.CallNamedPipe(self.pipename,"foo\0bar", 1024, win32pipe.NMPWAIT_WAIT_FOREVER) error: (231, 'CallNamedPipe', 'All pipe instances are busy.') ...Trying: import win32timezone, datetime Expecting nothing ok Trying: assert 'Mountain Standard Time' in win32timezone.GetTimeZoneNames() Expecting nothing ok Trying: tzi = TimeZoneInfo( 'Mountain Standard Time' ) Expecting nothing ok Trying: now = datetime.datetime.now( tzi ) Expecting nothing ok Trying: now.utcoffset() in ( datetime.timedelta(-1, 61200), datetime.timedelta(-1, 64800) ) Expecting: True ok Trying: now = datetime.datetime.now( TimeZoneInfo( 'Mountain Standard Time', True ) ) Expecting nothing ok Trying: now.utcoffset() Expecting: datetime.timedelta(-1, 61200) ok Trying: aug2 = datetime.datetime( 2003, 8, 2, tzinfo = tzi ) Expecting nothing ok Trying: aug2.utctimetuple() Expecting: (2003, 8, 2, 6, 0, 0, 5, 214, 0) ok Trying: nov2 = datetime.datetime( 2003, 11, 2, tzinfo = tzi ) Expecting nothing ok Trying: nov2.utctimetuple() Expecting: (2003, 11, 2, 7, 0, 0, 6, 306, 0) ok Trying: aug2.isoformat() Expecting: '2003-08-02T00:00:00-06:00' ok Trying: aug2est = aug2.astimezone( win32timezone.TimeZoneInfo( 'Eastern Standard Time' ) ) Expecting nothing ok Trying: aug2est.isoformat() Expecting: '2003-08-02T02:00:00-04:00' ok Trying: est = win32timezone.TimeZoneInfo( 'Eastern Standard Time' ) Expecting nothing ok Trying: est.displayName Expecting: u'(GMT-05:00) Eastern Time (US & Canada)' ok Trying: gmt = win32timezone.TimeZoneInfo( 'GMT Standard Time', True ) Expecting nothing ok Trying: gmt.displayName Expecting: u'(GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London' ok Trying: import pickle Expecting nothing ok Trying: tz = win32timezone.TimeZoneInfo( 'China Standard Time' ) Expecting nothing ok Trying: tz == pickle.loads( pickle.dumps( tz ) ) Expecting: True ok Trying: localTZ = GetLocalTimeZone() Expecting nothing ok Trying: nowLoc = datetime.datetime.now( localTZ ) Expecting nothing ok Trying: nowUTC = datetime.datetime.utcnow( ) Expecting nothing ok Trying: ( nowUTC - nowLoc ) < datetime.timedelta( seconds = 5 ) Expecting: Traceback (most recent call last): ... TypeError: can't subtract offset-naive and offset-aware datetimes ok Trying: nowUTC = nowUTC.replace( tzinfo = TimeZoneInfo( 'GMT Standard Time', True ) ) Expecting nothing ok Trying: ( nowUTC - nowLoc ) < datetime.timedelta( seconds = 5 ) Expecting: True ok 25 items had no tests: win32timezone.GetIndexedTimeZoneNames win32timezone.GetSortedTimeZoneNames win32timezone.GetTimeZoneNames win32timezone.TimeZoneInfo win32timezone.TimeZoneInfo.GetDSTEndTime win32timezone.TimeZoneInfo.GetDSTStartTime win32timezone.TimeZoneInfo._FindTimeZoneKey win32timezone.TimeZoneInfo._LoadInfoFromKey win32timezone.TimeZoneInfo._LocateDay win32timezone.TimeZoneInfo.__cmp__ win32timezone.TimeZoneInfo.__getinitargs__ win32timezone.TimeZoneInfo.__init__ win32timezone.TimeZoneInfo.__repr__ win32timezone.TimeZoneInfo.__str__ win32timezone.TimeZoneInfo._getDaylightBias win32timezone.TimeZoneInfo._getStandardBias win32timezone.TimeZoneInfo.daylightBias win32timezone.TimeZoneInfo.dst win32timezone.TimeZoneInfo.standardBias win32timezone.TimeZoneInfo.tzname win32timezone.TimeZoneInfo.utcoffset win32timezone._RegEnumerator win32timezone._RegKeyDict win32timezone._RegKeyEnumerator win32timezone._RegValueEnumerator 2 items passed all tests: 21 tests in win32timezone 6 tests in win32timezone.GetLocalTimeZone 27 tests in 27 items. 27 passed and 0 failed. Test passed. ............... ====================================================================== ERROR: testFtpCommand (test_win32inet.TestNetwork) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32\test\test_win32inet.py", line 44, in testFtpCommand INTERNET_SERVICE_FTP, 0, 0) error: (12029, 'InternetConnect', 'A connection with the server could not be established') ====================================================================== ERROR: testCallNamedPipe (test_win32pipe.CurrentUserTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32\test\test_win32pipe.py", line 37, in testCallNamedPipe win32file.WriteFile(pipeHandle, "bar\0foo") error: (109, 'WriteFile', 'The pipe has been ended.') ---------------------------------------------------------------------- Ran 85 tests in 9.719s FAILED (errors=2) This would be nice to fix, but it's not the end of the world. If I can't get it working here, I'll just move it to a Linux box and go on my merry way... ;) Robert Brewer System Architect Amor Ministries fumanchu at amor.org > -----Original Message----- > From: Mark Hammond [mailto:mhammond at skippinet.com.au] > Sent: Thursday, March 16, 2006 2:18 PM > To: Robert Brewer; python-win32 at python.org > Subject: RE: [python-win32] NT Service not re-startable after reboot > > I'm afraid I've no idea. The first thing to check is that username > configured to use the service, and check that the service > does not rely on > any network shares or similar. Most service problems relate > to this (eg, > trying to run a service from a mapped drive as the LocalSystem account > doomed to failure. > > After that, I'd suggest importing win32traceutil early in > your program and > trying to determine if you module is being entered at all. > However, that > seems unlikely - once the service framework gets to the point > it tries to > import your module, it should also be at the point where it > can correctly > log any Python errors caused by the import and write them to > the event log. > > Good luck! > > Mark > > > -----Original Message----- > > From: python-win32-bounces at python.org > > [mailto:python-win32-bounces at python.org]On Behalf Of Robert Brewer > > Sent: Friday, 17 March 2006 7:26 AM > > To: python-win32 at python.org > > Subject: [python-win32] NT Service not re-startable after reboot > > > > > > I have a Python service (vmpro_pager.py) which worked fine > when I wrote > > it a month ago. You can see the complete source code here: > > http://projects.amor.org/misc/browser/vmpro_pager.py It runs an SMTP > > proxy to clean up SMTP messages from a sender which is not compliant > > with the SMTP spec. Today, we found out that the service was not > > running, and had not been running for some time; my best > guess is since > > the first reboot after the service was installed. > > > > Attempts to remove the service via "vmpro_pager.py remove" failed, > > complaining that no such service was installed. After > manually deleting > > the appropriate registry keys, I am able to run > "vmpro_pager.py install" > > with no problems. However, starting the service from Windows Service > > Manager fails with the message, "Windows could not start > the Voicemail > > Pro Email Fixup service on Local Computer. For more > information, review > > the System Event Log. If this is a non-Microsoft service, > contact the > > service vendor, and refer to service-specific error code > 1." The Event > > Log contains a single Error event with the Description: > "The Voicemail > > Pro Email Fixup service terminated with service-specific > error 1." The > > PYS_SERVICE_STARTED message from SvcDoRun is *not* in the Event Log. > > > > Running the service via "vmpro_pager.py debug", however, works > > perfectly. > > > > Although I'm certainly open to answers of the type, "here's your > > problem..." ;) I'd like to also where I can insert hooks to > return an > > error code more-meaningful than "1" in the future. > > > > > > Robert Brewer > > System Architect > > Amor Ministries > > fumanchu at amor.org > > > > _______________________________________________ > > Python-win32 mailing list > > Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > From sumeet_sobti at yahoo.com Sat Mar 18 00:26:41 2006 From: sumeet_sobti at yahoo.com (Sumeet Sobti) Date: Fri, 17 Mar 2006 15:26:41 -0800 (PST) Subject: [python-win32] Strange message pump behavior In-Reply-To: Message-ID: <20060317232641.62922.qmail@web60715.mail.yahoo.com> Hi, I have a very simple, single-threaded COM client program. I use COM objects created by a third-party software. I use win32com to do all COM-related processing in my program. In my program, I create a few COM objects, some of which are supposed to periodically receive events. So, I have a message loop in my program that uses pythoncom.PumpWaitingMessages() to pump messages, so the events get fired whenever they arrive (usually every 1-3 seconds). I am not using any GUI, Tk, or anything. It's a stand-alone command-line program. However, in one particular case, I see some strange behavior where the message pump stops receiving any events for several minutes (sometimes tens of minutes). I have reduced the problem case to the following sequence of steps (the problem is illustrated in the last step): ## begin ## 1 create_com_objects() pump_messages_for_10_seconds() ## here events are received as expected ## 2 time.sleep(10) pump_messages_for_10_seconds() ## here events are received as expected ## 3 time.sleep(10) pump_messages_for_10_seconds() ## here events are received as expected ## 4 a_com_object.a_method() pump_messages_for_10_seconds() ## here events are received as expected ## 5 a_com_object.a_method() pump_messages_for_10_seconds() ## here events are received as expected ## 6 -- PROBLEM CASE time.sleep(10) a_com_object.a_method() pump_messages_for_1000_seconds() ## PROBLEM: NO EVENTS RECEIVED HERE ## end The above behavior seems to be very repeatable. (1) When my program sleeps or does something other than pumping messages, aren't messages/events supposed to get queued somewhere? So, when my program gets back to pumping, shouldn't it be able to pump the events that arrived while it was sleeping or doing other stuff? (2) The problem seems to be triggered when I invoke one particular method on one particular object in one particular way *immediately* after waking up from sleep (like in step 6 above). However, the problem doesn't occur in steps 4 and 5 where I invoke the same method in the exact same way as I do in step 6. (Steps 2,3,4,5 can be rearranged, deleted, executed multiple times, etc. without affecting the appearance of the problem in the last step.) Any ideas what could be causing this behavior? Is it at all possible that an incorrect implementation of the COM object is messing up with the messages/events in my client program? I'd really appreciate any help/ideas. Thanks! -Sumeet. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From me at phillatwood.name Sun Mar 19 00:33:34 2006 From: me at phillatwood.name (Phill Atwood) Date: Sat, 18 Mar 2006 18:33:34 -0500 Subject: [python-win32] os.system(cmd) In-Reply-To: <44161BA9.3050504@probo.com> References: <4415F45E.6030406@probo.com> <4415FA95.9040309@phillatwood.name> <4415FE2B.3020600@probo.com> <4416061F.80904@phillatwood.name> <44160DD0.7090605@probo.com> <441618A0.6010107@phillatwood.name> <44161BA9.3050504@probo.com> Message-ID: <441C98CE.1020905@phillatwood.name> I am using os.system(cmd) to call a DOS program on WinXP that I need to call. It works fine but it flashes a Command Prompt Window while it does it. Is there any way to suppress this? From shane.holloway at ieee.org Sun Mar 19 01:46:00 2006 From: shane.holloway at ieee.org (Shane Holloway (IEEE)) Date: Sat, 18 Mar 2006 17:46:00 -0700 Subject: [python-win32] os.system(cmd) In-Reply-To: <441C98CE.1020905@phillatwood.name> References: <4415F45E.6030406@probo.com> <4415FA95.9040309@phillatwood.name> <4415FE2B.3020600@probo.com> <4416061F.80904@phillatwood.name> <44160DD0.7090605@probo.com> <441618A0.6010107@phillatwood.name> <44161BA9.3050504@probo.com> <441C98CE.1020905@phillatwood.name> Message-ID: I'd suggest looking at the subprocess module if you are using python 2.4, or one of the many os.popen variants for prior versions. On Mar 18, 2006, at 16:33, Phill Atwood wrote: > > I am using os.system(cmd) to call a DOS program on WinXP that I > need to > call. It works fine but it flashes a Command Prompt Window while it > does it. Is there any way to suppress this? > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From me at phillatwood.name Sun Mar 19 02:38:22 2006 From: me at phillatwood.name (Phill Atwood) Date: Sat, 18 Mar 2006 20:38:22 -0500 Subject: [python-win32] os.system(cmd) In-Reply-To: References: <4415F45E.6030406@probo.com> <4415FA95.9040309@phillatwood.name> <4415FE2B.3020600@probo.com> <4416061F.80904@phillatwood.name> <44160DD0.7090605@probo.com> <441618A0.6010107@phillatwood.name> <44161BA9.3050504@probo.com> <441C98CE.1020905@phillatwood.name> Message-ID: <441CB60E.5080609@phillatwood.name> Thanks, using subprocess.call(cmd, shell=True) worked for me without flashing anything. Phill Shane Holloway (IEEE) wrote: > I'd suggest looking at the subprocess module if you are using python > 2.4, or one of the many os.popen variants for prior versions. > > > On Mar 18, 2006, at 16:33, Phill Atwood wrote: > >> >> I am using os.system(cmd) to call a DOS program on WinXP that I need to >> call. It works fine but it flashes a Command Prompt Window while it >> does it. Is there any way to suppress this? >> >> _______________________________________________ >> Python-win32 mailing list >> Python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Mon Mar 20 05:58:31 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 20 Mar 2006 15:58:31 +1100 Subject: [python-win32] pywin32 build 208 Message-ID: Hi all, I have just released build 208 of the pywin32 extensions. Change log and release notes: https://sourceforge.net/project/shownotes.php?release_id=403008 Download via: https://sourceforge.net/project/showfiles.php?group_id=78018 Please log any issues via the SourceForge bug collector: https://sourceforge.net/tracker/?group_id=78018&atid=551954 Regards, Mark. From mc at mclaveau.com Mon Mar 20 06:26:18 2006 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 20 Mar 2006 06:26:18 +0100 Subject: [python-win32] pywin32 build 208 References: Message-ID: <000401c64bde$d483d3f0$0701a8c0@PORTABLES> Downloaded, installed, OK. Then, => on my "Dist." CD Thank you very much. @-salutations -- Michel Claveau From david128 at receptec.net Mon Mar 20 15:42:24 2006 From: david128 at receptec.net (David S.) Date: Mon, 20 Mar 2006 09:42:24 -0500 Subject: [python-win32] win32process open-terminate loop cripples OS Message-ID: <441EBF50.8030001@receptec.net> Hello, I decided to attempt to use python's win32 extensions as a method to monitor and control process for my python application. It's working well in the short term, but, as this app is intended to be very low-maintenance, and probably high-uptimes without restarting, I want to put it to the test. I set a loop similar to below to run every second for the weekend. It wasn't very pretty. I didn't get any process information (couldn't - system was /almost/ unresponsive) - the most i could do was alt-tab around, though it wouldn't paint the window, move the mouse pointer and turn the num lock light on and off. Can anyone provide some guidance or perhaps point out a problem in my code? For what it's worth, I think I can poll process /ad infinitum/ without any lockups. Thank you, -David S. --------------------------------------------------------------------------- def weekendprocesstest(): print 1 Processes.StartProcess("notepad") print 2 Processes.KillName("notepad") print 3 ---and the functions.... def StartProcess(self, RunCmd): #not going to bother with win32 for this #output=os.System(RunCmd).read() StartupInfo = win32process.STARTUPINFO() win32process.CreateProcess( None, # program RunCmd, # command line None, # process security attributes None, # thread attributes 1, # inherit handles, or USESTDHANDLES won't work. # creation flags. Don't access the console. 0, # Don't need anything here. # If you're in a GUI app, you should use # CREATE_NEW_CONSOLE here, or any subprocesses # might fall victim to the problem described in: # KB article: Q156755, cmd.exe requires # an NT console in order to perform redirection.. None, # new environment None, # new directory StartupInfo) self.ProcessTableRefresh() def KillName(self, matchstring): #get PIDS that have the supplied substring self.ProcessTableRefresh() ProcessList=self.GetProcessList() for process in ProcessList: if process[2].lower().find(matchstring.lower())!=-1: win32process.TerminateProcess(process[0],0) self.ProcessTableRefresh() def ProcessTableRefresh(self): processes = win32process.EnumProcesses() pnamepidlist=list() for pid in processes: try: handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS,False, pid) exe = win32process.GetModuleFileNameEx(handle, 0) pnamepidlist.append((handle, pid, exe)) except: pass self.lProcessTable.acquire() self.ProcessList=pnamepidlist self.ProcessTableAge=0 self.lProcessTable.release() From Tom_RobbinsMilne at swissre.com Mon Mar 20 16:32:40 2006 From: Tom_RobbinsMilne at swissre.com (Tom_RobbinsMilne at swissre.com) Date: Mon, 20 Mar 2006 10:32:40 -0500 Subject: [python-win32] win32process open-terminate loop cripples OS In-Reply-To: <441EBF50.8030001@receptec.net> Message-ID: David, Maybe I'm missing something, but doesn't XP take awhile to launch and kill Notepad? Does it work a bit better if you launch a process every 10 seconds? Thanks, Tom "David S." Sent by: python-win32-bounces at python.org 03/20/2006 09:42 AM To python-win32 at python.org cc Subject [python-win32] win32process open-terminate loop cripples OS Hello, I decided to attempt to use python's win32 extensions as a method to monitor and control process for my python application. It's working well in the short term, but, as this app is intended to be very low-maintenance, and probably high-uptimes without restarting, I want to put it to the test. I set a loop similar to below to run every second for the weekend. It wasn't very pretty. I didn't get any process information (couldn't - system was /almost/ unresponsive) - the most i could do was alt-tab around, though it wouldn't paint the window, move the mouse pointer and turn the num lock light on and off. Can anyone provide some guidance or perhaps point out a problem in my code? For what it's worth, I think I can poll process /ad infinitum/ without any lockups. Thank you, -David S. --------------------------------------------------------------------------- def weekendprocesstest(): print 1 Processes.StartProcess("notepad") print 2 Processes.KillName("notepad") print 3 ---and the functions.... def StartProcess(self, RunCmd): #not going to bother with win32 for this #output=os.System(RunCmd).read() StartupInfo = win32process.STARTUPINFO() win32process.CreateProcess( None, # program RunCmd, # command line None, # process security attributes None, # thread attributes 1, # inherit handles, or USESTDHANDLES won't work. # creation flags. Don't access the console. 0, # Don't need anything here. # If you're in a GUI app, you should use # CREATE_NEW_CONSOLE here, or any subprocesses # might fall victim to the problem described in: # KB article: Q156755, cmd.exe requires # an NT console in order to perform redirection.. None, # new environment None, # new directory StartupInfo) self.ProcessTableRefresh() def KillName(self, matchstring): #get PIDS that have the supplied substring self.ProcessTableRefresh() ProcessList=self.GetProcessList() for process in ProcessList: if process[2].lower().find(matchstring.lower())!=-1: win32process.TerminateProcess(process[0],0) self.ProcessTableRefresh() def ProcessTableRefresh(self): processes = win32process.EnumProcesses() pnamepidlist=list() for pid in processes: try: handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS,False, pid) exe = win32process.GetModuleFileNameEx(handle, 0) pnamepidlist.append((handle, pid, exe)) except: pass self.lProcessTable.acquire() self.ProcessList=pnamepidlist self.ProcessTableAge=0 self.lProcessTable.release() _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060320/a38e69f9/attachment.htm From mkatshym+pythonwin32 at gmail.com Mon Mar 20 17:22:36 2006 From: mkatshym+pythonwin32 at gmail.com (Michael Katz-Hyman) Date: Mon, 20 Mar 2006 11:22:36 -0500 Subject: [python-win32] com_error: Object is not connected to server Message-ID: I get the following error when trying to thread an object that uses a COM connection to outlook. I tried re-Dispatching the object before accessing it again but to now avail, ideas? error: Exception in thread Thread-4: Traceback (most recent call last): File "C:\Python24\lib\threading.py", line 444, in __bootstrap self.run() File "c:\documents and settings\mkatzhyman\my documents\email\MainPanel.py", line 19, in run foundEmails = self.oc.findEmail(self.email) File "c:\documents and settings\mkatzhyman\my documents\email\OutlookConnection.py", line 51, in findEmail dlistCount = dlist.MemberCount File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 496, in __getattr__ if d is not None: return getattr(d, attr) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 455, in __getattr__ return self._ApplyTypes_(*args) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_( com_error: (-2147220995, 'Object is not connected to server', None, None) function that is callled: def findEmail(self,em): # call with the email, or name ## Re-connect to server pythoncom.CoInitialize() self.myOlApp = win32com.client.dynamic.Dispatch("Outlook.Application ") self.myOlApp.Session.Logon() self.myNameSpace = self.myOlApp.GetNamespace("MAPI") founddlists = [] dlist = self.myOlApp.CreateItem( win32com.client.constants.olDistributionListItem) for dl in self.ListOfDLs.keys(): dlist = self.ListOfDLs[dl] dlistCount = dlist.MemberCount #print dlistCount for a in range(1,dlistCount+1): tmpRecip = dlist.GetMember(a) name = tmpRecip.Name address = tmpRecip.Address if (name.find(em)>=0) or (address.find(em)>=0): rdl = [name,address,dl] founddlists.append(rdl) return founddlists -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060320/965805b2/attachment.html From mark.m.mcmahon at gmail.com Mon Mar 20 22:19:39 2006 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Mon, 20 Mar 2006 22:19:39 +0100 Subject: [python-win32] ANN: pywinauto 0.3.0 released - now localization proof Message-ID: <71b6302c0603201319o74fca6dbxf887044078b3b464@mail.gmail.com> Hi, The 0.3.0 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.2.5: 0.3.0 Added Application data - now useful for localization testing ------------------------------------------------------------------ 20-Mar-2006 * Added automatic Application data collection which can be used when running the same test on a different spoken language version. Support is still preliminary and is expected to change. Please treat as early Alpha. If you have a different language version of Windows then you can try this out by running the notepad_fast.py example with the langauge argument e.g. :: examples\notepad_fast.py language This will load the application data from the supplied file notepad_fast.pkl and use it for finding the right menu items and controls to select. * Test implementation to make it easier to start using an application. Previously you needed to write code like :: app = Application().connect_(title = 'Find') app.Find.Close.Click() app.NotePad.MenuSelect("File->Exit") 1st change was to implement static methods ``start()`` and ``connect()``. These methods return a new Application instance so the above code becomes:: app = Application.connect(title = 'Find') app.Find.Close.Click() app.NotePad.MenuSelect("File->Exit") I also wanted to make it easier to start working with a simple application - that may or may not have only one dialog. To make this situation easier I made ``window_()`` not throw if the application has not been ``start()ed`` or ``connect()ed`` first. This leads to simpler code like:: app = Application() app.Find.Close.Click() app.NotePad.MenuSelect("File->Exit") What happens here is that when you execute any of Application.window_(), Application.__getattr__() or Application.__getitem__() when the application hasn't been connected or started. It looks for the window that best matches your specification and connects the application to that process. This is extra functionality - existing connect_() and start_() methods still exist * Fixed HwndWrapper.SetFocus() so that it would work even if the window was not in the foreground. (it now makes the window foreground as well as giving it focus). This overcomes a restriction in Windows where you can only change the foreground window if you own the foreground window. * Changed some 2.4'isms that an anonymous commenter left on my blog :-) with these changes pywinauto should run on Python 2.3 (though I haven't done extensive testing). * Commented out controls.common_controls.TabControlWrapper.GetTabState() and TabStates() as these did not seem to be returning valid values anyway. * Fixed documentation issues were parts of the documentation were not getting generated to the HTML files. * Fixed issue where MenuSelect would sometimes not work as expected. Some Menu actions require that the window that owns the menu be active. Added a call to SetFocus() before selecting a menu item to ensure that the window was active. * Fixed Bug 1452832 where clipboard was not closed in clipboard.GetData() * Added more unit tests now up to 248 from 207 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 From mark.m.mcmahon at gmail.com Mon Mar 20 22:23:56 2006 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Mon, 20 Mar 2006 22:23:56 +0100 Subject: [python-win32] ANN: pywinauto 0.3.0 released - now localization proof Message-ID: <71b6302c0603201323v5db5309ci77b542a901020c59@mail.gmail.com> Hi, The 0.3.0 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.2.5: 0.3.0 Added Application data - now useful for localization testing ------------------------------------------------------------------ 20-Mar-2006 * Added automatic Application data collection which can be used when running the same test on a different spoken language version. Support is still preliminary and is expected to change. Please treat as early Alpha. If you have a different language version of Windows then you can try this out by running the notepad_fast.py example with the langauge argument e.g. :: examples\notepad_fast.py language This will load the application data from the supplied file notepad_fast.pkl and use it for finding the right menu items and controls to select. * Test implementation to make it easier to start using an application. Previously you needed to write code like :: app = Application().connect_(title = 'Find') app.Find.Close.Click() app.NotePad.MenuSelect("File->Exit") 1st change was to implement static methods ``start()`` and ``connect()``. These methods return a new Application instance so the above code becomes:: app = Application.connect(title = 'Find') app.Find.Close.Click() app.NotePad.MenuSelect("File->Exit") I also wanted to make it easier to start working with a simple application - that may or may not have only one dialog. To make this situation easier I made ``window_()`` not throw if the application has not been ``start()ed`` or ``connect()ed`` first. This leads to simpler code like:: app = Application() app.Find.Close.Click() app.NotePad.MenuSelect("File->Exit") What happens here is that when you execute any of Application.window_(), Application.__getattr__() or Application.__getitem__() when the application hasn't been connected or started. It looks for the window that best matches your specification and connects the application to that process. This is extra functionality - existing connect_() and start_() methods still exist * Fixed HwndWrapper.SetFocus() so that it would work even if the window was not in the foreground. (it now makes the window foreground as well as giving it focus). This overcomes a restriction in Windows where you can only change the foreground window if you own the foreground window. * Changed some 2.4'isms that an anonymous commenter left on my blog :-) with these changes pywinauto should run on Python 2.3 (though I haven't done extensive testing). * Commented out controls.common_controls.TabControlWrapper.GetTabState() and TabStates() as these did not seem to be returning valid values anyway. * Fixed documentation issues were parts of the documentation were not getting generated to the HTML files. * Fixed issue where MenuSelect would sometimes not work as expected. Some Menu actions require that the window that owns the menu be active. Added a call to SetFocus() before selecting a menu item to ensure that the window was active. * Fixed Bug 1452832 where clipboard was not closed in clipboard.GetData() * Added more unit tests now up to 248 from 207 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 From mli at deform.com Tue Mar 21 18:33:29 2006 From: mli at deform.com (Michael Li) Date: Tue, 21 Mar 2006 12:33:29 -0500 Subject: [python-win32] how to know the native file path of computer A on computer B In-Reply-To: <4411BCCE.9090003@probo.com> References: <4411BCCE.9090003@probo.com> Message-ID: <442038E9.8050201@deform.com> Hi, all I want to run a command remotely, but I have to know the native file path on the remote computer from client computer. Here is the details: ------------------------------ --------------------------- | | | | | computer A | | computer B | | | | | | C:\shared\database\test.DB | | W:\database\test.DB | | | | | | python server | | client | | | | | | | | | ----------------------------- --------------------------- /|\ /|\ | | |-----------------------------| From computer B, I send a command to computer A. On computer A, python.exe is running 24X7 as a service. When the pyhton server receives the command, it will go into folder C:\shared\database and lunch another program. Now I have to input native path on computer B, and pass the native file path as an argument with the command and send together to computer A. Then the python server knows where to go. I am wondering that is it possible to know the native file path of computer A on computer B ? If possible, is there anyone point me a direction how to do it? This may not be a python question, anyway I asked here, any C/C++/C# programs are ok. Thank you very much. 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 me at phillatwood.name Tue Mar 21 19:03:47 2006 From: me at phillatwood.name (Phill Atwood) Date: Tue, 21 Mar 2006 13:03:47 -0500 Subject: [python-win32] wxpython wxGrid Message-ID: <44204003.9050906@phillatwood.name> wxWidgets Question regarding grids. There seems to be a display problem. If you scroll horizontally or vertically eventually you get to the end of the row or col. At this point you seem to always be able to scroll a little bit further revealing just some empty space. All the examples in the wxWidgets demo seem to do this too. Is this a bug? Is there a way to avoid it? I saw a reference to wxSheet which seems to be someone's improvement on some shortcomings with wxGrid. Has anyone tried that? Phill From Tom_RobbinsMilne at swissre.com Tue Mar 21 19:37:37 2006 From: Tom_RobbinsMilne at swissre.com (Tom_RobbinsMilne at swissre.com) Date: Tue, 21 Mar 2006 13:37:37 -0500 Subject: [python-win32] how to know the native file path of computer A on computer B In-Reply-To: <442038E9.8050201@deform.com> Message-ID: Michael, If you just need to deal with the path to the executable, perhaps os.path.normpath() is what you're looking for. Regards, Tom Michael Li Sent by: python-win32-bounces+tom_robbinsmilne=swissre.com at python.org 03/21/2006 12:33 PM To python-win32 at python.org cc Subject [python-win32] how to know the native file path of computer A on computer B Hi, all I want to run a command remotely, but I have to know the native file path on the remote computer from client computer. Here is the details: ------------------------------ --------------------------- | | | | | computer A | | computer B | | | | | | C:\shared\database\test.DB | | W:\database\test.DB | | | | | | python server | | client | | | | | | | | | ----------------------------- --------------------------- /|\ /|\ | | |-----------------------------| From computer B, I send a command to computer A. On computer A, python.exe is running 24X7 as a service. When the pyhton server receives the command, it will go into folder C:\shared\database and lunch another program. Now I have to input native path on computer B, and pass the native file path as an argument with the command and send together to computer A. Then the python server knows where to go. I am wondering that is it possible to know the native file path of computer A on computer B ? If possible, is there anyone point me a direction how to do it? This may not be a python question, anyway I asked here, any C/C++/C# programs are ok. Thank you very much. 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. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060321/3d89ee62/attachment.html From mli at deform.com Tue Mar 21 21:28:46 2006 From: mli at deform.com (Michael Li) Date: Tue, 21 Mar 2006 15:28:46 -0500 Subject: [python-win32] how to know the native file path of computer A on computer B In-Reply-To: <442038E9.8050201@deform.com> References: <4411BCCE.9090003@probo.com> <442038E9.8050201@deform.com> Message-ID: <442061FE.1070407@deform.com> Hi, I got bunch of reply, thank you very much. But they are not what i want. Let me make it more clear, my code looks like: nRetCode = os.access(szFolder, os.F_OK) if nRetCode == 1: nRetCode = os.chdir(szFolder) szNormPath = os.path.normpath(szCommand) szBatchFile = szNormPath anArgs = [szBatchFile, 'NDEBUG'] nRetCode = os.spawnv(os.P_NOWAIT, szBatchFile, anArgs) The above code is on the computer A where python server is running. The szFolder must be "C:\shared\database", not "W:\database", because "W:" does not exist on computer A, "W:" is on computer B. Right now, szFolder comes from computer B as an argument inputed on computer B, I want to make szFolder auto-decide if possible. Any ideas ? Best regards. Michael Li Michael Li wrote: > Hi, all > > I want to run a command remotely, but I have to know > the native file path on the remote computer from client > computer. Here is the details: > > ------------------------------ --------------------------- > | | | | > | computer A | | computer B | > | | | | > | C:\shared\database\test.DB | | W:\database\test.DB | > | | | | > | python server | | client | > | | | | > | | | | > ----------------------------- --------------------------- > /|\ /|\ > | | > |-----------------------------| > > From computer B, I send a command to computer A. > On computer A, python.exe is running 24X7 as a service. > When the pyhton server receives the command, it will go into > folder C:\shared\database and lunch another program. > Now I have to input native path on computer B, and pass > the native file path as an argument with the command and send together > to computer A. Then the python server knows where to go. > I am wondering that is it possible to know the native file path of > computer A on computer B ? > If possible, is there anyone point me a direction how to do it? > This may not be a python question, anyway I asked here, any C/C++/C# > programs are ok. > Thank you very much. > > 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. > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 ========== 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 mli at deform.com Tue Mar 21 22:31:28 2006 From: mli at deform.com (Michael Li) Date: Tue, 21 Mar 2006 16:31:28 -0500 Subject: [python-win32] how to know the native file path of computer A on computer B In-Reply-To: <442061FE.1070407@deform.com> References: <4411BCCE.9090003@probo.com> <442038E9.8050201@deform.com> <442061FE.1070407@deform.com> Message-ID: <442070B0.9000306@deform.com> I forgot to mention that: W: on computer B is a mapped network drive, which is C:\shared on computer A. So W:\database\test.DB on computer B and C:\shared\database\test.DB on computer A are pointed to the same file. From computer B, I only know the file path is W:\database, when the program actually runs on computer A, I need to know the real file path C:\shared\database on computer A. The folder itself is not the fixed, it might be D:\aaa, also the mapped drive path is not fixed, it might be X:\bbb. Michael Li wrote: > Hi, > I got bunch of reply, thank you very much. > But they are not what i want. > Let me make it more clear, my code looks like: > > nRetCode = os.access(szFolder, os.F_OK) > if nRetCode == 1: > nRetCode = os.chdir(szFolder) > szNormPath = os.path.normpath(szCommand) > szBatchFile = szNormPath > anArgs = [szBatchFile, 'NDEBUG'] > nRetCode = os.spawnv(os.P_NOWAIT, szBatchFile, anArgs) > > The above code is on the computer A where python server > is running. The szFolder must be "C:\shared\database", not > "W:\database", because "W:" does not exist on computer A, > "W:" is on computer B. > > Right now, szFolder comes from computer B as an argument inputed > on computer B, I want to make szFolder auto-decide if possible. > Any ideas ? > > Best regards. > Michael Li > > > Michael Li wrote: > >> Hi, all >> >> I want to run a command remotely, but I have to know >> the native file path on the remote computer from client >> computer. Here is the details: >> >> ------------------------------ --------------------------- >> | | | | >> | computer A | | computer B | >> | | | | >> | C:\shared\database\test.DB | | W:\database\test.DB | >> | | | | >> | python server | | client | >> | | | | >> | | | | >> ----------------------------- --------------------------- >> /|\ /|\ >> | | >> |-----------------------------| >> >> From computer B, I send a command to computer A. >> On computer A, python.exe is running 24X7 as a service. >> When the pyhton server receives the command, it will go into >> folder C:\shared\database and lunch another program. >> Now I have to input native path on computer B, and pass >> the native file path as an argument with the command and send together >> to computer A. Then the python server knows where to go. >> I am wondering that is it possible to know the native file path of >> computer A on computer B ? >> If possible, is there anyone point me a direction how to do it? >> This may not be a python question, anyway I asked here, any C/C++/C# >> programs are ok. >> Thank you very much. >> >> 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. >> >> _______________________________________________ >> Python-win32 mailing list >> Python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 > > > ========== 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 rwupole at msn.com Wed Mar 22 02:08:07 2006 From: rwupole at msn.com (Roger Upole) Date: Tue, 21 Mar 2006 20:08:07 -0500 Subject: [python-win32] Re: how to know the native file path of computer A Message-ID: Michael Li wrote: > Hi, > I got bunch of reply, thank you very much. > But they are not what i want. > Let me make it more clear, my code looks like: > > nRetCode = os.access(szFolder, os.F_OK) > if nRetCode == 1: > nRetCode = os.chdir(szFolder) > szNormPath = os.path.normpath(szCommand) > szBatchFile = szNormPath > anArgs = [szBatchFile, 'NDEBUG'] > nRetCode = os.spawnv(os.P_NOWAIT, szBatchFile, anArgs) > > The above code is on the computer A where python server > is running. The szFolder must be "C:\shared\database", not > "W:\database", because "W:" does not exist on computer A, > "W:" is on computer B. > > Right now, szFolder comes from computer B as an argument inputed > on computer B, I want to make szFolder auto-decide if possible. > Any ideas ? > You can use win32net.NetUseGetInfo to find what network share your local drive is mapped to, and then win32net.NetShareGetInfo to get the local path on the remote machine. Roger From rwupole at msn.com Wed Mar 22 02:24:36 2006 From: rwupole at msn.com (Roger Upole) Date: Tue, 21 Mar 2006 20:24:36 -0500 Subject: [python-win32] Re: win32process open-terminate loop cripples OS Message-ID: David S wrote: > Hello, > > I decided to attempt to use python's win32 extensions as a method to > monitor and control process for my python application. It's working > well in the short term, but, as this app is intended to be very > low-maintenance, and probably high-uptimes without restarting, I want to > put it to the test. I set a loop similar to below to run every second > for the weekend. It wasn't very pretty. I didn't get any process > information (couldn't - system was /almost/ unresponsive) - the most i > could do was alt-tab around, though it wouldn't paint the window, move > the mouse pointer and turn the num lock light on and off. Can anyone > provide some guidance or perhaps point out a problem in my code? > > For what it's worth, I think I can poll process /ad infinitum/ without > any lockups. > > Thank you, > > -David S. > It's hard to diagnose without seeing all the code, but it sounds like you might be running out of memory. Are you printing a lot of output that could be bloating the screen buffer ? Also, you might want to check that all the handles you open are closed properly. The ones created as PyHANDLEs will be closed automatically, but plain int handles won't be. hth Roger From jbrunen at datasolid.de Wed Mar 22 08:30:12 2006 From: jbrunen at datasolid.de (Johannes Brunen) Date: Wed, 22 Mar 2006 08:30:12 +0100 Subject: [python-win32] Starting a GUI app from AddIn server Message-ID: <09E7D0B55C42DE4E9C27601E7491D793061F63@mail.datasolid.de> Hi, I'm facing the following problem: I have written an AddIn server which is called from a GUI application. After some action in the GUI app the function DoSomething of class CmdEvtHandlerStartApp is called. This works pretty fine. class AddInBase: """ Base class for CADdy++ AddIns. """ _com_interfaces_ = ['ICADdyAddIn'] _public_methods_ = [] _reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER _reg_policy_spec_ = "win32com.server.policy.EventHandlerPolicy" _typelib_guid_ = '{9C3BB401-114D-11D4-AC72-00105A4925FC}' .... class AddIn(AddInBase): _reg_clsid_ = '{FC76E6CC-B0C8-4233-AFFA-45594501A4F0}' _reg_progid_ = 'CADdyAddIn.PythonGui0' def __init__(self): AddInBase.__init__(self) def OnInit(self, theCADdy): NewCmd = self.AddCmd(NewPool, "StartGuiApplication", constants.CMD_NOBREAK, CmdEvtHandlerStartApp) class CmdEvtHandlerStartApp(CmdEvtHandlerBase): def OnExecute(self, cmd, data, cmdStr): self.DoSomething() def DoSomething(self): .... Now, I would like to start a separate wxPython GUI app/dialog (wxAppGui0) from the DoSomething call which should run asynchronously to the main GUI app. The following requirements should be met: 1. The app/dialog should always stay on top of the main GUI app 2. The app/dialog should not appear on the window taskbar 3. The main GUI should not be affected by the app/dialog 4. I need some communication between the AddIn class and the app/dialog I tried the following with varying success: a) Idee: Use a separate thread for the app/dialog and use proper locking for data exchange between the threads. def DoSomething(self): import threading import wxAppGui0 thread = threading.Thread(target = wxAppGui0.main) thread.start() => This seems to work fine for a first call to the DoSomething function. But after closing the wxAppGui0 app/dialog it is impossible to restart the app/dialog by a new call to function DoSomething. Inside wxPython the call to the embedded function CreateWindowEx failed: File "C:\Programme\Python\Lib\site-packages\wx-2.6-msw-ansi\wx\_controls.py", line 79, in __init__ newobj = _controls_.new_Button(*args, **kwargs) PyAssertionError: C++ assertion "wxAssertFailure" failed in ..\..\src\msw\control.cpp(162): CreateWindowEx("BUTTON", flags=56010000, ex=00000000) failed This problem only appears if I have set the wxFrame style to wx.FRAME_NO_TASKBAR. Is there anything I could do in order to use this case? Is this the recommended way to go? Are there any additionl flaws with this design? b) Idee: Create a completly separate process for the app/dialog and setup some communication infrastructure. def DoSomething(self): cmd = r'C:\Development\Learn\Python\COM\Test\Lesson3\wxAppGui0.pyw' import win32process procHandle, threadHandle, procId, threadId = win32process.CreateProcess( None, # appName 'pythonw.exe ' + cmd, None, # process security None, # thread security 0, # inherit handles win32process.NORMAL_PRIORITY_CLASS, None, # new environment None, # Current directory win32process.STARTUPINFO(), # startup info ) => For this scenario I have to build additional communication infrastructure (COM or pipes). I would like to avoid additional registering of a wxAppGui0 COM server. Another problem is that I do have to explicitly specify the wxAppGui0.pyw path. For a) and b), additionally, I don't know how to force the app/dialog always to be on top of the GUI app. How can I enforce this requirement? Can I somehow tell wxPython to use my GUI application as it's parent? Could someone recommend a design for the above use case? I don't have much experiences in the field. Best Johannes ____________ Virus checked by G DATA AntiVirusKit Version: AVK 16.5392 from 08.02.2006 Virus news: www.antiviruslab.com From Ola.Rylow at hiq.se Wed Mar 22 16:26:37 2006 From: Ola.Rylow at hiq.se (Ola Rylow) Date: Wed, 22 Mar 2006 16:26:37 +0100 Subject: [python-win32] Reading a UInt32 array from LabVIEW References: Message-ID: <4336B5C3DC33A74FA393F4F88152F4EC5DA13A@hiqqbexc001.sto.hiq.se> I've tested build 208 with success. Just one exception: When I try to read an array of unsigned 8bit integers I get the following result: () What is special about UInt8 and what shall I do to read them as integers (without having to change the type of the array in the source) -Ola ________________________________ Fr?n: python-win32-bounces at python.org genom Mark Hammond Skickat: ti 2006-03-14 23:21 Till: Ola Rylow; python-win32 at python.org ?mne: Re: [python-win32] Reading a UInt32 array from LabVIEW > From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On > Behalf Of Ola Rylow > I'm accessing LabVIEW through the ActiveX interface and I'm having a problem with reading a UInt32 array. Support for VT_UI4 safe-arrays was added in pywin32 build 207, so you should try that. Note however that build 208, soon to be released, fixes a bug that caused large unsigned numbers to be converted to negative Python integers - so you probably will also want to grab build 208 as soon as it released. Mark _______________________________________________ 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/20060322/3a315d34/attachment.html From mhammond at skippinet.com.au Thu Mar 23 00:07:10 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 23 Mar 2006 10:07:10 +1100 Subject: [python-win32] Reading a UInt32 array from LabVIEW In-Reply-To: <4336B5C3DC33A74FA393F4F88152F4EC5DA13A@hiqqbexc001.sto.hiq.se> Message-ID: > I've tested build 208 with success. Just one exception: > When I try to read an array of unsigned 8bit integers I > get the following result: > () > What is special about UInt8 An array of UInt8 is the standard way of moving "blobs" around in variants (eg, raw buffers, etc). Hence we return them as a string-like object (the buffer should act like a string - slice and dice it etc) > and what shall I do to read them > as integers (without having to change the type of the array in the source) If they really are small unsigned ints, you will need to use the struct module to unpack the string. Mark From jaywink at gmail.com Thu Mar 23 13:19:45 2006 From: jaywink at gmail.com (Jason Robinson) Date: Thu, 23 Mar 2006 14:19:45 +0200 Subject: [python-win32] Question about printing through IE Message-ID: <6c490de20603230419j1339dc7cxdcfdd79382f8c505@mail.gmail.com> Hi, Being relatively new to Python (and no advanced programmer anyhow) I have a question.. For a work related program I need my Python script to be able to change printer settings in IE before printing. I have a script which creates an HTML file with images and text and it uses the ShellExecute approach to print it to a printer (using IE obviously). Only problem is I need it to access the IE printing settings directly and modify them before printing (margins etc etc). I've searched the web throughout but can't figure out where to start... Any hints on what I should do? Cheers for any help! -- Jason Robinson jaywink at gmail.com MSN: jasupasu at hotmail.com AIM: jaywinx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060323/0638a135/attachment.htm From timr at probo.com Fri Mar 24 18:39:44 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 24 Mar 2006 09:39:44 -0800 Subject: [python-win32] Question about printing through IE In-Reply-To: References: Message-ID: <44242EE0.1080906@probo.com> On Thu, 23 Mar 2006 14:19:45 +0200, "Jason Robinson" wrote: >Being relatively new to Python (and no advanced programmer anyhow) I have a >question.. > >For a work related program I need my Python script to be able to change >printer settings in IE before printing. I have a script which creates an >HTML file with images and text and it uses the ShellExecute approach to >print it to a printer (using IE obviously). Only problem is I need it to >access the IE printing settings directly and modify them before printing >(margins etc etc). I've searched the web throughout but can't figure out >where to start... > >Any hints on what I should do? > There is actually very little you can do. It's improper to rely on precise rendering in a web browser to begin with. HTML is not a page description language; you just don't have that much control over layout. You describe roughly how it should look, and the browser does its best to present it. The layout might change with the next version of IE; it has certainly happened before. If you need to print something so that it looks the same on every printer, use ReportLab and create a PDF. Alternatively, you can convert your app to wxPython, which has a wxHtmlEasyPrinting module built in. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From DFeiock at ameripath.com Mon Mar 27 15:34:11 2006 From: DFeiock at ameripath.com (Feiock, Dennis) Date: Mon, 27 Mar 2006 07:34:11 -0600 Subject: [python-win32] Folder Permissions - Inherit problem Message-ID: <9D4F7EF13ED8B5428EF6DF9FF0EADC55857BD6@TXCLMAIL01.ameripath.local> Hi all, I have been trying to write a script to backup/restore NTFS permissions. I have come across one problem. How can I set a folder to inherit its permissions? I am able to detect if a folder has inherited permissions by: 16 & ACE_FLAGS == 16 When I am stepping through them and exporting to an XML file. I found this message: http://mail.python.org/pipermail/python-win32/2004-July/002112.html Which states that ACEs have to be in a certain order (inherited ACEs last). I am able to use the win32security.SetFileSecurity function correctly to set permissions. It's just that when I go to view the inheritance on the folder, the checkbox is always unchecked. Thanks for any assistance. Dennis Feiock -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060327/c02c71eb/attachment.htm From emlynj at gmail.com Tue Mar 28 02:14:42 2006 From: emlynj at gmail.com (Emlyn Jones) Date: Tue, 28 Mar 2006 01:14:42 +0100 Subject: [python-win32] Distributing a Python app using MSI Message-ID: <200603280114.43147.emlynj@gmail.com> Hello, This maybe better suited to the Distutils-SIG, but for now I'll try it here. I'm just wondering if anybody on this list has ever used the msilib functions used to build the Python installer to build an MSI installer for their own Python application. Sort of like distutils but to install scripts into a user specified folder as well as modules into .../site-packages. It looks like I could hack the msi.py script used to build the Python installation but I wondered if anybody could point me towards a hello world type example, I'm not really up to speed on the finer details of MSI. Google'n around it looks like I will have to install the extension modules using distutils and then my application using some other method. I'd like to install the whole lot (including dependencies if necessary; Stuff like fpconst) using MSI. If I'm being silly/missing something shouts will be gratefully heard. Cheers, Emlyn. P.S. py2exe et. al. are not an option because it's a web application. From rwupole at msn.com Tue Mar 28 08:09:34 2006 From: rwupole at msn.com (Roger Upole) Date: Tue, 28 Mar 2006 01:09:34 -0500 Subject: [python-win32] Re: Folder Permissions - Inherit problem Message-ID: Dennis Feiock wrote: > Hi all, > > I have been trying to write a script to backup/restore NTFS permissions. > I have come across one problem. > > How can I set a folder to inherit its permissions? I am able to detect > if a folder has inherited permissions by: > > 16 & ACE_FLAGS == 16 > > When I am stepping through them and exporting to an XML file. > > I found this message: > > http://mail.python.org/pipermail/python-win32/2004-July/002112.html > > Which states that ACEs have to be in a certain order (inherited ACEs > last). ACEs are automatically reordered when they're added. > I am able to use the win32security.SetFileSecurity function correctly to > set permissions. It's just that when I go to view the inheritance on > the folder, the checkbox is always unchecked. When building the ACL yourself, you'll need to use AddAccessAllowedAceEx and AddAccessDeniedAceEx to be able to specify the inheritance flags. Also, see this thread: http://mail.python.org/pipermail/python-win32/2006-February/004210.html for a discussion on storing permissions for later restoral. hth Roger From DFeiock at ameripath.com Tue Mar 28 14:20:50 2006 From: DFeiock at ameripath.com (Feiock, Dennis) Date: Tue, 28 Mar 2006 06:20:50 -0600 Subject: [python-win32] Folder Permissions - Inherit problem Message-ID: <9D4F7EF13ED8B5428EF6DF9FF0EADC55857E78@TXCLMAIL01.ameripath.local> > Dennis Feiock wrote: >> Hi all, >> >> I have been trying to write a script to backup/restore NTFS permissions. >> I have come across one problem. >> >> How can I set a folder to inherit its permissions? I am able to detect >> if a folder has inherited permissions by: >> >> 16 & ACE_FLAGS == 16 >> >> When I am stepping through them and exporting to an XML file. >> >> I found this message: >> >> http://mail.python.org/pipermail/python-win32/2004-July/002112.html >> >> Which states that ACEs have to be in a certain order (inherited ACEs >> last). > ACEs are automatically reordered when they're added. Thanks for the info! That makes things a lot easier. >> I am able to use the win32security.SetFileSecurity function correctly to >> set permissions. It's just that when I go to view the inheritance on >> the folder, the checkbox is always unchecked. > When building the ACL yourself, you'll need to use > AddAccessAllowedAceEx and AddAccessDeniedAceEx > to be able to specify the inheritance flags. > Also, see this thread: > http://mail.python.org/pipermail/python-win32/2006-February/004210.html > for a discussion on storing permissions for later restoral. Thanks for this link as well. That will make things much easier. So far, I have been exporting out the owner and each ACE to an xml file to verify/reconstruct in the future. When I tested using AddAccessAllowedAceEx on a folder, I noticed that the existing subfolders that have inheritance enabled do not automatically take on the added permission. When creating a new folder, it added the ACE as it should. Any suggestions? Here is the code I used (note: I couldn't find information on the SetDacl options, so that might be it): >>> import win32security >>> matt = win32security.LookupAccountName(None,'mbailey')[0] >>> matt >>> fullpath = r'K:\Python\ACL Report\testfolder1' >>> fullpath 'K:\\Python\\ACL Report\\testfolder1' >>> sd1 = win32security.GetFileSecurity(fullpath, win32security.DACL_SECURITY_IN FORMATION) >>> sd1 >>> dacl1 = sd1.GetSecurityDescriptorDacl() >>> dacl1 >>> dacl1.GetAceCount() 7 >>> dacl1.AddAccessAllowedAceEx(win32security.ACL_REVISION_DS, win32security.CON TAINER_INHERIT_ACE|win32security.OBJECT_INHERIT_ACE,2032127,matt) >>> dacl1.GetAceCount() 8 >>> sd1.SetDacl(1,dacl1,0) >>> sd1 >>> win32security.SetFileSecurity(fullpath,win32security.DACL_SECURITY_INFOR MATI ON,sd1) >>> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060328/80de7f72/attachment.htm From emlynj at gmail.com Tue Mar 28 18:19:59 2006 From: emlynj at gmail.com (Emlyn Jones) Date: Tue, 28 Mar 2006 17:19:59 +0100 Subject: [python-win32] Distributing a Python app using MSI In-Reply-To: <71b6302c0603272134r30e08f02ue1017f769b0bde65@mail.gmail.com> References: <200603280114.43147.emlynj@gmail.com> <71b6302c0603272134r30e08f02ue1017f769b0bde65@mail.gmail.com> Message-ID: On 3/28/06, Mark Mc Mahon wrote: > Hi Emlyn, > > On 3/28/06, Emlyn Jones wrote: > > Hello, > > This maybe better suited to the Distutils-SIG, but for now I'll try it here. > > I'm just wondering if anybody on this list has ever used the msilib functions > > used to build the Python installer to build an MSI installer for their own > > Python application. Sort of like distutils but to install scripts into a user > > specified folder as well as modules into .../site-packages. > > It looks like I could hack the msi.py script used to build the Python > > installation but I wondered if anybody could point me towards a hello world > > type example, I'm not really up to speed on the finer details of MSI. > > Google'n around it looks like I will have to install the extension modules > > using distutils and then my application using some other method. I'd like to > > install the whole lot (including dependencies if necessary; Stuff like > > fpconst) using MSI. > > If I'm being silly/missing something shouts will be gratefully heard. > > So let me see if I understand... > You have a bunch of files (.py, .pyd) etc. > > Do they need to go into different directories (e.g. > windows/python\lib\site-packages) or you can put them all under one > directory? > - If you are putting everything under one directory then I guess it > shouldn't be THAT difficult (though MSI is reasonably complicated!) > > If you are putting files under various directories - then it becomes > more complicated - but still possible. > > My suggestion would be to use distutils first to collect everything > into one usable/clean structure - then build the MSI out of that. > > I have worked quite a bit with MSI - but never created my own from > Scratch - some people use WIX (which I think was open sourced from > Microsoft themselves). > > > Cheers, > > Emlyn. > > P.S. py2exe et. al. are not an option because it's a web application. > > I hope that was of some use, > Mark > Hello, thanks for the reply. Yes, that's useful. I have a bunch of py and pyd files as you say; some get installed as Python modules (in site-packages) some get installed elsewhere (in a user specified folder). I wasn't aware of WIX, a quick look through the tutorial suggests it is what I'm looking for. I was just thinking that if Python had the were with-all (let's face it, when doesn't Python have the were with-all), it might be a less steep learning curve. I guess my next decision is whether to re package the existing extension modules (fpconst and the PyWebSvc stuff) and install them as components or to find a way of getting msi to call `python setup.py install`. Either way, I think your suggestion of grouping them all in a single distutils package first is the way to go. At least I know I'm heading in roughly the right direction. One more question though, if that's ok. I can test for Python by checking for the registry entries but what's the best way to check that the win32 stuff. Is it just a case of looking for the folders under site-packages? I guess a little Python script that attempts to import stuff and returns an error code may be another way. Cheers, Emlyn. From mark.m.mcmahon at gmail.com Tue Mar 28 18:33:32 2006 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Tue, 28 Mar 2006 18:33:32 +0200 Subject: [python-win32] Distributing a Python app using MSI In-Reply-To: References: <200603280114.43147.emlynj@gmail.com> <71b6302c0603272134r30e08f02ue1017f769b0bde65@mail.gmail.com> Message-ID: <71b6302c0603280833q58eb4849u7e786d92d12706b5@mail.gmail.com> Hi, I am sure Mark Hammond or someone else knowledgable can answer - but I am sure that there are registry entries for PyWin32 also (for all that COM/OLE stuff :-) I just did a quick search of my registry for win32com and that led me to... HKEY_CLASSES_ROOT\Python.Interpreter That looks like it might be usable? (though I am using the extensions installed on top of python.org Python - but I would guess that ActiveState python is similar). I don't completely see why you need an MSI though. You are requiring Python on the target machine - why not use something like sdist with a custom install script? (note I am not an expert in distutils - so maybe it doesn't do what you need!) Anyway - some ideas for you :-) Mark On 3/28/06, Emlyn Jones wrote: > On 3/28/06, Mark Mc Mahon wrote: > > Hi Emlyn, > > > > On 3/28/06, Emlyn Jones wrote: > > > Hello, > > > This maybe better suited to the Distutils-SIG, but for now I'll try it here. > > > I'm just wondering if anybody on this list has ever used the msilib functions > > > used to build the Python installer to build an MSI installer for their own > > > Python application. Sort of like distutils but to install scripts into a user > > > specified folder as well as modules into .../site-packages. > > > It looks like I could hack the msi.py script used to build the Python > > > installation but I wondered if anybody could point me towards a hello world > > > type example, I'm not really up to speed on the finer details of MSI. > > > Google'n around it looks like I will have to install the extension modules > > > using distutils and then my application using some other method. I'd like to > > > install the whole lot (including dependencies if necessary; Stuff like > > > fpconst) using MSI. > > > If I'm being silly/missing something shouts will be gratefully heard. > > > > So let me see if I understand... > > You have a bunch of files (.py, .pyd) etc. > > > > Do they need to go into different directories (e.g. > > windows/python\lib\site-packages) or you can put them all under one > > directory? > > - If you are putting everything under one directory then I guess it > > shouldn't be THAT difficult (though MSI is reasonably complicated!) > > > > If you are putting files under various directories - then it becomes > > more complicated - but still possible. > > > > My suggestion would be to use distutils first to collect everything > > into one usable/clean structure - then build the MSI out of that. > > > > I have worked quite a bit with MSI - but never created my own from > > Scratch - some people use WIX (which I think was open sourced from > > Microsoft themselves). > > > > > Cheers, > > > Emlyn. > > > P.S. py2exe et. al. are not an option because it's a web application. > > > > I hope that was of some use, > > Mark > > > Hello, thanks for the reply. > Yes, that's useful. > I have a bunch of py and pyd files as you say; some get installed as > Python modules (in site-packages) some get installed elsewhere (in a > user specified folder). > I wasn't aware of WIX, a quick look through the tutorial suggests it > is what I'm looking for. I was just thinking that if Python had the > were with-all (let's face it, when doesn't Python have the were > with-all), it might be a less steep learning curve. > I guess my next decision is whether to re package the existing > extension modules (fpconst and the PyWebSvc stuff) and install them as > components or to find a way of getting msi to call `python setup.py > install`. Either way, I think your suggestion of grouping them all in > a single distutils package first is the way to go. > At least I know I'm heading in roughly the right direction. > One more question though, if that's ok. I can test for Python by > checking for the registry entries but what's the best way to check > that the win32 stuff. Is it just a case of looking for the folders > under site-packages? I guess a little Python script that attempts to > import stuff and returns an error code may be another way. > > Cheers, > Emlyn. > From emlynj at gmail.com Tue Mar 28 19:24:19 2006 From: emlynj at gmail.com (Emlyn Jones) Date: Tue, 28 Mar 2006 18:24:19 +0100 Subject: [python-win32] Distributing a Python app using MSI In-Reply-To: <71b6302c0603280833q58eb4849u7e786d92d12706b5@mail.gmail.com> References: <200603280114.43147.emlynj@gmail.com> <71b6302c0603272134r30e08f02ue1017f769b0bde65@mail.gmail.com> <71b6302c0603280833q58eb4849u7e786d92d12706b5@mail.gmail.com> Message-ID: > On 3/28/06, Emlyn Jones wrote: > > On 3/28/06, Mark Mc Mahon wrote: > > > Hi Emlyn, > > > > > > On 3/28/06, Emlyn Jones wrote: > > > > Hello, > > > > This maybe better suited to the Distutils-SIG, but for now I'll try it here. > > > > I'm just wondering if anybody on this list has ever used the msilib functions > > > > used to build the Python installer to build an MSI installer for their own > > > > Python application. Sort of like distutils but to install scripts into a user > > > > specified folder as well as modules into .../site-packages. > > > > It looks like I could hack the msi.py script used to build the Python > > > > installation but I wondered if anybody could point me towards a hello world > > > > type example, I'm not really up to speed on the finer details of MSI. > > > > Google'n around it looks like I will have to install the extension modules > > > > using distutils and then my application using some other method. I'd like to > > > > install the whole lot (including dependencies if necessary; Stuff like > > > > fpconst) using MSI. > > > > If I'm being silly/missing something shouts will be gratefully heard. > > > > > > So let me see if I understand... > > > You have a bunch of files (.py, .pyd) etc. > > > > > > Do they need to go into different directories (e.g. > > > windows/python\lib\site-packages) or you can put them all under one > > > directory? > > > - If you are putting everything under one directory then I guess it > > > shouldn't be THAT difficult (though MSI is reasonably complicated!) > > > > > > If you are putting files under various directories - then it becomes > > > more complicated - but still possible. > > > > > > My suggestion would be to use distutils first to collect everything > > > into one usable/clean structure - then build the MSI out of that. > > > > > > I have worked quite a bit with MSI - but never created my own from > > > Scratch - some people use WIX (which I think was open sourced from > > > Microsoft themselves). > > > > > > > Cheers, > > > > Emlyn. > > > > P.S. py2exe et. al. are not an option because it's a web application. > > > > > > I hope that was of some use, > > > Mark > > > > > Hello, thanks for the reply. > > Yes, that's useful. > > I have a bunch of py and pyd files as you say; some get installed as > > Python modules (in site-packages) some get installed elsewhere (in a > > user specified folder). > > I wasn't aware of WIX, a quick look through the tutorial suggests it > > is what I'm looking for. I was just thinking that if Python had the > > were with-all (let's face it, when doesn't Python have the were > > with-all), it might be a less steep learning curve. > > I guess my next decision is whether to re package the existing > > extension modules (fpconst and the PyWebSvc stuff) and install them as > > components or to find a way of getting msi to call `python setup.py > > install`. Either way, I think your suggestion of grouping them all in > > a single distutils package first is the way to go. > > At least I know I'm heading in roughly the right direction. > > One more question though, if that's ok. I can test for Python by > > checking for the registry entries but what's the best way to check > > that the win32 stuff. Is it just a case of looking for the folders > > under site-packages? I guess a little Python script that attempts to > > import stuff and returns an error code may be another way. > > > > Cheers, > > Emlyn. > > > On 3/28/06, Mark Mc Mahon wrote: ..snip.. > I don't completely see why you need an MSI though. You are requiring > Python on the target machine - why not use something like sdist with a > custom install script? (note I am not an expert in distutils - so > maybe it doesn't do what you need!) > ..snip.. No, I'm not 100% sure yet either. I'm thinking that I do because I don't want all my code installed in site-packages and I can't see a way to get distutils to install stuff outside of the Python directory tree (or indeed to ask where it should be installed). I'm not a distutils expert either but I think it's designed for installing Python modules rather than Python applications. Unfortunatly I need to do both and ideally from a single install. There does seem to be a number of options, I guess it's just suck it and see. One other thought is to make an MSI to install everything that can't be installed using distutils and then run msiexec from distutils using a custom Python script as you suggest. A single install bundle has to be favourite though. Decisions, Decisions! Cheers, Emlyn. From rwupole at msn.com Tue Mar 28 22:26:31 2006 From: rwupole at msn.com (Roger Upole) Date: Tue, 28 Mar 2006 15:26:31 -0500 Subject: [python-win32] Re: Folder Permissions - Inherit problem Message-ID: Dennis Feiock wrote: > When I tested using AddAccessAllowedAceEx on a folder, I noticed that the existing subfolders that have inheritance enabled do > not automatically take on the added permission. When creating a new folder, it added the ACE as it should. Any suggestions? > Here is the code I used (note: I couldn't find information on the SetDacl options, so that might be it): ... >>> win32security.SetFileSecurity(fullpath,win32security.DACL_SECURITY_INFORMATION,sd1) Try using SetNamedSecurityInfo instead. I think SetFileSecurity is actually considered obsolete now. After playing around with both of these, it appears SetNamedSecurityInfo will cause the inherited ACEs to propagate to existing subfolders, whereas SetFileSecurity doesn't. win32security.SetNamedSecurityInfo(fullpath, win32security.SE_FILE_OBJECT, win32security.DACL_SECURITY_INFORMATION,None, None, dacl1, None) hth Roger From DFeiock at ameripath.com Wed Mar 29 14:19:55 2006 From: DFeiock at ameripath.com (Feiock, Dennis) Date: Wed, 29 Mar 2006 06:19:55 -0600 Subject: [python-win32] Folder Permissions - Inherit problem Message-ID: <9D4F7EF13ED8B5428EF6DF9FF0EADC558C84E5@TXCLMAIL01.ameripath.local> > Dennis Feiock wrote: >> When I tested using AddAccessAllowedAceEx on a folder, I noticed that the existing subfolders that have inheritance enabled do >> not automatically take on the added permission. When creating a new folder, it added the ACE as it should. Any suggestions? >> Here is the code I used (note: I couldn't find information on the SetDacl options, so that might be it): ... >>>> win32security.SetFileSecurity(fullpath,win32security.DACL_SECURITY_INFOR MATION,sd1) > Try using SetNamedSecurityInfo instead. I think SetFileSecurity is actually considered > obsolete now. > After playing around with both of these, it appears SetNamedSecurityInfo will > cause the inherited ACEs to propagate to existing subfolders, whereas SetFileSecurity doesn't. > win32security.SetNamedSecurityInfo(fullpath, win32security.SE_FILE_OBJECT, > win32security.DACL_SECURITY_INFORMATION,None, None, dacl1, None) > hth > Roger Using SetNamedSecurityInfo did the trick. Thanks a lot for all your help. By the way, do you know a good source of information for win32 api stuff? The resource I am using (ActivePython's documentation) doesn't make any note about the SetFileSecurity function's limitations or being obsolete and I would like to avoid beating my head against the wall in the future. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060329/70de2958/attachment.html From martin at martindengler.com Wed Mar 29 18:45:06 2006 From: martin at martindengler.com (martin at martindengler.com) Date: Wed, 29 Mar 2006 17:45:06 +0100 Subject: [python-win32] python com server exceptions don't make it to .NET / CLR app Message-ID: <20060329164501.GA2154@sun.xades.com> Hi, Has anyone seen exceptions raised from their python com server code get across to a .NET application (C# especially) with its *args somewhere in the C# COMException (probably the Exception.InnerException)? Couple of specific questions below, but the general gist is that the following code lets VB see the IErrorInfo.text field, but although the stack trace makes it over to a C# exception, none of the *args or IErrorInfo members do: ---- import inspect import pythoncom import winerror [...] def _create_com_ex(e, frames): #see O'Reilly's Python programming for win32 #google cache: http://72.14.203.104/search?q=cache:UHfawJfSAP0J:ngharo.com/~nick/oreilly/books/pythonwin32/ch12.htm+win32com+isupporterrorinfo&hl=en&ct=clnk&cd=21 errorcode = winerror.DISP_E_EXCEPTION #now we've committed to create an IErrorInfo errorcode = winerror.DISP_E_MEMBERNOTFOUND #some debugging sugar desc = "%s: -- %s" % (type(e), str(e)) frames.reverse() pretty_frames = "....".join(["%s:%s" % info[1:3] for info in frames]) #IErrorInfo members wCode = 0 #one of wCode or sCode must be zero source = str(frames[0]) text = "%s\r\n%s" % (desc, pretty_frames) helpFile = "comutils.py" helpId = 0 sCode = winerror.E_FAIL #from win32com's errorSemantics.py best practice ierrorinfo = (wCode, source, text, helpFile, helpId, sCode) err = pythoncom.com_error(errorcode, desc, ierrorinfo, None) return err [....inside a pythoncom IDispath subclass...] def test_exception(msg): raise _create_com_ex(msg, inspect.trace()) [...] ---- The "text" variable comes over fine to VB, but the following C#... ---- using System; using MyPythonCOMServer; namespace ConsoleApplication1 { class Class1 { [STAThread] static void Main(string[] args) { IMyServer s = new MyPythonCOMServer.CServer(); try { s.test_exception("goodbye cruel world"); } catch (Exception e) { Console.WriteLine(String.Format(@" C# stuff visible here.... Type: {0} Message: {1} InnerException: {2} StackTrace: {3} TargetSite: {4} HelpLink: {5} ", e.GetType(), e.Message, e.InnerException, e.StackTrace, e.TargetSite, e.HelpLink)); Console.WriteLine("Success"); } } } } ---- ...prints: ---- pythoncom error: Failed to call the universal dispatcher Traceback (most recent call last): File "C:\Python23\Lib\site-packages\win32com\universal.py", line 173, in dispatch retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None) File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 322, in _InvokeEx_ return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider) File "...MyPythonCOMServer.py", line 791, in _invokeex_ kwargs, serviceProvider) File "...MyPythonCOMServer.py", line 653, in _invokeex_ raise _create_com_ex(e, inspect.trace()) pywintypes.com_error: (-2147352573, ": -- goodbye cruel world", (0, '(, \'....\', 92, \'test_exception\', ...... , "C:\\Python23\\Lib\\site-packages\\win32com\\server\\policy.py:541...., 0, -2147467259), None) C# stuff visible here.... Type: System.Runtime.InteropServices.COMException Message: Unspecified error InnerException: StackTrace: at MyPythonCOMServer.CServer.test_exception(String msg) at ConsoleApplication1.Class1.Main(String[] args) in c:\temp\consoleapplication1\class1.cs:line 23 TargetSite: Void test_exception(System.String) HelpLink: ---- So: 1) What is pythoncom.com_error() and the code that handles it doing to get VB to see the (presumably) IErrorInfo? I'm sorry if I've missed where I can get the source as presumably it's the C unmarshaling code that's in the C# process calling SetLastError() or something, but it'd be nice to know how it's done. All the (nice) presentations / books by the experts basically stop at "it'll get done if you use win32com.server.exception.COMException, don't worry about how". 2) Has anyone gotten any win32com.server.exception.COMExceptions across to C# with the string/Exception passed to raise()? Thanks, Martin -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 191 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20060329/89aa7a00/attachment.pgp From rwupole at msn.com Thu Mar 30 10:54:59 2006 From: rwupole at msn.com (Roger Upole) Date: Thu, 30 Mar 2006 03:54:59 -0500 Subject: [python-win32] Re: Question about printing through IE Message-ID: Jason Robinson wrote: > Hi, > > Being relatively new to Python (and no advanced programmer anyhow) I have a > question.. > > For a work related program I need my Python script to be able to change > printer settings in IE before printing. I have a script which creates an > HTML file with images and text and it uses the ShellExecute approach to > print it to a printer (using IE obviously). Only problem is I need it to > access the IE printing settings directly and modify them before printing > (margins etc etc). I've searched the web throughout but can't figure out > where to start... > > Any hints on what I should do? > > Cheers for any help! IE stores printing parameters in the registry at HKCU\Software\Microsoft\Internet Explorer\PageSetup. For options not covered there, you can use functions in the win32print module to change your default printer settings, but they'll apply to anything you print, not just IE. hth Roger From jaywink at gmail.com Thu Mar 30 11:34:26 2006 From: jaywink at gmail.com (Jason Robinson) Date: Thu, 30 Mar 2006 12:34:26 +0300 Subject: [python-win32] Question about printing through IE In-Reply-To: References: Message-ID: <6c490de20603300134y119feae3k5424aa057b1620c2@mail.gmail.com> Roger, Thanks! I'm currently fixing the program to make a pdf file instead.. but being able to program it to do the page setup stuff for IE would be easier.. Will look into that registry stuff.. need to find out how to access it first :) -Jason On 3/30/06, Roger Upole wrote: > > Jason Robinson wrote: > > > Hi, > > > > Being relatively new to Python (and no advanced programmer anyhow) I > have a > > question.. > > > > For a work related program I need my Python script to be able to change > > printer settings in IE before printing. I have a script which creates an > > HTML file with images and text and it uses the ShellExecute approach to > > print it to a printer (using IE obviously). Only problem is I need it to > > access the IE printing settings directly and modify them before printing > > (margins etc etc). I've searched the web throughout but can't figure out > > where to start... > > > > Any hints on what I should do? > > > > Cheers for any help! > > IE stores printing parameters in the registry at > HKCU\Software\Microsoft\Internet Explorer\PageSetup. > For options not covered there, you can use functions in > the win32print module to change your default printer settings, > but they'll apply to anything you print, not just IE. > > hth > Roger > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- Jason Robinson jaywink at gmail.com http://jaywink.1g.fi for pics, gigs & mixes tel. +358468507826 MSN: jasupasu at hotmail.com AIM: jaywinx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20060330/e62118ce/attachment.htm From mhammond at skippinet.com.au Thu Mar 30 11:53:16 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 30 Mar 2006 20:53:16 +1100 Subject: [python-win32] python com server exceptions don't make it to .NET /CLR app In-Reply-To: <20060329164501.GA2154@sun.xades.com> Message-ID: > err = pythoncom.com_error(errorcode, desc, ierrorinfo, None) Try win32com.server.exception.COMException - the framework sees that exception as something that should be raised to the caller (whereas a normal pythoncom.com_exception is assumed to have been generated by a COM object *used* by the COM server, so is handled like any other 'unhandled' exception. > 1) What is pythoncom.com_error() and the code that handles it > doing to get VB to see the (presumably) IErrorInfo? I'm sorry if > I've missed where I can get the source as presumably it's the C > unmarshaling code that's in the C# process calling SetLastError() > or something, but it'd be nice to know how it's done. Exactly - SetErrorInfo should always be called - just how the attributes are set may change. > 2) Has anyone gotten any win32com.server.exception.COMExceptions > across to C# with the string/Exception passed to raise()? I'm not sure about C#, but certainly to another C++ (or similar) based app that uses IErrorInfo. I'm sure there are a few cans of worms waiting, so I'd be happy to accept some C# code to add to the test suite - the com\TestSources directory (in CVS or a source release) already contains VB6 and C++ COM servers... Mark From mark.m.mcmahon at gmail.com Thu Mar 30 14:02:37 2006 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Thu, 30 Mar 2006 14:02:37 +0200 Subject: [python-win32] ANN: pywinauto 0.3.1 released - performance tuneup Message-ID: <71b6302c0603300402y25cab4eekffac136f797f1bf3@mail.gmail.com> Hi, The 0.3.1 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.0: 0.3.1 Performance tune-ups ------------------------------------------------------------------ 30-Mar-2006 * Change calculation of distance in findbestmatch.GetNonTextControlName() so that it does not need to square or get the square root to find the real distance - as we only need to compare values - not have the actual distance. (Thanks to Stefaan Himple) * Compiled regular expression patterns before doing the match to avoid compiling the regular expression for window that is being tested (Thanks to Stefaan Himple) * Made it easier to add your own control tests by adding a file extra_tests.py which needs to export a ModifyRegisteredTests() method. Also cleaned up the code a little. * Updated notepad_fast.py to make it easier to profile (adde a method) * Changed WrapHandle to use a cache for classes it has matched - this is to avoid having to match against all classes constantly. * Changed default timeout in SendMessageTimeout to .001 seconds from .4 seconds this results in a significant speedup. Will need to make this value modifiable via the timing module/routine. * WaitNot was raising an error if the control was not found - it should have returned (i.e. success - control is not in any particular state because it does not exist!). * Added ListViewWrapper.Deselect() per Chistophe Keller's suggestion. While I was at it I added a check on the item value passed in and added a call to WaitGuiIdle(self) so that the control has a chance to process the message. * Changed doc templates and moved dependencies into pywinauto subversion to ensure that all files were availabe at www.openqa.org and that they are not broken when viewed there. * Moved all timing information into the timings.Timings class. There are some simple methods for changing the timings. 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 From le.dahut at laposte.net Thu Mar 30 15:25:23 2006 From: le.dahut at laposte.net (le dahut) Date: Thu, 30 Mar 2006 15:25:23 +0200 Subject: [python-win32] python and gina Message-ID: <442BDC43.4040302@laposte.net> Hello, Does someone any information about how to use gina stubs and python together -;) ? From bwmetz at att.com Thu Mar 30 17:51:51 2006 From: bwmetz at att.com (Metz, Bobby W, WCS) Date: Thu, 30 Mar 2006 09:51:51 -0600 Subject: [python-win32] Question about printing through IE In-Reply-To: <005301c653d7$a1628420$0100a8c0@rupole> Message-ID: <01D5341D04A2E64AB9B3457690473367018B9894@OCCLUST01EVS1.ugd.att.com> If you have Word installed on the user machines (assuming this is a locally run program), one could consider automating Word to open the file, change margins and then print. B -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Roger Upole Sent: Thursday, March 30, 2006 1:55 AM To: python-win32 at python.org Subject: [python-win32] Re: Question about printing through IE Jason Robinson wrote: > Hi, > > Being relatively new to Python (and no advanced programmer anyhow) I have a > question.. > > For a work related program I need my Python script to be able to change > printer settings in IE before printing. I have a script which creates an > HTML file with images and text and it uses the ShellExecute approach to > print it to a printer (using IE obviously). Only problem is I need it to > access the IE printing settings directly and modify them before printing > (margins etc etc). I've searched the web throughout but can't figure out > where to start... > > Any hints on what I should do? > > Cheers for any help! IE stores printing parameters in the registry at HKCU\Software\Microsoft\Internet Explorer\PageSetup. For options not covered there, you can use functions in the win32print module to change your default printer settings, but they'll apply to anything you print, not just IE. hth Roger _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From mark.m.mcmahon at gmail.com Fri Mar 31 01:56:36 2006 From: mark.m.mcmahon at gmail.com (Mark Mc Mahon) Date: Fri, 31 Mar 2006 01:56:36 +0200 Subject: [python-win32] ANN: pywinauto 0.3.2 released - fixed broken setup.py Message-ID: <71b6302c0603301556o486b1cf5x350a5ff06cc21981@mail.gmail.com> Hi, Seems like I broke setup.py :-( 0.3.2 Fixed setup.py and some typos ------------------------------------------------------------------ 31-Mar-2006 * Fixed the spelling of Stefaan Himpe's name * Fixed setup.py which was working for creating a distribution but not for installing it (again thanks to Stefaan for pointing it out!) Tested setup.py for installing as well as source distribution creation - and it worked. Thanks Mark ---------- Forwarded message ---------- From: Mark Mc Mahon Date: Mar 30, 2006 2:02 PM Subject: ANN: pywinauto 0.3.1 released - performance tuneup To: pywinauto-users at lists.sourceforge.net, python-win32 at python.org Hi, The 0.3.1 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.0: 0.3.1 Performance tune-ups ------------------------------------------------------------------ 30-Mar-2006 * Change calculation of distance in findbestmatch.GetNonTextControlName() so that it does not need to square or get the square root to find the real distance - as we only need to compare values - not have the actual distance. (Thanks to Stefaan Himple) * Compiled regular expression patterns before doing the match to avoid compiling the regular expression for window that is being tested (Thanks to Stefaan Himple) * Made it easier to add your own control tests by adding a file extra_tests.py which needs to export a ModifyRegisteredTests() method. Also cleaned up the code a little. * Updated notepad_fast.py to make it easier to profile (adde a method) * Changed WrapHandle to use a cache for classes it has matched - this is to avoid having to match against all classes constantly. * Changed default timeout in SendMessageTimeout to .001 seconds from .4 seconds this results in a significant speedup. Will need to make this value modifiable via the timing module/routine. * WaitNot was raising an error if the control was not found - it should have returned (i.e. success - control is not in any particular state because it does not exist!). * Added ListViewWrapper.Deselect() per Chistophe Keller's suggestion. While I was at it I added a check on the item value passed in and added a call to WaitGuiIdle(self) so that the control has a chance to process the message. * Changed doc templates and moved dependencies into pywinauto subversion to ensure that all files were availabe at www.openqa.org and that they are not broken when viewed there. * Moved all timing information into the timings.Timings class. There are some simple methods for changing the timings. 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 From rwupole at msn.com Fri Mar 31 12:18:20 2006 From: rwupole at msn.com (Roger Upole) Date: Fri, 31 Mar 2006 05:18:20 -0500 Subject: [python-win32] Re: Folder Permissions - Inherit problem Message-ID: > Using SetNamedSecurityInfo did the trick. Thanks a lot for all your > help. By the way, do you know a good source of information for win32 > api stuff? The resource I am using (ActivePython's documentation) > doesn't make any note about the SetFileSecurity function's limitations > or being obsolete and I would like to avoid beating my head against the > wall in the future. MSDN is your best bet for detailed api info. (msdn.microsoft.com). You also get a lot of what's on MSDN in CHM format with the Platform SDK download. Roger