From python at kapitalisten.no Thu Dec 1 14:26:09 2005 From: python at kapitalisten.no (=?iso-8859-1?Q?=D8yvind?=) Date: Thu, 1 Dec 2005 14:26:09 +0100 (CET) Subject: [python-win32] Unicode trouble Message-ID: <49628.193.71.38.142.1133443569.squirrel@mail.sporck.net> Hello. I am trying to use the search and replace-function in MS Word. (Office 2003, XP and Activestate Python 2.3). It works great until I use non-english letters. >>> from win32com.client import Dispatch >>> objWord = Dispatch("Word.Application") >>> objDoc = objWord.Documents.Open('c:/foo.doc') >>> objSelection = objWord.Selection >>> en = u'Kan man gj?re dette?' >>> to = u'N? tryner det skikkelig' >>> objSelection.Find.Execute(en, False, True, False, False, True, True, 1, True, to, 2, False, False, False, False) gives the errormessage: Traceback (most recent call last): File "", line 1, in ? File ">", line 2, in Execute com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Word', 'The Find What text for a Find All Word Forms search can only contain alphabetic letters.', 'C:\\Program Files\\Microsoft Office\\OFFICE11\\1033\\wdmain11.chm', 25090, -2146822678), None) I have also tried: en = en.decode('latin-1') and en = en.decode('utf-8') but it still gives me the same error. If I type the sentences directly into Word, it works as a dream. How can I get around this problem? Thanks in advance. -- This email has been scanned for viruses & spam by Decna as - www.decna.no Denne e-posten er sjekket for virus & spam av Decna as - www.decna.no From timr at probo.com Thu Dec 1 18:27:19 2005 From: timr at probo.com (Tim Roberts) Date: Thu, 01 Dec 2005 09:27:19 -0800 Subject: [python-win32] win32 service not receiving shutdown notification on reboot In-Reply-To: References: Message-ID: <438F3277.8060403@probo.com> On Wed, 30 Nov 2005 17:41:32 +0100, Ralf Schmitt >I use the attached program to start a win32 service. >Stopping the service using the service manager works fine, but when I >reboot the machine, the service just seems to be killed, without >SvcStop/SvcShutdown being called (i.e. it never prints "DONE" on reboot). >Tested on w2k using python2.3, and on XP using Python 2.4, both using >pywin 205. > >Does anybody have an idea? > > Umm, do you realize that your 'print "DONE"' statement is not part of the SvcStop function, but rather the SvcDoRun function? >#! /usr/bin/env python > >import sys >import time >import win32serviceutil, win32service > >class MyTwistedService(win32serviceutil.ServiceFramework): > _svc_name_ = 'AA' > _svc_display_name_ = 'AA' > def SvcDoRun(self): > # Can't use stdout for logging -- .flush will barf > sys.stdout = open('c:/mylog.txt','a', 0) > self.shouldStop = False > while not self.shouldStop: > print time.ctime(), "running" > time.sleep(1) > > print "DONE" > > def SvcStop(self): > self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) > self.shouldStop = True > > > SvcShutdown = SvcStop > >if __name__ == '__main__': > win32serviceutil.HandleCommandLine(MyTwistedService) > > -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ralf at brainbot.com Thu Dec 1 20:13:24 2005 From: ralf at brainbot.com (Ralf Schmitt) Date: Thu, 01 Dec 2005 20:13:24 +0100 Subject: [python-win32] win32 service not receiving shutdown notification on reboot In-Reply-To: <438F3277.8060403@probo.com> References: <438F3277.8060403@probo.com> Message-ID: <438F4B54.1040202@brainbot.com> Tim Roberts schrieb: >On Wed, 30 Nov 2005 17:41:32 +0100, Ralf Schmitt > > > >>I use the attached program to start a win32 service. >>Stopping the service using the service manager works fine, but when I >>reboot the machine, the service just seems to be killed, without >>SvcStop/SvcShutdown being called (i.e. it never prints "DONE" on reboot). >>Tested on w2k using python2.3, and on XP using Python 2.4, both using >>pywin 205. >> >>Does anybody have an idea? >> >> >> >> > >Umm, do you realize that your 'print "DONE"' statement is not part of >the SvcStop function, but rather the SvcDoRun function? > > > Yes, but if SvcStop is called, SvcDoRun should also finish afterwards...one can see the "DONE" being printed when stopping the service with the service manager, but not when rebooting the machine. Adding a print statement in in SvcStop (as the first thing it does), also doesn't get me any output... To me it looks like it really just is not being called. - Ralf >>#! /usr/bin/env python >> >>import sys >>import time >>import win32serviceutil, win32service >> >>class MyTwistedService(win32serviceutil.ServiceFramework): >> _svc_name_ = 'AA' >> _svc_display_name_ = 'AA' >> def SvcDoRun(self): >> # Can't use stdout for logging -- .flush will barf >> sys.stdout = open('c:/mylog.txt','a', 0) >> self.shouldStop = False >> while not self.shouldStop: >> print time.ctime(), "running" >> time.sleep(1) >> >> print "DONE" >> >> def SvcStop(self): >> self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) >> self.shouldStop = True >> >> >> SvcShutdown = SvcStop >> >>if __name__ == '__main__': >> win32serviceutil.HandleCommandLine(MyTwistedService) >> >> >> >> > > > > From andrew.markebo at comhem.se Fri Dec 2 11:17:32 2005 From: andrew.markebo at comhem.se (Andrew Markebo) Date: Fri, 02 Dec 2005 11:17:32 +0100 Subject: [python-win32] using InvokeTypes? Message-ID: I am communicating between LabVIEW and Python through the COM-interface, trying to drag out a LabVIEW defined enum. The sane problem as seen in "Reading custom output parameters from LabVIEW/ActiveX" There Mark Hammond writes: "Sadly there is no easy way to explicitly specify the exact variant type, other than using InvokeTypes. " So now I would like to throw an eye at InvokeTypes, been searching a bit, but only found non-commented InvokeTypes. How do I find the values of input/output lists, flags and so on. Is it possible just to set it to sort of list of bytes or so and we fipple it right?? /Andy -- Don't walk in front of me, I might be unable to follow you. Don't walk after me, I might be unable to lead you. Just walk by my side and be my friend. From tim.golden at viacom-outdoor.co.uk Fri Dec 2 11:52:34 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Fri, 2 Dec 2005 10:52:34 -0000 Subject: [python-win32] Unicode trouble Message-ID: <9A28C052FF32734DACB0A288A3533991044D23BE@vogbs009.gb.vo.local> [?yvind] > I am trying to use the search and replace-function in MS Word. (Office > 2003, XP and Activestate Python 2.3). It works great until I use > non-english letters. > [... ] >>> objSelection.Find.Execute(en, False, True, False, False, True, True, 1, True, to, 2, False, False, False, False) > "... The Find What text for a Find All Word > Forms search can only contain alphabetic letters" I think (and it's a guess) that the order of params isn't what you think it is. Frankly, it looks right, but playing around a bit with named params is both more readable, and seems to give the right results. I experimented a bit with your code, and even my own name (which uses nothing outside standard ASCII) gave the same error. The following code seems to work: import win32com.client word = win32com.client.gencache.EnsureDispatch ("Word.Application") constants = win32com.client.constants doc = word.Documents.Open ("c:/temp/test.doc") doc.Content.Find.Execute ( FindText=u'Kan man gj?re dette?', ReplaceWith=u'N? tryner det skikkelig', Replace=constants.wdReplaceAll ) 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 ralf at brainbot.com Fri Dec 2 14:14:06 2005 From: ralf at brainbot.com (Ralf Schmitt) Date: Fri, 02 Dec 2005 14:14:06 +0100 Subject: [python-win32] win32 service not receiving shutdown notification on reboot In-Reply-To: <438DD63C.1040805@brainbot.com> References: <438DD63C.1040805@brainbot.com> Message-ID: <4390489E.3050208@brainbot.com> Ralf Schmitt wrote: > Hi all, > > I use the attached program to start a win32 service. > Stopping the service using the service manager works fine, but when I > reboot the machine, the service just seems to be killed, without > SvcStop/SvcShutdown being called (i.e. it never prints "DONE" on reboot). > Tested on w2k using python2.3, and on XP using Python 2.4, both using > pywin 205. > > Does anybody have an idea? > One has to register a console ctrl handler: import win32api def handler(*args): print "HANDLER:", args return True win32api.SetConsoleCtrlHandler(handler, True) I'm not sure about the return value of handler, but at least I now get my "DONE" in the logfile: my logfile afterwards contains: Fri Dec 02 14:00:02 2005 running Fri Dec 02 14:00:03 2005 running HANDLER: (5,) Fri Dec 02 14:00:04 2005 running Fri Dec 02 14:00:05 2005 running Fri Dec 02 14:00:06 2005 running Fri Dec 02 14:00:07 2005 running Fri Dec 02 14:00:08 2005 running HANDLER: (5,) HANDLER: (6,) HANDLE CTRL:Fri Dec 02 14:00:09 2005 running 5 ACCEPTED: 5 DONE - Ralf WTF. Using Windows is just an aburd waste of time. From mhammond at skippinet.com.au Sat Dec 3 07:11:28 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 3 Dec 2005 17:11:28 +1100 Subject: [python-win32] using InvokeTypes? In-Reply-To: Message-ID: > There Mark Hammond writes: > "Sadly there is no easy way to explicitly specify the exact variant > type, other than using InvokeTypes. " > > So now I would like to throw an eye at InvokeTypes, been searching a > bit, but only found non-commented InvokeTypes. How do I find the > values of input/output lists, flags and so on. I'm afraid it is poorly documented, as you have discovered. InvokeTypes is very similar to the Invoke method, which is very similar to the IDispatch Invoke method. The primary documentation for that can be found at MSDN. There are 2 args that do need special documentation though: resultTypeDesc and typeDesc. resultTypeDesc describes the return value of the function, and is a tuple of (type_id, flags). typeDesc describes the type of each parameters, and is a list of the same (type_id, flags) tuple. type_id is a valid "variant type" constant (eg, VT_I4 | VT_ARRAY, VT_DATE, etc - see VARIANT at MSDN). flags is one of the PARAMFLAG constants (eg, PARAMFLAG_FIN, PARAMFLAG_FOUT, etc - see PARAMFLAG at MSDN). Eg, an example from the makepy generated file for Word: class Cells(DispatchBaseClass): ... def SetWidth(self, ColumnWidth=..., RulerStyle=...): return self._oleobj_.InvokeTypes(202, LCID, 1, (24, 0), ((4, 1), (3, 1)),...) The interesting bits are: resultTypeDesc: (24, 0) - (VT_VOID, ) typeDesc: ((4, 1), (3, 1)) - ((VT_R4, PARAMFLAG_FIN), (VT_I4, PARAMFLAG_FIN)) So, in this example, the function returns no value, and takes 2 "in" params - ColumnWidth is a float, and RulerStule is a short int. Hope this helps (I've also added something based on the above to the documentation...) Mark From sdb1031 at gmail.com Sat Dec 3 20:43:38 2005 From: sdb1031 at gmail.com (Stephen Briley) Date: Sat, 3 Dec 2005 14:43:38 -0500 Subject: [python-win32] os.popen4 and spaces in the directory name Message-ID: <74adb8df0512031143q2dceb2f7n6d1ba7a3ef7bee3d@mail.gmail.com> Hi all, I would like to run a program via the os.popen (or similar) commands. However, the path to the executable that I would like to run contains spaces (e.g. C:\program files\some directory\engine\theexe.exe). The python syntax that I am using is as follows: >>> os.popen4("C:\program files\some directory\engine\theexe.exe")[1].read() When I try to run it, I get the following message: "'C:\\program' is not recognized as an internal or external command,\noperable program or batch file.\n" So, the space for "program files" is messing it up. I thought that I could get around that by using progra~1: >>> os.popen4("C:\progra~1\some directory\engine\theexe.exe")[1].read() When I try to run it, I get the following message: "'C:\\progra~1\\some' is not recognized as an internal or external command,\noperable program or batch file.\n This time, it doesn't like the directory named "some directory". Is there any way around this? The command runs fine if I open up a Windows command prompt and specify the full directory path to the exe. I am using python 2.4 on a Windows 2003 server. I am also running this command on Windows 2003 server. Thanks, Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051203/51057ca1/attachment.html From mc at mclaveau.com Sun Dec 4 18:49:41 2005 From: mc at mclaveau.com (Michel Claveau) Date: Sun, 4 Dec 2005 18:49:41 +0100 Subject: [python-win32] os.popen4 and spaces in the directory name References: <74adb8df0512031143q2dceb2f7n6d1ba7a3ef7bee3d@mail.gmail.com> Message-ID: <001001c5f8fb$1ca43350$0701a8c0@PORTABLES> Hi ! Try : data=os.popen4('C:\\"program files"\\"some directory"\\engine\\theexe.exe')[1].read() @-salutations Michel Claveau From sjmachin at lexicon.net Sun Dec 4 21:55:33 2005 From: sjmachin at lexicon.net (John Machin) Date: Mon, 05 Dec 2005 07:55:33 +1100 Subject: [python-win32] os.popen4 and spaces in the directory name In-Reply-To: <74adb8df0512031143q2dceb2f7n6d1ba7a3ef7bee3d@mail.gmail.com> References: <74adb8df0512031143q2dceb2f7n6d1ba7a3ef7bee3d@mail.gmail.com> Message-ID: <439357C5.90000@lexicon.net> Stephen Briley wrote: > Hi all, > > I would like to run a program via the os.popen (or similar) commands. > However, the path to the executable that I would like to run contains > spaces (e.g. C:\program files\some directory\engine\theexe.exe). The > python syntax that I am using is as follows: > > >>> os.popen4("C:\program files\some > directory\engine\theexe.exe")[1].read() > > When I try to run it, I get the following message: > "'C:\\program' is not recognized as an internal or external > command,\noperable program or batch file.\n" You have more than one problem. Firstly, as you have detected, the Windows command interpreter's parser has to be steered away from the spaces. You do this by using quotes (so-called double quotes, not apostrophes aka single quotes). Secondly, you need to either double your backslashes or use raw strings; otherwise the \t in \theexe will be treated by Python as a TAB, not as two characters \ and t, and similarly with \n \r \f etc etc. So: r'"C:\program files\some directory\engine\theexe.exe"' > [snip] > > This time, it doesn't like the directory named "some directory". Is > there any way around this? The command runs fine if I open up a Windows > command prompt and specify the full directory path to the exe. Thirdly, there seems to be some perceptual problem here. I don't see how it could "run fine" if you type the same guff directly at the command prompt. It's the same program processing your input. Example (Windows XP, SP 2): C:\junk>c:\program files\textpad 4\textpad.exe 'c:\program' is not recognized as an internal or external command, operable program or batch file. C:\junk>"c:\program files\textpad 4\textpad.exe" [works OK] > I am > using python 2.4 on a Windows 2003 server. I am also running this > command on Windows 2003 server. > Fourthly, this mailing list is for discussion of Mark Hammond's python-win32 aka win32all package. news:com.lang.python is more appropriate and would give you a wider audience. Cheers, John From jbauer at rubic.com Mon Dec 5 16:15:58 2005 From: jbauer at rubic.com (Jeff Bauer) Date: Mon, 05 Dec 2005 09:15:58 -0600 Subject: [python-win32] win32 meta-topic Message-ID: <439459AE.5010802@rubic.com> > this mailing list is for discussion of Mark Hammond's > python-win32 aka win32all package. news:com.lang.python > is more appropriate and would give you a wider audience. I occasionally see this kind of reminder here, but it's not obvious from the name of mailing list, nor it's description on http://mail.python.org/mailman/listinfo that discussions should be restricted to questions regarding the win32all package. I'm not proposing that the charter be changed, just noting that it's not a case of TOOWTDI. -- Jeff Bauer http://serpentaddiction.blogspot.com Rubicon, Inc. http://www.rubic.com From tim.golden at viacom-outdoor.co.uk Mon Dec 5 16:27:39 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon, 5 Dec 2005 15:27:39 -0000 Subject: [python-win32] win32 meta-topic Message-ID: <9A28C052FF32734DACB0A288A3533991044D23C9@vogbs009.gb.vo.local> [Jeff Bauer] > > this mailing list is for discussion of Mark Hammond's > > python-win32 aka win32all package. news:com.lang.python > > is more appropriate and would give you a wider audience. >I occasionally see this kind of reminder here, but it's >not obvious from the name of mailing list For my part, regardless of the original intention of the list (and I've no idea what it was), I see this list as a forum for things which are more specific to win32, and which therefore might find a more finely-tuned audience, or which might be beyond the scope of many on c.l.py. Obviously, working with Python on win32 is often synonymous with Mark H's pywin32 package, but it doesn't have to be (and Thomas H's ctypes brings another avenue of possibilities). 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 tim.golden at viacom-outdoor.co.uk Mon Dec 5 16:42:18 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon, 5 Dec 2005 15:42:18 -0000 Subject: [python-win32] win32 meta-topic Message-ID: <9A28C052FF32734DACB0A288A3533991044D23CA@vogbs009.gb.vo.local> -----Original Message----- From: python-win32-bounces+tim.golden=viacom-outdoor.co.uk at python.org [mailto:python-win32-bounces+tim.golden=viacom-outdoor.co.uk at python.org] On Behalf Of Tim Golden Sent: 05 December 2005 15:28 To: python-win32 at python.org Subject: Re: [python-win32] win32 meta-topic [Jeff Bauer] > > this mailing list is for discussion of Mark Hammond's > > python-win32 aka win32all package. news:com.lang.python > > is more appropriate and would give you a wider audience. >I occasionally see this kind of reminder here, but it's >not obvious from the name of mailing list And, in fact, this appears to be the post which announced this list, and it doesn't suggest that it's limited to pywin32 (win32all as was): http://groups.google.com/group/comp.lang.python/msg/d168af9b981f38ba 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 justinjohnson at gmail.com Mon Dec 5 18:19:38 2005 From: justinjohnson at gmail.com (Justin Johnson) Date: Mon, 5 Dec 2005 11:19:38 -0600 Subject: [python-win32] Using signal handlers in a Windows Service Message-ID: <94a776e70512050919y524f054ep7671bd0fb9b7495d@mail.gmail.com> I'm trying to setup an application that runs as a Windows service to rotate logs upon receiving a certain signal. Whenever I try to do this I get the following error. Exception in TestService.SvcStart: signal only works in main thread Attached is a very trimmed down example. To run the example and see the error message, do the following. 1. In one DOS window run PYTHONHOME\Lib\site-packages\win32\lib\win32traceutil.py to begin collecting trace output. 2. In a separate DOS window run "python tsvc.py --username domain\user --password yourpassword --startup auto install" using your own user and password. 3. Using Start > Control Panel > Administrative Tools > Services, modify the service properties, modifying the user and password again (even though you already specified them) and click OK. Accept any prompts about granting the appropriate rights to run as a service. 4. Run "net start tsvc" 5. Observe the error in the win32traceutil window. I realize this is a known problem but am unsure how to get around it to make sure my log rotation works when receiving the signal. Does anyone have any ideas on how to get around this limitation? Thanks. Justin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051205/d48aca3f/attachment.html -------------- next part -------------- import win32serviceutil import win32service import sys import os SVC_NAME = "tsvc" SVC_DISPLAY_NAME = "Test Service" class TestService(win32serviceutil.ServiceFramework): _svc_name_ = SVC_NAME _svc_display_name_ = SVC_DISPLAY_NAME def SvcDoRun(self): ## Import inside the method, so we redirect all output ## to the trace output collector. If you need to debug this service, ## run win32traceutil.py as a script. It will receive all output from ## this service. import win32traceutil try: import signal SIGUSR1 = 10 # Windows doesn't care what the number is def rotateLog(signal, frame): pass signal.signal(SIGUSR1, rotateLog) except Exception, e: print "Exception in TestService.SvcStart:", str(e) def SvcStop(self): ## See above for why we import this. import win32traceutil try: self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) except Exception, e: print "Exception in TestService.SvcStop:", str(e) if __name__ == '__main__': win32serviceutil.HandleCommandLine(TestService) From tim.golden at viacom-outdoor.co.uk Mon Dec 5 18:27:45 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon, 5 Dec 2005 17:27:45 -0000 Subject: [python-win32] Using signal handlers in a Windows Service Message-ID: <9A28C052FF32734DACB0A288A3533991044D23CC@vogbs009.gb.vo.local> [Justin Johnson] > I'm trying to setup an application that runs as a > Windows service to rotate logs upon receiving a certain > signal. Whenever I try to do this I get the following error. > Exception in TestService.SvcStart: signal only works in main thread Is there some reason you have to use Unix-style signals? If you were to use win32 events (using, say, the win32event module from pywin32) I suspect it would bypass the problem altogether. 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 justinjohnson at gmail.com Mon Dec 5 18:42:12 2005 From: justinjohnson at gmail.com (Justin Johnson) Date: Mon, 5 Dec 2005 11:42:12 -0600 Subject: [python-win32] Using signal handlers in a Windows Service In-Reply-To: <9A28C052FF32734DACB0A288A3533991044D23CC@vogbs009.gb.vo.local> References: <9A28C052FF32734DACB0A288A3533991044D23CC@vogbs009.gb.vo.local> Message-ID: <94a776e70512050942p3fd53815qbf107c9037a1cf60@mail.gmail.com> I was trying to keep things consistent with UNIX, but I suppose there's no reason I have to do things that way. Thanks. On 12/5/05, Tim Golden wrote: > > [Justin Johnson] > > I'm trying to setup an application that runs as a > > Windows service to rotate logs upon receiving a certain > > signal. Whenever I try to do this I get the following error. > > > Exception in TestService.SvcStart: signal only works in main > thread > > Is there some reason you have to use Unix-style signals? If you > were to use win32 events (using, say, the win32event module from > pywin32) I suspect it would bypass the problem altogether. > > 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 > ________________________________________________________________________ > _______________________________________________ > 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/20051205/1fc057cb/attachment.html From sjmachin at lexicon.net Mon Dec 5 21:27:52 2005 From: sjmachin at lexicon.net (John Machin) Date: Tue, 06 Dec 2005 07:27:52 +1100 Subject: [python-win32] win32 meta-topic In-Reply-To: <9A28C052FF32734DACB0A288A3533991044D23CA@vogbs009.gb.vo.local> References: <9A28C052FF32734DACB0A288A3533991044D23CA@vogbs009.gb.vo.local> Message-ID: <4394A2C8.8050504@lexicon.net> Tim Golden wrote: > > > -----Original Message----- > From: python-win32-bounces+tim.golden=viacom-outdoor.co.uk at python.org > [mailto:python-win32-bounces+tim.golden=viacom-outdoor.co.uk at python.org] > On Behalf Of Tim Golden > Sent: 05 December 2005 15:28 > To: python-win32 at python.org > Subject: Re: [python-win32] win32 meta-topic > > [Jeff Bauer] > > >>>this mailing list is for discussion of Mark Hammond's >>>python-win32 aka win32all package. news:com.lang.python >>>is more appropriate and would give you a wider audience. > > >>I occasionally see this kind of reminder here, but it's >>not obvious from the name of mailing list > > > And, in fact, this appears to be the post which > announced this list, and it doesn't suggest that > it's limited to pywin32 (win32all as was): > > http://groups.google.com/group/comp.lang.python/msg/d168af9b981f38ba > > TJG Thanks, Tim. Maxima mea culpa. I'll pull my head in :-) Does anyone have any suggestions on what advice to give (a) people who post from work via e-mail, engendering enormous disclaimers (b) possibly over-sensitive folk who are annoyed by (a)? Cheers, John From theller at python.net Mon Dec 5 21:50:51 2005 From: theller at python.net (Thomas Heller) Date: Mon, 05 Dec 2005 21:50:51 +0100 Subject: [python-win32] win32 meta-topic References: <9A28C052FF32734DACB0A288A3533991044D23CA@vogbs009.gb.vo.local> <4394A2C8.8050504@lexicon.net> Message-ID: John Machin writes: > Does anyone have any suggestions on what advice to give (a) people who > post from work via e-mail, engendering enormous disclaimers (b) possibly > over-sensitive folk who are annoyed by (a)? Give those (b) people advice to ignore it (be tolerant when receiving), and give the (a) people advice to convince their employers to remove (ot fix) the enormous disclaimers - most of the time they are nothing but silly. Or just don't do anything ;-). My 2 pence. Thomas From tim.golden at viacom-outdoor.co.uk Tue Dec 6 09:27:38 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue, 6 Dec 2005 08:27:38 -0000 Subject: [python-win32] win32 meta-topic Message-ID: <9A28C052FF32734DACB0A288A3533991044D23CE@vogbs009.gb.vo.local> [John Machin] [... snip intentions of python-win32 list ...] > Thanks, Tim. Maxima mea culpa. I'll pull my head in :-) > Does anyone have any suggestions on what advice to give (a) people who > post from work via e-mail, engendering enormous disclaimers (b) possibly > over-sensitive folk who are annoyed by (a)? Well, my feelings more-or-less mirror those of Thomas H elsewhere on this thread. Ignore them, trim them out when replying, sigh a little or laugh at their absurdity, and then get on with whatever the post was really about. Occasionally, people post on c.l.py to say that any company who sends out such disclaimers (*) needs its head examining. Fine, but there's just no real incentive for most companies to change their position. (*) or which doesn't support open-source software, or which uses Microsoft products, or which doesn't allow usenet access through the company firewall, or which... 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 Laurent.Dufrechou at free.fr Tue Dec 6 14:39:47 2005 From: Laurent.Dufrechou at free.fr (=?ISO-8859-1?Q?Laurent_Dufr=E9chou?=) Date: Tue, 06 Dec 2005 14:39:47 +0100 Subject: [python-win32] How to get win32com events .. in my main class? Message-ID: <439594A3.4040902@free.fr> Hello, I'm currently trying to use event from a win32 application using it's COM interface. To connect to the application I use: #main class class MyApp_InterfaceManager (Thread): ... def run (self): # First we initialize the COM libraries for current thread pythoncom.CoInitialize() #Then we connect to the app with event handling... self.app = DispatchWithEvents('MyApp',MyApp_AppEvents) #event class class MyApp_AppEvents: OnHalt: print "halt event..." >From here all is ok when the OnHalt event arrives the print is called. The problem I have is that I need that MyApp_AppEvents class knows the thread object to call a thread function when the event occurs(for example I need to toggle a flag) I've got no idea how to do that, as th event handler object is not member of the main class... Anyone has encoutered the problem? I've tryied to use getevents but with no result... Best regards, Laurent From amit_antebi at yahoo.com Tue Dec 6 12:18:16 2005 From: amit_antebi at yahoo.com (Amit Antebi) Date: Tue, 6 Dec 2005 13:18:16 +0200 Subject: [python-win32] python - visualbasic integration Message-ID: <20051206111750.8546F1E400C@bag.python.org> We want to combine Visual Basic with Python. GUI will be in VIsual basic. Computation Engine will be in python. Which architecture do you recommend: 1. COM - who will be client and who server, and why? 2. Python API - access the python from VB using the python API. 3. Is there another way? DLL? Python Embedding Things to consider: a. The computation engine will need to work with big amounts of memory, and we don't want to load them each time we access python. b. Debugging is important. For your recommendations I thank you, Amitay -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051206/87a477db/attachment.htm From samzinho at yahoo.com Tue Dec 6 19:16:14 2005 From: samzinho at yahoo.com (deborah r) Date: Tue, 6 Dec 2005 10:16:14 -0800 (PST) Subject: [python-win32] Problems running Python 2.1 and ArcView 9.1 Message-ID: <20051206181614.74288.qmail@web35410.mail.mud.yahoo.com> Hello all, I'm hoping some of you may be able to help me since I'm getting nowhere with ESRI tech support on this matter. I was trying to run very simple scripts in Python 2.1 (e.g., create a folder) but Python would crash every time. Someone at ESRI suggested I add the line: gp.SetProduct("ArcView") to one of my scripts and run it. It worked, except that now I am unable to use any of the tools in ArcToolbox that are scripts. If I try running one of them, Pythonwin will open the script for that particular tool and it hangs. Even if it finishes running, no output is created. Does anybody have a suggestion on how to fix this? I have done a complete uninstall of both Python and ArcView, deleted every sort of registry, but the problem persists... Thanks! Deborah __________________________________________ Yahoo! DSL ? Something to write home about. Just $16.99/mo. or less. dsl.yahoo.com From hand_sawyer at hotmail.com Tue Dec 6 19:43:06 2005 From: hand_sawyer at hotmail.com (Kevin Ceder) Date: Tue, 06 Dec 2005 10:43:06 -0800 Subject: [python-win32] Problems running Python 2.1 and ArcView 9.1 In-Reply-To: <20051206181614.74288.qmail@web35410.mail.mud.yahoo.com> Message-ID: Deborah, I've done quite a bit of work with Python and ArcGIS but have not run into this issue and have noticed a couple of things in the ArcGIS install, namely that ESRI does not to a full install of Python. It appears that the interpreter commandline help is not installed as well as the "this" module. If you haven't imported this module in the python interactive window you should give it a try. On all my ArcGIS installs I bypass the instal of Python 2.1 and install the latest version of Python and PythonWin. After those installs you need to make a couple of registry edits (info on this is avaiable on the ERSI support site) so that ArcGIS recognizes the Python install. If you can include the code that causes the issue I may ba able to provide some more help. Cheers, kevin >From: deborah r >To: python-win32 at python.org >Subject: [python-win32] Problems running Python 2.1 and ArcView 9.1 >Date: Tue, 6 Dec 2005 10:16:14 -0800 (PST) > >Hello all, > >I'm hoping some of you may be able to help me since >I'm getting nowhere with ESRI tech support on this >matter. > >I was trying to run very simple scripts in Python 2.1 >(e.g., create a folder) but Python would crash every >time. Someone at ESRI suggested I add the line: > >gp.SetProduct("ArcView") > >to one of my scripts and run it. It worked, except >that now I am unable to use any of the tools in >ArcToolbox that are scripts. If I try running one of >them, Pythonwin will open the script for that >particular tool and it hangs. Even if it finishes >running, no output is created. > >Does anybody have a suggestion on how to fix this? I >have done a complete uninstall of both Python and >ArcView, deleted every sort of registry, but the >problem persists... > >Thanks! > >Deborah > > > >__________________________________________ >Yahoo! DSL – Something to write home about. >Just $16.99/mo. or less. >dsl.yahoo.com > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 From rwupole at msn.com Tue Dec 6 20:31:02 2005 From: rwupole at msn.com (Roger Upole) Date: Tue, 6 Dec 2005 14:31:02 -0500 Subject: [python-win32] Re: How to get win32com events .. in my main class? Message-ID: The class instance that's passed to your dispatch class methods is actually the original COM object, so you ought to be able to set an attribute on it to communicate that the event was called. In other words, in your OnHalt method, add something like self.OnHaltCalled=True, and then you can check for it in your MyApp_InterfaceManager instance with self.app.OnHaltCalled hth Roger "Ask the ToeCutter - HE knows who I am !" From bgailer at alum.rpi.edu Tue Dec 6 22:53:49 2005 From: bgailer at alum.rpi.edu (bob) Date: Tue, 06 Dec 2005 13:53:49 -0800 Subject: [python-win32] python - visualbasic integration In-Reply-To: <20051206111750.8546F1E400C@bag.python.org> References: <20051206111750.8546F1E400C@bag.python.org> Message-ID: <7.0.0.16.0.20051206134957.0233ada8@alum.rpi.edu> At 03:18 AM 12/6/2005, Amit Antebi wrote: >We want to combine Visual Basic with Python. >GUI will be in VIsual basic. >Computation Engine will be in python. >Which architecture do you recommend: > >1. COM - who will be client and who server, and why? >2. Python API - access the python from VB using the python API. >3. Is there another way? DLL? Python Embedding > >Things to consider: > > * The computation engine will need to work with big amounts of > memory, and we don't want to load them each time we access python. > * Debugging is important. Heres how I've done that. I run a Python program either from a command prompt (or IDE) for interactive debugging purposes, or as a background process under scheduled tasks. The program watches for tasks from the GUI using sockets or some more sophisticated layer on top of sockets, XMLRPC being one example, or periodically queries a database or file to see if there is something to do. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051206/1a077e57/attachment.html From mhammond at skippinet.com.au Tue Dec 6 23:00:54 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 7 Dec 2005 09:00:54 +1100 Subject: [python-win32] python - visualbasic integration In-Reply-To: <20051206111750.8546F1E400C@bag.python.org> Message-ID: Certainly COM would work. In this case your VB EXE would use CreateObject to create a Python implemented object. In response to GUI events, the VB code can call Python methods and use the results. For debugging, you should find any of the professional IDE packages that support remote process debugging can cope with that - I use Komodo for that kind of thing... Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Amit Antebi Sent: Tuesday, 6 December 2005 10:18 PM To: python-win32 at python.org Subject: [python-win32] python - visualbasic integration We want to combine Visual Basic with Python. GUI will be in VIsual basic. Computation Engine will be in python. Which architecture do you recommend: 1. COM - who will be client and who server, and why? 2. Python API - access the python from VB using the python API. 3. Is there another way? DLL? Python Embedding Things to consider: 1.. The computation engine will need to work with big amounts of memory, and we don't want to load them each time we access python. 2.. Debugging is important. For your recommendations I thank you, Amitay -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051207/82f6486d/attachment.htm From cappy2112 at gmail.com Wed Dec 7 03:19:27 2005 From: cappy2112 at gmail.com (Tony C) Date: Tue, 6 Dec 2005 18:19:27 -0800 Subject: [python-win32] Python-win32 Digest, Vol 33, Issue 7 In-Reply-To: References: Message-ID: <8249c4ac0512061819p352af2c7if3659919ea0127f8@mail.gmail.com> >>Certainly COM would work. In this case your VB EXE would use CreateObject >>to create a Python implemented object. As what type of Python Object? I have the VB6 ide open, and the references Browser as well, there is no generic Python object to include into a VB project. Which means one would have to create a Python COM server and Type library first, before being able to reference it from the VB IDE. Even though I have Python Programming in Win32, I'm not sure what needs to be done to make a minimal Python COM server that can be called from VB. Also, creating a type library requires using Visual C- which isn't a problem, it's the language of the IDL required to create the TLB that I don't udnerstand. Message: 7 Date: Wed, 7 Dec 2005 09:00:54 +1100 From: "Mark Hammond" Subject: Re: [python-win32] python - visualbasic integration To: "Amit Antebi" , Message-ID: Content-Type: text/plain; charset="us-ascii" Certainly COM would work. In this case your VB EXE would use CreateObject to create a Python implemented object. In response to GUI events, the VB code can call Python methods and use the results. For debugging, you should find any of the professional IDE packages that support remote process debugging can cope with that - I use Komodo for that kind of thing... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051206/b965e137/attachment.html From mhammond at skippinet.com.au Wed Dec 7 04:00:28 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 7 Dec 2005 14:00:28 +1100 Subject: [python-win32] Python-win32 Digest, Vol 33, Issue 7 In-Reply-To: <8249c4ac0512061819p352af2c7if3659919ea0127f8@mail.gmail.com> Message-ID: > >>Certainly COM would work. In this case your VB EXE would use CreateObject > >>to create a Python implemented object. > As what type of Python Object? > I have the VB6 ide open, and the references Browser as well, > there is no generic Python object to include into a VB project. > Which means one would have to create a Python COM server > and Type library first, before being able to reference it > from the VB IDE. Actually, you don't need to create a typelib. Just register the PythonCOM server, and have VB use CreateObject with the ProgID. All vars will need to be declared as "object", and you wont get auto-complete type features, but it will work. VB supports late-binding. > Even though I have Python Programming in Win32, I'm not sure what > needs to be done to make a minimal Python COM server that can be > called from VB. Pages 221 and 222 have an example using VBA (ie, the VB embedded in MSOffice apps) > Also, creating a type library requires using Visual C- which isn't a > problem, it's the language of the IDL required to create the TLB that > I don't udnerstand. You should be able to avoid TLBs - certainly to get started... Mark From steve at holdenweb.com Wed Dec 7 08:55:17 2005 From: steve at holdenweb.com (Steve Holden) Date: Wed, 07 Dec 2005 07:55:17 +0000 Subject: [python-win32] *** Spam *** Re: Python-win32 Digest, Vol 33, Issue 7 In-Reply-To: References: Message-ID: <43969565.9030505@holdenweb.com> Mark Hammond wrote: >>>>Certainly COM would work. In this case your VB EXE would use > > CreateObject > >>>>to create a Python implemented object. > > >>As what type of Python Object? > > >>I have the VB6 ide open, and the references Browser as well, >>there is no generic Python object to include into a VB project. > > >>Which means one would have to create a Python COM server >>and Type library first, before being able to reference it >>from the VB IDE. > > > Actually, you don't need to create a typelib. Just register the PythonCOM > server, and have VB use CreateObject with the ProgID. All vars will need to > be declared as "object", and you wont get auto-complete type features, but > it will work. VB supports late-binding. > > > >>Even though I have Python Programming in Win32, I'm not sure what >>needs to be done to make a minimal Python COM server that can be >>called from VB. > > > Pages 221 and 222 have an example using VBA (ie, the VB embedded in MSOffice > apps) > > >>Also, creating a type library requires using Visual C- which isn't a >>problem, it's the language of the IDL required to create the TLB that >>I don't udnerstand. > > > You should be able to avoid TLBs - certainly to get started... > I'll just underline Mark's encouraging words, since you appear to be a little hesitant about diving in. I had to write a credit-card processor for a web application one of my clients wanted, and I found it was relatively easy to construct a Python COM server. Although the application was in VBScript I created several test programs using VB, none of which had any problems manipulating the Python COM server. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ From Laurent.Dufrechou at free.fr Wed Dec 7 11:35:08 2005 From: Laurent.Dufrechou at free.fr (=?ISO-8859-1?Q?Laurent_Dufr=E9chou?=) Date: Wed, 07 Dec 2005 11:35:08 +0100 Subject: [python-win32] How to get win32com events .. in my main class? In-Reply-To: References: Message-ID: <4396BADC.4020204@free.fr> Thank you a lot ! That just work as you said :) coool Roger Upole wrote: >The class instance that's passed to your dispatch class >methods is actually the original COM object, so you >ought to be able to set an attribute on it to communicate >that the event was called. In other words, in your OnHalt >method, add something like self.OnHaltCalled=True, >and then you can check for it in your MyApp_InterfaceManager >instance with self.app.OnHaltCalled > > hth > Roger > > "Ask the ToeCutter - HE knows who I am !" >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > > > From cappy2112 at gmail.com Thu Dec 8 05:24:53 2005 From: cappy2112 at gmail.com (Tony C) Date: Wed, 7 Dec 2005 20:24:53 -0800 Subject: [python-win32] Python-win32 Digest, Vol 33, Issue 7 In-Reply-To: References: <8249c4ac0512061819p352af2c7if3659919ea0127f8@mail.gmail.com> Message-ID: <8249c4ac0512072024u4c3bbef0v182cf995260c6998@mail.gmail.com> Ok, I'm about 90% there now I've used the Simple.py from page 213, because there is less involved. when I run it- I see the registration messages. All is good so far. I made one tiny change, related to the call to CreateGuid() import pythoncom class PythonCOMServer: _public_methods_ = ['pyCOMSplit'] _reg_progid_= "PythonCOMDemo" _reg_clsid_= pythoncom.CreateGuid() def pyCOMSplit(StringFromVB): from string import split if self.StringFromVB != None: return split(self.StringFromVB ) if __name__ == '__main__': print"Registering COM server" import win32com.server.register win32com.server.register.UseCommandLine( PythonCOMServer ) When I try sending a string from the VB side, Type Error; str() takes at most 1 arguments, two given I see no explicit calls to str. Here's the VB side Option Explicit Private Sub cmdToPython_Click() Dim Python As Object Dim FromPython As Variant Set Python = CreateObject("PythonCOMDemo") FromPython = Python.pyCOMSplit("This string to Python") txtFromPython = FromPython End Sub This call, is what is causing the runtime exception Python.pyCOMSplit("This string to Python") What am I doing wrong? thanks On 12/6/05, Mark Hammond wrote: > > > >>Certainly COM would work. In this case your VB EXE would use > CreateObject > > >>to create a Python implemented object. > > > As what type of Python Object? > > > I have the VB6 ide open, and the references Browser as well, > > there is no generic Python object to include into a VB project. > > > Which means one would have to create a Python COM server > > and Type library first, before being able to reference it > > from the VB IDE. > > Actually, you don't need to create a typelib. Just register the PythonCOM > server, and have VB use CreateObject with the ProgID. All vars will need > to > be declared as "object", and you wont get auto-complete type features, but > it will work. VB supports late-binding. > > > > Even though I have Python Programming in Win32, I'm not sure what > > needs to be done to make a minimal Python COM server that can be > > called from VB. > > Pages 221 and 222 have an example using VBA (ie, the VB embedded in > MSOffice > apps) > > > Also, creating a type library requires using Visual C- which isn't a > > problem, it's the language of the IDL required to create the TLB that > > I don't udnerstand. > > You should be able to avoid TLBs - certainly to get started... > > Mark > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051207/49fc612d/attachment.html From mc at mclaveau.com Thu Dec 8 06:45:02 2005 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 8 Dec 2005 06:45:02 +0100 Subject: [python-win32] Python-win32 Digest, Vol 33, Issue 7 References: <8249c4ac0512061819p352af2c7if3659919ea0127f8@mail.gmail.com> <8249c4ac0512072024u4c3bbef0v182cf995260c6998@mail.gmail.com> Message-ID: <000c01c5fbba$8a2cfc60$0701a8c0@PORTABLES> Hi! Your function pyCOMSplit is a method of the class PythonCOMServer. Please, add'self', like this : def pyCOMSplit(self, StringFromVB): It's all Michel Claveau From mhammond at skippinet.com.au Thu Dec 8 06:47:49 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 8 Dec 2005 16:47:49 +1100 Subject: [python-win32] Python-win32 Digest, Vol 33, Issue 7 In-Reply-To: <8249c4ac0512072024u4c3bbef0v182cf995260c6998@mail.gmail.com> Message-ID: CreateGuid() will create a new GUID each time it is registered. That will end up creating "turds" in your registry. Generate the GUID once and hard-code it in, as the samples do. Your main problem is that you forgot the "self" param in the method. Cheers, Mark -----Original Message----- From: Tony C [mailto:cappy2112 at gmail.com] Sent: Thursday, 8 December 2005 3:25 PM To: Mark Hammond Cc: python-win32 at python.org Subject: Re: Python-win32 Digest, Vol 33, Issue 7 Ok, I'm about 90% there now I've used the Simple.py from page 213, because there is less involved. when I run it- I see the registration messages. All is good so far. I made one tiny change, related to the call to CreateGuid() import pythoncom class PythonCOMServer: _public_methods_ = ['pyCOMSplit'] _reg_progid_= "PythonCOMDemo" _reg_clsid_= pythoncom.CreateGuid() def pyCOMSplit(StringFromVB): from string import split if self.StringFromVB != None: return split(self.StringFromVB ) if __name__ == '__main__': print"Registering COM server" import win32com.server.register win32com.server.register.UseCommandLine( PythonCOMServer ) When I try sending a string from the VB side, Type Error; str() takes at most 1 arguments, two given I see no explicit calls to str. Here's the VB side Option Explicit Private Sub cmdToPython_Click() Dim Python As Object Dim FromPython As Variant Set Python = CreateObject("PythonCOMDemo") FromPython = Python.pyCOMSplit("This string to Python") txtFromPython = FromPython End Sub This call, is what is causing the runtime exception Python.pyCOMSplit ("This string to Python") What am I doing wrong? thanks On 12/6/05, Mark Hammond < mhammond at skippinet.com.au> wrote: > >>Certainly COM would work. In this case your VB EXE would use CreateObject > >>to create a Python implemented object. > As what type of Python Object? > I have the VB6 ide open, and the references Browser as well, > there is no generic Python object to include into a VB project. > Which means one would have to create a Python COM server > and Type library first, before being able to reference it > from the VB IDE. Actually, you don't need to create a typelib. Just register the PythonCOM server, and have VB use CreateObject with the ProgID. All vars will need to be declared as "object", and you wont get auto-complete type features, but it will work. VB supports late-binding. > Even though I have Python Programming in Win32, I'm not sure what > needs to be done to make a minimal Python COM server that can be > called from VB. Pages 221 and 222 have an example using VBA (ie, the VB embedded in MSOffice apps) > Also, creating a type library requires using Visual C- which isn't a > problem, it's the language of the IDL required to create the TLB that > I don't udnerstand. You should be able to avoid TLBs - certainly to get started... Mark From John.Gooch at echostar.com Thu Dec 8 18:22:17 2005 From: John.Gooch at echostar.com (Gooch, John) Date: Thu, 8 Dec 2005 10:22:17 -0700 Subject: [python-win32] ADSI and LDAP Searches Message-ID: <73D02FE1C9E959448BBC412590B56217010B8DCA@MER2-EXCHA2.echostar.com> I am trying to get my Python script to search Active Directory for users with a certain login name and then have it return their adspath attribute. Previously, I had a working script that used Tim Golden's active_directory module, but since the more recent round of NT Server patches, it no longer works, so now I am trying to make a work around to this issue. Here is what I have that is working ( in my test script ): ________________________________ import win32com.client username = "John.Gooch" adsi = win32com.client.Dispatch('ADsNameSpaces') ldap = adsi.getobject('','LDAP:') DSO = ldap.OpenDSObject( "LDAP://MER2-ECHDC2.echostar.com","","", 1) _________________________________ It works up to here, so now I assume I am connected to Active Direcory and can now run an LDAP-style search: _________________________________ DSO.execute(";(cn=*);adspath;top") _________________________________ Ok,no go on that line( throws error "AttributeError: .execute" , but then I am complete guessing the syntax based upon an old Perl script I had that used to do this job. Does anyone have a working example of searching Active Directory? Of you course you can put in made up domain/server names where necessary. Thank You, John A. Gooch Systems Administrator IT - Tools EchoStar Satellite L.L.C. 9601 S. Meridian Blvd. Englewood, CO 80112 Desk: 720-514-5708 From cappy2112 at gmail.com Thu Dec 8 19:24:31 2005 From: cappy2112 at gmail.com (Tony C) Date: Thu, 8 Dec 2005 10:24:31 -0800 Subject: [python-win32] Python-win32 Digest, Vol 33, Issue 7 In-Reply-To: References: <8249c4ac0512072024u4c3bbef0v182cf995260c6998@mail.gmail.com> Message-ID: <8249c4ac0512081024t24e5b736oe8774cb30d6b3274@mail.gmail.com> >>Your main problem is that you forgot the "self" param in the method. Actually, I started out *with* the self as described in the book. I removed it because the error message implied two args were being passed instead of one, not vice-versa. What do you suggest? Is there any chance that the previous turds in the reg are causing a problem? I will try to remove them all, if I can find them Cheers, > > Mark > -----Original Message----- > From: Tony C [mailto:cappy2112 at gmail.com] > Sent: Thursday, 8 December 2005 3:25 PM > To: Mark Hammond > Cc: python-win32 at python.org > Subject: Re: Python-win32 Digest, Vol 33, Issue 7 > > > Ok, I'm about 90% there now > > I've used the Simple.py from page 213, because there is less involved. > when I run it- I see the registration messages. All is good so far. > I made one tiny change, related to the call to CreateGuid() > > import pythoncom > > class PythonCOMServer: > > _public_methods_ = ['pyCOMSplit'] > _reg_progid_= "PythonCOMDemo" > _reg_clsid_= pythoncom.CreateGuid() > > def pyCOMSplit(StringFromVB): > from string import split > if self.StringFromVB != None: > return split(self.StringFromVB ) > > > if __name__ == '__main__': > print"Registering COM server" > import win32com.server.register > win32com.server.register.UseCommandLine( PythonCOMServer ) > > > When I try sending a string from the VB side, > Type Error; str() takes at most 1 arguments, two given > > I see no explicit calls to str. > > > Here's the VB side > > > Option Explicit > > Private Sub cmdToPython_Click() > > > Dim Python As Object > Dim FromPython As Variant > > Set Python = CreateObject("PythonCOMDemo") > > FromPython = Python.pyCOMSplit("This string to Python") > > txtFromPython = FromPython > > End Sub > > > This call, is what is causing the runtime exception > Python.pyCOMSplit ("This string to Python") > > > What am I doing wrong? > > thanks > > > > > > > > > On 12/6/05, Mark Hammond < mhammond at skippinet.com.au> wrote: > > >>Certainly COM would work. In this case your VB EXE would use > CreateObject > > >>to create a Python implemented object. > > > As what type of Python Object? > > > I have the VB6 ide open, and the references Browser as well, > > there is no generic Python object to include into a VB project. > > > Which means one would have to create a Python COM server > > and Type library first, before being able to reference it > > from the VB IDE. > > Actually, you don't need to create a typelib. Just register the PythonCOM > server, and have VB use CreateObject with the ProgID. All vars will need > to > be declared as "object", and you wont get auto-complete type features, but > it will work. VB supports late-binding. > > > > Even though I have Python Programming in Win32, I'm not sure what > > needs to be done to make a minimal Python COM server that can be > > called from VB. > > Pages 221 and 222 have an example using VBA (ie, the VB embedded in > MSOffice > apps) > > > Also, creating a type library requires using Visual C- which isn't a > > problem, it's the language of the IDL required to create the TLB that > > I don't udnerstand. > > You should be able to avoid TLBs - certainly to get started... > > Mark > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051208/fffa3bd2/attachment.htm From cappy2112 at gmail.com Thu Dec 8 21:38:58 2005 From: cappy2112 at gmail.com (Tony C) Date: Thu, 8 Dec 2005 12:38:58 -0800 Subject: [python-win32] Python-win32 Digest, Vol 33, Issue 7 In-Reply-To: <8249c4ac0512081024t24e5b736oe8774cb30d6b3274@mail.gmail.com> References: <8249c4ac0512072024u4c3bbef0v182cf995260c6998@mail.gmail.com> <8249c4ac0512081024t24e5b736oe8774cb30d6b3274@mail.gmail.com> Message-ID: <8249c4ac0512081238i5d21b800xe6df6c2122e72f94@mail.gmail.com> Ok, I've removed all of the references to my Class nam in the Reg- there were a lot, put in a static GUID, added self back to the arg list, and now the call to the split function works. There seems to be a problem on the VB side now, related to the types. Mark said all vars in VB need to be objects, and that's another place where I went wrong. Will change my variants to Objects. On 12/8/05, Tony C wrote: > > > > >>Your main problem is that you forgot the "self" param in the method. > > > Actually, I started out *with* the self as described in the book. > I removed it because the error message implied two args were being passed > instead of one, not vice-versa. > > What do you suggest? > Is there any chance that the previous turds in the reg are causing a > problem? > > I will try to remove them all, if I can find them > > > Cheers, > > > > Mark > > -----Original Message----- > > From: Tony C [mailto:cappy2112 at gmail.com] > > Sent: Thursday, 8 December 2005 3:25 PM > > To: Mark Hammond > > Cc: python-win32 at python.org > > Subject: Re: Python-win32 Digest, Vol 33, Issue 7 > > > > > > Ok, I'm about 90% there now > > > > I've used the Simple.py from page 213, because there is less involved. > > when I run it- I see the registration messages. All is good so far. > > I made one tiny change, related to the call to CreateGuid() > > > > import pythoncom > > > > class PythonCOMServer: > > > > _public_methods_ = ['pyCOMSplit'] > > _reg_progid_= "PythonCOMDemo" > > _reg_clsid_= pythoncom.CreateGuid() > > > > def pyCOMSplit(StringFromVB): > > from string import split > > if self.StringFromVB != None: > > return split(self.StringFromVB ) > > > > > > if __name__ == '__main__': > > print"Registering COM server" > > import win32com.server.register > > win32com.server.register.UseCommandLine( PythonCOMServer ) > > > > > > When I try sending a string from the VB side, > > Type Error; str() takes at most 1 arguments, two given > > > > I see no explicit calls to str. > > > > > > Here's the VB side > > > > > > Option Explicit > > > > Private Sub cmdToPython_Click() > > > > > > Dim Python As Object > > Dim FromPython As Variant > > > > Set Python = CreateObject("PythonCOMDemo") > > > > FromPython = Python.pyCOMSplit("This string to Python") > > > > txtFromPython = FromPython > > > > End Sub > > > > > > This call, is what is causing the runtime exception > > Python.pyCOMSplit ("This string to Python") > > > > > > What am I doing wrong? > > > > thanks > > > > > > > > > > > > > > > > > > On 12/6/05, Mark Hammond < mhammond at skippinet.com.au> wrote: > > > >>Certainly COM would work. In this case your VB EXE would use > > CreateObject > > > >>to create a Python implemented object. > > > > > As what type of Python Object? > > > > > I have the VB6 ide open, and the references Browser as well, > > > there is no generic Python object to include into a VB project. > > > > > Which means one would have to create a Python COM server > > > and Type library first, before being able to reference it > > > from the VB IDE. > > > > Actually, you don't need to create a typelib. Just register the > > PythonCOM > > server, and have VB use CreateObject with the ProgID. All vars will > > need to > > be declared as "object", and you wont get auto-complete type features, > > but > > it will work. VB supports late-binding. > > > > > > > Even though I have Python Programming in Win32, I'm not sure what > > > needs to be done to make a minimal Python COM server that can be > > > called from VB. > > > > Pages 221 and 222 have an example using VBA (ie, the VB embedded in > > MSOffice > > apps) > > > > > Also, creating a type library requires using Visual C- which isn't a > > > problem, it's the language of the IDL required to create the TLB that > > > I don't udnerstand. > > > > You should be able to avoid TLBs - certainly to get started... > > > > Mark > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051208/e851335a/attachment.htm From mhammond at skippinet.com.au Thu Dec 8 22:00:37 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 9 Dec 2005 08:00:37 +1100 Subject: [python-win32] ADSI and LDAP Searches In-Reply-To: <73D02FE1C9E959448BBC412590B56217010B8DCA@MER2-EXCHA2.echostar.com> Message-ID: Consider looking at the win32comext\adsi\demos directory - search.py has an example. This module exposes the ADSI interfaces "natively", rather than using IDispatch object. Mark > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of Gooch, John > Sent: Friday, 9 December 2005 4:22 AM > To: python-win32 at python.org > Subject: [python-win32] ADSI and LDAP Searches > > > I am trying to get my Python script to search Active Directory for users > with a certain login name and then have it return their adspath > attribute. Previously, I had a working script that used Tim Golden's > active_directory module, but since the more recent round of NT Server > patches, it no longer works, so now I am trying to make a work around to > this issue. > > Here is what I have that is working ( in my test script ): > > ________________________________ > import win32com.client > username = "John.Gooch" > > > adsi = win32com.client.Dispatch('ADsNameSpaces') > ldap = adsi.getobject('','LDAP:') > DSO = ldap.OpenDSObject( "LDAP://MER2-ECHDC2.echostar.com","","", 1) > _________________________________ > > It works up to here, so now I assume I am connected to Active Direcory > and can now run an LDAP-style search: > _________________________________ > DSO.execute(";(cn=*);adspath;top") > _________________________________ > > Ok,no go on that line( throws error "AttributeError: .execute" > , but then I am complete guessing the syntax based upon an old Perl > script I had that used to do this job. > > > Does anyone have a working example of searching Active Directory? Of you > course you can put in made up domain/server names where necessary. > > Thank You, > > > John A. Gooch > Systems Administrator > IT - Tools > EchoStar Satellite L.L.C. > 9601 S. Meridian Blvd. > Englewood, CO 80112 > Desk: 720-514-5708 > > > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From ggonzalez at austin.rr.com Fri Dec 9 02:57:18 2005 From: ggonzalez at austin.rr.com (George Gonzalez) Date: Thu, 08 Dec 2005 19:57:18 -0600 Subject: [python-win32] Using win32com to access uPNP Message-ID: <4398E47E.307@austin.rr.com> I had the same problem. I discovered that I needed to upgrade my router's firmware. This added an icon for my router in "network places." At this point though, double clicking on it gave me an error saying the "device you are currently trying to use is not currently available on your network" I then went through the network setup wizard. It all works now. Note that this will only work if your router is nPnP compatible. If it's not then you'll probably still get mappingPorts=None. Here's my python terminal output: >>> theNatter = win32com.client.Dispatch("HNetCfg.NATUPnP") >>> print theNatter >>> mappingPorts = theNatter.StaticPortMappingCollection >>> print mappingPorts > >>> mappingPorts.Add(1024, "TCP", 1024, "192.168.1.101", True, "IRC") >>> >>> listPorts(mappingPorts) 0: True FTP 21 TCP 192.168.1.100 21 1: False Telnet 23 TCP 192.168.1.0 23 2: False SMTP 25 TCP 192.168.1.0 25 3: False DNS 53 UDP 192.168.1.0 53 4: False TFTP 69 UDP 192.168.1.0 69 5: False finger 79 TCP 192.168.1.0 79 6: False HTTP 80 TCP 192.168.1.0 80 7: False POP3 110 TCP 192.168.1.0 110 8: False NNTP 119 TCP 192.168.1.0 119 9: False SNMP 161 UDP 192.168.1.0 161 10: True IRC 1024 TCP 192.168.1.101 1024 The original script is in the link below. The current version has a typo. You'll needed to change "mps[ii]" to "mappingPorts[ii]." http://icepick.info/python -George >I saw this on the internet & am having a similar problem - I think. I'm not a technical person, but have worked out that the script I am running errors ->"Object Required" when it reaches the first line that uses mappingports. > >Did you manage to fix this - if so please help! I have tried Microsoft & Netgear but nobody seems to want to help. > >Thank you, >Gavin > > >Your message: > > >>Hi -- >> >>I'm trying to use the interface in win32com to access the windows uPNP >>service, the code is as follows: >> >>import win32com.client >> >>theNatter = win32com.client.Dispatch("HNetCfg.NATUPnP") >> >>mappingPorts = theNatter.StaticPortMappingCollection >> >>At this point mappingPorts seems to contain the null object, so it would >>appear that theNatter doesn't have an attribute StaticPortMappingCollection >>though the msdn docs claim otherwise. >> >>Also, i notice there are a number of interfaces common to HNetCfg.dll and >>NATUPnP - how does the above code differntiate between them ? >> From tim.golden at viacom-outdoor.co.uk Fri Dec 9 09:31:19 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Fri, 9 Dec 2005 08:31:19 -0000 Subject: [python-win32] ADSI and LDAP Searches Message-ID: <9A28C052FF32734DACB0A288A3533991044D23E4@vogbs009.gb.vo.local> [Gooch, John] > I am trying to get my Python script to search > Active Directory for users with a certain login > name and then have it return their adspath attribute. > Previously, I had a working script that used Tim Golden's > active_directory module, but since the more recent round > of NT Server patches, it no longer works, so now I am > trying to make a work around to this issue. Could I just ask what problems arose, ie is there something I can do to help -- if not you, then any future users of the module? 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 rudy.schockaert at gmail.com Fri Dec 9 10:04:01 2005 From: rudy.schockaert at gmail.com (Rudy Schockaert) Date: Fri, 9 Dec 2005 10:04:01 +0100 Subject: [python-win32] Problem after running MakePy Message-ID: <60987dac0512090104q6492cc80w24336ffbe6aebf10@mail.gmail.com> I have a python program that does some things on Exchange mailboxes. I use the MAPI.Session object for this and create it like this: PythonWin 2.4.2 (#67, Oct 30 2005, 16:11:18) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2004 Mark Hammond (mhammond at skippinet.com.au) - see 'Help/About PythonWin' for further copyright information. >>> import win32com.client >>> MAPISession = win32com.client.Dispatch("MAPI.Session") >>> MAPISession.Logon() >>> for infostores in MAPISession.InfoStores: ... print infostores.Name ... Public Folders Mailbox - Rudy Schockaert >>> ---------------------- If I now use makepy to create a genpy for the CDO 1.21 library (MAPI.Session) I get the following result: PythonWin 2.4.2 (#67, Oct 30 2005, 16:11:18) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2004 Mark Hammond (mhammond at skippinet.com.au) - see 'Help/About PythonWin' for further copyright information. >>> import win32com.client >>> MAPISession = win32com.client.Dispatch("MAPI.Session") >>> MAPISession.Logon() >>> for infostores in MAPISession.InfoStores: ... print infostores.Name ... Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\lib\site-packages\win32com\gen_py\3FA7DEA7- 6438-101B-ACC1-00AA00423326x0x1x21.py", line 3039, in __getitem__ return self._get_good_object_(self._oleobj_.Invoke(*(21, LCID, 2, 1, item)), "Item") com_error: (-2147352565, 'Invalid index.', None, None) ---------------------- Am I doing something wrong? Forgetting something? Can someone explain this? Thanks in advance, Rudy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051209/81ddb028/attachment.htm From tim.golden at viacom-outdoor.co.uk Fri Dec 9 10:56:48 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Fri, 9 Dec 2005 09:56:48 -0000 Subject: [python-win32] Problem after running MakePy Message-ID: <9A28C052FF32734DACB0A288A3533991044D23E5@vogbs009.gb.vo.local> [Rudy Schockaert] > I have a python program that does some things on > Exchange mailboxes. I use the MAPI.Session object > for this and create it like this: > import win32com.client > MAPISession = win32com.client.Dispatch("MAPI.Session") > MAPISession.Logon() > for infostores in MAPISession.InfoStores: > print infostores.Name > If I now use makepy to create a genpy for the CDO 1.21 > library (MAPI.Session) I get the following result: [... snip ...] > Traceback (most recent call last): > File "", line 1, in ? > File "C:\Python24\lib\site-packages\win32com\gen_py\3FA7DEA7-6438-101B-ACC1-0 0AA00423326x0x1x21.py ", line 3039, in > __getitem__ > return self._get_good_object_(self._oleobj_.Invoke(*(21, LCID, 2, 1, item)), "Item") > com_error: (-2147352565, 'Invalid index.', None, None) OK, this is the quick get-you-working answer. For the longer answer, I'd have to look at the makepy-generated module and at the code for the DispatchBaseClass. It's almost certainly down to the fact that COM objects generally use 1-based indexing, while Python ones use 0-based. Do it this way: import win32com.client.gencache import EnsureDispatch MAPISession = EnsureDispatch ("MAPI.Session") MAPISession.Logon () for n in range (len (MAPISession.InfoStores)): # n will be 0, 1, 2, 3... while # InfoStores items are 1, 2, 3... # so add 1 to make up the difference store = MAPISession.InfoStores[1 + n] print store.Name 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 rudy.schockaert at gmail.com Fri Dec 9 15:31:20 2005 From: rudy.schockaert at gmail.com (Rudy Schockaert) Date: Fri, 9 Dec 2005 15:31:20 +0100 Subject: [python-win32] Problem after running MakePy In-Reply-To: <9A28C052FF32734DACB0A288A3533991044D23E5@vogbs009.gb.vo.local> References: <9A28C052FF32734DACB0A288A3533991044D23E5@vogbs009.gb.vo.local> Message-ID: <60987dac0512090631r594bb5afo15c449f3ec61187a@mail.gmail.com> This does indeed work. Is there a way to modify the generated code such tat it works with 1-based iterators instead of 0-based ones? I tried to modify the _getitem_ method by incrementing item before it executes return self._get_good_object_.... and then I get the correct list of Infostores, but directly after that I get another 'invalid index' error. On 12/9/05, Tim Golden wrote: > > [Rudy Schockaert] > > > I have a python program that does some things on > > Exchange mailboxes. I use the MAPI.Session object > > for this and create it like this: > > > import win32com.client > > MAPISession = win32com.client.Dispatch("MAPI.Session") > > MAPISession.Logon() > > for infostores in MAPISession.InfoStores: > > print infostores.Name > > > If I now use makepy to create a genpy for the CDO 1.21 > > library (MAPI.Session) I get the following result: > > [... snip ...] > > > Traceback (most recent call last): > > File "", line 1, in ? > > File > "C:\Python24\lib\site-packages\win32com\gen_py\3FA7DEA7-6438-101B-ACC1-0 > 0AA00423326x0x1x21.py ", line 3039, in > __getitem__ > > return self._get_good_object_(self._oleobj_.Invoke(*(21, LCID, 2, > 1, item)), "Item") > > com_error: (-2147352565, 'Invalid index.', None, None) > > OK, this is the quick get-you-working answer. For the longer answer, > I'd have to look at the makepy-generated module and at the code > for the DispatchBaseClass. It's almost certainly down to the fact > that COM objects generally use 1-based indexing, while Python > ones use 0-based. > > Do it this way: > > > import win32com.client.gencache import EnsureDispatch > > MAPISession = EnsureDispatch ("MAPI.Session") > MAPISession.Logon () > for n in range (len (MAPISession.InfoStores)): > # n will be 0, 1, 2, 3... while > # InfoStores items are 1, 2, 3... > # so add 1 to make up the difference > store = MAPISession.InfoStores[1 + n] > print store.Name > > > > 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 > ________________________________________________________________________ > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- "You don't stop laughing because you grow old. You grow old because you stop laughing." -- Michael Pritchard -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051209/8421cce1/attachment.html From DFreeman at pagnet.org Thu Dec 8 23:23:13 2005 From: DFreeman at pagnet.org (Don Freeman) Date: Thu, 8 Dec 2005 15:23:13 -0700 Subject: [python-win32] Newbee Message-ID: <001601c5fc45$fa95ee40$5469b6c6@TPD284> Hello all. Is this list a suitable place to ask for help on totally simple issues for an absolute beginner? If not can someone direct me to a better place for some simple help? Example: I know there are functions to parse a filespec string and return the path or filename or extension, but how do you use them? x = 'C:\mypath\myfile.txt' print PyCFileDialog.GetFileName(x) doesn't seem to work. Also, (perhaps a little more involved): How would you open a window and put a button in the window that would close the window? Some sample code for some basic practical tasks would be appreciated. Thanks Don W. Freeman, P.E. Transportation Engineer Pima Association of Governments 177 N. Church Ave. #405 Tucson AZ 85701 (520) 792-1093 voice (520) 792-9151 fax -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051208/1b351371/attachment.html From david at graniteweb.com Fri Dec 9 18:40:35 2005 From: david at graniteweb.com (David Rock) Date: Fri, 9 Dec 2005 11:40:35 -0600 Subject: [python-win32] Newbee In-Reply-To: <001601c5fc45$fa95ee40$5469b6c6@TPD284> References: <001601c5fc45$fa95ee40$5469b6c6@TPD284> Message-ID: <20051209174035.GA13238@wdfs.graniteweb.com> * Don Freeman [2005-12-08 15:23]: > Hello all. Is this list a suitable place to ask for help on totally simple > issues for an absolute beginner? If not can someone direct me to a better > place for some simple help? Nope, this is exactly the right place. > Example: > I know there are functions to parse a filespec string and return the path or > filename or extension, but how do you use them? > > x = 'C:\mypath\myfile.txt' > print PyCFileDialog.GetFileName(x) > > doesn't seem to work. > > Also, (perhaps a little more involved): I've never used ActivePython, so I'm not sure about this one. What do you mean, exactly, by "doesn't seem to work"? Do you get a traceback? Does it print something, but just not what you were expecting? -- David Rock david at graniteweb.com From wccppp at gmail.com Fri Dec 9 19:11:40 2005 From: wccppp at gmail.com (wccppp) Date: Fri, 9 Dec 2005 08:11:40 -1000 Subject: [python-win32] question about pywin32 and COM event again Message-ID: <87bd46aa0512091011m6b933e8fv9ae4d2299e12c342@mail.gmail.com> Hello, I'm learning to use python to automate AutoCAD and I was able to catch the AutoCAD application event using the code below. But I don't know if I can catch the event from the active document (or drawing) or not. The AutoCAD.Application has a property of "ActiveDocument" which is the active drawing opened. The document has an event "BeginClose" which is what I'm after. I'd like to do some clean up before the drawing is closed. Can anyone give me guide? Thank you very much! import win32com.client class ACADEvents: def OnEndOpen(self, fName): print "Drawing " + str(fName) + " opened..." def OnEndSave(self, fName): print "Drawing " + str(fName) + " saved..." def OnBeginCommand(self, cmdName): print "Beginning command " + str(cmdName) + "..." acad = win32com.client.DispatchWithEvents("AutoCAD.Application", ACADEvents) acad.WindowState = 3 acad.Visible = 1 dwgName = r"C:\AutoCAD\DWG\1.dwg" doc = acad.Documents.Open(dwgName) doc.Layers("0").LayerOn = False doc.Save() doc.Close() -- Regards, - wcc -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051209/346ef979/attachment.htm From Laurent.Dufrechou at free.fr Fri Dec 9 20:49:38 2005 From: Laurent.Dufrechou at free.fr (=?ISO-8859-1?Q?Laurent_Dufr=E9chou?=) Date: Fri, 09 Dec 2005 20:49:38 +0100 Subject: [python-win32] question about pywin32 and COM event again In-Reply-To: <87bd46aa0512091011m6b933e8fv9ae4d2299e12c342@mail.gmail.com> References: <87bd46aa0512091011m6b933e8fv9ae4d2299e12c342@mail.gmail.com> Message-ID: <4399DFD2.9030907@free.fr> wccppp a ?crit : > Hello, > > I'm learning to use python to automate AutoCAD and I was able to catch > the AutoCAD application event using the code below. But I don't know > if I can catch the event from the active document (or drawing) or > not. The AutoCAD.Application has a property of "ActiveDocument" which > is the active drawing opened. The document has an event "BeginClose" > which is what I'm after. I'd like to do some clean up before the > drawing is closed. Can anyone give me guide? Thank you very much! > > import win32com.client > class ACADEvents: > def OnEndOpen(self, fName): > print "Drawing " + str(fName) + " opened..." > def OnEndSave(self, fName): > print "Drawing " + str(fName) + " saved..." > def OnBeginCommand(self, cmdName): > print "Beginning command " + str(cmdName) + "..." > > acad = win32com.client.DispatchWithEvents("AutoCAD.Application", > ACADEvents) > acad.WindowState = 3 > acad.Visible = 1 > dwgName = r"C:\AutoCAD\DWG\1.dwg" > doc = acad.Documents.Open(dwgName) > doc.Layers("0").LayerOn = False > doc.Save() > doc.Close() > > -- > > Regards, > - wcc > >------------------------------------------------------------------------ > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > Hello, had the same problem, but now it's solved :) Take a look at the code below: class VisualDSP_AppEvents: def OnAppClose(self): print ' Visual DSP++ has been closed, program will terminate now!' class VisualDSP_ProcessorEvents: def OnHalted(self,ReasonCode,HaltReason): print ' ' app = DispatchWithEvents('VisualDSP.ADspApplication',VisualDSP_AppEvents) ... processor = session.ActiveProcessor processor_events = WithEvents(processor, VisualDSP_ProcessorEvents) Here I'm catching application event with DispatchWithEvents for the processors event that depends on app I've used WithEvents function, So for your problem try something like: class session_event_class: def BeginClose(self): print 'catched' acad = win32com.client.DispatchWithEvents("AutoCAD.Application", ACADEvents) active_session = acad.ActiveSession active_session_events = WithEvents(active_session,session_event_class) or WithEvents(active_session,session_event_class) active_session_events is usefull if you've done a main class and you want your event class methods access your main class methods. Laurent From wccppp at gmail.com Sat Dec 10 08:55:25 2005 From: wccppp at gmail.com (wccppp) Date: Fri, 9 Dec 2005 21:55:25 -1000 Subject: [python-win32] How do I post and reply message at any time? Message-ID: <87bd46aa0512092355x15977017sed736835f5d5525d@mail.gmail.com> Hello, This must be a stupid question. But I haven't found the answer for quite a while. Here is the problem: I posted a question today and Laurent Dufr?chou's response answered my question. I wanted to reply and say Thank you. But it seems I have to wait till tomorrow when I receive the daily digest. Is there a way to get around this? I did find a couple of websites which archives this list, but they do not give me an option to reply. Thank you very much, -- Regards, - wcc -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051209/93524b91/attachment-0001.html From wccppp at gmail.com Sat Dec 10 09:09:53 2005 From: wccppp at gmail.com (wccppp) Date: Fri, 9 Dec 2005 22:09:53 -1000 Subject: [python-win32] Python-win32 Digest, Vol 33, Issue 12 In-Reply-To: References: Message-ID: <87bd46aa0512100009p46950f16w3b3c4cc66526099b@mail.gmail.com> > > > Hello, had the same problem, but now it's solved :) > Take a look at the code below: > > class VisualDSP_AppEvents: > def OnAppClose(self): > print ' Visual DSP++ has been closed, program > will terminate now!' > > class VisualDSP_ProcessorEvents: > def OnHalted(self,ReasonCode,HaltReason): > print ' ' > > app = DispatchWithEvents('VisualDSP.ADspApplication',VisualDSP_AppEvents) > ... > processor = session.ActiveProcessor > processor_events = WithEvents(processor, VisualDSP_ProcessorEvents) > > Here I'm catching application event with DispatchWithEvents > for the processors event that depends on app I've used WithEvents > function, > So for your problem try something like: > > class session_event_class: > def BeginClose(self): > print 'catched' > > acad = win32com.client.DispatchWithEvents("AutoCAD.Application", > ACADEvents) > active_session = acad.ActiveSession > > active_session_events = WithEvents(active_session,session_event_class) > or > WithEvents(active_session,session_event_class) > > active_session_events is usefull if you've done a main class and you > want your event class methods access your main class methods. > > Laurent > Laurent, Thank you very much for your reply. I followed your code and got what I was after without a problem. - wcc -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051209/cba61e0e/attachment.htm From steve at holdenweb.com Sat Dec 10 09:35:46 2005 From: steve at holdenweb.com (Steve Holden) Date: Sat, 10 Dec 2005 08:35:46 +0000 Subject: [python-win32] How do I post and reply message at any time? In-Reply-To: <87bd46aa0512092355x15977017sed736835f5d5525d@mail.gmail.com> References: <87bd46aa0512092355x15977017sed736835f5d5525d@mail.gmail.com> Message-ID: <439A9362.6040205@holdenweb.com> wccppp wrote: > Hello, > > This must be a stupid question. But I haven't found the answer for > quite a while. Here is the problem: > > I posted a question today and Laurent Dufr?chou's response answered my > question. I wanted to reply and say Thank you. But it seems I have to > wait till tomorrow when I receive the daily digest. Is there a way to > get around this? I did find a couple of websites which archives this > list, but they do not give me an option to reply. > > Thank you very much, > If you're signed up for digests then the easiest thing to do is just reply to the list (as it seems you did, by a later post). If posters have taken the trouble to reply to you personally as well as the list that's just because they are more courteous than netiquette demands. One point you might have missed: when you make a posting based on an entry in a digest it's considered helpful to change the subject line so it is a bit more meaningful than "List Digest Volume XXX Isuue XXX". The more meaning ful your subject line the more likely it is to attract the help you need. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ From wccppp at gmail.com Sat Dec 10 10:48:07 2005 From: wccppp at gmail.com (wccppp) Date: Fri, 9 Dec 2005 23:48:07 -1000 Subject: [python-win32] How do I post and reply message at any time? In-Reply-To: <439A9362.6040205@holdenweb.com> References: <87bd46aa0512092355x15977017sed736835f5d5525d@mail.gmail.com> <439A9362.6040205@holdenweb.com> Message-ID: <87bd46aa0512100148x4cdc02f8l8e47b7634dd838f1@mail.gmail.com> On 12/9/05, Steve Holden wrote: > > wccppp wrote: > > Hello, > > > > This must be a stupid question. But I haven't found the answer for > > quite a while. Here is the problem: > > > > I posted a question today and Laurent Dufr?chou's response answered my > > question. I wanted to reply and say Thank you. But it seems I have to > > wait till tomorrow when I receive the daily digest. Is there a way to > > get around this? I did find a couple of websites which archives this > > list, but they do not give me an option to reply. > > > > Thank you very much, > > > If you're signed up for digests then the easiest thing to do is just > reply to the list (as it seems you did, by a later post). If posters > have taken the trouble to reply to you personally as well as the list > that's just because they are more courteous than netiquette demands. > > One point you might have missed: when you make a posting based on an > entry in a digest it's considered helpful to change the subject line so > it is a bit more meaningful than "List Digest Volume XXX Isuue XXX". The > more meaning ful your subject line the more likely it is to attract the > help you need. > > regards > Steve > -- > Steve Holden +44 150 684 7255 +1 800 494 3119 > Holden Web LLC www.holdenweb.com > PyCon TX 2006 www.python.org/pycon/ > Steve, Thanks for your explanation. I'm a beginner in both learning python and using the mailing list. Will keep those in mind. Regards, - wcc -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051209/d64bf222/attachment.html From wccppp at gmail.com Sun Dec 11 10:30:46 2005 From: wccppp at gmail.com (wccppp) Date: Sat, 10 Dec 2005 23:30:46 -1000 Subject: [python-win32] question about COM again: variable type? Message-ID: <87bd46aa0512110130u70570e7fy4be4b95f5163b1df@mail.gmail.com> Hello, I'm having problem implementing a "AddPoint" method in AutoCAD. From the search I've done, seems the problem is variable type: I supplied a list as the x,y,z coordinates of a point, why seems what is expected is a Variant (three-element array of doubles). The python code I tested with is: [code] import win32com.client acad = win32com.client.Dispatch("AutoCAD.Application") acad.WindowState = 3 acad.Visible = 1 doc = acad.ActiveDocument ms = doc.ModelSpace print str(ms.ObjectName) try: ms.AddPoint([0.0, 0.0, 0.0]) # this line gives the problem finally: print "\nTest finished." [/code] This is the error I got: Traceback (most recent call last): File "", line 65, in run_nodebug File "C:\Programming\Python\Codes\acad_add_point.py", line 11, in ? ms.AddPoint([0.0, 0.0, 0.0]) File "C:\Python24\lib\site-packages\win32com\gen_py\1EFD8E85- 7F3B-48E6-9341-3C8B2F60136Bx0x1x1.py", line 12688, in AddPoint ret = self._oleobj_.InvokeTypes(1562, LCID, 1, (9, 0), ((12, 1),),Point pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147024809), None) python code for AddPoint method from makepy: # Result is of type IAcadPoint def AddPoint(self, Point=defaultNamedNotOptArg): """Creates a Point object at a given location""" ret = self._oleobj_.InvokeTypes(1562, LCID, 1, (9, 0), ((12, 1),),Point) if ret is not None: ret = Dispatch(ret, 'AddPoint', '{35AF3AB5-755E-4AC9-8BAF-31B532870751}', UnicodeToString=0) return ret And finally, below is the VBA doucumentation provided with AutoCAD. Signature RetVal = object.AddPoint(Point) Object ModelSpace Collection, PaperSpace Collection, Block The object or objects this method applies to. Point Variant (three-element array of doubles); input-only The coordinates of the point to be created. RetVal Point object The newly created Point object. Example: Sub Example_AddPoint() ' This example creates a point in model space. Dim pointObj As AcadPoint Dim location(0 To 2) As Double ' Define the location of the point location(0) = 5#: location(1) = 5#: location(2) = 0# ' Create the point Set pointObj = ThisDrawing.ModelSpace.AddPoint(location) ZoomAll End Sub Sorry for the long post. I've actually spent more than 2 or 3 hours searching the web for an answer. And I did see lots of discussions related to this sort of issue: safearray, variant array, etc.. But I didn't see a definite answer. More than likely it is because I'm a beginner in Python and could not make sense out of those discussion. Can someone elaborate a little bit on this? Thanks a lot for just reading my long message. -- Regards, - wcc -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051210/f1dca702/attachment.htm From waylan at gmail.com Mon Dec 12 04:18:56 2005 From: waylan at gmail.com (Waylan Limberg) Date: Sun, 11 Dec 2005 22:18:56 -0500 Subject: [python-win32] How do I post and reply message at any time? In-Reply-To: <439A9362.6040205@holdenweb.com> References: <87bd46aa0512092355x15977017sed736835f5d5525d@mail.gmail.com> <439A9362.6040205@holdenweb.com> Message-ID: On 12/10/05, Steve Holden wrote: > wccppp wrote: > > Hello, > > > > This must be a stupid question. But I haven't found the answer for > > quite a while. Here is the problem: > > > > I posted a question today and Laurent Dufr?chou's response answered my > > question. I wanted to reply and say Thank you. But it seems I have to > > wait till tomorrow when I receive the daily digest. Is there a way to > > get around this? I did find a couple of websites which archives this > > list, but they do not give me an option to reply. > > > > Thank you very much, > > > If you're signed up for digests then the easiest thing to do is just > reply to the list (as it seems you did, by a later post). If posters > have taken the trouble to reply to you personally as well as the list > that's just because they are more courteous than netiquette demands. > > One point you might have missed: when you make a posting based on an > entry in a digest it's considered helpful to change the subject line so > it is a bit more meaningful than "List Digest Volume XXX Isuue XXX". The > more meaning ful your subject line the more likely it is to attract the > help you need. > In addition, you don't have to get digests. You can receive each message seperatly. This list seems to not get that much activity, so there are only a few messages a day anyway. Just go to http://mail.python.org/mailman/listinfo/python-win32, select the edit options button and after you enter your address and password, set Digest Mode to 'off'. After submitting you changes, you will get each message when it is sent to the list. In adition, the subject will be retained, which makes it easier to follow a ceretain dicussion. And seeing you have a gmail account. Gmail will actually list all responces with the same subject as one conversation, which makes it really easy to follow dicussions. -- ---- Waylan Limberg waylan at gmail.com From drkick16 at gmail.com Mon Dec 12 06:50:23 2005 From: drkick16 at gmail.com (drkick16) Date: Sun, 11 Dec 2005 21:50:23 -0800 Subject: [python-win32] question about COM again: variable type? (wccppp) Message-ID: <7b953baa0512112150r2fd2f4a2n8bbd2da434475d58@mail.gmail.com> wccppp, I too am working on this same issue as we speak. It is my goal to automate AutoCAD using Python. I've had success using C# (.net) for Automation but I haven't given up with Python yet. I have done searches here and there on various search engines and haven't come up with any complete answers on passing 3 doubles as an array of Variants. This as you see doesn't happen automatically as it should and Mark has mentioned that idispatch invoke() manually is the way to correctly pass them. I have yet to master invoke and all the params. What I need is a working example of Invoke and its parameters. It seems AutoCAD object model is easy to decifer and the passing and retrieval of a Variant(s) in Python are my only stepping stones to complete a successful automation. I am continually monitoring this mailing list and in my research I will pass on any information that I uncover. Drkick16 On 12/11/05, python-win32-request at python.org < python-win32-request at python.org> wrote: > > Send Python-win32 mailing list submissions to > python-win32 at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-win32 > or, via email, send a message with subject or body 'help' to > python-win32-request at python.org > > You can reach the person managing the list at > python-win32-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Python-win32 digest..." > > > Today's Topics: > > 1. question about COM again: variable type? (wccppp) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sat, 10 Dec 2005 23:30:46 -1000 > From: wccppp > Subject: [python-win32] question about COM again: variable type? > To: python-win32 at python.org > Message-ID: > <87bd46aa0512110130u70570e7fy4be4b95f5163b1df at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > Hello, > > I'm having problem implementing a "AddPoint" method in AutoCAD. From the > search I've done, seems the problem is variable type: I supplied a list > as > the x,y,z coordinates of a point, why seems what is expected is a Variant > (three-element array of doubles). > > The python code I tested with is: > > [code] > > import win32com.client > > acad = win32com.client.Dispatch("AutoCAD.Application") > acad.WindowState = 3 > acad.Visible = 1 > > doc = acad.ActiveDocument > ms = doc.ModelSpace > print str(ms.ObjectName) > try: > ms.AddPoint([0.0, 0.0, 0.0]) # this line gives the problem > finally: > print "\nTest finished." > > [/code] > > This is the error I got: > > Traceback (most recent call last): > File "", line 65, in run_nodebug > File "C:\Programming\Python\Codes\acad_add_point.py", line 11, in ? > ms.AddPoint([0.0, 0.0, 0.0]) > File "C:\Python24\lib\site-packages\win32com\gen_py\1EFD8E85- > 7F3B-48E6-9341-3C8B2F60136Bx0x1x1.py", line 12688, in AddPoint > ret = self._oleobj_.InvokeTypes(1562, LCID, 1, (9, 0), ((12, > 1),),Point > pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, > None, 0, -2147024809), None) > > > python code for AddPoint method from makepy: > > # Result is of type IAcadPoint > def AddPoint(self, Point=defaultNamedNotOptArg): > """Creates a Point object at a given location""" > ret = self._oleobj_.InvokeTypes(1562, LCID, 1, (9, 0), ((12, > 1),),Point) > if ret is not None: > ret = Dispatch(ret, 'AddPoint', > '{35AF3AB5-755E-4AC9-8BAF-31B532870751}', UnicodeToString=0) > return ret > > > And finally, below is the VBA doucumentation provided with AutoCAD. > > Signature > > RetVal = object.AddPoint(Point) > > Object > > ModelSpace Collection, PaperSpace Collection, Block > The object or objects this method applies to. > > Point > > Variant (three-element array of doubles); input-only > The coordinates of the point to be created. > > RetVal > > Point object > The newly created Point object. > > Example: > > Sub Example_AddPoint() > ' This example creates a point in model space. > Dim pointObj As AcadPoint > Dim location(0 To 2) As Double > > ' Define the location of the point > location(0) = 5#: location(1) = 5#: location(2) = 0# > > ' Create the point > Set pointObj = ThisDrawing.ModelSpace.AddPoint(location) > ZoomAll > > End Sub > > Sorry for the long post. I've actually spent more than 2 or 3 hours > searching the web for an answer. And I did see lots of discussions > related > to this sort of issue: safearray, variant array, etc.. But I didn't see a > definite answer. More than likely it is because I'm a beginner in Python > and could not make sense out of those discussion. Can someone elaborate a > little bit on this? > > Thanks a lot for just reading my long message. > > -- > > Regards, > - wcc > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > http://mail.python.org/pipermail/python-win32/attachments/20051210/f1dca702/attachment-0001.htm > > ------------------------------ > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > End of Python-win32 Digest, Vol 33, Issue 14 > ******************************************** > -- drkick16 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051211/c18895ad/attachment.htm From mikael.mikaelsson at ltdalarna.se Mon Dec 12 17:38:29 2005 From: mikael.mikaelsson at ltdalarna.se (mikael.mikaelsson@ltdalarna.se) Date: Mon, 12 Dec 2005 17:38:29 +0100 Subject: [python-win32] Newbie question. Python asp and diacritic characters Message-ID: <3AA0BEDAA0CFC44FB0BF3BF919BBDCDF2B7AD7@wfalitesr049.ltdalarna.se> Hello, I'm new to Python and also to asp. I started checking those two out just a couple of days ago. Anyway, things seems to work fine except that diacritic characters like the Swedish ?????? generate a "HTTP/1.1 500 Server Error". This example generates the error: ------------------------------------ <%@ LANGUAGE = Python%> <% sGreetings = "H?lsningar fr?n Python
" Response.Write(sGreetings) sGreetings = "(Greetings from Python)" Response.Write(sGreetings) %> ------------------------------------ If I replace the literal diacrites with escape codes for these characters, things work allright. This code works: ----------------------------------- <%@ LANGUAGE = Python%> <% sGreetings = "H\xe4lsningar fr\xe5n Python
" Response.Write(sGreetings) sGreetings = "(Greetings from Python)" Response.Write(sGreetings) %> ----------------------------------- Is this a bug in the python asp-lib or is there some setting for non-english charsets? I do not get this error if I run python as cgi with the diacrits included. Also checked that asp under vbscript works allright with these characters. Is there anyone encountered this problem, and perhaps also found a solution/workaround? Best regards, Mikael Mikaelsson Falu lasarettsbibliotek, Falun, Sweden From wccppp at gmail.com Mon Dec 12 18:49:51 2005 From: wccppp at gmail.com (wccppp) Date: Mon, 12 Dec 2005 07:49:51 -1000 Subject: [python-win32] Python-win32 Digest, Vol 33, Issue 15 How do I post and reply message at any time? Message-ID: <87bd46aa0512120949q6c70faa0q76a9a46ccb0f490f@mail.gmail.com> Re: How do I post and reply message at any time? (Waylan Limberg) > > > Message: 1 > Date: Sun, 11 Dec 2005 22:18:56 -0500 > From: Waylan Limberg > Subject: Re: [python-win32] How do I post and reply message at any > time? > To: wccppp > Cc: python-win32 Mailinglist > > In addition, you don't have to get digests. You can receive each > message seperatly. This list seems to not get that much activity, so > there are only a few messages a day anyway. Just go to > http://mail.python.org/mailman/listinfo/python-win32, select the edit > options button and after you enter your address and password, set > Digest Mode to 'off'. After submitting you changes, you will get each > message when it is sent to the list. In adition, the subject will be > retained, which makes it easier to follow a ceretain dicussion. And > seeing you have a gmail account. Gmail will actually list all > responces with the same subject as one conversation, which makes it > really easy to follow dicussions. > -- > ---- > Waylan Limberg > waylan at gmail.com > Waylan, Thanks for your help. I've just changed my subscribe options. I do wish there is more activity in this mailing list. Since it is considered impolite to post same question on multiple list (is it?), I didn't post my question in other python mailing lists. PyWin32 seems to be more appropriate for my question. -- Regards, wcc -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051212/820eeb11/attachment.htm From wccppp at gmail.com Mon Dec 12 18:54:25 2005 From: wccppp at gmail.com (wccppp) Date: Mon, 12 Dec 2005 07:54:25 -1000 Subject: [python-win32] Python-win32 Digest, Vol 33, Issue 15 question about COM again: variable type? Message-ID: <87bd46aa0512120954u4fe821c1s752bf2b97058b904@mail.gmail.com> > > > Message: 2 > Date: Sun, 11 Dec 2005 21:50:23 -0800 > From: drkick16 > Subject: Re: [python-win32] question about COM again: variable type? > (wccppp) > To: python-win32 at python.org > Message-ID: > <7b953baa0512112150r2fd2f4a2n8bbd2da434475d58 at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > wccppp, > > I too am working on this same issue as we speak. It is my goal to > automate > AutoCAD using Python. I've had success using C# (.net) for Automation but > I > haven't given up with Python yet. I have done searches here and there on > various search engines and haven't come up with any complete answers on > passing 3 doubles as an array of Variants. This as you see doesn't happen > automatically as it should and Mark has mentioned that idispatch invoke() > manually is the way to correctly pass them. I have yet to master invoke > and > all the params. What I need is a working example of Invoke and its > parameters. It seems AutoCAD object model is easy to decifer and the > passing and retrieval of a Variant(s) in Python are my only stepping > stones > to complete a successful automation. I am continually monitoring this > mailing list and in my research I will pass on any information that I > uncover. > > Drkick16 > > > Drkick16, Thanks for your reply. I agree with you that AutoCAD object model is easy ot decifer. Especially if you've used other programming language(s) on it. I recently bought Mark's book "Python Programming on Win32". Havn't really had chance to go through it. I'll see if there is answer in the book and post back if I find something useful. -- Regards, - wcc -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051212/fbae9d0b/attachment.html From python at kareta.de Mon Dec 19 11:44:51 2005 From: python at kareta.de (=?ISO-8859-15?Q?J=FCrgen_Kareta?=) Date: Mon, 19 Dec 2005 11:44:51 +0100 Subject: [python-win32] kill process on a remote server Message-ID: <43A68F23.30600@kareta.de> Hi list, I need some suggestions on how I best kill a process on a remote server. It is a NT4 Terminalserver. Until now I have a working script which use the windows commands: 'qprocess' and 'kill' over popen to terminate the process. This works fine for me as an administrator but I like to give this possibility to normal users (ok, I know thats a security issue, but it is restricted to only a few applications). Therefore I have to give this user the right permissions. What I want to know is, which way I should go on: 1) I can try to set the acl permissions for the processes using popen + setacl (setacl = commandtool found on sourceforge) 2) try to solve it with the win32 extension in python. I looked also at the wmi stuff, but unfortunately wmi is not installed on that machine and I won't install it as long as I have other possibilities. With win32process.EnumProcesse I can get all Process Ids, can I get them also from a remote machine ? And if yes, can I use win32process.TerminateProcess or win32process.ExitProcesses to terminate the process on the remote machine and if yes, how can I get rid of the permission restrictions. Any hints are higly appreciated. Regards, J?rgen From eric.powell at srs.gov Mon Dec 19 14:58:17 2005 From: eric.powell at srs.gov (eric.powell@srs.gov) Date: Mon, 19 Dec 2005 08:58:17 -0500 Subject: [python-win32] Error message.... Message-ID: Hello all! I am trying to use the OSISoft PI (Plant Information) API to collect data about processes within our facility, however, when I try to connect to the PI server using their API calls, I get the following error" >>> from ctypes import * >>> PiAPI=windll.piapi32 >>> valid = 0 >>> status = PiAPI.piut_setservernode(servername) >>> status = pi.piut_login("pidemo", "dorazio", valid) Traceback (most recent call last): File "", line 1, in ? status = pi.piut_login("pidemo", "dorazio", valid) WindowsError: exception: access violation writing 0x00000000 I THINK this means we are not licensed to make API calls against this dll, but I am not sure. If anyone can translate the error message, I would be grateful. Eric Eric B. Powell BSRI Electronic Aids (803)208-6691 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051219/ee28de8e/attachment.htm From aurora00 at gmail.com Mon Dec 19 23:06:20 2005 From: aurora00 at gmail.com (aurora) Date: Mon, 19 Dec 2005 14:06:20 -0800 Subject: [python-win32] filling Windows properties "Summary" tab? Message-ID: I am reading the discussion of "filling Windows properties "Summary" tab?" on 2005-06-23: http://thread.gmane.org/gmane.comp.python.windows/3164 I too am interesting in finding out a way to read and write the summary propreties. It isn't very clear for me from the thread that what classes of if there are any sample program I can use. A more basic issue is I would like to write some meta data for any kind of files (even for folders if possible). There are mention of COM "structured storage" files like MS office documents. However I am able to set this for a simple text file. On the other hand this summary is not available if I rename it to .html. Much appreciate if you can help me to understand this. Thanks, wy From aurora00 at gmail.com Mon Dec 19 23:27:34 2005 From: aurora00 at gmail.com (aurora) Date: Mon, 19 Dec 2005 14:27:34 -0800 Subject: [python-win32] Newbie question. Python asp and diacritic characters References: <3AA0BEDAA0CFC44FB0BF3BF919BBDCDF2B7AD7@wfalitesr049.ltdalarna.se> Message-ID: Do you find any more detail error message than a 500 Server Error? I have no experience with using Python in the context of ASP. To use non-ASCII characters correctly requires the understanding of character encoding and to use them correctly through out a chain of software components. In your case this might have happended: 1. You use your text editor to write your first version of ASP. It was saved in encoding X. 2. Python load the code, try to interpret the source code in encoding Y. 3. Calls Response.Write(sGreetings). I guess this would cause the parameter sGreetings first converted into unicode. 4. IIS spit put to end user in encoding Z. As you can see there are many places a mismatch can happen. Encoding X obviously should match encoding Y. I bet a mismatch there cause an 500 error later in step 3. \xe4 and \xe5 stands for ? and ? in latin-1 encoding. Since that work one thing your can do is to ensure encoding X and encoding Y are all latin-1. Do you know what character encoding your editor save your file in? I use an Windows editor called EmEditor, which is especially good in giving your this kind of detail. After that you still have to make sure Python knows the encoding you have chosen for step 2. The proper way to do it is documented in http://www.python.org/doc/2.4.2/ref/encodings.html However things maybe different in the ASP context. That's as far as I can help. Character encoding is really more complicated than it should be. I hope a few years from now everything would be unicode and we should not bother by this anymore. wy > Hello, > > I'm new to Python and also to asp. I started checking those two out just > a couple of days ago. > > Anyway, things seems to work fine except that diacritic characters like > the Swedish ?????? generate a "HTTP/1.1 500 Server Error". > > This example generates the error: > ------------------------------------ > <%@ LANGUAGE = Python%> > > > <% > sGreetings = "H?lsningar fr?n Python
" > Response.Write(sGreetings) > sGreetings = "(Greetings from Python)" > Response.Write(sGreetings) > %> > > > ------------------------------------ > > If I replace the literal diacrites with escape codes for these > characters, things work allright. > This code works: > ----------------------------------- > <%@ LANGUAGE = Python%> > > > <% > sGreetings = "H\xe4lsningar fr\xe5n Python
" > Response.Write(sGreetings) > sGreetings = "(Greetings from Python)" > Response.Write(sGreetings) > %> > > > ----------------------------------- > > Is this a bug in the python asp-lib or is there some setting for > non-english charsets? I do not get this error if I run python as cgi > with the diacrits included. Also checked that asp under vbscript works > allright with these characters. > > Is there anyone encountered this problem, and perhaps also found a > solution/workaround? > > Best regards, > Mikael Mikaelsson > Falu lasarettsbibliotek, Falun, Sweden From aurora00 at gmail.com Tue Dec 20 03:12:08 2005 From: aurora00 at gmail.com (aurora) Date: Mon, 19 Dec 2005 18:12:08 -0800 Subject: [python-win32] How to reload ShellExtension? Message-ID: I am working with the ShellExtension context menu sample: win32comext\shell\demos\servers\context_menu.py My question after I change the code, how to I get it reloaded? --unregister and then --register won't do it. I have to log off and then log back in. Thanks for your help, wy From mhammond at skippinet.com.au Tue Dec 20 04:58:26 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 20 Dec 2005 14:58:26 +1100 Subject: [python-win32] How to reload ShellExtension? In-Reply-To: Message-ID: > I am working with the ShellExtension context menu sample: > > win32comext\shell\demos\servers\context_menu.py > > My question after I change the code, how to I get it reloaded? > --unregister and then --register won't do it. I have to log off and then > log back in. Its tricky. Either restart explorer manually (using a utility like "pskill") to automate it, or somehow arrange for your Python module to have reload() called on it. Exactly how you do the latter depends on your app, but is generally not trivial. At the end of the day though, your shell extension is just another module in use by Python - in this case it just happens to be hosted inside explorer.exe Mark From timr at probo.com Tue Dec 20 20:05:12 2005 From: timr at probo.com (Tim Roberts) Date: Tue, 20 Dec 2005 11:05:12 -0800 Subject: [python-win32] Error message.... In-Reply-To: References: Message-ID: <43A855E8.10206@probo.com> On Mon, 19 Dec 2005 08:58:17 -0500, eric.powell at srs.gov wrote: >I am trying to use the OSISoft PI (Plant Information) API to collect data >about processes within our facility, however, when I try to connect to the >PI server using their API calls, I get the following error" > > > >>>>>>> from ctypes import * >>>>>>> PiAPI=windll.piapi32 >>>>>>> valid = 0 >>>>>>> status = PiAPI.piut_setservernode(servername) >>>>>>> status = pi.piut_login("pidemo", "dorazio", valid) >>>> >>>> >Traceback (most recent call last): > File "", line 1, in ? > status = pi.piut_login("pidemo", "dorazio", valid) >WindowsError: exception: access violation writing 0x00000000 > > >I THINK this means we are not licensed to make API calls against this dll, >but I am not sure. > > No, that's not what it means. "Access violation" is an Intel processor term that mean you tried to access an invalid memory address. It is also called "general protection fault". In this particular instance, it tried to write to a null pointer. What is "servername"? What is "pi"? Neither is defined here. Is it possible that the third parameter to piut_login is an OUTPUT parameter -- that it is returning a "valid" state to you? In that case, you have to use ctypes magic to declare that the parameter is a pointer: pi.piut_login( "pidemo", "dorazio", ctypes.byref( valid ) ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rwupole at msn.com Wed Dec 21 09:07:28 2005 From: rwupole at msn.com (Roger Upole) Date: Wed, 21 Dec 2005 03:07:28 -0500 Subject: [python-win32] Re: filling Windows properties "Summary" tab? Message-ID: aurora wrote: > I am reading the discussion of "filling Windows properties "Summary" tab?" > on 2005-06-23: > http://thread.gmane.org/gmane.comp.python.windows/3164 > I too am interesting in finding out a way to read and write the summary > propreties. It isn't very clear for me from the thread that what classes > of if there are any sample program I can use. A more basic issue is I > would like to write some meta data for any kind of files (even for folders > if possible). There are mention of COM "structured storage" files like MS > office documents. However I am able to set this for a simple text file. On > the other hand this summary is not available if I rename it to .html. Much > appreciate if you can help me to understand this. > Thanks, > wy The function to access document properties for non-COM files is StgOpenStorageEx. Take a look at \win32com\test\testStorage.py for an example of how to use it. However, it doesn't work for directories. The reason you don't see the Summary tab for .html files is because property sheet handlers are registered per file extension, and the document summary handler apparently isn't registered for .html. However, you can still access the properties programmatically. hth Roger From timr at probo.com Wed Dec 21 22:31:26 2005 From: timr at probo.com (Tim Roberts) Date: Wed, 21 Dec 2005 13:31:26 -0800 Subject: [python-win32] Error message.... In-Reply-To: References: Message-ID: <43A9C9AE.9010101@probo.com> On Tue, 20 Dec 2005 11:05:12 -0800, I wrote: >On Mon, 19 Dec 2005 08:58:17 -0500, eric.powell at srs.gov wrote: > > >>I am trying to use the OSISoft PI (Plant Information) API to collect data >>about processes within our facility, however, when I try to connect to the >>PI server using their API calls, I get the following error" >> >> >> >> >>>>>>>>from ctypes import * >>>>>>>>PiAPI=windll.piapi32 >>>>>>>>valid = 0 >>>>>>>>status = PiAPI.piut_setservernode(servername) >>>>>>>>status = pi.piut_login("pidemo", "dorazio", valid >>>>>>>> >>Traceback (most recent call last): >> File "", line 1, in ? >> status = pi.piut_login("pidemo", "dorazio", valid) >>WindowsError: exception: access violation writing 0x00000000 >> >> >>I THINK this means we are not licensed to make API calls against this dll, >>but I am not sure. >> >No, that's not what it means. "Access violation" is an Intel processor >term that mean you tried to access an invalid memory address. It is >also called "general protection fault". In this particular instance, it >tried to write to a null pointer. > >What is "servername"? What is "pi"? Neither is defined here. Is it >possible that the third parameter to piut_login is an OUTPUT parameter >-- that it is returning a "valid" state to you? In that case, you have >to use ctypes magic to declare that the parameter is a pointer: > > pi.piut_login( "pidemo", "dorazio", ctypes.byref( valid ) ) > We continued this discussion off-list. Had either one of us taken the time to look at the examples, we would have seen that the proper answer was: valid = ctypes.c_int( 0 ) pi.piut_login( "pidemo", "dorazio", ctypes.byref( valid ) ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From dzrudy at gmail.com Thu Dec 22 16:15:29 2005 From: dzrudy at gmail.com (Dawid Zamirski) Date: Thu, 22 Dec 2005 10:15:29 -0500 Subject: [python-win32] FetchProgress event problem Message-ID: <43AAC311.3090004@gmail.com> Hello I'm trying to track recordset loading progress (it is loaded asynchronously), but neither FetchProgresss or FetchComplete event is launched. I played with WillMove events in sychronous mode and they work just fine. Can someone guide me how to get those events fired? I'm using pywin32 build 205. Here's my test code: import win32com.client class RSEvents: def OnWillMove(*args): print "will move" def OnFetchProgress(*args): print "fetch progress" def OnFetchComplete(*args): print "fetch complete" def Test(): conn = win32com.client.Dispatch(r"ADODB.Connection") connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb" conn.Open( connstr ) rs = win32com.client.DispatchWithEvents(r"ADODB.Recordset", RSEvents) rs.CursorLocation = 3 rs.Open("SELECT * FROM test", 3, 1, 49) if __name__ == "__main__": Test() Thank You in Advance From rtilley at vt.edu Thu Dec 22 20:24:45 2005 From: rtilley at vt.edu (Brad Tilley) Date: Thu, 22 Dec 2005 14:24:45 -0500 Subject: [python-win32] Adding Printers on Windows XP Message-ID: <43AAFD7D.8060108@vt.edu> When I do this: import win32print printers = ['http://128.173.120.65'] for printer in printers: pHandle = win32print.OpenPrinter(printer, None) #print pHandle pInfo = win32print.GetPrinter(pHandle, 2) #print pInfo win32print.ClosePrinter(pHandle) pAdd = win32print.AddPrinter(None, 2, pInfo) I get this error: Traceback (most recent call last): File "C:\Documents and Settings\Administrator\Desktop\printers.py", line 15, in ? pAdd = win32print.AddPrinter(None, 2, pInfo) ValueError: PyDEVMODE cannot be None in this context Any ideas? From rwupole at msn.com Fri Dec 23 10:08:13 2005 From: rwupole at msn.com (Roger Upole) Date: Fri, 23 Dec 2005 04:08:13 -0500 Subject: [python-win32] Re: FetchProgress event problem Message-ID: It's likely your recordset and connection objects are going out of scope before they get a chance to fire any events. As soon as the function exits, both of the COM objects will be released. Also, you might want to use the named constants from win32com.client.constants in place of hardcoded values. rs.CursorLocation=win32com.client.constants.adUseClient makes the intent much clearer. hth Roger From timr at probo.com Fri Dec 23 19:38:02 2005 From: timr at probo.com (Tim Roberts) Date: Fri, 23 Dec 2005 10:38:02 -0800 Subject: [python-win32] FetchProgress event problem In-Reply-To: References: Message-ID: <43AC440A.5050703@probo.com> On Thu, 22 Dec 2005 10:15:29 -0500, Dawid Zamirski wrote: >I'm trying to track recordset loading progress (it is loaded >asynchronously), but neither FetchProgresss or FetchComplete event is >launched. I played with WillMove events in sychronous mode and they work >just fine. Can someone guide me how to get those events fired? I'm using >pywin32 build 205. Here's my test code: > >import win32com.client > >class RSEvents: > def OnWillMove(*args): > print "will move" > > def OnFetchProgress(*args): > print "fetch progress" > > def OnFetchComplete(*args): > print "fetch complete" > >def Test(): > conn = win32com.client.Dispatch(r"ADODB.Connection") > connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb" > conn.Open( connstr ) > rs = win32com.client.DispatchWithEvents(r"ADODB.Recordset", RSEvents) > rs.CursorLocation = 3 > rs.Open("SELECT * FROM test", 3, 1, 49) > >if __name__ == "__main__": > Test() > > Besides Roger's comments, in this PARTICULAR example, you have not connected the Recordset with the Connection. Don't you want this: rs.Open( "SELECT * FROM test", conn, 3, 1, 49 ) or: rs.Open( "test", conn, 3, 2, 49 ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From dzrudy at gmail.com Fri Dec 23 20:06:50 2005 From: dzrudy at gmail.com (Dawid Zamirski) Date: Fri, 23 Dec 2005 14:06:50 -0500 Subject: [python-win32] FetchProgress event problem In-Reply-To: References: Message-ID: <43AC4ACA.3050504@gmail.com> The objects last quite long because it's a huge database (about 730000 records) and it takes a few minutes to load, that is why I wanted to track the progress so the user know that something is happening. As for now, I implemented "pulse" progress bar to notify the user of activity, however accurate progress bar would be nicer Roger Upole wrote: > It's likely your recordset and connection objects are going out > of scope before they get a chance to fire any events. As soon as > the function exits, both of the COM objects will be released. > > Also, you might want to use the named constants from > win32com.client.constants in place of hardcoded values. > rs.CursorLocation=win32com.client.constants.adUseClient > makes the intent much clearer. > > hth > Roger > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From dzrudy at gmail.com Fri Dec 23 20:11:57 2005 From: dzrudy at gmail.com (Dawid Zamirski) Date: Fri, 23 Dec 2005 14:11:57 -0500 Subject: [python-win32] FetchProgress event problem In-Reply-To: <43AC440A.5050703@probo.com> References: <43AC440A.5050703@probo.com> Message-ID: <43AC4BFD.1090006@gmail.com> That was just a typo when I was posting to the list :-). In real code I have the recordset setup correctly, it's just the FetchProgress and FetchComplete events that do not work. Tim Roberts wrote: > On Thu, 22 Dec 2005 10:15:29 -0500, Dawid Zamirski wrote: > > >> I'm trying to track recordset loading progress (it is loaded >> asynchronously), but neither FetchProgresss or FetchComplete event is >> launched. I played with WillMove events in sychronous mode and they work >> just fine. Can someone guide me how to get those events fired? I'm using >> pywin32 build 205. Here's my test code: >> >> import win32com.client >> >> class RSEvents: >> def OnWillMove(*args): >> print "will move" >> >> def OnFetchProgress(*args): >> print "fetch progress" >> >> def OnFetchComplete(*args): >> print "fetch complete" >> >> def Test(): >> conn = win32com.client.Dispatch(r"ADODB.Connection") >> connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb" >> conn.Open( connstr ) >> rs = win32com.client.DispatchWithEvents(r"ADODB.Recordset", RSEvents) >> rs.CursorLocation = 3 >> rs.Open("SELECT * FROM test", 3, 1, 49) >> >> if __name__ == "__main__": >> Test() >> >> >> > > Besides Roger's comments, in this PARTICULAR example, you have not > connected the Recordset with the Connection. Don't you want this: > > rs.Open( "SELECT * FROM test", conn, 3, 1, 49 ) > or: > rs.Open( "test", conn, 3, 2, 49 ) > > From rwupole at msn.com Sun Dec 25 07:07:01 2005 From: rwupole at msn.com (Roger Upole) Date: Sun, 25 Dec 2005 01:07:01 -0500 Subject: [python-win32] Re: FetchProgress event problem References: <43AC4ACA.3050504@gmail.com> Message-ID: Try adding pythoncom.PumpWaitingMessages() at the point where you're waiting for the fetch to complete. The events show up for me if I add this loop to the bottom of the test function: while 1: pythoncom.PumpWaitingMessages() time.sleep(0.1) Roger ----- Original Message ----- From: "Dawid Zamirski" To: Sent: Friday, December 23, 2005 2:06 PM Subject: Re: [python-win32] FetchProgress event problem > The objects last quite long because it's a huge database (about 730000 > records) and it takes a few minutes to load, that is why I wanted to > track the progress so the user know that something is happening. As for > now, I implemented "pulse" progress bar to notify the user of activity, > however accurate progress bar would be nicer > > Roger Upole wrote: >> It's likely your recordset and connection objects are going out >> of scope before they get a chance to fire any events. As soon as >> the function exits, both of the COM objects will be released. >> >> Also, you might want to use the named constants from >> win32com.client.constants in place of hardcoded values. >> rs.CursorLocation=win32com.client.constants.adUseClient >> makes the intent much clearer. >> >> hth >> Roger From rwupole at msn.com Sun Dec 25 07:36:14 2005 From: rwupole at msn.com (Roger Upole) Date: Sun, 25 Dec 2005 01:36:14 -0500 Subject: [python-win32] Re: Adding Printers on Windows XP References: <43AAFD7D.8060108@vt.edu> Message-ID: A null DEVMODE usually indicates a problem with the printer driver. Are you sure you have the correct driver installed on the local machine ? Also, what do you get back from GetPrinter for DriverName ? A couple of things you could try: Use win32print.DocumentProperties to retreive the printer's DEVMODE Create one yourself using pywintypes.DEVMODEType() and insert it into the pInfo dict hth Roger ----- Original Message ----- From: "Brad Tilley" To: Sent: Thursday, December 22, 2005 2:24 PM Subject: [python-win32] Adding Printers on Windows XP > When I do this: > > import win32print > printers = ['http://128.173.120.65'] > for printer in printers: > pHandle = win32print.OpenPrinter(printer, None) > #print pHandle > > pInfo = win32print.GetPrinter(pHandle, 2) > #print pInfo > > win32print.ClosePrinter(pHandle) > > pAdd = win32print.AddPrinter(None, 2, pInfo) > > I get this error: > > Traceback (most recent call last): > File "C:\Documents and Settings\Administrator\Desktop\printers.py", > line 15, in ? > pAdd = win32print.AddPrinter(None, 2, pInfo) > ValueError: PyDEVMODE cannot be None in this context > > Any ideas? > > > From dzrudy at gmail.com Tue Dec 27 15:03:21 2005 From: dzrudy at gmail.com (Dawid Zamirski) Date: Tue, 27 Dec 2005 09:03:21 -0500 Subject: [python-win32] FetchProgress event problem In-Reply-To: References: <43AC4ACA.3050504@gmail.com> Message-ID: <43B149A9.6080900@gmail.com> Success! The PumpWaitingMessages method solved the problem and the events are called now. Thank You, Dawid Roger Upole wrote: > Try adding pythoncom.PumpWaitingMessages() at the point where > you're waiting for the fetch to complete. The events show up for > me if I add this loop to the bottom of the test function: > while 1: > pythoncom.PumpWaitingMessages() > time.sleep(0.1) > > Roger > > > ----- Original Message ----- > From: "Dawid Zamirski" > To: > Sent: Friday, December 23, 2005 2:06 PM > Subject: Re: [python-win32] FetchProgress event problem > > > >> The objects last quite long because it's a huge database (about 730000 >> records) and it takes a few minutes to load, that is why I wanted to >> track the progress so the user know that something is happening. As for >> now, I implemented "pulse" progress bar to notify the user of activity, >> however accurate progress bar would be nicer >> >> Roger Upole wrote: >> >>> It's likely your recordset and connection objects are going out >>> of scope before they get a chance to fire any events. As soon as >>> the function exits, both of the COM objects will be released. >>> >>> Also, you might want to use the named constants from >>> win32com.client.constants in place of hardcoded values. >>> rs.CursorLocation=win32com.client.constants.adUseClient >>> makes the intent much clearer. >>> >>> hth >>> Roger >>> > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From gregpinero at gmail.com Tue Dec 27 22:07:01 2005 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Tue, 27 Dec 2005 16:07:01 -0500 Subject: [python-win32] win32com.client - How to raise an exception after timeout Message-ID: <312cfe2b0512271307g1c4617cdh5dc8ab08608f4734@mail.gmail.com> Hi guys, I'm working with the COM stuff in python-win32 to talk to QuickBooks and in the last line of the code below, the function just hangs (forever?). I was hoping someone could enlighten me on how to have an exception raised after a specified time has passed so I can clean up and continue my program? import win32com.client from QBCONSTANTS import * #all the QB consts? qbxmlrp = win32com.client.DispatchEx("QbXMLRP2e.RequestProcessor") qbxmlrp.OpenConnection(None, application_name) qbxmlrp.BeginSession(r'file1.qbw', win32com.client.constants.qbFileOpenDoNotCare) What I've tried so far: I looked into doing a Python threading approach, but even when I figured out how to kill a thread (http://tinyurl.com/ey7lo), I can't do it here because this function is stalling below the Python level. Even then I found a Unix only solution (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/307871) using the signal module but that doens't help me here. Any help is greatly appriciated. -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com)