From patter001 at gmail.com Fri Feb 1 04:34:23 2008 From: patter001 at gmail.com (Kevin Patterson) Date: Thu, 31 Jan 2008 22:34:23 -0500 Subject: [python-win32] How to create a com_record? Message-ID: I have a COM server that is expecting a GUID as an argument. The generated makepy shows that the function is expecting a VT_RECORD. I cannot seem to pass in the CLSID, I get the following: TypeError: Only com_record objects can be used as records I looked at the win32com.client.Record function, but it looks like it will create another COM object if I give it the GUID.What I really need is to pass the GUID in to this function as a sort of structure. I "think" I have to build a struct (using the struct class?) turn it into a buffer and then somehow convert this to a Record object....Trouble is I can't find any documentation on com_record objects anywhere....Any ideas? Thanks, Kevin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080131/95154f25/attachment.htm From mhammond at skippinet.com.au Fri Feb 1 06:34:42 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 1 Feb 2008 16:34:42 +1100 Subject: [python-win32] How to create a com_record? In-Reply-To: References: Message-ID: <091c01c86494$28e28390$7aa78ab0$@com.au> The record will be defined in a typelib somewhere, and have named elements. For example, the win32com test VB code: Public Type VBStruct int_val As Integer str_val As String ob_val As Object sub_val As SubStruct End Type And VB arranges for that to become a COM record. Python code can then say: s = win32com.client.Record("VBStruct", vbtest) s.int_val = -1 (Where vbtest in the first line is a COM object that comes from the same typelib which defines the struct). The object 's' can then be passed as a param, where it will become VT_RECORD. Without knowing how the struct is defined in your case I can't speculate how a GUID would be carried. If it was a simply array of bytes, then using 'buffer(guid)' will give you the raw bytes. Cheers, Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Kevin Patterson Sent: Friday, 1 February 2008 2:34 PM To: python-win32 at python.org Subject: [python-win32] How to create a com_record? I have a COM server that is expecting a GUID as an argument. The generated makepy shows that the function is expecting a VT_RECORD. I cannot seem to pass in the CLSID, I get the following: TypeError: Only com_record objects can be used as records I looked at the win32com.client.Record function, but it looks like it will create another COM object if I give it the GUID.What I really need is to pass the GUID in to this function as a sort of structure. I "think" I have to build a struct (using the struct class?) turn it into a buffer and then somehow convert this to a Record object....Trouble is I can't find any documentation on com_record objects anywhere....Any ideas? Thanks, Kevin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080201/d5d8742e/attachment.htm From maria.reinhammar at swisslog-accalon.com Fri Feb 1 10:40:48 2008 From: maria.reinhammar at swisslog-accalon.com (Reinhammar Maria) Date: Fri, 1 Feb 2008 10:40:48 +0100 Subject: [python-win32] makepy exception Message-ID: Hi all, Any advice to give on this? (python 2.5.1, win32 ext 210) D:\Python25\Lib\site-packages\win32com\client>"D:\Python25\python.exe" makepy.py -d SmarTeam.Std.SessionManagement.Authentication.Modules.tlb Generating to D:\Python25\lib\site-packages\win32com\gen_py\69661005-524C-44A4-B1B8-9E 4B3C6940C3x0x5x18\__init__.py Building definitions from type library... Traceback (most recent call last): File "makepy.py", line 370, in rc = main() File "makepy.py", line 363, in main GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, bForDemand = bForDemand, bBuildHidden = hiddenSpec) File "makepy.py", line 264, in GenerateFromTypeLibSpec gen.generate(fileUse, bForDemand) File "D:\Python25\lib\site-packages\win32com\client\genpy.py", line 770, in generate self.do_generate() File "D:\Python25\lib\site-packages\win32com\client\genpy.py", line 831, in do_generate oleItems, enumItems, recordItems, vtableItems = self.BuildOleItemsFromType() File "D:\Python25\lib\site-packages\win32com\client\genpy.py", line 745, in BuildOleItemsFromType oleItem, vtableItem = self._Build_Interface(type_info_tuple) File "D:\Python25\lib\site-packages\win32com\client\genpy.py", line 713, in _Build_Interface oleItem = DispatchItem(info, attr, doc) File "D:\Python25\lib\site-packages\win32com\client\genpy.py", line 266, in __init__ build.DispatchItem.__init__(self, typeinfo, attr, doc) File "D:\Python25\lib\site-packages\win32com\client\build.py", line 113, in __init__ self.Build(typeinfo, attr, bForUser) File "D:\Python25\lib\site-packages\win32com\client\build.py", line 261, in Build self._AddFunc_(typeinfo,fdesc,bForUser) File "D:\Python25\lib\site-packages\win32com\client\build.py", line 174, in _AddFunc_ typerepr, resultCLSID, resultDoc = _ResolveType(typerepr, typeinfo) File "D:\Python25\lib\site-packages\win32com\client\build.py", line 438, in _ResolveType subrepr, sub_clsid, sub_doc = _ResolveType(subrepr, itypeinfo) File "D:\Python25\lib\site-packages\win32com\client\build.py", line 454, in _ResolveType resultTypeInfo = itypeinfo.GetRefTypeInfo(subrepr) pywintypes.com_error: (-2147319765, 'Element not found.', None, None) D:\Python25\Lib\site-packages\win32com\client> Regards// Maria Reinhammar Software Engineer Swisslog-Accalon AB ************************************************************************ ************************ CONFIDENTIALITY AND DISCLAIMER This e-mail and its attachments are intended for the above named addressee(s) only and may be confidential. If the mail has come to you in error please reply to this e-mail and highlight the error. In addition, we kindly ask you to destroy the Mail. Please be aware that we disclaim all liability for the integrity or for the accuracy of this Mail, as transmissions via Internet are not error free communications medium. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080201/c0149b68/attachment-0001.htm From suraj at barkale.com Fri Feb 1 14:48:30 2008 From: suraj at barkale.com (Suraj Barkale) Date: Fri, 1 Feb 2008 13:48:30 +0000 (UTC) Subject: [python-win32] Reading .py or .pyc from an excel sheet References: Message-ID: Hi, Pallavi Apotikar tcs.com> writes: > > I know how to write the macro using > VB, but I don't know how to do the same thing using python -- where is > the option available etc. You can not run Python inside excel but you can use COM to get data from an excel sheet using same API as VBA. I have found that using the Excel API is a pain. If you just want to read data from Excel please check this out: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440661 http://www.lexicon.net/sjmachin/xlrd.htm http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/483742 > Can you give me any reference? I have found this (http://starship.python.net/crew/pirx/spam7/COMtut.PPT) tutorial to be an excellent introduction to subject. If you are already familiar with VBA then you might find comtypes easier than win32com for automating Excel. The comtypes documentation talks about using Excel (http://starship.python.net/crew/theller/comtypes/). Regards, Suraj From patter001 at gmail.com Fri Feb 1 17:59:14 2008 From: patter001 at gmail.com (Kevin Patterson) Date: Fri, 1 Feb 2008 11:59:14 -0500 Subject: [python-win32] How to create a com_record? In-Reply-To: <091c01c86494$28e28390$7aa78ab0$@com.au> References: <091c01c86494$28e28390$7aa78ab0$@com.au> Message-ID: Thanks Mark. I'll dig around the various windows typelilbs and see if one of them has a GUID structure. If I know the order of the structure myself (and know how to turn in to a buffer) does anyone know how I could convert the buffer in to a com_record ? On Feb 1, 2008 12:34 AM, Mark Hammond wrote: > The record will be defined in a typelib somewhere, and have named > elements. For example, the win32com test VB code: > > > > Public Type VBStruct > > int_val As Integer > > str_val As String > > ob_val As Object > > sub_val As SubStruct > > End Type > > > > And VB arranges for that to become a COM record. Python code can then > say: > > > > s = win32com.client.Record("VBStruct", vbtest) > > s.int_val = -1 > > > > (Where vbtest in the first line is a COM object that comes from the same > typelib which defines the struct). The object 's' can then be passed as a > param, where it will become VT_RECORD. Without knowing how the struct is > defined in your case I can't speculate how a GUID would be carried. If it > was a simply array of bytes, then using 'buffer(guid)' will give you the raw > bytes. > > > > Cheers, > > > > Mark > > > > *From:* python-win32-bounces at python.org [mailto: > python-win32-bounces at python.org] *On Behalf Of *Kevin Patterson > *Sent:* Friday, 1 February 2008 2:34 PM > *To:* python-win32 at python.org > *Subject:* [python-win32] How to create a com_record? > > > > I have a COM server that is expecting a GUID as an argument. The generated > makepy shows that the function is expecting a VT_RECORD. I cannot seem to > pass in the CLSID, I get the following: > > TypeError: Only com_record objects can be used as records > > I looked at the win32com.client.Record function, but it looks like it will > create another COM object if I give it the GUID.What I really need is to > pass the GUID in to this function as a sort of structure. I "think" I have > to build a struct (using the struct class?) turn it into a buffer and then > somehow convert this to a Record object....Trouble is I can't find any > documentation on com_record objects anywhere....Any ideas? > > Thanks, > Kevin > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080201/d72cfaa5/attachment.htm From larry.bates at websafe.com Fri Feb 1 21:20:12 2008 From: larry.bates at websafe.com (Larry Bates) Date: Fri, 01 Feb 2008 14:20:12 -0600 Subject: [python-win32] Reading .py or .pyc from an excel sheet In-Reply-To: References: Message-ID: Pallavi Apotikar wrote: > > Actually, I have an excel sheet, where I am entering the data. > > I am reading the entered data in python. > > excel takes data as a string. > > before passing it to python, i wanted to check whether the entered > data(value) is a valid python data type. > > so instead of checking this in python script(/ say program), I wanted to > put macro in excel , so that all the values are checked at a stretch (or > say while entering - before passing it to the python program.) > > So is it possible ? > > Pallavi Ajabrao Apotikar > Tata Consultancy Services > Mailto: pallavi.apotikar at tcs.com > Website: http://www.tcs.com > ____________________________________________ > Experience certainty. IT Services > Business Solutions > Outsourcing > ____________________________________________ > > > *"Graeme Glass" * > > 01/31/2008 03:31 PM > > > To > "Pallavi Apotikar" > cc > python-win32 at python.org > Subject > Re: [python-win32] Reading .py or .pyc from an excel sheet > > > > > > > > > > On Jan 31, 2008 11:43 AM, Pallavi Apotikar <_pallavi.apotikar at tcs.com_ > > wrote: > > Hello Sir/Madam, > > I would like to know, is it possible to read a python file from an excel > sheet ? > > Thanks and Regards > > Pallavi Ajabrao Apotikar > > > I don't fully understand what you are asking, > > But... > > If you where however asking, if it is possible to display the contents > of a python script in an excel sheet, yes it's possible (it's just > text), why you would want to? a .pyc file would be pretty meaningless to > you as it is a 'compiled' python script, and is 'bytecode'. > > If you where asking if you could control excel via a python script, > which I think is the most plausible, the answer is a resounding yes! > > There are countless examples on this mailing list of such tasks. > > Google for 'python +excel', will bring up loads of examples. > > (_http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html_) > > import win32com.client > xl = win32com.client.Dispatch("Excel.Application") > xl.Visible = 1 > > I hope one of these answers will help with what you where asking. > > G > ForwardSourceID:NT00006176 > > =====-----=====-----===== > Notice: The information contained in this e-mail > message and/or attachments to it may contain > confidential or privileged information. If you are > not the intended recipient, any dissemination, use, > review, distribution, printing or copying of the > information contained in this e-mail message > and/or attachments to it are strictly prohibited. If > you have received this communication in error, > please notify us by reply e-mail or telephone and > immediately and permanently delete the message > and any attachments. Thank you > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 Is sound line you should write the entire data entry program in wxWindows using the wxGrid (which looks like Excel to the end user). Then you can control the data that goes into each cell with your Python program. -Larry From Kyle.Rickey at bakerhughes.com Fri Feb 1 21:24:55 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Fri, 1 Feb 2008 14:24:55 -0600 Subject: [python-win32] odbc timeouts Message-ID: Is it possible to change the default timeout for an odbc connection? For instance: import odbc conn = odbc.odbc(DBNAME) It seems to timeout ~15 seconds. But the above method only takes 1 argument. Is it possible to set a timeout in the connection string? -Kyle Rickey -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080201/bf42bcb6/attachment.htm From timr at probo.com Fri Feb 1 22:12:19 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 01 Feb 2008 13:12:19 -0800 Subject: [python-win32] odbc timeouts In-Reply-To: References: Message-ID: <47A38B33.5030103@probo.com> Rickey, Kyle W wrote: > > Is it possible to change the default timeout for an odbc connection? > For instance: > > > > import odbc > > > > conn = odbc.odbc(DBNAME) > > > > It seems to timeout ~15 seconds. But the above method only takes 1 > argument. Is it possible to set a timeout in the connection string? > You can add "Connect Timeout=120;" to your connection string. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Kyle.Rickey at bakerhughes.com Fri Feb 1 22:51:39 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Fri, 1 Feb 2008 15:51:39 -0600 Subject: [python-win32] odbc timeouts In-Reply-To: <47A38B33.5030103@probo.com> References: <47A38B33.5030103@probo.com> Message-ID: Thanks Tim, I'll give that a shot -Kyle Rickey -----Original Message----- From: python-win32-bounces+kyle.rickey=bakerhughes.com at python.org [mailto:python-win32-bounces+kyle.rickey=bakerhughes.com at python.org] On Behalf Of Tim Roberts Sent: Friday, February 01, 2008 3:12 PM To: Python-Win32 List Subject: Re: [python-win32] odbc timeouts Rickey, Kyle W wrote: > > Is it possible to change the default timeout for an odbc connection? > For instance: > > > > import odbc > > > > conn = odbc.odbc(DBNAME) > > > > It seems to timeout ~15 seconds. But the above method only takes 1 > argument. Is it possible to set a timeout in the connection string? > You can add "Connect Timeout=120;" to your connection string. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From gerdusvanzyl at gmail.com Sat Feb 2 23:53:01 2008 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Sun, 3 Feb 2008 00:53:01 +0200 Subject: [python-win32] Print PDF Message-ID: <91882ea90802021453s29534e93o22c85540eb70ffbe@mail.gmail.com> Is there a way to print a PDF using the activeX control of Acrobat Reader? I have seen the previous discussing on this on this list but nothing seems to resolve if this is possible or not. My code: import win32com.client.dynamic avdoc = win32com.client.Dispatch("AcroPDF.PDF.1") pd = "C:\uxpython\fun\iac.pdf" avdoc.LoadFile(pd) print avdoc.GetVersions() avdoc.printAll() This does not have any effect, as in nothing is printed or displayed but the call to GetVersions does return information. Thanks, Gerdus van Zyl From mc at mclaveau.com Sun Feb 3 00:29:25 2008 From: mc at mclaveau.com (Michel Claveau) Date: Sun, 3 Feb 2008 00:29:25 +0100 Subject: [python-win32] Print PDF In-Reply-To: <91882ea90802021453s29534e93o22c85540eb70ffbe@mail.gmail.com> References: <91882ea90802021453s29534e93o22c85540eb70ffbe@mail.gmail.com> Message-ID: <0BF012BBFD04484DB323C526B48F53F3@MCI1330> Hi! Perso, I use Adobe-Reader AND SumatraPDF. And, SumatraPDF has command-line options for print directly a file. See : http://blog.kowalczyk.info/software/sumatrapdf/manual.html In Python, you can use system, popen, subprocess, etc. @-salutation Michel Claveau From mhammond at skippinet.com.au Sun Feb 3 05:08:37 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 3 Feb 2008 15:08:37 +1100 Subject: [python-win32] makepy exception In-Reply-To: References: Message-ID: <0a1401c8661a$76447580$62cd6080$@com.au> I'm afraid I've never seen that before. The code in build.py at line 261 is looping over each method defined in an object, and seems to be havng trouble loading the info for one of them. It might be that a dependent typelib hasn't been loaded - I don't think we handle dependent typelibs correctly in all cases. If you add debug prints you might be able to find some clues as to what is happening, but I'm reluctant to simply catch and ignore such errors until I have a better idea what is going on. Cheers, Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Reinhammar Maria Sent: Friday, 1 February 2008 8:41 PM To: python-win32 at python.org Subject: [python-win32] makepy exception Hi all, Any advice to give on this? (python 2.5.1, win32 ext 210) D:\Python25\Lib\site-packages\win32com\client>"D:\Python25\python.exe" makepy.py -d SmarTeam.Std.SessionManagement.Authentication.Modules.tlb Generating to D:\Python25\lib\site-packages\win32com\gen_py\69661005-524C-44A4-B1B8-9E4B3C 6940C3x0x5x18\__init__.py Building definitions from type library... Traceback (most recent call last): File "makepy.py", line 370, in rc = main() File "makepy.py", line 363, in main GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, bForDemand = bForDemand, bBuildHidden = hiddenSpec) File "makepy.py", line 264, in GenerateFromTypeLibSpec gen.generate(fileUse, bForDemand) File "D:\Python25\lib\site-packages\win32com\client\genpy.py", line 770, in generate self.do_generate() File "D:\Python25\lib\site-packages\win32com\client\genpy.py", line 831, in do_generate oleItems, enumItems, recordItems, vtableItems = self.BuildOleItemsFromType() File "D:\Python25\lib\site-packages\win32com\client\genpy.py", line 745, in BuildOleItemsFromType oleItem, vtableItem = self._Build_Interface(type_info_tuple) File "D:\Python25\lib\site-packages\win32com\client\genpy.py", line 713, in _Build_Interface oleItem = DispatchItem(info, attr, doc) File "D:\Python25\lib\site-packages\win32com\client\genpy.py", line 266, in __init__ build.DispatchItem.__init__(self, typeinfo, attr, doc) File "D:\Python25\lib\site-packages\win32com\client\build.py", line 113, in __init__ self.Build(typeinfo, attr, bForUser) File "D:\Python25\lib\site-packages\win32com\client\build.py", line 261, in Build self._AddFunc_(typeinfo,fdesc,bForUser) File "D:\Python25\lib\site-packages\win32com\client\build.py", line 174, in _AddFunc_ typerepr, resultCLSID, resultDoc = _ResolveType(typerepr, typeinfo) File "D:\Python25\lib\site-packages\win32com\client\build.py", line 438, in _ResolveType subrepr, sub_clsid, sub_doc = _ResolveType(subrepr, itypeinfo) File "D:\Python25\lib\site-packages\win32com\client\build.py", line 454, in _ResolveType resultTypeInfo = itypeinfo.GetRefTypeInfo(subrepr) pywintypes.com_error: (-2147319765, 'Element not found.', None, None) D:\Python25\Lib\site-packages\win32com\client> Regards// Maria Reinhammar Software Engineer Swisslog-Accalon AB **************************************************************************** ******************** CONFIDENTIALITY AND DISCLAIMER This e-mail and its attachments are intended for the above named addressee(s) only and may be confidential. If the mail has come to you in error please reply to this e-mail and highlight the error. In addition, we kindly ask you to destroy the Mail. Please be aware that we disclaim all liability for the integrity or for the accuracy of this Mail, as transmissions via Internet are not error free communications medium. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080203/d8e5149e/attachment.htm From tomdiz at yahoo.com Sun Feb 3 06:07:58 2008 From: tomdiz at yahoo.com (Thomas DiZoglio) Date: Sat, 2 Feb 2008 21:07:58 -0800 (PST) Subject: [python-win32] Windows Python 2.5.1 IPV6 problems Message-ID: <476627.62676.qm@web53507.mail.re2.yahoo.com> Hi, I'm trying to get some IPV6 python code running under Windows. I have installed Python 2.5.1 for Windows using the binaries from python.org. The code works fine under Debian and MacOSX (both using Python 2.5) I have rebuilt the python binaries from source and set ENABLE_IPV6. This didn't help. I have also read about not being able to bind to a IPV4 and IPV6 socket. I tried setting the setsockopt() call using IPV6_V6ONLY, but this is not recognized by the python interpreter. Thanks for any help I can get. I'm stuck on this and searching the NET for help. I get the following error: C:\test_py>python ipv6.py Traceback (most recent call last): File "ipv6.py", line 119, in main() File "ipv6.py", line 113, in main p = listenTCP6(6666, TrivialServerFactory()) File "ipv6.py", line 95, in listenTCP6 return reactor.listenWith(Port, port, factory, backlog, interface) File "C:\python251\lib\site-packages\twisted\internet\posixbase.py", line 499, in listenWith p.startListening() File "C:\python251\lib\site-packages\twisted\internet\tcp.py", line 730, in st artListening skt = self.createInternetSocket() File "C:\python251\lib\site-packages\twisted\internet\tcp.py", line 718, in cr eateInternetSocket s = base.BasePort.createInternetSocket(self) File "C:\python251\lib\site-packages\twisted\internet\base.py", line 724, in c reateInternetSocket s = socket.socket(self.addressFamily, self.socketType) File "C:\Python251\lib\socket.py", line 154, in __init__ _sock = _realsocket(family, type, proto) TypeError: an integer is required Thanks. ------------------------- t0md I run with the following command: python ipv6.py ------------------------------------------------ HERE IS THE CODE for ipv6.py: ------------------------------------------------ #this is copied verbatim from http://twistedmatrix.com/trac/browser/sandbox/exarkun/ipv6.py #I'm unclear on the license that applies import socket from twisted.internet import tcp from twisted.internet import protocol from twisted.internet import reactor class IPv6Address(object): def __init__(self, type, host, port, flowInfo, scope): self.type = type self.host = host self.port = port self.flowInfo = flowInfo self.scope = scope def __eq__(self, other): if isinstance(other, IPv6Address): a = (self.type, self.host, self.port, self.flowInfo, self.scope) b = (other.type, other.host, other.port, other.flowInfo, other.scope) return a == b return False def __str__(self): return 'IPv6Address(%s, %r, %d, %d, %d)' % ( self.type, self.host, self.port, self.flowInfo, self.scope) def isIPv6Address(ip): try: socket.inet_pton(socket.AF_INET6, ip) except: return 0 return 1 class Client(tcp.Client): addressFamily = socket.AF_INET6 def resolveAddress(self): if isIPv6Address(self.addr[0]): self._setRealAddress(self.addr[0]) else: reactor.resolve(self.addr[0]).addCallbacks( self._setRealAddress, self.failIfNotConnected ) def getHost(self): return IPv6Address('TCP', *self.socket.getsockname()) def getPeer(self): return IPv6Address('TCP', *self.socket.getpeername()) class Connector(tcp.Connector): def _makeTransport(self): return Client(self.host, self.port, self.bindAddress, self, self.reactor) def getDestination(self): return IPv6Address('TCP', self.host, self.port, 0, 0) class Server(tcp.Server): def getHost(self): return IPv6Address('TCP', *self.socket.getsockname()) def getPeer(self): return IPv6Address('TCP', *self.client) class Port(tcp.Port): addressFamily = socket.AF_INET6 transport = Server def _buildAddr(self, address): return IPv6Address('TCP', *address) def getHost(self): return IPv6Address('TCP', *self.socket.getsockname()) def getPeer(self): return IPv6Address('TCP', *self.socket.getpeername()) def connectTCP6(host, port, factory, timeout=30, bindAddress=None, reactor=None): if reactor is None: from twisted.internet import reactor return reactor.connectWith( Connector, host, port, factory, timeout, bindAddress ) def listenTCP6(port, factory, backlog=5, interface='::', reactor=None): if reactor is None: from twisted.internet import reactor #IPV6_V6ONLY = 27, IPV6_BINDV6ONLY #IPPROTO_IPV6 = 41 #_socket.socket.setsockopt(_socket.IPPROTO_IPV6, _socket.IPV6_V6ONLY, 0) return reactor.listenWith(Port, port, factory, backlog, interface) def main(): from twisted.internet import reactor class TrivialProtocol(protocol.Protocol): def connectionMade(self): print 'I (', self.transport.getHost(), ') am connected! (to ', self.transport.getPeer(), ')' self.transport.write('Hello, world!\n') def dataReceived(self, data): print 'Received: ' + repr(data) class TrivialServerFactory(protocol.ServerFactory): protocol = TrivialProtocol class TrivialClientFactory(protocol.ClientFactory): protocol = TrivialProtocol p = listenTCP6(6666, TrivialServerFactory()) c = connectTCP6('::1', 6666, TrivialClientFactory()) reactor.run() if __name__ == '__main__': main() CONFIDENTIALITY NOTICE: Proprietary/Confidential Information belonging to Virgil Software, Inc. may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message (and all attachments) to anyone else. In such case, you should destroy this message (and all attached documents) and are asked to notify the sender by reply email. ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs From gerdusvanzyl at gmail.com Sun Feb 3 16:19:14 2008 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Sun, 3 Feb 2008 17:19:14 +0200 Subject: [python-win32] Print PDF In-Reply-To: <0BF012BBFD04484DB323C526B48F53F3@MCI1330> References: <91882ea90802021453s29534e93o22c85540eb70ffbe@mail.gmail.com> <0BF012BBFD04484DB323C526B48F53F3@MCI1330> Message-ID: <91882ea90802030719v5298c7a5vde0d0e75db019a6e@mail.gmail.com> Thanks the SumatraPDF link is very useful. The following code is what I came up with and is based on this msg: http://two.pairlist.net/pipermail/reportlab-users/2003-February/001260.html import win32ui import dde from win32api import FindExecutable import os.path from os import spawnl,P_NOWAIT,startfile import time pd = "C:/uxpython/fun/godsdebris.pdf" pdbits = os.path.split(pd) readerexe = FindExecutable(pdbits[1],pdbits[0]) spawnl(P_NOWAIT,readerexe[1]) time.sleep(2) s = dde.CreateServer() s.Create('') c = dde.CreateConversation(s) c.ConnectTo('acroview', 'control') # driverName is optional (I think) #c.Exec('[FilePrintTo("%s", "%s", "%s", "%s")]' % (filename, printerName, #driverName, portName)) c.Exec('[DocOpen("%s")]' % (pd,)) #c.Exec('[FilePrint("%s")]' % (pd,)) #c.Exec('[FilePrintSilent("%s")]' % (pd,)) s.Destroy() With the above you can open,print,print silent a PDF. I leave it as an exercise to the reader to make the reader window hidden instead if so desired. ~Gerdus van zyl On Feb 3, 2008 1:29 AM, Michel Claveau wrote: > Hi! > > > Perso, I use Adobe-Reader AND SumatraPDF. > And, SumatraPDF has command-line options for print directly a file. > See : http://blog.kowalczyk.info/software/sumatrapdf/manual.html > > > In Python, you can use system, popen, subprocess, etc. > > > @-salutation > > Michel Claveau > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From pallavi.apotikar at tcs.com Mon Feb 4 07:58:10 2008 From: pallavi.apotikar at tcs.com (Pallavi Apotikar) Date: Mon, 4 Feb 2008 12:28:10 +0530 Subject: [python-win32] Reading .py or .pyc from an excel sheet In-Reply-To: Message-ID: I am sorry, instead of "file", I should have said "a python function". Is it possible to access/use a python function from Excel VB Editor e.g. a library function called "eval()" is used to detect whether the expression/datatype is a valid python expression/datatype ? Can we do that? Thanks and Regards. Pallavi Ajabrao Apotikar Tata Consultancy Services Mailto: pallavi.apotikar at tcs.com Website: http://www.tcs.com ____________________________________________ Experience certainty. IT Services Business Solutions Outsourcing ____________________________________________ Larry Bates Sent by: python-win32-bounces at python.org 02/02/2008 01:50 AM To python-win32 at python.org cc Subject Re: [python-win32] Reading .py or .pyc from an excel sheet Pallavi Apotikar wrote: > > Actually, I have an excel sheet, where I am entering the data. > > I am reading the entered data in python. > > excel takes data as a string. > > before passing it to python, i wanted to check whether the entered > data(value) is a valid python data type. > > so instead of checking this in python script(/ say program), I wanted to > put macro in excel , so that all the values are checked at a stretch (or > say while entering - before passing it to the python program.) > > So is it possible ? > > Pallavi Ajabrao Apotikar > Tata Consultancy Services > Mailto: pallavi.apotikar at tcs.com > Website: http://www.tcs.com > ____________________________________________ > Experience certainty. IT Services > Business Solutions > Outsourcing > ____________________________________________ > > > *"Graeme Glass" * > > 01/31/2008 03:31 PM > > > To > "Pallavi Apotikar" > cc > python-win32 at python.org > Subject > Re: [python-win32] Reading .py or .pyc from an excel sheet > > > > > > > > > > On Jan 31, 2008 11:43 AM, Pallavi Apotikar <_pallavi.apotikar at tcs.com_ > > wrote: > > Hello Sir/Madam, > > I would like to know, is it possible to read a python file from an excel > sheet ? > > Thanks and Regards > > Pallavi Ajabrao Apotikar > > > I don't fully understand what you are asking, > > But... > > If you where however asking, if it is possible to display the contents > of a python script in an excel sheet, yes it's possible (it's just > text), why you would want to? a .pyc file would be pretty meaningless to > you as it is a 'compiled' python script, and is 'bytecode'. > > If you where asking if you could control excel via a python script, > which I think is the most plausible, the answer is a resounding yes! > > There are countless examples on this mailing list of such tasks. > > Google for 'python +excel', will bring up loads of examples. > > (_http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html_) > > import win32com.client > xl = win32com.client.Dispatch("Excel.Application") > xl.Visible = 1 > > I hope one of these answers will help with what you where asking. > > G > ForwardSourceID:NT00006176 > > =====-----=====-----===== > Notice: The information contained in this e-mail > message and/or attachments to it may contain > confidential or privileged information. If you are > not the intended recipient, any dissemination, use, > review, distribution, printing or copying of the > information contained in this e-mail message > and/or attachments to it are strictly prohibited. If > you have received this communication in error, > please notify us by reply e-mail or telephone and > immediately and permanently delete the message > and any attachments. Thank you > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 Is sound line you should write the entire data entry program in wxWindows using the wxGrid (which looks like Excel to the end user). Then you can control the data that goes into each cell with your Python program. -Larry _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 ForwardSourceID:NT000063AA =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080204/a54eadb7/attachment.htm From amish at net-square.com Mon Feb 4 10:12:26 2008 From: amish at net-square.com (Amish Shah) Date: Mon, 04 Feb 2008 14:42:26 +0530 Subject: [python-win32] COM server support on Vista In-Reply-To: <32D138BDBFD14DEAB12BA7439BB8A77F@MCI1330> References: <58b84f8e0711050109t473f5bf3rf33156f95bc133@mail.gmail.com> <3D0CF802BB2B4EFB97686A335C13AE07@MCI1330> <8a6b8e350711051458o35b5aab8hd78229a97b5e880c@mail.gmail.com> <47A1C237.2080604@net-square.com> <32D138BDBFD14DEAB12BA7439BB8A77F@MCI1330> Message-ID: <47A6D6FA.5070904@net-square.com> Hi Michel, I'm having a problem on following configuration of Vista, OS - Vista Ultimate Pyhton: ver 2.4 IE7: Protected mode On I'm installing ietoolbar by following command 1) Run cmd.exe as an administrator, 2) Reach to directory, where ietoobar.py resides, in C:\Python24\Lib\site-packages\win32com\demos 3) python ietoolbar.py --install 4) Open, IE7, right click on toolbar, click on "Pywin32 IE toolbar" 5) If protected mode is on, doesn't comes up, toolbar doesn't load. but if I set Protected mode to Off, restart IE and select "Pywin32 IE toolbar", it loads correctly. Are you using python 2.5 ? Regards, --Amish Michel Claveau wrote: > Hi! > > Because Protected mode need to activate UAC, I prefer to test (to try) on a > virtual-PC. I have done a Vista-premium with UAC on, Security center on, > Protected mode on. > > In the passing, I benefitted from it to test my procedures of installation > for Vista. > > Results : > iebutton: install OK ; run OK (a "bit" slow) > ietoolbar: install OK ; run OK. > > @-salutations > > Michel Claveau > > > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- Amish Shah Chief Technology Officer Net Square Solutions Pvt. Ltd. amish at net-square.com http://net-square.com/ From mail at timgolden.me.uk Mon Feb 4 10:21:28 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 04 Feb 2008 09:21:28 +0000 Subject: [python-win32] Reading .py or .pyc from an excel sheet In-Reply-To: References: Message-ID: <47A6D918.2000206@timgolden.me.uk> Pallavi Apotikar wrote: > I am sorry, instead of "file", I should have said "a python function". > > Is it possible to access/use a python function from Excel VB Editor e.g. a > library function called "eval()" is used to detect whether the > expression/datatype is a valid python expression/datatype ? Can we do > that? Well as far as I can see, there's nothing to stop you instantiating a Python interpreter via COM from Excel (class name is "Python.Interpreter") and then use .Eval or .Exec to do things. I'm not sure just how much this will buy you, but it should at least be possible. TJG From janakiraman.mohanakrishnan at tcs.com Mon Feb 4 11:12:05 2008 From: janakiraman.mohanakrishnan at tcs.com (Janakiraman Mohanakrishnan) Date: Mon, 4 Feb 2008 15:42:05 +0530 Subject: [python-win32] Executing eval function in VBscript Message-ID: Hi all, I have been trying to execute python library functions VBscript, Public sc As New MSScriptControl.ScriptControl sc.Language = "python" Value = sc.Eval("{'key':[1,2]}") While i try to execute the above shown code i am getting exception by saying "type mismatch" that is due to eval function which returns dictionary in this case where in VB does not support this, how shall i proceed in this case. Thanks and Regards! Janakiraman Mohanakrishnan Tata Consultancy Services Mailto: janakiraman.mohanakrishnan at tcs.com Website: http://www.tcs.com ____________________________________________ Experience certainty. IT Services Business Solutions Outsourcing ____________________________________________ =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080204/18381262/attachment-0001.htm From bgailer at alum.rpi.edu Mon Feb 4 16:05:11 2008 From: bgailer at alum.rpi.edu (bob gailer) Date: Mon, 04 Feb 2008 10:05:11 -0500 Subject: [python-win32] Executing eval function in VBscript In-Reply-To: References: Message-ID: <47A729A7.5030709@alum.rpi.edu> Janakiraman Mohanakrishnan wrote: > > Hi all, > I have been trying to execute python library functions VBscript, > > Public sc As New MSScriptControl.ScriptControl > > sc.Language = "python" > Value = sc.Eval("{'key':[1,2]}") > > While i try to execute the above shown code i am getting > exception by saying "type mismatch" that is due to eval function which > returns dictionary in this case where in VB does not support > this, how shall i proceed in this case. That's hard to answer until we know what you want to accomplish! Tell us more. What problem are you trying to solve? Also I'm not very familiar with MSScriptControl. I googled it and found no useful documentation. Do you have any references to it? FWIW I did the following from a Python session: >>> import win32com.client >>> c = win32com.client.Dispatch('MSScriptControl.ScriptControl') >>> c.Language='python' Debugging interfaces not available - debugging is disabled.. >>> c.Eval("3 if 1 else 4") Traceback (most recent call last): File "", line 1, in File "", line 2, in Eval com_error: (-2147352567, 'Exception occurred.', (0, 'Python COM Server Internal Error', "Unexpected Python Error: : Objects of type 'dict' can not be converted to a COM VARIANT", None, 0, -2147467259), None) -- Bob Gailer 919-636-4239 Chapel Hill, NC From cappy2112 at gmail.com Mon Feb 4 16:37:28 2008 From: cappy2112 at gmail.com (Tony Cappellini) Date: Mon, 4 Feb 2008 07:37:28 -0800 Subject: [python-win32] Executing eval function in VBscript Message-ID: <8249c4ac0802040737h3db549d0s3b1f097452b78d66@mail.gmail.com> I tried the same - after seeing a post regarding calling Python from an Excel sheet. It seems some people have done this, as it is posted on several different websties. However, I'm getting an error on this line sc.Language = "python" "A script engine for the specified language can not be created" I've tried adding the MSscript control to the references in Excel, but I still get the same error message Date: Mon, 4 Feb 2008 15:42:05 +0530 From: Janakiraman Mohanakrishnan Subject: [python-win32] Executing eval function in VBscript To: python-win32 at python.org Message-ID: Content-Type: text/plain; charset="us-ascii" Hi all, I have been trying to execute python library functions VBscript, Public sc As New MSScriptControl.ScriptControl sc.Language = "python" From patter001 at gmail.com Mon Feb 4 18:06:52 2008 From: patter001 at gmail.com (Kevin Patterson) Date: Mon, 4 Feb 2008 12:06:52 -0500 Subject: [python-win32] How to create a com_record? In-Reply-To: <0a8d01c866de$b3b97db0$1b2c7910$@com.au> References: <091c01c86494$28e28390$7aa78ab0$@com.au> <0a0a01c86619$2feff650$8fcfe2f0$@com.au> <0a5201c866b5$88447280$98cd5780$@com.au> <0a8d01c866de$b3b97db0$1b2c7910$@com.au> Message-ID: (adding win32 list back in in case someone know more about GetType) Yeah, that's a good way for getting/setting the data. The hangup is: guid = win32com.client.Record("GUID", some_ob) I don't have the some_obj that allows me to build "GUID". From looking through the code it seems that GUID has to be exposed by the COM (which it is not) for that function call to work. VB.NET (GetType) and C++ (__uuid) both already know that a GUID is a record. It seems the python CLSID is the same thing, but i don't know what to call to get a CLSID that is a com_record type. Am I understanding the win32com.client.Record call correctly? It needs GUID to be defined by the COM right? It's not something that I can define within the python code? The other choice appears to be to call pythoncom.GetRecordByTypeInfo directly, but I can't figure out how to make that work without the COM exposing the GUID as well. Its odd b/c the GIUD (python's CLSID) is all over the COM definitions its just type VT_RECORD type that I'm not understanding how to convert to. On Feb 3, 2008 10:33 PM, Mark Hammond wrote: > Something like: > > > > >>> struct.unpack("ihh8b", buffer(pythoncom.IID_IUnknown)) > > (0, 0, 0, -64, 0, 0, 0, 0, 0, 0, 70) > > >>> > > > > Might help? > > > > I'm not quite sure how the BYTE[] array will be handled, but maybe > something like: > > > > >>> struct.unpack("ihh8s", buffer(pythoncom.IID_IUnknown)) > > (0, 0, 0, '\xc0\x00\x00\x00\x00\x00\x00F') > > > > would be better if a string was necessary. Specifically, you would say: > > > > guid = win32com.client.Record("GUID", some_ob) > > d1, d2, d3, d4 = struct.unpack("ihh8s", buffer(pythoncom.IID_IUnknown)) > > guid.Data1 = d1 > > guid.Data2 = d2 > > etc > > > > > > Mark > > > > *From:* Kevin Patterson [mailto:patter001 at gmail.com] > *Sent:* Monday, 4 February 2008 1:59 PM > > *To:* Mark Hammond > *Subject:* Re: [python-win32] How to create a com_record? > > > > Yeah, I'll try to rename some of the variables and post to the list. > > The GUID is the record. It is a struct defined like below (its the same as > the CLSID in the makepy generated file). The trick/problem is how to turn it > in to a VT_RECORD. > > typedef struct _GUID { > > DWORD Data1; > > WORD Data2; > > WORD Data3; > > BYTE Data4[8]; > > } GUID; > > > > On Feb 3, 2008 5:38 PM, Mark Hammond wrote: > > I'm afraid I don't know what GetType() does, but the record seems to have > an element named GUID. Maybe you could post this info to the mailing list, > where someone might know more than me about VB. > > > > Thanks, > > > > Mark > > > > *From:* Kevin Patterson [mailto:patter001 at gmail.com] > *Sent:* Monday, 4 February 2008 5:44 AM > > > *To:* Mark Hammond > *Subject:* Re: [python-win32] How to create a com_record? > > > > Here's how the COM is accessed in VB.NET...The GetInterface is the > function I'm trying to use. It is the one looking for a VT_RECORD. I'm > assuming the GetType is a standard VB.NET function. I don't have a > complete C++ example, but the one snippet I saw of C++ used something like: > __uuidof(ILib.IApi) as the parameter to GetInterface function. > > [VB.Net] > Dim myinstance As AccessManagerLib.Instance ' Obtained earlier > Dim myapi As ILib.IApi > Try > myapi = myinstance.GetInterface(GetType(ILib.IApi).GUID) > ' Do something with myapi > myapi = Nothing ' Release interface when done > End Try > > On Feb 2, 2008 10:59 PM, Mark Hammond wrote: > > I don't think you can pass an arbitrary buffer as a COM record - you will > need to find the name and type of the element in the record. Do you have > example code for any other language? > > > > Mark > > > > *From:* Kevin Patterson [mailto:patter001 at gmail.com] > *Sent:* Friday, 1 February 2008 10:50 PM > *To:* Mark Hammond > *Subject:* Re: [python-win32] How to create a com_record? > > > > Thanks Mark. I'll dig around the various windows typelilbs and see if one > of them has a GUID structure. > > If I know the order of the structure myself (and know how to turn in to a > buffer) do you know how I could convert the buffer in to a com_record ? > > On Feb 1, 2008 12:34 AM, Mark Hammond wrote: > > The record will be defined in a typelib somewhere, and have named > elements. For example, the win32com test VB code: > > > > Public Type VBStruct > > int_val As Integer > > str_val As String > > ob_val As Object > > sub_val As SubStruct > > End Type > > > > And VB arranges for that to become a COM record. Python code can then > say: > > > > s = win32com.client.Record("VBStruct", vbtest) > > s.int_val = -1 > > > > (Where vbtest in the first line is a COM object that comes from the same > typelib which defines the struct). The object 's' can then be passed as a > param, where it will become VT_RECORD. Without knowing how the struct is > defined in your case I can't speculate how a GUID would be carried. If it > was a simply array of bytes, then using 'buffer(guid)' will give you the raw > bytes. > > > > Cheers, > > > > Mark > > > > *From:* python-win32-bounces at python.org [mailto: > python-win32-bounces at python.org] *On Behalf Of *Kevin Patterson > *Sent:* Friday, 1 February 2008 2:34 PM > *To:* python-win32 at python.org > *Subject:* [python-win32] How to create a com_record? > > > > I have a COM server that is expecting a GUID as an argument. The generated > makepy shows that the function is expecting a VT_RECORD. I cannot seem to > pass in the CLSID, I get the following: > > TypeError: Only com_record objects can be used as records > > I looked at the win32com.client.Record function, but it looks like it will > create another COM object if I give it the GUID.What I really need is to > pass the GUID in to this function as a sort of structure. I "think" I have > to build a struct (using the struct class?) turn it into a buffer and then > somehow convert this to a Record object....Trouble is I can't find any > documentation on com_record objects anywhere....Any ideas? > > Thanks, > Kevin > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080204/88101f63/attachment.htm From dave at boost-consulting.com Mon Feb 4 19:02:26 2008 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 04 Feb 2008 13:02:26 -0500 Subject: [python-win32] Can win32com handle this one? Message-ID: <8763x438i5.fsf@gutsy.luannocracy.com> I have a couple of type libraries that I've run makepy on. The first can be loaded with s = win32com.client.Dispatch('nameof.Lib1') I have verified that the above gets the ILib1Session object, which the documentation for that library says is the entry point for everything. The documentation then states I'm to call the GetProvider method to get an instance of ILib2Provider, which, naturally, is defined in Lib2. The GetProvider method is declared thus: HRESULT GetProvider ( ILib2Provider **ppProvider) When I do s.GetProvider() in Python, I get a PyIUnknown object. No QueryInterface call I have been able to manufacture will get me an ILib2Provider object. Note also that trying win32com.client.Dispatch('nameof.Lib2') produces a com_error ('No such interface supported') I'm a total com n00b but am surprised to find myself stymied so quickly. Can anyone help me get a little further with this? Thanks in advance, -- Dave Abrahams Boost Consulting http://boost-consulting.com From timr at probo.com Mon Feb 4 20:02:00 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 04 Feb 2008 11:02:00 -0800 Subject: [python-win32] Can win32com handle this one? In-Reply-To: <8763x438i5.fsf@gutsy.luannocracy.com> References: <8763x438i5.fsf@gutsy.luannocracy.com> Message-ID: <47A76128.2000205@probo.com> David Abrahams wrote: > I have a couple of type libraries that I've run makepy on. > > The first can be loaded with > > s = win32com.client.Dispatch('nameof.Lib1') > > I have verified that the above gets the ILib1Session object, which > the documentation for that library says is the entry point for > everything. > > The documentation then states I'm to call the GetProvider method to get > an instance of ILib2Provider, which, naturally, is defined in Lib2. The > GetProvider method is declared thus: > > HRESULT GetProvider ( > ILib2Provider **ppProvider) > > When I do > > s.GetProvider() > > in Python, I get a PyIUnknown object. No QueryInterface call I have > been able to manufacture will get me an ILib2Provider object. > Actually, you DO have an ILib2Provider object, wrapped in Python by PyIUnknown. You should be able to call the methods and properties of ILib2Provider using that object. Python doesn't know it's an ILib2Provider, because that's just a name used in the C++ source code, but the methods and properties should all be there. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From dave at boost-consulting.com Mon Feb 4 20:44:47 2008 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 04 Feb 2008 14:44:47 -0500 Subject: [python-win32] Can win32com handle this one? References: <8763x438i5.fsf@gutsy.luannocracy.com> <47A76128.2000205@probo.com> Message-ID: <87tzkoa4ls.fsf@gutsy.luannocracy.com> on Mon Feb 04 2008, Tim Roberts wrote: > David Abrahams wrote: >> I have a couple of type libraries that I've run makepy on. >> >> The first can be loaded with >> >> s = win32com.client.Dispatch('nameof.Lib1') >> >> I have verified that the above gets the ILib1Session object, which >> the documentation for that library says is the entry point for >> everything. >> >> The documentation then states I'm to call the GetProvider method to get >> an instance of ILib2Provider, which, naturally, is defined in Lib2. The >> GetProvider method is declared thus: >> >> HRESULT GetProvider ( >> ILib2Provider **ppProvider) >> >> When I do >> >> s.GetProvider() >> >> in Python, I get a PyIUnknown object. No QueryInterface call I have >> been able to manufacture will get me an ILib2Provider object. >> > > Actually, you DO have an ILib2Provider object, wrapped in Python by > PyIUnknown. Well, I SHOULD have such an object, I know. The question is, of course, how to retrieve it. > You should be able to call the methods and properties of > ILib2Provider using that object. > > Python doesn't know it's an ILib2Provider, because that's just a name > used in the C++ source code, but the methods and properties should all > be there. They don't seem to be. p.GetVersion() gets me a traceback with an AttributeError. Any further ideas? Even if we can make that work, it seems to me there oughta be a way to get a Python ILib2Provider from this object, no? -- Dave Abrahams Boost Consulting http://boost-consulting.com From cappy2112 at gmail.com Mon Feb 4 21:21:25 2008 From: cappy2112 at gmail.com (Tony Cappellini) Date: Mon, 4 Feb 2008 12:21:25 -0800 Subject: [python-win32] Executing eval function in VBscript Message-ID: <8249c4ac0802041221x72684619of965d6dd3e7fef81@mail.gmail.com> Date: Mon, 04 Feb 2008 10:05:11 -0500 From: bob gailer Subject: Re: [python-win32] Executing eval function in VBscript To: Janakiraman Mohanakrishnan Cc: python-win32 at python.org Message-ID: <47A729A7.5030709 at alum.rpi.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed >>That's hard to answer until we know what you want to accomplish! Tell us >>more. What problem are you trying to solve? I think he wants to have python functionality from excel, which is what I'd like to accomplish as well. (Python embedded into excel, as opposed to launching Excel from Python) >>Also I'm not very familiar with MSScriptControl. I googled it and found >>no useful documentation. Do you have any references to it? Everything you want to know about the MSScriptControl is on microsoft's site. From glenn.graessle at honeywell.com Mon Feb 4 23:01:14 2008 From: glenn.graessle at honeywell.com (Graessle, Glenn (FC COE)) Date: Mon, 4 Feb 2008 15:01:14 -0700 Subject: [python-win32] Word FormField types Message-ID: <782F51FEE95A4848BD87BD3E75DAD0F90680EE@AZ18EV801.global.ds.honeywell.com> Is there an import file that defines the FormField types symbolically? For example, Word Checkbox has the value of 71 for it's type. Glenn Graessle Flight Controls CoE Honeywell International, Inc. 23500 West 105th Street (M/D 42) Olathe, KS 66061 913-712-2645(phone/fax) 913-832-2345 (mobile) glenn.graessle at honeywell.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080204/37a4a86d/attachment.htm From mhammond at skippinet.com.au Mon Feb 4 23:44:39 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 5 Feb 2008 09:44:39 +1100 Subject: [python-win32] How to create a com_record? In-Reply-To: References: <091c01c86494$28e28390$7aa78ab0$@com.au> <0a0a01c86619$2feff650$8fcfe2f0$@com.au> <0a5201c866b5$88447280$98cd5780$@com.au> <0a8d01c866de$b3b97db0$1b2c7910$@com.au> Message-ID: <009001c8677f$8931d0f0$9b9572d0$@com.au> > guid = win32com.client.Record("GUID", some_ob) > I don't have the some_obj that allows me to build "GUID". It should be any object from the same typelib - almost certainly whatever object you intend passing this record to. > VB.NET (GetType) and C++ (__uuid) both already know that a GUID is a record. C++ doesn't know it is a COM record. A COM record is something quite different to a C/C++ struct or from .NET types. A COM record is specifically designed to be cross-language. > It seems the python CLSID is the same thing, but i don't know what to call > to get a CLSID that is a com_record type. As I've explained, we are looking for the COM record definition you are trying to use. A C++ struct definition for a GUID is *not* what you are looking for - you are looking for the COM record definition of a GUID. I see now that you simply copied me a C++ struct you found, which is not at all useful in this context. To clarify: in a *typelib* you will find a struct definition that you are trying to use. Finding a struct definition of the same name somewhere else is not suitable. > Am I understanding the win32com.client.Record call correctly? It needs GUID to be defined by the > COM right? Not "defined by COM", but "defined using COM" - the author of a typelib must have defined it somewhere. > Its odd b/c the GIUD (python's CLSID) is all over the COM definitions its just type > VT_RECORD type that I'm not understanding how to convert to. Yes, I'm afraid you are confused. All existing GUID or CLSID definitions you can find are useless - there is only 1 that is relevant, and that will be defined in a typelib. I think the confusion is such that you need to find basic docs for the object, so we can get back to square 1. Mark From mhammond at skippinet.com.au Mon Feb 4 23:47:00 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 5 Feb 2008 09:47:00 +1100 Subject: [python-win32] Can win32com handle this one? In-Reply-To: <8763x438i5.fsf@gutsy.luannocracy.com> References: <8763x438i5.fsf@gutsy.luannocracy.com> Message-ID: <009101c8677f$de6be6a0$9b43b3e0$@com.au> > I have a couple of type libraries that I've run makepy on. > > The first can be loaded with > > s = win32com.client.Dispatch('nameof.Lib1') > > I have verified that the above gets the ILib1Session object, which > the documentation for that library says is the entry point for > everything. > > The documentation then states I'm to call the GetProvider method to get > an instance of ILib2Provider, which, naturally, is defined in Lib2. > The > GetProvider method is declared thus: > > HRESULT GetProvider ( > ILib2Provider **ppProvider) > > When I do Unfortunately, win32com doesn't support arbitrary interfaces. If the object you are using doesn't support IDispatch, then you can't use it from win32com. You may like to try something like: ob = win32com.client.Dispatch(s.GetProvider()) to see if it does support IDispatch, in which case you could then start calling methods etc on it. Mark From maria.reinhammar at swisslog-accalon.com Mon Feb 4 13:08:46 2008 From: maria.reinhammar at swisslog-accalon.com (Reinhammar Maria) Date: Mon, 4 Feb 2008 13:08:46 +0100 Subject: [python-win32] makepy exception Message-ID: Hi again, An answer of sorts.. The original problem disappeared when I took some care about *the order* of generation of several .tlb's What I did not reveal in my original post was that I have *many* tlb's associated with SmarTeam. The following snippet shows a successful makepy on the former problem tlb. SmarTeam.Std.SessionManagement.Authentication.Modules.tlb (seem to) depend on SmarTeam.Std.SessionManagement.tlb By simply making sure that they are makepy'ed in the correct order, the problem went away :o) BEGIN sbippet D:\Python25\Lib\site-packages\win32com\client>"D:\Python25\python.exe" makepy.py SmarTeam.Std.SessionManagement.tlb Generating to D:\Python25\lib\site-packages\win32com\gen_py\141DB3A2-8C51-4F07-802B-CD E9BA18B8C4x0x5x18.py Building definitions from type library... Generating... Importing module D:\Python25\Lib\site-packages\win32com\client>"D:\Python25\python.exe" makepy.py SmarTeam.Std.SessionManagement.Authentication.Modules.tlb Generating to D:\Python25\lib\site-packages\win32com\gen_py\69661005-524C-44A4-B1B8-9E 4B3C6940C3x0x5x18.py Building definitions from type library... Generating... Importing module END snippet Regards// Maria Reinhammar Software Engineer Swisslog-Accalon AB ************************************************************************ ************************ CONFIDENTIALITY AND DISCLAIMER This e-mail and its attachments are intended for the above named addressee(s) only and may be confidential. If the mail has come to you in error please reply to this e-mail and highlight the error. In addition, we kindly ask you to destroy the Mail. Please be aware that we disclaim all liability for the integrity or for the accuracy of this Mail, as transmissions via Internet are not error free communications medium. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080204/509197c2/attachment-0001.htm From tojo2000 at gmail.com Tue Feb 5 00:22:50 2008 From: tojo2000 at gmail.com (Tim Johnson) Date: Mon, 4 Feb 2008 15:22:50 -0800 Subject: [python-win32] Reading .py or .pyc from an excel sheet In-Reply-To: <47A6D918.2000206@timgolden.me.uk> References: <47A6D918.2000206@timgolden.me.uk> Message-ID: <5394762f0802041522i4c3b28d3m55e94a950b0c58df@mail.gmail.com> My machine doesn't seem to recognize Python.Interpreter. Is there some prerequisite that I could be missing? On Feb 4, 2008 1:21 AM, Tim Golden wrote: > Pallavi Apotikar wrote: > > I am sorry, instead of "file", I should have said "a python function". > > > > Is it possible to access/use a python function from Excel VB Editor e.g. > a > > library function called "eval()" is used to detect whether the > > expression/datatype is a valid python expression/datatype ? Can we do > > that? > > Well as far as I can see, there's nothing to stop you instantiating > a Python interpreter via COM from Excel (class name is > "Python.Interpreter") and then use .Eval or .Exec to do things. > I'm not sure just how much this will buy you, but it should at > least be possible. > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- _____________________ Ceci n'est pas un email. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080204/4f53c9b6/attachment.htm From timr at probo.com Tue Feb 5 01:01:10 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 04 Feb 2008 16:01:10 -0800 Subject: [python-win32] Reading .py or .pyc from an excel sheet In-Reply-To: <5394762f0802041522i4c3b28d3m55e94a950b0c58df@mail.gmail.com> References: <47A6D918.2000206@timgolden.me.uk> <5394762f0802041522i4c3b28d3m55e94a950b0c58df@mail.gmail.com> Message-ID: <47A7A746.1090501@probo.com> Tim Johnson wrote: > My machine doesn't seem to recognize Python.Interpreter. Is there > some prerequisite that I could be missing? What did you try? I just went into the Excel VBA editor and created a function with this: Dim x As Object Set x = CreateObject("Python.Interpreter") It seemed to work OK, although I didn't actually try to use the object.. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From tojo2000 at gmail.com Tue Feb 5 01:10:17 2008 From: tojo2000 at gmail.com (Tim Johnson) Date: Mon, 4 Feb 2008 16:10:17 -0800 Subject: [python-win32] Reading .py or .pyc from an excel sheet In-Reply-To: <47A7A746.1090501@probo.com> References: <47A6D918.2000206@timgolden.me.uk> <5394762f0802041522i4c3b28d3m55e94a950b0c58df@mail.gmail.com> <47A7A746.1090501@probo.com> Message-ID: <5394762f0802041610v379ffcdnc721aa6a509661a@mail.gmail.com> I started out just trying it via vbscript, but when I use the code you provided I get Run-time error '429': ActiveX component can't create object. I'm guessing there's a .dll or something not registered somewhere. I'll do some more digging. On Feb 4, 2008 4:01 PM, Tim Roberts wrote: > Tim Johnson wrote: > > My machine doesn't seem to recognize Python.Interpreter. Is there > > some prerequisite that I could be missing? > > What did you try? I just went into the Excel VBA editor and created a > function with this: > Dim x As Object > Set x = CreateObject("Python.Interpreter") > > It seemed to work OK, although I didn't actually try to use the object.. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- _____________________ Ceci n'est pas un email. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080204/06c72dcf/attachment.htm From timr at probo.com Tue Feb 5 01:17:54 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 04 Feb 2008 16:17:54 -0800 Subject: [python-win32] Reading .py or .pyc from an excel sheet In-Reply-To: <5394762f0802041610v379ffcdnc721aa6a509661a@mail.gmail.com> References: <47A6D918.2000206@timgolden.me.uk> <5394762f0802041522i4c3b28d3m55e94a950b0c58df@mail.gmail.com> <47A7A746.1090501@probo.com> <5394762f0802041610v379ffcdnc721aa6a509661a@mail.gmail.com> Message-ID: <47A7AB32.7050104@probo.com> Tim Johnson wrote: > I started out just trying it via vbscript, but when I use the code you > provided I get > > Run-time error '429': > > ActiveX component can't create object. > > I'm guessing there's a .dll or something not registered somewhere. > I'll do some more digging. If you will forgive a stupid question, do you actually have Python and PyWin32 installed on this machine? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Tue Feb 5 01:18:36 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 5 Feb 2008 11:18:36 +1100 Subject: [python-win32] Reading .py or .pyc from an excel sheet In-Reply-To: <5394762f0802041522i4c3b28d3m55e94a950b0c58df@mail.gmail.com> References: <47A6D918.2000206@timgolden.me.uk> <5394762f0802041522i4c3b28d3m55e94a950b0c58df@mail.gmail.com> Message-ID: <009e01c8678c$aaa7b8a0$fff729e0$@com.au> It might be necessary to execute win32com\servers\interp.py to register the object (which inturn might not work if you installed Python without admin privs or selected "just for me") Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Johnson Sent: Tuesday, 5 February 2008 10:23 AM To: Tim Golden Cc: python-win32 at python.org Subject: Re: [python-win32] Reading .py or .pyc from an excel sheet My machine doesn't seem to recognize Python.Interpreter. Is there some prerequisite that I could be missing? On Feb 4, 2008 1:21 AM, Tim Golden wrote: Pallavi Apotikar wrote: > I am sorry, instead of "file", I should have said "a python function". > > Is it possible to access/use a python function from Excel VB Editor e.g. a > library function called "eval()" is used to detect whether the > expression/datatype is a valid python expression/datatype ? Can we do > that? Well as far as I can see, there's nothing to stop you instantiating a Python interpreter via COM from Excel (class name is "Python.Interpreter") and then use .Eval or .Exec to do things. I'm not sure just how much this will buy you, but it should at least be possible. TJG _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -- _____________________ Ceci n'est pas un email. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080205/ea9bc053/attachment.htm From tojo2000 at gmail.com Tue Feb 5 01:22:46 2008 From: tojo2000 at gmail.com (Tim Johnson) Date: Mon, 4 Feb 2008 16:22:46 -0800 Subject: [python-win32] Reading .py or .pyc from an excel sheet In-Reply-To: <009e01c8678c$aaa7b8a0$fff729e0$@com.au> References: <47A6D918.2000206@timgolden.me.uk> <5394762f0802041522i4c3b28d3m55e94a950b0c58df@mail.gmail.com> <009e01c8678c$aaa7b8a0$fff729e0$@com.au> Message-ID: <5394762f0802041622v2102d306w22a6f576beff772b@mail.gmail.com> That was it. I'm using ActivePython 32-bit, but I just remembered that this is a 64-bit machine, so maybe that's why it wasn't set up, or is that something you usually have to do manually? On Feb 4, 2008 4:18 PM, Mark Hammond wrote: > It might be necessary to execute win32com\servers\interp.py to register > the object (which inturn might not work if you installed Python without > admin privs or selected "just for me") > > > > Mark > > > > *From:* python-win32-bounces at python.org [mailto: > python-win32-bounces at python.org] *On Behalf Of *Tim Johnson > *Sent:* Tuesday, 5 February 2008 10:23 AM > *To:* Tim Golden > *Cc:* python-win32 at python.org > *Subject:* Re: [python-win32] Reading .py or .pyc from an excel sheet > > > > My machine doesn't seem to recognize Python.Interpreter. Is there some > prerequisite that I could be missing? > > On Feb 4, 2008 1:21 AM, Tim Golden wrote: > > Pallavi Apotikar wrote: > > I am sorry, instead of "file", I should have said "a python function". > > > > Is it possible to access/use a python function from Excel VB Editor e.g. > a > > library function called "eval()" is used to detect whether the > > expression/datatype is a valid python expression/datatype ? Can we do > > that? > > Well as far as I can see, there's nothing to stop you instantiating > a Python interpreter via COM from Excel (class name is > "Python.Interpreter") and then use .Eval or .Exec to do things. > I'm not sure just how much this will buy you, but it should at > least be possible. > > TJG > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > > > -- > _____________________ > Ceci n'est pas un email. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- _____________________ Ceci n'est pas un email. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080204/81feef3a/attachment-0001.htm From dave at boost-consulting.com Tue Feb 5 02:38:07 2008 From: dave at boost-consulting.com (David Abrahams) Date: Mon, 04 Feb 2008 20:38:07 -0500 Subject: [python-win32] Can win32com handle this one? References: <8763x438i5.fsf@gutsy.luannocracy.com> <009101c8677f$de6be6a0$9b43b3e0$@com.au> Message-ID: <87wspk6v40.fsf@gutsy.luannocracy.com> on Mon Feb 04 2008, "Mark Hammond" wrote: >> I have a couple of type libraries that I've run makepy on. >> >> The first can be loaded with >> >> s = win32com.client.Dispatch('nameof.Lib1') >> >> I have verified that the above gets the ILib1Session object, which >> the documentation for that library says is the entry point for >> everything. >> >> The documentation then states I'm to call the GetProvider method to get >> an instance of ILib2Provider, which, naturally, is defined in Lib2. >> The >> GetProvider method is declared thus: >> >> HRESULT GetProvider ( >> ILib2Provider **ppProvider) >> >> When I do > > Unfortunately, win32com doesn't support arbitrary interfaces. If the object > you are using doesn't support IDispatch, then you can't use it from > win32com. You may like to try something like: > > ob = win32com.client.Dispatch(s.GetProvider()) > > to see if it does support IDispatch, Hmm, thanks, I guess it doesn't: 'PyIUnknown' object has no attribute 'GetTypeInfo' > in which case you could then start calling methods etc on it. So I guess I need to resort to wrapping the C++ API into an extension module. -- Dave Abrahams Boost Consulting http://boost-consulting.com From mhammond at skippinet.com.au Tue Feb 5 02:44:26 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 5 Feb 2008 12:44:26 +1100 Subject: [python-win32] Reading .py or .pyc from an excel sheet In-Reply-To: <5394762f0802041622v2102d306w22a6f576beff772b@mail.gmail.com> References: <47A6D918.2000206@timgolden.me.uk> <5394762f0802041522i4c3b28d3m55e94a950b0c58df@mail.gmail.com> <009e01c8678c$aaa7b8a0$fff729e0$@com.au> <5394762f0802041622v2102d306w22a6f576beff772b@mail.gmail.com> Message-ID: <00be01c86798$a6dcfe90$f496fbb0$@com.au> I suspect it is simply because ActivePython doesn't register these objects (and my be why python isn't also working with the script host for some users). The pywin32 distribution registers these objects automatically. Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Johnson Sent: Tuesday, 5 February 2008 11:23 AM To: Mark Hammond Cc: python-win32 at python.org Subject: Re: [python-win32] Reading .py or .pyc from an excel sheet That was it. I'm using ActivePython 32-bit, but I just remembered that this is a 64-bit machine, so maybe that's why it wasn't set up, or is that something you usually have to do manually? On Feb 4, 2008 4:18 PM, Mark Hammond wrote: It might be necessary to execute win32com\servers\interp.py to register the object (which inturn might not work if you installed Python without admin privs or selected "just for me") Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Johnson Sent: Tuesday, 5 February 2008 10:23 AM To: Tim Golden Cc: python-win32 at python.org Subject: Re: [python-win32] Reading .py or .pyc from an excel sheet My machine doesn't seem to recognize Python.Interpreter. Is there some prerequisite that I could be missing? On Feb 4, 2008 1:21 AM, Tim Golden wrote: Pallavi Apotikar wrote: > I am sorry, instead of "file", I should have said "a python function". > > Is it possible to access/use a python function from Excel VB Editor e.g. a > library function called "eval()" is used to detect whether the > expression/datatype is a valid python expression/datatype ? Can we do > that? Well as far as I can see, there's nothing to stop you instantiating a Python interpreter via COM from Excel (class name is "Python.Interpreter") and then use .Eval or .Exec to do things. I'm not sure just how much this will buy you, but it should at least be possible. TJG _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -- _____________________ Ceci n'est pas un email. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -- _____________________ Ceci n'est pas un email. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080205/9657ef86/attachment.htm From mhammond at skippinet.com.au Tue Feb 5 02:46:05 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 5 Feb 2008 12:46:05 +1100 Subject: [python-win32] Can win32com handle this one? In-Reply-To: <87wspk6v40.fsf@gutsy.luannocracy.com> References: <8763x438i5.fsf@gutsy.luannocracy.com> <009101c8677f$de6be6a0$9b43b3e0$@com.au> <87wspk6v40.fsf@gutsy.luannocracy.com> Message-ID: <00c301c86798$e25ec250$a71c46f0$@com.au> > > > > ob = win32com.client.Dispatch(s.GetProvider()) > > > > to see if it does support IDispatch, > > Hmm, thanks, I guess it doesn't: > > 'PyIUnknown' object has no attribute 'GetTypeInfo' > > > in which case you could then start calling methods etc on it. Oops - it looks like I should have written: ob = win32com.client.Dispatch(s.GetProvider().QueryInterface(pythoncom.IID_IDispa tch)) > > So I guess I need to resort to wrapping the C++ API into an extension > module. Or look at 'comtypes', which may end up being less work than an extension module. Cheers, Mark From tojo2000 at gmail.com Tue Feb 5 03:07:14 2008 From: tojo2000 at gmail.com (Tim Johnson) Date: Mon, 4 Feb 2008 18:07:14 -0800 Subject: [python-win32] Reading .py or .pyc from an excel sheet In-Reply-To: <00be01c86798$a6dcfe90$f496fbb0$@com.au> References: <47A6D918.2000206@timgolden.me.uk> <5394762f0802041522i4c3b28d3m55e94a950b0c58df@mail.gmail.com> <009e01c8678c$aaa7b8a0$fff729e0$@com.au> <5394762f0802041622v2102d306w22a6f576beff772b@mail.gmail.com> <00be01c86798$a6dcfe90$f496fbb0$@com.au> Message-ID: <5394762f0802041807w29067c33k8427fec41a95e611@mail.gmail.com> I'll go ahead and file a bug with ActiveState and see what they say. On Feb 4, 2008 5:44 PM, Mark Hammond wrote: > I suspect it is simply because ActivePython doesn't register these > objects (and my be why python isn't also working with the script host for > some users). The pywin32 distribution registers these objects > automatically. > > > > Mark > > > > *From:* python-win32-bounces at python.org [mailto: > python-win32-bounces at python.org] *On Behalf Of *Tim Johnson > *Sent:* Tuesday, 5 February 2008 11:23 AM > *To:* Mark Hammond > > *Cc:* python-win32 at python.org > *Subject:* Re: [python-win32] Reading .py or .pyc from an excel sheet > > > > That was it. I'm using ActivePython 32-bit, but I just remembered that > this is a 64-bit machine, so maybe that's why it wasn't set up, or is that > something you usually have to do manually? > > On Feb 4, 2008 4:18 PM, Mark Hammond wrote: > > It might be necessary to execute win32com\servers\interp.py to register > the object (which inturn might not work if you installed Python without > admin privs or selected "just for me") > > > > Mark > > > > *From:* python-win32-bounces at python.org [mailto: > python-win32-bounces at python.org] *On Behalf Of *Tim Johnson > *Sent:* Tuesday, 5 February 2008 10:23 AM > *To:* Tim Golden > *Cc:* python-win32 at python.org > > > *Subject:* Re: [python-win32] Reading .py or .pyc from an excel sheet > > > > My machine doesn't seem to recognize Python.Interpreter. Is there some > prerequisite that I could be missing? > > On Feb 4, 2008 1:21 AM, Tim Golden wrote: > > Pallavi Apotikar wrote: > > I am sorry, instead of "file", I should have said "a python function". > > > > Is it possible to access/use a python function from Excel VB Editor e.g. > a > > library function called "eval()" is used to detect whether the > > expression/datatype is a valid python expression/datatype ? Can we do > > that? > > Well as far as I can see, there's nothing to stop you instantiating > a Python interpreter via COM from Excel (class name is > "Python.Interpreter") and then use .Eval or .Exec to do things. > I'm not sure just how much this will buy you, but it should at > least be possible. > > TJG > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > > > -- > _____________________ > Ceci n'est pas un email. > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > > > -- > _____________________ > Ceci n'est pas un email. > -- _____________________ Ceci n'est pas un email. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080204/4c502afb/attachment.htm From tojo2000 at gmail.com Tue Feb 5 03:22:14 2008 From: tojo2000 at gmail.com (Tim Johnson) Date: Mon, 4 Feb 2008 18:22:14 -0800 Subject: [python-win32] Reading .py or .pyc from an excel sheet In-Reply-To: <5394762f0802041807w29067c33k8427fec41a95e611@mail.gmail.com> References: <47A6D918.2000206@timgolden.me.uk> <5394762f0802041522i4c3b28d3m55e94a950b0c58df@mail.gmail.com> <009e01c8678c$aaa7b8a0$fff729e0$@com.au> <5394762f0802041622v2102d306w22a6f576beff772b@mail.gmail.com> <00be01c86798$a6dcfe90$f496fbb0$@com.au> <5394762f0802041807w29067c33k8427fec41a95e611@mail.gmail.com> Message-ID: <5394762f0802041822m18c3603dw114443dbf4e441a3@mail.gmail.com> There were several bugs there that could possibly have been related, but I submitted it as bug 74669 . On Feb 4, 2008 6:07 PM, Tim Johnson wrote: > I'll go ahead and file a bug with ActiveState and see what they say. > > > On Feb 4, 2008 5:44 PM, Mark Hammond wrote: > > > I suspect it is simply because ActivePython doesn't register these > > objects (and my be why python isn't also working with the script host for > > some users). The pywin32 distribution registers these objects > > automatically. > > > > > > > > Mark > > > > > > > > *From:* python-win32-bounces at python.org [mailto: > > python-win32-bounces at python.org] *On Behalf Of *Tim Johnson > > *Sent:* Tuesday, 5 February 2008 11:23 AM > > *To:* Mark Hammond > > > > *Cc:* python-win32 at python.org > > *Subject:* Re: [python-win32] Reading .py or .pyc from an excel sheet > > > > > > > > That was it. I'm using ActivePython 32-bit, but I just remembered that > > this is a 64-bit machine, so maybe that's why it wasn't set up, or is that > > something you usually have to do manually? > > > > On Feb 4, 2008 4:18 PM, Mark Hammond wrote: > > > > It might be necessary to execute win32com\servers\interp.py to register > > the object (which inturn might not work if you installed Python without > > admin privs or selected "just for me") > > > > > > > > Mark > > > > > > > > *From:* python-win32-bounces at python.org [mailto: > > python-win32-bounces at python.org] *On Behalf Of *Tim Johnson > > *Sent:* Tuesday, 5 February 2008 10:23 AM > > *To:* Tim Golden > > *Cc:* python-win32 at python.org > > > > > > *Subject:* Re: [python-win32] Reading .py or .pyc from an excel sheet > > > > > > > > My machine doesn't seem to recognize Python.Interpreter. Is there some > > prerequisite that I could be missing? > > > > On Feb 4, 2008 1:21 AM, Tim Golden wrote: > > > > Pallavi Apotikar wrote: > > > I am sorry, instead of "file", I should have said "a python function". > > > > > > Is it possible to access/use a python function from Excel VB Editor > > e.g. a > > > library function called "eval()" is used to detect whether the > > > expression/datatype is a valid python expression/datatype ? Can we do > > > that? > > > > Well as far as I can see, there's nothing to stop you instantiating > > a Python interpreter via COM from Excel (class name is > > "Python.Interpreter") and then use .Eval or .Exec to do things. > > I'm not sure just how much this will buy you, but it should at > > least be possible. > > > > TJG > > > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > > > > > -- > > _____________________ > > Ceci n'est pas un email. > > > > > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > > > > > -- > > _____________________ > > Ceci n'est pas un email. > > > > > > -- > _____________________ > Ceci n'est pas un email. > -- _____________________ Ceci n'est pas un email. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080204/9b19dd74/attachment-0001.htm From bgailer at alum.rpi.edu Tue Feb 5 03:30:12 2008 From: bgailer at alum.rpi.edu (bob gailer) Date: Mon, 04 Feb 2008 21:30:12 -0500 Subject: [python-win32] Executing eval function in VBscript In-Reply-To: <8249c4ac0802041221x72684619of965d6dd3e7fef81@mail.gmail.com> References: <8249c4ac0802041221x72684619of965d6dd3e7fef81@mail.gmail.com> Message-ID: <47A7CA34.30307@alum.rpi.edu> Tony Cappellini wrote: > Date: Mon, 04 Feb 2008 10:05:11 -0500 > From: bob gailer > Subject: Re: [python-win32] Executing eval function in VBscript > To: Janakiraman Mohanakrishnan > Cc: python-win32 at python.org > Message-ID: <47A729A7.5030709 at alum.rpi.edu> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > >>> That's hard to answer until we know what you want to accomplish! Tell us >>> more. What problem are you trying to solve? >>> > > I think he wants to have python functionality from excel, which is > what I'd like to accomplish as well. > (Python embedded into excel, as opposed to launching Excel from Python) > > > > >>> Also I'm not very familiar with MSScriptControl. I googled it and found >>> no useful documentation. Do you have any references to it? >>> > Everything you want to know about the MSScriptControl is on microsoft's site. > I'm glad it is there. I certainly can't find it. I have searched microsoft.com and msdn.microsoft.com with no success. All I find are forum discussions; no reference. I guess your mileage is better. Can you offer any useful links? Bob Gailer 919-636-4239 Chapel Hill, NC From cappy2112 at gmail.com Tue Feb 5 03:41:12 2008 From: cappy2112 at gmail.com (Tony Cappellini) Date: Mon, 4 Feb 2008 18:41:12 -0800 Subject: [python-win32] Executing eval function in VBscript In-Reply-To: <47A7CA34.30307@alum.rpi.edu> References: <8249c4ac0802041221x72684619of965d6dd3e7fef81@mail.gmail.com> <47A7CA34.30307@alum.rpi.edu> Message-ID: <8249c4ac0802041841i131731f9q47d5da0a70c997ec@mail.gmail.com> I may have a type in my previous posts. I have only used it with VB6 (not .NET) http://msdn2.microsoft.com/en-us/library/aa227400.aspx On Feb 4, 2008 6:30 PM, bob gailer wrote: > > Tony Cappellini wrote: > > Date: Mon, 04 Feb 2008 10:05:11 -0500 > > From: bob gailer > > Subject: Re: [python-win32] Executing eval function in VBscript > > To: Janakiraman Mohanakrishnan > > Cc: python-win32 at python.org > > Message-ID: <47A729A7.5030709 at alum.rpi.edu> > > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > > > > >>> That's hard to answer until we know what you want to accomplish! Tell us > >>> more. What problem are you trying to solve? > >>> > > > > I think he wants to have python functionality from excel, which is > > what I'd like to accomplish as well. > > (Python embedded into excel, as opposed to launching Excel from Python) > > > > > > > > > >>> Also I'm not very familiar with MSScriptControl. I googled it and found > >>> no useful documentation. Do you have any references to it? > >>> > > Everything you want to know about the MSScriptControl is on microsoft's site. > > > I'm glad it is there. I certainly can't find it. I have searched > microsoft.com and msdn.microsoft.com with no success. All I find are > forum discussions; no reference. I guess your mileage is better. Can you > offer any useful links? > > Bob Gailer > 919-636-4239 Chapel Hill, NC > > From cappy2112 at gmail.com Tue Feb 5 03:42:05 2008 From: cappy2112 at gmail.com (Tony Cappellini) Date: Mon, 4 Feb 2008 18:42:05 -0800 Subject: [python-win32] Executing eval function in VBscript In-Reply-To: <47A7CA34.30307@alum.rpi.edu> References: <8249c4ac0802041221x72684619of965d6dd3e7fef81@mail.gmail.com> <47A7CA34.30307@alum.rpi.edu> Message-ID: <8249c4ac0802041842s4ec066ay511e257bbb05bc8f@mail.gmail.com> http://msdn2.microsoft.com/en-us/library/aa227633(VS.60).aspx On Feb 4, 2008 6:30 PM, bob gailer wrote: > > Tony Cappellini wrote: > > Date: Mon, 04 Feb 2008 10:05:11 -0500 > > From: bob gailer > > Subject: Re: [python-win32] Executing eval function in VBscript > > To: Janakiraman Mohanakrishnan > > Cc: python-win32 at python.org > > Message-ID: <47A729A7.5030709 at alum.rpi.edu> > > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > > > > >>> That's hard to answer until we know what you want to accomplish! Tell us > >>> more. What problem are you trying to solve? > >>> > > > > I think he wants to have python functionality from excel, which is > > what I'd like to accomplish as well. > > (Python embedded into excel, as opposed to launching Excel from Python) > > > > > > > > > >>> Also I'm not very familiar with MSScriptControl. I googled it and found > >>> no useful documentation. Do you have any references to it? > >>> > > Everything you want to know about the MSScriptControl is on microsoft's site. > > > I'm glad it is there. I certainly can't find it. I have searched > microsoft.com and msdn.microsoft.com with no success. All I find are > forum discussions; no reference. I guess your mileage is better. Can you > offer any useful links? > > Bob Gailer > 919-636-4239 Chapel Hill, NC > > From janakiraman.mohanakrishnan at tcs.com Tue Feb 5 06:48:29 2008 From: janakiraman.mohanakrishnan at tcs.com (Janakiraman Mohanakrishnan) Date: Tue, 5 Feb 2008 11:18:29 +0530 Subject: [python-win32] Executing eval function in VBscript In-Reply-To: <8249c4ac0802041221x72684619of965d6dd3e7fef81@mail.gmail.com> Message-ID: yes i want to have python functionality in excel, iam trying to call python functions from VBscript, more like evaluating a python expression say dictionary or list in VBscript For evaluating a python expression , python has some library functions like eval which takes python expressions in string format and checks whether it is a valid python expression or not so i thought of calling that python eval function in VBscript and validate my datas but the problem is when i tried to pass dictionaries for eg, "{'key':value}" this is the format of dictionary in python VBscript throws error like type mismatch since VB dictionary representation of VB and python are different Thanks and Regards! "Tony Cappellini" 02/05/2008 01:51 AM Please respond to cappy2112 at gmail.com To python-win32 at python.org cc bgailer at alum.rpi.edu, janakiraman.mohanakrishnan at tcs.com Subject [python-win32] Executing eval function in VBscript Date: Mon, 04 Feb 2008 10:05:11 -0500 From: bob gailer Subject: Re: [python-win32] Executing eval function in VBscript To: Janakiraman Mohanakrishnan Cc: python-win32 at python.org Message-ID: <47A729A7.5030709 at alum.rpi.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed >>That's hard to answer until we know what you want to accomplish! Tell us >>more. What problem are you trying to solve? I think he wants to have python functionality from excel, which is what I'd like to accomplish as well. (Python embedded into excel, as opposed to launching Excel from Python) >>Also I'm not very familiar with MSScriptControl. I googled it and found >>no useful documentation. Do you have any references to it? Everything you want to know about the MSScriptControl is on microsoft's site. ForwardSourceID:NT0000976E =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080205/b906b931/attachment.htm From mhammond at skippinet.com.au Tue Feb 5 07:18:22 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 5 Feb 2008 17:18:22 +1100 Subject: [python-win32] Executing eval function in VBscript In-Reply-To: References: <8249c4ac0802041221x72684619of965d6dd3e7fef81@mail.gmail.com> Message-ID: <00f701c867be$f0b48a30$d21d9e90$@com.au> You probably want to take a copy of interp.py and modify it so that when a dictionary is returned, you return something like the Python.Dictionary object (see win32com\servers\dictionary.py). You can create such an object via something like: >>> from win32com.servers.dictionary import DictionaryPolicy >>> from win32com.server.util import wrap >>> ob = wrap({"foo":"bar"}, usePolicy=DictionaryPolicy) >>> ob If interp.py returned 'ob', VB should be able to access it somewhat like a regular VB collection - so instead of simply: return eval(str(exp), self.dict) you checked the result, and if it's a dict, execute the lines above and return 'ob' instead of the dict (and obviously using a real dict instead of the constant one in the example above) Hope this helps (and works ;) Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Janakiraman Mohanakrishnan Sent: Tuesday, 5 February 2008 4:48 PM To: cappy2112 at gmail.com Cc: bgailer at alum.rpi.edu; python-win32 at python.org Subject: Re: [python-win32] Executing eval function in VBscript yes i want to have python functionality in excel, iam trying to call python functions from VBscript, more like evaluating a python expression say dictionary or list in VBscript For evaluating a python expression , python has some library functions like eval which takes python expressions in string format and checks whether it is a valid python expression or not so i thought of calling that python eval function in VBscript and validate my datas but the problem is when i tried to pass dictionaries for eg, "{'key':value}" this is the format of dictionary in python VBscript throws error like type mismatch since VB dictionary representation of VB and python are different Thanks and Regards! "Tony Cappellini" 02/05/2008 01:51 AM Please respond to cappy2112 at gmail.com To python-win32 at python.org cc bgailer at alum.rpi.edu, janakiraman.mohanakrishnan at tcs.com Subject [python-win32] Executing eval function in VBscript Date: Mon, 04 Feb 2008 10:05:11 -0500 From: bob gailer Subject: Re: [python-win32] Executing eval function in VBscript To: Janakiraman Mohanakrishnan Cc: python-win32 at python.org Message-ID: <47A729A7.5030709 at alum.rpi.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed >>That's hard to answer until we know what you want to accomplish! Tell us >>more. What problem are you trying to solve? I think he wants to have python functionality from excel, which is what I'd like to accomplish as well. (Python embedded into excel, as opposed to launching Excel from Python) >>Also I'm not very familiar with MSScriptControl. I googled it and found >>no useful documentation. Do you have any references to it? Everything you want to know about the MSScriptControl is on microsoft's site. ForwardSourceID:NT0000976E =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080205/f2063acb/attachment-0001.htm From graemeglass at gmail.com Tue Feb 5 08:14:11 2008 From: graemeglass at gmail.com (Graeme Glass) Date: Tue, 5 Feb 2008 09:14:11 +0200 Subject: [python-win32] Word FormField types In-Reply-To: <782F51FEE95A4848BD87BD3E75DAD0F90680EE@AZ18EV801.global.ds.honeywell.com> References: <782F51FEE95A4848BD87BD3E75DAD0F90680EE@AZ18EV801.global.ds.honeywell.com> Message-ID: On Feb 5, 2008 12:01 AM, Graessle, Glenn (FC COE) < glenn.graessle at honeywell.com> wrote: > Is there an import file that defines the FormField types symbolically? > > For example, Word Checkbox has the value of 71 for it's type. > > > *Glenn Graessle* > Flight Controls CoE > Honeywell International, Inc. > 23500 West 105th Street (M/D 42) > Olathe, KS 66061 > > 913-712-2645(phone/fax) > 913-832-2345 (mobile) > glenn.graessle at honeywell.com > > > This what you looking for? import win32com.client win32com.client.Dispatch('Word.Application') win32com.client.constants.__dicts__[0].keys() -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080205/f45a5d16/attachment.htm From kf9150 at gmail.com Tue Feb 5 08:43:16 2008 From: kf9150 at gmail.com (Kelie) Date: Tue, 5 Feb 2008 07:43:16 +0000 (UTC) Subject: [python-win32] Word FormField types References: <782F51FEE95A4848BD87BD3E75DAD0F90680EE@AZ18EV801.global.ds.honeywell.com> Message-ID: Graessle, Glenn (FC COE honeywell.com> writes: > Is there an import > file that defines the FormField types symbolically? > from win32com.client import constants print constants.xlAscending print constants.wdFieldFormCheckBox From mail at timgolden.me.uk Tue Feb 5 09:56:24 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 05 Feb 2008 08:56:24 +0000 Subject: [python-win32] Can win32com handle this one? In-Reply-To: <87wspk6v40.fsf@gutsy.luannocracy.com> References: <8763x438i5.fsf@gutsy.luannocracy.com> <009101c8677f$de6be6a0$9b43b3e0$@com.au> <87wspk6v40.fsf@gutsy.luannocracy.com> Message-ID: <47A824B8.4010505@timgolden.me.uk> David Abrahams wrote: > on Mon Feb 04 2008, "Mark Hammond" wrote: >> Unfortunately, win32com doesn't support arbitrary interfaces. If the object >> you are using doesn't support IDispatch, then you can't use it from >> win32com. You may like to try something like: >> >> ob = win32com.client.Dispatch(s.GetProvider()) >> >> to see if it does support IDispatch, > > Hmm, thanks, I guess it doesn't: > > 'PyIUnknown' object has no attribute 'GetTypeInfo' > >> in which case you could then start calling methods etc on it. > > So I guess I need to resort to wrapping the C++ API into an extension > module. Worth looking at comtypes. As long as the interface isn't too abstruse you can define it yourself. (And Thomas Heller, the maintainer, is usually pretty responsive on the lists if you're stuck). TJG From mail at timgolden.me.uk Tue Feb 5 09:59:04 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 05 Feb 2008 08:59:04 +0000 Subject: [python-win32] Can win32com handle this one? In-Reply-To: <47A824B8.4010505@timgolden.me.uk> References: <8763x438i5.fsf@gutsy.luannocracy.com> <009101c8677f$de6be6a0$9b43b3e0$@com.au> <87wspk6v40.fsf@gutsy.luannocracy.com> <47A824B8.4010505@timgolden.me.uk> Message-ID: <47A82558.7090808@timgolden.me.uk> Tim Golden wrote: > David Abrahams wrote: >> on Mon Feb 04 2008, "Mark Hammond" wrote: >>> Unfortunately, win32com doesn't support arbitrary interfaces. If the object >>> you are using doesn't support IDispatch, then you can't use it from >>> win32com. You may like to try something like: >>> >>> ob = win32com.client.Dispatch(s.GetProvider()) >>> >>> to see if it does support IDispatch, >> Hmm, thanks, I guess it doesn't: >> >> 'PyIUnknown' object has no attribute 'GetTypeInfo' >> >>> in which case you could then start calling methods etc on it. >> So I guess I need to resort to wrapping the C++ API into an extension >> module. > > Worth looking at comtypes. As long as the interface isn't too > abstruse you can define it yourself. (And Thomas Heller, the > maintainer, is usually pretty responsive on the lists if you're > stuck). Meant to add: probably worth using the svn version: http://svn.python.org/projects/ctypes/trunk/comtypes TJG From le.dahut at laposte.net Tue Feb 5 11:02:08 2008 From: le.dahut at laposte.net (le dahut) Date: Tue, 05 Feb 2008 11:02:08 +0100 Subject: [python-win32] RegisterServiceCtrlHandler(Ex) and Handler(Ex) Message-ID: <47A83420.4040001@laposte.net> Hello, While trying to use RegisterServiceCtrlHandler function, it appears that this function acts like RegisterServiceCtrlHandlerEx if it is run on W2000 or higher. According to msdn, a HandlerEx function has to be used to get callbacks. This function should take 4 arguments : DWORD WINAPI HandlerEx( __in DWORD dwControl, __in DWORD dwEventType, __in LPVOID lpEventData, __in LPVOID lpContext ); But in fact it gets only one. I've modified win32serviceutil to verify it : def ServiceCtrlHandler(self, control) => def ServiceCtrlHandler(self, control, *args) and : def SvcOther(self, control, *args): *args still is an empty tuple (). I only get "dwControl", why don't I get "dwEventType", "lpEventData" and "lpContext" (this last one is user defined so it can be empty, but not the other two) ? From mhammond at skippinet.com.au Tue Feb 5 12:24:25 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 5 Feb 2008 22:24:25 +1100 Subject: [python-win32] RegisterServiceCtrlHandler(Ex) and Handler(Ex) In-Reply-To: <47A83420.4040001@laposte.net> References: <47A83420.4040001@laposte.net> Message-ID: <010d01c867e9$ac8e58b0$05ab0a10$@com.au> > While trying to use RegisterServiceCtrlHandler function, it appears > that > this function acts like RegisterServiceCtrlHandlerEx if it is run on > W2000 or higher. Yes - this is because it calls RegisterServiceCtrlHandlerEx on those platforms. > According to msdn, a HandlerEx function has to be used to get > callbacks. > This function should take 4 arguments : > DWORD WINAPI HandlerEx( > __in DWORD dwControl, > __in DWORD dwEventType, > __in LPVOID lpEventData, > __in LPVOID lpContext > ); > > But in fact it gets only one. > I've modified win32serviceutil to verify it : > def ServiceCtrlHandler(self, control) => def ServiceCtrlHandler(self, > control, *args) > > and : > def SvcOther(self, control, *args): > > *args still is an empty tuple (). I only get "dwControl", why don't I > get "dwEventType", "lpEventData" and "lpContext" (this last one is user > defined so it can be empty, but not the other two) ? It is because I took a bit of a shortcut, and when moving to RegisterServiceCtrlHandlerEx() I didn't work to allow for an alternative python callback that takes the additional args (and supplying them, as in the '* args' in your example, would break existing services). I'd be happy to add this though - contact me offline for the best way to arrange for this (and lpContext is used by the implementation, so if you have a specific use-case for this param, I'd like to know about that too) Cheers, Mark From mc at mclaveau.com Wed Feb 6 08:32:20 2008 From: mc at mclaveau.com (Michel Claveau) Date: Wed, 6 Feb 2008 08:32:20 +0100 Subject: [python-win32] Vista ; elevation (for developers) Message-ID: <854AC58D812E4019B82F69CD08A20CCE@MCI1330> Hi! Developers of PyWin32, what do you think for thia page: http://www.codeproject.com/KB/vista-security/UAC__The_Definitive_Guide.aspx @-salutations -- Michel Claveau -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080206/695c71ca/attachment.htm From dave at boost-consulting.com Wed Feb 6 21:45:05 2008 From: dave at boost-consulting.com (David Abrahams) Date: Wed, 06 Feb 2008 15:45:05 -0500 Subject: [python-win32] Can win32com handle this one? References: <8763x438i5.fsf@gutsy.luannocracy.com> <009101c8677f$de6be6a0$9b43b3e0$@com.au> <87wspk6v40.fsf@gutsy.luannocracy.com> <00c301c86798$e25ec250$a71c46f0$@com.au> Message-ID: <8763x1g6ge.fsf@gutsy.luannocracy.com> on Mon Feb 04 2008, "Mark Hammond" wrote: >> > >> > ob = win32com.client.Dispatch(s.GetProvider()) >> > >> > to see if it does support IDispatch, >> >> Hmm, thanks, I guess it doesn't: >> >> 'PyIUnknown' object has no attribute 'GetTypeInfo' >> >> > in which case you could then start calling methods etc on it. > > Oops - it looks like I should have written: > > ob = > win32com.client.Dispatch(s.GetProvider().QueryInterface(pythoncom.IID_IDispa > tch)) > >> >> So I guess I need to resort to wrapping the C++ API into an extension >> module. > > Or look at 'comtypes', which may end up being less work than an extension > module. Seems to handle the problem very nicely, thank you! Is there somewhere a summary of criteria by which I'd choose win32com or comtypes? -- Dave Abrahams Boost Consulting http://boost-consulting.com From gerdusvanzyl at gmail.com Wed Feb 6 22:34:32 2008 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Wed, 6 Feb 2008 23:34:32 +0200 Subject: [python-win32] Fastest GDI loop Message-ID: <91882ea90802061334o7743301dia3cdc4b95df57146@mail.gmail.com> Hi Please find attached my program (please excuse the mess) that uses cairographics.org to draw on a win32 window using GDI. My question is: What is the best event handling/drawing loop that one can have in pywin32? Is for instance a message map faster or slower? I am new to the win32 api and don't know what is the best way to do things. Thank You, Gerdus van Zyl -------------- next part -------------- A non-text attachment was scrubbed... Name: platformWin32c.py Type: text/x-python Size: 21882 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20080206/37d5b6d0/attachment-0001.py From timr at probo.com Wed Feb 6 22:48:46 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 06 Feb 2008 13:48:46 -0800 Subject: [python-win32] Fastest GDI loop In-Reply-To: <91882ea90802061334o7743301dia3cdc4b95df57146@mail.gmail.com> References: <91882ea90802061334o7743301dia3cdc4b95df57146@mail.gmail.com> Message-ID: <47AA2B3E.1000904@probo.com> Gerdus van Zyl wrote: > Please find attached my program (please excuse the mess) that uses > cairographics.org to draw on a win32 window using GDI. My question is: > What is the best event handling/drawing loop that one can have in > pywin32? Is for instance a message map faster or slower? I am new to > the win32 api and don't know what is the best way to do things. > The "best" one is the one that makes sense to you -- the one you can maintain in the future. The overhead of running Python (as opposed to C++) is going to swamp any difference in performance between various techniques of handling the message loop. That's true of user interfaces in general; the typical user interface application spends 99.9% of its time waiting for the next message. I'm a Python advocate, but if you need to squeeze every microsecond out of your drawing code, then you probably shouldn't be writing it in Python. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Wed Feb 6 23:13:00 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 7 Feb 2008 09:13:00 +1100 Subject: [python-win32] Vista ; elevation (for developers) In-Reply-To: <854AC58D812E4019B82F69CD08A20CCE@MCI1330> References: <854AC58D812E4019B82F69CD08A20CCE@MCI1330> Message-ID: <01c201c8690d$7319ef70$594dce50$@com.au> I think its quite informative - but I don't really see how it relates to pywin32 more than it does to any other language or environment. Cheers, Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Michel Claveau Sent: Wednesday, 6 February 2008 6:32 PM To: python-win32 at python.org Subject: [python-win32] Vista ; elevation (for developers) Hi! Developers of PyWin32, what do you think for thia page: http://www.codeproject.com/KB/vista-security/UAC__The_Definitive_Guide.aspx @-salutations -- Michel Claveau -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080207/274aa2e8/attachment.htm From mail at timgolden.me.uk Thu Feb 7 11:56:59 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 07 Feb 2008 10:56:59 +0000 Subject: [python-win32] Can win32com handle this one? In-Reply-To: <8763x1g6ge.fsf@gutsy.luannocracy.com> References: <8763x438i5.fsf@gutsy.luannocracy.com> <009101c8677f$de6be6a0$9b43b3e0$@com.au> <87wspk6v40.fsf@gutsy.luannocracy.com> <00c301c86798$e25ec250$a71c46f0$@com.au> <8763x1g6ge.fsf@gutsy.luannocracy.com> Message-ID: <47AAE3FB.8080709@timgolden.me.uk> David Abrahams wrote: > Is there somewhere a summary of criteria by which I'd choose win32com or > comtypes? Not that I know of. I offer a so-obvious-as-to-be-almost-unneeded list here. It's entirely likely that I've misrepresented things somewhat so I'd be very grateful for additions & editions. ================== pywin32 (win32com) ================== PRO: Been around for years so more mature, more stable and more (knowledgeable) users. PRO: For those interfaces which it *does* wrap, does most or all of the dirty work for you. PRO: Actively maintained CON / PRO: Makes things so easy for the novice programmer that they forgo any attempt to learn how COM really works... which means that when it gets messy they don't really know what's going on. CON: Has dark and little known/tried corners; I think I discover one new win32com feature every month either through this list or from reading the source to find something else out. CON: Occasionally shows its age, esp. wrt Unicode, datetime and other types whiseh postdate its original conception. CON: Only wraps those interfaces (including, critically, IDispatch) for which its maintainers have time / inclination. ======== comtypes ======== PRO: Effectively native Python -- relies on ctypes which is a C extension but now part of stdlib. PRO: Actively maintained PRO: Can, in principle, wrap any interface. PRO: Newer / smaller so fewer dark corners and refactor-candidates. PRO/CON: You have to understand more about the way the COM works -- as above this has positive and negative points. CON: Newer, so less tried-and-tested: fewer (experienced) users. CON: You have to do the dirty work yourself; as with ctypes, more scope for crashing Python nastily. TJG From tonal at promsoft.ru Thu Feb 7 12:58:33 2008 From: tonal at promsoft.ru (Alexandr N Zamaraev) Date: Thu, 07 Feb 2008 17:58:33 +0600 Subject: [python-win32] How to work with Dispach callback? Message-ID: <47AAF269.5000506@promsoft.ru> I use MicroStation through Automation interface. Bat I do not known how use Events. For example: Object CommandState have method StartLocate: Syntax object.StartLocate EventHandlers object A valid object. EventHandlers An ILocateCommandEvents expression. The object that will handle the events. An instance of the class that you've defined, which implements ILocateCommandEvents. How to write EventHandlers object and call CommandState.StartLocate? I write simple: from win32com.server.util import wrap as com_wrap IID_ILocateCommandEvents = '{67CBDE4A-F073-11D4-A8E6-00508B4D8FED}' class LocateCommandEvents: _com_interfaces_ = [IID_ILocateCommandEvents] _public_methods_ = [ 'Accept', 'Cleanup', 'Dynamics', 'LocateFailed', 'LocateFilter', 'LocateReset', 'Start'] # skip dummy methods... ev = LocateCommandEvents() events = com_wrap(self.ev, IID_ILocateCommandEvents) MSApp.CommandState.StartLocate(events) But it do not work: events = com_wrap(self.ev, IID_ILocateCommandEvents) File "C:\Lang\Python\25\lib\site-packages\win32com\server\util.py", line 30, in wrap ob = ob.QueryInterface(iid) # Ask the PyIDispatch if it supports it? pywintypes.com_error: (-2147467262, 'The interface is not supported', None, None) From dave at boost-consulting.com Thu Feb 7 16:32:54 2008 From: dave at boost-consulting.com (David Abrahams) Date: Thu, 07 Feb 2008 10:32:54 -0500 Subject: [python-win32] Can win32com handle this one? References: <8763x438i5.fsf@gutsy.luannocracy.com> <009101c8677f$de6be6a0$9b43b3e0$@com.au> <87wspk6v40.fsf@gutsy.luannocracy.com> <00c301c86798$e25ec250$a71c46f0$@com.au> <8763x1g6ge.fsf@gutsy.luannocracy.com> <47AAE3FB.8080709@timgolden.me.uk> Message-ID: <871w7olr2x.fsf@gutsy.luannocracy.com> on Thu Feb 07 2008, Tim Golden wrote: > David Abrahams wrote: >> Is there somewhere a summary of criteria by which I'd choose win32com or >> comtypes? > > Not that I know of. I offer a so-obvious-as-to-be-almost-unneeded > list here. It's entirely likely that I've misrepresented things > somewhat so I'd be very grateful for additions & editions. Thanks, this should be very helpful. Please see questions below. > ================== > pywin32 (win32com) > ================== > > PRO: Been around for years so more mature, more stable and > more (knowledgeable) users. > > PRO: For those interfaces which it *does* wrap, does most or > all of the dirty work for you. > > PRO: Actively maintained > > CON / PRO: Makes things so easy for the novice programmer ...or the expert short on COM fu and time -- that's me... > that they forgo any attempt to learn how COM really works... which > means that when it gets messy they don't really know what's going on. > > CON: Has dark and little known/tried corners; I think I discover > one new win32com feature every month either through this list or > from reading the source to find something else out. > > CON: Occasionally shows its age, esp. wrt Unicode, datetime > and other types whiseh postdate its original conception. > > CON: Only wraps those interfaces (including, critically, IDispatch) > for which its maintainers have time / inclination. > > > ======== > comtypes > ======== > > PRO: Effectively native Python -- relies on ctypes which is > a C extension but now part of stdlib. > > PRO: Actively maintained That's a biggie. > PRO: Can, in principle, wrap any interface. > > PRO: Newer / smaller so fewer dark corners and refactor-candidates. Also that. > PRO/CON: You have to understand more about the way the COM > works -- as above this has positive and negative points. Hmm, what I've tried to do so far (admittedly not much) didn't seem to expose any COM details. So, like what? > CON: Newer, so less tried-and-tested: fewer (experienced) users. > > CON: You have to do the dirty work yourself; as with ctypes, more > scope for crashing Python nastily. Really? Again, what I saw looked like a pretty clean abstraction layer. -- Dave Abrahams Boost Consulting http://boost-consulting.com From mail at timgolden.me.uk Thu Feb 7 16:58:33 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 07 Feb 2008 15:58:33 +0000 Subject: [python-win32] Can win32com handle this one? In-Reply-To: <871w7olr2x.fsf@gutsy.luannocracy.com> References: <8763x438i5.fsf@gutsy.luannocracy.com> <009101c8677f$de6be6a0$9b43b3e0$@com.au> <87wspk6v40.fsf@gutsy.luannocracy.com> <00c301c86798$e25ec250$a71c46f0$@com.au> <8763x1g6ge.fsf@gutsy.luannocracy.com> <47AAE3FB.8080709@timgolden.me.uk> <871w7olr2x.fsf@gutsy.luannocracy.com> Message-ID: <47AB2AA9.5050202@timgolden.me.uk> David Abrahams wrote: > on Thu Feb 07 2008, Tim Golden wrote: > >> David Abrahams wrote: >>> Is there somewhere a summary of criteria by which I'd choose win32com or >>> comtypes? >> Not that I know of. I offer a so-obvious-as-to-be-almost-unneeded >> list here. It's entirely likely that I've misrepresented things >> somewhat so I'd be very grateful for additions & editions. > > Thanks, this should be very helpful. Please see questions below. > >> ================== >> pywin32 (win32com) >> ================== >> >> PRO: Actively maintained >> ======== >> comtypes >> ======== >> PRO: Actively maintained > > That's a biggie. Note that pywin32 is, as well (obviously, given the fact of Mark H's response earlier in this thread). >> PRO/CON: You have to understand more about the way the COM >> works -- as above this has positive and negative points. > > Hmm, what I've tried to do so far (admittedly not much) didn't seem to > expose any COM details. So, like what? > >> CON: You have to do the dirty work yourself; as with ctypes, more >> scope for crashing Python nastily. > > Really? Again, what I saw looked like a pretty clean abstraction layer. Yes, I don't mean to imply that it's crufty or ill-conceived. I agree entirely that it represents a neat abstraction. All I really meant was that if you, say, use the shell module from win32com.shell then someone's done all the work setting up the different interfaces -- IColumnProvider, IActiveDesktop and so on -- and exposing them as Python objects. You can do the same yourself with comtypes (at least, I assume you can; I haven't tried) but at the least you have to fossick around for typelibs and constants and it's one more thing to maintain. The real nitty-gritty has already been done by Thomas H in terms of memory access, Pythonic function names and so on. (And all the more credit to him, may I add!) TJG From larry.bates at websafe.com Fri Feb 8 16:35:06 2008 From: larry.bates at websafe.com (Larry Bates) Date: Fri, 08 Feb 2008 09:35:06 -0600 Subject: [python-win32] Fastest GDI loop In-Reply-To: <91882ea90802061334o7743301dia3cdc4b95df57146@mail.gmail.com> References: <91882ea90802061334o7743301dia3cdc4b95df57146@mail.gmail.com> Message-ID: Gerdus van Zyl wrote: > Hi > > Please find attached my program (please excuse the mess) that uses > cairographics.org to draw on a win32 window using GDI. My question is: > What is the best event handling/drawing loop that one can have in > pywin32? Is for instance a message map faster or slower? I am new to > the win32 api and don't know what is the best way to do things. > > Thank You, > Gerdus van Zyl > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 Do you have a performance problem or is this "premature" optimization? -Larry From gerdusvanzyl at gmail.com Fri Feb 8 17:08:47 2008 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Fri, 8 Feb 2008 18:08:47 +0200 Subject: [python-win32] Fastest GDI loop In-Reply-To: References: <91882ea90802061334o7743301dia3cdc4b95df57146@mail.gmail.com> Message-ID: <91882ea90802080808l57df559dwc8da38c839034539@mail.gmail.com> I would say "premature" optimization :-) Was just wondering if there was some standard way to structure a graphics/gdi program. for example: Message maps suck! use XYZ or ABC instead. ~GerdusVZ On Feb 8, 2008 5:35 PM, Larry Bates wrote: > > Gerdus van Zyl wrote: > > Hi > > > > Please find attached my program (please excuse the mess) that uses > > cairographics.org to draw on a win32 window using GDI. My question is: > > What is the best event handling/drawing loop that one can have in > > pywin32? Is for instance a message map faster or slower? I am new to > > the win32 api and don't know what is the best way to do things. > > > > Thank You, > > Gerdus van Zyl > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > Do you have a performance problem or is this "premature" optimization? > > -Larry > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From mhammond at skippinet.com.au Sat Feb 9 05:14:57 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 9 Feb 2008 15:14:57 +1100 Subject: [python-win32] Fastest GDI loop In-Reply-To: <91882ea90802080808l57df559dwc8da38c839034539@mail.gmail.com> References: <91882ea90802061334o7743301dia3cdc4b95df57146@mail.gmail.com> <91882ea90802080808l57df559dwc8da38c839034539@mail.gmail.com> Message-ID: <03e701c86ad2$57030030$05090090$@com.au> > I would say "premature" optimization :-) Was just wondering if there > was some standard way to structure a graphics/gdi program. for > example: Message maps suck! use XYZ or ABC instead. My advice is that 'win32ui' is deprecated (along with the MFC it is built on) - be sure to stick to win32gui/winxpgui if possible. win32gui allows you to have either a dispatch function or a message map - my thinking at the time was that message maps are likely to be more convenient but not as flexible - so just allow both! They both suck in their own way :) A message map is likely to be faster, simply as less python code would be executed per-message. If GDI performance did become an issue, there is a simple optimization we can make for hot GDI functions that can't possibly cause a message to be sent (ie, don't release/acquire the GIL), but that is a bridge we can cross should we ever face it. Cheers, Mark > > ~GerdusVZ > > On Feb 8, 2008 5:35 PM, Larry Bates wrote: > > > > Gerdus van Zyl wrote: > > > Hi > > > > > > Please find attached my program (please excuse the mess) that uses > > > cairographics.org to draw on a win32 window using GDI. My question > is: > > > What is the best event handling/drawing loop that one can have in > > > pywin32? Is for instance a message map faster or slower? I am new > to > > > the win32 api and don't know what is the best way to do things. > > > > > > Thank You, > > > Gerdus van Zyl > > > > > > > > > ------------------------------------------------------------------- > ----- > > > > > > _______________________________________________ > > > python-win32 mailing list > > > python-win32 at python.org > > > http://mail.python.org/mailman/listinfo/python-win32 > > > > Do you have a performance problem or is this "premature" > optimization? > > > > -Larry > > > > > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From tonal at promsoft.ru Tue Feb 12 07:41:04 2008 From: tonal at promsoft.ru (Alexandr N Zamaraev) Date: Tue, 12 Feb 2008 12:41:04 +0600 Subject: [python-win32] How to work with Dispach callback? In-Reply-To: <47AAF269.5000506@promsoft.ru> References: <47AAF269.5000506@promsoft.ru> Message-ID: <47B13F80.6090100@promsoft.ru> Alexandr N Zamaraev wrote: > I use MicroStation through Automation interface. > But I do not known how use Events. I change code: class LocateCommandEvents(object): _com_interfaces_ = [IID_ILocateCommandEvents] _public_methods_ = [] _dispid_to_func_ = { 0x60020000: 'Accept', 0x60020001: 'LocateFailed', 0x60020002: 'LocateFilter', 0x60020003: 'LocateReset', 0x60020004: 'Cleanup', 0x60020005: 'Start', 0x60020006: 'Dynamics'} # skip dummy methods... events = LocateCommandEvents() ev = com_wrap(events, usePolicy=EventHandlerPolicy) MSApp.CommandState.StartLocate(ev) But it not work: File "D:\Lang\Projects\Promsoft\mun_ob\doc_circ\src\tools\MicroEvents.py", line 220, in start_event MSApp.CommandState.StartLocate(ev) File "C:\Lang\Python\25\lib\site-packages\win32com\gen_py\CF9F97BF-39F2-4B8E-835C-8BE9E99DAF5Bx0x8x0.py", line 8047, in StartLocate return self._oleobj_.InvokeTypes(1610743809, LCID, 1, (24, 0), ((9, 1),),EventHandlers pywintypes.com_error: (-2147352571, 'Discrepancy of types.', None, 1) From mhammond at skippinet.com.au Tue Feb 12 13:24:36 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 12 Feb 2008 23:24:36 +1100 Subject: [python-win32] How to work with Dispach callback? In-Reply-To: <47B13F80.6090100@promsoft.ru> References: <47AAF269.5000506@promsoft.ru> <47B13F80.6090100@promsoft.ru> Message-ID: <057101c86d72$4014e670$c03eb350$@com.au> I'd suggest passing 'useDispatcher=1' to com_wrap, so that debug output is generated as your object is called (you can see it via the win32traceutil.py tool). Its hard to tell though, as the MicroStation object is throwing a type error without providing any other information about what it is upset about. You might want to check that MicroStation supports IDispatch based event interfaces, otherwise you will need yet more magic to make things work... Cheers, Mark > -----Original Message----- > From: python-win32-bounces at python.org [mailto:python-win32- > bounces at python.org] On Behalf Of Alexandr N Zamaraev > Sent: Tuesday, 12 February 2008 5:41 PM > To: python-win32 at python.org > Subject: Re: [python-win32] How to work with Dispach callback? > > Alexandr N Zamaraev wrote: > > I use MicroStation through Automation interface. > > But I do not known how use Events. > I change code: > > class LocateCommandEvents(object): > _com_interfaces_ = [IID_ILocateCommandEvents] > > _public_methods_ = [] > _dispid_to_func_ = { > 0x60020000: 'Accept', 0x60020001: 'LocateFailed', 0x60020002: > 'LocateFilter', 0x60020003: 'LocateReset', 0x60020004: 'Cleanup', > 0x60020005: 'Start', 0x60020006: 'Dynamics'} > # skip dummy methods... > > events = LocateCommandEvents() > ev = com_wrap(events, usePolicy=EventHandlerPolicy) > MSApp.CommandState.StartLocate(ev) > > But it not work: > File > "D:\Lang\Projects\Promsoft\mun_ob\doc_circ\src\tools\MicroEvents.py", > line 220, in start_event > MSApp.CommandState.StartLocate(ev) > File > "C:\Lang\Python\25\lib\site-packages\win32com\gen_py\CF9F97BF-39F2- > 4B8E-835C-8BE9E99DAF5Bx0x8x0.py", > > > line 8047, in StartLocate > return self._oleobj_.InvokeTypes(1610743809, LCID, 1, (24, 0), > ((9, > 1),),EventHandlers > pywintypes.com_error: (-2147352571, 'Discrepancy of types.', None, 1) > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From sal at stodge.org Wed Feb 13 14:06:46 2008 From: sal at stodge.org (Salim Fadhley) Date: Wed, 13 Feb 2008 13:06:46 +0000 Subject: [python-win32] How do you find the Windows process ID of a COM server? Message-ID: I'm trying to write a Python program to automate the testing of a very large number of Excel spreadsheets. From time to time these spreadsheets mis-behave and leave Excel in an unstable state - under those circumstances I would like to kill off Excel and restart my COM server with a new process. Unfortunately when a Excel application object goes wrong it often does not respond to quit events. Usually the only thing I can do is kill off all of the Excel processes running - surely there must be a better way? Is there a way to find the process ID of the excel.exe process that I have connected to? That way when I want to kill off a malfunctioning Excel object I need to only kill the affected object. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080213/ce360b1e/attachment.htm From sal at stodge.org Wed Feb 13 16:00:37 2008 From: sal at stodge.org (Salim Fadhley) Date: Wed, 13 Feb 2008 15:00:37 +0000 Subject: [python-win32] How do you find the Windows process ID of a COM server? In-Reply-To: <562bcc10802130626x9297ad2t418fb3f937c29354@mail.gmail.com> References: <562bcc10802130626x9297ad2t418fb3f937c29354@mail.gmail.com> Message-ID: Thanks Kevin, This is all new stuff to me. At the moment I do not have a handle to the Excel window, nor do I know how to get that. Presumably this is something that I can extract from the COM server? This window handle of which you speak - is it anything more than a COM object that represents the Window object of the Excel application? Also is there a more COM / Python friendly way to kill processes than what I currently do which is to use os.system to execute the windows Kill Process command? Thanks! On 2/13/08, Kevin Horn wrote: > > On Feb 13, 2008 7:06 AM, Salim Fadhley wrote: > > > I'm trying to write a Python program to automate the testing of a very > > large number of Excel spreadsheets. From time to time these spreadsheets > > mis-behave and leave Excel in an unstable state - under those circumstances > > I would like to kill off Excel and restart my COM server with a new process. > > > > Unfortunately when a Excel application object goes wrong it often does > > not respond to quit events. Usually the only thing I can do is kill off all > > of the Excel processes running - surely there must be a better way? > > > > Is there a way to find the process ID of the excel.exe process that I > > have connected to? That way when I want to kill off a malfunctioning Excel > > object I need to only kill the affected object. > > > > > Do you have a handle to the Excel window? If so you can get the process > id using GetWindowThreadProcessId. > > There are probably other ways too, but that's what came to mind. > > Kevin Horn > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080213/1e7b4f8e/attachment.htm From sidnei at enfoldsystems.com Wed Feb 13 16:45:41 2008 From: sidnei at enfoldsystems.com (Sidnei da Silva) Date: Wed, 13 Feb 2008 13:45:41 -0200 Subject: [python-win32] How do you find the Windows process ID of a COM server? In-Reply-To: References: <562bcc10802130626x9297ad2t418fb3f937c29354@mail.gmail.com> Message-ID: On Feb 13, 2008 1:00 PM, Salim Fadhley wrote: > Thanks Kevin, > > This is all new stuff to me. At the moment I do not have a handle to the > Excel window, nor do I know how to get that. Presumably this is something > that I can extract from the COM server? > > This window handle of which you speak - is it anything more than a COM > object that represents the Window object of the Excel application? > > Also is there a more COM / Python friendly way to kill processes than what I > currently do which is to use os.system to execute the windows Kill Process > command? There are some great tips and explanations in this article: http://www.ddj.com/windows/184416547 -- Sidnei da Silva Enfold Systems http://enfoldsystems.com Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214 From timr at probo.com Wed Feb 13 20:14:21 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 13 Feb 2008 11:14:21 -0800 Subject: [python-win32] How do you find the Windows process ID of a COM server? In-Reply-To: References: <562bcc10802130626x9297ad2t418fb3f937c29354@mail.gmail.com> Message-ID: <47B3418D.2070504@probo.com> Salim Fadhley wrote: > > This is all new stuff to me. At the moment I do not have a handle to > the Excel window, nor do I know how to get that. Presumably this is > something that I can extract from the COM server? No, unfortunately. However, you can use the FindWindow API to do this. It searches for windows by class and title. The Excel window class is "XLMAIN". > This window handle of which you speak - is it anything more than a COM > object that represents the Window object of the Excel application? Yes. The world of window handles is different from the world of COM, and Microsoft has actually made it rather different to move from one to the other. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From teekaysoh at gmail.com Thu Feb 14 10:35:11 2008 From: teekaysoh at gmail.com (TK Soh) Date: Thu, 14 Feb 2008 09:35:11 +0000 Subject: [python-win32] shell.SHChangeNotify failed to refresh icons Message-ID: <58b84f8e0802140135w60bb55d4gb4fe5d551cd8ea4e@mail.gmail.com> I have noticed quite frequently that shell.SHChangeNotify does not trigger the refreshing of icons on Explorer windows. This happens mostly when relative large number of shell.SHChangeNotify() calls are made on files residing in the same folder. I am using pythonwin b210.5 (special test build by Mark), but I believe the problem is also observed in earlier builds. Any clues or pointer on resolving this issue? Thanks. From williambattersea at gmail.com Thu Feb 14 17:44:26 2008 From: williambattersea at gmail.com (Prof. William Battersea) Date: Thu, 14 Feb 2008 11:44:26 -0500 Subject: [python-win32] Getting Wireless Signal Strength / Windows XP Message-ID: <97d780f10802140844g20fc22d0o552d35b5f20c2ed6@mail.gmail.com> Hello, I posted the following to Comp Lang Python list, but didn't receive any replies: I'm looking for a way to get wireless signal strength on Windows XP with Python. I see there's a library for Linux, but I can't find anything for windows. However, I see that using WMI I can access it in theory at least, using a query like "select Ndis80211ReceivedSignalStrength from MSNdis_80211_ReceivedSignalStrength where active=true" (I got this from: http://www.dotnet247.com/247reference/msgs/36/181397.aspx) I just began playing with the WMI library, but I can't get a hold of the signal strength. As far as I can tell, I should be able to get a handle on it with: import wmi c = wmi.WMI() wql = "select Ndis80211ReceivedSignalStrength from MSNdis_80211_ReceivedSignalStrength where active=true" o = c.query(wql) But I get an error. Traceback (most recent call last): File "", line 1, in c.query("select Ndis80211ReceivedSignalStrength from MSNdis_80211_ReceivedSignalStrength where active=true") File "C:\Python25\Lib\site-packages\wmi.py", line 889, in query return [ _wmi_object (obj, instance_of, fields) for obj in self._raw_query(wql) ] File "C:\Python25\lib\site-packages\win32com\client\util.py", line 83, in next return _get_good_object_(self._iter_.next()) com_error: (-2147217392, 'OLE error 0x80041010', None, None) Is this not available to me? Any ideas? Am I going about this in the wrong way? Thanks From mail at timgolden.me.uk Thu Feb 14 18:13:33 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 14 Feb 2008 17:13:33 +0000 Subject: [python-win32] Getting Wireless Signal Strength / Windows XP In-Reply-To: <97d780f10802140844g20fc22d0o552d35b5f20c2ed6@mail.gmail.com> References: <97d780f10802140844g20fc22d0o552d35b5f20c2ed6@mail.gmail.com> Message-ID: <47B476BD.5040805@timgolden.me.uk> Prof. William Battersea wrote: > I posted the following to Comp Lang Python list, but didn't receive any replies: [... snip WMI problem ...] Bizarre. I'm quite certain I replied to this days ago. I even remember failing to find a wireless machine to test it on. But I can't see the post now. Give me a couple of hours to get home and I'll track it down and repost. Basically, use the "root/WMI" namespace, not the default (root/cimv2) one. TJG From mail at timgolden.me.uk Thu Feb 14 19:23:02 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 14 Feb 2008 18:23:02 +0000 Subject: [python-win32] Getting Wireless Signal Strength / Windows XP In-Reply-To: References: Message-ID: <47B48706.4000000@timgolden.me.uk> [Somehow got stuck in my outbox... ] williambattersea at gmail.com wrote: > Hello, > > I'm looking for a way to get wireless signal strength on Windows XP > with Python. I see there's a library for Linux, but I can't find > anything for windows. However, I see that using WMI I can access it in > theory at least, using a query like "select > Ndis80211ReceivedSignalStrength from > MSNdis_80211_ReceivedSignalStrength where active=true" > > (I got this from: http://www.dotnet247.com/247reference/msgs/36/181397.aspx) > > I just began playing with the WMI library, but I can't get a hold of > the signal strength. > > As far as I can tell, I should be able to get a handle on it with: > > import wmi > c = wmi.WMI() > > wql = "select Ndis80211ReceivedSignalStrength from > MSNdis_80211_ReceivedSignalStrength where active=true" > > o = c.query(wql) > > But I get an error. > Traceback (most recent call last): > File "", line 1, in > c.query("select Ndis80211ReceivedSignalStrength from > MSNdis_80211_ReceivedSignalStrength where active=true") > File "C:\Python25\Lib\site-packages\wmi.py", line 889, in query > return [ _wmi_object (obj, instance_of, fields) for obj in > self._raw_query(wql) ] > File "C:\Python25\lib\site-packages\win32com\client\util.py", line > 83, in next > return _get_good_object_(self._iter_.next()) > com_error: (-2147217392, 'OLE error 0x80041010', None, None) > > Is this not available to me? Any ideas? Am I going about this in the > wrong way? > > Thanks > I don't have a machine to test this on at present, but one thing to note is that the article specifies the WMI namespace (the default is CIMv2), so at the very least you'd need to do something like this: import wmi c = wmi.WMI (namespace="WMI") Once you've got the namespace, you should be able to use the standard syntax to query the -- frankly, unwieldy -- WMI class: for result in c.MSNdis_80211_ReceivedSignalStrength (active=True): print result.Ndis80211ReceivedSignalStrength The machine I'm on is Win2k and non-wireless so I don't have the class available to check. Hope that helped TJG From mhammond at skippinet.com.au Thu Feb 14 23:55:49 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 15 Feb 2008 09:55:49 +1100 Subject: [python-win32] shell.SHChangeNotify failed to refresh icons In-Reply-To: <58b84f8e0802140135w60bb55d4gb4fe5d551cd8ea4e@mail.gmail.com> References: <58b84f8e0802140135w60bb55d4gb4fe5d551cd8ea4e@mail.gmail.com> Message-ID: <019501c86f5c$c04d1290$40e737b0$@com.au> MSDN documents that " For performance reasons, multiple notifications may be combined into a single notification. For example, if a large number of SHCNE_UPDATEITEM notifications are generated for files in the same folder, they can be joined into a single SHCNE_UPDATEDIR notification." which I suspect is your problem. I work on an app that makes heavy use of SHChangeNotify and handling the notifications and I've not had any problems (other than some machines failing to SHChangeNotifyRegister, for reasons that escape me) Cheers, Mark > -----Original Message----- > From: python-win32-bounces at python.org [mailto:python-win32- > bounces at python.org] On Behalf Of TK Soh > Sent: Thursday, 14 February 2008 8:35 PM > To: Python-Win32 List > Subject: [python-win32] shell.SHChangeNotify failed to refresh icons > > I have noticed quite frequently that shell.SHChangeNotify does not > trigger the refreshing of icons on Explorer windows. This happens > mostly when relative large number of shell.SHChangeNotify() calls are > made on files residing in the same folder. I am using pythonwin b210.5 > (special test build by Mark), but I believe the problem is also > observed in earlier builds. Any clues or pointer on resolving this > issue? Thanks. > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From teekaysoh at gmail.com Fri Feb 15 00:56:09 2008 From: teekaysoh at gmail.com (TK Soh) Date: Thu, 14 Feb 2008 23:56:09 +0000 Subject: [python-win32] shell.SHChangeNotify failed to refresh icons In-Reply-To: <019501c86f5c$c04d1290$40e737b0$@com.au> References: <58b84f8e0802140135w60bb55d4gb4fe5d551cd8ea4e@mail.gmail.com> <019501c86f5c$c04d1290$40e737b0$@com.au> Message-ID: <58b84f8e0802141556u6cffa1e0ie736d227f9c060d1@mail.gmail.com> On Thu, Feb 14, 2008 at 10:55 PM, Mark Hammond wrote: > MSDN documents that " For performance reasons, multiple notifications may > be combined into a single notification. For example, if a large number of > SHCNE_UPDATEITEM notifications are generated for files in the same folder, > they can be joined into a single SHCNE_UPDATEDIR notification." > > which I suspect is your problem. I work on an app that makes heavy use of > SHChangeNotify and handling the notifications and I've not had any problems > (other than some machines failing to SHChangeNotifyRegister, for reasons > that escape me) Thanks for the tip. I just found out I was passing SHCNF_FLUSHNOWAIT flag to the calls. By changing the flag to SHCNF_FLUSH, the icons are refreshed correctly (at least most of the time). Though the delay on refreshing is noticeable from one icon to the other. But that's not intolerable for now. BTW, is there any ill effect in the use of SHCNF_FLUSH? I don't understand the reason why SHCNF_FLUSHNOWAIT would not work though. I will experiment with SHCNE_UPDATEDIR to see if it help on this. From mhammond at skippinet.com.au Fri Feb 15 01:26:05 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 15 Feb 2008 11:26:05 +1100 Subject: [python-win32] shell.SHChangeNotify failed to refresh icons In-Reply-To: <58b84f8e0802141556u6cffa1e0ie736d227f9c060d1@mail.gmail.com> References: <58b84f8e0802140135w60bb55d4gb4fe5d551cd8ea4e@mail.gmail.com> <019501c86f5c$c04d1290$40e737b0$@com.au> <58b84f8e0802141556u6cffa1e0ie736d227f9c060d1@mail.gmail.com> Message-ID: <019601c86f69$5d561170$18023450$@com.au> > I just found out I was passing SHCNF_FLUSHNOWAIT flag to the calls. By > changing the flag to SHCNF_FLUSH, the icons are refreshed correctly > (at least most of the time). Though the delay on refreshing is > noticeable from one icon to the other. But that's not intolerable for > now. That is strange. Maybe that flag determines if windows will collapse them down. > BTW, is there any ill effect in the use of SHCNF_FLUSH? I don't > understand the reason why SHCNF_FLUSHNOWAIT would not work though. The only effect is the obvious documented one - you block until all notifications have been processed. It depends on your app how ill that effect is :) Cheers, Mark From tonal at promsoft.ru Fri Feb 15 12:16:10 2008 From: tonal at promsoft.ru (Alexandr N Zamaraev) Date: Fri, 15 Feb 2008 17:16:10 +0600 Subject: [python-win32] How to work with Dispach callback? In-Reply-To: <057101c86d72$4014e670$c03eb350$@com.au> References: <47AAF269.5000506@promsoft.ru> <47B13F80.6090100@promsoft.ru> <057101c86d72$4014e670$c03eb350$@com.au> Message-ID: <47B5747A.3070401@promsoft.ru> Mark Hammond wrote: > I'd suggest passing 'useDispatcher=1' to com_wrap, so that debug output is > generated as your object is called (you can see it via the win32traceutil.py > tool). Thank you for the reply. I'd made it in such way: class LocateCommandEvents(object): _com_interfaces_ = [IID_ILocateCommandEvents] _typelib_guid_ = '{CF9F97BF-39F2-4B8E-835C-8BE9E99DAF5B}' _typelib_version_ = 8, 0 _typelib_lcid_ = 0 _public_methods_ = [] _dispid_to_func_ = { 0x60020000: 'Accept', 0x60020001: 'LocateFailed', 0x60020002: 'LocateFilter', 0x60020003: 'LocateReset', 0x60020004: 'Cleanup', 0x60020005: 'Start', 0x60020006: 'Dynamics'} after it and after editing in win32com.server.policy (http://sourceforge.net/tracker/?func=detail&aid=1892592&group_id=78018&atid=551956) the call of StartLocate has worked successfully. Now errors occur in calls to LocateCommandEvents.LocateFilter function from MicroStation: pythoncom error: Failed to call the universal dispatcher Traceback (most recent call last): File "C:\Lang\Python\25\lib\site-packages\win32com\universal.py", line 193, in dispatch WriteFromOutTuple(retVal, meth._gw_out_args, argPtr) : The VARIANT type is unknown (0x24). pythoncom error: Unexpected gateway error Traceback (most recent call last): File "C:\Lang\Python\25\lib\site-packages\win32com\universal.py", line 193, in dispatch WriteFromOutTuple(retVal, meth._gw_out_args, argPtr) : The VARIANT type is unknown (0x24). Perhaps the reason of it is that ILocateCommandEvents turn out not fully compatible with IDispatch interfaces: [ odl, uuid(67CBDE4A-F073-11D4-A8E6-00508B4D8FED), helpcontext(0x0000021a), dual, nonextensible, oleautomation ] interface ILocateCommandEvents : IDispatch { [id(0x60020000), helpcontext(0x0000001d)] HRESULT Accept( [in] _Element* Element, [in, out] Point3d* Point, [in] _View* View); [id(0x60020001), helpcontext(0x00000025)] HRESULT LocateFailed(); [id(0x60020002), helpcontext(0x00000026)] HRESULT LocateFilter( [in] _Element* Element, [in, out] Point3d* Point, [in, out] VARIANT_BOOL* Accepted); [id(0x60020003), helpcontext(0x00000027)] HRESULT LocateReset(); [id(0x60020004), helpcontext(0x00000020)] HRESULT Cleanup(); [id(0x60020005), helpcontext(0x0000002e)] HRESULT Start(); [id(0x60020006), helpcontext(0x00000022)] HRESULT Dynamics( [in, out] Point3d* Point, [in] _View* View, [in] MsdDrawingMode DrawMode); }; Point3d - struct, MsdDrawingMode - enum, declared in MicroStation Typelib. Can you give me an advise in the case? > Its hard to tell though, as the MicroStation object is throwing a > type error without providing any other information about what it is upset > about. You might want to check that MicroStation supports IDispatch based > event interfaces, otherwise you will need yet more magic to make things > work... > > Cheers, > > Mark From teekaysoh at gmail.com Fri Feb 15 16:41:01 2008 From: teekaysoh at gmail.com (TK Soh) Date: Fri, 15 Feb 2008 15:41:01 +0000 Subject: [python-win32] shell.SHChangeNotify failed to refresh icons In-Reply-To: <58b84f8e0802141556u6cffa1e0ie736d227f9c060d1@mail.gmail.com> References: <58b84f8e0802140135w60bb55d4gb4fe5d551cd8ea4e@mail.gmail.com> <019501c86f5c$c04d1290$40e737b0$@com.au> <58b84f8e0802141556u6cffa1e0ie736d227f9c060d1@mail.gmail.com> Message-ID: <58b84f8e0802150741h6068c206r11e90656d20a89f@mail.gmail.com> On Thu, Feb 14, 2008 at 11:56 PM, TK Soh wrote: > On Thu, Feb 14, 2008 at 10:55 PM, Mark Hammond > wrote: > > MSDN documents that " For performance reasons, multiple notifications may > > be combined into a single notification. For example, if a large number of > > SHCNE_UPDATEITEM notifications are generated for files in the same folder, > > they can be joined into a single SHCNE_UPDATEDIR notification." > > > > which I suspect is your problem. I work on an app that makes heavy use of > > SHChangeNotify and handling the notifications and I've not had any problems > > (other than some machines failing to SHChangeNotifyRegister, for reasons > > that escape me) > > Thanks for the tip. > > I just found out I was passing SHCNF_FLUSHNOWAIT flag to the calls. By > changing the flag to SHCNF_FLUSH, the icons are refreshed correctly > (at least most of the time). Though the delay on refreshing is > noticeable from one icon to the other. But that's not intolerable for > now. > > BTW, is there any ill effect in the use of SHCNF_FLUSH? I don't > understand the reason why SHCNF_FLUSHNOWAIT would not work though. > > I will experiment with SHCNE_UPDATEDIR to see if it help on this. I tried passing SHCNE_UPDATEDIR to the parent dir of the icons, but the icons were not refreshed. Win32traceutil also didn't record any overlay icons requests. Here's how it was done: dir = os.path.dirname(path) pidl, ignore = shell.SHILCreateFromPath(dir, 0) print "notify: ", shell.SHGetPathFromIDList(pidl) shell.SHChangeNotify(shellcon.SHCNE_UPDATEDIR, shellcon.SHCNF_IDLIST | shellcon.SHCNF_FLUSH, pidl, None) Any thing I did wrong? From stef.mientki at gmail.com Fri Feb 15 19:11:58 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Fri, 15 Feb 2008 19:11:58 +0100 Subject: [python-win32] How to get active process list ? Message-ID: <47B5D5EE.6040007@gmail.com> hello, How do I get the list of active processes ? I tried this call, but ... items, instances = win32pdh.EnumObjectItems(None,None,object, win32pdh.PERF_DETAIL_WIZARD) return instances ... it doesn't reflect dynamic changes, just the status quo at the start of my program :-( thanks, Stef Mientki From tojo2000 at gmail.com Fri Feb 15 19:29:55 2008 From: tojo2000 at gmail.com (Tim Johnson) Date: Fri, 15 Feb 2008 10:29:55 -0800 Subject: [python-win32] How to get active process list ? In-Reply-To: <47B5D5EE.6040007@gmail.com> References: <47B5D5EE.6040007@gmail.com> Message-ID: <5394762f0802151029i4d251a3ch4ea408b02dde1805@mail.gmail.com> Have you tried using WMI? http://timgolden.me.uk/python/wmi.html import wmi w = wmi.WMI() processes = w.instances('Win32_Process') for process in processes: print process.name On Fri, Feb 15, 2008 at 10:11 AM, Stef Mientki wrote: > hello, > > How do I get the list of active processes ? > > I tried this call, but ... > items, instances = win32pdh.EnumObjectItems(None,None,object, > win32pdh.PERF_DETAIL_WIZARD) > return instances > > ... it doesn't reflect dynamic changes, > just the status quo at the start of my program :-( > > thanks, > Stef Mientki > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- _____________________ Ceci n'est pas un email. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080215/7c614d5f/attachment.htm From stef.mientki at gmail.com Fri Feb 15 20:54:43 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Fri, 15 Feb 2008 20:54:43 +0100 Subject: [python-win32] How to get active process list ? In-Reply-To: <5394762f0802151029i4d251a3ch4ea408b02dde1805@mail.gmail.com> References: <47B5D5EE.6040007@gmail.com> <5394762f0802151029i4d251a3ch4ea408b02dde1805@mail.gmail.com> Message-ID: <47B5EE03.7050200@gmail.com> thanks Tim, that works. cheeers, Stef Tim Johnson wrote: > Have you tried using WMI? http://timgolden.me.uk/python/wmi.html > > import wmi > w = wmi.WMI() > processes = w.instances('Win32_Process') > for process in processes: > print process.name > > On Fri, Feb 15, 2008 at 10:11 AM, Stef Mientki > wrote: > > hello, > > How do I get the list of active processes ? > > I tried this call, but ... > items, instances = win32pdh.EnumObjectItems(None,None,object, > win32pdh.PERF_DETAIL_WIZARD) > return instances > > ... it doesn't reflect dynamic changes, > just the status quo at the start of my program :-( > > thanks, > Stef Mientki > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > > > -- > _____________________ > Ceci n'est pas un email. From ykoncontact at yahoo.fr Fri Feb 15 21:43:56 2008 From: ykoncontact at yahoo.fr (pierre) Date: Fri, 15 Feb 2008 12:43:56 -0800 (PST) Subject: [python-win32] Some problems with instantiating a type library Message-ID: <447722.67469.qm@web65515.mail.ac4.yahoo.com> Hi, i'm trying to make use of win32 and makepy for automatizing the CAD/CAMsoftware Rhino3D. I'm beginning with something like this: import win32com.client from RSInterface import RhinoScript #Interface made by makepy from the RhinoScript type library Rhino = win32com.client.Dispatch('Rhino4.Application') Rhino.Visible = True #this works and launches rhino but not the following RS = Rhino.GetScriptObject RS = RS.RhinoScript #it returns : RS = RS.RhinoScript AttributeError: 'NoneType' object has no attribute 'RhinoScript' Does anybody could help about that? Best regards _____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail http://mail.yahoo.fr From timr at probo.com Fri Feb 15 22:26:53 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 15 Feb 2008 13:26:53 -0800 Subject: [python-win32] Some problems with instantiating a type library In-Reply-To: <447722.67469.qm@web65515.mail.ac4.yahoo.com> References: <447722.67469.qm@web65515.mail.ac4.yahoo.com> Message-ID: <47B6039D.2060803@probo.com> pierre wrote: > Hi, i'm trying to make use of win32 and makepy for automatizing the CAD/CAMsoftware Rhino3D. > > I'm beginning with something like this: > > import win32com.client > from RSInterface import RhinoScript #Interface made by makepy from the RhinoScript type library > > Rhino = win32com.client.Dispatch('Rhino4.Application') > Rhino.Visible = True > > #this works and launches rhino but not the following > > RS = Rhino.GetScriptObject > This is a function, not a property. Unlike VB, function calls in Python must have the parens: RS = Rhino.GetScriptObject() However, their knowledge base mentions that it can take quite a long time before it loads the RhinoScript plugin. They suggest retrying the GetScriptObject call in a loop with a delay: http://en.wiki.mcneel.com/default.aspx/McNeel/Rhino4Automation It shouldn't be hard to convert that to Python. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From storoe at google.com Fri Feb 15 23:59:26 2008 From: storoe at google.com (Brian Storoe) Date: Fri, 15 Feb 2008 14:59:26 -0800 Subject: [python-win32] RegCreateKeyEx Message-ID: <47B6194E.6060600@google.com> All, I'm looking for a way to access the RegCreateKeyEx() using the pywin32 libraries. The circumstances are as follows: I'm running Python 2.4 on a Windows Vista 64-bit system and need a way to access 64-bit keys in the registry. Per http://msdn2.microsoft.com/en-us/library/aa384129(VS.85).aspx it looks like the way to do this is using RegCreateKeyEx() and passing in the correct flag inthe samDesired parameter to that function. In the win32api module we have a RegOpenKeyEx() function but no RegCreateKeyEx() (only RegCreateKey(). Any help or advice would be appreciate. Thanks, -Brian Storoe From mhammond at skippinet.com.au Sat Feb 16 00:18:39 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 16 Feb 2008 10:18:39 +1100 Subject: [python-win32] RegCreateKeyEx In-Reply-To: <47B6194E.6060600@google.com> References: <47B6194E.6060600@google.com> Message-ID: <022901c87029$1bba8dc0$532fa940$@com.au> > All, > > I'm looking for a way to access the RegCreateKeyEx() using the pywin32 > libraries. > > The circumstances are as follows: I'm running Python 2.4 on a Windows > Vista 64-bit system and need a way to access 64-bit keys in the > registry. Per > http://msdn2.microsoft.com/en-us/library/aa384129(VS.85).aspx it looks > like the way to do this is using RegCreateKeyEx() and passing in the > correct flag inthe samDesired parameter to that function. > > In the win32api module we have a RegOpenKeyEx() function but no > RegCreateKeyEx() (only RegCreateKey(). Roger has already added this to pywin32, so build 211 of pywin32 will have it. Build 211 should be ready in a week or so too - I believe that everythign outstanding has been done, and once Roger finishes checking in his outstanding stuff (which he may have already done) I will start turning cranks... Cheers, Mark From mhammond at skippinet.com.au Sat Feb 16 00:25:03 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 16 Feb 2008 10:25:03 +1100 Subject: [python-win32] How to work with Dispach callback? In-Reply-To: <47B5747A.3070401@promsoft.ru> References: <47AAF269.5000506@promsoft.ru> <47B13F80.6090100@promsoft.ru> <057101c86d72$4014e670$c03eb350$@com.au> <47B5747A.3070401@promsoft.ru> Message-ID: <022a01c8702a$00e90e30$02bb2a90$@com.au> It appears that the "universal gateway" support in pywin32 doesn't handle VT_RECORD. I doubt this would be hard to fix, but its not something I have time to look at in the short term. I'd suggest you open a bug at sourceforge, and/or let me know if you are interested in getting your hands dirty and trying to help fix it (but you will require a C++ compiler) Cheers, Mark > -----Original Message----- > From: python-win32-bounces at python.org [mailto:python-win32- > bounces at python.org] On Behalf Of Alexandr N Zamaraev > Sent: Friday, 15 February 2008 10:16 PM > To: python-win32 at python.org > Subject: Re: [python-win32] How to work with Dispach callback? > > Mark Hammond wrote: > > I'd suggest passing 'useDispatcher=1' to com_wrap, so that debug > output is > > generated as your object is called (you can see it via the > win32traceutil.py > > tool). > Thank you for the reply. > > I'd made it in such way: > > class LocateCommandEvents(object): > _com_interfaces_ = [IID_ILocateCommandEvents] > _typelib_guid_ = '{CF9F97BF-39F2-4B8E-835C-8BE9E99DAF5B}' > _typelib_version_ = 8, 0 > _typelib_lcid_ = 0 > > _public_methods_ = [] > _dispid_to_func_ = { > 0x60020000: 'Accept', 0x60020001: 'LocateFailed', 0x60020002: > 'LocateFilter', 0x60020003: 'LocateReset', 0x60020004: 'Cleanup', > 0x60020005: 'Start', 0x60020006: 'Dynamics'} > > after it and after editing in win32com.server.policy > (http://sourceforge.net/tracker/?func=detail&aid=1892592&group_id=78018 > &atid=551956) > > the call of > StartLocate has worked successfully. > > Now errors occur in calls to LocateCommandEvents.LocateFilter function > from MicroStation: > > pythoncom error: Failed to call the universal dispatcher > > Traceback (most recent call last): > File "C:\Lang\Python\25\lib\site-packages\win32com\universal.py", > line 193, in > dispatch > WriteFromOutTuple(retVal, meth._gw_out_args, argPtr) > : The VARIANT type is unknown (0x24). > pythoncom error: Unexpected gateway error > > Traceback (most recent call last): > File "C:\Lang\Python\25\lib\site-packages\win32com\universal.py", > line 193, in > dispatch > WriteFromOutTuple(retVal, meth._gw_out_args, argPtr) > : The VARIANT type is unknown (0x24). > > > Perhaps the reason of it is that ILocateCommandEvents turn out not > fully > compatible with IDispatch interfaces: > > [ > odl, > uuid(67CBDE4A-F073-11D4-A8E6-00508B4D8FED), > helpcontext(0x0000021a), > dual, > nonextensible, > oleautomation > ] > interface ILocateCommandEvents : IDispatch { > [id(0x60020000), helpcontext(0x0000001d)] > HRESULT Accept( > [in] _Element* Element, > [in, out] Point3d* Point, > [in] _View* View); > [id(0x60020001), helpcontext(0x00000025)] > HRESULT LocateFailed(); > [id(0x60020002), helpcontext(0x00000026)] > HRESULT LocateFilter( > [in] _Element* Element, > [in, out] Point3d* Point, > [in, out] VARIANT_BOOL* Accepted); > [id(0x60020003), helpcontext(0x00000027)] > HRESULT LocateReset(); > [id(0x60020004), helpcontext(0x00000020)] > HRESULT Cleanup(); > [id(0x60020005), helpcontext(0x0000002e)] > HRESULT Start(); > [id(0x60020006), helpcontext(0x00000022)] > HRESULT Dynamics( > [in, out] Point3d* Point, > [in] _View* View, > [in] MsdDrawingMode DrawMode); > }; > > Point3d - struct, MsdDrawingMode - enum, declared in MicroStation > Typelib. > > Can you give me an advise in the case? > > > Its hard to tell though, as the MicroStation object is throwing a > > type error without providing any other information about what it is > upset > > about. You might want to check that MicroStation supports IDispatch > based > > event interfaces, otherwise you will need yet more magic to make > things > > work... > > > > Cheers, > > > > Mark > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From timr at probo.com Sat Feb 16 00:29:39 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 15 Feb 2008 15:29:39 -0800 Subject: [python-win32] Some problems with instantiating a type library In-Reply-To: <3c8b20230802151514m4973771fx7e533e48ea8f8049@mail.gmail.com> References: <447722.67469.qm@web65515.mail.ac4.yahoo.com> <47B6039D.2060803@probo.com> <3c8b20230802151514m4973771fx7e533e48ea8f8049@mail.gmail.com> Message-ID: <47B62063.5020400@probo.com> pierre cutellic wrote: > Thanks Tim, its becoming better > > I'm doing the following: > > import win32com.client, time > from RSInterface import RhinoScript > time.sleep(2) > > Rhino.Visible = True > > RS = Rhino.GetScriptObject() > RS = RS.RhinoScript > > But it's returning the following: > > File "C:\Python24\lib\site-packages\win32com\client\dynamic.py", line > 172, in __call__ > return > self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None) > pywintypes.com_error: (-2147352573, 'Membre introuvable.', None, None) > > It's a bit weird and incomprehensible for a new user like me. > Any idea? -2148352583 is 0x80020003, which is DISP_E_MEMBERNOTFOUND (which is probably what "Membre introuvable" means...). Where did you read that you need that second step? Once you call GetScriptObject, you should HAVE the script engine. You should be able to call RS.Command or whatever you need. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Sat Feb 16 00:34:23 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 16 Feb 2008 10:34:23 +1100 Subject: [python-win32] shell.SHChangeNotify failed to refresh icons In-Reply-To: <58b84f8e0802150741h6068c206r11e90656d20a89f@mail.gmail.com> References: <58b84f8e0802140135w60bb55d4gb4fe5d551cd8ea4e@mail.gmail.com> <019501c86f5c$c04d1290$40e737b0$@com.au> <58b84f8e0802141556u6cffa1e0ie736d227f9c060d1@mail.gmail.com> <58b84f8e0802150741h6068c206r11e90656d20a89f@mail.gmail.com> Message-ID: <023001c8702b$4de35d70$e9aa1850$@com.au> > I tried passing SHCNE_UPDATEDIR to the parent dir of the icons, but > the icons were not refreshed. Win32traceutil also didn't record any > overlay icons requests. Here's how it was done: > > dir = os.path.dirname(path) > pidl, ignore = shell.SHILCreateFromPath(dir, 0) > print "notify: ", shell.SHGetPathFromIDList(pidl) > shell.SHChangeNotify(shellcon.SHCNE_UPDATEDIR, > shellcon.SHCNF_IDLIST | shellcon.SHCNF_FLUSH, > pidl, > None) > > Any thing I did wrong? Not that I can see - but you are relying on the behaviour of Explorer's SHChangeNotify handler, and I've no idea how that is implemented - but I wouldn't be surprised to find that an SHCNE_UPDATEDIR is *not* treated as a full refresh, even if that does leave the possibility that icons or other attributes will be slightly out of date - they will correct themselves after a refresh after all. In other words, just because the shell may collapse many SHCNE_UPDATEITEM calls into a single SHCNE_UPDATEDIR notification, there is no requirement that notification handlers treat SHCNE_UPDATEDIR as performing a complete SHCNE_UPDATEITEM for every item in the directory. Cheers, Mark From timr at probo.com Sat Feb 16 01:08:59 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 15 Feb 2008 16:08:59 -0800 Subject: [python-win32] Some problems with instantiating a type library In-Reply-To: <3c8b20230802151556k3db02fa8s44c7fc63e79b8a6f@mail.gmail.com> References: <447722.67469.qm@web65515.mail.ac4.yahoo.com> <47B6039D.2060803@probo.com> <3c8b20230802151514m4973771fx7e533e48ea8f8049@mail.gmail.com> <47B62063.5020400@probo.com> <3c8b20230802151556k3db02fa8s44c7fc63e79b8a6f@mail.gmail.com> Message-ID: <47B6299B.4040304@probo.com> pierre cutellic wrote: > I'm trying to do this way because the Rhino Type Library and the > RhinoScript Type Library > are separated and I need it to script some geometry. Right, there are two separate objects, and you HAVE two separate objects. The "Rhino" object that you start with is the Rhino application. But when you call GetScriptObject, it is giving you the RhinoScript object. You shouldn't need another step. You can take the object that Rhino.GetScriptObject() gives you, and start scripting geometry using that. > So i first created an interface of the RhinoScript tlb with makepy > and then tried this code. But ther is certainly a smarter way to do it Well, this is not about whether it's smart or not. What I'm saying is that the line that says RS = RS.RhinoScript is an error and should not be there. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rwupole at msn.com Sat Feb 16 01:15:10 2008 From: rwupole at msn.com (Roger Upole) Date: Fri, 15 Feb 2008 19:15:10 -0500 Subject: [python-win32] Re: RegCreateKeyEx Message-ID: Mark Hammond" wrote: > Roger has already added this to pywin32, so build 211 of pywin32 will have > it. Build 211 should be ready in a week or so too - I believe that > everythign outstanding has been done, and once Roger finishes checking in > his outstanding stuff (which he may have already done) I will start > turning > cranks... > > Cheers, > > Mark The only things I have left for now are win32notify.cpp and win32thread.cpp. I should be checking them in shortly after a few more tests. The stale thread associations should finally be sorted out (I think). Roger From marcus at internetnowasp.net Sat Feb 16 18:17:48 2008 From: marcus at internetnowasp.net (Marcus Low) Date: Sun, 17 Feb 2008 01:17:48 +0800 Subject: [python-win32] How do you find the Windows process ID of a COM server? In-Reply-To: <47B3418D.2070504@probo.com> References: <562bcc10802130626x9297ad2t418fb3f937c29354@mail.gmail.com> <47B3418D.2070504@probo.com> Message-ID: <892EE528D64C49EE9A1545FCC3BC6EFE@ToolBox> This wont work on Vista. FindWindow is no longer an acceptable api to use. ----- Original Message ----- From: "Tim Roberts" To: "Python-Win32 List" Sent: Thursday, February 14, 2008 3:14 AM Subject: Re: [python-win32] How do you find the Windows process ID of a COM server? > Salim Fadhley wrote: >> >> This is all new stuff to me. At the moment I do not have a handle to >> the Excel window, nor do I know how to get that. Presumably this is >> something that I can extract from the COM server? > > No, unfortunately. However, you can use the FindWindow API to do this. > It searches for windows by class and title. The Excel window class is > "XLMAIN". > > >> This window handle of which you speak - is it anything more than a COM >> object that represents the Window object of the Excel application? > > Yes. The world of window handles is different from the world of COM, > and Microsoft has actually made it rather different to move from one to > the other. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From nicholasinparis at gmail.com Sun Feb 17 17:07:04 2008 From: nicholasinparis at gmail.com (Nicholas) Date: Sun, 17 Feb 2008 17:07:04 +0100 Subject: [python-win32] Excel columnwise writing Message-ID: I am writing to arrays to excel. If I write row-wise everything works well. app.Range('d4:f4').Value = [2,3,4] However if I try to assign column wise everything goes wrong app.Range('d4:d6').Value = [2,3,4] I know I can rearrage things like [[i] for i in [2,3,4]] but it does not seem terribly efficient. Is there some trick which can allow me to write column wise with good performance? From s.khushalani at yahoo.co.uk Sun Feb 17 23:01:59 2008 From: s.khushalani at yahoo.co.uk (Sagar Khushalani) Date: Sun, 17 Feb 2008 22:01:59 +0000 (GMT) Subject: [python-win32] message queueing between processes Message-ID: <454195.16135.qm@web28303.mail.ukl.yahoo.com> i have 5 processes. out of these, i need 1 to start a queue that can be shared between the other 4. 2 of them will add messages to the queue and 2 will read and remove off of it. any ideas? i'm a little confused how to share the queue between them. Sagar Khushalani Graduate Student, UTA Networking / Systems and Architecture s.khushalani at yahoo.co.uk http://www.sagark.info --------------------------------- Support the World Aids Awareness campaign this month with Yahoo! for Good -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080217/c8099d1a/attachment.htm From teekaysoh at gmail.com Mon Feb 18 08:22:36 2008 From: teekaysoh at gmail.com (TK Soh) Date: Mon, 18 Feb 2008 07:22:36 +0000 Subject: [python-win32] gc does not free memory Message-ID: <58b84f8e0802172322u2fab0bccp2847c791f61e486@mail.gmail.com> I am trying to understand Python's garbage collection mechanism. I have a long running program (actually a shell extension) that needs to allocate large arrays occasionally, which I'd del after use, then call gc.collect() to collect them. But although gc.get_objects() reported the arrays have been collected (also confirmed they didn't end up in gc.garbage), but the memory footprint (VM size) remain the same, as if the memory was never freed and return to heap. Appreciate if anyone can help shed some light on this. Google didn't hit much useful websites on this topic. FYI, I am using ActivePython 2.5 on XP SP2. Thanks. From nicholasinparis at gmail.com Mon Feb 18 10:28:11 2008 From: nicholasinparis at gmail.com (Nicholas) Date: Mon, 18 Feb 2008 10:28:11 +0100 Subject: [python-win32] columnwise writing to excel Message-ID: I am writing to arrays to excel. If I write row-wise everything works well. app.Range('d4:f4').Value = [2,3,4] However if I try to assign column wise everything goes wrong app.Range('d4:d6').Value = [2,3,4] I know I can rearrage things like [[i] for i in [2,3,4]] but it does not seem terribly efficient. Is there some trick which can allow me to write column wise with good performance? From timr at probo.com Mon Feb 18 18:04:20 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 18 Feb 2008 09:04:20 -0800 Subject: [python-win32] How do you find the Windows process ID of a COM server? In-Reply-To: <892EE528D64C49EE9A1545FCC3BC6EFE@ToolBox> References: <562bcc10802130626x9297ad2t418fb3f937c29354@mail.gmail.com> <47B3418D.2070504@probo.com> <892EE528D64C49EE9A1545FCC3BC6EFE@ToolBox> Message-ID: <47B9BA94.2030203@probo.com> Marcus Low wrote: > This wont work on Vista. FindWindow is no longer an acceptable api to > use. That is simply not true. If you can point to the web site where you read this, I'll try to figure out how you misinterpreted it. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Feb 18 18:09:10 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 18 Feb 2008 09:09:10 -0800 Subject: [python-win32] Some problems with instantiating a type library In-Reply-To: <3c8b20230802161539u453bf1aap70e096d572c8fba1@mail.gmail.com> References: <447722.67469.qm@web65515.mail.ac4.yahoo.com> <47B6039D.2060803@probo.com> <3c8b20230802151514m4973771fx7e533e48ea8f8049@mail.gmail.com> <47B62063.5020400@probo.com> <3c8b20230802151556k3db02fa8s44c7fc63e79b8a6f@mail.gmail.com> <47B6299B.4040304@probo.com> <3c8b20230802161539u453bf1aap70e096d572c8fba1@mail.gmail.com> Message-ID: <47B9BBB6.1080304@probo.com> pierre cutellic wrote: > Well, I tried this way first, > but this is not working, and that's why i'm a bit stuck. > > import win32com.client, time > Rhino = win32com.client.Dispatch('Rhino4.Application') > time.sleep(1) > Rhino.Visible = True > RS = Rhino.GetScriptObject() > > *It returns: > > *RS = Rhino.GetScriptObject() > File "C:\Python24\lib\site-packages\win32com\client\dynamic.py", line > 172, in __call__ > return > self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None) > pywintypes.com_error: (-2147352573, 'Membre introuvable.', None, None)* > * I thought you said this was working! It may be that 1 second is not enough. Remember that the web page I quoted was doing this in a loop, retrying and delaying until it succeeded. You could do the same thing by doing something like: import pywintypes ... gotit = False while not gotit: try: RS = Rhino.GetScriptObject() gotit = True except pywintype.com_error: time.sleep(1) print "Retrying" -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Feb 18 18:49:29 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 18 Feb 2008 09:49:29 -0800 Subject: [python-win32] columnwise writing to excel In-Reply-To: References: Message-ID: <47B9C529.40905@probo.com> Nicholas wrote: > I am writing to arrays to excel. If I write row-wise everything works well. > app.Range('d4:f4').Value = [2,3,4] > However if I try to assign column wise everything goes wrong > app.Range('d4:d6').Value = [2,3,4] > > I know I can rearrage things like [[i] for i in [2,3,4]] but it does > not seem terribly efficient. Is there some trick which can allow me to > write column wise with good performance? > The difference in efficiency is irrelevant. Have you measured it, or are you over-optimizing too early? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Feb 18 18:52:57 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 18 Feb 2008 09:52:57 -0800 Subject: [python-win32] message queueing between processes In-Reply-To: <454195.16135.qm@web28303.mail.ukl.yahoo.com> References: <454195.16135.qm@web28303.mail.ukl.yahoo.com> Message-ID: <47B9C5F9.2010409@probo.com> Sagar Khushalani wrote: > i have 5 processes. out of these, i need 1 to start a queue that can > be shared between the other 4. 2 of them will add messages to the > queue and 2 will read and remove off of it. any ideas? i'm a little > confused how to share the queue between them. The Python "Queue" module is designed for communicating between threads of a single process. It relies on a common memory space. For interprocess communication, you'll need to use a different scheme. On Windows, you can try to use a named pipe or a mailslot, or even spawn a message loop and exchange window messages. Or, you could take a cross-platform approach and use sockets. You might try to Google for "python ipc"; I found a couple of good hits in the first couple of pages. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gerdusvanzyl at gmail.com Mon Feb 18 22:23:17 2008 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Mon, 18 Feb 2008 23:23:17 +0200 Subject: [python-win32] message queueing between processes In-Reply-To: <47B9C5F9.2010409@probo.com> References: <454195.16135.qm@web28303.mail.ukl.yahoo.com> <47B9C5F9.2010409@probo.com> Message-ID: <91882ea90802181323q41144c44sdf7a6ad4db9ed658@mail.gmail.com> Try one of these: (in order of my preference) http://datamining.anu.edu.au/~ole/pypar/ http://www.parallelpython.com/ http://www.its.caltech.edu/~astraw/seppo.html http://www-users.cs.york.ac.uk/~aw/pylinda/ They exist on a higher level than pure IPC in that running a master server, spawning clients and message passing is already integrated. Depends on your use case of course. ~Gerdus On Feb 18, 2008 7:52 PM, Tim Roberts wrote: > Sagar Khushalani wrote: > > i have 5 processes. out of these, i need 1 to start a queue that can > > be shared between the other 4. 2 of them will add messages to the > > queue and 2 will read and remove off of it. any ideas? i'm a little > > confused how to share the queue between them. > > The Python "Queue" module is designed for communicating between threads > of a single process. It relies on a common memory space. > > For interprocess communication, you'll need to use a different scheme. > On Windows, you can try to use a named pipe or a mailslot, or even spawn > a message loop and exchange window messages. Or, you could take a > cross-platform approach and use sockets. > > You might try to Google for "python ipc"; I found a couple of good hits > in the first couple of pages. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From Andrew.MacIntyre at acma.gov.au Tue Feb 19 00:38:43 2008 From: Andrew.MacIntyre at acma.gov.au (Andrew MacIntyre) Date: Tue, 19 Feb 2008 10:38:43 +1100 Subject: [python-win32] gc does not free memory [SEC=PERSONAL] References: <58b84f8e0802172322u2fab0bccp2847c791f61e486@mail.gmail.com> Message-ID: <7B01D7143C4AD54899EA079D4557562A5CDBE7@ACT01EXC02.internal.govt> > I am trying to understand Python's garbage collection mechanism. I > have a long running program (actually a shell > extension) that needs to allocate large arrays occasionally, which I'd > del after use, then call > gc.collect() to collect them. But although gc.get_objects() reported > the arrays have been collected (also confirmed they didn't end up in > gc.garbage), but the memory footprint (VM > size) remain the same, as if the memory was never freed and return to > heap. > > Appreciate if anyone can help shed some light on this. Google didn't > hit much useful websites on this topic. FYI, I am using ActivePython > 2.5 on XP SP2. Thanks. You need to be a bit more specific about what you're doing to get detailed information. Some things to remember about memory consumption, taking into account you're using Python 2.5: - make sure that you aren't keeping unnecessary references (only cyclic references show up in the gc as potential garbage) - if by array you mean list or tuple, be aware that the members of these structures are independent objects in their own right. arrays created using the array module store all members internally. this difference matters if your members are floats or ints. - int and float objects use a free list structure for deleted objects which is never pruned, so allocating large numbers of these objects and deleting them will leave memory in the free list that is not returned to the OS until the interpreter exits. additionally, only integers in the range -5..256 (IIRC) are shared; for all other integer values, multiple objects can exist with the same value. - while most small Python objects (those occupying <=256 bytes, except ints and floats) are managed through Python's internal memory allocator this allocator uses 256kB arenas which are only returned when completely unused. this allocator only moves objects in memory when resizing an object, so usage patterns exist which can result in no arenas being free'ed even with most memory unused. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre National Licensing and Allocations Branch tel: +61 2 6219 5356 Inputs to Industry Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: andrew.macintyre at acma.gov.au If you have received this email in error, please notify the sender immediately and erase all copies of the email and any attachments to it. The information contained in this email and any attachments may be private, confidential and legally privileged or the subject of copyright. If you are not the addressee it may be illegal to review, disclose, use, forward, or distribute this email and/or its contents. Unless otherwise specified, the information in the email and any attachments is intended as a guide only and should not be relied upon as legal or technical advice or regarded as a substitute for legal or technical advice in individual cases. Opinions contained in this email or any of its attachments do not necessarily reflect the opinions of ACMA. From s.khushalani at yahoo.co.uk Mon Feb 18 21:02:22 2008 From: s.khushalani at yahoo.co.uk (Sagar Khushalani) Date: Mon, 18 Feb 2008 20:02:22 +0000 (GMT) Subject: [python-win32] error Message-ID: <691545.4736.qm@web28315.mail.ukl.yahoo.com> I'm using wxPython and the processing module. I create a "main" file which has a gui with buttons. Each button creates starts a separate process. However, when I click any of the buttons, I get an stderr/stdout box from wxPython with the following error. I checked online, and found some similar errors that are related to bugs, but they were not exactly the same. Has anyone had the same problem? Traceback (most recent call last): File "C:\Homework\Python\main.py", line 54, in startP1 p1.start() File "C:\Python25\Lib\site-packages\processing\process.py", line 111, in start self._popen = Popen(self, self._stoppable) File "C:\Python25\Lib\site-packages\processing\process.py", line 393, in __init__ creationflags=new_console and CREATE_NEW_PROCESS_GROUP File "C:\Python25\lib\subprocess.py", line 586, in __init__ errread, errwrite) = self._get_handles(stdin, stdout, stderr) File "C:\Python25\lib\subprocess.py", line 715, in _get_handles c2pwrite = self._make_inheritable(c2pwrite) File "C:\Python25\lib\subprocess.py", line 744, in _make_inheritable DUPLICATE_SAME_ACCESS) WindowsError: [Error 6] The handle is invalid I get this error regardless of whether I run it from IDLE or from the DOS prompt. Help -S Sagar Khushalani Graduate Student, UTA Networking / Systems and Architecture s.khushalani at yahoo.co.uk http://www.sagark.info --------------------------------- 5, 50, 500, 5000 - Store N number of mails in your inbox. Click here. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080218/7ceeaea0/attachment.htm From antonyjoseph89 at gmail.com Tue Feb 19 08:51:23 2008 From: antonyjoseph89 at gmail.com (Antony Joseph) Date: Tue, 19 Feb 2008 13:21:23 +0530 Subject: [python-win32] how to set outlook/thunderbird as default e-mail client . Message-ID: hi How to set outlook or Thunderbird as a default e-mail client in windows. Any help.pls Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080219/3c3d7d14/attachment.htm From timr at probo.com Tue Feb 19 18:53:45 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 19 Feb 2008 09:53:45 -0800 Subject: [python-win32] error In-Reply-To: <691545.4736.qm@web28315.mail.ukl.yahoo.com> References: <691545.4736.qm@web28315.mail.ukl.yahoo.com> Message-ID: <47BB17A9.1030502@probo.com> Sagar Khushalani wrote: > I'm using wxPython and the processing module. I create a "main" file > which has a gui with buttons. Each button creates starts a separate > process. However, when I click any of the buttons, I get an > stderr/stdout box from wxPython with the following error. I checked > online, and found some similar errors that are related to bugs, but > they were not exactly the same. Has anyone had the same problem? > > Traceback (most recent call last): > File "C:\Homework\Python\main.py", line 54, in startP1 > p1.start() > File "C:\Python25\Lib\site-packages\processing\process.py", line > 111, in start > self._popen = Popen(self, self._stoppable) > File "C:\Python25\Lib\site-packages\processing\process.py", line > 393, in __init__ > creationflags=new_console and CREATE_NEW_PROCESS_GROUP > File "C:\Python25\lib\subprocess.py", line 586, in __init__ > errread, errwrite) = self._get_handles(stdin, stdout, stderr) > File "C:\Python25\lib\subprocess.py", line 715, in _get_handles > c2pwrite = self._make_inheritable(c2pwrite) > File "C:\Python25\lib\subprocess.py", line 744, in _make_inheritable > DUPLICATE_SAME_ACCESS) > WindowsError: [Error 6] The handle is invalid > I get this error regardless of whether I run it from IDLE or from the > DOS prompt. By default, a Windows GUI application does not have stdin (or stdout or stderr, but wxPython can provide those). The files are not created, so the handles are invalid. You might try something like this: sys.stdin = open('nul','rb') If that doesn't work, try asking on the wxPython mailing list. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Tue Feb 19 18:55:07 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 19 Feb 2008 09:55:07 -0800 Subject: [python-win32] how to set outlook/thunderbird as default e-mail client . In-Reply-To: References: Message-ID: <47BB17FB.5080806@probo.com> Antony Joseph wrote: > > How to set outlook or Thunderbird as a default e-mail client in windows. > Any help.pls This question is not related to Python in any way. Google is your friend. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ladymcse2000 at gmail.com Wed Feb 20 07:32:17 2008 From: ladymcse2000 at gmail.com (Becky Mcquilling) Date: Tue, 19 Feb 2008 22:32:17 -0800 Subject: [python-win32] Using Python and WMI for multiple machines Message-ID: I'm new to Python and wanted to do what is a pretty routine and common admin function, simple enough in VBScript, but wanted to try it in Python as well. I'm having troulbe working it out on my own. Here goes: I have a text file c:\servernames.txt. I want the script to read from that file, each line being a different machine name, then give me a list of the services on the machine and the state, write the result to a log file. The wmi part is easy to produce, on a single machine, it's stripping the contents from a text file one at a time and then logging it to a file, that I havne't gotten quite right. I'm sure this is pretty simple for most of you, I just can't quite seem to get it. bmcquill -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080219/85fe4040/attachment.htm From tojo2000 at gmail.com Wed Feb 20 07:55:31 2008 From: tojo2000 at gmail.com (Tim Johnson) Date: Tue, 19 Feb 2008 22:55:31 -0800 Subject: [python-win32] Using Python and WMI for multiple machines In-Reply-To: References: Message-ID: <5394762f0802192255n6ebc2e00se7fefd85d6040183@mail.gmail.com> You mean something like this? servers = file('serverfile.txt') for server in servers.readlines(): servername = server.rstrip() MyWmiFunction(servername) On Feb 19, 2008 10:32 PM, Becky Mcquilling wrote: > I'm new to Python and wanted to do what is a pretty routine and common > admin function, simple enough in VBScript, but wanted to try it in Python > as well. I'm having troulbe working it out on my own. > > Here goes: > > I have a text file c:\servernames.txt. I want the script to read from > that file, each line being a different machine name, then give me a list of > the services on the machine and the state, write the result to a log file. > > The wmi part is easy to produce, on a single machine, it's stripping the > contents from a text file one at a time and then logging it to a file, that > I havne't gotten quite right. > > I'm sure this is pretty simple for most of you, I just can't quite seem to > get it. > > bmcquill > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- _____________________ Ceci n'est pas un email. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080219/7e183962/attachment.htm From mail at timgolden.me.uk Wed Feb 20 10:04:37 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 20 Feb 2008 09:04:37 +0000 Subject: [python-win32] Using Python and WMI for multiple machines In-Reply-To: References: Message-ID: <47BBED25.1000401@timgolden.me.uk> Becky Mcquilling wrote: > I'm new to Python and wanted to do what is a pretty routine and common admin > function, simple enough in VBScript, but wanted to try it in Python as > well. I'm having troulbe working it out on my own. Welcome to Python! > I have a text file c:\servernames.txt. I want the script to read from that > file, each line being a different machine name, then give me a list of the > services on the machine and the state, write the result to a log file. Reading lines from a file is easy enough. My own preference is this: servers = open ("c:/servernames.txt").read ().splitlines () because it strips off the trailing line feeds, but there are several alternatives. > The wmi part is easy to produce, on a single machine, it's stripping the > contents from a text file one at a time and then logging it to a file, that > I havne't gotten quite right. It's not entirely clear what you want to log and to how many files, but assuming that: a) You're using the wmi module from: http://timgolden.me.uk/python/wmi.html b) You have a list of servers in c:\servernames.txt c) You want the list of services from each machine to go into a file called -services.log then this code should at least give you an outline: One caveat: because in Python, as in other languages, the backslash acts as a special-character escape, you either need to double them up in Windows filenames, ("c:\\server...") or use raw strings (r"c:\server..") or use forward slashes ("c:/server...") import wmi servers = open ("c:/servernames.txt").read ().splitlines () for server in servers: wmi_connection = wmi.WMI (server) with open ("%s-services.log" % server, "w") as f: for service in wmi_connection.Win32_Service (): f.write ("%s\t%s\n" % (service.Caption, service.State)) HTH TJG From mauro.tiz at gmail.com Wed Feb 20 16:47:46 2008 From: mauro.tiz at gmail.com (mauro tizianel) Date: Wed, 20 Feb 2008 16:47:46 +0100 Subject: [python-win32] Help with COM objs across threads: The object exporter specified was not found Message-ID: Dear list, I wrote a small class which has some COM objects among its attributes. I need to access the object from different threads so I defined two methods to marshal and unmarshal the interfaces when working with the object. Everything seemed to work fine on my PC, never had an error. But I distributed the module to a user and I have been told that after a few threads successfully exiting (can be two or hundreds...) something goes wrong in "unMarshal" and Exception occurred ((-2147022986, 'Der angegebene Objektexporter wurde nicht gefunden.', None, None)) is reported (it took me a while to figure out that this is: 0x00000776 - 1910 The object exporter specified was not found). Then, but that's obvious, I get Exception occurred ((-2147417827, 'Das Schnittstellendatenpaket (Marshall/OBJREF) hat ein ung?ltiges oder unbekanntes Format.', None, None)) when I try to marshal (unknown or invalid format). Since I cannot reproduce the exception I was not able neither to locate exactly where the exception occurs, nor to find the reason (the only difference is that I am administrator on my machine and he is not). Before modifying the code to deal with the exception, (here's the request for help) I would need help to figure out if I am doing things the wrong way with threads (I am new to COM and not a software developer) or such exceptions 'just occurs sometimes'. Thanks, Mauro class AppInterface(object): def __init__(self): self.fmApp = win32com.client.Dispatch("Whatever.Application") self.fmProject = self.fmApp.Project("Newproject") def marshal(self): self.fmAppStream = pythoncom.CoMarshalInterThreadInterfaceInStream( pythoncom.IID_IDispatch, self.fmApp._oleobj_) self.fmProjectStream = pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch, self.fmProject._oleobj_) def unMarshal(self): idispatch = pythoncom.CoGetInterfaceAndReleaseStream( self.fmAppStream, pythoncom.IID_IDispatch) self.fmApp = win32com.client.Dispatch(idispatch) idispatch = pythoncom.CoGetInterfaceAndReleaseStream( self.fmProjectStream, pythoncom.IID_IDispatch) self.fmProject = win32com.client.Dispatch(idispatch) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080220/634705c0/attachment.htm From kevin.horn at gmail.com Wed Feb 20 22:09:12 2008 From: kevin.horn at gmail.com (Kevin Horn) Date: Wed, 20 Feb 2008 15:09:12 -0600 Subject: [python-win32] Fwd: Using Python and WMI for multiple machines In-Reply-To: <562bcc10802201307v63472d75h6d35d9c5294edfb0@mail.gmail.com> References: <47BBED25.1000401@timgolden.me.uk> <562bcc10802201307v63472d75h6d35d9c5294edfb0@mail.gmail.com> Message-ID: <562bcc10802201309u25a556b6u31d757f7c55b9e6d@mail.gmail.com> On Feb 20, 2008 3:04 AM, Tim Golden wrote: > Becky Mcquilling wrote: > > I'm new to Python and wanted to do what is a pretty routine and common > admin > > function, simple enough in VBScript, but wanted to try it in Python as > > well. I'm having troulbe working it out on my own. > > Welcome to Python! > > > I have a text file c:\servernames.txt. I want the script to read from > that > > file, each line being a different machine name, then give me a list of > the > > services on the machine and the state, write the result to a log file. > > Reading lines from a file is easy enough. My own preference > is this: > > servers = open ("c:/servernames.txt").read ().splitlines () > > because it strips off the trailing line feeds, but there > are several alternatives. > > > The wmi part is easy to produce, on a single machine, it's stripping the > > contents from a text file one at a time and then logging it to a file, > that > > I havne't gotten quite right. > > It's not entirely clear what you want to log and to how many files, but > assuming that: > > a) You're using the wmi module from: > http://timgolden.me.uk/python/wmi.html > > b) You have a list of servers in c:\servernames.txt > > c) You want the list of services from each machine > to go into a file called -services.log > > then this code should at least give you an outline: > > One caveat: because in Python, as in other languages, > the backslash acts as a special-character escape, you > either need to double them up in Windows filenames, > ("c:\\server...") or use raw strings (r"c:\server..") > or use forward slashes ("c:/server...") > > > import wmi > > servers = open ("c:/servernames.txt").read ().splitlines () > for server in servers: > wmi_connection = wmi.WMI (server) > with open ("%s-services.log" % server, "w") as f: > for service in wmi_connection.Win32_Service (): > f.write ("%s\t%s\n" % (service.Caption, service.State)) > > > > HTH > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > Note that the above code will only work under Python 2.5, since that's when the "with" statement was added. (Some of us are still stuck in 2.4 land :) ) In 2.4 and earlier, it could look something more like: import wmi servers = open ("c:/servernames.txt").read ().splitlines () for server in servers: wmi_connection = wmi.WMI (server) f = open ("%s-services.log" % server, "w") for service in wmi_connection.Win32_Service (): f.write ("%s\t%s\n" % (service.Caption, service.State)) f.close() Kevin Horn -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080220/bbdde928/attachment.htm From mhammond at skippinet.com.au Wed Feb 20 22:56:25 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 21 Feb 2008 08:56:25 +1100 Subject: [python-win32] Help with COM objs across threads: The object exporter specified was not found In-Reply-To: References: Message-ID: <014101c8740b$732388b0$596a9a10$@com.au> I can?t see how this class is used, but it is slightly suspect, in the fact it stores the result of the unmarshal in ?self.fmProject? ? but there is nothing to prevent other threads from using self.fmProject, which would be an error. Unless something not shown prevents this happening, you need to avoid storing the result of the unmarshal anywhere than in variables local to a function and passed around as a param (or maybe using something like threading.local() to help with this. Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of mauro tizianel Sent: Thursday, 21 February 2008 2:48 AM To: python-win32 at python.org Subject: [python-win32] Help with COM objs across threads: The object exporter specified was not found Dear list, I wrote a small class which has some COM objects among its attributes. I need to access the object from different threads so I defined two methods to marshal and unmarshal the interfaces when working with the object. Everything seemed to work fine on my PC, never had an error. But I distributed the module to a user and I have been told that after a few threads successfully exiting (can be two or hundreds...) something goes wrong in "unMarshal" and Exception occurred ((-2147022986, 'Der angegebene Objektexporter wurde nicht gefunden.', None, None)) is reported (it took me a while to figure out that this is: 0x00000776 - 1910 The object exporter specified was not found). Then, but that's obvious, I get Exception occurred ((-2147417827, 'Das Schnittstellendatenpaket (Marshall/OBJREF) hat ein ung?ltiges oder unbekanntes Format.', None, None)) when I try to marshal (unknown or invalid format). Since I cannot reproduce the exception I was not able neither to locate exactly where the exception occurs, nor to find the reason (the only difference is that I am administrator on my machine and he is not). Before modifying the code to deal with the exception, (here's the request for help) I would need help to figure out if I am doing things the wrong way with threads (I am new to COM and not a software developer) or such exceptions 'just occurs sometimes'. Thanks, Mauro class AppInterface(object): def __init__(self): self.fmApp = win32com.client.Dispatch("Whatever.Application") self.fmProject = self.fmApp.Project("Newproject") def marshal(self): self.fmAppStream = pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch, self.fmApp._oleobj_) self.fmProjectStream = pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch, self.fmProject._oleobj_) def unMarshal(self): idispatch = pythoncom.CoGetInterfaceAndReleaseStream(self.fmAppStream, pythoncom.IID_IDispatch) self.fmApp = win32com.client.Dispatch(idispatch) idispatch = pythoncom.CoGetInterfaceAndReleaseStream(self.fmProjectStream, pythoncom.IID_IDispatch) self.fmProject = win32com.client.Dispatch(idispatch) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080221/c08a010c/attachment.htm From s.khushalani at yahoo.co.uk Thu Feb 21 06:01:23 2008 From: s.khushalani at yahoo.co.uk (Sagar Khushalani) Date: Thu, 21 Feb 2008 05:01:23 +0000 (GMT) Subject: [python-win32] error In-Reply-To: <47BB17A9.1030502@probo.com> Message-ID: <644071.9649.qm@web28303.mail.ukl.yahoo.com> Thanks! Another question, related and random. Someone, anyone? I am trying to implement an MSMQ, and I have no idea whats going wrong. I looked at: http://comsci.liu.edu/~murali/python/python28.txt one of the few places that actually has help with that. I tried to implement it but for some reason it didnt work. I even tried just the Example #1, and even that didnt work. I have attached the error in the text file.I know its a long error, but I can't find any decent documentation on win32com and MSMQs. This is the same error I get when I tried my own program. In the main file, I put this: queueinfo = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") queueinfo.PathName = ".\\private$\ErrorQueue" queue = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") and I have the Open and rest of the stuff in another file which is a different process and adds/removes stuff from it. queueinfo = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") queueinfo.PathName = ".\\private$\ErrorQueue" queue = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") msg = win32com.client.Dispatch("MSMQ.MSMQMessage") if eval(sec)%2 == 0: self.txtArea.WriteText("Service is up and running\n") msg.Label = "ON" msg.Body = "P1:UP" msg.Send(self.errors) else: self.txtArea.WriteText("Error! Writing message to queue. Service is down\n") msg.Label = "ERROR" msg.Body = "P1:DOWN" msg.Send(self.errors) self.errors.Close() Please help me. I'm very confused. Tim Roberts wrote: Sagar Khushalani wrote: > I'm using wxPython and the processing module. I create a "main" file > which has a gui with buttons. Each button creates starts a separate > process. However, when I click any of the buttons, I get an > stderr/stdout box from wxPython with the following error. I checked > online, and found some similar errors that are related to bugs, but > they were not exactly the same. Has anyone had the same problem? > > Traceback (most recent call last): > File "C:\Homework\Python\main.py", line 54, in startP1 > p1.start() > File "C:\Python25\Lib\site-packages\processing\process.py", line > 111, in start > self._popen = Popen(self, self._stoppable) > File "C:\Python25\Lib\site-packages\processing\process.py", line > 393, in __init__ > creationflags=new_console and CREATE_NEW_PROCESS_GROUP > File "C:\Python25\lib\subprocess.py", line 586, in __init__ > errread, errwrite) = self._get_handles(stdin, stdout, stderr) > File "C:\Python25\lib\subprocess.py", line 715, in _get_handles > c2pwrite = self._make_inheritable(c2pwrite) > File "C:\Python25\lib\subprocess.py", line 744, in _make_inheritable > DUPLICATE_SAME_ACCESS) > WindowsError: [Error 6] The handle is invalid > I get this error regardless of whether I run it from IDLE or from the > DOS prompt. By default, a Windows GUI application does not have stdin (or stdout or stderr, but wxPython can provide those). The files are not created, so the handles are invalid. You might try something like this: sys.stdin = open('nul','rb') If that doesn't work, try asking on the wxPython mailing list. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 Sagar Khushalani Graduate Student, UTA Networking / Systems and Architecture s.khushalani at yahoo.co.uk http://www.sagark.info --------------------------------- Yahoo! Answers - Get better answers from someone who knows. Try it now. Sagar Khushalani Graduate Student, UTA Networking / Systems and Architecture s.khushalani at yahoo.co.uk http://www.sagark.info --------------------------------- Support the World Aids Awareness campaign this month with Yahoo! for Good -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080221/8bd59ab3/attachment-0001.htm -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: error.txt Url: http://mail.python.org/pipermail/python-win32/attachments/20080221/8bd59ab3/attachment-0001.txt From graemeglass at gmail.com Thu Feb 21 07:35:22 2008 From: graemeglass at gmail.com (Graeme Glass) Date: Thu, 21 Feb 2008 08:35:22 +0200 Subject: [python-win32] Fwd: Using Python and WMI for multiple machines In-Reply-To: <562bcc10802201309u25a556b6u31d757f7c55b9e6d@mail.gmail.com> References: <47BBED25.1000401@timgolden.me.uk> <562bcc10802201307v63472d75h6d35d9c5294edfb0@mail.gmail.com> <562bcc10802201309u25a556b6u31d757f7c55b9e6d@mail.gmail.com> Message-ID: > import wmi > > > > servers = open ("c:/servernames.txt").read ().splitlines () > > for server in servers: > > wmi_connection = wmi.WMI (server) > > with open ("%s-services.log" % server, "w") as f: > > for service in wmi_connection.Win32_Service (): > > f.write ("%s\t%s\n" % (service.Caption, service.State)) > > > > > > > > HTH > > TJG > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > Note that the above code will only work under Python 2.5, since that's > when the "with" statement was added. > > (Some of us are still stuck in 2.4 land :) ) > > If I am not mistaken, you can use the with statement with python 2.4 from __future__ import with_statement -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080221/fbf7a380/attachment.htm From graemeglass at gmail.com Thu Feb 21 07:44:28 2008 From: graemeglass at gmail.com (Graeme Glass) Date: Thu, 21 Feb 2008 08:44:28 +0200 Subject: [python-win32] Fwd: Using Python and WMI for multiple machines In-Reply-To: References: <47BBED25.1000401@timgolden.me.uk> <562bcc10802201307v63472d75h6d35d9c5294edfb0@mail.gmail.com> <562bcc10802201309u25a556b6u31d757f7c55b9e6d@mail.gmail.com> Message-ID: > If I am not mistaken, you can use the with statement with python 2.4 > > from __future__ import with_statement > > > Um, forget that. That is 2.5 like you said. Sorry. Don't have 2.4 installed anymore to test my brain farts before sending them on. *Jedi mind trick* You never saw this mail -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080221/c5f1e93e/attachment.htm From mail at timgolden.me.uk Thu Feb 21 09:10:52 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 21 Feb 2008 08:10:52 +0000 Subject: [python-win32] Fwd: Using Python and WMI for multiple machines In-Reply-To: <562bcc10802201309u25a556b6u31d757f7c55b9e6d@mail.gmail.com> References: <47BBED25.1000401@timgolden.me.uk> <562bcc10802201307v63472d75h6d35d9c5294edfb0@mail.gmail.com> <562bcc10802201309u25a556b6u31d757f7c55b9e6d@mail.gmail.com> Message-ID: <47BD320C.6050001@timgolden.me.uk> Kevin Horn wrote: > On Feb 20, 2008 3:04 AM, Tim Golden wrote: [... snip Python 2.5+ code example ...] > Note that the above code will only work under Python 2.5, since that's when > the "with" statement was added. > > (Some of us are still stuck in 2.4 land :) ) > > In 2.4 and earlier, it could look something more like: [...] Thanks for picking that up, Kevin. I'm normally quite conservative in my examples but for some reason I've been doing quite a bit of "with..." code recently, and it just came more naturally to my fingers! TJG From s.khushalani at yahoo.co.uk Thu Feb 21 06:55:46 2008 From: s.khushalani at yahoo.co.uk (Sagar Khushalani) Date: Thu, 21 Feb 2008 05:55:46 +0000 (GMT) Subject: [python-win32] error In-Reply-To: <644071.9649.qm@web28303.mail.ukl.yahoo.com> Message-ID: <229287.49809.qm@web28314.mail.ukl.yahoo.com> that was the error for the example from the website. here it the error for my program. Traceback (most recent call last): File "C:\Homework\Python\main.py", line 73, in main() File "C:\Homework\Python\main.py", line 68, in main queueinfo = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221164, 'Class not registered', None, None) Sagar Khushalani wrote: Thanks! Another question, related and random. Someone, anyone? I am trying to implement an MSMQ, and I have no idea whats going wrong. I looked at: http://comsci.liu.edu/~murali/python/python28.txt one of the few places that actually has help with that. I tried to implement it but for some reason it didnt work. I even tried just the Example #1, and even that didnt work. I have attached the error in the text file.I know its a long error, but I can't find any decent documentation on win32com and MSMQs. This is the same error I get when I tried my own program. In the main file, I put this: queueinfo = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") queueinfo.PathName = ".\\private$\ErrorQueue" queue = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") and I have the Open and rest of the stuff in another file which is a different process and adds/removes stuff from it. queueinfo = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") queueinfo.PathName = ".\\private$\ErrorQueue" queue = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") msg = win32com.client.Dispatch("MSMQ.MSMQMessage") if eval(sec)%2 == 0: self.txtArea.WriteText("Service is up and running\n") msg.Label = "ON" msg.Body = "P1:UP" msg.Send(self.errors) else: self.txtArea.WriteText("Error! Writing message to queue. Service is down\n") msg.Label = "ERROR" msg.Body = "P1:DOWN" msg.Send(self.errors) self.errors.Close() Please help me. I'm very confused. Tim Roberts wrote: Sagar Khushalani wrote: > I'm using wxPython and the processing module. I create a "main" file > which has a gui with buttons. Each button creates starts a separate > process. However, when I click any of the buttons, I get an > stderr/stdout box from wxPython with the following error. I checked > online, and found some similar errors that are related to bugs, but > they were not exactly the same. Has anyone had the same problem? > > Traceback (most recent call last): > File "C:\Homework\Python\main.py", line 54, in startP1 > p1.start() > File "C:\Python25\Lib\site-packages\processing\process.py", line > 111, in start > self._popen = Popen(self, self._stoppable) > File "C:\Python25\Lib\site-packages\processing\process.py", line > 393, in __init__ > creationflags=new_console and CREATE_NEW_PROCESS_GROUP > File "C:\Python25\lib\subprocess.py", line 586, in __init__ > errread, errwrite) = self._get_handles(stdin, stdout, stderr) > File "C:\Python25\lib\subprocess.py", line 715, in _get_handles > c2pwrite = self._make_inheritable(c2pwrite) > File "C:\Python25\lib\subprocess.py", line 744, in _make_inheritable > DUPLICATE_SAME_ACCESS) > WindowsError: [Error 6] The handle is invalid > I get this error regardless of whether I run it from IDLE or from the > DOS prompt. By default, a Windows GUI application does not have stdin (or stdout or stderr, but wxPython can provide those). The files are not created, so the handles are invalid. You might try something like this: sys.stdin = open('nul','rb') If that doesn't work, try asking on the wxPython mailing list. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 Sagar Khushalani Graduate Student, UTA Networking / Systems and Architecture s.khushalani at yahoo.co.uk http://www.sagark.info --------------------------------- Yahoo! Answers - Get better answers from someone who knows. Try it now. Sagar Khushalani Graduate Student, UTA Networking / Systems and Architecture s.khushalani at yahoo.co.uk http://www.sagark.info --------------------------------- Support the World Aids Awareness campaign this month with Yahoo! for Good Traceback (most recent call last): File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 307, in RunScript debugger.run(codeObject, __main__.__dict__, start_stepping=0) File "C:\Python25\Lib\site-packages\pythonwin\pywin\debugger\__init__.py", line 60, in run _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) File "C:\Python25\Lib\site-packages\pythonwin\pywin\debugger\debugger.py", line 631, in run exec cmd in globals, locals File "C:\Homework\Python\test.py", line 12, in qinfo=win32com.client.Dispatch("MSMQ.MSMQQueueInfo") File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221164, 'Class not registered', None, None)_______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 Sagar Khushalani Graduate Student, UTA Networking / Systems and Architecture s.khushalani at yahoo.co.uk http://www.sagark.info --------------------------------- Yahoo! Answers - Get better answers from someone who knows. Tryit now. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080221/9d0d0ba3/attachment.htm From simon.dahlbacka at gmail.com Thu Feb 21 09:34:00 2008 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Thu, 21 Feb 2008 10:34:00 +0200 Subject: [python-win32] error In-Reply-To: <229287.49809.qm@web28314.mail.ukl.yahoo.com> References: <644071.9649.qm@web28303.mail.ukl.yahoo.com> <229287.49809.qm@web28314.mail.ukl.yahoo.com> Message-ID: <57124720802210034j618b6534xa711225137c7a6ba@mail.gmail.com> Let's start with the obvious, you *do* have the MSMQ stuff installed? /Simon 2008/2/21, Sagar Khushalani : > > that was the error for the example from the website. > here it the error for my program. > > Traceback (most recent call last): > File "C:\Homework\Python\main.py", line 73, in > main() > File "C:\Homework\Python\main.py", line 68, in main > queueinfo = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") > File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line > 95, in Dispatch > dispatch, userName = > dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line > 98, in _GetGoodDispatchAndUserName > return (_GetGoodDispatch(IDispatch, clsctx), userName) > File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line > 78, in _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > pythoncom.IID_IDispatch) > com_error: (-2147221164, 'Class not registered', None, None) > > *Sagar Khushalani * wrote: > > Thanks! Another question, related and random. Someone, anyone? > > I am trying to implement an MSMQ, and I have no idea whats going wrong. I > looked at: > > http://comsci.liu.edu/~murali/python/python28.txt > > one of the few places that actually has help with that. I tried to > implement it but for some reason it didnt work. I even tried just the > Example #1, and even that didnt work. I have attached the error in the text > file.I know its a long error, but I can't find any decent documentation on > win32com and MSMQs. This is the same error I get when I tried my own > program. In the main file, I put this: > > queueinfo = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") > queueinfo.PathName = ".\\private$\ErrorQueue" > queue = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") > > and I have the Open and rest of the stuff in another file which is a > different process and adds/removes stuff from it. > > queueinfo = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") > queueinfo.PathName = ".\\private$\ErrorQueue" > queue = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") > > msg = win32com.client.Dispatch("MSMQ.MSMQMessage") > if eval(sec)%2 == 0: > self.txtArea.WriteText("Service is up and running\n") > msg.Label = "ON" > msg.Body = "P1:UP" > msg.Send(self.errors) > else: > self.txtArea.WriteText("Error! Writing message to queue. > Service is down\n") > msg.Label = "ERROR" > msg.Body = "P1:DOWN" > msg.Send(self.errors) > self.errors.Close() > > Please help me. I'm very confused. > > > > *Tim Roberts * wrote: > > Sagar Khushalani wrote: > > I'm using wxPython and the processing module. I create a "main" file > > which has a gui with buttons. Each button creates starts a separate > > process. However, when I click any of the buttons, I get an > > stderr/stdout box from wxPython with the following error. I checked > > online, and found some similar errors that are related to bugs, but > > they were not exactly the same. Has anyone had the same problem? > > > > Traceback (most recent call last): > > File "C:\Homework\Python\main.py", line 54, in startP1 > > p1.start() > > File "C:\Python25\Lib\site-packages\processing\process.py", line > > 111, in start > > self._popen = Popen(self, self._stoppable) > > File "C:\Python25\Lib\site-packages\processing\process.py", line > > 393, in __init__ > > creationflags=new_console and CREATE_NEW_PROCESS_GROUP > > File "C:\Python25\lib\subprocess.py", line 586, in __init__ > > errread, errwrite) = self._get_handles(stdin, stdout, stderr) > > File "C:\Python25\lib\subprocess.py", line 715, in _get_handles > > c2pwrite = self._make_inheritable(c2pwrite) > > File "C:\Python25\lib\subprocess.py", line 744, in _make_inheritable > > DUPLICATE_SAME_ACCESS) > > WindowsError: [Error 6] The handle is invalid > > I get this error regardless of whether I run it from IDLE or from the > > DOS prompt. > > By default, a Windows GUI application does not have stdin (or stdout or > stderr, but wxPython can provide those). The files are not created, so > the handles are invalid. > > You might try something like this: > sys.stdin = open('nul','rb') > If that doesn't work, try asking on the wxPython mailing list. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > > > *Sagar Khushalani* > Graduate Student, UTA > Networking / Systems and Architecture > s.khushalani at yahoo.co.uk > http://www.sagark.info > ------------------------------ > Yahoo! Answers - Get better answers from someone who knows. Try it now > . > > *Sagar Khushalani* > Graduate Student, UTA > Networking / Systems and Architecture > s.khushalani at yahoo.co.uk > http://www.sagark.info > ------------------------------ > Support the World Aids Awareness campaign this month with Yahoo! for GoodTraceback (most recent call last): > File > "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", > line 307, in RunScript > debugger.run(codeObject, __main__.__dict__, start_stepping=0) > File "C:\Python25\Lib\site-packages\pythonwin\pywin\debugger\__init__.py", > line 60, in run > _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) > File "C:\Python25\Lib\site-packages\pythonwin\pywin\debugger\debugger.py", > line 631, in run > exec cmd in globals, locals > File "C:\Homework\Python\test.py", line 12, in > qinfo=win32com.client.Dispatch("MSMQ.MSMQQueueInfo") > File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line 95, > in Dispatch > dispatch, userName = > dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 98, > in _GetGoodDispatchAndUserName > return (_GetGoodDispatch(IDispatch, clsctx), userName) > File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 78, > in _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > pythoncom.IID_IDispatch) > com_error: (-2147221164, 'Class not registered', None, > None)_______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > > > *Sagar Khushalani* > Graduate Student, UTA > Networking / Systems and Architecture > s.khushalani at yahoo.co.uk > http://www.sagark.info > > ------------------------------ > Yahoo! Answers - Get better answers from someone who knows. Try it now > . > > > _______________________________________________ > 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/20080221/8439f75e/attachment-0001.htm From chinux at gmail.com Thu Feb 21 17:20:46 2008 From: chinux at gmail.com (Chen) Date: Thu, 21 Feb 2008 11:20:46 -0500 Subject: [python-win32] Data Type Conversion in Python Win32 COM Message-ID: Hello, I have a question regarding to how Data type is being converted into COM object. For example, there is a function A in one COM object that requires an Unsigned 32 bit Integer as a parameter. How could I pass a Long Integer in python to Function A. I found that if the parameter is smaller or equal to ( 2^31 -1 ), the parameter is correctly passed to Function A. Any value that bigger than ( 2 ^31 - 1) will be interpreted as 0xFFFFFFFF. Does Python Win32 COM has its own data conversion if the data type of the passed parameter is different from the data type of the required parameter. If yes, how python win32 COM does the conversion? Thanks Chen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080221/ac494402/attachment.htm From s.khushalani at yahoo.co.uk Thu Feb 21 19:37:43 2008 From: s.khushalani at yahoo.co.uk (Sagar Khushalani) Date: Thu, 21 Feb 2008 18:37:43 +0000 (GMT) Subject: [python-win32] error Message-ID: <518333.53132.qm@web28301.mail.ukl.yahoo.com> wow thank you! i know its a stupid mistake but i've been really busy and didnt notice that. solved :D thanks a lot!! Simon Dahlbacka wrote: Let's start with the obvious, you *do* have the MSMQ stuff installed? /Simon 2008/2/21, Sagar Khushalani : that was the error for the example from the website. here it the error for my program. Sagar Khushalani Graduate Student, UTA Networking / Systems and Architecture s.khushalani at yahoo.co.uk http://www.sagark.info --------------------------------- Sent from Yahoo! Mail. A Smarter Inbox. Sagar Khushalani Graduate Student, UTA Networking / Systems and Architecture s.khushalani at yahoo.co.uk http://www.sagark.info --------------------------------- Sent from Yahoo! Mail. A Smarter Inbox. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080221/0f9d633c/attachment.htm From timr at probo.com Thu Feb 21 19:49:03 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 21 Feb 2008 10:49:03 -0800 Subject: [python-win32] error In-Reply-To: <644071.9649.qm@web28303.mail.ukl.yahoo.com> References: <644071.9649.qm@web28303.mail.ukl.yahoo.com> Message-ID: <47BDC79F.3040203@probo.com> Sagar Khushalani wrote: > one of the few places that actually has help with that. I tried to > implement it but for some reason it didnt work. I even tried just the > Example #1, and even that didnt work. I have attached the error in the > text file.I know its a long error, but I can't find any decent > documentation on win32com and MSMQs. This is the same error I get when > I tried my own program. In the main file, I put this: > > queueinfo = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") > queueinfo.PathName = ".\\private$\ErrorQueue" That string does not say what you think it says. You need either: queueinfo.PathName = ".\\\\private$\\ErrorQueue" or queueinfo.PathName = r".\\private$\ErrorQueue" -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Thu Feb 21 23:25:04 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 22 Feb 2008 09:25:04 +1100 Subject: [python-win32] Data Type Conversion in Python Win32 COM In-Reply-To: References: Message-ID: <022601c874d8$9dbce760$d936b620$@com.au> Pythoncom does its conversions in oleargs.cpp in the source tree. My guess is that we are hitting a path causing one of the "*_AsLong" or similar functions to fail, returning -1, but we don't check that error condition. However, the best I can tell, the test suite does try and cover these cases (see win32com\test\testpycomtest.py and search for "ulong"). Also, things behave differently based on whether typeinfo is available - if it is not, Python "guesses" about the variant type based on the python type, but if it is known, python attempts to convert the python value to the requested type. Can you provide any more info, or suggest how testpycomtest could be modified to demonstrate the problem? Mark From: python-win32-bounces+mhammond=keypoint.com.au at python.org [mailto:python-win32-bounces+mhammond=keypoint.com.au at python.org] On Behalf Of Chen Sent: Friday, 22 February 2008 3:21 AM To: python-win32 at python.org Subject: [python-win32] Data Type Conversion in Python Win32 COM Hello, I have a question regarding to how Data type is being converted into COM object. For example, there is a function A in one COM object that requires an Unsigned 32 bit Integer as a parameter. How could I pass a Long Integer in python to Function A. I found that if the parameter is smaller or equal to ( 2^31 -1 ), the parameter is correctly passed to Function A. Any value that bigger than ( 2 ^31 - 1) will be interpreted as 0xFFFFFFFF. Does Python Win32 COM has its own data conversion if the data type of the passed parameter is different from the data type of the required parameter. If yes, how python win32 COM does the conversion? Thanks Chen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080222/f53ae23c/attachment.htm From MSmith at carilion.com Fri Feb 22 15:23:51 2008 From: MSmith at carilion.com (Mike Smith) Date: Fri, 22 Feb 2008 09:23:51 -0500 Subject: [python-win32] HTTP Server as a Windows Service Message-ID: <47BE94A6.BE67.009D.0@carilion.com> I've written the following script based on information I have found on the web. The purpose of the script is to start an HTTP listener on the machine it's running on that will give status on a particular process running on that system that can be polled by an external load balancer to determine if the host is a viable candidate for traffic to be sent to. For testing, I'm just using notepad.exe as the process I'm looking for. I've tried to create this as a service on the windows server it's running on, and it will install fine. The HTTP server starts up and provides the information I want. The problem I'm having is that the service will not stop when I tell it to. When I issue the stop request it tries to stop for a long time and throws back an error that it couldn't. Within the service control panel is just stays in a state of stopping. Any help that anyone could provide would be greatly appreciated. I'm new to python so please let me know if there is a more efficient way to do what I'm trying to do. The code follows: import win32service import win32serviceutil import wmi from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler class BlobCheck(win32serviceutil.ServiceFramework): _svc_name_ = "BlobCheck" _svc_display_name_ = "BlobCheck" def __init__(self,args): win32serviceutil.ServiceFramework.__init__(self,args) self.isAlive = True def SvcDoRun(self): import servicemanager c = wmi.WMI() while self.isAlive: class RequestHandler(BaseHTTPRequestHandler): def _writeheaders(self): self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() def do_HEAD(self): self._writeheaders() def do_GET(self): self._writeheaders() running = c.Win32_Process (name="notepad.exe") if running: self.wfile.write("""Monitor Kool-Aid!!!""") else: self.wfile.write("""Monitor Oh No!!!""") serveraddr = ('', 12345) srvr = HTTPServer(serveraddr, RequestHandler) srvr.handle_request() def SvcStop(self): import servicemanager servicemanager.LogInfoMsg("aservice - Recieved stop signal") self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) self.isAlive = False if __name__ == '__main__': win32serviceutil.HandleCommandLine(BlobCheck) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080222/02cc073b/attachment.htm From larry.bates at websafe.com Fri Feb 22 18:08:49 2008 From: larry.bates at websafe.com (Larry Bates) Date: Fri, 22 Feb 2008 11:08:49 -0600 Subject: [python-win32] Help calling IProgressDialog Interface Message-ID: I've spent all morning searching and I just can't seem to find the TypeLibrary name for this COM interface. I've searched the registry, scanned COM browser list at least a dozen times, etc. Some information about this COM object is located here: http://www.com.it-berater.org/COM/windows_shell/interfaces/IProgressDialog%20.htm It appears to be located in browseui.dll, but that didn't help either. I also tried using pythoncom.CoCreateInstance, but it reports: >>> pdlg=pythoncom.CoCreateInstance('{F8383852-FCD3-11d1-A6B9-006097DF5BD4}', No ne, 1, '{EBBC7C04-315E-11d2-B62F-006097DF5BD4}') Traceback (most recent call last): File "", line 1, in TypeError: There is no interface object registered that supports this IID I'm hoping that someone out there can assist? Thanks in advance, Larry From larry.bates at websafe.com Fri Feb 22 18:09:46 2008 From: larry.bates at websafe.com (Larry Bates) Date: Fri, 22 Feb 2008 11:09:46 -0600 Subject: [python-win32] HTTP Server as a Windows Service In-Reply-To: <47BE94A6.BE67.009D.0@carilion.com> References: <47BE94A6.BE67.009D.0@carilion.com> Message-ID: <47BF01DA.2050101@websafe.com> Mike Smith wrote: > I've written the following script based on information I have found on > the web. The purpose of the script is to start an HTTP listener on the > machine it's running on that will give status on a particular process > running on that system that can be polled by an external load balancer > to determine if the host is a viable candidate for traffic to be sent > to. For testing, I'm just using notepad.exe as the process I'm looking > for. I've tried to create this as a service on the windows server it's > running on, and it will install fine. The HTTP server starts up and > provides the information I want. The problem I'm having is that the > service will not stop when I tell it to. When I issue the stop request > it tries to stop for a long time and throws back an error that it > couldn't. Within the service control panel is just stays in a state of > stopping. Any help that anyone could provide would be greatly > appreciated. I'm new to python so please let me know if there is a more > efficient way to do what I'm trying to do. The code follows: > > import win32service > import win32serviceutil > import wmi > from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler > > class BlobCheck(win32serviceutil.ServiceFramework): > _svc_name_ = "BlobCheck" > _svc_display_name_ = "BlobCheck" > > > def __init__(self,args): > win32serviceutil.ServiceFramework.__init__(self,args) > self.isAlive = True > > def SvcDoRun(self): > import servicemanager > c = wmi.WMI() > > while self.isAlive: > class RequestHandler(BaseHTTPRequestHandler): > def _writeheaders(self): > self.send_response(200) > self.send_header('Content-type', > 'text/html') > self.end_headers() > > def do_HEAD(self): > self._writeheaders() > > def do_GET(self): > self._writeheaders() > running = c.Win32_Process > (name="notepad.exe") > if running: > > self.wfile.write("""Monitor > > Kool-Aid!!!""") > else: > > self.wfile.write("""Monitor > Oh > No!!!""") > > serveraddr = ('', 12345) > srvr = HTTPServer(serveraddr, RequestHandler) > srvr.handle_request() > > def SvcStop(self): > import servicemanager > > servicemanager.LogInfoMsg("aservice - Recieved stop > signal") > self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) > self.isAlive = False > > if __name__ == '__main__': > win32serviceutil.HandleCommandLine(BlobCheck) > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 This seems to come up about every other week. The problem is that you haven't given your service a way to KNOW that you have sent a stop signal. Below is a skeleton of a correct SvcDoRun method: def SvcDoRun(self): import servicemanager #--------------------------------------------------------------------- # Make entry in the event log that this service started #--------------------------------------------------------------------- servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, '')) self.timeout=1000 # In milliseconds (update every second) while 1: #------------------------------------------------------------------- # Wait for service stop signal, if I timeout, loop again #------------------------------------------------------------------- rc=win32event.WaitForSingleObject(self.hWaitStop, self.timeout) # # Check to see if self.hWaitStop happened # if rc == win32event.WAIT_OBJECT_0: # # Stop signal encountered # break else: # # Insert your functional code here # #--End while-- #--------------------------------------------------------------------- # Log stopped message to EventLog #--------------------------------------------------------------------- servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STOPPED, (self._svc_name_, '')) return def SvcStop(self): #--------------------------------------------------------------------- # Before we do anything, tell SCM we are beginning the stop process. #--------------------------------------------------------------------- self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) #--------------------------------------------------------------------- # And set my event #--------------------------------------------------------------------- win32event.SetEvent(self.hWaitStop) return You have to register WaitForSingleObject so that you will know that the stop signal has been sent and break out of the loop. It is also important that you "sleep" (timeout) so that other processes can run in the background. You don't want your service to take over 100% of the machine. The amount of time you set in self.timeout determines how often the loop runs. You must determine how often that will be depending on your application. You may want to invest in a book: "Python Programming On Win32" it helped me a lot when I was getting started. Note: I don't think you want to define your RequestHandler class inside SvcDoRun and instantiate the HTTPserver every time through the loop. You should just update the information on the page each time through the loop. Hope information helps. Larry From theller at ctypes.org Fri Feb 22 19:02:00 2008 From: theller at ctypes.org (Thomas Heller) Date: Fri, 22 Feb 2008 19:02:00 +0100 Subject: [python-win32] Help calling IProgressDialog Interface In-Reply-To: References: Message-ID: Larry Bates schrieb: > I've spent all morning searching and I just can't seem to find the TypeLibrary > name for this COM interface. I've searched the registry, scanned COM browser > list at least a dozen times, etc. Some information about this COM object is > located here: > > http://www.com.it-berater.org/COM/windows_shell/interfaces/IProgressDialog%20.htm > > It appears to be located in browseui.dll, but that didn't help either. > > I also tried using pythoncom.CoCreateInstance, but it reports: > > >>> pdlg=pythoncom.CoCreateInstance('{F8383852-FCD3-11d1-A6B9-006097DF5BD4}', No > ne, 1, '{EBBC7C04-315E-11d2-B62F-006097DF5BD4}') > Traceback (most recent call last): > File "", line 1, in > TypeError: There is no interface object registered that supports this IID > > I'm hoping that someone out there can assist? Quite some com objects do not have a type library; probably those that are only supposed (by MS) to be used by C++ code. Sometimes an .idl file can be found somewhere in the SDKs which you can compile into a .tlb file, sometimes not. Sometimes someone who wants to use the object from VB writes an idl file and compiles a typelib (but you could also try it yourself, maybe). With a little googling I found a zip-file containing such a library: http://www.msjogren.net/dotnet/eng/samples/vb6_progdlg.asp However, this typelib would not help if you are using pywin32; comtypes would probably be able to use it - I haven't tried it myself. Thomas From eriflo at gmail.com Fri Feb 22 19:16:24 2008 From: eriflo at gmail.com (=?ISO-8859-1?Q?Erik_Fl=F8isbonn?=) Date: Fri, 22 Feb 2008 19:16:24 +0100 Subject: [python-win32] Wrapper Windows Installer API functions, ctypes, .dll Message-ID: <35c0173e0802221016s15717d0ew14ae369a6407c47f@mail.gmail.com> Hello, I am creating a .dll that I load in python with ctypes. The .dll calls Windows Installer API functions (like MsiEnumProducts). I am having trouble calling these functions from python. When I import the msilib (or _msi) that comes with python, the function calls work. But when I do not import them, the call does not work and I get the following error message: WindowsError: [Error 182] The operatingsystem can not run %1 (Original message is in norwegian: WindowsError: [Error 182] Operativsystemet kan ikke kj?re %1) I am wondering why the function calls are not working when I do not import the msi module, and why they work when I do import the module. I am running Windows Vista and python 2.5.1. I am compiling the source code with cl (from the windows SDK) like this: cl /LD msi.c msi.def "C:\Program Files\Microsoft SDKs\Windows\v6.0\Lib\Msi.lib" My python file looks like this: from ctypes import * # import msilib (everything works when I uncomment this) print cdll.LoadLibrary("C:\Users\Erik\Documents\INF5660\Msi.dll").test(2) The test function is defined like this in msi.c int test(int inn) { char product[100]; int i = 0; while (!MsiEnumProducts(i++, product)) { // Calling the api function (defined in msi.h) printf("%s", product); } return inn*2; } I have looked through the _msi.c source code for python 2.5.1, but I can not find any clues to what it does to make my functions work, and I have no idea what I am doing wrong with the creation of my wrappers. Anyone knows? Have a nice day, - Erik -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080222/d9d6eead/attachment-0001.htm From timr at probo.com Fri Feb 22 19:54:14 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 22 Feb 2008 10:54:14 -0800 Subject: [python-win32] Wrapper Windows Installer API functions, ctypes, .dll In-Reply-To: <35c0173e0802221016s15717d0ew14ae369a6407c47f@mail.gmail.com> References: <35c0173e0802221016s15717d0ew14ae369a6407c47f@mail.gmail.com> Message-ID: <47BF1A56.8000305@probo.com> Erik Fl?isbonn wrote: > Hello, I am creating a .dll that I load in python with ctypes. The > .dll calls Windows Installer API functions (like MsiEnumProducts). I > am having trouble calling these functions from python. When I import > the msilib (or _msi) that comes with python, the function calls work. > But when I do not import them, the call does not work and I get the > following error message: > > WindowsError: [Error 182] The operatingsystem can not run %1 > > (Original message is in norwegian: WindowsError: [Error 182] > Operativsystemet kan ikke kj?re %1) > > I am wondering why the function calls are not working when I do not > import the msi module, and why they work when I do import the module. > > I am running Windows Vista and python 2.5.1. I am compiling the source > code with cl (from the windows SDK) like this: > > cl /LD msi.c msi.def "C:\Program Files\Microsoft > SDKs\Windows\v6.0\Lib\Msi.lib" > > My python file looks like this: > > from ctypes import * > # import msilib (everything works when I uncomment this) > print cdll.LoadLibrary("C:\Users\Erik\Documents\INF5660\Msi.dll").test(2) You can't write normal strings with single backslashes! You happened to get lucky here, because 'u', 'e', 'd', 'i', and 'm' aren't recognized escape codes, but if your name had been "Tom", this would not work. You can write this in one of three ways: print cdll.LoadLibrary("C:\\Users\\Erik\\Documents\\INF5660\\Msi.dll").test(2) print cdll.LoadLibrary(r"C:\Users\Erik\Documents\INF5660\Msi.dll").test(2) print cdll.LoadLibrary("C:/Users/Erik/Documents/INF5660/Msi.dll").test(2) However, this is not causing your immediate problem. You might try dumping the imports for your DLL, to see if it needs a DLL that it's not finding. You can use the "depends" tool for that, or just "link /dump /exports msi.dll". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Feb 22 21:27:56 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 22 Feb 2008 12:27:56 -0800 Subject: [python-win32] Wrapper Windows Installer API functions, ctypes, .dll In-Reply-To: <35c0173e0802221214q7a94e132g2cb3ad986d42fdc0@mail.gmail.com> References: <35c0173e0802221016s15717d0ew14ae369a6407c47f@mail.gmail.com> <47BF1A56.8000305@probo.com> <35c0173e0802221214q7a94e132g2cb3ad986d42fdc0@mail.gmail.com> Message-ID: <47BF304C.8060008@probo.com> Erik Fl?isbonn wrote: > > Heh, I see that I was lucky with the backslashes. > > "link /dump /exports msi.dll" gives the following output: Did I say /exports? I see that I did. That was dumb. I meant to say /imports instead. However, "depends" does the same thing. > When I open the .dll in 'depends' (dependency walker), i get an error > message saying "Error: At least one module has an unresolved import > due to a missing export function in an implicitly dependent module." I > see the function called test, but I also get two red 'functions', with > function = "N/A" and entry point = "not bound". This is most probably > the two functions MsiEnumProducts and MsiEnumComponents that is called > in msi.c. I just noticed the name of your DLL. That's almost certainly the problem. You have called your DLL "msi.dll", but that's also the name of the system DLL that contains MsiEnumProducts and MsiEnumComponents! Change the name of your DLL to something like "msiwrapper.dll", and I'll bet the problem goes away. Do you have the system's msi.dll in \windows\system32? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From larry.bates at websafe.com Fri Feb 22 22:56:13 2008 From: larry.bates at websafe.com (Larry Bates) Date: Fri, 22 Feb 2008 15:56:13 -0600 Subject: [python-win32] Help calling IProgressDialog Interface In-Reply-To: References: Message-ID: Thomas Heller wrote: > Larry Bates schrieb: >> I've spent all morning searching and I just can't seem to find the TypeLibrary >> name for this COM interface. I've searched the registry, scanned COM browser >> list at least a dozen times, etc. Some information about this COM object is >> located here: >> >> http://www.com.it-berater.org/COM/windows_shell/interfaces/IProgressDialog%20.htm >> >> It appears to be located in browseui.dll, but that didn't help either. >> >> I also tried using pythoncom.CoCreateInstance, but it reports: >> >> >>> pdlg=pythoncom.CoCreateInstance('{F8383852-FCD3-11d1-A6B9-006097DF5BD4}', No >> ne, 1, '{EBBC7C04-315E-11d2-B62F-006097DF5BD4}') >> Traceback (most recent call last): >> File "", line 1, in >> TypeError: There is no interface object registered that supports this IID >> >> I'm hoping that someone out there can assist? > > Quite some com objects do not have a type library; probably those that are only > supposed (by MS) to be used by C++ code. > > Sometimes an .idl file can be found somewhere in the SDKs which you can > compile into a .tlb file, sometimes not. > > Sometimes someone who wants to use the object from VB writes an idl file > and compiles a typelib (but you could also try it yourself, maybe). > With a little googling I found a zip-file containing such a library: > > http://www.msjogren.net/dotnet/eng/samples/vb6_progdlg.asp > > However, this typelib would not help if you are using pywin32; comtypes > would probably be able to use it - I haven't tried it myself. > > Thomas Ok, I downloaded that project, and stripped out the TLB. I then got comtypes and was able to use comtypes.client.GetModule to generate the typelib wrapper module for it: >>> GetModule("progdlg.tlb") >>> import comtypes.gen.VBProgressDialog Now I can't seem to figure out what to do. There are three classes generated: class IOleWindow(comtypes.IUnknown) class IProgressDialog(comtypes.IUnknown) class ProgressDialog(comtypes.CoClass) Instantiating IProgressDialog() seems to give me an instance that has the methods that I'm looking for (at least they show up in Idle as callable methods), but when I try to call one I get the following message: Traceback (most recent call last): File "", line 1, in b.SetTitle('test') TypeError: Expected a COM this pointer as first argument Sorry to be so dense, I'm still learning the COM stuff. Thanks in advance. Larry Test program: import comtypes.client.GetModule GetModule('progdlg.tlb') import comtypes.gen.VBProgressDialog ci=comtypes.gen.VBProgressDialog a=ci.ProgressDialog() a.SetTitle('test') From theller at ctypes.org Fri Feb 22 23:43:27 2008 From: theller at ctypes.org (Thomas Heller) Date: Fri, 22 Feb 2008 23:43:27 +0100 Subject: [python-win32] Help calling IProgressDialog Interface In-Reply-To: References: Message-ID: > Ok, I downloaded that project, and stripped out the TLB. I then got comtypes > and was able to use comtypes.client.GetModule to generate the typelib wrapper > module for it: > > >>> GetModule("progdlg.tlb") > 'C:\Python25\lib\site-packages\comtypes\gen\_2F2719A2_83CC_11D3_A08C_0040F6A4BFEC_0_1_1.pyc'> > >>> import comtypes.gen.VBProgressDialog > > Now I can't seem to figure out what to do. There are three classes generated: > > class IOleWindow(comtypes.IUnknown) > class IProgressDialog(comtypes.IUnknown) > class ProgressDialog(comtypes.CoClass) > > Instantiating IProgressDialog() seems to give me an instance that has the > methods that I'm looking for (at least they show up in Idle as callable > methods), but when I try to call one I get the following message: > > Traceback (most recent call last): > File "", line 1, in > b.SetTitle('test') > TypeError: Expected a COM this pointer as first argument > > Sorry to be so dense, I'm still learning the COM stuff. > > Thanks in advance. > Larry > > Test program: > > import comtypes.client.GetModule > GetModule('progdlg.tlb') > import comtypes.gen.VBProgressDialog > ci=comtypes.gen.VBProgressDialog > a=ci.ProgressDialog() > a.SetTitle('test') I will look into that, but not before Monday or Tuesday. Thanks, Thomas From s.khushalani at yahoo.co.uk Sat Feb 23 11:24:37 2008 From: s.khushalani at yahoo.co.uk (Sagar Khushalani) Date: Sat, 23 Feb 2008 10:24:37 +0000 (GMT) Subject: [python-win32] msmq error Message-ID: <287714.57021.qm@web28315.mail.ukl.yahoo.com> i am trying to use a queue to pass messages between 2 processes. however i get this message. i'm new to this so question: is there a way to create the queue first? both the processes are local, under the same user account. Traceback (most recent call last): File "C:\Python25\lib\threading.py", line 462, in __bootstrap self.run() File "C:\Python25\lib\threading.py", line 442, in run self.__target(*self.__args, **self.__kwargs) File "C:\Documents and Settings\Sagar\My Documents\Homework\Lab I\p1.pyw", line 86, in start_proc errors = qinfo.Open(2,0) #Open queue File "", line 3, in Open com_error: (-2147352567, 'Exception occurred.', (0, 'MSMQQueueInfo', 'The queue does not exist, or you do not have sufficient permissions to perform the operation. ', None, 0, -1072824317), None) Sagar Khushalani Graduate Student, UTA Networking / Systems and Architecture s.khushalani at yahoo.co.uk http://www.sagark.info --------------------------------- Sent from Yahoo! Mail. A Smarter Inbox. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080223/81a82c7b/attachment.htm From jim.vickroy at noaa.gov Sat Feb 23 14:31:42 2008 From: jim.vickroy at noaa.gov (j vickroy) Date: Sat, 23 Feb 2008 06:31:42 -0700 Subject: [python-win32] SQL Server event notifications ? In-Reply-To: <854AC58D812E4019B82F69CD08A20CCE@MCI1330> References: <854AC58D812E4019B82F69CD08A20CCE@MCI1330> Message-ID: <47C0203E.5000207@noaa.gov> Hello all, I realize this is more of a SQL Server question than a Python/Windows question, but ... I would like to develop an application that receives event notifications from SQL Server rather than polling the database. Specifically, I am interested in table INSERT and UPDATE events. Is this possible? Has anyone done this from Python? I looked at: * CREATE EVENT NOTIFICATION (Transact-SQL) -- http://msdn2.microsoft.com/en-us/library/ms189453.aspx * Creating Service Broker Services -- http://msdn2.microsoft.com/en-us/library/ms171609.aspx but I did not understand the Service Broker Services information well enough to know. I am not very knowledgable about SQL Server, but I could have our DBA assist me in setting this up. Thanks, -- jv -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080223/c17153f1/attachment.htm From s.khushalani at yahoo.co.uk Sun Feb 24 01:28:20 2008 From: s.khushalani at yahoo.co.uk (Sagar Khushalani) Date: Sun, 24 Feb 2008 00:28:20 +0000 (GMT) Subject: [python-win32] msmq error In-Reply-To: <014701c87679$4bf113f0$e3d33bd0$@com.au> Message-ID: <907454.40069.qm@web28312.mail.ukl.yahoo.com> found the solution. thanks. sorry if anyone got personal mails, i was just using reply and i thought it would automatically go to the list rather than the person. -sagar Mark Hammond wrote: v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} The very last line of your mail includes the exact reason why your code isn?t working ? but without seeing your code, we can?t tell you what the underlying reason is. Please follow-up to the list, not to me personally! Cheers, Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Sagar Khushalani Sent: Saturday, 23 February 2008 9:25 PM To: python-win32 at python.org Subject: [python-win32] msmq error i am trying to use a queue to pass messages between 2 processes. however i get this message. i'm new to this so question: is there a way to create the queue first? both the processes are local, under the same user account. Traceback (most recent call last): File "C:\Python25\lib\threading.py", line 462, in __bootstrap self.run() File "C:\Python25\lib\threading.py", line 442, in run self.__target(*self.__args, **self.__kwargs) File "C:\Documents and Settings\Sagar\My Documents\Homework\Lab I\p1.pyw", line 86, in start_proc errors = qinfo.Open(2,0) #Open queue File "", line 3, in Open com_error: (-2147352567, 'Exception occurred.', (0, 'MSMQQueueInfo', 'The queue does not exist, or you do not have sufficient permissions to perform the operation. ', None, 0, -1072824317), None) Sagar Khushalani Graduate Student, UTA Networking / Systems and Architecture s.khushalani at yahoo.co.uk http://www.sagark.info --------------------------------- Sent from Yahoo! Mail. A Smarter Inbox. Sagar Khushalani Graduate Student, UTA Networking / Systems and Architecture s.khushalani at yahoo.co.uk http://www.sagark.info --------------------------------- Rise to the challenge for Sport Relief with Yahoo! for Good -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080224/3d990fd3/attachment.htm From marcus at internetnowasp.net Sun Feb 24 12:26:25 2008 From: marcus at internetnowasp.net (Marcus Low) Date: Sun, 24 Feb 2008 19:26:25 +0800 Subject: [python-win32] Wrapper Windows Installer API functions, ctypes, .dll In-Reply-To: <47BF1A56.8000305@probo.com> References: <35c0173e0802221016s15717d0ew14ae369a6407c47f@mail.gmail.com> <47BF1A56.8000305@probo.com> Message-ID: <3BFA095D255D44B0BC6EA1797031D807@ToolBox> I love this community, you guys are really patient. Backslashes...... If you want to use single backslashed, you probably need to use "r" in front of the string http://docs.python.org/ref/strings.html I strongly recommend anyone new to python to get :- 1. learning python from Mark lutz 2. python on win32 , mark hammond Its money well spent, you will be asking less questions that you wish u didnt ask. ----- Original Message ----- From: "Tim Roberts" To: "Python-Win32 List" Sent: Saturday, February 23, 2008 2:54 AM Subject: Re: [python-win32] Wrapper Windows Installer API functions, ctypes, .dll Erik Fl?isbonn wrote: > Hello, I am creating a .dll that I load in python with ctypes. The > .dll calls Windows Installer API functions (like MsiEnumProducts). I > am having trouble calling these functions from python. When I import > the msilib (or _msi) that comes with python, the function calls work. > But when I do not import them, the call does not work and I get the > following error message: > > WindowsError: [Error 182] The operatingsystem can not run %1 > > (Original message is in norwegian: WindowsError: [Error 182] > Operativsystemet kan ikke kj?re %1) > > I am wondering why the function calls are not working when I do not > import the msi module, and why they work when I do import the module. > > I am running Windows Vista and python 2.5.1. I am compiling the source > code with cl (from the windows SDK) like this: > > cl /LD msi.c msi.def "C:\Program Files\Microsoft > SDKs\Windows\v6.0\Lib\Msi.lib" > > My python file looks like this: > > from ctypes import * > # import msilib (everything works when I uncomment this) > print cdll.LoadLibrary("C:\Users\Erik\Documents\INF5660\Msi.dll").test(2) You can't write normal strings with single backslashes! You happened to get lucky here, because 'u', 'e', 'd', 'i', and 'm' aren't recognized escape codes, but if your name had been "Tom", this would not work. You can write this in one of three ways: print cdll.LoadLibrary("C:\\Users\\Erik\\Documents\\INF5660\\Msi.dll").test(2) print cdll.LoadLibrary(r"C:\Users\Erik\Documents\INF5660\Msi.dll").test(2) print cdll.LoadLibrary("C:/Users/Erik/Documents/INF5660/Msi.dll").test(2) However, this is not causing your immediate problem. You might try dumping the imports for your DLL, to see if it needs a DLL that it's not finding. You can use the "depends" tool for that, or just "link /dump /exports msi.dll". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From drshade at gmail.com Mon Feb 25 08:16:56 2008 From: drshade at gmail.com (Tom Wells) Date: Mon, 25 Feb 2008 09:16:56 +0200 Subject: [python-win32] [pywin32-bugs] ISAPI Set-Cookie Probs In-Reply-To: <00b301c875a4$7e6406b0$7b2c1410$@com.au> References: <00b301c875a4$7e6406b0$7b2c1410$@com.au> Message-ID: Hi Mark Thanks for the reply - I've subscribed and copied the correct mailing list now. Actually there is no such fc.SetHeader() function (assuming fc is the FILTER_CONTEXT structure) - you may be thinking about the pp.SetHeader() function (where pp is the PREPROC notification structure). I'm aware of this, but need to be able to set my cookie after (or during) the SF_NOTIFY_AUTHENTICATION notification, which unfortunately is comes directly after the preproc notification. SendResponseHeaders() not working is odd, and maybe i'm just misunderstanding it's use, but a call to fc.SendResponseHeaders('Set-Cookie:', 'TEST_COOKIE=VALUE') within the SEND_DATA notification produces a response packet looking like (from memory): HTTP/1.x Set-Cookie: TEST_COOKIE=VALUE Content-Type: text/html Content-Length: 237 --- SNIP --- So it seems like the function is for writing an HTTP response value (200, 302 etc), and not for actually setting an HTTP header. Another thought I had was keeping a reference to the PREPROC notification structure, and then calling SetHeader() on it inside the AUTHENTICATION notification - do you think this might work? Thanks, Tom On Sat, Feb 23, 2008 at 12:44 AM, Mark Hammond wrote: > Actually, this is just for automated emails from the bug tracker ? you > should send them to python-win32 at python.org (I'll try and make that more > obvious on the subscription page). But a quick note about your problem: I'm > not sure how I missed AddResponseHeaders(), but I will add it now, so it > should make pywin32-211. I'm not sure why SendResponseHeader() is failing, > but another option is fc.SetHeader() ? see the 'redirector' sample. > Please followup via the above list > > > > *From:* pywin32-bugs-bounces at lists.sourceforge.net [mailto: > pywin32-bugs-bounces at lists.sourceforge.net] *On Behalf Of *Tom Wells > *Sent:* Saturday, 23 February 2008 5:29 AM > *To:* pywin32-bugs at lists.sourceforge.net > *Subject:* [pywin32-bugs] ISAPI Set-Cookie Probs > > > > Hi Guys > > Hope this is the correct mailing list for this kind of post! > > I've been busy busy writing an ISAPI Filter in Python using Pywin32 and > have made loads of progress. However I've come across a bit of an issue > while trying to set a cookie within my filter code. I'm actually porting an > existing ISAPI Filter (written in C++) to make use of python instead, so > have the luxury of having a good set of reference source code. > > My issue is that I don't have access to AddResponseHeaders() on the > FILTER_CONTEXT object, and thus battling to actually set the cookie value. > I've tried using fc.SendResponseHeader() within the > SF_NOTIFY_SEND_RESPONSE event too - but this produces some 'interesting' > results so quite sure it's the wrong approach. > > So my last resort is to grab the pywin32 sources and implement the > wrapping, but i'd far prefer to be able to use pywin32 exactly as installed > and not have to patch as this filter could quite likely be rolled out to > multiple sites. > > Does anyone know or could suggest an alternate approach to setting a > cookie? > > Thanks, > Tom > > p.s. I have used the following page as a reference to my set-cookie issue: > http://support.microsoft.com/kb/q168864/ > -- http://www.tomwells.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080225/256ef249/attachment.htm From p.f.moore at gmail.com Mon Feb 25 13:42:27 2008 From: p.f.moore at gmail.com (Paul Moore) Date: Mon, 25 Feb 2008 12:42:27 +0000 Subject: [python-win32] HTTP Server as a Windows Service In-Reply-To: <47BF01DA.2050101@websafe.com> References: <47BE94A6.BE67.009D.0@carilion.com> <47BF01DA.2050101@websafe.com> Message-ID: <79990c6b0802250442j56c44952m92b338bb892ee922@mail.gmail.com> On 22/02/2008, Larry Bates wrote: > This seems to come up about every other week. The problem is that you haven't > given your service a way to KNOW that you have sent a stop signal. Below is a > skeleton of a correct SvcDoRun method: In fact, the code shown uses self.isAlive for this purpose. An event would probably be better than a single flag variable, as the different methods of a service program tend to get called from different threads in the service control program, so something thread-safe is advisable. It shouldn't matter in this case, though. The real problem here is that the OP hasn't notified the service control manager that it has stopped, once SvcDoRun completes. He needs a call to self.ReportServiceStatus(win32service.SERVICE_STOPPED) outside the while loop in SvcDoRun. Otherwise the status never gets set to "Stop", and remains at "Stopping" as he is seeing. > You may want to invest in a book: "Python Programming On Win32" it helped me a > lot when I was getting started. Absolutely. That's a great book, and well worth a read for service programming in particular. > Note: I don't think you want to define your RequestHandler class inside SvcDoRun > and instantiate the HTTPserver every time through the loop. You should just > update the information on the page each time through the loop. Again, I'd agree, but the given code looks OK for a quick hack. Paul. From mhammond at skippinet.com.au Mon Feb 25 14:08:30 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 26 Feb 2008 00:08:30 +1100 Subject: [python-win32] HTTP Server as a Windows Service In-Reply-To: <79990c6b0802250442j56c44952m92b338bb892ee922@mail.gmail.com> References: <47BE94A6.BE67.009D.0@carilion.com> <47BF01DA.2050101@websafe.com> <79990c6b0802250442j56c44952m92b338bb892ee922@mail.gmail.com> Message-ID: <01ff01c877af$8d3e4670$a7bad350$@com.au> I'm afraid I haven't followed this closely, but: > The real problem here is that the OP hasn't notified the service > control manager that it has stopped, once SvcDoRun completes. He needs > a call to self.ReportServiceStatus(win32service.SERVICE_STOPPED) > outside the while loop in SvcDoRun. Otherwise the status never gets > set to "Stop", and remains at "Stopping" as he is seeing. The above *should* be incorrect (and actually is, best I can tell). The tail of SvcRun, which is called by the C++ code, reads: # Once SvcDoRun terminates, the service has stopped. # We tell the SCM the service is still stopping - the C framework # will automatically tell the SCM it has stopped when this returns. self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) and a quick look at the C++ code shows this should indeed be true. Looking at pipeTestService.py, it never explicitly sets the state to SERVICE_STOPPED either, and it has always been my intent that the final stopped state be automatic as the handler terminates. So even if the OP overrides SvcRun directly, it should be impossible to avoid a stopped state being notified. Unless the fact I'm too lazy to big into the thread plays a part in a misunderstanding... :) Cheers, Mark From p.f.moore at gmail.com Mon Feb 25 14:26:29 2008 From: p.f.moore at gmail.com (Paul Moore) Date: Mon, 25 Feb 2008 13:26:29 +0000 Subject: [python-win32] HTTP Server as a Windows Service In-Reply-To: <01ff01c877af$8d3e4670$a7bad350$@com.au> References: <47BE94A6.BE67.009D.0@carilion.com> <47BF01DA.2050101@websafe.com> <79990c6b0802250442j56c44952m92b338bb892ee922@mail.gmail.com> <01ff01c877af$8d3e4670$a7bad350$@com.au> Message-ID: <79990c6b0802250526s3492b017l635331e9f37ba570@mail.gmail.com> On 25/02/2008, Mark Hammond wrote: > I'm afraid I haven't followed this closely, but: > > > > The real problem here is that the OP hasn't notified the service > > control manager that it has stopped, once SvcDoRun completes. He needs > > a call to self.ReportServiceStatus(win32service.SERVICE_STOPPED) > > outside the while loop in SvcDoRun. Otherwise the status never gets > > set to "Stop", and remains at "Stopping" as he is seeing. > > > The above *should* be incorrect (and actually is, best I can tell). Apologies. I really should know better than to post without thinking. I was going by my incorrect recollections of code I had written, rather than checking. Thanks, Mark, for correcting my error. Sorry for the noise. Paul. From mhammond at skippinet.com.au Mon Feb 25 14:50:05 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 26 Feb 2008 00:50:05 +1100 Subject: [python-win32] [pywin32-bugs] ISAPI Set-Cookie Probs In-Reply-To: References: <00b301c875a4$7e6406b0$7b2c1410$@com.au> Message-ID: <020401c877b5$561805e0$024811a0$@com.au> > Actually there is no such fc.SetHeader() function ... Yep - it was PREPROC_HEADERS I was referring to. > SendResponseHeaders() not working is odd, and maybe i'm just misunderstanding it's use Sadly, there is a layer of indirection here I inherited from the original author which isn't necessarily intuitive. SendResponseHeaders() is used by an extension and which as the docs mention (or at least do in CVS - its likely they do not in your copy), "calls ServerSupportFunction with HSE_REQ_SEND_RESPONSE_HEADER_EX" - which you will find takes 3 params - response, complete_headers, keep_alive, where response is the "200 OK" string, complete_headers is a string with \r\n terminators, and keep_alive is a bool (which, best I can tell, has no effect on anything!) I have added HTTP_FILTER_CONTEXT AddResponseHeaders() to CVS though - let me know if you would like a build to test (and let me know your Python version) - and that goes for anyone else too - build 211 gets closer by the day (just get Roger to stop fixing lots of pythonwin bugs ) so I'll point anyone who asks at test builds... Cheers, Mark. From teekaysoh at gmail.com Mon Feb 25 15:20:09 2008 From: teekaysoh at gmail.com (TK Soh) Date: Mon, 25 Feb 2008 14:20:09 +0000 Subject: [python-win32] context menu extension get called twice Message-ID: <58b84f8e0802250620s1485a039lbde716a22fe47ac3@mail.gmail.com> I'm having some problem with my Explorer context menu extension. I have registered the extension to the following registry: (_winreg.HKEY_CLASSES_ROOT, r"Directory\Background\shellex\ContextMenuHandlers\TortoiseHg"), (_winreg.HKEY_CLASSES_ROOT, r"Directory\shellex\ContextMenuHandlers\TortoiseHg"), When I clicked on the File menu on the main menu of Explorer with a folder selected in the window, the context menu extension will be called twice in a roll, resulting in two sets of TortoiseHg menu. With no folder selected, the extension appear to work correctly I wonder if there's something I am doing wrong here. Appreciate if anyone can give an advice or pointer. Thanks. From drshade at gmail.com Mon Feb 25 15:28:58 2008 From: drshade at gmail.com (Tom Wells) Date: Mon, 25 Feb 2008 16:28:58 +0200 Subject: [python-win32] [pywin32-bugs] ISAPI Set-Cookie Probs In-Reply-To: <020401c877b5$561805e0$024811a0$@com.au> References: <00b301c875a4$7e6406b0$7b2c1410$@com.au> <020401c877b5$561805e0$024811a0$@com.au> Message-ID: Mark, Hi A test build would be great - I just sync'd CVS and saw your changes and about to download platform SDK etc to compile the newest version, but i'm sure you can probably get me something sooner! I will however get the sources anyways, as it's a good reference plus I may feel inclined to finish off some of your TBD's (such as the SF_NOTIFY_SEND_RESPONSE notification, which should be very easy as it takes exactly the same notificationtype as SF_NOTIFY_PREPROC_HEADERS according to ISAPI documentation). Thanks for the support so far - really appreciate it! Please let me know once you have a build available, I am running python 2.5.1 (32 bit), but would also require an amd64 build if possible? Thanks, Tom On Mon, Feb 25, 2008 at 3:50 PM, Mark Hammond wrote: > > Actually there is no such fc.SetHeader() function ... > > Yep - it was PREPROC_HEADERS I was referring to. > > > SendResponseHeaders() not working is odd, and maybe i'm just > misunderstanding it's use > > Sadly, there is a layer of indirection here I inherited from the original > author which isn't necessarily intuitive. SendResponseHeaders() is used > by > an extension and which as the docs mention (or at least do in CVS - its > likely they do not in your copy), "calls ServerSupportFunction with > HSE_REQ_SEND_RESPONSE_HEADER_EX" - which you will find takes 3 params - > response, complete_headers, keep_alive, where response is the "200 OK" > string, complete_headers is a string with \r\n terminators, and keep_alive > is a bool (which, best I can tell, has no effect on anything!) > > I have added HTTP_FILTER_CONTEXT AddResponseHeaders() to CVS though - let > me > know if you would like a build to test (and let me know your Python > version) > - and that goes for anyone else too - build 211 gets closer by the day > (just > get Roger to stop fixing lots of pythonwin bugs ) so I'll point > anyone > who asks at test builds... > > Cheers, > > Mark. > > -- http://www.tomwells.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080225/9b4490f1/attachment.htm From drshade at gmail.com Mon Feb 25 16:36:35 2008 From: drshade at gmail.com (Tom Wells) Date: Mon, 25 Feb 2008 17:36:35 +0200 Subject: [python-win32] [pywin32-bugs] ISAPI Set-Cookie Probs In-Reply-To: References: <00b301c875a4$7e6406b0$7b2c1410$@com.au> <020401c877b5$561805e0$024811a0$@com.au> Message-ID: Just tried to run a build, and getting the following errors: C:\temp\pywin32>python setup.py -q build Building pywin32 2.5.210.9 Skipping win32cred WINDOWS.H with version 0x501 is required, but only version 0x500 is installed. win32servicemodule.cpp win32\src\win32servicemodule.cpp(2675) : error C2065: 'SERVICE_CONTROL_PRESHUTDOWN' : undeclared identifier win32\src\win32servicemodule.cpp(2733) : error C2065: 'SERVICE_ACCEPT_PRESHUTDOWN' : undeclared identifier error: command '"C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe"' failed with exit status 2 I have vs2003 installed (for python 2.5.1), plus just downloaded and installed the latest platform sdk from ( http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en#filelist ). Any ideas? I'm purely after the ISAPI bits. Thanks, Tom On Mon, Feb 25, 2008 at 4:28 PM, Tom Wells wrote: > Mark, Hi > > A test build would be great - I just sync'd CVS and saw your changes and > about to download platform SDK etc to compile the newest version, but i'm > sure you can probably get me something sooner! I will however get the > sources anyways, as it's a good reference plus I may feel inclined to finish > off some of your TBD's (such as the SF_NOTIFY_SEND_RESPONSE notification, > which should be very easy as it takes exactly the same notificationtype as > SF_NOTIFY_PREPROC_HEADERS according to ISAPI documentation). > > Thanks for the support so far - really appreciate it! > > Please let me know once you have a build available, I am running python > 2.5.1 (32 bit), but would also require an amd64 build if possible? > > Thanks, > Tom > > > > On Mon, Feb 25, 2008 at 3:50 PM, Mark Hammond > wrote: > > > > Actually there is no such fc.SetHeader() function ... > > > > Yep - it was PREPROC_HEADERS I was referring to. > > > > > SendResponseHeaders() not working is odd, and maybe i'm just > > misunderstanding it's use > > > > Sadly, there is a layer of indirection here I inherited from the > > original > > author which isn't necessarily intuitive. SendResponseHeaders() is used > > by > > an extension and which as the docs mention (or at least do in CVS - its > > likely they do not in your copy), "calls ServerSupportFunction with > > HSE_REQ_SEND_RESPONSE_HEADER_EX" - which you will find takes 3 params - > > response, complete_headers, keep_alive, where response is the "200 OK" > > string, complete_headers is a string with \r\n terminators, and > > keep_alive > > is a bool (which, best I can tell, has no effect on anything!) > > > > I have added HTTP_FILTER_CONTEXT AddResponseHeaders() to CVS though - > > let me > > know if you would like a build to test (and let me know your Python > > version) > > - and that goes for anyone else too - build 211 gets closer by the day > > (just > > get Roger to stop fixing lots of pythonwin bugs ) so I'll point > > anyone > > who asks at test builds... > > > > Cheers, > > > > Mark. > > > > > > > -- > http://www.tomwells.org -- http://www.tomwells.org -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080225/3acc3d11/attachment-0001.htm From theller at ctypes.org Tue Feb 26 16:35:09 2008 From: theller at ctypes.org (Thomas Heller) Date: Tue, 26 Feb 2008 16:35:09 +0100 Subject: [python-win32] Help calling IProgressDialog Interface In-Reply-To: References: Message-ID: Larry Bates schrieb: > Thomas Heller wrote: >> Larry Bates schrieb: >>> I've spent all morning searching and I just can't seem to find the TypeLibrary >>> name for this COM interface. >> Sometimes someone who wants to use the object from VB writes an idl file >> and compiles a typelib (but you could also try it yourself, maybe). >> With a little googling I found a zip-file containing such a library: >> >> http://www.msjogren.net/dotnet/eng/samples/vb6_progdlg.asp > Ok, I downloaded that project, and stripped out the TLB. I then got comtypes > and was able to use comtypes.client.GetModule to generate the typelib wrapper > module for it: > > >>> GetModule("progdlg.tlb") > 'C:\Python25\lib\site-packages\comtypes\gen\_2F2719A2_83CC_11D3_A08C_0040F6A4BFEC_0_1_1.pyc'> > >>> import comtypes.gen.VBProgressDialog > > Now I can't seem to figure out what to do. There are three classes generated: > > class IOleWindow(comtypes.IUnknown) > class IProgressDialog(comtypes.IUnknown) > class ProgressDialog(comtypes.CoClass) > > Instantiating IProgressDialog() seems to give me an instance that has the > methods that I'm looking for (at least they show up in Idle as callable > methods), but when I try to call one I get the following message: Larry, you do not instantiate the generated classes directly. You must use the comtypes.client.CreateObject function to do that for you, passing the CoClass as parameter. I think that this code should work: import comtypes.gen.VBProgressDialog from comtypes.client import CreateObject dia = CreateObject(comtypes.gen.VBProgressDialog.ProgressDialog) dia.StartProgressDialog(....) Thomas From larry.bates at websafe.com Wed Feb 27 14:56:13 2008 From: larry.bates at websafe.com (Larry Bates) Date: Wed, 27 Feb 2008 07:56:13 -0600 Subject: [python-win32] Help calling IProgressDialog Interface In-Reply-To: References: Message-ID: <47C56BFD.3040400@websafe.com> Thomas Heller wrote: > Larry Bates schrieb: >> Thomas Heller wrote: >>> Larry Bates schrieb: >>>> I've spent all morning searching and I just can't seem to find the TypeLibrary >>>> name for this COM interface. > >>> Sometimes someone who wants to use the object from VB writes an idl file >>> and compiles a typelib (but you could also try it yourself, maybe). >>> With a little googling I found a zip-file containing such a library: >>> >>> http://www.msjogren.net/dotnet/eng/samples/vb6_progdlg.asp > >> Ok, I downloaded that project, and stripped out the TLB. I then got comtypes >> and was able to use comtypes.client.GetModule to generate the typelib wrapper >> module for it: >> >> >>> GetModule("progdlg.tlb") >> > 'C:\Python25\lib\site-packages\comtypes\gen\_2F2719A2_83CC_11D3_A08C_0040F6A4BFEC_0_1_1.pyc'> >> >>> import comtypes.gen.VBProgressDialog >> >> Now I can't seem to figure out what to do. There are three classes generated: >> >> class IOleWindow(comtypes.IUnknown) >> class IProgressDialog(comtypes.IUnknown) >> class ProgressDialog(comtypes.CoClass) >> >> Instantiating IProgressDialog() seems to give me an instance that has the >> methods that I'm looking for (at least they show up in Idle as callable >> methods), but when I try to call one I get the following message: > > Larry, you do not instantiate the generated classes directly. You must use > the comtypes.client.CreateObject function to do that for you, passing the CoClass > as parameter. I think that this code should work: > > import comtypes.gen.VBProgressDialog > from comtypes.client import CreateObject > dia = CreateObject(comtypes.gen.VBProgressDialog.ProgressDialog) > dia.StartProgressDialog(....) > > Thomas Thomas, I almost have it completely working with one remaining problem. The dialog allows the user to specify an AVI that runs showing activity while things are going in the background. There are AVIs stored in shell32.dll for move/copy (resource number 160 and 161 respectively). Below is the VB code to set these, but I'm not getting anywhere trying to convert. I was hoping you could take a quick look. Thanks for your help. I'll be happy to share the class when I'm done if you are interested or can you suggest a good place to post? Might be a good comtypes example???? Regards, Larry ' File operation animations resource IDs in shell32.dll Private Const RES_AVI_FILEMOVE = 160 Private Const RES_AVI_FILECOPY = 161 With oProgDlg .SetTitle IIf(fMove, "Moving file...", "Copying file...") .SetAnimation m_hLibShell32, IIf(fMove, RES_AVI_FILEMOVE, RES_AVI_FILECOPY) .SetLine 1, txtSource.Text, 1&, ByVal 0& .SetLine 2, txtDest.Text, 1&, ByVal 0& .SetCancelMsg "Please wait...", ByVal 0& .StartProgressDialog Me.hwnd, Nothing, PROGDLG_MODAL Or _ PROGDLG_AUTOTIME Or _ PROGDLG_NOMINIMIZE, ByVal 0& End With Private Sub Form_Load() ' Load Shell32 to access the AVI animation resources m_hLibShell32 = LoadLibrary("shell32.dll") End Sub Private Sub Form_Unload(Cancel As Integer) Call FreeLibrary(m_hLibShell32) End Sub From mail at timgolden.me.uk Wed Feb 27 15:19:46 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 27 Feb 2008 14:19:46 +0000 Subject: [python-win32] Help calling IProgressDialog Interface In-Reply-To: <47C56BFD.3040400@websafe.com> References: <47C56BFD.3040400@websafe.com> Message-ID: <47C57182.3020808@timgolden.me.uk> Larry Bates wrote: > I almost have it completely working with one remaining problem. The dialog > allows the user to specify an AVI that runs showing activity while things are > going in the background. There are AVIs stored in shell32.dll for move/copy > (resource number 160 and 161 respectively). Below is the VB code to set these, > but I'm not getting anywhere trying to convert. I was hoping you could take a > quick look. > ' File operation animations resource IDs in shell32.dll > Private Const RES_AVI_FILEMOVE = 160 > Private Const RES_AVI_FILECOPY = 161 > > With oProgDlg > .SetTitle IIf(fMove, "Moving file...", "Copying file...") > .SetAnimation m_hLibShell32, IIf(fMove, RES_AVI_FILEMOVE, RES_AVI_FILECOPY) > .SetLine 1, txtSource.Text, 1&, ByVal 0& > .SetLine 2, txtDest.Text, 1&, ByVal 0& > .SetCancelMsg "Please wait...", ByVal 0& > .StartProgressDialog Me.hwnd, Nothing, PROGDLG_MODAL Or _ > PROGDLG_AUTOTIME Or _ > PROGDLG_NOMINIMIZE, ByVal 0& > End With > > Private Sub Form_Load() > > ' Load Shell32 to access the AVI animation resources > m_hLibShell32 = LoadLibrary("shell32.dll") > > End Sub > > Private Sub Form_Unload(Cancel As Integer) > > Call FreeLibrary(m_hLibShell32) > > End Sub Which bit aren't you getting, Larry? (Not sure how far your existing expertise extends). The LoadLibrary stuff is what ctypes.windll encapsulates. ie import ctypes shell32 = ctypes.windll.shell32 m_hLibShell32 = shell32._handle gets you the same as the Form_Load Sub. Alternatively, you could import the lower-level _ctypes and use its LoadLibrary binding directly: import _ctypes m_hLibShell32 = _ctypes.LoadLibrary ("shell32.dll") # # _ctypes.FreeLibrary (m_hLibShell32) But maybe that's not the bit you're having trouble with? TJG From jkpeck at aya.yale.edu Wed Feb 27 16:58:09 2008 From: jkpeck at aya.yale.edu (Jon Peck) Date: Wed, 27 Feb 2008 08:58:09 -0700 Subject: [python-win32] Launching a New Instance of an Application Message-ID: We need to launch Excel from a Python application using win32com, and we want to be sure that we get a new instance whether or not Excel is already running. What is the best way to do this? Thanks for your help. -- Jon K Peck jkpeck at gmail.com 505-983-1955 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080227/73353d6c/attachment.htm From mail at timgolden.me.uk Wed Feb 27 17:07:33 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 27 Feb 2008 16:07:33 +0000 Subject: [python-win32] Launching a New Instance of an Application In-Reply-To: References: Message-ID: <47C58AC5.8070507@timgolden.me.uk> Jon Peck wrote: > We need to launch Excel from a Python application using win32com, and we > want to be sure that we get a new instance whether or not Excel is already > running. What is the best way to do this? http://timgolden.me.uk/python/win32_how_do_i/start-a-new-com-instance.html TJG From larry.bates at websafe.com Wed Feb 27 17:16:29 2008 From: larry.bates at websafe.com (Larry Bates) Date: Wed, 27 Feb 2008 10:16:29 -0600 Subject: [python-win32] Help calling IProgressDialog Interface In-Reply-To: <47C57182.3020808@timgolden.me.uk> References: <47C56BFD.3040400@websafe.com> <47C57182.3020808@timgolden.me.uk> Message-ID: Tim Golden wrote: > Larry Bates wrote: >> I almost have it completely working with one remaining problem. The dialog >> allows the user to specify an AVI that runs showing activity while things are >> going in the background. There are AVIs stored in shell32.dll for move/copy >> (resource number 160 and 161 respectively). Below is the VB code to set these, >> but I'm not getting anywhere trying to convert. I was hoping you could take a >> quick look. > >> ' File operation animations resource IDs in shell32.dll >> Private Const RES_AVI_FILEMOVE = 160 >> Private Const RES_AVI_FILECOPY = 161 >> >> With oProgDlg >> .SetTitle IIf(fMove, "Moving file...", "Copying file...") >> .SetAnimation m_hLibShell32, IIf(fMove, RES_AVI_FILEMOVE, RES_AVI_FILECOPY) >> .SetLine 1, txtSource.Text, 1&, ByVal 0& >> .SetLine 2, txtDest.Text, 1&, ByVal 0& >> .SetCancelMsg "Please wait...", ByVal 0& >> .StartProgressDialog Me.hwnd, Nothing, PROGDLG_MODAL Or _ >> PROGDLG_AUTOTIME Or _ >> PROGDLG_NOMINIMIZE, ByVal 0& >> End With >> >> Private Sub Form_Load() >> >> ' Load Shell32 to access the AVI animation resources >> m_hLibShell32 = LoadLibrary("shell32.dll") >> >> End Sub >> >> Private Sub Form_Unload(Cancel As Integer) >> >> Call FreeLibrary(m_hLibShell32) >> >> End Sub > > Which bit aren't you getting, Larry? (Not sure how far your > existing expertise extends). The LoadLibrary stuff is what > ctypes.windll encapsulates. ie > > > import ctypes > shell32 = ctypes.windll.shell32 > m_hLibShell32 = shell32._handle > > > gets you the same as the Form_Load Sub. Alternatively, you > could import the lower-level _ctypes and use its LoadLibrary > binding directly: > > > import _ctypes > m_hLibShell32 = _ctypes.LoadLibrary ("shell32.dll") > > # > # > > _ctypes.FreeLibrary (m_hLibShell32) > > > But maybe that's not the bit you're having trouble with? > > TJG Tim, That did the trick. It was the: m_hLibShell32 = shell32._handle that I needed. Thanks loads. -Larry From happybrowndog at hotmail.com Wed Feb 27 20:47:44 2008 From: happybrowndog at hotmail.com (happybrowndog) Date: Wed, 27 Feb 2008 11:47:44 -0800 Subject: [python-win32] Detecting when the Windows screen saver comes on Message-ID: Hello, Does anyone know how to detect when the windows screen saver comes on? Any other kind of detection of windows being idle (ie: sleep or whatever) would also be useful if you happen to know it. I'm basically looking for whatever is easy to implement. My wxpython chat application needs to know if the user has gone "idle" by detecting whatever windows event will tell me that. Thanks. From happybrowndog at hotmail.com Wed Feb 27 21:06:15 2008 From: happybrowndog at hotmail.com (happybrowndog) Date: Wed, 27 Feb 2008 12:06:15 -0800 Subject: [python-win32] Is Mark Hammond going to produce a new Python Programming on Win32 book? Message-ID: I've had Mark's Python Programming on Win32 book for 6 years now, and it's been a constant source of information and a joy to read and possess. Windows has added a lot since the book hit the shelves, with the maturation of .Net, winforms and other application technologies, and a "new" OS. There's still the old way of doing things with COM, etc. The Ctypes package has also fleshed out to be very useful on Windows. Then there's IronPython, and Python for .Net. So.... Mark, I love your book. I just was wishing that you would produce another one. Even on the topics you covered (COM, services, for example), much more could be said in a new edition. I'm hoping this post will become a plea from the many other fans of your book that you have. Pythoneers, please post your support! From mail at timgolden.me.uk Wed Feb 27 21:11:50 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 27 Feb 2008 20:11:50 +0000 Subject: [python-win32] Detecting when the Windows screen saver comes on In-Reply-To: References: Message-ID: <47C5C406.3050401@timgolden.me.uk> happybrowndog wrote: > Hello, > > Does anyone know how to detect when the windows screen saver comes on? > Any other kind of detection of windows being idle (ie: sleep or > whatever) would also be useful if you happen to know it. I'm basically > looking for whatever is easy to implement. My wxpython chat application > needs to know if the user has gone "idle" by detecting whatever > windows event will tell me that. There *are* -- slightly awkward -- ways of doing such things (eg a combination of polling the GetSystemParameterInfo with the right flags and / or monitoring for a system power event) but I came across this article: http://www.codeproject.com/KB/cs/GetIdleTimeWithCS.aspx which would seem to be do-able in Python with ctypes. Haven't tried it myself, mind you. TJG From happybrowndog at hotmail.com Wed Feb 27 21:20:37 2008 From: happybrowndog at hotmail.com (happybrowndog) Date: Wed, 27 Feb 2008 12:20:37 -0800 Subject: [python-win32] Is Mark Hammond going to produce a new Python Programming on Win32 book? In-Reply-To: References: Message-ID: Actually I'd like to add one more thing about Mark's book. You know what brought me over to Python? I was sick and tired of writing desktop applications for Windows with VB, VFoxpro, and all those moronic language/containers that were not very consistent and felt like the programmer was being spoon fed like a baby. Then I took my server side Java knowledge and decided to apply it client side with Swing, and it resulted in a failed project because it took way too long to develop in, and the results were horrible for the users. I wasted a lot of time on Swing and at the end of it all, my fingers were killing me because of Java's horrid verboseness - and the lack of code generators client side as there are server side ones for J2EE (in retrospect, a language that requires code generation of the language itself has got to be one of the most ridiculous things I've ever come across). I desperately searched for solutions, and found Mark's book on the shelves at Chapters books. I was very intrigued with his discussion on using Delphi and writing python business logic against it. It took me on a detour into writing a pure Delphi app, but something about his book made me curious. A week later I went back to the store and bought the book. I looked at the python code in his book and began learning python because it seemed so clear and made so much sense (especially compared to VB, VFoxpro, and Java) and ... best of all, reminded me of my early post-college days programming in C. In fact, I realized that programming python was like scripting C. I abandoned Delphi and went with what Mark wrote about re: WxPython. I've developed over 20 full fledged apps in WxPython since, with the added advantage of integrating them into windows applications through automation.... all thanks to Mark's book. From jkpeck at aya.yale.edu Wed Feb 27 21:57:19 2008 From: jkpeck at aya.yale.edu (Jon Peck) Date: Wed, 27 Feb 2008 13:57:19 -0700 Subject: [python-win32] Launch a New Instance of Excel Message-ID: Message: 4 Date: Wed, 27 Feb 2008 16:07:33 +0000 From: Tim Golden Subject: Re: [python-win32] Launching a New Instance of an Application Cc: python-win32 at python.org Message-ID: <47C58AC5.8070507 at timgolden.me.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Jon Peck wrote: > We need to launch Excel from a Python application using win32com, and we > want to be sure that we get a new instance whether or not Excel is already > running. What is the best way to do this? http://timgolden.me.uk/python/win32_how_do_i/start-a-new-com-instance.html TJG ------------------------------ [>>>Peck, Jon] Thanks for the pointer. It worked perfectly. But, in the spirit of self help, where could I have found DispatchEx documentation that would have explained this (other than the website above)? Regards, Jon Peck -- Jon K Peck jkpeck at gmail.com 505-983-1955 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080227/6b583e43/attachment.htm From larry.bates at websafe.com Wed Feb 27 22:01:08 2008 From: larry.bates at websafe.com (Larry Bates) Date: Wed, 27 Feb 2008 15:01:08 -0600 Subject: [python-win32] Help calling IProgressDialog Interface In-Reply-To: References: <47C56BFD.3040400@websafe.com> <47C57182.3020808@timgolden.me.uk> Message-ID: Larry Bates wrote: > Tim Golden wrote: >> Larry Bates wrote: >>> I almost have it completely working with one remaining problem. The dialog >>> allows the user to specify an AVI that runs showing activity while things are >>> going in the background. There are AVIs stored in shell32.dll for move/copy >>> (resource number 160 and 161 respectively). Below is the VB code to set these, >>> but I'm not getting anywhere trying to convert. I was hoping you could take a >>> quick look. >>> ' File operation animations resource IDs in shell32.dll >>> Private Const RES_AVI_FILEMOVE = 160 >>> Private Const RES_AVI_FILECOPY = 161 >>> >>> With oProgDlg >>> .SetTitle IIf(fMove, "Moving file...", "Copying file...") >>> .SetAnimation m_hLibShell32, IIf(fMove, RES_AVI_FILEMOVE, RES_AVI_FILECOPY) >>> .SetLine 1, txtSource.Text, 1&, ByVal 0& >>> .SetLine 2, txtDest.Text, 1&, ByVal 0& >>> .SetCancelMsg "Please wait...", ByVal 0& >>> .StartProgressDialog Me.hwnd, Nothing, PROGDLG_MODAL Or _ >>> PROGDLG_AUTOTIME Or _ >>> PROGDLG_NOMINIMIZE, ByVal 0& >>> End With >>> >>> Private Sub Form_Load() >>> >>> ' Load Shell32 to access the AVI animation resources >>> m_hLibShell32 = LoadLibrary("shell32.dll") >>> >>> End Sub >>> >>> Private Sub Form_Unload(Cancel As Integer) >>> >>> Call FreeLibrary(m_hLibShell32) >>> >>> End Sub >> Which bit aren't you getting, Larry? (Not sure how far your >> existing expertise extends). The LoadLibrary stuff is what >> ctypes.windll encapsulates. ie >> >> >> import ctypes >> shell32 = ctypes.windll.shell32 >> m_hLibShell32 = shell32._handle >> >> >> gets you the same as the Form_Load Sub. Alternatively, you >> could import the lower-level _ctypes and use its LoadLibrary >> binding directly: >> >> >> import _ctypes >> m_hLibShell32 = _ctypes.LoadLibrary ("shell32.dll") >> >> # >> # >> >> _ctypes.FreeLibrary (m_hLibShell32) >> >> >> But maybe that's not the bit you're having trouble with? >> >> TJG > > Tim, > > That did the trick. It was the: > > m_hLibShell32 = shell32._handle > > that I needed. > > Thanks loads. > > -Larry One last problem. When I working class inside my COM object and everything works until I (or Python) destroys the reference to this object. I then get this exception: Exception exceptions.ValueError: 'COM method call without VTable' in > ignored I tried putting del inside try block with blank exception (normally a bad idea but in this case I thought it would be OK) as follows: try: del CB except: pass and try: del CB except pythoncom.com_error: pass but neither of these worke (e.g. exception still echos to console). I guess I'm missing a step in "properly" destroying this object, but I can't seem to determine what it is. Any suggestions would be greatly appreciated. Regards, Larry From timr at probo.com Wed Feb 27 22:52:49 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 27 Feb 2008 13:52:49 -0800 Subject: [python-win32] Is Mark Hammond going to produce a new Python Programming on Win32 book? In-Reply-To: References: Message-ID: <47C5DBB1.1030105@probo.com> happybrowndog wrote: > I've had Mark's Python Programming on Win32 book for 6 years now, and > it's been a constant source of information and a joy to read and possess. > > Windows has added a lot since the book hit the shelves, with the > maturation of .Net, winforms and other application technologies, and a > "new" OS. There's still the old way of doing things with COM, etc. The > Ctypes package has also fleshed out to be very useful on Windows. Then > there's IronPython, and Python for .Net. > Well, there's an interesting issue here. Much of the new stuff you have mentioned has nothing to do with the Python that we know and love. .NET and winforms (which is part of .NET) requires managed code, and that means IronPython. IronPython is NOT the same as Python; although the language is the same, the library and the idiomatic usage are so very different that it's difficult for one person to be competent in both. Indeed, for things that are not .NET, Mark's book is still pretty much current. Perhaps we'll get a book on IronPython to make it a little more approachable for us CPython users. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Feb 27 23:49:30 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 27 Feb 2008 14:49:30 -0800 Subject: [python-win32] Is Mark Hammond going to produce a new Python Programming on Win32 book? In-Reply-To: <47C5E507.9020801@voidspace.org.uk> References: <47C5DBB1.1030105@probo.com> <47C5E507.9020801@voidspace.org.uk> Message-ID: <47C5E8FA.5020502@probo.com> Michael Foord wrote: > Tim Roberts wrote: >> >> Well, there's an interesting issue here. Much of the new stuff you >> have mentioned has nothing to do with the Python that we know and >> love. .NET and winforms (which is part of .NET) requires managed >> code, and that means IronPython. IronPython is NOT the same as >> Python; although the language is the same, the library and the >> idiomatic usage are so very different that it's difficult for one >> person to be competent in both. >> >> > > Hmmm... that hasn't been my experience. Programming IronPython with > idiomatic Python works very well. Perhaps the issue is more than I'm not comfortable with idiomatic .NET. I did take a semi-serious stab at working with WPF in IronPython, but it just wasn't comfortable. I am very pleased to see that an IronPython book is in the works. Because I think WPF is one of the most exciting things to come out of Microsoft in a very long time, I will be among the first in line. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From fuzzyman at voidspace.org.uk Wed Feb 27 23:32:39 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 27 Feb 2008 22:32:39 +0000 Subject: [python-win32] Is Mark Hammond going to produce a new Python Programming on Win32 book? In-Reply-To: <47C5DBB1.1030105@probo.com> References: <47C5DBB1.1030105@probo.com> Message-ID: <47C5E507.9020801@voidspace.org.uk> Tim Roberts wrote: > happybrowndog wrote: > >> I've had Mark's Python Programming on Win32 book for 6 years now, and >> it's been a constant source of information and a joy to read and possess. >> >> Windows has added a lot since the book hit the shelves, with the >> maturation of .Net, winforms and other application technologies, and a >> "new" OS. There's still the old way of doing things with COM, etc. The >> Ctypes package has also fleshed out to be very useful on Windows. Then >> there's IronPython, and Python for .Net. >> >> > > Well, there's an interesting issue here. Much of the new stuff you have > mentioned has nothing to do with the Python that we know and love. .NET > and winforms (which is part of .NET) requires managed code, and that > means IronPython. IronPython is NOT the same as Python; although the > language is the same, the library and the idiomatic usage are so very > different that it's difficult for one person to be competent in both. > > Hmmm... that hasn't been my experience. Programming IronPython with idiomatic Python works very well. Michael http://www.manning.com/foord > Indeed, for things that are not .NET, Mark's book is still pretty much > current. > > Perhaps we'll get a book on IronPython to make it a little more > approachable for us CPython users. > > From fuzzyman at voidspace.org.uk Wed Feb 27 23:58:23 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 27 Feb 2008 22:58:23 +0000 Subject: [python-win32] Is Mark Hammond going to produce a new Python Programming on Win32 book? In-Reply-To: <47C5E8FA.5020502@probo.com> References: <47C5DBB1.1030105@probo.com> <47C5E507.9020801@voidspace.org.uk> <47C5E8FA.5020502@probo.com> Message-ID: <47C5EB0F.2070203@voidspace.org.uk> Tim Roberts wrote: > Michael Foord wrote: > >> Tim Roberts wrote: >> >>> >>> Well, there's an interesting issue here. Much of the new stuff you >>> have mentioned has nothing to do with the Python that we know and >>> love. .NET and winforms (which is part of .NET) requires managed >>> code, and that means IronPython. IronPython is NOT the same as >>> Python; although the language is the same, the library and the >>> idiomatic usage are so very different that it's difficult for one >>> person to be competent in both. >>> >>> >>> >> Hmmm... that hasn't been my experience. Programming IronPython with >> idiomatic Python works very well. >> > > Perhaps the issue is more than I'm not comfortable with idiomatic .NET. > I did take a semi-serious stab at working with WPF in IronPython, but it > just wasn't comfortable. > > I am very pleased to see that an IronPython book is in the works. > Because I think WPF is one of the most exciting things to come out of > Microsoft in a very long time, I will be among the first in line. > > Ok. Personally I have found that I can still *basically* use idiomatic Python when working with .NET classes. The exception is when optimizing as the performance profiles of IronPython vs CPython are very different. "The IronPython Book" is already available in "early access" preview form and the WPF chapter will appear in the preview in the next couple of weeks or so - http://www.manning.com/foord Michael From theller at ctypes.org Thu Feb 28 08:15:09 2008 From: theller at ctypes.org (Thomas Heller) Date: Thu, 28 Feb 2008 08:15:09 +0100 Subject: [python-win32] Help calling IProgressDialog Interface In-Reply-To: References: <47C56BFD.3040400@websafe.com> <47C57182.3020808@timgolden.me.uk> Message-ID: Larry Bates schrieb: > One last problem. When I working class inside my COM object and everything > works until I (or Python) destroys the reference to this object. I then get > this exception: > > Exception exceptions.ValueError: 'COM method call without VTable' in od POINTER(IProgressDialog).__del__ of 1ef5e90>> ignored > Can you post (or send by mail) your code? Thanks, Thomas From singhai.nish at gmail.com Thu Feb 28 10:04:12 2008 From: singhai.nish at gmail.com (kNish) Date: Thu, 28 Feb 2008 14:34:12 +0530 Subject: [python-win32] createtoolbar Message-ID: <81bfef2e0802280104o357a0306h7f5ff00f8d445fbf@mail.gmail.com> Hi, #!/usr/bin/python # panels.py import wx class Panels(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title) hbox = wx.BoxSizer(wx.HORIZONTAL) splitter = wx.SplitterWindow(self, -1) vbox1 = wx.BoxSizer(wx.VERTICAL) panel1 = wx.Panel(splitter, -1) panel11 = wx.Panel(panel1, -1, size=(-1, 40)) panel11.SetBackgroundColour('#53728c') st1 = wx.StaticText(panel11, -1, 'Feeds', (5, 5)) st1.SetForegroundColour('WHITE') panel12 = wx.Panel(panel1, -1, style=wx.BORDER_SUNKEN) panel12.SetBackgroundColour('WHITE') vbox1.Add(panel11, 0, wx.EXPAND) vbox1.Add(panel12, 1, wx.EXPAND) panel1.SetSizer(vbox1) vbox2 = wx.BoxSizer(wx.VERTICAL) panel2 = wx.Panel(splitter, -1) panel21 = wx.Panel(panel2, -1, size=(-1, 40), style=wx.NO_BORDER) st2 = wx.StaticText(panel21, -1, 'Articles', (5, 5)) st2.SetForegroundColour('WHITE') panel21.SetBackgroundColour('#53728c') panel22 = wx.Panel(panel2, -1, style=wx.BORDER_RAISED) panel22.SetBackgroundColour('WHITE') vbox2.Add(panel21, 0, wx.EXPAND) vbox2.Add(panel22, 1, wx.EXPAND) panel2.SetSizer(vbox2) toolbar = self.CreateToolBar(self) toolbar.AddLabelTool(1, 'Exit', wx.Bitmap('icons/stock_exit.png')) toolbar.Realize() self.Bind(wx.EVT_TOOL, self.ExitApp, id=1) hbox.Add(splitter, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) self.SetSizer(hbox) self.CreateStatusBar() splitter.SplitVertically(panel1, panel2) self.Centre() self.Show(True) def ExitApp(self, event): self.Close() app = wx.App() Panels(None, -1, 'Panels') app.MainLoop() createToolbar gives an error. (Look at the Attachment). How may I get this to work successfully. BRgds, kNish -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080228/7d46ba14/attachment-0001.htm -------------- next part -------------- A non-text attachment was scrubbed... Name: createtoolbarerror.JPG Type: image/jpeg Size: 27222 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20080228/7d46ba14/attachment-0001.jpeg From lreenaers at ressource-toi.org Thu Feb 28 14:30:29 2008 From: lreenaers at ressource-toi.org (Ludovic Reenaers) Date: Thu, 28 Feb 2008 14:30:29 +0100 Subject: [python-win32] createtoolbar In-Reply-To: <81bfef2e0802280104o357a0306h7f5ff00f8d445fbf@mail.gmail.com> References: <81bfef2e0802280104o357a0306h7f5ff00f8d445fbf@mail.gmail.com> Message-ID: <47C6B775.3070103@ressource-toi.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 kNish a ?crit : > Hi, > > #!/usr/bin/python > > # panels.py > > import wx > > > class Panels(wx.Frame): > def __init__(self, parent, id, title): > wx.Frame.__init__(self, parent, id, title) > > hbox = wx.BoxSizer(wx.HORIZONTAL) > splitter = wx.SplitterWindow(self, -1) > > vbox1 = wx.BoxSizer(wx.VERTICAL) > panel1 = wx.Panel(splitter, -1) > panel11 = wx.Panel(panel1, -1, size=(-1, 40)) > panel11.SetBackgroundColour('#53728c') > st1 = wx.StaticText(panel11, -1, 'Feeds', (5, 5)) > st1.SetForegroundColour('WHITE') > > panel12 = wx.Panel(panel1, -1, style=wx.BORDER_SUNKEN) > panel12.SetBackgroundColour('WHITE') > > vbox1.Add(panel11, 0, wx.EXPAND) > vbox1.Add(panel12, 1, wx.EXPAND) > > panel1.SetSizer(vbox1) > > vbox2 = wx.BoxSizer(wx.VERTICAL) > panel2 = wx.Panel(splitter, -1) > panel21 = wx.Panel(panel2, -1, size=(-1, 40), style=wx.NO_BORDER) > st2 = wx.StaticText(panel21, -1, 'Articles', (5, 5)) > st2.SetForegroundColour('WHITE') > > panel21.SetBackgroundColour('#53728c') > panel22 = wx.Panel(panel2, -1, style=wx.BORDER_RAISED) > > panel22.SetBackgroundColour('WHITE') > vbox2.Add(panel21, 0, wx.EXPAND) > vbox2.Add(panel22, 1, wx.EXPAND) > > panel2.SetSizer(vbox2) > > toolbar = self.CreateToolBar(self) > toolbar.AddLabelTool(1, 'Exit', wx.Bitmap('icons/stock_exit.png')) > toolbar.Realize() > self.Bind(wx.EVT_TOOL, self.ExitApp, id=1) > > hbox.Add(splitter, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) > self.SetSizer(hbox) > self.CreateStatusBar() > splitter.SplitVertically(panel1, panel2) > self.Centre() > self.Show(True) > > > def ExitApp(self, event): > self.Close() > > > app = wx.App() > Panels(None, -1, 'Panels') > app.MainLoop() > > > createToolbar gives an error. (Look at the Attachment). How may I get > this to work successfully. > > BRgds, > > kNish > > > > ------------------------------------------------------------------------ > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 seems that you missed an argument...try like this self.toolbar = self.CreateToolBar(wx.TB_HORIZONTAL |wx.NO_BORDER |wx.TB_FLAT) - -- Two Major products have come out of Berkeley, Unix and LSD. It is uncertain which caused the other. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHxrd0abe5k24WqmcRAjvOAKDboJo/je6T76niAQIR78zHJIl2kQCg53DB f5QY8Ec/z7HwJmlMjhLmzQY= =QdNP -----END PGP SIGNATURE----- From mail at timgolden.me.uk Thu Feb 28 15:25:52 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 28 Feb 2008 14:25:52 +0000 Subject: [python-win32] Launch a New Instance of Excel In-Reply-To: References: Message-ID: <47C6C470.1020506@timgolden.me.uk> > [>>>Peck, Jon] Thanks for the pointer. It worked perfectly. But, in the > spirit of self help, where could I have found DispatchEx documentation that > would have explained this (other than the website above)? One of those perennially unanswerable questions, I'm afraid. A lot of the pywin32 stuff is pretty much raw Win32 API. The win32com stuff is a little more wrapped, but still fairly much expects you to dive into MSDN to find out what you want and then look for the equivalent thing in the pywin32.chm file! Which is why I try to put things up on my site, and why I and others try our best to field questions on this and the main Python list. Mark Hammond, Roger Upole and the other contributors to the pywin32 extensions do a great job of getting things in there and trying to track the moving target that is the Windows API. I feel that one way in which the rest of us can contribute is to produce documentation at whatever level we can. (I have a long-unrealised plan to start a documentation site for Python-on-Windows, but as they say: The best-laid plans of mice and men... Maybe one day I'll realise it :) TJG From mdriscoll at co.marshall.ia.us Thu Feb 28 15:28:09 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Thu, 28 Feb 2008 08:28:09 -0600 (CST) Subject: [python-win32] createtoolbar In-Reply-To: References: Message-ID: <002401c87a16$0a43e4f0$96c051d8@mcis0492> Hi, > > Message: 1 > Date: Thu, 28 Feb 2008 14:34:12 +0530 > From: kNish > Subject: [python-win32] createtoolbar > To: python-win32 at python.org > Message-ID: > <81bfef2e0802280104o357a0306h7f5ff00f8d445fbf at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > Hi, > > #!/usr/bin/python > > # panels.py > > import wx > > > class Panels(wx.Frame): > def __init__(self, parent, id, title): > wx.Frame.__init__(self, parent, id, title) > > hbox = wx.BoxSizer(wx.HORIZONTAL) > splitter = wx.SplitterWindow(self, -1) > > vbox1 = wx.BoxSizer(wx.VERTICAL) > panel1 = wx.Panel(splitter, -1) > panel11 = wx.Panel(panel1, -1, size=(-1, 40)) > panel11.SetBackgroundColour('#53728c') > st1 = wx.StaticText(panel11, -1, 'Feeds', (5, 5)) > st1.SetForegroundColour('WHITE') > > panel12 = wx.Panel(panel1, -1, style=wx.BORDER_SUNKEN) > panel12.SetBackgroundColour('WHITE') > > vbox1.Add(panel11, 0, wx.EXPAND) > vbox1.Add(panel12, 1, wx.EXPAND) > > panel1.SetSizer(vbox1) > > vbox2 = wx.BoxSizer(wx.VERTICAL) > panel2 = wx.Panel(splitter, -1) > panel21 = wx.Panel(panel2, -1, size=(-1, 40), > style=wx.NO_BORDER) > st2 = wx.StaticText(panel21, -1, 'Articles', (5, 5)) > st2.SetForegroundColour('WHITE') > > panel21.SetBackgroundColour('#53728c') > panel22 = wx.Panel(panel2, -1, style=wx.BORDER_RAISED) > > panel22.SetBackgroundColour('WHITE') > vbox2.Add(panel21, 0, wx.EXPAND) > vbox2.Add(panel22, 1, wx.EXPAND) > > panel2.SetSizer(vbox2) > > toolbar = self.CreateToolBar(self) > toolbar.AddLabelTool(1, 'Exit', > wx.Bitmap('icons/stock_exit.png')) > toolbar.Realize() > self.Bind(wx.EVT_TOOL, self.ExitApp, id=1) > > hbox.Add(splitter, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) > self.SetSizer(hbox) > self.CreateStatusBar() > splitter.SplitVertically(panel1, panel2) > self.Centre() > self.Show(True) > > > def ExitApp(self, event): > self.Close() > > > app = wx.App() > Panels(None, -1, 'Panels') > app.MainLoop() > > > createToolbar gives an error. (Look at the Attachment). How > may I get this to work successfully. > > BRgds, > > kNish First of all, this is a wxPython question, NOT a PyWin32 question. You should be posting there: http://wxpython.org/maillist.php Secondly, you sent code that does not work. You need to change line 41 from toolbar = self.CreateToolBar(self) to toolbar = self.CreateToolBar() And if you use images in your code, you need to provide them. I added the following line right after the one above: ico = wx.ArtProvider.GetBitmap(wx.ART_QUIT, wx.ART_TOOLBAR, (16,16)) and then changed toolbar.AddLabelTool(1, 'Exit', wx.Bitmap('icons/stock_exit.png')) to toolbar.AddLabelTool(1, 'Exit', ico) See http://www.wxpython.org/docs/api/wx.ArtProvider-class.html for more information on generic icons for wxPython. So the full code with changes if below: import wx class Panels(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title) hbox = wx.BoxSizer(wx.HORIZONTAL) splitter = wx.SplitterWindow(self, -1) vbox1 = wx.BoxSizer(wx.VERTICAL) panel1 = wx.Panel(splitter, -1) panel11 = wx.Panel(panel1, -1, size=(-1, 40)) panel11.SetBackgroundColour('#53728c') st1 = wx.StaticText(panel11, -1, 'Feeds', (5, 5)) st1.SetForegroundColour('WHITE') panel12 = wx.Panel(panel1, -1, style=wx.BORDER_SUNKEN) panel12.SetBackgroundColour('WHITE') vbox1.Add(panel11, 0, wx.EXPAND) vbox1.Add(panel12, 1, wx.EXPAND) panel1.SetSizer(vbox1) vbox2 = wx.BoxSizer(wx.VERTICAL) panel2 = wx.Panel(splitter, -1) panel21 = wx.Panel(panel2, -1, size=(-1, 40), style=wx.NO_BORDER) st2 = wx.StaticText(panel21, -1, 'Articles', (5, 5)) st2.SetForegroundColour('WHITE') panel21.SetBackgroundColour('#53728c') panel22 = wx.Panel(panel2, -1, style=wx.BORDER_RAISED) panel22.SetBackgroundColour('WHITE') vbox2.Add(panel21, 0, wx.EXPAND) vbox2.Add(panel22, 1, wx.EXPAND) panel2.SetSizer(vbox2) toolbar = self.CreateToolBar() ico = wx.ArtProvider.GetBitmap(wx.ART_QUIT, wx.ART_TOOLBAR, (16,16)) toolbar.AddLabelTool(1, 'Exit', ico) toolbar.Realize() self.Bind(wx.EVT_TOOL, self.ExitApp, id=1) hbox.Add(splitter, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) self.SetSizer(hbox) self.CreateStatusBar() splitter.SplitVertically(panel1, panel2) self.Centre() self.Show(True) def ExitApp(self, event): self.Close() app = wx.App(0) Panels(None, -1, 'Panels') app.MainLoop() In the future, be sure to post to the wxPython group if you have a question about that GUI toolkit. If you need help with Mark Hammond's win32 modules, drop us a line. Mike From chinux at gmail.com Thu Feb 28 16:12:44 2008 From: chinux at gmail.com (Chen) Date: Thu, 28 Feb 2008 10:12:44 -0500 Subject: [python-win32] How to delete a dispatched object Message-ID: Hi I am wondering how could I delete an dispatched object? Do I just delete the reference to that object? Does python garbage collector take care of everything after I delete the reference? Is there any method which I could use to delete a dispatched object? -- CHEN HUANG COMPUTER Engineering McMaster University -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080228/b8e874be/attachment.htm From patrick.hartling at gmail.com Thu Feb 28 18:31:14 2008 From: patrick.hartling at gmail.com (Patrick Hartling) Date: Thu, 28 Feb 2008 11:31:14 -0600 Subject: [python-win32] pywin32 installer problems with Python 2.6 Message-ID: Are there any known problems with the pywin32 installer when building against Python 2.6? I am using the 32-bit build of Python 2.6.13936 installed using the pre-built daily snapshot installer. Everything compiles fine, and running 'setup.py bdist_wininst' executes without errors. However, when I run the installer, it crashes when trying to compile files to .pyc. Running 'setup.py install' works just fine, and I can certainly work with an installation made in that way. It would help the other people in my group if we had a single installer, though. I can dig into this some more with debug builds of Python and pywin32 if it would help. -Patrick -- Patrick L. Hartling Senior Software Engineer, Priority 5 http://www.priority5.com/ -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 186 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/python-win32/attachments/20080228/d46464fe/attachment.pgp From mhammond at skippinet.com.au Thu Feb 28 23:44:19 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 29 Feb 2008 09:44:19 +1100 Subject: [python-win32] How to delete a dispatched object In-Reply-To: References: Message-ID: <056501c87a5b$77d6fd50$6784f7f0$@com.au> As soon as the last reference to the PyIDispatch object goes away, the COM object is released. Unfortunately, neither Python nor COM offer a way to actually destroy an object - they are both independently reference counted so the only option available is to drop all references being held. In Python, this means that: ob = win32com.client.Dispatch(.) del ob would cause the object to die (as would assigning 'ob' to something, such as None), but: ob = win32com.client.Dispatch(.) ob2 = ob del ob would not - nothing you can do to 'ob' can help you now - you must also remove the reference in 'ob2' Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Chen Sent: Friday, 29 February 2008 2:13 AM To: python-win32 at python.org Subject: [python-win32] How to delete a dispatched object Hi I am wondering how could I delete an dispatched object? Do I just delete the reference to that object? Does python garbage collector take care of everything after I delete the reference? Is there any method which I could use to delete a dispatched object? -- CHEN HUANG COMPUTER Engineering McMaster University -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080229/06492078/attachment-0001.htm From mhammond at skippinet.com.au Fri Feb 29 00:21:52 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 29 Feb 2008 10:21:52 +1100 Subject: [python-win32] pywin32 installer problems with Python 2.6 In-Reply-To: References: Message-ID: <057801c87a60$b6a45050$23ecf0f0$@com.au> Its likely that you snapshot of 2.5 is built with a different MSVC version than pywin32 (python decided on VS2007 in the meantime). Its not immediately obvious how that would cause the problem you see, but it may well. Please let me know if http://starship.python.net/crew/mhammond/pywin32-210.9.win32-py2.6.exe works any better for you (it does for me) Mark > -----Original Message----- > From: python-win32-bounces at python.org [mailto:python-win32- > bounces at python.org] On Behalf Of Patrick Hartling > Sent: Friday, 29 February 2008 4:31 AM > To: python-win32 at python.org > Subject: [python-win32] pywin32 installer problems with Python 2.6 > > Are there any known problems with the pywin32 installer when building > against Python 2.6? I am using the 32-bit build of Python 2.6.13936 > installed using the pre-built daily snapshot installer. Everything > compiles fine, and running 'setup.py bdist_wininst' executes without > errors. However, when I run the installer, it crashes when trying to > compile files to .pyc. Running 'setup.py install' works just fine, and > I can certainly work with an installation made in that way. It would > help the other people in my group if we had a single installer, though. > I can dig into this some more with debug builds of Python and > pywin32 if it would help. > > -Patrick > > > -- > Patrick L. Hartling > Senior Software Engineer, Priority 5 > http://www.priority5.com/ From mhammond at skippinet.com.au Fri Feb 29 00:32:51 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 29 Feb 2008 10:32:51 +1100 Subject: [python-win32] pywin32 installer problems with Python 2.6 In-Reply-To: <057801c87a60$b6a45050$23ecf0f0$@com.au> References: <057801c87a60$b6a45050$23ecf0f0$@com.au> Message-ID: <057901c87a62$3f228630$bd679290$@com.au> Oops - I should proof-read, especially before the first coffee is empty: > Its likely that you snapshot of 2.5 is built with a different MSVC I meant 2.6 there (and an extra 'r' :) Mark From patrick.hartling at gmail.com Fri Feb 29 00:37:32 2008 From: patrick.hartling at gmail.com (Patrick Hartling) Date: Thu, 28 Feb 2008 17:37:32 -0600 Subject: [python-win32] pywin32 installer problems with Python 2.6 In-Reply-To: <057801c87a60$b6a45050$23ecf0f0$@com.au> References: <057801c87a60$b6a45050$23ecf0f0$@com.au> Message-ID: <8788B081-5224-4E5A-B28D-CF6843A30A34@gmail.com> I am using Visual C++ 9.0 to build pywin32, and Dependency Walker shows that the pyhon.exe from the 2.6 snapshot is linked against the Visual C++ 9.0 runtime. The installer that you provided crashes for me in the same way. Perhaps it's a bug in Python or something wrong with my machine? Other installers that I have made today for Python 2.6 have succeeded. Very curious. -Patrick On Feb 28, 2008, at 5:21 PM, Mark Hammond wrote: > Its likely that you snapshot of 2.5 is built with a different MSVC > version > than pywin32 (python decided on VS2007 in the meantime). Its not > immediately obvious how that would cause the problem you see, but it > may > well. Please let me know if > http://starship.python.net/crew/mhammond/pywin32-210.9.win32- > py2.6.exe works > any better for you (it does for me) > > Mark > >> -----Original Message----- >> From: python-win32-bounces at python.org [mailto:python-win32- >> bounces at python.org] On Behalf Of Patrick Hartling >> Sent: Friday, 29 February 2008 4:31 AM >> To: python-win32 at python.org >> Subject: [python-win32] pywin32 installer problems with Python 2.6 >> >> Are there any known problems with the pywin32 installer when building >> against Python 2.6? I am using the 32-bit build of Python 2.6.13936 >> installed using the pre-built daily snapshot installer. Everything >> compiles fine, and running 'setup.py bdist_wininst' executes without >> errors. However, when I run the installer, it crashes when trying to >> compile files to .pyc. Running 'setup.py install' works just fine, >> and >> I can certainly work with an installation made in that way. It would >> help the other people in my group if we had a single installer, >> though. >> I can dig into this some more with debug builds of Python and >> pywin32 if it would help. >> >> -Patrick >> >> >> -- >> Patrick L. Hartling >> Senior Software Engineer, Priority 5 >> http://www.priority5.com/ > > -- Patrick L. Hartling Senior Software Engineer, Priority 5 http://www.priority5.com/ -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 186 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/python-win32/attachments/20080228/4d385081/attachment.pgp From mhammond at skippinet.com.au Fri Feb 29 00:54:11 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 29 Feb 2008 10:54:11 +1100 Subject: [python-win32] pywin32 installer problems with Python 2.6 In-Reply-To: <8788B081-5224-4E5A-B28D-CF6843A30A34@gmail.com> References: <057801c87a60$b6a45050$23ecf0f0$@com.au> <8788B081-5224-4E5A-B28D-CF6843A30A34@gmail.com> Message-ID: <058701c87a65$397ce0b0$ac76a210$@com.au> > I am using Visual C++ 9.0 to build pywin32, and Dependency Walker shows > that the pyhon.exe from the 2.6 snapshot is linked against the Visual > C++ 9.0 runtime. Ahh - sorry, I missed that you are building pywin32 yourself. > The installer that you provided crashes for me in the same way. > Perhaps it's a bug in Python or something wrong with my machine? Other > installers that I have made today for Python 2.6 have succeeded. Very > curious. Yes, strange. The creation of the .pyc files is done by the installer exe and it will be *that* runtime which is of interest - but depends shows the installer exe links against msvcr90.dll which is what we want. I'm surprised a version you build yourself does that though, as I don't believe the skeleton executable has been updated in the python core yet. That installer binary works for me (at least, it doesn't crash - but it does give a useless error message at the end ("*** run_installscript: internal error 0xFFFFFFFF ***"). *sob* IIRC, building python and pywin32 from source - even the release versions - should give .pdb files which are useful for debugging. Have you tried breaking into the process using the debugger? Mark From patrick.hartling at gmail.com Fri Feb 29 01:10:17 2008 From: patrick.hartling at gmail.com (Patrick Hartling) Date: Thu, 28 Feb 2008 18:10:17 -0600 Subject: [python-win32] pywin32 installer problems with Python 2.6 In-Reply-To: <058701c87a65$397ce0b0$ac76a210$@com.au> References: <057801c87a60$b6a45050$23ecf0f0$@com.au> <8788B081-5224-4E5A-B28D-CF6843A30A34@gmail.com> <058701c87a65$397ce0b0$ac76a210$@com.au> Message-ID: <13AE6C47-19F9-42A0-8545-9E82B0F9245D@gmail.com> On Feb 28, 2008, at 5:54 PM, Mark Hammond wrote: >> I am using Visual C++ 9.0 to build pywin32, and Dependency Walker >> shows >> that the pyhon.exe from the 2.6 snapshot is linked against the Visual >> C++ 9.0 runtime. > > Ahh - sorry, I missed that you are building pywin32 yourself. > >> The installer that you provided crashes for me in the same way. >> Perhaps it's a bug in Python or something wrong with my machine? >> Other >> installers that I have made today for Python 2.6 have succeeded. Very >> curious. > > Yes, strange. The creation of the .pyc files is done by the > installer exe > and it will be *that* runtime which is of interest - but depends > shows the > installer exe links against msvcr90.dll which is what we want. I'm > surprised a version you build yourself does that though, as I don't > believe > the skeleton executable has been updated in the python core yet. That > installer binary works for me (at least, it doesn't crash - but it > does give > a useless error message at the end ("*** run_installscript: internal > error > 0xFFFFFFFF ***"). *sob* > > IIRC, building python and pywin32 from source - even the release > versions - > should give .pdb files which are useful for debugging. Have you tried > breaking into the process using the debugger? Yes, and it showed the crash happening in a call to realloc(). The call stack seemed oddly short, so I may have been looking at the wrong thread or something like that. I did not give it a lot of attention at the time, but I can look into it more tomorrow (in about 14 hours). Thanks for the feedback. -Patrick -- Patrick L. Hartling Senior Software Engineer, Priority 5 http://www.priority5.com/ -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 186 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/python-win32/attachments/20080228/3c87e023/attachment.pgp From jkpeck at aya.yale.edu Fri Feb 29 20:03:21 2008 From: jkpeck at aya.yale.edu (Jon Peck) Date: Fri, 29 Feb 2008 12:03:21 -0700 Subject: [python-win32] win32com Documentation In-Reply-To: References: Message-ID: On Fri, Feb 29, 2008 at 12:02 PM, Jon Peck wrote: > Date: Thu, 28 Feb 2008 14:25:52 +0000 > From: Tim Golden > Subject: Re: [python-win32] Launch a New Instance of Excel > Cc: python-win32 at python.org > Message-ID: <47C6C470.1020506 at timgolden.me.uk> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > > [>>>Peck, Jon] Thanks for the pointer. It worked perfectly. But, in > the > > spirit of self help, where could I have found DispatchEx documentation > that > > would have explained this (other than the website above)? > > One of those perennially unanswerable questions, I'm afraid. A lot > of the pywin32 stuff is pretty much raw Win32 API. The win32com > stuff is a little more wrapped, but still fairly much expects you > to dive into MSDN to find out what you want and then look for > the equivalent thing in the pywin32.chm file! > > Which is why I try to put things up on my site, and why I and > others try our best to field questions on this and the main > Python list. Mark Hammond, Roger Upole and the other contributors > to the pywin32 extensions do a great job of getting things in > there and trying to track the moving target that is the Windows > API. I feel that one way in which the rest of us can contribute > is to produce documentation at whatever level we can. > > (I have a long-unrealised plan to start a documentation site > for Python-on-Windows, but as they say: The best-laid plans > of mice and men... Maybe one day I'll realise it :) > > TJG > > >>>JKP > The documentation is the most frustrating part of the win32com library. > And DispatchEx does not even appear in pywin32.chm (or in the MH book). > At least I couldn't find it. > > -- Jon K Peck jkpeck at gmail.com 505-983-1955 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20080229/ffe7c928/attachment.htm