From lefevrol at yahoo.com Tue Nov 1 20:37:33 2005 From: lefevrol at yahoo.com (Olivier Lefevre) Date: Tue, 01 Nov 2005 20:37:33 +0100 Subject: [python-win32] Illegal instruction while installing win32 extensions Message-ID: Trying to run pywin32-205.win32-py2.4.exe on a Windows XP SP2 machine with a HT P4 processor gives me "The NTVDM CPU has encountered an illegal instruction error". Any idea? -- O.L. From sjmachin at lexicon.net Tue Nov 1 21:59:58 2005 From: sjmachin at lexicon.net (John Machin) Date: Wed, 02 Nov 2005 07:59:58 +1100 Subject: [python-win32] Illegal instruction while installing win32 extensions In-Reply-To: References: Message-ID: <4367D74E.1030402@lexicon.net> Olivier Lefevre wrote: > Trying to run pywin32-205.win32-py2.4.exe on a Windows XP SP2 machine > with a HT P4 processor gives me "The NTVDM CPU has encountered an > illegal instruction error". Any idea? > Gives me one of those stupid "do you want to send your life history to Microsoft" dialogue boxes, not an error message as quoted above. Looks like the offending instruction is in ntdll.dll ... Works OK on Windows 2000 SP 4, with an AMD Athlon CPU. From spamtrap at day8.com.au Wed Nov 2 05:35:15 2005 From: spamtrap at day8.com.au (Michael Thompson) Date: Wed, 02 Nov 2005 15:35:15 +1100 Subject: [python-win32] win32com and static dispatch Message-ID: I've come across something puzzling about static dispatch. I've used win32com a bit and normally understand what is going on, but I've stubed my toe on something here that I just can't understand. It almost looks like a bug ... Dynamic dispatch works: (First I go to 'C:\Python24\Lib\site-packages\win32com\gen_py' and remove all the generated '.py') >>> import win32com.client >>> dispatch = win32com.client.Dispatch >>> xlApp = dispatch('Excel.Application') >>> books = xlApp.Workbooks.Open('SomeNew.xls') >>> books > And if I try to use 'books', no problems: >>> sheet = books.WorkSheets('sheet1') >>> sheet > Great. So dynamic dispatch works just fine. Except, of course, I can't get the 'constants' and its a bit inefficient, so I tried switching to static dispatch: >>> dispatch = win32com.client.gencache.EnsureDispatch >>> xlApp = dispatch('Excel.Application') >>> books = xlApp.Workbooks.Open('SomeNew.xls') But now, when I look at 'books': >>> books which seems to mean 'books' is unusable: >>> books.WorkSheets('channels') Traceback (most recent call last): ... AttributeError: '' object has no attribute 'WorkSheets' The only way around this seems to be: >>> books = win32com.client.Dispatch(books) which means 'books' changes to become: >>> books And therefor is now usable: >>> sheet = books.Worksheets('sheet1') No traceback! So, I've learned (much like a mouse in a maze), that I have to add the line: books = win32com.client.Dispatch(books) and static dispatch will work. What I don't understand is why, under staic dispatch, 'books' becomes this unusable object: instead of something useful like either of these two: > I looked in C:\Python24\Lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-000000000046x0x1x5 which is the folder created by win32com.client.gencache.EnsureDispatch, and, sure enough, it contains all the code for 'Workbook', so its known. And if you look at the AttributeError traceback given above, it correctly identifies the object as: despite claiming that it doesn't have the attribute of that class. Also strange it doesn't seem to happen for all classes of object. For example, if I continue on: >>> sheet = books.Worksheets('sheet1') >>> rng = sheet sheet.Range('A2:B11') >>> rng In effect, the Range object is correctly identified and useable without having to do this (which I had to do for books): >>> rng = win32com.client.Dispatch(rng) I don't understand the ins and outs of this. I'm left thinking: * there is a bug in the type library suppied which is causing win32com to do something odd * there is a bug in win32com * there's something really important that I don't know and I don't even know where to look. I'm on Windows XP, Python 2.4, win32com ???? (something installed within the last month), Excel 2003 SP1. Any help appreciated. Cheers, Mike From spamtrap at day8.com.au Wed Nov 2 23:35:42 2005 From: spamtrap at day8.com.au (Michael Thompson) Date: Thu, 03 Nov 2005 09:35:42 +1100 Subject: [python-win32] win32com and static dispatch In-Reply-To: References: Message-ID: Michael Thompson wrote: > > Great. So dynamic dispatch works just fine. Except, of course, I can't > get the 'constants' and its a bit inefficient, so I tried switching to > static dispatch: > > >>> dispatch = win32com.client.gencache.EnsureDispatch > >>> xlApp = dispatch('Excel.Application') > >>> books = xlApp.Workbooks.Open('SomeNew.xls') > > But now, when I look at 'books': > > >>> books > > > which seems to mean 'books' is unusable: > > >>> books.WorkSheets('channels') > Traceback (most recent call last): > ... > AttributeError: ' Library._Workbook instance at 0x13234048>' object has no attribute > 'WorkSheets' > I've found the problem. Groan. Dynamic and Static dispatch differ WRT to case sensitivity. My tests involved this: >>> books.WorkSheets('channels') You'll see that I'm incorrectly using CamelCase for 'Worksheets'. Using Dynamic dispatch I got away with this "case" error, but not with static dispatch. -- Mike From spamtrap at day8.com.au Thu Nov 3 00:47:01 2005 From: spamtrap at day8.com.au (Michael Thompson) Date: Thu, 03 Nov 2005 10:47:01 +1100 Subject: [python-win32] win32com and GetRef Message-ID: I'm using win32com to manipulate the DOM inside of Internet Explorer. Something like this: #--------------------------------------------------------------------------- import win32com.client ie = win32com.client.Dispatch('InternetExplorer.Application') ie.Navigate('about:about') body = ie.Document.getElementsByTagName("BODY")[0] # # Now comes the tricky part, I need to supply a "pointer-to-a-function" # def init(): pass body.onload = init # XXXXXX Problem here #--------------------------------------------------------------------------- Everything works a treat until the line marked XXXXXX. It fails with an exception: TypeError: Objects of type 'function' can not be converted to a COM VARIANT I'm need to effectively supply callback function for an event. If I where using javascript, this line would be fine as is. If I was using VB, then it would look like this: body.onload = GetRef("init") So, my question is how do I make the line marked XXXXX work in python? Is it possible? Any pointers greatly appreciated. Further Question: if its not possible would I be able to do this using Mozilla and pyxcom? -- Mike From mhammond at skippinet.com.au Thu Nov 3 02:45:39 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 3 Nov 2005 12:45:39 +1100 Subject: [python-win32] win32com and GetRef In-Reply-To: Message-ID: > I'm using win32com to manipulate the DOM inside of Internet > Explorer. Something like this: > > #----------------------------------------------------------------- > ---------- > import win32com.client > > ie = win32com.client.Dispatch('InternetExplorer.Application') > ie.Navigate('about:about') > body = ie.Document.getElementsByTagName("BODY")[0] > > # > # Now comes the tricky part, I need to supply a "pointer-to-a-function" > # > def init(): > pass > > body.onload = init # XXXXXX Problem here You need to have a look at win32com.client.DispatchWithEvents. Python takes a different approach to hookup events. >>> import win32com.client >>> help(win32com.client.DispatchWithEvents) > Further Question: if its not possible would I be able to do this > using Mozilla and pyxcom? Not from an external process, no - xpcom does not work across processes. If you wanted to write a Mozilla extension (ie, some "chrome"), then other work I am doing with the Mozilla guys will soon make this possible - you will be able to use Python whereever you can currently use JS - but that's a different story Mark From Ola.Rylow at hiq.se Thu Nov 3 08:25:44 2005 From: Ola.Rylow at hiq.se (Ola Rylow) Date: Thu, 3 Nov 2005 08:25:44 +0100 Subject: [python-win32] Reading custom output parameters from LabVIEW/ActiveX Message-ID: <31A473DBB655D21180850008C71E251A099DB000@mail.kebne.se> Hi! I'm running LabVIEW as a ActiveX server and access it from Python (which is a quit new language for me). Now I have encountered a problem when trying to read an output control that is a RefNum (actually a strict type def that I think is based on a DataLogRefNum containing a Enum). I get the following error message: "pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352571), 2)" Has anyone experience of reading LabVIEW RefNums controls using ActiveX from Python? Or any other comments on problems when reading custom output parameters from COM object? How do you handle parameters of "unknown" type? Thanks! Ola From tim.golden at viacom-outdoor.co.uk Thu Nov 3 09:26:52 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu, 3 Nov 2005 08:26:52 -0000 Subject: [python-win32] win32com and static dispatch Message-ID: <9A28C052FF32734DACB0A288A3533991044D22E4@vogbs009.gb.vo.local> [Michael Thompson] > I've found the problem. Groan. > Dynamic and Static dispatch differ WRT to case sensitivity. You've probably realised but, just in case, the case-sensitivity is a by-product of the fact that static dispatch actually creates a Python module to act as a proxy for the COM objects, and since Python is case sensitive... (Just trying to be helpful) 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 davidf at sjsoft.com Thu Nov 3 14:52:40 2005 From: davidf at sjsoft.com (David Fraser) Date: Thu, 03 Nov 2005 15:52:40 +0200 Subject: [python-win32] win32com and GetRef In-Reply-To: References: Message-ID: <436A1628.9030706@sjsoft.com> Mark Hammond wrote: >Not from an external process, no - xpcom does not work across processes. If >you wanted to write a Mozilla extension (ie, some "chrome"), then other work >I am doing with the Mozilla guys will soon make this possible - you will be >able to use Python whereever you can currently use JS - but that's a >different story > Any way of helping you out with this / watching updates on your progress? Are you committing to the mozilla CVS? Its very exciting :-) David From geon at post.cz Thu Nov 3 17:18:56 2005 From: geon at post.cz (geon) Date: Thu, 03 Nov 2005 17:18:56 +0100 Subject: [python-win32] win32com and static dispatch In-Reply-To: References: Message-ID: <436A3870.1050702@post.cz> Does there exist any tutorial/manual about static vs. dynamic dispatch? Thank you Pavel From theller at python.net Thu Nov 3 18:48:35 2005 From: theller at python.net (Thomas Heller) Date: Thu, 03 Nov 2005 18:48:35 +0100 Subject: [python-win32] win32com and static dispatch References: <436A3870.1050702@post.cz> Message-ID: geon writes: > Does there exist any tutorial/manual about static vs. dynamic dispatch? > > Thank you > Pavel Mark Hammond's book "Programming Python on win32". http://www.oreilly.com/catalog/pythonwin32/ A sample chapter is online: http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html Thomas From mc at mclaveau.com Thu Nov 3 22:55:47 2005 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 3 Nov 2005 22:55:47 +0100 Subject: [python-win32] win32com and COM-dynamic-server References: <436A3870.1050702@post.cz> Message-ID: <000a01c5e0c1$5d548fa0$0701a8c0@PORTABLES> Good evening! I have troubles with dynamic COM. I made, with PyWin, a dynamic extension of my COM-server. If I call the COM-server since VB-Script, it is OK, with the names of functions (call) in small letters. If I call the COM-server since ObjectPAL (Paradox), it is OK, with the names of functions (call) converted in capital letters. If I call the COM-server since Javascript, it is OK, with the names of functions (call) in small letters. BUT, if I call the COM-server since Python, no parameter sended!. The names of functions are in small letters, but no other parameter is transmitted. To check, I supervised the line: def _dynamic_(self, name, lcid, wFlags, args): I tested Dispatch, DispatchEx, dynamic.Dispatch, without more success. It should be noted that, if I remove the line: _ reg_policy_spec _ = "DynamicPolicy" The problem disappears. My question: how to use (call functions with parameters) a (my) dynamic-COM-server-Python, since Python? Last infos : Python 2.4.2 ; PyWin32 205 ; Win-XP-SP2 ; Bedside's book: "Programming Python on win32". Thank you in advance, for any answer Michel Claveau From mhammond at skippinet.com.au Thu Nov 3 23:19:56 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 4 Nov 2005 09:19:56 +1100 Subject: [python-win32] win32com and GetRef In-Reply-To: <436A1628.9030706@sjsoft.com> Message-ID: > Mark Hammond wrote: > > >Not from an external process, no - xpcom does not work across > processes. If > >you wanted to write a Mozilla extension (ie, some "chrome"), > then other work > >I am doing with the Mozilla guys will soon make this possible - > you will be > >able to use Python whereever you can currently use JS - but that's a > >different story > > > Any way of helping you out with this / watching updates on your > progress? Are you committing to the mozilla CVS? > Its very exciting :-) Yes, it is good fun! I'm doing this work on a DOM_AGNOSTIC2_BRANCH branch, and if you know enough voodoo to pull mozilla CVS and build it from source, then I would *love* some help - at this stage I would love some better samples and tests. Mark From mhammond at skippinet.com.au Thu Nov 3 23:19:55 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 4 Nov 2005 09:19:55 +1100 Subject: [python-win32] win32com and COM-dynamic-server In-Reply-To: <000a01c5e0c1$5d548fa0$0701a8c0@PORTABLES> Message-ID: When Python code does: obj.foo(1) On a COM object that has no makepy support, Python will first query the object if it has a *property* named 'foo' before it asks if it has a *method* named foo. I suspect you are seeing this. To work correctly in this case, Python will be expecting the property reference to fail (so it can determine it is indeed a method) > of functions are in small letters, but no other parameter is transmitted. > To check, I supervised the line: > def _dynamic_(self, name, lcid, wFlags, args): The wFlags param of that call indicates if it is a property or method reference. If it does turn out to be a property reference, there will be no args passed. > > I tested Dispatch, DispatchEx, dynamic.Dispatch, without more success. > > It should be noted that, if I remove the line: > _ reg_policy_spec _ = "DynamicPolicy" > The problem disappears. > > > My question: how to use (call functions with parameters) a (my) > dynamic-COM-server-Python, since Python? > > Last infos : Python 2.4.2 ; PyWin32 205 ; Win-XP-SP2 ; Bedside's book: > "Programming Python on win32". Have a look at page 220 - it has an example of _dynamic_ checking wFlags. Cheers, Mark From mc at mclaveau.com Fri Nov 4 01:25:01 2005 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 4 Nov 2005 01:25:01 +0100 Subject: [python-win32] win32com and COM-dynamic-server References: Message-ID: <000801c5e0d6$356609f0$0701a8c0@PORTABLES> Hi! >>> Python will first query the object if it has a *property* named 'foo' >>> before it asks if it has a *method* named foo. I suspect you are seeing >>> this. Yes, you are right! Python send wFlags=pythoncom.DISPATCH_PROPERTYGET With your advice, I had found than : if wFlags & pythoncom.DISPATCH_PROPERTYGET: raise COMException("inexistant", winerror.DISP_E_MEMBERNOTFOUND) solve the problem. Thank, Mark. You are great, in the Python's hall of fame! Good night. Michel Claveau From rmcburne at telcordia.com Thu Nov 3 22:39:44 2005 From: rmcburne at telcordia.com (McBurnett, Roe D) Date: Thu, 3 Nov 2005 16:39:44 -0500 Subject: [python-win32] n00b problems accessing Outlook Message-ID: Hi People, I am new to Python, just installed the ActivePython 2.4.1 and downloaded pywin32-205.win32-py2.4.exe. I executed the provided demo application outlookAddin.py and got the following error message: C:\Python24\Lib\site-packages\win32com\demos>outlookAddin Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\demos\outlookAddin.py", line 38,in ? gencache.EnsureModule('{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}', 0, 2, 1, bForDemand=True) # Office 9 File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 407, in EnsureModule module = GetModuleForTypelib(typelibCLSID, tlbAttr[1], tlbAttr[3], tlbAttr[4]) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 258, in GetModuleForTypelib mod = _GetModule(modName) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 629, in _GetModule mod = __import__(mod_name) File "C:\Python24\lib\site-packages\win32com\gen_py\2DF8D04C-5BFA-101B-BDE5-0 0AA0044DE52x0x2x2\__init__.py", line 1691 win32com.client.constants.__dicts__.append(constants.__dict__) ^ SyntaxError: invalid syntax C:\Python24\Lib\site-packages\win32com\demos>outlookAddin I edited the "C:\Python24\lib\site-packages\win32com\gen_py\2DF8D04C-5BFA-101B-BDE5-0 0AA0044DE52x0x2x2\__init__.py" file to remove a few comment lines and re-executed with the following results: C:\Python24\Lib\site-packages\win32com\demos>outlookAddin Registered: Python.Test.OutlookAddin So I followed the instructions in the module: # To debug, execute: # outlookAddin.py --debug # # Then open Pythonwin, and select "Tools->Trace Collector Debugging Tool" # Restart Outlook, and you should see some output generated. With these results: C:\Python24\Lib\site-packages\win32com\demos>outlookAddin --debug Registered: Python.Test.OutlookAddin (for debugging) When I opened Pythonwin, and selected the Trace collector Debugging Tool and restarted Outlook I got this in the Python Trace Collector Window: # This window will display output from any programs that import win32traceutil # win32com servers registered with '--debug' are in this category. Object with win32trace dispatcher created (object=None) pythoncom error: Failed to call the universal dispatcher Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\universal.py", line 177, in dispatch retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 332, in _InvokeEx_ return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 653, in _invokeex_ args, kwArgs = self._transform_args_(args, kwArgs, dispid, lcid, wFlags, serviceProvider) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 640, in _transform_args_ arg = win32com.client.Dispatch(arg) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 38, in __WrapDispatch klass = gencache.GetClassForCLSID(resultCLSID) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 179, in GetClassForCLSID mod = GetModuleForCLSID(clsid) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 232, in GetModuleForCLSID __import__(sub_mod_name) exceptions.SyntaxError: invalid syntax (_Application.py, line 87) pythoncom error: Unexpected gateway error Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\universal.py", line 177, in dispatch retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 332, in _InvokeEx_ return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 653, in _invokeex_ args, kwArgs = self._transform_args_(args, kwArgs, dispid, lcid, wFlags, serviceProvider) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 640, in _transform_args_ arg = win32com.client.Dispatch(arg) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 38, in __WrapDispatch klass = gencache.GetClassForCLSID(resultCLSID) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 179, in GetClassForCLSID mod = GetModuleForCLSID(clsid) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 232, in GetModuleForCLSID __import__(sub_mod_name) exceptions.SyntaxError: invalid syntax (_Application.py, line 87) Can anyone shed any light on what is going on? Thanks -Roe McBurnett rdm2ATmcburnettDOTorg -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051103/7b8103e1/attachment.html From ebiaugustine at yahoo.com Fri Nov 4 23:42:32 2005 From: ebiaugustine at yahoo.com (John Augustine) Date: Fri, 4 Nov 2005 14:42:32 -0800 (PST) Subject: [python-win32] Installation issues.... Message-ID: <20051104224232.17426.qmail@web60125.mail.yahoo.com> Hello, I am trying to install Python 2.4.2 on my XP laptop using the MS installer (http://www.python.org/ftp/python/2.4.2/python-2.4.2.msi) and I get this error message when I run it: The cabinet file "python" required for this installation is corrupt and cannot be used. This could indicate network error or problem with the package. I downloaded it several times using both IE and mozilla just in case it was a download error. That did not resolve it. Has anybody else encountered this and resolved it? Let me know how you did it. Thanks, John. __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com From gregpinero at gmail.com Sat Nov 5 18:29:56 2005 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Sat, 5 Nov 2005 12:29:56 -0500 Subject: [python-win32] Pythonwin - Word automation - Removing watermark not working In-Reply-To: <312cfe2b0511031655x22c866cdj8bd213d4d3be4ea7@mail.gmail.com> References: <312cfe2b0511031655x22c866cdj8bd213d4d3be4ea7@mail.gmail.com> Message-ID: <312cfe2b0511050929u410f4266gcb280a149b97d1d0@mail.gmail.com> Hi everybody. I originally sent this question to the main Python list to have it be met with roaring silence ;-) Someone there suggested I try this group instead. Any help or suggestions would be greatly appriciated. Thanks, -Greg ---------- Forwarded message ---------- From: Gregory Pi?ero Date: Nov 3, 2005 7:55 PM Subject: Pythonwin - Word automation - Removing watermark not working To: python-list at python.org I thought I'd take a shot and see if anyone knows the answer to this? I've been stuck for a while now on this. Would anyone happen to know why this my function removewatermark() in this code isn't working? I copied it from a Word macro I recorded and it did work when I recorded the macro. When I run it the watermark doesn't go away. I've also attached the code in case the formatting gets messed up from the email. import sys import os from win32com.client import gencache, constants WORD='Word.Application' False,True=0,-1 class Word: def __init__(self): self.app=gencache.EnsureDispatch(WORD) self.app.Visible = 1 self.app.DisplayAlerts = 0 def open(self,doc): self.app.Documents.Open(FileName=doc) def removewatermark(self): self.app.ActiveDocument.Sections(1).Range.Select() self.app.ActiveWindow.ActivePane.View.SeekView = 9 # wdSeekCurrentPageHeader self.app.Selection.HeaderFooter.Shapes("PowerPlusWaterMarkObject1").Select() self.app.Selection.Delete() self.app.ActiveWindow.ActivePane.View.SeekView = 0 #wdSeekMainDocument Thanks, Greg -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com ) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051105/57548658/attachment.html -------------- next part -------------- import sys import os from win32com.client import gencache, constants WORD='Word.Application' False,True=0,-1 class Word: def __init__(self): self.app=gencache.EnsureDispatch(WORD) self.app.Visible = 1 self.app.DisplayAlerts = 0 def open(self,doc): self.app.Documents.Open(FileName=doc) def removewatermark(self): self.app.ActiveDocument.Sections(1).Range.Select() self.app.ActiveWindow.ActivePane.View.SeekView = 9 # wdSeekCurrentPageHeader self.app.Selection.HeaderFooter.Shapes("PowerPlusWaterMarkObject1").Select() self.app.Selection.Delete() self.app.ActiveWindow.ActivePane.View.SeekView = 0 #wdSeekMainDocument From sjmachin at lexicon.net Sat Nov 5 20:09:16 2005 From: sjmachin at lexicon.net (John Machin) Date: Sun, 06 Nov 2005 06:09:16 +1100 Subject: [python-win32] Pythonwin - Word automation - Removing watermark not working In-Reply-To: <312cfe2b0511050929u410f4266gcb280a149b97d1d0@mail.gmail.com> References: <312cfe2b0511031655x22c866cdj8bd213d4d3be4ea7@mail.gmail.com> <312cfe2b0511050929u410f4266gcb280a149b97d1d0@mail.gmail.com> Message-ID: <436D035C.5080001@lexicon.net> Gregory Pi?ero wrote: > > Would anyone happen to know why this my function removewatermark() in > this code isn't working? I copied it from a Word macro I recorded and > it did work when I recorded the macro. When I run it the watermark > doesn't go away. > > I've also attached the code in case the formatting gets messed up from > the email. > > > > import sys > import os > from win32com.client import gencache, constants Idle curiosity: why import constants but not use it? > WORD='Word.Application' > False,True=0,-1 > > class Word: > def __init__(self): > self.app=gencache.EnsureDispatch(WORD) > self.app.Visible = 1 > self.app.DisplayAlerts = 0 What does this do? Suppress any warnings? > def open(self,doc): > self.app.Documents.Open(FileName=doc) > def removewatermark(self): > self.app.ActiveDocument.Sections(1).Range.Select() > self.app.ActiveWindow.ActivePane.View.SeekView = 9 # > wdSeekCurrentPageHeader ... the cause of the "idle curiosity" question. > > self.app.Selection.HeaderFooter.Shapes("PowerPlusWaterMarkObject1").Select() Have you tried inspecting self.app.Selection before and after the attempt to .Delete() it? > self.app.Selection.Delete() > self.app.ActiveWindow.ActivePane.View.SeekView = 0 > #wdSeekMainDocument > > How do you know it didn't work? Your class and its methods don't have any problems that I can see -- but it's early here and I'm not quite awake. Is it possible for you to show us the few lines of code that you actually used to test this? You know, something like: wc = Word() wc.open("myfile.doc") wc.removewatermark() # then what? Cheers, John From gregpinero at gmail.com Sat Nov 5 21:15:40 2005 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Sat, 5 Nov 2005 15:15:40 -0500 Subject: [python-win32] Pythonwin - Word automation - Removing watermark not working In-Reply-To: <436D035C.5080001@lexicon.net> References: <312cfe2b0511031655x22c866cdj8bd213d4d3be4ea7@mail.gmail.com> <312cfe2b0511050929u410f4266gcb280a149b97d1d0@mail.gmail.com> <436D035C.5080001@lexicon.net> Message-ID: <312cfe2b0511051215w695b6b55h2a68073c1a6026e@mail.gmail.com> See below: On 11/5/05, John Machin wrote: > > Gregory Pi?ero wrote: > > > > > Would anyone happen to know why this my function removewatermark() in > > this code isn't working? I copied it from a Word macro I recorded and > > it did work when I recorded the macro. When I run it the watermark > > doesn't go away. > > > > I've also attached the code in case the formatting gets messed up from > > the email. > > > > > > > > import sys > > import os > > from win32com.client import gencache, constants > > Idle curiosity: why import constants but not use it? It was giving me errors when I tried to use the constants so I stopped using them. A future question perhaps... > WORD='Word.Application' > > False,True=0,-1 > > > > class Word: > > def __init__(self): > > self.app=gencache.EnsureDispatch(WORD) > > self.app.Visible = 1 > > self.app.DisplayAlerts = 0 > > What does this do? Suppress any warnings? That is correct. > def open(self,doc): > > self.app.Documents.Open(FileName=doc) > > def removewatermark(self): > > self.app.ActiveDocument.Sections(1).Range.Select() > > self.app.ActiveWindow.ActivePane.View.SeekView = 9 # > > wdSeekCurrentPageHeader > > ... the cause of the "idle curiosity" question. This doesn't bother me much to write out numbers. > > > self.app.Selection.HeaderFooter.Shapes > ("PowerPlusWaterMarkObject1").Select() > > Have you tried inspecting self.app.Selection before and after the > attempt to .Delete() it? What do you mean by inspect? > self.app.Selection.Delete() > > self.app.ActiveWindow.ActivePane.View.SeekView = 0 > > #wdSeekMainDocument > > > > > > How do you know it didn't work? Well I run my code, word opens the file, other changes happen, but the watermark doesn't dissapear. Your class and its methods don't have any problems that I can see -- > but it's early here and I'm not quite awake. Is it possible for you to > show us the few lines of code that you actually used to test this? You > know, something like: > > wc = Word() > wc.open("myfile.doc") > wc.removewatermark() > # then what? Something like this: word=Word() word.open("myfile.doc") word.replace("[Sender]","Bill Brown") #replace a word word.removewatermark() word.printdoc(numcopies=3) #prints, works fine word.close() #closes doc word.quit() #shuts down word I only included the relevant parts of this class. So you see some methods above that aren't in my class. I guess I should have included the whole class, sorry. Now I can't get back to that code until Tuesday :-( But all of the methods work fine except for removewatermark. -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com ) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051105/82a623a9/attachment.htm From sjmachin at lexicon.net Sun Nov 6 01:25:18 2005 From: sjmachin at lexicon.net (John Machin) Date: Sun, 06 Nov 2005 11:25:18 +1100 Subject: [python-win32] Pythonwin - Word automation - Removing watermark not working In-Reply-To: <312cfe2b0511051215w695b6b55h2a68073c1a6026e@mail.gmail.com> References: <312cfe2b0511031655x22c866cdj8bd213d4d3be4ea7@mail.gmail.com> <312cfe2b0511050929u410f4266gcb280a149b97d1d0@mail.gmail.com> <436D035C.5080001@lexicon.net> <312cfe2b0511051215w695b6b55h2a68073c1a6026e@mail.gmail.com> Message-ID: <436D4D6E.2060406@lexicon.net> Gregory Pi?ero wrote: > See below: > > On 11/5/05, *John Machin* > wrote: > > Gregory Pi?ero wrote: > > > > > Would anyone happen to know why this my function removewatermark() in > > this code isn't working? I copied it from a Word macro I > recorded and > > it did work when I recorded the macro. When I run it the watermark > > doesn't go away. > > > > I've also attached the code in case the formatting gets messed up > from > > the email. > > > > > > > > import sys > > import os > > from win32com.client import gencache, constants > > Idle curiosity: why import constants but not use it? > > > It was giving me errors when I tried to use the constants so I stopped > using them. A future question perhaps... > > > WORD='Word.Application' > > False,True=0,-1 > > > > class Word: > > def __init__(self): > > self.app=gencache.EnsureDispatch(WORD) > > self.app.Visible = 1 > > self.app.DisplayAlerts = 0 > > What does this do? Suppress any warnings? > > > That is correct. Try unsuppressing warnings. You may learn something. > > > > def open(self,doc): > > self.app.Documents.Open(FileName=doc) > > def removewatermark(self): > > self.app.ActiveDocument.Sections(1).Range.Select() > > self.app.ActiveWindow.ActivePane.View.SeekView = 9 # > > wdSeekCurrentPageHeader > > ... the cause of the "idle curiosity" question. > > > This doesn't bother me much to write out numbers. It mightn't bother you. Seeing hard-coded magic numbers bothers the bejasus out of many people. > > > > > > self.app.Selection.HeaderFooter.Shapes("PowerPlusWaterMarkObject1").Select() > > > Have you tried inspecting self.app.Selection before and after the > attempt to .Delete() it? > > > What do you mean by inspect? It is an object. It must have some properties that you can retrieve and display so that you have some reassurance that you've actually got the object you think you've got. > > > self.app.Selection.Delete() What happens if you try foo.Delete() and foo is frozen/write-protected/whatever? > > self.app.ActiveWindow.ActivePane.View.SeekView = 0 > > #wdSeekMainDocument > > > > > > How do you know it didn't work? > > > Well I run my code, word opens the file, other changes happen, but the > watermark doesn't dissapear. > > Your class and its methods don't have any problems that I can see -- > but it's early here and I'm not quite awake. Is it possible for you to > show us the few lines of code that you actually used to test this? You > know, something like: > > wc = Word() > wc.open("myfile.doc") > wc.removewatermark() > # then what? > > > Something like this: > > word=Word() > word.open("myfile.doc") > word.replace("[Sender]","Bill Brown") #replace a word > word.removewatermark() > word.printdoc(numcopies=3) #prints, works fine > word.close() #closes doc > word.quit() #shuts down word > > I only included the relevant parts of this class. So you see some > methods above that aren't in my class. I guess I should have included > the whole class, sorry. Now I can't get back to that code until Tuesday :-( > But all of the methods work fine except for removewatermark. > We're not interested in the parts of your class that are irrelevant to the problem. If by Tuesday, no-one has been able to help you by inspecting the code that you have shown so far, considering doing this: 1. Make up a *small* .doc file with your watermark in it. Make it from scratch i.e. don't copy an existing file and delete your proprietary info -- it may not actually be deleted. 2. Assemble the *minimal* Python script that demonstrates the problem. 3. Send it to this mailing list. Include in your message which version of (a) Python (2) win32com (3) MS Word (4) MS Windows you are using. HTH, John From gregpinero at gmail.com Sun Nov 6 04:32:27 2005 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Sat, 5 Nov 2005 22:32:27 -0500 Subject: [python-win32] Pythonwin - Word automation - Removing watermark not working In-Reply-To: <436D4D6E.2060406@lexicon.net> References: <312cfe2b0511031655x22c866cdj8bd213d4d3be4ea7@mail.gmail.com> <312cfe2b0511050929u410f4266gcb280a149b97d1d0@mail.gmail.com> <436D035C.5080001@lexicon.net> <312cfe2b0511051215w695b6b55h2a68073c1a6026e@mail.gmail.com> <436D4D6E.2060406@lexicon.net> Message-ID: <312cfe2b0511051932i67f9f5e7sa32969661f3ff91f@mail.gmail.com> Thanks, John. I'll try your ideas on Tuesday and see what happens. They sound promising. If I'm still having problems I'll try sending a sample word file like you said. -Greg On 11/5/05, John Machin wrote: > > Gregory Pi?ero wrote: > > See below: > > > > On 11/5/05, *John Machin* > > wrote: > > > > Gregory Pi?ero wrote: > > > > > > > > Would anyone happen to know why this my function removewatermark() in > > > this code isn't working? I copied it from a Word macro I > > recorded and > > > it did work when I recorded the macro. When I run it the watermark > > > doesn't go away. > > > > > > I've also attached the code in case the formatting gets messed up > > from > > > the email. > > > > > > > > > > > > import sys > > > import os > > > from win32com.client import gencache, constants > > > > Idle curiosity: why import constants but not use it? > > > > > > It was giving me errors when I tried to use the constants so I stopped > > using them. A future question perhaps... > > > > > WORD='Word.Application' > > > False,True=0,-1 > > > > > > class Word: > > > def __init__(self): > > > self.app=gencache.EnsureDispatch(WORD) > > > self.app.Visible = 1 > > > self.app.DisplayAlerts = 0 > > > > What does this do? Suppress any warnings? > > > > > > That is correct. > > Try unsuppressing warnings. You may learn something. > > > > > > > > > def open(self,doc): > > > self.app.Documents.Open(FileName=doc) > > > def removewatermark(self): > > > self.app.ActiveDocument.Sections(1).Range.Select() > > > self.app.ActiveWindow.ActivePane.View.SeekView = 9 # > > > wdSeekCurrentPageHeader > > > > ... the cause of the "idle curiosity" question. > > > > > > This doesn't bother me much to write out numbers. > > It mightn't bother you. Seeing hard-coded magic numbers bothers the > bejasus out of many people. > > > > > > > > > > > self.app.Selection.HeaderFooter.Shapes > ("PowerPlusWaterMarkObject1").Select() > > > > > > Have you tried inspecting self.app.Selection before and after the > > attempt to .Delete() it? > > > > > > What do you mean by inspect? > > It is an object. It must have some properties that you can retrieve and > display so that you have some reassurance that you've actually got the > object you think you've got. > > > > > > > > self.app.Selection.Delete() > > What happens if you try foo.Delete() and foo is > frozen/write-protected/whatever? > > > > > self.app.ActiveWindow.ActivePane.View.SeekView = 0 > > > #wdSeekMainDocument > > > > > > > > > > How do you know it didn't work? > > > > > > Well I run my code, word opens the file, other changes happen, but the > > watermark doesn't dissapear. > > > > Your class and its methods don't have any problems that I can see -- > > but it's early here and I'm not quite awake. Is it possible for you to > > show us the few lines of code that you actually used to test this? You > > know, something like: > > > > wc = Word() > > wc.open("myfile.doc") > > wc.removewatermark() > > # then what? > > > > > > Something like this: > > > > word=Word() > > word.open("myfile.doc") > > word.replace("[Sender]","Bill Brown") #replace a word > > word.removewatermark() > > word.printdoc(numcopies=3) #prints, works fine > > word.close() #closes doc > > word.quit() #shuts down word > > > > I only included the relevant parts of this class. So you see some > > methods above that aren't in my class. I guess I should have included > > the whole class, sorry. Now I can't get back to that code until Tuesday > :-( > > But all of the methods work fine except for removewatermark. > > > > We're not interested in the parts of your class that are irrelevant to > the problem. If by Tuesday, no-one has been able to help you by > inspecting the code that you have shown so far, considering doing this: > > 1. Make up a *small* .doc file with your watermark in it. Make it from > scratch i.e. don't copy an existing file and delete your proprietary > info -- it may not actually be deleted. > 2. Assemble the *minimal* Python script that demonstrates the problem. > 3. Send it to this mailing list. Include in your message which version > of (a) Python (2) win32com (3) MS Word (4) MS Windows you are using. > > HTH, > John > -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com ) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051105/3a649e89/attachment.html From avl at cad.ru Sun Nov 6 15:47:59 2005 From: avl at cad.ru (Alexey Lubimov) Date: Sun, 06 Nov 2005 17:47:59 +0300 Subject: [python-win32] com_error wrong conversation from python sequense (float, float, float) to Variant (double, double, double) Message-ID: <436E179F.9070207@cad.ru> - testcase begin ---------------------- import win32com.client acad=win32com.client.Dispatch("AutoCAD.Application.16") ms=acad.ActiveDocument.ModelSpace point = win32com.client.CastTo(ms.Item(0), "IAcadPoint") # get iterface coord = point.Coordinates # some debug information print "Object Summary - type numeric: %d, type name: %s, coordinates: %s" % (point.EntityType,point.EntityName,coord) point.Coordinates=coord # Trouble! - testcase end --------------------------- - output begin -------------------------- Object Summary - type numeric: 22, type name: AcDbPoint, coordinates: (-33.414681873609801, 243.83545432672364, 0.0) Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 307, in RunScript debugger.run(codeObject, __main__.__dict__, start_stepping=0) File "C:\Python24\Lib\site-packages\pythonwin\pywin\debugger\__init__.py", line 60, in run _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) File "C:\Python24\Lib\site-packages\pythonwin\pywin\debugger\debugger.py", line 631, in run exec cmd in globals, locals File "C:\decoder\Convert\testcase.py", line 13, in ? point.Coordinates=point.Coordinates File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 463, in __setattr__ self._oleobj_.Invoke(*(args + (value,) + defArgs)) com_error: (-2147352567, 'error', (0, None, None, None, 0, -2147024809), None) - output end ------------------------------------------------- Any idea? From tim.golden at viacom-outdoor.co.uk Mon Nov 7 09:36:57 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon, 7 Nov 2005 08:36:57 -0000 Subject: [python-win32] Installation issues.... Message-ID: <9A28C052FF32734DACB0A288A3533991044D22F2@vogbs009.gb.vo.local> [John Augustine] > I am trying to install Python 2.4.2 on my XP laptop > using the MS installer > (http://www.python.org/ftp/python/2.4.2/python-2.4.2.msi) > and I get this error message when I run it: > The cabinet file "python" required for this > installation is corrupt and cannot be used. This could >< indicate network error or problem with the package. No consolation, I'm sure, but I recently installed exactly the same version on my XP desktop (SP2, in case it matters) without problems. Have you tried ActiveState? They're only on 2.4.1, but unless you're after a particular bugfix I doubt it'll matter. At least it's a different packaging. http://www.activestate.com/Products/ActivePython/ 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 fepeacock at bulldoghome.com Mon Nov 7 16:34:01 2005 From: fepeacock at bulldoghome.com (Frank Peacock) Date: Mon, 7 Nov 2005 15:34:01 -0000 Subject: [python-win32] VBScript compilation error - expected end of statement Message-ID: Hello I am running a python script which calls an ESRI ArcGIS COM function called calculatefield. If the text variable I pass to this function is longer than 10 characters I get the following error: "Microsoft VBScript compilation error - expected end of statement". I do not know what I need to do to solve this problem. I have installed the latest WSH 5.6 but to no avail. The following is my code: # -------------------------------------------------------------------------- - # Create Time Field.py # Created on: Sun Nov 06 2005 11:37:26 PM # (generated by ArcGIS/ModelBuilder) # -------------------------------------------------------------------------- - # Import system modules import sys, string, os, win32com.client # Create the Geoprocessor object gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1") gp.SetProduct("ArcView") # Load required toolboxes... gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx") # Local variables... gp.workspace = "C:\\GIS_DATA\\Satellite\\CLAUS\\I2-235\\" try: fas=gp.ListFeatureClasses("*","POLYGON") fas.reset() fa=fas.next() while fa: text=fa[0:11] print text # Process: Calculate Field... gp.CalculateField_management(fa, "Time", text) fa=fas.next() except: gp.AddMessage(gp.GetMessages(2)) print gp.GetMessages(2) --- [This E-mail has been scanned for viruses but it is your responsibility to maintain up to date anti virus software on the device that you are currently using to read this email. ] From eric.powell at srs.gov Mon Nov 7 17:50:57 2005 From: eric.powell at srs.gov (eric.powell@srs.gov) Date: Mon, 07 Nov 2005 11:50:57 -0500 Subject: [python-win32] VBScript compilation error - expected end of statement In-Reply-To: Message-ID: Frank- How are you trying to run the script? Are you trying to use a front-end through ArcTool box, running it from the command line, or running it in PythonWin? All three should be roughly equivalent, however, it sounds like you trying to Access the script the Toolbox or Model Builder and ArcGIS is interpreting the script as being a VBScript and not python. Send me a private e-mail and we can discuss this some more (and I will bring my training materials to the office tommorrow), but I don' t think this is an issue for the general list, as it is an ESRI issue and not a Python issue. HTH- Eric Eric B. Powell Bechtel Savnnah River Inc. (803) 557-6612 "Frank Peacock" Sent by: python-win32-bounces at python.org 11/07/2005 10:34 AM Please respond to fepeacock at bulldoghome.com To cc Subject [python-win32] VBScript compilation error - expected end of statement Hello I am running a python script which calls an ESRI ArcGIS COM function called calculatefield. If the text variable I pass to this function is longer than 10 characters I get the following error: "Microsoft VBScript compilation error - expected end of statement". I do not know what I need to do to solve this problem. I have installed the latest WSH 5.6 but to no avail. The following is my code: # -------------------------------------------------------------------------- - # Create Time Field.py # Created on: Sun Nov 06 2005 11:37:26 PM # (generated by ArcGIS/ModelBuilder) # -------------------------------------------------------------------------- - # Import system modules import sys, string, os, win32com.client # Create the Geoprocessor object gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1") gp.SetProduct("ArcView") # Load required toolboxes... gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx") # Local variables... gp.workspace = "C:\\GIS_DATA\\Satellite\\CLAUS\\I2-235\\" try: fas=gp.ListFeatureClasses("*","POLYGON") fas.reset() fa=fas.next() while fa: text=fa[0:11] print text # Process: Calculate Field... gp.CalculateField_management(fa, "Time", text) fa=fas.next() except: gp.AddMessage(gp.GetMessages(2)) print gp.GetMessages(2) --- [This E-mail has been scanned for viruses but it is your responsibility to maintain up to date anti virus software on the device that you are currently using to read this email. ] _______________________________________________ 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/20051107/ff5f949a/attachment.htm From mpjoh1977 at yahoo.com.au Tue Nov 8 03:14:10 2005 From: mpjoh1977 at yahoo.com.au (Michael Johnstone) Date: Tue, 8 Nov 2005 13:14:10 +1100 (EST) Subject: [python-win32] com error Message-ID: <20051108021410.42557.qmail@web33607.mail.mud.yahoo.com> Hi I was hoping to get some help trouble shooting the following error: Traceback (most recent call last): File "C:\Python22\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\Deneb\BHSS\Projects\AKL_0502\VC\PythonApplications\OPCWriteTestor.py", line 103, in ? Sensor(1) File "C:\Deneb\BHSS\Projects\AKL_0502\VC\PythonApplications\OPCWriteTestor.py", line 100, in Sensor grpPinWheel.SyncWrite(num, sh, listval, errors)#, CID, SID) File "C:\Python22\Lib\site-packages\win32com\gen_py\F5F1FC84-DB0B-11D3-883B-0050041DD057x0x1x0.py", line 302, in SyncWrite , ServerHandles, Values, Errors) File "C:\Python22\Lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_( com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147024809), None) This is occuring whenever I try to use a method of a COM object. If I use VB this method doesn't fail. Thanks in advance for any help mike ____________________________________________________ Do you Yahoo!? Listen to over 20 online radio stations and watch the latest music videos on Yahoo! Music. http://au.launch.yahoo.com From mhammond at skippinet.com.au Tue Nov 8 04:11:15 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 8 Nov 2005 14:11:15 +1100 Subject: [python-win32] com error In-Reply-To: <20051108021410.42557.qmail@web33607.mail.mud.yahoo.com> Message-ID: > "C:\Python22\Lib\site-packages\win32com\client\__init__.py", > line 446, in _ApplyTypes_ > return self._get_good_object_( > com_error: (-2147352567, 'Exception occurred.', (0, > None, None, None, 0, -2147024809), None) The second value in that error tuple is the error code provided by the object. It didn't bother to fill in a message, but we can get one if it is a standard COM error: >>> pythoncom.GetScodeString(-2147024809) 'The parameter is incorrect.' >>> I'm not sure why it is throwing that specific error. I guess it may be "default params". Try passing explicit values for all params - explicitly pass pythoncom.Missing for ones you don't know the correct value for (the win32com framework will currently be passing pythoncom.Empty for them - the difference is subtle, but some objects are very picky about which one you choose (basically, 'Empty' means an empty param will be supplied to the object, whereas 'Missing' will tell pythoncom to not present that argument at all)) Mark From graham.bloice at trihedral.com Tue Nov 8 09:28:15 2005 From: graham.bloice at trihedral.com (Graham Bloice) Date: Tue, 8 Nov 2005 08:28:15 -0000 Subject: [python-win32] com error In-Reply-To: <20051108021410.42557.qmail@web33607.mail.mud.yahoo.com> Message-ID: > Traceback (most recent call last): > File > "C:\Python22\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", > line 310, in RunScript > exec codeObject in __main__.__dict__ > File > "C:\Deneb\BHSS\Projects\AKL_0502\VC\PythonApplications\OPCWriteTestor.py", > line 103, in ? > Sensor(1) > File > "C:\Deneb\BHSS\Projects\AKL_0502\VC\PythonApplications\OPCWriteTestor.py", > line 100, in Sensor > grpPinWheel.SyncWrite(num, sh, listval, errors)#, > CID, SID) > File > "C:\Python22\Lib\site-packages\win32com\gen_py\F5F1FC84-DB0B-11D3- > 883B-0050041DD057x0x1x0.py", > line 302, in SyncWrite > , ServerHandles, Values, Errors) > File > "C:\Python22\Lib\site-packages\win32com\client\__init__.py", > line 446, in _ApplyTypes_ > return self._get_good_object_( > com_error: (-2147352567, 'Exception occurred.', (0, > None, None, None, 0, -2147024809), None) > > Have you set errors to be an empty list before the call ? Graham From Ola.Rylow at hiq.se Tue Nov 8 14:35:26 2005 From: Ola.Rylow at hiq.se (Ola Rylow) Date: Tue, 8 Nov 2005 14:35:26 +0100 Subject: [python-win32] Reading custom output parameters from LabVIEW/Acti veX Message-ID: <31A473DBB655D21180850008C71E251A099DB007@mail.kebne.se> By using pythoncom.Missing, which I read about in another thread, I got a LabVIEW error message instead: return self._get_good_object_( pywintypes.com_error: (-2147352567, 'Exception occurred.', (5002, 'LabVIEW', 'LabVIEW : paramVals type mismatch. Expected 1D array of variants.', None, 0, 0), None) So the new question is: how do you create a 1D array of variants in python? >From what I've read this is normally handled behind the scenes by PythonCom...? /Ola From mpjoh1977 at yahoo.com.au Tue Nov 8 23:25:42 2005 From: mpjoh1977 at yahoo.com.au (Michael Johnstone) Date: Wed, 9 Nov 2005 09:25:42 +1100 (EST) Subject: [python-win32] com error In-Reply-To: Message-ID: <20051108222542.59387.qmail@web33605.mail.mud.yahoo.com> --- Graham Bloice wrote: > > Traceback (most recent call last): > > File > > > "C:\Python22\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", > > line 310, in RunScript > > exec codeObject in __main__.__dict__ > > File > > > "C:\Deneb\BHSS\Projects\AKL_0502\VC\PythonApplications\OPCWriteTestor.py", > > line 103, in ? > > Sensor(1) > > File > > > "C:\Deneb\BHSS\Projects\AKL_0502\VC\PythonApplications\OPCWriteTestor.py", > > line 100, in Sensor > > grpPinWheel.SyncWrite(num, sh, listval, > errors)#, > > CID, SID) > > File > > > "C:\Python22\Lib\site-packages\win32com\gen_py\F5F1FC84-DB0B-11D3- > > 883B-0050041DD057x0x1x0.py", > > line 302, in SyncWrite > > , ServerHandles, Values, Errors) > > File > > > "C:\Python22\Lib\site-packages\win32com\client\__init__.py", > > line 446, in _ApplyTypes_ > > return self._get_good_object_( > > com_error: (-2147352567, 'Exception occurred.', > (0, > > None, None, None, 0, -2147024809), None) > > > > > > Have you set errors to be an empty list before the > call ? > > Graham > > Yes I have tried errors as an empty list and array without success. I have also tried to use pythoncom.missing as this argument. cheers Mike ____________________________________________________ Do you Yahoo!? The New Yahoo! Movies: Check out the Latest Trailers, Premiere Photos and full Actor Database. http://au.movies.yahoo.com From mhammond at skippinet.com.au Tue Nov 8 23:31:55 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 9 Nov 2005 09:31:55 +1100 Subject: [python-win32] Reading custom output parameters fromLabVIEW/Acti veX In-Reply-To: <31A473DBB655D21180850008C71E251A099DB007@mail.kebne.se> Message-ID: > So the new question is: how do you create a 1D array of variants > in python? > >From what I've read this is normally handled behind the scenes by > PythonCom...? That's correct - just pass a list or tuple. However, that is rarely the complete answer - what *type* of variant should be in the array? Since you only received this error when you changed to Missing, it appears LabView *is* seeing the real param as an array of variants, as it does not return this specific error. Sadly there is no easy way to explicitly specify the exact variant type, other than using InvokeTypes. Mark From mpjoh1977 at yahoo.com.au Tue Nov 8 23:59:18 2005 From: mpjoh1977 at yahoo.com.au (Michael Johnstone) Date: Wed, 9 Nov 2005 09:59:18 +1100 (EST) Subject: [python-win32] com error In-Reply-To: Message-ID: <20051108225918.42976.qmail@web33614.mail.mud.yahoo.com> --- Mark Hammond wrote: > > > "C:\Python22\Lib\site-packages\win32com\client\__init__.py", > > line 446, in _ApplyTypes_ > > return self._get_good_object_( > > com_error: (-2147352567, 'Exception occurred.', > (0, > > None, None, None, 0, -2147024809), None) > > The second value in that error tuple is the error > code provided by the > object. It didn't bother to fill in a message, but > we can get one if it is > a standard COM error: > > >>> pythoncom.GetScodeString(-2147024809) > 'The parameter is incorrect.' > >>> > > I'm not sure why it is throwing that specific error. > I guess it may be > "default params". Try passing explicit values for > all params - explicitly > pass pythoncom.Missing for ones you don't know the > correct value for (the > win32com framework will currently be passing > pythoncom.Empty for them - the > difference is subtle, but some objects are very > picky about which one you > choose (basically, 'Empty' means an empty param will > be supplied to the > object, whereas 'Missing' will tell pythoncom to not > present that argument > at all)) > > Mark > > Hi Mark Not sure if I got what you suggested correct. The method I am trying to use is defined as: def SyncWrite(self, NumItems=defaultNamedNotOptArg, ServerHandles=defaultNamedNotOptArg, Values=defaultNamedNotOptArg), Errors=pythoncom.Missing): I have tried calling this different ways: grpPinWheel.SyncWrite(NumItems=num, ServerHandles=sh, Values=listval, Errors=errors) grpPinWheel.SyncWrite(NumItems=num, ServerHandles=sh, Values=listval, Errors=pythoncom.Missing) I still get the same error. I have also tried using arrays and lists for the variables but these don"t seem to make a difference> cheers michael ____________________________________________________ Do you Yahoo!? Listen to over 20 online radio stations and watch the latest music videos on Yahoo! Music. http://au.launch.yahoo.com From mhammond at skippinet.com.au Wed Nov 9 00:32:55 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 9 Nov 2005 10:32:55 +1100 Subject: [python-win32] com error In-Reply-To: <20051108225918.42976.qmail@web33614.mail.mud.yahoo.com> Message-ID: > Hi Mark > > Not sure if I got what you suggested correct. The > method I am trying to use is defined as: > > def SyncWrite(self, NumItems=defaultNamedNotOptArg, > ServerHandles=defaultNamedNotOptArg, > Values=defaultNamedNotOptArg), > Errors=pythoncom.Missing): There appears to be an extra close paren there... > I have tried calling this different ways: > grpPinWheel.SyncWrite(NumItems=num, ServerHandles=sh, > Values=listval, Errors=errors) > grpPinWheel.SyncWrite(NumItems=num, ServerHandles=sh, > Values=listval, Errors=pythoncom.Missing) Try pythoncom.Empty too. You should find from the decls at the top of the generated file that 'defaultNamedNotOptArg' is actually pythoncom.Empty - and that is what I assumed would be used for 'Errors'. It appears however that pythoncom.Missing is *already* being used for that param. Sadly though, this may be a red herring, and the problem may be related to the types of the other params. Without more useful info from the object itself, it is very hard to speculate. Mark From mpjoh1977 at yahoo.com.au Wed Nov 9 02:06:08 2005 From: mpjoh1977 at yahoo.com.au (Michael Johnstone) Date: Wed, 9 Nov 2005 12:06:08 +1100 (EST) Subject: [python-win32] com error In-Reply-To: Message-ID: <20051109010608.99481.qmail@web33609.mail.mud.yahoo.com> --- Mark Hammond wrote: > > Hi Mark > > > > Not sure if I got what you suggested correct. The > > method I am trying to use is defined as: > > > > def SyncWrite(self, > NumItems=defaultNamedNotOptArg, > > ServerHandles=defaultNamedNotOptArg, > > Values=defaultNamedNotOptArg), > > Errors=pythoncom.Missing): > > There appears to be an extra close paren there... > > > I have tried calling this different ways: > > grpPinWheel.SyncWrite(NumItems=num, > ServerHandles=sh, > > Values=listval, Errors=errors) > > grpPinWheel.SyncWrite(NumItems=num, > ServerHandles=sh, > > Values=listval, Errors=pythoncom.Missing) > > Try pythoncom.Empty too. You should find from the > decls at the top of the > generated file that 'defaultNamedNotOptArg' is > actually pythoncom.Empty - > and that is what I assumed would be used for > 'Errors'. It appears however > that pythoncom.Missing is *already* being used for > that param. > > Sadly though, this may be a red herring, and the > problem may be related to > the types of the other params. Without more useful > info from the object > itself, it is very hard to speculate. > > Mark > > I am using arrays for two for of the variables. If I append the item in the array twice it seems to solve the problem, so it looks like the com object is indexing arrays from 1 rather than 0. cheers Michael ____________________________________________________ Do you Yahoo!? Find a local business fast with Yahoo! Local Search http://au.local.yahoo.com From mhammond at skippinet.com.au Wed Nov 9 02:36:57 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 9 Nov 2005 12:36:57 +1100 Subject: [python-win32] Bug in pythoncom.CoInitialize(Ex) Message-ID: There is a subtle bug in CoInitialize and CoInitializeEx. I'd like some feedback on how to best fix it. The problem is that error results from these functions are not reported correctly. This is best demonstrated by example: --- coinit.py --- import thread, time import pythoncom def wtf(): pythoncom.CoInitializeEx(0) pythoncom.CoInitialize() # Uncomment the next line to see the error ignored. #getattr(pythoncom, "foo", None) if type(0) in [int, str]: pass thread.start_new(wtf, ()) time.sleep(0.5) --- end --- Running this as it stands yields: Unhandled exception in thread started by Traceback (most recent call last): File "coinit.py", line 9, in wtf if type(0) in [int, str]: pywintypes.com_error: (-2147417850, 'Cannot change thread mode after it is set.', None, None) Note that the traceback does *not* point at the CoInit calls - it points at the 'if' statement. This also means an exception handler around the CoInit call fails to catch the error. If you uncomment the line indicated, the error is completely ignored - the "getattr" for a non-existing attribute internally masks the "pending" error set by pythoncom.CoInitialize(). I can see the underlying problem that causes this. My concern is how to fix with without breaking code, as there may be code out there today that is managing to mask this error. Interestingly though, a thread that calls CoInit then immediately calls win32com.client.Dispatch *will* see the error - but as in my example, the traceback will point at the wrong place. I suspect that many people calling CoInit from a thread *will* immediately call win32com.client.Dispatch, so I would be quite surprised if it would break things. What I propose is that I change CoInitialize() to ignore this specific RPC_E_CHANGED_MODE error. My reasoning is that people calling CoInitialize() don't care about the threading model - all they want is to be able to use a COM object from their thread. However, I think CoInitializeEx() should always raise an exception on error return, including for that specific error. My reasoning is that people explicitly calling CoInitializeEx(thread_model) *do* care about the threading model, and may take great interest in the fact the thread has already been initialized differently. If it is prepared to work in a different threading model, it just needs to catch the exception. Does anyone have any comments? Thanks, Mark From upadhyay at gmail.com Wed Nov 9 07:42:44 2005 From: upadhyay at gmail.com (Amit Upadhyay) Date: Wed, 9 Nov 2005 12:12:44 +0530 Subject: [python-win32] COM object has been seperated from its underlying RCW cannot be used. Message-ID: <349edb380511082242u6e549a19p292b4d9b39cbd23d@mail.gmail.com> Hi, I am getting a crash with message: "COM object has been seperated from its underlying RCW cannot be used.", when using a COM server written in win32com and being accessed by .NET client. I have win2k-sp3 on that machine, and its not very reproducable. I get no results on msdn about this message, and can't locate any informaiton about how to solve it via google either, just that it is somehow related to threading. Can anyone tell me how to go about solving it? Thanks, -- Amit Upadhyay Blog: http://www.rootshell.be/~upadhyay +91-9867-359-701 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051109/e15b0be0/attachment.htm From gagenellina at softlab.com.ar Wed Nov 9 09:59:57 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Wed, 09 Nov 2005 05:59:57 -0300 Subject: [python-win32] Bug in pythoncom.CoInitialize(Ex) In-Reply-To: References: Message-ID: <6.2.1.2.0.20051109055614.03c1ac60@192.168.0.115> At Tuesday 8/11/2005 22:36, Mark Hammond wrote: >What I propose is that I change CoInitialize() to ignore this specific >RPC_E_CHANGED_MODE error. My reasoning is that people calling >CoInitialize() don't care about the threading model - all they want is to be >able to use a COM object from their thread. However, I think >CoInitializeEx() should always raise an exception on error return, including >for that specific error. My reasoning is that people explicitly calling >CoInitializeEx(thread_model) *do* care about the threading model, and may >take great interest in the fact the thread has already been initialized >differently. If it is prepared to work in a different threading model, it >just needs to catch the exception. I think these are reasonable asumptions so it's unlikely you would break existing code. None mine, FWIW. Gabriel Genellina Softlab SRL From gagenellina at softlab.com.ar Wed Nov 9 10:14:54 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Wed, 09 Nov 2005 06:14:54 -0300 Subject: [python-win32] COM object has been seperated from its underlying RCW cannot be used. In-Reply-To: <349edb380511082242u6e549a19p292b4d9b39cbd23d@mail.gmail.co m> References: <349edb380511082242u6e549a19p292b4d9b39cbd23d@mail.gmail.com> Message-ID: <6.2.1.2.0.20051109061155.03c18b50@192.168.0.115> At Wednesday 9/11/2005 03:42, Amit Upadhyay wrote: >I am getting a crash with message: "COM object has been seperated from its >underlying RCW cannot be used.", when using a COM server written in >win32com and being accessed by .NET client. I have win2k-sp3 on that >machine, and its not very reproducable. I get no results on msdn about >this message, and can't locate any informaiton about how to solve it via >google either, just that it is somehow related to threading. Can anyone >tell me how to go about solving it? Perhaps updating your .NET would help: http://support.microsoft.com/default.aspx?scid=kb;EN-US;818612 An explanation of the problem: http://radio.weblogs.com/0105852/stories/2002/12/21/comInteropNotFundamentallyFlawedButHard.html Gabriel Genellina Softlab SRL From wccppp at gmail.com Wed Nov 9 19:04:01 2005 From: wccppp at gmail.com (wccppp) Date: Wed, 9 Nov 2005 08:04:01 -1000 Subject: [python-win32] COM - respond to other application's event Message-ID: <87bd46aa0511091004i3c61c32fmd476a2d0f7f33a9e@mail.gmail.com> Hello group, I'm a beginner learning Python. Trying to automate AutoCAD. What I wanted to know is how to receive event fired by the AutoCAD application. When a drawing opening process is done, the application will fire an event EndOpen. In VBA, I know how to catch and respond to this event. But do not know how to accomplish it with Python. import win32com.client acad = win32com.client.Dispatch("AutoCAD.Application") acad.Visible = True acad.WindowState = 3 doc = acad.Documents.Open(r"C:\Drawings\test.dwg") print ("Drawing opened.") Thanks for your time and help, -- Regards, - wcc -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051109/4f59c78a/attachment.htm From mhammond at skippinet.com.au Thu Nov 10 06:57:27 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 10 Nov 2005 16:57:27 +1100 Subject: [python-win32] COM - respond to other application's event In-Reply-To: <87bd46aa0511091004i3c61c32fmd476a2d0f7f33a9e@mail.gmail.com> Message-ID: Check out DispatchWithEvents >>> import win32com.client >>> help(win32com.client.DispatchWithEvents) Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of wccppp Sent: Thursday, 10 November 2005 5:04 AM To: python-win32 at python.org Subject: [python-win32] COM - respond to other application's event Hello group, I'm a beginner learning Python. Trying to automate AutoCAD. What I wanted to know is how to receive event fired by the AutoCAD application. When a drawing opening process is done, the application will fire an event EndOpen. In VBA, I know how to catch and respond to this event. But do not know how to accomplish it with Python. import win32com.client acad = win32com.client.Dispatch("AutoCAD.Application") acad.Visible = True acad.WindowState = 3 doc = acad.Documents.Open(r"C:\Drawings\test.dwg") print ("Drawing opened.") Thanks for your time and help, -- Regards, - wcc -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051110/bcd12a38/attachment.html From mhammond at skippinet.com.au Thu Nov 10 06:57:27 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 10 Nov 2005 16:57:27 +1100 Subject: [python-win32] n00b problems accessing Outlook In-Reply-To: Message-ID: MessageSorry for the delay! I think you may find this is a problem with pywin32 on Python 2.4. I'll look at it as I find time, but for now, try Python 2.3. Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of McBurnett, Roe D Sent: Friday, 4 November 2005 8:40 AM To: python-win32 at python.org Subject: [python-win32] n00b problems accessing Outlook Hi People, I am new to Python, just installed the ActivePython 2.4.1 and downloaded pywin32-205.win32-py2.4.exe. I executed the provided demo application outlookAddin.py and got the following error message: C:\Python24\Lib\site-packages\win32com\demos>outlookAddin Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\demos\outlookAddin.py", line 38,in ? gencache.EnsureModule('{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}', 0, 2, 1, bForDemand=True) # Office 9 File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 407, in EnsureModule module = GetModuleForTypelib(typelibCLSID, tlbAttr[1], tlbAttr[3], tlbAttr[4]) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 258, in GetModuleForTypelib mod = _GetModule(modName) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 629, in _GetModule mod = __import__(mod_name) File "C:\Python24\lib\site-packages\win32com\gen_py\2DF8D04C-5BFA-101B-BDE5-00AA0 044DE52x0x2x2\__init__.py", line 1691 win32com.client.constants.__dicts__.append(constants.__dict__) ^ SyntaxError: invalid syntax C:\Python24\Lib\site-packages\win32com\demos>outlookAddin I edited the "C:\Python24\lib\site-packages\win32com\gen_py\2DF8D04C-5BFA-101B-BDE5-00AA0 044DE52x0x2x2\__init__.py" file to remove a few comment lines and re-executed with the following results: C:\Python24\Lib\site-packages\win32com\demos>outlookAddin Registered: Python.Test.OutlookAddin So I followed the instructions in the module: # To debug, execute: # outlookAddin.py --debug # # Then open Pythonwin, and select "Tools->Trace Collector Debugging Tool" # Restart Outlook, and you should see some output generated. With these results: C:\Python24\Lib\site-packages\win32com\demos>outlookAddin --debug Registered: Python.Test.OutlookAddin (for debugging) When I opened Pythonwin, and selected the Trace collector Debugging Tool and restarted Outlook I got this in the Python Trace Collector Window: # This window will display output from any programs that import win32traceutil # win32com servers registered with '--debug' are in this category. Object with win32trace dispatcher created (object=None) pythoncom error: Failed to call the universal dispatcher Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\universal.py", line 177, in dispatch retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 332, in _InvokeEx_ return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 653, in _invokeex_ args, kwArgs = self._transform_args_(args, kwArgs, dispid, lcid, wFlags, serviceProvider) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 640, in _transform_args_ arg = win32com.client.Dispatch(arg) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 38, in __WrapDispatch klass = gencache.GetClassForCLSID(resultCLSID) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 179, in GetClassForCLSID mod = GetModuleForCLSID(clsid) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 232, in GetModuleForCLSID __import__(sub_mod_name) exceptions.SyntaxError: invalid syntax (_Application.py, line 87) pythoncom error: Unexpected gateway error Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\universal.py", line 177, in dispatch retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 332, in _InvokeEx_ return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 653, in _invokeex_ args, kwArgs = self._transform_args_(args, kwArgs, dispid, lcid, wFlags, serviceProvider) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 640, in _transform_args_ arg = win32com.client.Dispatch(arg) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 38, in __WrapDispatch klass = gencache.GetClassForCLSID(resultCLSID) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 179, in GetClassForCLSID mod = GetModuleForCLSID(clsid) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 232, in GetModuleForCLSID __import__(sub_mod_name) exceptions.SyntaxError: invalid syntax (_Application.py, line 87) Can anyone shed any light on what is going on? Thanks -Roe McBurnett rdm2ATmcburnettDOTorg -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051110/c75d2860/attachment.htm From kshepitzki at yahoo.com Thu Nov 10 23:35:04 2005 From: kshepitzki at yahoo.com (Gary Kshepitzki) Date: Thu, 10 Nov 2005 22:35:04 -0000 Subject: [python-win32] COM server with events Message-ID: Hi I am trying to implement a COM server in python that supports events. I went over the available documentation, I looked in the example in win32com/demos/connect.py (which mixes client and server too much) and still I find it hard to understand what I need to do. I am looking for a complete, straight forward example (templatish if you will) that shows how to implement a full COM server with an event interface and an event. In particular I don't understand how to define an EventInterface in my server that can be retrived by FindConnectionPoint() and getting mixed up on what needs to be implemented for supporting the ConnectionPointContainer and ConnectionPoint interfaces. Anyone can point me to something? Regards G. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051110/5688512a/attachment.htm From mark.mclarnon at gmail.com Sat Nov 12 00:54:34 2005 From: mark.mclarnon at gmail.com (mark mclarnon) Date: Fri, 11 Nov 2005 18:54:34 -0500 Subject: [python-win32] Pipe output of tethereal to python Message-ID: <253738580511111554l407671cam342f5ec1d60a678f@mail.gmail.com> Anyone have any idea how to startup a program like tethereal which when run with a '-w - -l' set of flags produces A LOT of output on stdout and pipe this output to a python class? I noticed the object subprocess.Popen might be best suited to this but it doesnt seem to work right. The flag combination I provided above will cause tethereal to print each packet it recieves to stdout and then hopefully flush the stream. I want to "pipe" this output to a python script which will block read on that process stdout until a packet is recieved and then perform some processing on that packet. I realize that 3rd party modules are available like pcapy but there is added value in using tethereal that just isnt worth discussing here. Hope this makes sense -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051111/cc0c117f/attachment.html From bjarrett at garcoschools.org Sat Nov 12 20:40:03 2005 From: bjarrett at garcoschools.org (Brian Jarrett) Date: Sat, 12 Nov 2005 12:40:03 -0700 Subject: [python-win32] monitoring application controls... Message-ID: <0067E36738F75E4BB04832584BAED63CA7A0DC@localdns.garcoschools.org> Hello all, I'm currently researching ways to use Python to monitor the state, data, and events associated with controls (comboboxes, editboxes, etc.) using Python and the win32 extensions. I'd like to write a script that would allow me to observe the changes that occur to an application's controls while I use the application. For example, logging the text that gets entered in a combo box to a text file. I've already found the necessary information for enumerating windows and their controls, mostly by looking at the winguiauto.py example. I guess I'm used to working with OnChange and OnClick events when writing an application, but now I want to be able to "hook" into these sort of events when outside of the application itself. Where should I be looking? Any help would be appreciated. Brian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051112/16b869b1/attachment.html From adnan.chowdhury at gmail.com Mon Nov 14 04:45:20 2005 From: adnan.chowdhury at gmail.com (Adnan Chowdhury) Date: Mon, 14 Nov 2005 14:45:20 +1100 Subject: [python-win32] win32com.client.Dispatch("MAPI.Session") error exchange 2003 Message-ID: <66bd0e60511131945y487177c2w@mail.gmail.com> I'm trying to connect to an Exchange 2003 server win ActiveState's python implementation 2.4.1. When I run the following code: import win32com.client session = win32com.client.Dispatch ("MAPI.Session") session.Logon (ProfileName="Adnan Chowdhury") I get this error: Traceback (most recent call last): File "MAPI Test.py", line 3, in ? session = win32com.client.Dispatch ("MAPI.Session") File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 79, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) Is there something more that I need to define? From adnan.chowdhury at gmail.com Mon Nov 14 05:13:18 2005 From: adnan.chowdhury at gmail.com (Adnan Chowdhury) Date: Mon, 14 Nov 2005 15:13:18 +1100 Subject: [python-win32] win32com.client.Dispatch("MAPI.Session") error exchange 2003 In-Reply-To: <66bd0e60511131945y487177c2w@mail.gmail.com> References: <66bd0e60511131945y487177c2w@mail.gmail.com> Message-ID: <66bd0e60511132013t36cb3dd0o@mail.gmail.com> Found the answer at http://groups.google.com/group/comp.lang.python/browse_frm/thread/20f31e67c4d01d31/4d984204876e3319?q=exchange&rnum=35#4d984204876e3319 (comp.lang.python:"Q: Basic MAPI") You have to specifically install CDO components when installing Outlook 2003, it is not installed by default. ac On 14/11/05, Adnan Chowdhury wrote: > I'm trying to connect to an Exchange 2003 server win ActiveState's > python implementation 2.4.1. > > When I run the following code: > import win32com.client > session = win32com.client.Dispatch ("MAPI.Session") > session.Logon (ProfileName="Adnan Chowdhury") > > I get this error: > Traceback (most recent call last): > File "MAPI Test.py", line 3, in ? > session = win32com.client.Dispatch ("MAPI.Session") > File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", > line 95, in Dispatch > dispatch, userName = > dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", > line 91, in _GetGoodDispatchAndUserName > return (_GetGoodDispatch(IDispatch, clsctx), userName) > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", > line 79, in _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > pythoncom.IID_IDispatch) > pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) > > Is there something more that I need to define? > From python at kareta.de Mon Nov 14 16:42:51 2005 From: python at kareta.de (=?ISO-8859-15?Q?J=FCrgen_Kareta?=) Date: Mon, 14 Nov 2005 16:42:51 +0100 Subject: [python-win32] error message after many win32pipe.popen calls Message-ID: <4378B07B.5090704@kareta.de> Hi all, currently I'm testing a scipt which converts many (>500) ps files to pdf. I use ghostscript and the conversion is done by win32pipe.popen( ps2pdf.bat inputfile outputfile). I got the following error message, but it seems that all files were correctly converted: Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\editor\document.py", line 301, in Run win32api.PostMessage(self.hwnd, MSG_CHECK_EXTERNAL_FILE, 0, 0) pywintypes.error: (1816, 'PostMessage', 'Nicht gen\xfcgend Quoten verf\xfcgbar, um diesen Befehl zu verarbeiten.') win32ui: Run() virtual handler (>) raised an exception Is there a way to avoid this error ? (win2k, py2.4.1, pywin205) thanks in advance J?rgen From timr at probo.com Mon Nov 14 19:13:38 2005 From: timr at probo.com (Tim Roberts) Date: Mon, 14 Nov 2005 10:13:38 -0800 Subject: [python-win32] monitoring application controls... In-Reply-To: References: Message-ID: <4378D3D2.7040802@probo.com> On Sat, 12 Nov 2005 12:40:03 -0700, "Brian Jarrett" wrote: > >I'm currently researching ways to use Python to monitor the state, data, >and events associated with controls (comboboxes, editboxes, etc.) using >Python and the win32 extensions. I'd like to write a script that would >allow me to observe the changes that occur to an application's controls >while I use the application. For example, logging the text that gets >entered in a combo box to a text file. > >I've already found the necessary information for enumerating windows and >their controls, mostly by looking at the winguiauto.py example. > >I guess I'm used to working with OnChange and OnClick events when >writing an application, but now I want to be able to "hook" into these >sort of events when outside of the application itself. > >Where should I be looking? Any help would be appreciated. > > Well, I started to reply that I believed this could not be done entirely in Python, but I thought I'd better do a quick web search first, and it appears I am wrong. What you need are Windows hooks, which allows you to participate in the window procedures for other processes. Implementing a hook requires code in a DLL, because the DLL has to actually be "injected" into another process, to run in that processes context. That would usually make Python unsuitable, but there are people doing research in accessability that have done it: http://www.cs.unc.edu/~parente/tech/tr01.shtml Note particularly the libraries for pyHook and pyAA. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From kehilanyas at hotmail.com Tue Nov 15 10:58:55 2005 From: kehilanyas at hotmail.com (Gary) Date: Tue, 15 Nov 2005 11:58:55 +0200 Subject: [python-win32] Sending an event from a python COM server to a VB COM client Message-ID: Hello I am trying to send an event from a Python COM server to a VB (or VB.NET) COM client. I am a newbe both in VB and in python. Can anyone give me a simple (but complete) code example both of the Python server side and the VB client side for raising a single event. Any answer would be highly appreciated. Regards Gary -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051115/1a90011d/attachment.htm From billburns at pennswoods.net Tue Nov 15 12:45:52 2005 From: billburns at pennswoods.net (Bill Burns) Date: Tue, 15 Nov 2005 06:45:52 -0500 Subject: [python-win32] error message after many win32pipe.popen calls In-Reply-To: <4378B07B.5090704@kareta.de> References: <4378B07B.5090704@kareta.de> Message-ID: <4379CA70.4020600@pennswoods.net> [J?rgen wrote] > Hi all, > > currently I'm testing a scipt which converts many (>500) ps files to > pdf. I use ghostscript and the conversion is done by win32pipe.popen( > ps2pdf.bat inputfile outputfile). I got the following error message, but > it seems that all files were correctly converted: > > Traceback (most recent call last): > File > "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\editor\document.py", > line 301, in Run > win32api.PostMessage(self.hwnd, MSG_CHECK_EXTERNAL_FILE, 0, 0) > pywintypes.error: (1816, 'PostMessage', 'Nicht gen\xfcgend Quoten > verf\xfcgbar, um diesen Befehl zu verarbeiten.') > win32ui: Run() virtual handler ( 0x06A45878>>) raised an exception > > Is there a way to avoid this error ? (win2k, py2.4.1, pywin205) > Hi J?rgen, Achtung - The following does not address your win32pipe.open() problem, but you can continue to read it if you want to :-) I routinely convert many ps files myself and I use something like this: import os def convert2pdf(directory): os.chdir(directory) for f in os.listdir('.'): if f.endswith('.ps'): path, filename = os.path.split(f) name, ext = os.path.splitext(f) newName = os.path.join(path, name + ".pdf") command = 'ps2pdf "%s" "%s"' % (filename, newName) os.popen(command) if __name__ == '__main__': convert2pdf(r'C:\ps_files') The above just uses os.popen(). I've converted thousands of ps files with no problems at all. My specs are: Windows 2000 Pro SP4 Python 2.4.1 GPL GhostScript 8.15 HTH, Bill From python at kareta.de Tue Nov 15 16:13:24 2005 From: python at kareta.de (=?ISO-8859-15?Q?J=FCrgen_Kareta?=) Date: Tue, 15 Nov 2005 16:13:24 +0100 Subject: [python-win32] error message after many win32pipe.popen calls In-Reply-To: <4379CA70.4020600@pennswoods.net> References: <4378B07B.5090704@kareta.de> <4379CA70.4020600@pennswoods.net> Message-ID: <4379FB14.4020500@kareta.de> Hi Bill, thanks for your help, it works for me too :-) J?rgen > [J?rgen wrote] > >> Hi all, >> >> currently I'm testing a scipt which converts many (>500) ps files to >> pdf. I use ghostscript and the conversion is done by win32pipe.popen( >> ps2pdf.bat inputfile outputfile). I got the following error message, >> but it seems that all files were correctly converted: >> >> Traceback (most recent call last): >> File >> "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\editor\document.py", >> line 301, in Run >> win32api.PostMessage(self.hwnd, MSG_CHECK_EXTERNAL_FILE, 0, 0) >> pywintypes.error: (1816, 'PostMessage', 'Nicht gen\xfcgend Quoten >> verf\xfcgbar, um diesen Befehl zu verarbeiten.') >> win32ui: Run() virtual handler (> of > 0x06A45878>>) raised an exception >> >> Is there a way to avoid this error ? (win2k, py2.4.1, pywin205) >> > > Hi J?rgen, > > Achtung - The following does not address your win32pipe.open() problem, > but you can continue to read it if you want to :-) > > I routinely convert many ps files myself and I use something like this: > > > > import os > > def convert2pdf(directory): > os.chdir(directory) > for f in os.listdir('.'): > if f.endswith('.ps'): > path, filename = os.path.split(f) > name, ext = os.path.splitext(f) > newName = os.path.join(path, name + ".pdf") > command = 'ps2pdf "%s" "%s"' % (filename, newName) > os.popen(command) > > if __name__ == '__main__': > convert2pdf(r'C:\ps_files') > > > > The above just uses os.popen(). I've converted thousands of ps files > with no problems at all. > > My specs are: > Windows 2000 Pro SP4 > Python 2.4.1 > GPL GhostScript 8.15 > > HTH, > > Bill > > > > > > From timr at probo.com Tue Nov 15 18:49:28 2005 From: timr at probo.com (Tim Roberts) Date: Tue, 15 Nov 2005 09:49:28 -0800 Subject: [python-win32] error message after many win32pipe.popen calls In-Reply-To: References: Message-ID: <437A1FA8.3030808@probo.com> On Mon, 14 Nov 2005 16:42:51 +0100, J?rgen Kareta wrote: >currently I'm testing a scipt which converts many (>500) ps files to >pdf. I use ghostscript and the conversion is done by win32pipe.popen( >ps2pdf.bat inputfile outputfile). I got the following error message, but >it seems that all files were correctly converted: > >Traceback (most recent call last): > File >"C:\Python24\Lib\site-packages\pythonwin\pywin\framework\editor\document.py", >line 301, in Run > win32api.PostMessage(self.hwnd, MSG_CHECK_EXTERNAL_FILE, 0, 0) >pywintypes.error: (1816, 'PostMessage', 'Nicht gen\xfcgend Quoten >verf\xfcgbar, um diesen Befehl zu verarbeiten.') >win32ui: Run() virtual handler (0x06A45878>>) raised an exception > >Is there a way to avoid this error ? (win2k, py2.4.1, pywin205) > Does it fail if you run it outside of Pythonwin? Are you sure you're closing all of the pipes properly before starting a new one? Have you tried this with the new "subprocess" module? Error 1816 is an "exceeded quota" sort of error. You've hit some kind of limit, although I'm not sure which one. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From bjarrett at garcoschools.org Tue Nov 15 21:01:44 2005 From: bjarrett at garcoschools.org (Brian Jarrett) Date: Tue, 15 Nov 2005 13:01:44 -0700 Subject: [python-win32] monitoring application controls... Message-ID: <0067E36738F75E4BB04832584BAED63CA7A0DD@localdns.garcoschools.org> What you need are Windows hooks, which allows you to participate in the window procedures for other processes. Implementing a hook requires code in a DLL, because the DLL has to actually be "injected" into another process, to run in that processes context. That would usually make Python unsuitable, but there are people doing research in accessability that have done it: http://www.cs.unc.edu/~parente/tech/tr01.shtml Note particularly the libraries for pyHook and pyAA. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. Tim, Thanks for your reply. I had looked at pyHook before, but not the pyAA module. That definitely looks more promising, but so far I haven't found a way to make it track events for something like a combobox, just the actual windows. Of course I'm working from extremely limited experience with the Windows (COM) API, etc. I've also found some information on WM_COMMAND messages(?) that might hold some answers as well. Here is MSDN information specifically on the ComboBox message that indicates when it has been updated: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc /platform/commctls/comboboxes/comboboxreference/comboboxmessages/cbn_edi tchange.asp If I could find a way to hook in and receive those sorts of messages, I think that'd be the ticket, but again I am not well versed in these matters. As I find more info I'll post to this list. Thanks for the tips. Brian From gregpinero at gmail.com Wed Nov 16 00:21:40 2005 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Tue, 15 Nov 2005 18:21:40 -0500 Subject: [python-win32] mapisend.py - How does it work? Message-ID: <312cfe2b0511151521w648ad178x6e477db9a5e7177b@mail.gmail.com> Would anyone be kind enough to explain a bit about how this Python24\Lib\site-packages\win32comext\mapi\demos\mapisend.py demo program works? Specifically I was wondering: Does it require that I have outlook installed? Does it require that there is an exchange server somewhere? What is the role of the email server in all of this? Is there an SMTP server somewhere in the process? Background: A. I'm curious how it works. B. I was asked to send emails through my company's exchange server. (will this count?) Any pointers on how to do this otherwise? Much thanks! -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com ) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051115/de80591c/attachment.html -------------- next part -------------- #!/usr/bin/env python """module to send mail with Extended MAPI using the pywin32 mapi wrappers...""" # this was based on Jason Hattingh's C++ code at http://www.codeproject.com/internet/mapadmin.asp # written by David Fraser and Stephen Emslie # you can test this by changing the variables at the bottom and running from the command line from win32com.mapi import mapi from win32com.mapi import mapitags # Pre 2.2.1 compat. try: True, False except NameError: True = 1==1; False = 1==0 def SendEMAPIMail(Subject="", Message="", SendTo=None, SendCC=None, SendBCC=None, MAPIProfile=None): """Sends an email to the recipient using the extended MAPI interface Subject and Message are strings Send{To,CC,BCC} are comma-separated address lists MAPIProfile is the name of the MAPI profile""" # initialize and log on mapi.MAPIInitialize(None) session = mapi.MAPILogonEx(0, MAPIProfile, None, mapi.MAPI_EXTENDED | mapi.MAPI_USE_DEFAULT) messagestorestable = session.GetMsgStoresTable(0) messagestorestable.SetColumns((mapitags.PR_ENTRYID, mapitags.PR_DISPLAY_NAME_A, mapitags.PR_DEFAULT_STORE),0) while True: rows = messagestorestable.QueryRows(1, 0) #if this is the last row then stop if len(rows) != 1: break row = rows[0] #if this is the default store then stop if ((mapitags.PR_DEFAULT_STORE,True) in row): break # unpack the row and open the message store (eid_tag, eid), (name_tag, name), (def_store_tag, def_store) = row msgstore = session.OpenMsgStore(0,eid,None,mapi.MDB_NO_DIALOG | mapi.MAPI_BEST_ACCESS) # get the outbox hr, props = msgstore.GetProps((mapitags.PR_IPM_OUTBOX_ENTRYID), 0) (tag, eid) = props[0] #check for errors if mapitags.PROP_TYPE(tag) == mapitags.PT_ERROR: raise TypeError,'got PT_ERROR instead of PT_BINARY: %s'%eid outboxfolder = msgstore.OpenEntry(eid,None,mapi.MAPI_BEST_ACCESS) # create the message and the addrlist message = outboxfolder.CreateMessage(None,0) # note: you can use the resolveaddress functions for this. but you may get headaches pal = [] def makeentry(recipient, recipienttype): return ((mapitags.PR_RECIPIENT_TYPE, recipienttype), (mapitags.PR_SEND_RICH_INFO, False), (mapitags.PR_DISPLAY_TYPE, 0), (mapitags.PR_OBJECT_TYPE, 6), (mapitags.PR_EMAIL_ADDRESS_A, recipient), (mapitags.PR_ADDRTYPE_A, 'SMTP'), (mapitags.PR_DISPLAY_NAME_A, recipient)) if SendTo: pal.extend([makeentry(recipient, mapi.MAPI_TO) for recipient in SendTo.split(",")]) if SendCC: pal.extend([makeentry(recipient, mapi.MAPI_CC) for recipient in SendCC.split(",")]) if SendBCC: pal.extend([makeentry(recipient, mapi.MAPI_BCC) for recipient in SendBCC.split(",")]) # add the resolved recipients to the message message.ModifyRecipients(mapi.MODRECIP_ADD,pal) message.SetProps([(mapitags.PR_BODY_A,Message), (mapitags.PR_SUBJECT_A,Subject)]) # save changes and submit outboxfolder.SaveChanges(0) message.SubmitMessage(0) if __name__ == '__main__': MAPIProfile = "" # Change this to a valid email address to test SendTo = "an.invalid at address" SendMessage = "testing one two three" SendSubject = "Testing Extended MAPI!!" SendEMAPIMail(SendSubject, SendMessage, SendTo, MAPIProfile=MAPIProfile) From mhammond at skippinet.com.au Wed Nov 16 02:23:49 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 16 Nov 2005 12:23:49 +1100 Subject: [python-win32] mapisend.py - How does it work? In-Reply-To: <312cfe2b0511151521w648ad178x6e477db9a5e7177b@mail.gmail.com> Message-ID: > Specifically I was wondering: > Does it require that I have outlook installed? It requires outlook plus the "simple mapi", or "cdo" libraries. These are an optional component of the office 2000 install that is de-selected by default (ie, you need to explicitly install it). Worse, for later Outlook versions you always get "nag" dialogs in MS' attempt at stopping malware from sending mail or accessing your contacts. > Does it require that there is an exchange server somewhere? > What is the role of the email server in all of this? Is there > an SMTP server somewhere in the process? The MAPI libraries themselves take care of this detail. Really, it is just Outlook that sends the mail however it is configured to do so (ie, either directly to an smtp server, or to an exchange server). So it does not *need* an exchange server. > B. I was asked to send emails through my company's exchange server. (will this count?) > Any pointers on how to do this otherwise? If your exchange server is acting as an SMTP server you could just use smptlib. Otherwise you could use "extended MAPI", which is fully supported by Python, but somewhat tricky to use. Also, something like: app = Dispatch("Outlook.Application") new_msg = app.CreateItem(0) new_msg.Body = "hello" ... new_msg.Send() may work - I've actually no idea if it does, but something similar should :) The trick here would be to find docs for the Outlook object model (eg, VB code that uses it). This will obviously depend on Outlook being installed. Mark From jek at zer0.org Wed Nov 16 02:35:46 2005 From: jek at zer0.org (Joshua Kaderlan) Date: Tue, 15 Nov 2005 17:35:46 -0800 Subject: [python-win32] mapisend.py - How does it work? In-Reply-To: References: <312cfe2b0511151521w648ad178x6e477db9a5e7177b@mail.gmail.com> Message-ID: <20051116013545.GD74484@klapaucius.zer0.org> On 2005-11-16 12:23 +1100, Mark Hammond wrote: > > > B. I was asked to send emails through my company's exchange server. (will > > this count?) > > Any pointers on how to do this otherwise? > > If your exchange server is acting as an SMTP server you could just use > smptlib. Otherwise you could use "extended MAPI", which is fully supported > by Python, but somewhat tricky to use. Also, something like: > > app = Dispatch("Outlook.Application") > new_msg = app.CreateItem(0) > new_msg.Body = "hello" > ... > new_msg.Send() > > may work - I've actually no idea if it does, but something similar should :) > The trick here would be to find docs for the Outlook object model (eg, VB > code that uses it). This will obviously depend on Outlook being installed. You can download the Outlook 2003 Visual Basic Application Reference (which, despite the name, is the Simple MAPI documentation; it uses VB for sample code though) from MSDN: Doing what you suggest above (or something very similar to it) will probably work, although it'll trigger the Outlook security dialog. If you want to get around that, either use Extended MAPI or the Outlook Redemption DLL: There are also a couple of apps which will allow you to use the regular Simple MAPI calls and programmatically suppress the dialog. -Josh From python at kareta.de Wed Nov 16 11:31:55 2005 From: python at kareta.de (=?ISO-8859-1?Q?J=FCrgen_Kareta?=) Date: Wed, 16 Nov 2005 11:31:55 +0100 Subject: [python-win32] error message after many win32pipe.popen calls In-Reply-To: <437A1FA8.3030808@probo.com> References: <437A1FA8.3030808@probo.com> Message-ID: <437B0A9B.6010200@kareta.de> Hi Tim, thanks for your suggestions. >Does it fail if you run it outside of Pythonwin? > No it doesn't. So I can ignore this error, as the script will normally run outside Pythonwin. > Are you sure you're >closing all of the pipes properly before starting a new one? > Yes, I explicitly close the pipes > Have you >tried this with the new "subprocess" module? > > Yes, but I have to investigate a bit more. In the first try gostscipt opens its own viewer for every file :-( J?rgen From mark.mclarnon at gmail.com Wed Nov 16 19:13:40 2005 From: mark.mclarnon at gmail.com (mark mclarnon) Date: Wed, 16 Nov 2005 13:13:40 -0500 Subject: [python-win32] inspect32.exe python equivalent? Message-ID: <253738580511161013s7ec3d155l73d96f2d3f8abd56@mail.gmail.com> The Microsoft SDK contains an EXE called inspect32.exe which implements an active accessibility API interface. Is anyone aware of work in the Python community to interface with the ActiveAccessibility API? This program inspect32 is wonderful in that it can programmatically invoke actions of the GUI items it identifies on screen it is this functionality that I desire. I know of some fantastic projects like cPAMIE but they only work for particular software titles. Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051116/35ccc833/attachment.html From peter.schuetz at gmail.com Thu Nov 17 13:36:27 2005 From: peter.schuetz at gmail.com (=?WINDOWS-1252?Q?Peter_Sch=FCtz?=) Date: Thu, 17 Nov 2005 13:36:27 +0100 Subject: [python-win32] Creating pivot tables in excel using python Message-ID: <50de3d0511170436u2901b261ifc948518c07b6d51@mail.gmail.com> Hi, I am using Python 2.4.1 and I want to retrieve data from an Access database and display the results in an Excel pivot table. To get the data out of Access is no problem, but I have problems creating the pivot table in Excel. The following code is what I came up with (after running makepy on the Excel library): Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from win32com.client import constants, Dispatch >>> xl = Dispatch('Excel.Application') >>> xl.Workbooks.Add() >>> xl.ActiveWorkbook.SaveAs(r'd:\pivottable.xls') >>> pc = xl.ActiveWorkbook.PivotCaches().Add(constants.xlExternal) >>> pc >>> conn = Dispatch('ADODB.Connection') >>> rs = Dispatch('ADODB.Recordset') >>> ado = r'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\test.mdb;' >>> sql = 'SELECT * FROM whatever' >>> conn.Open(ado) >>> rs.Open(sql,conn) >>> pc.Recordset = rs Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\lib\site-packages\win32com\client\__init__.py", line 463, in __setattr__ self._oleobj_.Invoke(*(args + (value,) + defArgs)) pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2146827284), None) As you can see, I get the PivotCache object, but I need to set the Recordset in order to use rs. I get the same error message when want to set pc.OptimizeCache to True. Honestly, I have no idea what is going on, so if someone could help me? Thanks in advance peter -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051117/a1f0d636/attachment.html From durumdara at mailpont.hu Thu Nov 17 16:35:37 2005 From: durumdara at mailpont.hu (durumdara@mailpont.hu) Date: Thu, 17 Nov 2005 16:35:37 +0100 Subject: [python-win32] Midi files to Wav files Message-ID: <437CA349.3030608@mailpont.hu> Hi ! I want to convert my mid files to way files in MS Windows. I know that I can play the mid files, and I can record them as wav - with MMSystem unit. I need to play a midi file and record it in in-line. But how can I do it ? Anybody can help me ? I need some informations to start this work. Thanx for help: dd From timr at probo.com Thu Nov 17 19:13:40 2005 From: timr at probo.com (Tim Roberts) Date: Thu, 17 Nov 2005 10:13:40 -0800 Subject: [python-win32] inspect32.exe python equivalent? In-Reply-To: References: Message-ID: <437CC854.1060402@probo.com> On Wed, 16 Nov 2005 13:13:40 -0500, mark mclarnon wrote: >The Microsoft SDK contains an EXE called inspect32.exe which implements an >active accessibility API interface. Is anyone aware of work in the Python >community to interface with the ActiveAccessibility API? This program >inspect32 is wonderful in that it can programmatically invoke actions of the >GUI items it identifies on screen it is this functionality that I desire. I >know of some fantastic projects like cPAMIE but they only work for >particular software titles. > > Are you new to the mailing list? This very topic was discussed earlier this week. Here's part of my reply: >What you need are Windows hooks, which allows you to participate in the >window procedures for other processes. Implementing a hook requires >code in a DLL, because the DLL has to actually be "injected" into >another process, to run in that processes context. That would usually >make Python unsuitable, but there are people doing research in >accessability that have done it: > > http://www.cs.unc.edu/~parente/tech/tr01.shtml > >Note particularly the libraries for pyHook and pyAA. > Note that the "AA" in "pyAA" stands for "Active Accessibility". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gregpinero at gmail.com Thu Nov 17 19:23:31 2005 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Thu, 17 Nov 2005 13:23:31 -0500 Subject: [python-win32] mapisend.py - How does it work? In-Reply-To: <20051116013545.GD74484@klapaucius.zer0.org> References: <312cfe2b0511151521w648ad178x6e477db9a5e7177b@mail.gmail.com> <20051116013545.GD74484@klapaucius.zer0.org> Message-ID: <312cfe2b0511171023j729ce944scbab461e6edbbeae@mail.gmail.com> Thanks for all the help guys. It turns out that their exchange server does act as an SMTP server. So I'll just go that route for now. -Greg On 11/15/05, Joshua Kaderlan wrote: > > On 2005-11-16 12:23 +1100, Mark Hammond wrote: > > > > > B. I was asked to send emails through my company's exchange server. > (will > > > this count?) > > > Any pointers on how to do this otherwise? > > > > If your exchange server is acting as an SMTP server you could just use > > smptlib. Otherwise you could use "extended MAPI", which is fully > supported > > by Python, but somewhat tricky to use. Also, something like: > > > > app = Dispatch("Outlook.Application") > > new_msg = app.CreateItem(0) > > new_msg.Body = "hello" > > ... > > new_msg.Send() > > > > may work - I've actually no idea if it does, but something similar > should :) > > The trick here would be to find docs for the Outlook object model (eg, > VB > > code that uses it). This will obviously depend on Outlook being > installed. > > You can download the Outlook 2003 Visual Basic Application Reference > (which, > despite the name, is the Simple MAPI documentation; it uses VB for sample > code > though) from MSDN: > < > http://www.microsoft.com/downloads/details.aspx?FamilyId=A1CEAD80-23E2-456F-8618-4DA50CC2C38C&displaylang=en > > > > Doing what you suggest above (or something very similar to it) will > probably > work, although it'll trigger the Outlook security dialog. If you want to > get > around that, either use Extended MAPI or the Outlook Redemption DLL: > > There are also a couple of apps which will allow you to use the regular > Simple > MAPI calls and programmatically suppress the dialog. > > > -Josh > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com ) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051117/c968cad3/attachment.htm From tony at tcapp.com Fri Nov 18 16:45:10 2005 From: tony at tcapp.com (Tony Cappellini) Date: Fri, 18 Nov 2005 07:45:10 -0800 Subject: [python-win32] Midi files to Wav files In-Reply-To: References: Message-ID: <6.1.2.0.0.20051118074411.049aad60@mail.yamato.com> Try pysonic http://pysonic.sourceforge.net/ Message: 2 Date: Thu, 17 Nov 2005 16:35:37 +0100 From: "durumdara at mailpont.hu" Subject: [python-win32] Midi files to Wav files To: python-win32 at python.org Message-ID: <437CA349.3030608 at mailpont.hu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hi ! I want to convert my mid files to way files in MS Windows. I know that I can play the mid files, and I can record them as wav - with MMSystem unit. I need to play a midi file and record it in in-line. But how can I do it ? Anybody can help me ? I need some informations to start this work. Thanx for help: dd From haraldarminmassa at gmail.com Fri Nov 18 13:11:55 2005 From: haraldarminmassa at gmail.com (Harald Armin Massa) Date: Fri, 18 Nov 2005 13:11:55 +0100 Subject: [python-win32] Pivot in Excel from Python Message-ID: <7be3f35d0511180411q6350b645y@mail.gmail.com> Peter, I had similiar challenges. After trying in vain for some time, I decided to add a VB-macro to the Excel Templates which does all the pivot creation and refresh of data, and to call that macro from Python. My impression was that there is some missing link within the Excel COM Interface, which integrated VBA does not care. Harald -- GHUM Harald Massa persuasion python postgresql Harald Armin Massa Reinsburgstra?e 202b 70197 Stuttgart 0173/9409607 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051118/97e2db82/attachment.htm From timr at probo.com Fri Nov 18 20:32:11 2005 From: timr at probo.com (Tim Roberts) Date: Fri, 18 Nov 2005 11:32:11 -0800 Subject: [python-win32] Creating pivot tables in excel using python In-Reply-To: References: Message-ID: <437E2C3B.5060508@probo.com> On Thu, 17 Nov 2005 13:36:27 +0100, Peter Sch?tz wrote: >I am using Python 2.4.1 and I want to retrieve data from an Access database >and display the results in an Excel pivot table. To get the data out of >Access is no problem, but I have problems creating the pivot table in Excel.what I came up with > ... >Traceback (most recent call last): >File "", line 1, in ? >File "C:\Python24\lib\site-packages\win32com\client\__init__.py", line 463, >in __setattr__ >self._oleobj_.Invoke(*(args + (value,) + defArgs)) >pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, >None, 0, -2146827284), None) > >As you can see, I get the PivotCache object, but I need to set the Recordset >in order to use rs. I get the same error message when want to set >pc.OptimizeCache to True. Honestly, I have no idea what is going on, so if >someone could help me? > Well, -2146827284 is 800A03EC, which is some kind of generic "access denied" error within Excel. Can you run this EXACT sequence in VBA within Excel? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From peter.schuetz at gmail.com Fri Nov 18 21:15:51 2005 From: peter.schuetz at gmail.com (=?ISO-8859-1?Q?Peter_Sch=FCtz?=) Date: Fri, 18 Nov 2005 21:15:51 +0100 Subject: [python-win32] Creating pivot tables in excel using python Message-ID: <50de3d0511181215u6ae852eaj33f0918b65304e38@mail.gmail.com> I tried VBA and it didn't work either. Some sort of Application Object error (don't remember the exact error message). However, I managed to create a pivot table in Excel by means of an ODBC connection. So I gave up trying to figure out why it didn't work. The following code created the Pivot table in Excel, all that is left to do is do define the row, column, and data fields. It should be no problem to program this in Python. Otherwise the user can set up the table in Excel himself. from win32com.client import constants, Dispatch xl = Dispatch('Excel.Application') xl.Workbooks.Add() xl.ActiveWorkbook.SaveAs(r'd:\pivottable.xls') ws = xl.ActiveWorkbook.ActiveSheet pc = xl.ActiveWorkbook.PivotCaches().Add(constants.xlExternal) pc.Connection = r'ODBC;DSN=MS Access Database;DBQ=d:\test.mdb;' pc.CommandType = constants.xlCmdSql pc.CommandText = 'SELECT * FROM whatever' pc.CreatePivotTable(ws.Cells(3,1),'pivot') xl.ActiveWorkbook.Save() Thanks for all the help peter > >Traceback (most recent call last): > >File "", line 1, in ? > >File "C:\Python24\lib\site-packages\win32com\client\__init__.py", line > > 463, in __setattr__ > >self._oleobj_.Invoke(*(args + (value,) + defArgs)) > >pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, > >None, 0, -2146827284), None) > > > >As you can see, I get the PivotCache object, but I need to set the > > Recordset in order to use rs. I get the same error message when want to > > set pc.OptimizeCache to True. Honestly, I have no idea what is going on, > > so if someone could help me? > > Well, -2146827284 is 800A03EC, which is some kind of generic "access > denied" error within Excel. > > Can you run this EXACT sequence in VBA within Excel? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051118/511853d7/attachment.htm From gregpinero at gmail.com Mon Nov 21 15:14:46 2005 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Mon, 21 Nov 2005 09:14:46 -0500 Subject: [python-win32] PythonWin Not starting - Windows Server 2003 OS Message-ID: <312cfe2b0511210614j32b6b34m5edf260bbfc2badb@mail.gmail.com> Hi, I just installed PythonWin on a fresh install of Windows Server 2003. When I try to launch the PythonWin IDE it starts up and shows the IDE for about 1 second and then shuts down. If you need more information, just let me know what to check to get. Thanks! -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com ) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051121/dc487ad7/attachment.htm From kimwaic888-pythonwin32 at yahoo.com Mon Nov 21 21:13:15 2005 From: kimwaic888-pythonwin32 at yahoo.com (kimwaic888-pythonwin32@yahoo.com) Date: Mon, 21 Nov 2005 12:13:15 -0800 (PST) Subject: [python-win32] Junk mail received In-Reply-To: <79cLiynZZjo9XTYpAgkFB@xn--ren-rna.com> Message-ID: <20051121201316.6524.qmail@web51404.mail.yahoo.com> Please be alert that I have received a junk mail from a spammer to my python win32 address. The spam was signed by a: Reuben Wiesenthal , exivey at yahoo.com --- Reuben Wiesenthal wrote: From AddisonN at iti-ab.com Tue Nov 22 12:03:13 2005 From: AddisonN at iti-ab.com (AddisonN@iti-ab.com) Date: Tue, 22 Nov 2005 11:03:13 -0000 Subject: [python-win32] PythonWin Not starting on Windows Server 2003 Message-ID: <9355218C54DDFF4CA43FC31AEB6FB0EC2C6641@iti00-exc01.iti.arabbank.plc> We had the same problem recently - we were missing mfc71.dll in the system folder. -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of python-win32-request at python.org Sent: 22 November 2005 11:00 To: python-win32 at python.org Subject: Python-win32 Digest, Vol 32, Issue 20 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. PythonWin Not starting - Windows Server 2003 OS (Gregory Pi?ero) 2. Junk mail received (kimwaic888-pythonwin32 at yahoo.com) ---------------------------------------------------------------------- Message: 1 Date: Mon, 21 Nov 2005 09:14:46 -0500 From: Gregory Pi?ero Subject: [python-win32] PythonWin Not starting - Windows Server 2003 OS To: python-win32 at python.org Message-ID: <312cfe2b0511210614j32b6b34m5edf260bbfc2badb at mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Hi, I just installed PythonWin on a fresh install of Windows Server 2003. When I try to launch the PythonWin IDE it starts up and shows the IDE for about 1 second and then shuts down. If you need more information, just let me know what to check to get. Thanks! -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com ) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051121/dc487 ad7/attachment.html ------------------------------ Message: 2 Date: Mon, 21 Nov 2005 12:13:15 -0800 (PST) From: Subject: [python-win32] Junk mail received To: "python-win32 at python.org" Message-ID: <20051121201316.6524.qmail at web51404.mail.yahoo.com> Content-Type: text/plain; charset=iso-8859-1 Please be alert that I have received a junk mail from a spammer to my python win32 address. The spam was signed by a: Reuben Wiesenthal , exivey at yahoo.com --- Reuben Wiesenthal wrote: ------------------------------ _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 End of Python-win32 Digest, Vol 32, Issue 20 ******************************************** ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. Information Technology International (ITI) +44 (0)20 7315 8500 ********************************************************************** From gregpinero at gmail.com Tue Nov 22 15:22:54 2005 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Tue, 22 Nov 2005 09:22:54 -0500 Subject: [python-win32] PythonWin Not starting - Windows Server 2003 OS In-Reply-To: <312cfe2b0511210614j32b6b34m5edf260bbfc2badb@mail.gmail.com> References: <312cfe2b0511210614j32b6b34m5edf260bbfc2badb@mail.gmail.com> Message-ID: <312cfe2b0511220622p781b45ecwb196c6fcd46514d1@mail.gmail.com> Yeah, I know this is a pretty vague question. I'm willing to try to debug it myself. Could anyone point me towards where to start? Is there a error log file somewhere or any known issues with Windows Server 2003? Thanks, Greg On 11/21/05, Gregory Pi?ero wrote: > > Hi, > > I just installed PythonWin on a fresh install of Windows Server 2003. When > I try to launch the PythonWin IDE it starts up and shows the IDE for about 1 > second and then shuts down. > > If you need more information, just let me know what to check to get. > > Thanks! > > -- > Gregory Pi?ero > Chief Innovation Officer > Blended Technologies > (www.blendedtechnologies.com ) -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com ) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051122/e28e3eb8/attachment.html From gregpinero at gmail.com Tue Nov 22 18:22:37 2005 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Tue, 22 Nov 2005 12:22:37 -0500 Subject: [python-win32] PythonWin - Start in script's directory Message-ID: <312cfe2b0511220922x6b75a5e3m6988fbb916083e39@mail.gmail.com> I'm not sure how to phrase this question. How can I make PythonWin have it's current directory automatically set to the same directory as my script? For example I want the statement: file('test.txt','w') to make a file in the same directory as my script, instead of wherever PythonWin wants to put it by default, I think somewhere in C:\Python? Thanks, -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com ) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051122/ce9aa861/attachment.htm From gagenellina at softlab.com.ar Tue Nov 22 18:35:56 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Tue, 22 Nov 2005 14:35:56 -0300 Subject: [python-win32] PythonWin - Start in script's directory In-Reply-To: <312cfe2b0511220922x6b75a5e3m6988fbb916083e39@mail.gmail.co m> References: <312cfe2b0511220922x6b75a5e3m6988fbb916083e39@mail.gmail.com> Message-ID: <6.2.1.2.0.20051122143152.033d42a0@192.168.0.115> At Tuesday 22/11/2005 14:22, Gregory Pi?ero wrote: >I'm not sure how to phrase this question. How can I make PythonWin have >it's current directory automatically set to the same directory as my script? > >For example I want the statement: >file('test.txt','w') >to make a file in the same directory as my script, instead of wherever >PythonWin wants to put it by default, I think somewhere in C:\Python? os.path.dirname(os.path.abspath(sys.argv[0])) returns the directory where your script is. You can make it the current dir using os.chdir Gabriel Genellina Softlab SRL From gregpinero at gmail.com Tue Nov 22 19:14:51 2005 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Tue, 22 Nov 2005 13:14:51 -0500 Subject: [python-win32] PythonWin - Start in script's directory In-Reply-To: <6.2.1.2.0.20051122143152.033d42a0@192.168.0.115> References: <312cfe2b0511220922x6b75a5e3m6988fbb916083e39@mail.gmail.com> <6.2.1.2.0.20051122143152.033d42a0@192.168.0.115> Message-ID: <312cfe2b0511221014g3fd1eb2fs7f374933e2e9a47b@mail.gmail.com> And then is there a way to make Pythonwin run that automatically or do I have to add that to my script: os.chdir(os.path.dirname(os.path.abspath(sys.argv[0]))) -Greg On 11/22/05, Gabriel Genellina wrote: > > At Tuesday 22/11/2005 14:22, Gregory Pi?ero wrote: > > >I'm not sure how to phrase this question. How can I make PythonWin have > >it's current directory automatically set to the same directory as my > script? > > > >For example I want the statement: > >file('test.txt','w') > >to make a file in the same directory as my script, instead of wherever > >PythonWin wants to put it by default, I think somewhere in C:\Python? > > os.path.dirname(os.path.abspath(sys.argv[0])) returns the directory where > your script is. > You can make it the current dir using os.chdir > > > Gabriel Genellina > Softlab SRL > > -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com ) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051122/f4392129/attachment.htm From gagenellina at softlab.com.ar Tue Nov 22 19:37:49 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Tue, 22 Nov 2005 15:37:49 -0300 Subject: [python-win32] PythonWin - Start in script's directory In-Reply-To: <312cfe2b0511221014g3fd1eb2fs7f374933e2e9a47b@mail.gmail.co m> References: <312cfe2b0511220922x6b75a5e3m6988fbb916083e39@mail.gmail.com> <6.2.1.2.0.20051122143152.033d42a0@192.168.0.115> <312cfe2b0511221014g3fd1eb2fs7f374933e2e9a47b@mail.gmail.com> Message-ID: <6.2.1.2.0.20051122152646.033dee10@192.168.0.115> At Tuesday 22/11/2005 15:14, Gregory Pi?ero wrote: >And then is there a way to make Pythonwin run that automatically or do I >have to add that to my script: >os.chdir(os.path.dirname(os.path.abspath(sys.argv[0]))) I'm not sure what Pythonwin has to do with this exactly... You always can run a process with a "startup directory" different from where it is located. If you want to ensure that they are the same, you must do something like above. Or create a shortcut icon. Gabriel Genellina Softlab SRL From gregpinero at gmail.com Tue Nov 22 23:50:58 2005 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Tue, 22 Nov 2005 17:50:58 -0500 Subject: [python-win32] PythonWin - Start in script's directory In-Reply-To: <6fae95540511221352i375d0980v512a6ac08f55564d@mail.gmail.com> References: <312cfe2b0511220922x6b75a5e3m6988fbb916083e39@mail.gmail.com> <6.2.1.2.0.20051122143152.033d42a0@192.168.0.115> <312cfe2b0511221014g3fd1eb2fs7f374933e2e9a47b@mail.gmail.com> <6fae95540511221352i375d0980v512a6ac08f55564d@mail.gmail.com> Message-ID: <312cfe2b0511221450j7ddf7a54y8aef1f02b8cc483@mail.gmail.com> Ah, very good idea! I just tried that and it works. For posterity you can add an "edit with" option to a file type in windows by going to folder options, selecting the file types tab, go to the file type you want to change, select change, select new, type in a name like edit with pythonwin, and finally browse for the pythonwin exe. -Greg On 11/22/05, Waldemar Osuch wrote: > > On 11/22/05, Gregory Pi?ero wrote: > > And then is there a way to make Pythonwin run that automatically or do I > > have to add that to my script: > > os.chdir(os.path.dirname(os.path.abspath(sys.argv[0]))) > > > My work around is to right click on the script and select "Edit with > Pythonwin". > This way the current directory stays the same as the script's. > > If you do not the "Edit with Pythonwin" option it is easy to create it > manually. > > Waldemar > -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com ) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051122/d9a1e073/attachment-0001.htm From andrew.markebo at comhem.se Wed Nov 23 14:19:30 2005 From: andrew.markebo at comhem.se (Andrew Markebo) Date: Wed, 23 Nov 2005 14:19:30 +0100 Subject: [python-win32] Reading custom output parameters fromLabVIEW/Acti veX References: <31A473DBB655D21180850008C71E251A099DB007@mail.kebne.se> Message-ID: Hello! Sorry for getting in so late, are there any god notes/examples on how to use InvokeTypes? Been looking around a little but don't get it straight. / "Mark Hammond" wrote: |> So the new question is: how do you create a 1D array of variants |> in python? |> >From what I've read this is normally handled behind the scenes by |> PythonCom...? | | That's correct - just pass a list or tuple. However, that is rarely the | complete answer - what *type* of variant should be in the array? Since you | only received this error when you changed to Missing, it appears LabView | *is* seeing the real param as an array of variants, as it does not return | this specific error. | | Sadly there is no easy way to explicitly specify the exact variant type, | other than using InvokeTypes. -- "I [..] am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand." -- Douglas Adams, "Last Chance to See" -= May he rest in peace! =- From Tom_RobbinsMilne at swissre.com Wed Nov 23 18:14:51 2005 From: Tom_RobbinsMilne at swissre.com (Tom_RobbinsMilne@swissre.com) Date: Wed, 23 Nov 2005 12:14:51 -0500 Subject: [python-win32] Application exception in Python.dll In-Reply-To: <312cfe2b0511221450j7ddf7a54y8aef1f02b8cc483@mail.gmail.com> Message-ID: Hi, I have a series of python programs that communicate over sockets. The server is using asyncore, the clients just the bare socket library. The system is just storing strings of XML associated with a particular name, kinda like a poor man's file system. The trouble is that it mostly runs fine, but every once in a while (lots of activity each day, but trouble once every week or so) one of the applications dies mysteriously. Is there anyway to track down the trouble? Would a different version of python be better? These processes are launched and then run until they die. I'm thinking of bouncing them nightly, but would prefer to find the trouble and fix it. Advice very much appreciated. The error I'm getting is: Event viewer: Faulting application python.exe, version 0.0.0.0, faulting module python24.dll, version 2.4.150.1012, fault address 0x000t2f60 Doctor Watson: The application, C:\Python24\python.exe, generated an application error. .... The exception generated was c0000005 at address 1E07EF60 (python24!PyObject_GetAttr). BTW, I did post a query awhile ago about launching excel as part of this system, which would respond to a remote query. I have that working, but we're not in production yet so I thought I'd hold off on letting y'all know that it worked until it actually got used in anger. Thanks, Tom This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051123/162e7ca4/attachment.htm From rogelio.flores at gmail.com Wed Nov 23 18:30:01 2005 From: rogelio.flores at gmail.com (Rogelio Flores) Date: Wed, 23 Nov 2005 12:30:01 -0500 Subject: [python-win32] Changing the name of a service Message-ID: Is there a way to override the name of a service when installing it? What I want to do is use the same python script to install more than one copies of the same service, under a different name, on the same machine. I know I can simply copy the python file and change the _svc_name_ and have two clones of the service I can install with different names, but I want something like providing the service name on the command line when I do the install. I already have a customOptionHandler function that can take arguments, but I cannot change the _svc_name_ property since win32serviceutil.HandleCommandLine(MyService, argv = sys.argv, customInstallOptions = 'c:', customOptionHandler = customOptionHandler) takes the class name and I guess it gets the name from there so anything I do in customOptionHandler to the name doesn't get recorded at install time. -- Rogelio From sjmachin at lexicon.net Wed Nov 23 20:21:17 2005 From: sjmachin at lexicon.net (John Machin) Date: Thu, 24 Nov 2005 06:21:17 +1100 Subject: [python-win32] Application exception in Python.dll In-Reply-To: References: Message-ID: <4384C12D.7060608@lexicon.net> Tom_RobbinsMilne at swissre.com wrote: > [snip] > The error I'm getting is: > Event viewer: > > Faulting application python.exe, version 0.0.0.0, faulting module > python24.dll, version 2.4.150.1012, fault address 0x000t2f60 What is that "t" in the middle of a hexadecimal number? > > Doctor Watson: > The application, C:\Python24\python.exe, generated an > application error. > .... > The exception generated was c0000005 at address 1E07EF60 > (python24!PyObject_GetAttr). Tom, this points squarely at a bug in core Python. Report the problem using the SourceForge bug tracker. This mailing list is for Mark Hammond's win32all aka pywin32 package. Cheers, John From Tom_RobbinsMilne at swissre.com Wed Nov 23 20:31:11 2005 From: Tom_RobbinsMilne at swissre.com (Tom_RobbinsMilne@swissre.com) Date: Wed, 23 Nov 2005 14:31:11 -0500 Subject: [python-win32] Application exception in Python.dll In-Reply-To: <4384C12D.7060608@lexicon.net> Message-ID: John, Thanks very much. I'll try there. I thought it may be something specific to windows, as running it on Linux seems to work fine. My apologies for the typo, the correct hex number is : fault address 0x0007ef60 Thanks, Tom John Machin Sent by: python-win32-bounces at python.org 11/23/2005 02:21 PM To Tom_RobbinsMilne at swissre.com cc python-win32 at python.org Subject Re: [python-win32] Application exception in Python.dll Tom_RobbinsMilne at swissre.com wrote: > [snip] > The error I'm getting is: > Event viewer: > > Faulting application python.exe, version 0.0.0.0, faulting module > python24.dll, version 2.4.150.1012, fault address 0x000t2f60 What is that "t" in the middle of a hexadecimal number? > > Doctor Watson: > The application, C:\Python24\python.exe, generated an > application error. > .... > The exception generated was c0000005 at address 1E07EF60 > (python24!PyObject_GetAttr). Tom, this points squarely at a bug in core Python. Report the problem using the SourceForge bug tracker. This mailing list is for Mark Hammond's win32all aka pywin32 package. Cheers, John _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051123/db442d5b/attachment.html From gregpinero at gmail.com Wed Nov 23 21:01:26 2005 From: gregpinero at gmail.com (=?ISO-8859-1?Q?Gregory_Pi=F1ero?=) Date: Wed, 23 Nov 2005 15:01:26 -0500 Subject: [python-win32] PythonWin Not starting - Windows Server 2003 OS In-Reply-To: <312cfe2b0511220622p781b45ecwb196c6fcd46514d1@mail.gmail.com> References: <312cfe2b0511210614j32b6b34m5edf260bbfc2badb@mail.gmail.com> <312cfe2b0511220622p781b45ecwb196c6fcd46514d1@mail.gmail.com> Message-ID: <312cfe2b0511231201h129e135ctb7b833b64ed3410e@mail.gmail.com> Ok, I got it working. I had to log in as administrator on that computer and then it asked me to allow Pythonwin to run. Something about data execution prevention. -Greg On 11/22/05, Gregory Pi?ero wrote: > > Yeah, I know this is a pretty vague question. I'm willing to try to debug > it myself. Could anyone point me towards where to start? Is there a error > log file somewhere or any known issues with Windows Server 2003? > > Thanks, > > Greg > > > On 11/21/05, Gregory Pi?ero wrote: > > > > Hi, > > > > I just installed PythonWin on a fresh install of Windows Server 2003. > > When I try to launch the PythonWin IDE it starts up and shows the IDE for > > about 1 second and then shuts down. > > > > If you need more information, just let me know what to check to get. > > > > Thanks! > > > > -- > > Gregory Pi?ero > > Chief Innovation Officer > > Blended Technologies > > ( www.blendedtechnologies.com) > > > > > -- > Gregory Pi?ero > Chief Innovation Officer > Blended Technologies > (www.blendedtechnologies.com) > -- Gregory Pi?ero Chief Innovation Officer Blended Technologies (www.blendedtechnologies.com) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051123/9edc05f5/attachment.htm From janez.jere at void.si Fri Nov 25 09:47:56 2005 From: janez.jere at void.si (Janez Jere) Date: Fri, 25 Nov 2005 09:47:56 +0100 Subject: [python-win32] Wrong string indentation in PyWin Message-ID: <20051125085231.7CA8333C3A@gw.void.si> Starting with python 2.4.2 and pywin32 205, opening file with multiline comment, where at least two lines are "not correctly indented" causes huge traceback in Pythonwin.exe Example of ill string: """ - a - b """ I am not 100% sure, but problem might be in python's tokenize.py, so I am asking, that someone more competent helps to clear the bug. Janez From Klaus.Noekel at ptv.de Fri Nov 25 08:54:29 2005 From: Klaus.Noekel at ptv.de (=?ISO-8859-1?Q?Klaus_N=F6kel?=) Date: Fri, 25 Nov 2005 08:54:29 +0100 Subject: [python-win32] Can I pass non-VARIANT SAFARRAYs via COM without converting to VA RIANT? Message-ID: Hi, I am working on an application where one of our own number crunching products acts as a COM server. From a Python script which is the COM client I want to retrieve large matrices, manipulate them with numarray, and store the result back in the COM server. I currently pass the matrices as VT_ARRAY | VT_VARIANT objects, but this is a waste of time and space compared to VT_ARRAY | VT_R8. Tests with a VBA client show that the latter are passed ~20 times faster, and in less memory. For matrices of 3000x3000 elements this is a concern. Interestingly, win32com accepts matrices of VT_V8 element type, but actually takes longer (!) than in the case of VT_VARIANT, presumably because of an extra conversion (instead of one less). Is there any way that I can configure python-win32 to use VT_V8 as the element type of a SAFE_ARRAY and suppress any conversion to VT_VARIANT? Any hints are appreciated! Cheers, Klaus Noekel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051125/4aa5dbe7/attachment.html From mhammond at skippinet.com.au Sun Nov 27 01:08:45 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 27 Nov 2005 11:08:45 +1100 Subject: [python-win32] Can I pass non-VARIANT SAFARRAYs via COM withoutconverting to VA RIANT? In-Reply-To: Message-ID: > Is there any way that I can configure python-win32 to use VT_V8 as > the element type of a SAFE_ARRAY and suppress any conversion to > VT_VARIANT? Not without patching the code, I'm afraid. The code (oleargs.cpp) has explicit support for VT_UI1, but everything else does go through the generic variant conversion. Additional support for other types could be added, but I'm wondering if specific support for numarray would make sense. I'd be happy to offer guidance should you choose to look at these enhancements. Mark From flamexx7 at yahoo.co.in Sun Nov 27 18:57:45 2005 From: flamexx7 at yahoo.co.in (flame burns) Date: Sun, 27 Nov 2005 17:57:45 +0000 (GMT) Subject: [python-win32] Question on .pyw extension in Python Message-ID: <20051127175745.69368.qmail@web8605.mail.in.yahoo.com> I've installed Python 2.4 on my pc which runs Windows xp. I downloaded scripts from some sites which uses .pyw extension. When I use them the script runs without popping up a console. But when I try to write my own script with pyw extension it doesn't work. Can any one help me? --------------------------------- Enjoy this Diwali with Y! India Click here -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051127/7b90cbab/attachment.html From durumdara at mailpont.hu Mon Nov 28 13:55:00 2005 From: durumdara at mailpont.hu (durumdara@mailpont.hu) Date: Mon, 28 Nov 2005 13:55:00 +0100 Subject: [python-win32] mciSendCommand from win32 ??? Message-ID: <438AFE24.8020703@mailpont.hu> Hi ! I want to call mciSendCommand to record a music in Windows. I want to do same thing like in this code (Delphi): procedure TForm1.OpenMedia; var MyOpenParms: TMCI_Open_Parms; begin Flags:=mci_Wait or mci_Open_Element or mci_Open_Type; with MyOpenParms do begin dwCallback:=Handle; // TForm1.Handle lpstrDeviceType:=PChar('WaveAudio'); lpstrElementName:=PChar(''); end; MyError:=mciSendCommand(0, mci_Open, Flags,Cardinal(@MyOpenParms)); if MyError = 0 then FDeviceID:=MyOpenParms.wDeviceID; end; procedure TForm1.RecordMedia; var MyRecordParms: TMCI_Record_Parms; set_parms: MCI_WAVE_SET_PARMS; begin set_parms.wFormatTag := WAVE_FORMAT_PCM; set_parms.wBitsPerSample := 16; set_parms.nChannels := 1; set_parms.nBlockAlign := (set_parms.nChannels*set_parms.wBitsPerSample) div 8; set_parms.nSamplesPerSec := 44100; set_parms.nAvgBytesPerSec := ((set_parms.wBitsPerSample) * set_parms.nChannels * set_parms.nSamplesPerSec) div 8; MyError:=mciSendCommand(FDeviceID,MCI_SET, MCI_WAIT or MCI_WAVE_SET_FORMATTAG or MCI_WAVE_SET_BITSPERSAMPLE or MCI_WAVE_SET_CHANNELS or MCI_WAVE_SET_SAMPLESPERSEC or MCI_WAVE_SET_AVGBYTESPERSEC or MCI_WAVE_SET_BLOCKALIGN, Cardinal(@set_parms)); Flags:=mci_Notify; with MyRecordParms do begin dwCallback:=Handle; // TForm1.Handle dwFrom:=0; dwTo:=10000; end; MyError:=mciSendCommand(FDeviceID, mci_Record, Flags, Longint(@MyRecordParms)); end; procedure TForm1.StopMedia; var MyGenParms: TMCI_Generic_Parms; begin if FDeviceID <> 0 then begin Flags:=mci_Wait; MyGenParms.dwCallback:=Handle; // TForm1.Handle MyError:=mciSendCommand(FDeviceID, mci_Stop, Flags,Longint(MyGenParms)); end; end; procedure TForm1.SaveMedia(OrgFileName,FileName:string); type // not implemented by Delphi PMCI_Save_Parms = ^TMCI_Save_Parms; TMCI_Save_Parms = record dwCallback: DWord; lpstrFileName: PAnsiChar; // name of file to save end; var MySaveParms: TMCI_Save_Parms; begin if FDeviceID <> 0 then begin // save the file... Flags:=mci_Save_File or mci_Wait; with MySaveParms do begin dwCallback:=Handle; lpstrFileName:=PChar(FileName); end; MyError:=mciSendCommand(FDeviceID, mci_Save, Flags, Longint(@MySaveParms)); end; end; procedure TForm1.CloseMedia; var MyGenParms: TMCI_Generic_Parms; begin if FDeviceID <> 0 then begin Flags:=0; MyGenParms.dwCallback:=Handle; // TForm1.Handle MyError:=mciSendCommand(FDeviceID, mci_Close, Flags, Longint(MyGenParms)); if MyError = 0 then FDeviceID:=0; end; end; 1. Can I do it ? 2. If not, what is the solution (I haven't Delphi... I have only freeware things) Thanx for help: dd From tim.golden at viacom-outdoor.co.uk Mon Nov 28 16:45:52 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon, 28 Nov 2005 15:45:52 -0000 Subject: [python-win32] Question on .pyw extension in Python Message-ID: <9A28C052FF32734DACB0A288A3533991044D2383@vogbs009.gb.vo.local> [flame burns] > I've installed Python 2.4 on my pc which runs Windows xp. > I downloaded scripts from some sites which uses .pyw > extension. When I use them the script runs without popping > up a console. But when I try to write my own script with > pyw extension it doesn't work. Can any one help me? Just to clarify: the .pyw extension simply means: run this Python script without creating a console window. This is generally what you want if you have a program which is GUI-based. You can run *exactly* the same program with a console window simply by renaming it to .py. In general, you'll want to name your scripts .py until you've debugged everything, That way, any errors will appear on your console window. If you haven't already, have a look at the FAQ: http://www.python.org/doc/faq/ and in particular the Python Windows FAQ: http://www.python.org/doc/faq/windows.html 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 gagenellina at softlab.com.ar Mon Nov 28 20:23:06 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Mon, 28 Nov 2005 16:23:06 -0300 Subject: [python-win32] mciSendCommand from win32 ??? In-Reply-To: <438AFE24.8020703@mailpont.hu> References: <438AFE24.8020703@mailpont.hu> Message-ID: <6.2.1.2.0.20051128161705.03a4ba00@192.168.0.115> At Monday 28/11/2005 09:55, durumdara at mailpont.hu wrote: >I want to call mciSendCommand to record a music in Windows. >I want to do same thing like in this code (Delphi): >1. Can I do it ? >2. If not, what is the solution (I haven't Delphi... I have only >freeware things) Try http://www.freepascal.org/ and Lazarus. Or, there is a small DirectSound example, see the PyWin32 help. Gabriel Genellina Softlab SRL From rogelio.flores at gmail.com Tue Nov 29 00:03:48 2005 From: rogelio.flores at gmail.com (Rogelio Flores) Date: Mon, 28 Nov 2005 18:03:48 -0500 Subject: [python-win32] Error calling win32pdh.EnumObjectItems Message-ID: Can anyone tell me what this error message means? >>> win32pdhutil.ShowAllProcesses() Traceback (most recent call last): File "", line 1, in ? File "c:\...\win32pdhutil.py", line 67, in ShowAllProcesses items, instances = win32pdh.EnumObjectItems(None,None,object, win32pdh.PERF_ DETAIL_WIZARD) pywintypes.api_error: (-2147481646, 'EnumObjectItems for buffer size', 'No error message is available') Thanks. From mhammond at skippinet.com.au Tue Nov 29 05:45:48 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 29 Nov 2005 15:45:48 +1100 Subject: [python-win32] Error calling win32pdh.EnumObjectItems In-Reply-To: Message-ID: It looks like you have an old win32all version (it looks like it was fixed in win32all-154). This should be fixed in all pywin32 versions available from sourceforge. Mark > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of Rogelio Flores > Sent: Tuesday, 29 November 2005 10:04 AM > To: python-win32 at python.org > Subject: [python-win32] Error calling win32pdh.EnumObjectItems > > > Can anyone tell me what this error message means? > > >>> win32pdhutil.ShowAllProcesses() > Traceback (most recent call last): > File "", line 1, in ? > File "c:\...\win32pdhutil.py", line 67, in ShowAllProcesses > items, instances = win32pdh.EnumObjectItems(None,None,object, > win32pdh.PERF_ > DETAIL_WIZARD) > pywintypes.api_error: (-2147481646, 'EnumObjectItems for buffer > size', 'No error > message is available') > > > Thanks. > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From timr at probo.com Tue Nov 29 18:31:40 2005 From: timr at probo.com (Tim Roberts) Date: Tue, 29 Nov 2005 09:31:40 -0800 Subject: [python-win32] mciSendCommand from win32 ??? In-Reply-To: References: Message-ID: <438C907C.6070404@probo.com> On Mon, 28 Nov 2005 13:55:00 +0100, wrote: >I want to call mciSendCommand to record a music in Windows. > >I want to do same thing like in this code (Delphi): >... > >1. Can I do it ? >2. If not, what is the solution (I haven't Delphi... I have only >freeware things) > > I have not seen a Python wrapper for the multimedia APIs in winmm.dll. There are a couple of references in Google, but no good hits. However, you could certainly construct one with ctypes. In your case, all you should need is the mciSendString command. Everything you have done with mciSendCommand can be done with the simpler mciSendString commands, kind of like this: mciSendString( "open new type waveaudio alias cap" ) mciSendString( "set cap bitspersample 16 channels 1 samplespersec 44100" ) mciSendString( "record cap" ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mc at mclaveau.com Wed Nov 30 08:50:47 2005 From: mc at mclaveau.com (Michel Claveau) Date: Wed, 30 Nov 2005 08:50:47 +0100 Subject: [python-win32] mciSendCommand from win32 ??? References: <438C907C.6070404@probo.com> Message-ID: <000301c5f582$c87854d0$0701a8c0@PORTABLES> Hi! I had wrapped MCI with ctypes. Here, begin of my source : from ctypes import windll, c_buffer class mci: def __init__(self): self.w32mci = windll.winmm.mciSendStringA self.w32mcierror = windll.winmm.mciGetErrorStringA def send(self,commande): buffer = c_buffer(255) errorcode = self.w32mci(str(commande),buffer,254,0) if errorcode: # il y a une erreur return errorcode, self.w32mcierror(errorcode,buffer,254) else: # commande Ok retourne 0 return errorcode,buffer.value @-salutation MCI (Michel Claveau Informatique) From ralf at brainbot.com Wed Nov 30 17:41:32 2005 From: ralf at brainbot.com (Ralf Schmitt) Date: Wed, 30 Nov 2005 17:41:32 +0100 Subject: [python-win32] win32 service not receiving shutdown notification on reboot Message-ID: <438DD63C.1040805@brainbot.com> 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? TIA, - 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)