From gansevle at ewi.utwente.nl Wed Jun 1 11:10:13 2005 From: gansevle at ewi.utwente.nl (Fred Gansevles) Date: Wed, 01 Jun 2005 11:10:13 +0200 Subject: [python-win32] Ref-count bug in win32file.GetQueuedCompletionStatus Message-ID: <20050601091014.2E43B508BF@mamba.cs.utwente.nl> Hi, I think I've found a ref-count bug in win32file.GetQueuedCompletionStatus running "svcbug.py s" starts a correct server and "svcbug.py s b" starts a buggy server. running "svcbug.py c" starts a client ____________________________________________________________________________ # svcbug.py import win32file, win32pipe, pywintypes PIPE = r"\\.\pipe\Bug.Svc" BUFSIZE = 512 class Iocp: def __init__(self, object): self.port = win32file.CreateIoCompletionPort(-1, 0, 0, 0) win32file.CreateIoCompletionPort(object.handle, self.port, 1, 0) def wait_buggy(self): win32file.GetQueuedCompletionStatus(self.port, -1) def wait_good(self): # keep a reference to the overlapped object self.result = win32file.GetQueuedCompletionStatus(self.port, -1)[3] class PipeService: def __init__(self): self.handle = win32pipe.CreateNamedPipe(PIPE, win32pipe.PIPE_ACCESS_DUPLEX| win32file.FILE_FLAG_OVERLAPPED, win32pipe.PIPE_TYPE_MESSAGE| win32pipe.PIPE_READMODE_MESSAGE| win32pipe.PIPE_WAIT, 1, BUFSIZE, BUFSIZE, win32pipe.NMPWAIT_WAIT_FOREVER, None) self.overlapped = pywintypes.OVERLAPPED() win32pipe.ConnectNamedPipe(self.handle, self.overlapped) def serve(self): data = win32file.ReadFile(self.handle, BUFSIZE)[1] win32file.WriteFile(self.handle, data) def __del__(self): win32pipe.DisconnectNamedPipe(self.handle) if __name__ == '__main__': import sys if 's' in sys.argv: svc = PipeService() iocp = Iocp(svc) if 'bug' in sys.argv: iocp.wait_buggy() else: iocp.wait_good() print sys.getrefcount(svc.overlapped) svc.serve() elif 'c' in sys.argv: print win32pipe.CallNamedPipe(PIPE, "Hello there", BUFSIZE, 0) ____________________________________________________________________________ Fred Gansevles Phone: +31 53 489 4613 Org.: Twente University, Fac. of EWI, Box 217, 7500 AE Enschede, Netherlands "Linux is like a wigwam, No windows, no gates and an apache inside" From python at kareta.de Wed Jun 1 12:47:00 2005 From: python at kareta.de (=?ISO-8859-1?Q?J=FCrgen_Kareta?=) Date: Wed, 01 Jun 2005 12:47:00 +0200 Subject: [python-win32] getting email adresses from outlook In-Reply-To: <8c7f10c60505310620324dd877@mail.gmail.com> References: <429C5231.8040007@kareta.de> <8c7f10c60505310620324dd877@mail.gmail.com> Message-ID: <429D9224.9000905@kareta.de> Hi Simon, thanks for the useful link. I think that should help me out, specialy as I found a mapi viewer on the net wich shows the nessesary ids. I need the CDO com object. But I get errors, when I trie to open the com object. from win32com.client.dynamic import Dispatch s=Dispatch("Mapi.session") results in File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 79, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221005, 'Ung\xfcltige Klassenzeichenfolge', None, None) So it seems to be that mapi/cdo is not or not correct installed on my machine (xp pro sp2). Can anybody tell me, wich libary is needed to support that com object ? thanks in advance, J?rgen From mhammond at skippinet.com.au Wed Jun 1 14:19:31 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 1 Jun 2005 22:19:31 +1000 Subject: [python-win32] getting email adresses from outlook In-Reply-To: <429D9224.9000905@kareta.de> Message-ID: <0c7601c566a4$2b6f6ec0$030a0a0a@enfoldsystems.local> > results in > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line > 79, in _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > pythoncom.IID_IDispatch) > com_error: (-2147221005, 'Ung\xfcltige Klassenzeichenfolge', > None, None) > > So it seems to be that mapi/cdo is not or not correct installed on my > machine (xp pro sp2). I'm guessing that MAPI is installed, but SP2 is preventing "script" (automation) access. I know that well before XP SP2, the SpamBayes project moved away from the high-level Mapi.Session objects towards the low-level win32com.mapi interfaces for similar reasons (eg, an Outlook 2000 SP would cause a confirmation dialog before allowing access to these Mapi.Session objects - the low-level MAPI functions avoided this.) I'm fairly confident that these low-level interfaces work in XP SP2, as SpamBayes apparently does. Unfortunately there is a steep learning curve related to using these interfaces, but on the upside their performance is significantly better ;) Mark From python at kareta.de Wed Jun 1 14:44:52 2005 From: python at kareta.de (=?ISO-8859-1?Q?J=FCrgen_Kareta?=) Date: Wed, 01 Jun 2005 14:44:52 +0200 Subject: [python-win32] getting email adresses from outlook In-Reply-To: <0c7601c566a4$2b6f6ec0$030a0a0a@enfoldsystems.local> References: <0c7601c566a4$2b6f6ec0$030a0a0a@enfoldsystems.local> Message-ID: <429DADC4.60102@kareta.de> Hello, I've solved my problem. After adding CDO to my Outlook installation it works now: from win32com.client.dynamic import Dispatch s=Dispatch("Mapi.session") s.Logon('Microsoft Outlook') entries=s.AddressLists('Globales Adressbuch').AddressEntries for entr in entries: print entr.Name,entr.Fields(0x39fe001e).Value Mark and Simon: thanks for your useful help. I'll look for the spambayes solution, as this code is only the first step for a bigger solution. regards, J?rgen From gansevle at ewi.utwente.nl Wed Jun 1 11:02:25 2005 From: gansevle at ewi.utwente.nl (Fred Gansevles) Date: Wed, 01 Jun 2005 11:02:25 +0200 Subject: [python-win32] Ref-count bug in win32file.GetQueuedCompletionStatus Message-ID: <20050601090225.E830A508BF@mamba.cs.utwente.nl> Hi, I think I've found a ref-count bug in win32file.GetQueuedCompletionStatus running "svcbug.py s" starts a correct server and "svcbug.py s b" starts a buggy server. running "svcbug.py c" starts a client ____________________________________________________________________________ # svcbug.py import win32file, win32pipe, pywintypes PIPE = r"\\.\pipe\Bug.Svc" BUFSIZE = 512 class Iocp: def __init__(self, object): self.port = win32file.CreateIoCompletionPort(-1, 0, 0, 0) win32file.CreateIoCompletionPort(object.handle, self.port, 1, 0) def wait_buggy(self): win32file.GetQueuedCompletionStatus(self.port, -1) def wait_good(self): # keep a reference to the overlapped object self.result = win32file.GetQueuedCompletionStatus(self.port, -1)[3] class PipeService: def __init__(self): self.handle = win32pipe.CreateNamedPipe(PIPE, win32pipe.PIPE_ACCESS_DUPLEX| win32file.FILE_FLAG_OVERLAPPED, win32pipe.PIPE_TYPE_MESSAGE| win32pipe.PIPE_READMODE_MESSAGE| win32pipe.PIPE_WAIT, 1, BUFSIZE, BUFSIZE, win32pipe.NMPWAIT_WAIT_FOREVER, None) self.overlapped = pywintypes.OVERLAPPED() win32pipe.ConnectNamedPipe(self.handle, self.overlapped) def serve(self): data = win32file.ReadFile(self.handle, BUFSIZE)[1] win32file.WriteFile(self.handle, data) def __del__(self): win32pipe.DisconnectNamedPipe(self.handle) if __name__ == '__main__': import sys if 's' in sys.argv: svc = PipeService() iocp = Iocp(svc) if 'bug' in sys.argv: iocp.wait_buggy() else: iocp.wait_good() print sys.getrefcount(svc.overlapped) svc.serve() elif 'c' in sys.argv: print win32pipe.CallNamedPipe(PIPE, "Hello there", BUFSIZE, 0) ____________________________________________________________________________ Fred Gansevles Phone: +31 53 489 4613 Org.: Twente University, Fac. of EWI, Box 217, 7500 AE Enschede, Netherlands "Linux is like a wigwam, No windows, no gates and an apache inside" From mhammond at skippinet.com.au Thu Jun 2 02:05:59 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 2 Jun 2005 10:05:59 +1000 Subject: [python-win32] Ref-count bug in win32file.GetQueuedCompletionStatus In-Reply-To: <20050601090225.E830A508BF@mamba.cs.utwente.nl> Message-ID: <0de301c56706$dc308840$030a0a0a@enfoldsystems.local> > Hi, > I think I've found a ref-count bug in win32file.GetQueuedCompletionStatus You have indeed! GetQueuedCompletionStatus used to assume that the OVERLAPPED object was previously added to the IOCP via PortQueuedCompletionStatus. I've now fixed that bug and checked the changes into CVS. Thanks very much for the effective repro case - it allowed me to see your issue quickly and I even borrowed that code for the test suite. Let me know if you would like a new version of the affected DLLs (and what Python version you use). Cheers, Mark From chad.hughes at pnl.gov Thu Jun 2 02:25:50 2005 From: chad.hughes at pnl.gov (Hughes, Chad O) Date: Wed, 01 Jun 2005 17:25:50 -0700 Subject: [python-win32] 1MB Thread Stack Size Message-ID: <42C7E766869C42408F0360B7BF0CBD9B014B613A@pnlmse27.pnl.gov> I have a program that needs to create a great deal of threads. Unfortunately, I cannot seem to find a way to lower the 1MB default stack size per thread. The threading module does not seem to support setting the stack size explicitly. I have 1GB of memory on my system so I can only create about 1000 threads before I receive the following error trace: File "C:\Python24\lib\threading.py", line 442, in __bootstrap self.run() File "C:\Python24\lib\threading.py", line 422, in run self.__target(*self.__args, **self.__kwargs) File "C:\tagent\globalModule.py", line 190, in shell self.target() File "C:\tagent\agent.py", line 132, in runLoop self.timeSliceEvent(currentTime,delta) File "C:\tagent\agent.py", line 397, in timeSliceEvent actorInstance.threadStart() File "C:\tagent\agent.py", line 117, in threadStart threading.Thread.start(self) File "C:\Python24\lib\threading.py", line 416, in start _start_new_thread(self.__bootstrap, ()) error: can't start new thread Any ideas on how to lower the stack size? Chad -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050601/8029372d/attachment.htm From mhammond at skippinet.com.au Thu Jun 2 03:44:24 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 2 Jun 2005 11:44:24 +1000 Subject: [python-win32] 1MB Thread Stack Size In-Reply-To: <42C7E766869C42408F0360B7BF0CBD9B014B613A@pnlmse27.pnl.gov> Message-ID: <0e3d01c56714$9b90eba0$030a0a0a@enfoldsystems.local> win32process.beginthreadex allows you to specify the size. However there is almost certainly a better way of doing what you want than creating that many threads, generally using non-blocking operations and an IO Completion Port - what exactly are you doing? I believe the "stackless" prject is all but dead - but that offered "micro-threads" for cases where a huge number of threads were desired and hard to avoid. Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Hughes, Chad O Sent: Thursday, 2 June 2005 10:26 AM To: python-win32 at python.org Subject: [python-win32] 1MB Thread Stack Size I have a program that needs to create a great deal of threads. Unfortunately, I cannot seem to find a way to lower the 1MB default stack size per thread. The threading module does not seem to support setting the stack size explicitly. I have 1GB of memory on my system so I can only create about 1000 threads before I receive the following error trace: File "C:\Python24\lib\threading.py", line 442, in __bootstrap self.run() File "C:\Python24\lib\threading.py", line 422, in run self.__target(*self.__args, **self.__kwargs) File "C:\tagent\globalModule.py", line 190, in shell self.target() File "C:\tagent\agent.py", line 132, in runLoop self.timeSliceEvent(currentTime,delta) File "C:\tagent\agent.py", line 397, in timeSliceEvent actorInstance.threadStart() File "C:\tagent\agent.py", line 117, in threadStart threading.Thread.start(self) File "C:\Python24\lib\threading.py", line 416, in start _start_new_thread(self.__bootstrap, ()) error: can't start new thread Any ideas on how to lower the stack size? Chad -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 4504 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050602/fd8210fb/winmail-0001.bin From Andrew.MacIntyre at aba.gov.au Thu Jun 2 03:46:15 2005 From: Andrew.MacIntyre at aba.gov.au (Andrew MacIntyre) Date: Thu, 2 Jun 2005 11:46:15 +1000 Subject: [python-win32] 1MB Thread Stack Size Message-ID: > I have a program that needs to create a great deal of > threads. Unfortunately, I cannot seem to find a way to lower > the 1MB default stack size per thread. The threading module > does not seem to support setting the stack size explicitly. > I have 1GB of memory on my system so I can only create about > 1000 threads before I receive the following error trace: > > File "C:\Python24\lib\threading.py", line 442, in __bootstrap > self.run() > File "C:\Python24\lib\threading.py", line 422, in run > self.__target(*self.__args, **self.__kwargs) > File "C:\tagent\globalModule.py", line 190, in shell > self.target() > File "C:\tagent\agent.py", line 132, in runLoop > self.timeSliceEvent(currentTime,delta) > File "C:\tagent\agent.py", line 397, in timeSliceEvent > actorInstance.threadStart() > File "C:\tagent\agent.py", line 117, in threadStart > threading.Thread.start(self) > File "C:\Python24\lib\threading.py", line 416, in start > _start_new_thread(self.__bootstrap, ()) > error: can't start new thread > > Any ideas on how to lower the stack size? Python's thread module is hard-coded to use Windows' default thread stack size, which according to the docs I have will be the same as the process' primary thread stack size (which is usually set at link time). These same docs also indicate that thread creation fails if all memory for the thread stack cannot be committed (some other OSes don't attempt to commit all stack space on thread creation). If you can find a way to modify the stack-size setting of python.exe this might work for you, but be warned that this could also cause other stack related failures as the primary thread usually requires more stack than other threads. If you're in a position to recompile Python, it doesn't take much to change the thread module's hard-coded thread stack size. In my spare time I've been working on a patch to allow the default thread stack size to be changed programmatically - its mostly complete except for doc updates, and I hope to get it into Python 2.5. ---------------------------------------------------------------------- Andrew MacIntyre \ email: andrew.macintyre at aba.gov.au Planning Branch \ tel: +61 2 6256 2812 Australian Broadcasting Authority \ fax: +61 2 6253 3277 -> "These thoughts are mine alone!" <--------------------------------- > > Chad > > From gansevle at cs.utwente.nl Thu Jun 2 10:32:34 2005 From: gansevle at cs.utwente.nl (Fred Gansevles) Date: Thu, 02 Jun 2005 10:32:34 +0200 Subject: [python-win32] Ref-count bug in win32file.GetQueuedCompletionStatus In-Reply-To: Your message of Thu, 02 Jun 2005 10:05:59 +1000 Message-ID: <20050602083234.E467E50E65@mamba.cs.utwente.nl> > > Hi, > > I think I've found a ref-count bug in > win32file.GetQueuedCompletionStatus > > You have indeed! GetQueuedCompletionStatus used to assume that the > OVERLAPPED object was previously added to the IOCP via > PortQueuedCompletionStatus. I've now fixed that bug and checked the changes > into CVS. > Thanks. > Thanks very much for the effective repro case - it allowed me to see your > issue quickly and I even borrowed that code for the test suite. Feel free to use it! > > Let me know if you would like a new version of the affected DLLs (and what > Python version you use). I'm not in a hurry right now, since I made a work-around with ctypes def GetQueuedCompletionStatus(port, timeout): from ctypes import windll, c_long, c_void_p, byref n = c_long() k = c_long() o = c_void_p() r = windll.kernel32.GetQueuedCompletionStatus( int(port), byref(n), byref(k), byref(o), timeout) return r, n.value, k.value, o.value and this does the job perfectely. b.t.w. the bug 'worked' in both python-2.3.5 and python-2.4.1 > > Cheers, > > Mark ____________________________________________________________________________ Fred Gansevles Phone: +31 53 489 4613 Org.: Twente University, Fac. of EWI, Box 217, 7500 AE Enschede, Netherlands "Linux is like a wigwam, No windows, no gates and an apache inside" From gijs at globaltrack.com Thu Jun 2 14:58:25 2005 From: gijs at globaltrack.com (Gijs Korremans) Date: Thu, 2 Jun 2005 14:58:25 +0200 Subject: [python-win32] return pramater in com object function Message-ID: <200506021302.j52D2Opl029201@rrba-146-94-166.telkomadsl.co.za> Hi, One of the functions in the com object I need to use has a pointer in one of it's functions (object.function(string input, struct * output)) (I've created the struct with win32com.client.Record("structure", object)) I've tried to use the id() function but then Python gives me a message that it's an int, not a tructure and when I just give the object without a pointer, the object is still empty afterwards. In the mailinglist archive I saw this message from Mark Hammond: "Well, their IDL is at fault, and it clearly should be marked as [in,out]. All we should need to do is to get the makepy generated code for this function, and change the last "type tuple" for this function. It will be a tuple of, eg (pythoncom.VT_OBJECT, pythoncom.PARAMFLAG_FIN). Telling Python it is really _FIN | _FOUT should do the trick" So I opened the by genPy generated file and tried to change the last tuple from _ApplyTypes_ but it was already 2 (PARAMFLAG_FOUT): return self._ApplyTypes_(1, 1, (24, 0), ((8, 1), (36, 2)), 'SetIDString', None,inID, outID) Does anyone know how to solve this? Kind regards, Gijs -- This message has been scanned for viruses and dangerous content by Network Sentry, and is believed to be clean. http://www.networksentry.co.za From emlynj at gmail.com Thu Jun 2 16:10:20 2005 From: emlynj at gmail.com (Emlyn Jones) Date: Thu, 2 Jun 2005 15:10:20 +0100 Subject: [python-win32] Swig DLL with ASP Message-ID: Hello, I have Python working as the script engine for ASP under IIS 5.1, XP Pro. I created a DLL using SWIG and Visual Studio .NET which works fine from the command line but when I try and run it from an ASP script I get: """ DLL load failed: Invalid access to memory location """ When I try to import it. Has anybody any experience with this type of setup? I tested a simple DLL (handcrafted, no SWIG) and that worked ok. The real DLL does load other DLL's though, is that likely to be a problem? Is there a way to set things up so I can run a debug version of python and my dll from IIS and stand some chance of setting break points in Visual Studio? Or maybe some tool to tell me exactly why the load fails? I tried a good old fashion debug file but it wasn't created which may suggest it's not even getting as far as calling the init function on import (which takes me back to the loading other DLL's question). Any help will be much appreciated. Regards, Emlyn Jones From John.Gooch at echostar.com Thu Jun 2 17:10:12 2005 From: John.Gooch at echostar.com (Gooch, John) Date: Thu, 2 Jun 2005 09:10:12 -0600 Subject: [python-win32] Question: Finding the "owner" Of A Process Message-ID: <15A1FDA26DAD524DA7A7AF77313EBA8F0F60D440@riv-excha5.echostar.com> I am trying to print out the owner of running process on Windows 2000 Professional ( SP4 ) using WMI, but my call to the "GetOwner" Process defined here - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/ getowner_method_in_class_win32_process.asp , which is part of the Win32_Process Class defined here - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/ wmi_tasks__processes.asp . Here is my code, followed by the error message: import odbc import socket import re import win32com.client import win32api import win32con import win32file import pythoncom import datetime import os pythoncom.CoInitialize() #connect to localhost wmi service wmi = win32com.client.GetObject('winmgmts://' ) procs = wmi.ExecQuery( "SELECT * FROM WIN32_PROCESS") user = "" domain = "" for proc in procs: proc.GetOwner( user, domain ) print "%s's owner is %s" % ( proc.Name, user ) x.GetOwner() Error: Traceback (most recent call last): File "C:\Documents and Settings\John.Gooch\My Documents\File Manager\getowner.py", line 20, in ? proc.GetOwner( user, domain ) TypeError: 'int' object is not callable Any ideas? I tried using the proc.Method('GetOwner') syntax to locate the function, but I don't know how to pass in paramaters ( explained on Microsoft's site ) to the function using that syntax. Thank You, John A. Gooch Systems Administrator IT - Tools EchoStar Satellite L.L.C. 9601 S. Meridian Blvd. Englewood, CO 80112 Desk: 720-514-5708 John A. Gooch Systems Administrator IT - Tools EchoStar Satellite L.L.C. 9601 S. Meridian Blvd. Englewood, CO 80112 Desk: 720-514-5708 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050602/03417617/attachment.html From dja at info.ucl.ac.be Thu Jun 2 17:25:59 2005 From: dja at info.ucl.ac.be (David Janssens) Date: Thu, 02 Jun 2005 17:25:59 +0200 Subject: [python-win32] COM server with events and multiple threads In-Reply-To: References: Message-ID: <429F2507.1020000@info.ucl.ac.be> I attached a zip file that contains a small python COM server and a small VB6 client that reproduces the problem. The server sends events to the VB6 client, but the problem is the events are handled in different threads in the VB6 client. I would appreciate it if someone could tell me what are the minimal changes I need to make to this sample so that each event is handled in the same GUI thread. Also what would be some good COM books to read that are relevant to this subject? Thanks, David Janssens Mark Hammond wrote: >>I don't know how to tell VB6 to use free-threading or how to >>spawn new >>threads in VB6 that belong to the MTA. Are you sure it's possible, do >>you have more information on how to do this? >> >> > >I doubt it is possible for the main GUI thread. I believe VB can create >threads via API calls, so they are up for grabs. I meant to say something >like "the host (in thise case VB) must set the thread-mode. I doubt VB >can". > > > >>I suppose the problem is >>quite common to all people who whish to use a VB6 GUI with a >>python COM server backend. >> >> > >I'm not aware of normal single threaded apps doing similarly strange things >for people. Using connection-points directly is not common, so maybe VB is >doing something stange with them. > > > >>The events are sent to the GUI as follows: (This is based on >>a sample I >>found on the same mailing list, except the sample didn't set the >>threading model of the component to "free") >> >> > >Your original query said "the python COM server has multiple threads running >in it" - but its still not clear to me what these threads are, or where they >are created. Are these multiple-threads just an observed side-effect of the >code as posted? > >Mark > > > -------------- next part -------------- A non-text attachment was scrubbed... Name: vbtest.zip Type: application/x-zip-compressed Size: 5487 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050602/1ee72a9e/vbtest.bin From radams at nassco.com Thu Jun 2 20:23:35 2005 From: radams at nassco.com (Robert Adams) Date: Thu, 2 Jun 2005 11:23:35 -0700 Subject: [python-win32] Strange page header text in PythonWin Message-ID: <000601c567a0$30316920$8fe210ac@nassco.local> Hello List, Can anyone please point in the correct direction to resolve this minor printing annoyance. When printing a copy of my code, why is the header using strange characters and not readable text as expected ? Thanks in advance! Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050602/004fa189/attachment-0001.html From timr at probo.com Thu Jun 2 20:32:27 2005 From: timr at probo.com (Tim Roberts) Date: Thu, 02 Jun 2005 11:32:27 -0700 Subject: [python-win32] 1MB Thread Stack Size In-Reply-To: References: Message-ID: <429F50BB.9030908@probo.com> On Wed, 01 Jun 2005 17:25:50 -0700, "Hughes, Chad O" wrote: >I have a program that needs to create a great deal of threads. >Unfortunately, I cannot seem to find a way to lower the 1MB default >stack size per thread. The threading module does not seem to support >setting the stack size explicitly. I have 1GB of memory on my system so >I can only create about 1000 threads before I receive the following >error trace: > > It is almost impossible to imagine a situation in which 1,000 threads actually provides any productivity. Any time the number of threads in a process is more than an order of magnitude greater than the number of CPUs, the operating system administration overhead begins to overwhelm the productive work that can be done. Surely you could solve your problem with 100 threads and some appropriate queueing? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From chad.hughes at pnl.gov Thu Jun 2 21:14:32 2005 From: chad.hughes at pnl.gov (Hughes, Chad O) Date: Thu, 02 Jun 2005 12:14:32 -0700 Subject: [python-win32] 1MB Thread Stack Size Message-ID: <42C7E766869C42408F0360B7BF0CBD9B014B613B@pnlmse27.pnl.gov> Actually, the bottleneck is not the CPU. Using Perfmon, I have verified that I can currently have 1000 threads running with under 25% CPU usage. The threads are fairly light weight. However, the stack size for each thread is by default 1MB, so the memory is the bottleneck. I want to have about 1000 threads, however, this requires that every machine I run my app on must have at least 1GB of memory. Not all my machines have this much memory. I have read that you can change the default by recompiling Python and have at least 16 thousand threads. In fact, this is what I read at http://www.gossamer-threads.com/lists/python/python/354638: The only way to change the stack size is to define THREAD_STACK_SIZE in the thread_pthread.h header. There is an ifdef for the Mac that sets this to 64k. Just as a test I forced THREAD_STACK_SIZE to that value and recompiled Python. I can now create 16k threads although I'm not sure yet whether our application will run; some tuning is probably in order. I'm going to get the 2.2 source code and see what is different between the two and maybe get an idea of what a reasonable stack size is. However, this pertained to Linux and I am running my app Windows and I was looking for a solution that does not require a Python recompile. -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Roberts Sent: Thursday, June 02, 2005 11:32 AM To: python-win32 at python.org Subject: [python-win32] 1MB Thread Stack Size On Wed, 01 Jun 2005 17:25:50 -0700, "Hughes, Chad O" wrote: >I have a program that needs to create a great deal of threads. >Unfortunately, I cannot seem to find a way to lower the 1MB default >stack size per thread. The threading module does not seem to support >setting the stack size explicitly. I have 1GB of memory on my system >so I can only create about 1000 threads before I receive the following >error trace: > > It is almost impossible to imagine a situation in which 1,000 threads actually provides any productivity. Any time the number of threads in a process is more than an order of magnitude greater than the number of CPUs, the operating system administration overhead begins to overwhelm the productive work that can be done. Surely you could solve your problem with 100 threads and some appropriate queueing? -- 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 rwupole at msn.com Thu Jun 2 22:29:01 2005 From: rwupole at msn.com (Roger Upole) Date: Thu, 2 Jun 2005 16:29:01 -0400 Subject: [python-win32] Re: Question: Finding the "owner" Of A Process Message-ID: You should be able to use proc.ExecMethod_('GetOwner'). All the parameters are output, so you shouldn't have to pass anything in. hth Roger From mhammond at skippinet.com.au Fri Jun 3 00:44:42 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 3 Jun 2005 08:44:42 +1000 Subject: [python-win32] return pramater in com object function In-Reply-To: <200506021302.j52D2Opl029201@rrba-146-94-166.telkomadsl.co.za> Message-ID: <10e501c567c4$ab587840$030a0a0a@enfoldsystems.local> > One of the functions in the com object I need to use has a > pointer in one of it's functions > (object.function(string input, struct * output)) In that case you should be writing: ret = object.function("input") And ret should be the record structure. Mark From mhammond at skippinet.com.au Fri Jun 3 00:46:39 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 3 Jun 2005 08:46:39 +1000 Subject: [python-win32] Strange page header text in PythonWin In-Reply-To: <000601c567a0$30316920$8fe210ac@nassco.local> Message-ID: <10e601c567c4$f15a6010$030a0a0a@enfoldsystems.local> MessageI'm afraid you would need to look in pythonwin\pywin\scintilla\view.py and try to determine what is going wrong. Cheers, Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Robert Adams Sent: Friday, 3 June 2005 4:24 AM To: python-win32 Subject: [python-win32] Strange page header text in PythonWin Hello List, Can anyone please point in the correct direction to resolve this minor printing annoyance. When printing a copy of my code, why is the header using strange characters and not readable text as expected ? Thanks in advance! Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050603/bd12d267/attachment.htm From mhammond at skippinet.com.au Fri Jun 3 01:30:38 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 3 Jun 2005 09:30:38 +1000 Subject: [python-win32] COM server with events and multiple threads In-Reply-To: <429F2507.1020000@info.ucl.ac.be> Message-ID: <10fd01c567cb$15e442b0$030a0a0a@enfoldsystems.local> > I attached a zip file that contains a small python COM server and a > small VB6 client that reproduces the problem. > > The server sends events to the VB6 client, but the problem is > the events > are handled in different threads in the VB6 client. > > I would appreciate it if someone could tell me what are the minimal > changes I need to make to this sample so that each event is > handled in > the same GUI thread. The problem is that the connection server is getting an interface object on one thread (the main thread as part of the Advise call) - but the new threads you create are using these objects without marshalling the objects. ie, your new threads are referencing objects "owned" by another thread. This is why the calls are being delivered to VB on the wrong thread. If you marshalled the objects to the new thread, that marshalling would ensure VB received the call on the correct thread. You marshall the COM object by using CoMarshalInterThreadInterfaceInStream and CoGetInterfaceAndReleaseStream. win32com.server.connect wasn't really designed for this case - 'self.connections' can only be used directly or indirectly by thead the Advise call was made on. Each thread must have its own copy of the interfaces in self.connections, passed to it via CoMarshalInterThreadInterfaceInStream. This will be tricky to work with new connections established after the thread has started. One option may be a queue - the "main" thread could queue CoMarshalInterThreadInterfaceInStream wrapped objects, and the worker thread could dequeue the objects and call CoGetInterfaceAndReleaseStream before attempting to use the object. If you could make sensible modifications to win32com.server.connect to support that scenario, I'd be happy to integrate them. You may find it easier to "fork" that class for your own purposes though. > Also what would be some good COM books to read that are > relevant to this > subject? Not sure about entire books. I have explained these COM rules before in this thread ;) "Python Programming on Win32" also covers this in some detail. A google seatch for "COM threading model" returns a number of hits from good sites that seem fairly useful. A good starting point at MSDN might be: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/html/7b d6f62f-8c91-44bd-9a7f-d47988180eed.asp Mark From theller at python.net Fri Jun 3 11:30:30 2005 From: theller at python.net (Thomas Heller) Date: Fri, 03 Jun 2005 11:30:30 +0200 Subject: [python-win32] COM server with events and multiple threads In-Reply-To: <10fd01c567cb$15e442b0$030a0a0a@enfoldsystems.local> References: <429F2507.1020000@info.ucl.ac.be> <10fd01c567cb$15e442b0$030a0a0a@enfoldsystems.local> Message-ID: Mark Hammond schrieb: > The problem is that the connection server is getting an interface object on > one thread (the main thread as part of the Advise call) - but the new > threads you create are using these objects without marshalling the objects. > > ie, your new threads are referencing objects "owned" by another thread. > This is why the calls are being delivered to VB on the wrong thread. If you > marshalled the objects to the new thread, that marshalling would ensure VB > received the call on the correct thread. > > You marshall the COM object by using CoMarshalInterThreadInterfaceInStream > and CoGetInterfaceAndReleaseStream. > > win32com.server.connect wasn't really designed for this case - > 'self.connections' can only be used directly or indirectly by thead the > Advise call was made on. Each thread must have its own copy of the > interfaces in self.connections, passed to it via > CoMarshalInterThreadInterfaceInStream. This will be tricky to work with new > connections established after the thread has started. One option may be a > queue - the "main" thread could queue CoMarshalInterThreadInterfaceInStream > wrapped objects, and the worker thread could dequeue the objects and call > CoGetInterfaceAndReleaseStream before attempting to use the object. > > If you could make sensible modifications to win32com.server.connect to > support that scenario, I'd be happy to integrate them. You may find it > easier to "fork" that class for your own purposes though. > Another (easier, imo) option would be to use the Global Interface Table. Once that is wrapped in win32com. Thomas From dja at info.ucl.ac.be Fri Jun 3 12:00:31 2005 From: dja at info.ucl.ac.be (David Janssens) Date: Fri, 03 Jun 2005 12:00:31 +0200 Subject: [python-win32] COM server with events and multiple threads In-Reply-To: <10fd01c567cb$15e442b0$030a0a0a@enfoldsystems.local> References: <10fd01c567cb$15e442b0$030a0a0a@enfoldsystems.local> Message-ID: <42A02A3F.1090805@info.ucl.ac.be> Thanks for the hints, I will try to modify the sample now to make it work using inter thread marshalling. But isn't it possible to have all the threads in the python COM server run in a single MTA? Instead of having several worker threads in several STA's in the python COM server with marshalling between the STA's. This way, I don't need to implement marshalling between threads in the python COM server and the marshalling could be done implicitely between the python COM server (created in the MTA) and the VB6 gui (running in an STA). Actually, when I uncomment the line _reg_threading_='free' in server.py, it seems to do exactly that. But the problem is it doesn't work after that, when I compile the server using py2exe and distribute it on other desktops. David Mark Hammond wrote: >>I attached a zip file that contains a small python COM server and a >>small VB6 client that reproduces the problem. >> >>The server sends events to the VB6 client, but the problem is >>the events >>are handled in different threads in the VB6 client. >> >>I would appreciate it if someone could tell me what are the minimal >>changes I need to make to this sample so that each event is >>handled in >>the same GUI thread. >> >> > >The problem is that the connection server is getting an interface object on >one thread (the main thread as part of the Advise call) - but the new >threads you create are using these objects without marshalling the objects. > >ie, your new threads are referencing objects "owned" by another thread. >This is why the calls are being delivered to VB on the wrong thread. If you >marshalled the objects to the new thread, that marshalling would ensure VB >received the call on the correct thread. > >You marshall the COM object by using CoMarshalInterThreadInterfaceInStream >and CoGetInterfaceAndReleaseStream. > >win32com.server.connect wasn't really designed for this case - >'self.connections' can only be used directly or indirectly by thead the >Advise call was made on. Each thread must have its own copy of the >interfaces in self.connections, passed to it via >CoMarshalInterThreadInterfaceInStream. This will be tricky to work with new >connections established after the thread has started. One option may be a >queue - the "main" thread could queue CoMarshalInterThreadInterfaceInStream >wrapped objects, and the worker thread could dequeue the objects and call >CoGetInterfaceAndReleaseStream before attempting to use the object. > >If you could make sensible modifications to win32com.server.connect to >support that scenario, I'd be happy to integrate them. You may find it >easier to "fork" that class for your own purposes though. > > > >>Also what would be some good COM books to read that are >>relevant to this >>subject? >> >> > >Not sure about entire books. I have explained these COM rules before in >this thread ;) "Python Programming on Win32" also covers this in some >detail. A google seatch for "COM threading model" returns a number of hits >from good sites that seem fairly useful. A good starting point at MSDN >might be: >http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/html/7b >d6f62f-8c91-44bd-9a7f-d47988180eed.asp > > >Mark > > > From mhammond at skippinet.com.au Fri Jun 3 12:57:08 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 3 Jun 2005 20:57:08 +1000 Subject: [python-win32] COM server with events and multiple threads In-Reply-To: <42A02A3F.1090805@info.ucl.ac.be> Message-ID: <11e501c5682a$fcf5f5e0$030a0a0a@enfoldsystems.local> > Thanks for the hints, I will try to modify the sample now to make it > work using inter thread marshalling. > > But isn't it possible to have all the threads in the python > COM server run in a single MTA? Not when the hosting application (VB in this case) is not in the MTA. You either need to convince VB to live in the MTA (which we have already agreed you can't), or live with it . > Instead of having several worker threads in several STA's in > the python > COM server with marshalling between the STA's. The threads you create are under your control, yes. So assuming you arrange for all threads to be in the MTA, you can freely share objects between the threads. You can't share the object with any threads not in the MTA though - which includes the (one and only) VB thread that is not in the MTA. In this specific case, the problem is we store the object/pointer, unmarshalled, in the instance. If we could store the marshalled object, all other threads would be fine. I'm not sure now to simply get the MTA marshalled object in a non-MTA thread, but it may be possible. Worst case you could spin a new thread just to marshall it! > This way, I don't need to implement marshalling between > threads in the > python COM server and the marshalling could be done > implicitely between > the python COM server (created in the MTA) and the VB6 gui > (running in > an STA). Yes, that is fine - just not for the VB thread. VB will only have one thread - so in effect, your "main thread" is not in the free-threaded apartment, but all other threads can be. Mark. From dja at info.ucl.ac.be Fri Jun 3 16:35:30 2005 From: dja at info.ucl.ac.be (David Janssens) Date: Fri, 03 Jun 2005 16:35:30 +0200 Subject: [python-win32] COM server with events and multiple threads In-Reply-To: <11e501c5682a$fcf5f5e0$030a0a0a@enfoldsystems.local> References: <11e501c5682a$fcf5f5e0$030a0a0a@enfoldsystems.local> Message-ID: <42A06AB2.60003@info.ucl.ac.be> I made some changes to the sample and now it seems to work, all the events are handled in the main VB6 GUI thread. The new sample code is attached as a zip file. I defined a subclass of win32com.server.connect.ConnectableServer. The difference is that _BroadcastNotify can be called from any thread. The actual notifications are made by a separate thread which is synchronized with the other threads using queues. The thread that does the notifications has a marshalled copy of all the interfaces in self.connections. It works for me, but please let me know if you have other suggestions. Thanks, David Mark Hammond wrote: >>Thanks for the hints, I will try to modify the sample now to make it >>work using inter thread marshalling. >> >>But isn't it possible to have all the threads in the python >>COM server run in a single MTA? >> >> > >Not when the hosting application (VB in this case) is not in the MTA. You >either need to convince VB to live in the MTA (which we have already agreed >you can't), or live with it . > > > >>Instead of having several worker threads in several STA's in >>the python >>COM server with marshalling between the STA's. >> >> > >The threads you create are under your control, yes. So assuming you arrange >for all threads to be in the MTA, you can freely share objects between the >threads. You can't share the object with any threads not in the MTA >though - which includes the (one and only) VB thread that is not in the MTA. > >In this specific case, the problem is we store the object/pointer, >unmarshalled, in the instance. If we could store the marshalled object, all >other threads would be fine. I'm not sure now to simply get the MTA >marshalled object in a non-MTA thread, but it may be possible. Worst case >you could spin a new thread just to marshall it! > > > >>This way, I don't need to implement marshalling between >>threads in the >>python COM server and the marshalling could be done >>implicitely between >>the python COM server (created in the MTA) and the VB6 gui >>(running in >>an STA). >> >> > >Yes, that is fine - just not for the VB thread. VB will only have one >thread - so in effect, your "main thread" is not in the free-threaded >apartment, but all other threads can be. > >Mark. > > > -------------- next part -------------- A non-text attachment was scrubbed... Name: vbtest.zip Type: application/x-zip-compressed Size: 6776 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050603/bf6a786f/vbtest.bin From timr at probo.com Fri Jun 3 19:14:19 2005 From: timr at probo.com (Tim Roberts) Date: Fri, 03 Jun 2005 10:14:19 -0700 Subject: [python-win32] 1MB Thread Stack Size In-Reply-To: References: Message-ID: <42A08FEB.9060206@probo.com> On Thu, 02 Jun 2005 12:14:32 -0700, "Hughes, Chad O" wrote: >Actually, the bottleneck is not the CPU. Using Perfmon, I have verified >that I can currently have 1000 threads running with under 25% CPU usage. >The threads are fairly light weight. However, the stack size for each >thread is by default 1MB, so the memory is the bottleneck. I want to >have about 1000 threads, however, this requires that every machine I run >my app on must have at least 1GB of memory. Not all my machines have >this much memory. > Well, let me try to restate my point. Having 1,000 lightweight threads sitting around waiting for things is not a big drain on resources, but it also doesn't serve any purpose. If you have a pool of 1,000 threads sitting around, I assume you eventually plan to have them do some real work. If you try to assign real tasks to 1,000 threads, the context switching overhead would kill the machine. You would get much better performance by having 100 threads, each one reading tasks from a queue. That way, a single thread can handle a couple of tasks without relying on the operating system to switch the context. And if you DON'T really plan on having 1,000 threads working on tasks at the same time, then you don't really need 1,000 threads. I'm sure you can solve the stack space problem. I'm just suggesting that time spent on such a solution might be wasted, when you could actually solve your problem in a better way. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From radams at nassco.com Fri Jun 3 21:34:57 2005 From: radams at nassco.com (Robert Adams) Date: Fri, 3 Jun 2005 12:34:57 -0700 Subject: [python-win32] Strange page header text in PythonWin In-Reply-To: Message-ID: <000001c56873$52f9fd90$8fe210ac@nassco.local> I am somewhat of a newbie to Python, but thanks for the heads-up on where to look. Question, since I have not customized anything that I am aware of, my Python environment should be as installed from scratch, so why would I get then strange text in page header ? I am running the following, Python 2.3.3, wxPython 2.4.2.4, PythonWin 2.3.3 win32all build 163 Thanks, Robert -----Original Message----- From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: Thursday, June 02, 2005 3:47 PM To: 'Robert Adams'; 'python-win32' Subject: RE: [python-win32] Strange page header text in PythonWin I'm afraid you would need to look in pythonwin\pywin\scintilla\view.py and try to determine what is going wrong. Cheers, Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Robert Adams Sent: Friday, 3 June 2005 4:24 AM To: python-win32 Subject: [python-win32] Strange page header text in PythonWin Hello List, Can anyone please point in the correct direction to resolve this minor printing annoyance. When printing a copy of my code, why is the header using strange characters and not readable text as expected ? Thanks in advance! Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050603/253aa337/attachment.html From timr at probo.com Fri Jun 3 22:00:54 2005 From: timr at probo.com (Tim Roberts) Date: Fri, 03 Jun 2005 13:00:54 -0700 Subject: [python-win32] Strange page header text in PythonWin In-Reply-To: References: Message-ID: <42A0B6F6.1080500@probo.com> On Fri, 3 Jun 2005 12:34:57 -0700, "Robert Adams" wrote: >I am somewhat of a newbie to Python, but thanks for the heads-up on where to >look. > >Question, since I have not customized anything that I am aware of, my Python >environment should be as installed from scratch, so why would I get then >strange text in page header ? > >I am running the following, Python 2.3.3, wxPython 2.4.2.4, PythonWin 2.3.3 >win32all build 163 > The problem you describe sounds like a font issue: the program is printing characters that aren't in the font it is using. This sometimes happens when an application stores its font setting as a number (like, "the 19th font in the list") instead of a face name, and the font list changes. I don't think that's the case here. However, I don't see that the Scintilla code ever sets the font for the titles. The code itself gets all of the formatting applied, so it gets fonts and colors. Is the title really being printed with whatever font was leftover in the dc? That's probably a bug. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From sjmachin at lexicon.net Fri Jun 3 22:28:12 2005 From: sjmachin at lexicon.net (John Machin) Date: Sat, 04 Jun 2005 06:28:12 +1000 Subject: [python-win32] Strange page header text in PythonWin In-Reply-To: <000001c56873$52f9fd90$8fe210ac@nassco.local> References: <000001c56873$52f9fd90$8fe210ac@nassco.local> Message-ID: <42A0BD5C.6000403@lexicon.net> Robert Adams wrote: > I am somewhat of a newbie to Python, but thanks for the heads-up on > where to look. > > Question, since I have not customized anything that I am aware of, my > Python environment should be as installed from scratch, so why would I > get then strange text in page header ? > > I am running the following, Python 2.3.3, wxPython 2.4.2.4, PythonWin > 2.3.3 win32all build 163 > Any good reason why you're running old versions of software? I used to get that "strange text in page header" problem, but it went away with an upgrade. Cheers, John From dan+python-win32-list at dan.tulsa.ok.us Sat Jun 4 08:29:30 2005 From: dan+python-win32-list at dan.tulsa.ok.us (Dan Fulbright) Date: Sat, 04 Jun 2005 01:29:30 -0500 Subject: [python-win32] IIS CGI installation Message-ID: <42A14A4A.4050302@dan.tulsa.ok.us> I have found a lot of links to http://www.e-coli.net/pyiis_server.html, however, this page starts out with: "This is really very easy. It is also not a good idea for both security and performance reasons." What are the security and performance issues, and how can they be overcome? I am wanting to use Python for CGI on a shared Windows 2000 Server with IIS, so security and performance are of utmost importance. Thanks in advance. --df From fumanchu at amor.org Sat Jun 4 20:27:28 2005 From: fumanchu at amor.org (Robert Brewer) Date: Sat, 4 Jun 2005 11:27:28 -0700 Subject: [python-win32] IIS CGI installation Message-ID: <3A81C87DC164034AA4E2DDFE11D258E37722DD@exchange.hqamor.amorhq.net> Dan Fulbright wrote: > I have found a lot of links to > http://www.e-coli.net/pyiis_server.html, > however, this page starts out with: > > "This is really very easy. It is also not a good idea for > both security and performance reasons." > > What are the security and performance issues, and how can they be > overcome? I am wanting to use Python for CGI on a shared Windows 2000 > Server with IIS, so security and performance are of utmost importance. It's probably considered insecure because you are passing params (%s) to python on the command line. Those "clever hackers" could find a way to pass Nasty Things, like "del C:" Performance will be intolerable, since each page request has to start and stop the Python interpreter, which is not a quick process. There are other ways of using Python with IIS, such as ISAPI + WSGI: http://isapi-wsgi.python-hosting.com/ or ASP: http://www.4guysfromrolla.com/webtech/082201-1.shtml or (my preferred method) ASP + WSGI: http://www.amorhq.net/blogs/index.php/fumanchu/2005/05/26/wsgi_gateway_f or_asp_microsoft_iis If you used the latter, you could use CherryPy and be on the cutting edge of Python web development. :) Robert Brewer System Architect Amor Ministries fumanchu at amor.org From mhammond at skippinet.com.au Sun Jun 5 13:23:39 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 5 Jun 2005 21:23:39 +1000 Subject: [python-win32] IIS CGI installation In-Reply-To: <3A81C87DC164034AA4E2DDFE11D258E37722DD@exchange.hqamor.amorhq.net> Message-ID: <03db01c569c1$064b7420$010a0a0a@enfoldsystems.local> > There are other ways of using Python with IIS, such as: Also note that recent pywin32 builds ship with Python support for ISAPI filters and extensions. The support is quite low-level (ie, no significant attempt to abstract the ISAPI interface) which is either good or bad, depending on your point-of-view :) There is a sample proxy-server in the distribution. For many cases, a higher-level framework is more suitable - but for raw performance under IIS in Python, I suspect this is the best you will find (depending on *your* code too of course - as mentioned, this is fairly low-level) Mark. -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 1872 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050605/ee11414b/winmail.bin From python at kareta.de Mon Jun 6 12:12:10 2005 From: python at kareta.de (=?ISO-8859-1?Q?J=FCrgen_Kareta?=) Date: Mon, 06 Jun 2005 12:12:10 +0200 Subject: [python-win32] [Re: getting email adresses from outlook] Message-ID: <42A4217A.1090305@kareta.de> Hi Tony, > > > I've written a python program which loops over an Outlook distribution > list, so I can pull off the names of the people on it. > When my program tries to run Outlook, Outlook pops up a Dialoge > I'd like to know what CDO is and how to install it. for installing look at http://www.cdolive.com/asp1.htm. In my case I installed it from the Outlook 2000 cd. For the differences look at http://www.msexchangefaq.de/code/mapicdo.htm and http://support.microsoft.com/kb/q200018/ regards, J?rgen From 7qrj45 at clayelectric.com Mon Jun 6 14:52:46 2005 From: 7qrj45 at clayelectric.com (Ronnie Jones) Date: Mon, 6 Jun 2005 08:52:46 -0400 Subject: [python-win32] Windows LogParser COM interface Message-ID: <5555C0CF56DDD24BBF143A7454A266CA10CD09@khw3sent01.clayelectric.com> I am trying to access LogParser 2.2 through the COM interface provided and I am having a bit of a problem. Here is what is going on: First up is the VBScript version of the code then comes the Python version. Set objLogParser = CreateObject("MSUtil.LogQuery") Set objInputFormat = _ CreateObject("MSUtil.LogQuery.FileSystemInputFormat") objInputFormat.recurse = 0 Set objOutputFormat = _ CreateObject("MSUtil.LogQuery.NativeOutputFormat") objOutputFormat.rtp = -1 strQuery = "SELECT Name, Size FROM 'C:\Program Files\Log Parser 2.2\*.*' ORDER BY Name ASC" objLogParser.ExecuteBatch strQuery, objInputFormat, objOutputFormat When I installed Log Parsers 2.2 on WinXP home edition SP1 version 2002 it went in c:\Program Files\Log Parser 2.2 and then I ran regsvr32 LogParser.dll from that directory. The error I get is : Error executing query:Error while writing to file: The handle is invalid. NOW!! This occurs when I run the script from the command line just by typing the script name and letting XP load cscript. However if I type: cscript test.vbs from the command line it runs ok. Now what I am trying to do is program this interface from ActiveState python 2.3 with win32com extentions. Everything works fine but when I run the script I get the same error I get when I type 'test.vbs' at the command line. Python is my main language and I would really like to make it work. It seems like there is some condition of having the script directly called from 'cscript' for the COM interface to work. Does anyone know the workings of the COM interface. I understand the API, but how are the calls being made. Here is the python code for the same example: >>> import win32com.client >>> objLogParser = win32com.client.Dispatch("MSUtil.LogQuery") >>> objOutput = win32com.client.Dispatch("MSUtil.LogQuery.NativeOutputFormat") >>> objOutput.rtp = -1 >>> objInput = win32com.client.Dispatch("MSUtil.LogQuery.FileSystemInputFormat") >>> objInput.recurse = 0 >>> myquery = "SELECT Name, Size FROM 'C:/lame/misc/*.*' ORDER BY Name ASC" >>> objLogParser.ExecuteBatch(myquery, objInput, objOutput) Traceback (most recent call last): File "", line 1, in ? File "C:\Python23\Lib\site-packages\win32com\gen_py\A7E75D86-41CD-4B6E-B4BD-C C2ED34B3FB0x0x1x0.py", line 819, in ExecuteBatch return self._oleobj_.InvokeTypes(2, LCID, 1, (11, 0), ((8, 1), (13, 49), (13, 49)),szQuery, pObjectInputContext, pObjectOutputContext) com_error: (-2147352567, 'Exception occurred.', (0, 'CLogQueryClass', 'Error executing query: Error while writing to file: The handle is invalid. [The handle is invalid.]', None, 0, -2147024890), None) Any ideas would be appreciated. I can run the select command at the command line using LogParser.exe and all is well but not with COM. Thank you, Ronnie Jones -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050606/5d84cc58/attachment.html From gijs at globaltrack.com Mon Jun 6 15:34:13 2005 From: gijs at globaltrack.com (Gijs Korremans) Date: Mon, 6 Jun 2005 15:34:13 +0200 Subject: [python-win32] com object gives a pointer to a C++ struct array back Message-ID: <200506061337.j56DbvoW026946@rrba-146-73-34.telkomadsl.co.za> Hi one of the functions in a com object I have to use gives me a pointer to the firtst struct in an array back. With Python it's possible to use the first truct, but is it possible to use the others as well? //for example: PointerToFirstStruct = comObj.GetPackets() argOne = PointerToFirstStruct.argOne argTwo = PointerToFirstStruct.argTwo # Go to the next struct # PointerToFirstStruct++ doesn't work Kind regards, Gijs -- This message has been scanned for viruses and dangerous content by Network Sentry, and is believed to be clean. http://www.networksentry.co.za From mhammond at skippinet.com.au Mon Jun 6 15:44:28 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 6 Jun 2005 23:44:28 +1000 Subject: [python-win32] Windows LogParser COM interface In-Reply-To: <5555C0CF56DDD24BBF143A7454A266CA10CD09@khw3sent01.clayelectric.com> Message-ID: <056301c56a9d$dca94e20$010a0a0a@enfoldsystems.local> I'm a little lost here. It sounds lilke cscript is having problems in some cases, and that Python may be having problems in the same situation. This sounds like a problem with the COM object. I suspect running your script from pythonwin would be closer to running from wscript.exe, but you don't mention that. It sounds a little like something is trying to write to stdout and failing when being run as a GUI. Have you tried asking the authors of the component about the VB issue (ie, leaving Python out of the equation)? That may help you determine the issue when running under Python. Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Ronnie Jones Sent: Monday, 6 June 2005 10:53 PM To: python-win32 at python.org Subject: [python-win32] Windows LogParser COM interface I am trying to access LogParser 2.2 through the COM interface provided and I am having a bit of a problem. Here is what is going on: First up is the VBScript version of the code then comes the Python version. Set objLogParser = CreateObject("MSUtil.LogQuery") Set objInputFormat = _ CreateObject("MSUtil.LogQuery.FileSystemInputFormat") objInputFormat.recurse = 0 Set objOutputFormat = _ CreateObject("MSUtil.LogQuery.NativeOutputFormat") objOutputFormat.rtp = -1 strQuery = "SELECT Name, Size FROM 'C:\Program Files\Log Parser 2.2\*.*' ORDER BY Name ASC" objLogParser.ExecuteBatch strQuery, objInputFormat, objOutputFormat When I installed Log Parsers 2.2 on WinXP home edition SP1 version 2002 it went in c:\Program Files\Log Parser 2.2 and then I ran regsvr32 LogParser.dll from that directory. The error I get is : Error executing query:Error while writing to file: The handle is invalid. NOW!! This occurs when I run the script from the command line just by typing the script name and letting XP load cscript. However if I type: cscript test.vbs from the command line it runs ok. Now what I am trying to do is program this interface from ActiveState python 2.3 with win32com extentions. Everything works fine but when I run the script I get the same error I get when I type 'test.vbs' at the command line. Python is my main language and I would really like to make it work. It seems like there is some condition of having the script directly called from 'cscript' for the COM interface to work. Does anyone know the workings of the COM interface. I understand the API, but how are the calls being made. Here is the python code for the same example: >>> import win32com.client >>> objLogParser = win32com.client.Dispatch("MSUtil.LogQuery") >>> objOutput = win32com.client.Dispatch("MSUtil.LogQuery.NativeOutputFormat") >>> objOutput.rtp = -1 >>> objInput = win32com.client.Dispatch("MSUtil.LogQuery.FileSystemInputFormat") >>> objInput.recurse = 0 >>> myquery = "SELECT Name, Size FROM 'C:/lame/misc/*.*' ORDER BY Name ASC" >>> objLogParser.ExecuteBatch(myquery, objInput, objOutput) Traceback (most recent call last): File "", line 1, in ? File "C:\Python23\Lib\site-packages\win32com\gen_py\A7E75D86-41CD-4B6E-B4BD-CC2ED 34B3FB0x0x1x0.py", line 819, in ExecuteBatch return self._oleobj_.InvokeTypes(2, LCID, 1, (11, 0), ((8, 1), (13, 49), (13, 49)),szQuery, pObjectInputContext, pObjectOutputContext) com_error: (-2147352567, 'Exception occurred.', (0, 'CLogQueryClass', 'Error executing query: Error while writing to file: The handle is invalid. [The handle is invalid.]', None, 0, -2147024890), None) Any ideas would be appreciated. I can run the select command at the command line using LogParser.exe and all is well but not with COM. Thank you, Ronnie Jones -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 6316 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050606/32a83219/winmail.bin From python at kareta.de Mon Jun 6 16:50:22 2005 From: python at kareta.de (=?ISO-8859-15?Q?J=FCrgen_Kareta?=) Date: Mon, 06 Jun 2005 16:50:22 +0200 Subject: [python-win32] getting global addressbook with extended mapi Message-ID: <42A462AE.707@kareta.de> Hello, I followed Marks hint and tried to get my global addressbook entries with extended mapi. from win32com.mapi import mapiutil from win32com.mapi import exchange import pprint,pythoncom profileName = "Test" session = mapi.MAPIInitialize(None) session =mapi.MAPILogonEx(0,'test',None, mapi.MAPI_EXTENDED | mapi.MAPI_LOGON_UI |\ mapi.MAPI_NO_MAIL |mapi.MAPI_USE_DEFAULT) hr=session.OpenAddressBook(0,None,mapi.AB_NO_DIALOG) gal = exchange.HrFindExchangeGlobalAddressList (hr) raise: gal = exchange.HrFindExchangeGlobalAddressList (hr) NotImplementedError: Not available with this version of the Exchange SDK So it seems to be that our exchange5.5 SP3 Server don't provide all extended mapi features. But the DumpTopLevelFolders funktion of the class MAPIDriver in spambayes sandbox works fine. How can I find a workaround to access the gal entries ? The final solution should work like the following cdo code: from win32com.client.dynamic import Dispatch s=Dispatch("Mapi.session") s.Logon("", "", False, True, 0, True,\ ProfileInfo="/o=myserver/ou=myside/cn=Configuration/cn=myserver\n\nanon") entries=s.AddressLists('Globales Adressbuch').AddressEntries.Item(my distribution list).Members for entr in entries: print entr.Name,entr.Fields(0x39fe001e).Value,entr.Fields(0x3a00001e) Any hints ? regards, J?rgen From jbrunen at datasolid.de Mon Jun 6 17:19:11 2005 From: jbrunen at datasolid.de (Johannes Brunen) Date: Mon, 6 Jun 2005 17:19:11 +0200 Subject: [python-win32] Problem with gencache.EnsureModule Message-ID: <23D83A07C60A0E47AD964F74DA96940104BD29@mail.datasolid.de> Hi, First, I'm new to this list as well as new to python/pythonCom. I have tried to connect to a COM server installed on my machine with this little script: import win32com.client from win32com.client import gencache def main(): gencache.EnsureModule('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 2) gencache.EnsureModule('{F6B548E2-1A91-11D4-AC7B-00105A4925FC}', 0, 1, 2) gencache.EnsureModule('{2FF5212B-C12E-11D4-AD46-00105A4925FC}', 0, 1, 2) gencache.EnsureModule('{9C3BB403-114D-11D4-AC72-00105A4925FC}', 0, 1, 2) gencache.EnsureModule('{D5224AA1-0F95-11D4-AC6E-00105A4925FC}', 0, 1, 2) gencache.EnsureModule('{83273D63-C3B6-11D6-99B4-00105A492792}', 0, 1, 2) gencache.EnsureModule('{DA061171-5185-11D4-8B25-00105A49278B}', 0, 1, 2) theCADdy = win32com.client.Dispatch("CADdy.CADdy") if __name__ == '__main__': main() I have used makepy.py -i to get the guids of the registered type libraries. Running this script yields [C:/Development/Learn/Python/COM] Test2.py Traceback (most recent call last): File "C:\DEVELO~1\Learn\Python\COM\test2.py", line 19, in ? main() File "C:\DEVELO~1\Learn\Python\COM\test2.py", line 9, in main gencache.EnsureModule('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 2) File "C:\Programme\Python\Lib\site-packages\win32com\client\gencache.py", line 525, in EnsureModule module = MakeModuleForTypelib(typelibCLSID, lcid, major, minor, progressInstance, bForDemand = bForDemand, bBuildHid den = bBuildHidden) File "C:\Programme\Python\Lib\site-packages\win32com\client\gencache.py", line 292, in MakeModuleForTypelib makepy.GenerateFromTypeLibSpec( (typelibCLSID, lcid, major, minor), progressInstance=progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden) File "c:\programme\python\lib\site-packages\win32com\client\makepy.py", line 274, in GenerateFromTypeLibSpec gencache.AddModuleToCache(info.clsid, info.lcid, info.major, info.minor) File "C:\Programme\Python\Lib\site-packages\win32com\client\gencache.py", line 555, in AddModuleToCache mod = _GetModule(fname) File "C:\Programme\Python\Lib\site-packages\win32com\client\gencache.py", line 634, in _GetModule mod = __import__(mod_name) File "C:\DOKUME~1\Arthur\LOKALE~1\Temp\gen_py\2.4\9C3BB401-114D-11D4-AC72-00105A4925FCx0x1x2\__init__.py", line 57 'IEnumCADdyAddIn' : '{14F65AE3-4671-11D4-8B1A-00105A49278B}', ^ SyntaxError: invalid syntax Can anyone tell me what I'm doing wrong. Is this a known problem? I'm using the ActiveState Python 2.4.1.-245 build. With kind regards Johannes ____________ Virus checked by G DATA AntiVirusKit From niki at vintech.bg Mon Jun 6 18:34:29 2005 From: niki at vintech.bg (Niki Spahiev) Date: Mon, 06 Jun 2005 19:34:29 +0300 Subject: [python-win32] Problem with gencache.EnsureModule In-Reply-To: <23D83A07C60A0E47AD964F74DA96940104BD29@mail.datasolid.de> References: <23D83A07C60A0E47AD964F74DA96940104BD29@mail.datasolid.de> Message-ID: <42A47B15.9070500@vintech.bg> Johannes Brunen wrote: > File "C:\DOKUME~1\Arthur\LOKALE~1\Temp\gen_py\2.4\9C3BB401-114D-11D4-AC72-00105A4925FCx0x1x2\__init__.py", line 57 Remove encoding comment from start of this file. HTH Niki Spahiev From 7qrj45 at clayelectric.com Mon Jun 6 19:31:25 2005 From: 7qrj45 at clayelectric.com (Ronnie Jones) Date: Mon, 6 Jun 2005 13:31:25 -0400 Subject: [python-win32] Windows LogParser COM interface Message-ID: <5555C0CF56DDD24BBF143A7454A266CA10CD0E@khw3sent01.clayelectric.com> The issue is resolved. Apparently it is an issue with the COM object from LogParser not writing to the same file handle for standard out that PythonWin is using so the two never meet. If I write the script and a .py and run from the command line it works just like the VB script. No actually better 'cause it's written in Python. Thanks for the heads up Mark. Ronnie Jones -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050606/53af2f6d/attachment.htm From timr at probo.com Mon Jun 6 19:32:18 2005 From: timr at probo.com (Tim Roberts) Date: Mon, 06 Jun 2005 10:32:18 -0700 Subject: [python-win32] IIS CGI installation In-Reply-To: References: Message-ID: <42A488A2.6090003@probo.com> On Sat, 4 Jun 2005 11:27:28 -0700, "Robert Brewer" wrote" >It's probably considered insecure because you are passing params (%s) to >python on the command line. Those "clever hackers" could find a way to >pass Nasty Things, like "del C:" > >Performance will be intolerable, since each page request has to start >and stop the Python interpreter, which is not a quick process. > This is a dangerous exaggeration. There are a huge number of web sites for which a Python CGI implementation is quite workable. If you're creating a web site that will get 5 hits a minute, no one will either care or notice the extra half second from loading Python. The vast majority of the web sites in the world fall into that category. Now, if you're getting 100 hits a minute, then you need to look at another approach. But don't waste time optimizing unnecessarily. First, see if you have a problem. Then attack it. The ease of developing and debugging using CGI should not be underestimated. >If you used the latter, you could use CherryPy and be on the cutting >edge of Python web development. :) > Here, I am in complete agreement. There's something very appealing about CherryPy. Simple, functional, understandable. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Jun 6 19:41:08 2005 From: timr at probo.com (Tim Roberts) Date: Mon, 06 Jun 2005 10:41:08 -0700 Subject: [python-win32] Windows LogParser COM interface In-Reply-To: References: Message-ID: <42A48AB4.6090104@probo.com> On Mon, 6 Jun 2005 08:52:46 -0400, "Ronnie Jones" <7qrj45 at clayelectric.com> wrote: >I am trying to access LogParser 2.2 through the COM interface provided >and I am having a bit of a problem. Here is what is going on: First up >is the VBScript version of the code then comes the Python version. > > ... > >Here is the python code for the same example: > > > >>>>>>> import win32com.client >>>>>>> objLogParser = win32com.client.Dispatch("MSUtil.LogQuery") >>>>>>> objOutput = win32com.client.Dispatch("MSUtil.LogQuery.NativeOutputFormat") >>>> >>>> >>>>>>> objOutput.rtp = -1 >>>>>>> objInput = win32com.client.Dispatch("MSUtil.LogQuery.FileSystemInputFormat") >>>> >>>> >>>>>>> objInput.recurse = 0 >>>>>>> myquery = "SELECT Name, Size FROM 'C:/lame/misc/*.*' ORDER BY Name ASC" >>>> >>>> >>>>>>> objLogParser.ExecuteBatch(myquery, objInput, objOutput) >>>> >>>> > >Traceback (most recent call last): >File "", line 1, in ? >File >"C:\Python23\Lib\site-packages\win32com\gen_py\A7E75D86-41CD-4B6E-B4BD-C >C2ED34B3FB0x0x1x0.py", line 819, in ExecuteBatch >return self._oleobj_.InvokeTypes(2, LCID, 1, (11, 0), ((8, 1), (13, 49), >(13, 49)),szQuery, pObjectInputContext, pObjectOutputContext) >com_error: (-2147352567, 'Exception occurred.', (0, 'CLogQueryClass', >'Error executing query: Error while writing to file: The handle is >invalid. [The handle is invalid.]', None, 0, -2147024890), None) > > Well, I cut and pasted your code as-is onto my XP SP2 system, and it worked perfectly. As Mark said, however, you can't run this within a GUI app. If you put this in a "pyw" file, or if you launch it with pythonw, it won't work, because there is no stdout to write to. The fact that the traceback shows "file "", line 1, in ?" tells me that you might be running it from inside a GUI, and not from a real command line. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From shane.holloway at ieee.org Mon Jun 6 19:50:56 2005 From: shane.holloway at ieee.org (Shane Holloway (IEEE)) Date: Mon, 06 Jun 2005 11:50:56 -0600 Subject: [python-win32] COM Events and Type libraries Message-ID: <42A48D00.70602@ieee.org> I've been having a devil of a time trying to get events working in win32com with an attached Type library. It seems like I'm missing something obvious, but I haven't been able to figure it out. So I'd like to ask your collective wisdom! My code is at: http://www.teuton.org/~sholloway/pyTestEvents.zip IDL compiles into a tlb just fine, and I am able to register the COM server. However, when I try to run pyEventsTestUser.py, I keep getting server.policy errors creating the control. (Tracebacks attached) Thank you very much for any time you spend on this! -Shane Holloway -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: pyEventsTestUser.py.out Url: http://mail.python.org/pipermail/python-win32/attachments/20050606/8ebae9bc/pyEventsTestUser.py.ksh From mhammond at skippinet.com.au Tue Jun 7 00:53:11 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 7 Jun 2005 08:53:11 +1000 Subject: [python-win32] getting global addressbook with extended mapi In-Reply-To: <42A462AE.707@kareta.de> Message-ID: <06c701c56aea$84278080$010a0a0a@enfoldsystems.local> HrFindExchangeGlobalAddressList and a few others appeared to vanish from recent Exchange SDK versions. Its not clear from MSDN what the status is of those functions, but they certainly don't appear in any MS .h files I currently have. It appears that ActiveDirectory can be used to access the GAL on later exchanges - maybe that is the new "official" way of doing it? A quick google may offer other advice - eg, see if you can find any C++ code that references the GAL by any way other than that function. Mark > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of J?rgen Kareta > Sent: Tuesday, 7 June 2005 12:50 AM > To: python-win32 Mailinglist > Subject: [python-win32] getting global addressbook with extended mapi > > > Hello, > > I followed Marks hint and tried to get my global addressbook entries > with extended mapi. > > from win32com.mapi import mapiutil > from win32com.mapi import exchange > import pprint,pythoncom > profileName = "Test" > session = mapi.MAPIInitialize(None) > session =mapi.MAPILogonEx(0,'test',None, mapi.MAPI_EXTENDED | > mapi.MAPI_LOGON_UI |\ > mapi.MAPI_NO_MAIL |mapi.MAPI_USE_DEFAULT) > hr=session.OpenAddressBook(0,None,mapi.AB_NO_DIALOG) > gal = exchange.HrFindExchangeGlobalAddressList (hr) > > raise: > gal = exchange.HrFindExchangeGlobalAddressList (hr) > NotImplementedError: Not available with this version of the > Exchange SDK > > So it seems to be that our exchange5.5 SP3 Server don't provide all > extended mapi features. But the > DumpTopLevelFolders funktion of the class MAPIDriver in spambayes > sandbox works fine. > > How can I find a workaround to access the gal entries ? > > The final solution should work like the following cdo code: > from win32com.client.dynamic import Dispatch > s=Dispatch("Mapi.session") > s.Logon("", "", False, True, 0, True,\ > > ProfileInfo="/o=myserver/ou=myside/cn=Configuration/cn=myserve > r\n\nanon") > entries=s.AddressLists('Globales Adressbuch').AddressEntries.Item(my > distribution list).Members > for entr in entries: > print > entr.Name,entr.Fields(0x39fe001e).Value,entr.Fields(0x3a00001e) > > Any hints ? > > regards, > J?rgen > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Tue Jun 7 00:56:35 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 7 Jun 2005 08:56:35 +1000 Subject: [python-win32] com object gives a pointer to a C++ struct array back In-Reply-To: <200506061337.j56DbvoW026946@rrba-146-73-34.telkomadsl.co.za> Message-ID: <06cc01c56aea$fdcd7840$010a0a0a@enfoldsystems.local> IIRC at a RECORD data type includes any array sizes. Does your IDL explicitly indicate it is an array of records, or are you declaring it as a simple record, but then using it as an array? If the former, please send me a sample of your IDL so I can reproduce the error. If the latter, then you probably need to adjust your IDL. Does your code work with VB? Mark > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of Gijs Korremans > Sent: Monday, 6 June 2005 11:34 PM > To: python-win32 at python.org > Subject: [python-win32] com object gives a pointer to a C++ > struct array > back > > > Hi > > one of the functions in a com object I have to use gives me a > pointer to the firtst struct in an array back. With Python > it's possible to use the first truct, but is it possible to > use the others as well? > > //for example: > PointerToFirstStruct = comObj.GetPackets() > argOne = PointerToFirstStruct.argOne > argTwo = PointerToFirstStruct.argTwo > # Go to the next struct > # PointerToFirstStruct++ doesn't work > > > Kind regards, > > > Gijs > > -- > This message has been scanned for viruses and > dangerous content by Network Sentry, and is > believed to be clean. > http://www.networksentry.co.za > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From simon.j.hook at jpl.nasa.gov Tue Jun 7 02:16:25 2005 From: simon.j.hook at jpl.nasa.gov (Simon Hook) Date: Mon, 06 Jun 2005 17:16:25 -0700 Subject: [python-win32] import and asp-python and iis - strange behaviour Message-ID: <42A4E759.3000902@jpl.nasa.gov> Hi, I am trying to use import in an asp python page. If I have: <%@ LANGUAGE = Python%> <% import myfile %> Then myfile can only be found if its in the root of the python install directory, e.g. c:\python23 and only if the file is called myfile.py and it contains python NOT asp code. If I have some python code and it is loaded by a webpage, if I make any changes to the code in myfile.py the changes do not come into effect unless I reboot my machine. I tried start/stop/start iis but that has no effect, I tried open/close/open and I tried the python reload() command. None of these had any effect. The only way I could get an asp-python file included was to use the asp include: How can I get asp to pull python code from another directory and how can I make a change and not have to reboot for the change to be invoked? Can I use import with an asp page? Many thanks Simon From steve at holdenweb.com Tue Jun 7 03:39:51 2005 From: steve at holdenweb.com (Steve Holden) Date: Mon, 06 Jun 2005 21:39:51 -0400 Subject: [python-win32] import and asp-python and iis - strange behaviour In-Reply-To: <42A4E759.3000902@jpl.nasa.gov> References: <42A4E759.3000902@jpl.nasa.gov> Message-ID: <42A4FAE7.2020402@holdenweb.com> Simon Hook wrote: > Hi, > > I am trying to use import in an asp python page. If I have: > > <%@ LANGUAGE = Python%> > <% > import myfile > %> > > Then myfile can only be found if its in the root of the python install > directory, e.g. > > c:\python23 > > and only if the file is called myfile.py and it contains python NOT asp > code. If I have some python code and it is loaded by a webpage, if I > make any changes to the code in myfile.py the changes do not come into > effect unless I reboot my machine. I tried start/stop/start iis but that > has no effect, I tried open/close/open and I tried the python reload() > command. None of these had any effect. > Technically it will be found if the corresponding .py or .pyc is in any of the directories (or other importers) on sys.path. > The only way I could get an asp-python file included was to use the asp > include: > > > This is correct. > How can I get asp to pull python code from another directory and how can > I make a change and not have to reboot for the change to be invoked? Can > I use import with an asp page? > Well, obviously with #include you could include a path in the file="..." or virtual="..." string. You will need to ensure that sys.path contains an appropriate directory to find modules you wan to import. Since you want to use "import" the files must be pure Python, you can't import .ASP pages (but, as you have discovered, you can include them). IIRC I did some experiments that showed me that under suitable circumstances the Python interpreter will see an updated module after an ASP page performs a reload() of the required module. regards Steve > Many thanks Simon > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- Steve Holden +1 703 861 4237 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ From simon.j.hook at jpl.nasa.gov Tue Jun 7 05:33:37 2005 From: simon.j.hook at jpl.nasa.gov (Simon Hook) Date: Mon, 06 Jun 2005 20:33:37 -0700 Subject: [python-win32] import and asp-python and iis - strange behaviour In-Reply-To: <42A4FAE7.2020402@holdenweb.com> References: <42A4E759.3000902@jpl.nasa.gov> <42A4FAE7.2020402@holdenweb.com> Message-ID: <42A51591.7000709@jpl.nasa.gov> Steve, Thanks for the quick response, everything you said works, I have a couple more questions. Here are a couple of scripts that illustrate how I implemented your suggestions. -------file1 listing ---------------gofetch.asp <%@ LANGUAGE = Python%> <% import sys path = "d:/inetpub/wwwroot" sys.path.append(path) import somefunctions reload(somefunctions) from somefunctions import * %> <%=returnthevalue("okay it works")%> ------------------------------------- -------file2 listing --------- somefunctions.asp def returnthevalue(thevalue): return thevalue ------------------------------------ Both files go in the wwwroot directory. Now you see how bad I am at python, my two additonal questions are: 1) How can I avoid using an explicit path specification "d:/inetpub/wwwroot" I tried using os.getcwd() but that returned a system directory. 2) How can I avoid the 2 import calls for somefunctions. If I just use "import somefunctions" then I have to call the function as somefunctions.returnthevalue. But if I just use "from somefunctions import *" then reload does not work! Thanks and great acronym BTW I had never heard that one. Simon Steve Holden wrote: > Simon Hook wrote: > >> Hi, >> >> I am trying to use import in an asp python page. If I have: >> >> <%@ LANGUAGE = Python%> >> <% >> import myfile >> %> >> >> Then myfile can only be found if its in the root of the python >> install directory, e.g. >> >> c:\python23 >> >> and only if the file is called myfile.py and it contains python NOT >> asp code. If I have some python code and it is loaded by a webpage, >> if I make any changes to the code in myfile.py the changes do not >> come into effect unless I reboot my machine. I tried start/stop/start >> iis but that has no effect, I tried open/close/open and I tried the >> python reload() command. None of these had any effect. >> > Technically it will be found if the corresponding .py or .pyc is in > any of the directories (or other importers) on sys.path. > >> The only way I could get an asp-python file included was to use the >> asp include: >> >> >> > This is correct. > >> How can I get asp to pull python code from another directory and how >> can I make a change and not have to reboot for the change to be >> invoked? Can I use import with an asp page? >> > Well, obviously with #include you could include a path in the > file="..." or virtual="..." string. > > You will need to ensure that sys.path contains an appropriate > directory to find modules you wan to import. Since you want to use > "import" the files must be pure Python, you can't import .ASP pages > (but, as you have discovered, you can include them). > > IIRC I did some experiments that showed me that under suitable > circumstances the Python interpreter will see an updated module after > an ASP page performs a reload() of the required module. > > regards > Steve > >> Many thanks Simon >> _______________________________________________ >> Python-win32 mailing list >> Python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> > > From fumanchu at amor.org Tue Jun 7 05:43:50 2005 From: fumanchu at amor.org (Robert Brewer) Date: Mon, 6 Jun 2005 20:43:50 -0700 Subject: [python-win32] import and asp-python and iis - strange behaviour Message-ID: <3A81C87DC164034AA4E2DDFE11D258E377232B@exchange.hqamor.amorhq.net> Simon Hook wrote: > I am trying to use import in an asp python page. If I have: > > <%@ LANGUAGE = Python%> > <% > import myfile > %> > > Then myfile can only be found if its in the root of the > python install directory, e.g. c:\python23 > and only if the file is called myfile.py and it contains > python NOT asp code. If I have some python code and it is > loaded by a webpage, if I make any changes to the code > in myfile.py the changes do not come into effect unless > I reboot my machine. I tried start/stop/start iis but that > has no effect, I tried open/close/open and I tried the python > reload() command. None of these had any effect. > > The only way I could get an asp-python file included was to > use the asp include: > > > > How can I get asp to pull python code from another directory > and how can I make a change and not have to reboot for the > change to be invoked? Can I use import with an asp page? That's odd. When you say "stop/start iis" are you only restarting the www service? I find that the following works: open the Internet Services Manager, right click on the computer and choose "Restart IIS..." from the menu, then "Restart Internet Service on machinename". AFAICT, any code inside an .asp file will be reloaded whenever it changes. Any code within an imported .py file requires the restart I described above. FWIW I've had some issues in the past with "import myfile", and I find "from mypackage import mfile" to be more reliable. Sorry; I don't have any hard data on that at the moment--lost in the mists of history. But everything I import in .asp files sits in my site-packages folder anyway. Robert Brewer System Architect Amor Ministries fumanchu at amor.org From simon.j.hook at jpl.nasa.gov Tue Jun 7 06:14:08 2005 From: simon.j.hook at jpl.nasa.gov (Simon Hook) Date: Mon, 06 Jun 2005 21:14:08 -0700 Subject: [python-win32] import and asp-python and iis - strange behaviour In-Reply-To: <3A81C87DC164034AA4E2DDFE11D258E377232B@exchange.hqamor.amorhq.net> References: <3A81C87DC164034AA4E2DDFE11D258E377232B@exchange.hqamor.amorhq.net> Message-ID: <42A51F10.3030009@jpl.nasa.gov> Bob, Looks like our messages crossed in the ether. Thanks for the clarification. I was using iis->click on default web site and start/stop, rather than restart iis. Also thanks for info on python versus asp. In my previous message using reload in a python file does work so you do not need to restart iis everytime but it is probably inefficient? Simon Robert Brewer wrote: >Simon Hook wrote: > > >>I am trying to use import in an asp python page. If I have: >> >><%@ LANGUAGE = Python%> >><% >>import myfile >>%> >> >>Then myfile can only be found if its in the root of the >>python install directory, e.g. c:\python23 >>and only if the file is called myfile.py and it contains >>python NOT asp code. If I have some python code and it is >>loaded by a webpage, if I make any changes to the code >>in myfile.py the changes do not come into effect unless >>I reboot my machine. I tried start/stop/start iis but that >>has no effect, I tried open/close/open and I tried the python >>reload() command. None of these had any effect. >> >>The only way I could get an asp-python file included was to >>use the asp include: >> >> >> >>How can I get asp to pull python code from another directory >>and how can I make a change and not have to reboot for the >>change to be invoked? Can I use import with an asp page? >> >> > >That's odd. When you say "stop/start iis" are you only restarting the >www service? I find that the following works: open the Internet Services >Manager, right click on the computer and choose "Restart IIS..." from >the menu, then "Restart Internet Service on machinename". > >AFAICT, any code inside an .asp file will be reloaded whenever it >changes. Any code within an imported .py file requires the restart I >described above. > >FWIW I've had some issues in the past with "import myfile", and I find >"from mypackage import mfile" to be more reliable. Sorry; I don't have >any hard data on that at the moment--lost in the mists of history. But >everything I import in .asp files sits in my site-packages folder >anyway. > > >Robert Brewer >System Architect >Amor Ministries >fumanchu at amor.org > > From mhammond at skippinet.com.au Tue Jun 7 07:25:44 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 7 Jun 2005 15:25:44 +1000 Subject: [python-win32] import and asp-python and iis - strange behaviour In-Reply-To: <42A4FAE7.2020402@holdenweb.com> Message-ID: <072701c56b21$5b368680$010a0a0a@enfoldsystems.local> [Steve] > IIRC I did some experiments that showed me that under suitable > circumstances the Python interpreter will see an updated > module after an > ASP page performs a reload() of the required module. Yes, that is my experience too. Python's reload sementics WRT existing class instances from a reloaded module often catches people off-guard though. eg: import foo ob = foo.Klass() # make a change to the class in module foo reload(foo) # 'ob' is still an instance of the *old* class - it does not see new class changes. But all these things should bite in exactly the same way in ASP and in normal Python. ASP may also call your script multiple times in multiple threads, which you may also need to take into consideration when doing these things (Python will never crash in this case, but the behaviour may not be quite as expected) Mark From python at kareta.de Tue Jun 7 18:32:01 2005 From: python at kareta.de (=?ISO-8859-15?Q?J=FCrgen_Kareta?=) Date: Tue, 07 Jun 2005 18:32:01 +0200 Subject: [python-win32] getting global addressbook with extended mapi In-Reply-To: <06c701c56aea$84278080$010a0a0a@enfoldsystems.local> References: <06c701c56aea$84278080$010a0a0a@enfoldsystems.local> Message-ID: <42A5CC01.9010004@kareta.de> Hi Mark, can you please give me some more instructions ? > A quick >google may offer other advice - eg, see if you can find any C++ code that >references the GAL by any way other than that function. > >Mark > > I found the following on http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mapi/html/11b2475b-c6e2-4251-a7a6-0f19a7e560f8.asp *To open a specific container other than the PAB* Open the address book's root container by calling the IAddrBook::OpenEntry method with a NULL entry identifier. The root container is constructed by MAPI and contains the top-level containers of all the address book providers in the profile. ok Get the list of top-level containers by calling the IMAPIContainer::GetHierarchyTable method ok If you want a specific container type such as the global address list, restrict the table on PR_DISPLAY_TYPE : Create a property restriction to match PR_DISPLAY_TYPE with the value for the particular type of container you want to open. For example, to open the global address book, build a property restriction that matches PR_DISPLAY_TYPE with the DT_GLOBAL value. d. Call the IAddrBook::OpenEntry method with the PR_ENTRYID column from the row you want to open the container. Create an SPropTagArray including PR_ENTRYID , PR_DISPLAY_TYPE , and any other columns of interest. Call the HrQueryAllRows function passing your property tag array and restriction. Ordinarily, there will be a single global address list, but the call can return zero, one, or more rows depending on the address book providers in your profile. Be prepared to handle all these cases, not just one row. profileName = "Test" session = mapi.MAPIInitialize(None) session =mapi.MAPILogonEx(0,'test',None, mapi.MAPI_EXTENDED | mapi.MAPI_LOGON_UI |\ mapi.MAPI_NO_MAIL |mapi.MAPI_USE_DEFAULT) hr=session.OpenAddressBook(0,None,mapi.AB_NO_DIALOG) containers=hr.OpenEntry(None,None,mapi.MAPI_BEST_ACCESS) con_list=containers.GetHierarchyTable(0) restriction = (mapi.RES_CONTENT, # a property restriction (mapi.FL_SUBSTRING | mapi.FL_IGNORECASE | mapi.FL_LOOSE, # fuzz level PR_DISPLAY_TYPE, # of the given prop (PR_DISPLAY_TYPE, 'DT_GLOBAL'))) # with given val rows = mapi.HrQueryAllRows(con_list, (PR_ENTRYID, PR_DISPLAY_TYPE), # columns to retrieve restriction, # only these rows None, # any sort order is fine 0) results in: TypeError: an integer is required. If I change 'DT_GLOBAL' to an integer, rows is empty. I found some c code on http://www.wrconsulting.com/Software/Publications/Exchange/Folders/Client.htm: // Prepare recipients list... ADRLIST * pal = NULL; MAPIAllocateBuffer(CbNewADRLIST(1), (LPVOID *) &pal); pal->cEntries = 1; SPropValue * pPropArray = NULL; MAPIAllocateBuffer(3 * sizeof(SPropValue), (LPVOID*) &pPropArray); pPropArray[0].ulPropTag = PR_RECIPIENT_TYPE; pPropArray[0].Value.l = MAPI_TO; pPropArray[1].ulPropTag = PR_DISPLAY_NAME; pPropArray[1].Value.lpszA = "Nik Okuntseff"; pPropArray[2].ulPropTag = PR_ADDRTYPE; pPropArray[2].Value.lpszA = "EX"; // Exchange address type pal->aEntries[0].ulReserved1 = 0; pal->aEntries[0].cValues = 3; // This "3" is important, otherwise the ResolveName fails! pal->aEntries[0].rgPropVals = pPropArray; // We'll IAddrBook interface to resolve display names to entry IDs. LPADRBOOK pAdrBook = NULL; hRes = pSession->OpenAddressBook(0, 0, MAPI_ACCESS_MODIFY, &pAdrBook ); if (FAILED(hRes)) throw -1; // Call IAdrBook::ResolveName method to resolve display names in our list to entry IDs. hRes = pAdrBook->ResolveName(0, 0, NULL, pal); if (FAILED(hRes)) throw -1; but I'm unable to adapt that in python. regards, J?rgen From bmukherj at shoshin.uwaterloo.ca Tue Jun 7 20:14:32 2005 From: bmukherj at shoshin.uwaterloo.ca (Roop Mukherjee) Date: Tue, 7 Jun 2005 14:14:32 -0400 (EDT) Subject: [python-win32] Interfacing to windows explorer Message-ID: I have a python app that runs on my machine. I want to use IE as a front end to it. To that end I want to start up a new IE window when this program is run, and respond to all events on the window (like clicks or form submissions) by calling functions in a python module. I want this to run on machine's that do not run web servers. I do not have any of the microsoft developer tools. I am hoping to do this by using exporting my python object's interface as a COM server. I want the IE to run as a client of this server and send all actions to it. I have seen the examples of how to use excel or word as clients (in "The quick python book", Harms et. al.). e.g. xlapp = Dispatch("Excel.Application") xlapp.WorkBooks.Add() Does someone know of similar examples for IE? Does IE have a library like the Microsoft Word XX Object library that I can use from python? Thanks, -Roop From timr at probo.com Tue Jun 7 20:48:38 2005 From: timr at probo.com (Tim Roberts) Date: Tue, 07 Jun 2005 11:48:38 -0700 Subject: [python-win32] import and asp-python and iis - strange behaviour In-Reply-To: References: Message-ID: <42A5EC06.7090102@probo.com> On Mon, 06 Jun 2005 17:16:25 -0700, Simon Hook wrote: >I am trying to use import in an asp python page. If I have: >... >How can I get asp to pull python code from another directory and how can >I make a change and not have to reboot for the change to be invoked? Can >I use import with an asp page? > In my experience, the best way to deal with the unpredictable and unfriendly nature of IIS and ASP is to "upgrade" IIS by disabling it and installing Apache for Win32 in its place. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mc at mclaveau.com Tue Jun 7 22:03:37 2005 From: mc at mclaveau.com (Michel Claveau) Date: Tue, 7 Jun 2005 22:03:37 +0200 Subject: [python-win32] Interfacing to windows explorer References: Message-ID: <000401c56b9c$00629ca0$0701a8c0@PORTABLES> Bonsoir ! Je fais exactement ce que vous esp?rez : IE comme frontal d'un logiciel en Python. Au d?part, j'utilise un fichier .HTA, qui se connecte ? Python avec Javascript : var comlink = new ActiveXObject("Soft.Python"); Entre les objets de l'interface, et le logiciel Python, j'ai ?tablit plusieurs dizaines de liens COM. Les ?v?nements sont intercept?s par javascript, et transmis au logiciel Python. De la m?me mani?re, les activeX peuvent ?tre t?l?guid?s par Python. A partir de ?a, je suis all? plus loin. Mais cela est difficile ? expliquer avec un simple message... @-salutations Michel Claveau m?l : http://cerbermail.com/?6J1TthIa8B ***** Translation with Babelfish ***** : Good evening! I do exactly what you hope for: IE like frontal of a software in Python. At the beginning, I use a file HTA, which is connected to Python with Javascript: var comlink = new ActiveXObject("Soft.Python"); Between the objects of the interface, and the software Python, I have establishes several tens of bonds COM. The events are intercepted by Javascript, and transmitted to the Python software. Same manner, the activeX can be radio-controlled by Python. >From that, I went further. But that is difficult to explain with a simple message... From mhammond at skippinet.com.au Wed Jun 8 00:48:29 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 8 Jun 2005 08:48:29 +1000 Subject: [python-win32] getting global addressbook with extended mapi In-Reply-To: <42A5CC01.9010004@kareta.de> Message-ID: <00e301c56bb3$0674c0c0$010a0a0a@enfoldsystems.local> > Hi Mark, > > can you please give me some more instructions ? Not in any detail as I don't have an exchange server to test against. > restriction = (mapi.RES_CONTENT, # a property restriction > (mapi.FL_SUBSTRING | mapi.FL_IGNORECASE | > mapi.FL_LOOSE, # fuzz level > PR_DISPLAY_TYPE, # of the given prop > (PR_DISPLAY_TYPE, 'DT_GLOBAL'))) # > with given val > rows = mapi.HrQueryAllRows(con_list, > (PR_ENTRYID, PR_DISPLAY_TYPE), # > columns to retrieve > restriction, # only these rows > None, # any > sort order is fine > 0) > > > results in: TypeError: an integer is required. If I change > 'DT_GLOBAL' > to an integer, rows is empty. PR_DISPLAY_TYPE is indeed an integer. >>> from win32com.mapi import mapitags >>> mapitags.PROP_TYPE(mapitags.PR_DISPLAY_TYPE) 3 >>> mapitags.PT_LONG 3 Why not change your code to remove that restriction, then dump all records found - that should allow you see what values are actually in there. > but I'm unable to adapt that in python. Why? Is something missing, or it just tricky? Sadly, if you want easy, you use CDO/Simple MAPI. Extended MAPI is not for the faint hearted (or for people with deadlines :) Mark From chad.hughes at pnl.gov Wed Jun 8 00:52:15 2005 From: chad.hughes at pnl.gov (Hughes, Chad O) Date: Tue, 07 Jun 2005 15:52:15 -0700 Subject: [python-win32] PythonWin as a MDI Message-ID: <42C7E766869C42408F0360B7BF0CBD9B014B614A@pnlmse27.pnl.gov> Is there a way to launch PythonWin as a Multiple Document Interface so that I can make good use of my multi-monitor system? I would like to open a number of code pages and have them on different monitors. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050607/edb6e3f2/attachment.html From Simon.J.Hook at jpl.nasa.gov Wed Jun 8 02:00:51 2005 From: Simon.J.Hook at jpl.nasa.gov (Simon Hook) Date: Tue, 7 Jun 2005 17:00:51 -0700 Subject: [python-win32] Interfacing to windows explorer Message-ID: Roop, I do not have a python app but do have one in javascript which MAY help. I had a bunch of programs with text files which described the input variables. I wrote 2 programs, the first took the text files and converted them into html. The second, much shorter program, took the html and used ie as the interface, if you like a poor man's gui, to the standalone executables. The final step was to build the execution script for the executable and run it and then exit out of ie. You can download the software from the link at http://winvicar.jpl.nasa.gov After installation, the program you want to look at is Winvicar\tutor\tu.wsf I would think python and javascript would behave in a similar manner. Simon -----Original Message----- From: Roop Mukherjee [mailto:bmukherj at shoshin.uwaterloo.ca] Sent: Tuesday, June 07, 2005 11:15 AM To: python-win32 at python.org Cc: bmukherj at styx.uwaterloo.ca Subject: [python-win32] Interfacing to windows explorer I have a python app that runs on my machine. I want to use IE as a front end to it. To that end I want to start up a new IE window when this program is run, and respond to all events on the window (like clicks or form submissions) by calling functions in a python module. I want this to run on machine's that do not run web servers. I do not have any of the microsoft developer tools. I am hoping to do this by using exporting my python object's interface as a COM server. I want the IE to run as a client of this server and send all actions to it. I have seen the examples of how to use excel or word as clients (in "The quick python book", Harms et. al.). e.g. xlapp = Dispatch("Excel.Application") xlapp.WorkBooks.Add() Does someone know of similar examples for IE? Does IE have a library like the Microsoft Word XX Object library that I can use from python? Thanks, -Roop _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From simon.j.hook at jpl.nasa.gov Wed Jun 8 06:00:41 2005 From: simon.j.hook at jpl.nasa.gov (Simon Hook) Date: Tue, 07 Jun 2005 21:00:41 -0700 Subject: [python-win32] import and asp-python and iis - strange behaviour Message-ID: <42A66D69.2000000@jpl.nasa.gov> Mark et al I cleaned up my example so you do not need to explicity define the directory that the .py script is in, provided it is in the same directory as the asp script. Is there any way to avoid the 2 import statements, "import somefunctions" in order to be able to use reload and "from somefunctions import *" to avoid having to say somefunctions.importthevalue(). --------------------filelisting1 gofetch.asp--------------------------------- <%@ LANGUAGE = Python%> <% # Add this scripts path to the system path so can import modules in this directory import sys sys.path.append(Server.MapPath(".")) # Import a module with a function returnthevalue import somefunctions # When no longer need to reload module set to 0 debug_mode = 1 # Force a reload to ensure any changes to .py files are included if debug_mode: reload(somefunctions) # Import again so can call by name without "somefuctions." from somefunctions import * %> <%=returnthevalue("okay it works")%> ------------------------------------------------------------------------- -----------file listing2 somefunctions.py---------------------------------- def returnthevalue(thevalue): return thevalue ------------------------------------------------------------------------- Many thanks, Simon Mark Hammond wrote: >> Also thanks for info on python versus asp. In my previous message >> using reload in a python file does work so you do not need to restart >> iis everytime but it is probably inefficient? >> > > Having something like: > > import foo, bar > > debug_mode = 1 > > if debug_mode: > reload(foo) > reload(bar) > > When finished dev, set debug_mode = 0, then the penalty is very small. > > Mark > From mhammond at skippinet.com.au Wed Jun 8 06:19:32 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 8 Jun 2005 14:19:32 +1000 Subject: [python-win32] COM Events and Type libraries In-Reply-To: <42A48D00.70602@ieee.org> Message-ID: <003401c56be1$45cd1910$010a0a0a@enfoldsystems.local> > I've been having a devil of a time trying to get events > working in win32com with an attached Type library. It seems > like I'm missing something obvious, but I haven't been able > to figure it out. So I'd like to ask your collective wisdom! > > My code is at: http://www.teuton.org/~sholloway/pyTestEvents.zip Yeah, you have struct a few limitations in the win32com universal support. There are a few key bugs: * If an unknown interface name was requested, universal.py would get a None but fail to treat it as an error. The interface entries used by universal must be interface *names* - you were passing an IID as a string, so looking up this interface name failed. * Even if we get past that, you will strike a problem when you attempt to have a real IID in _com_interfaces_ - a type error as we attempt to use that as a string interface name as described above. You may be able to work around it by having _com_interfaces_ have only the interface names from the typelib, and implementing a _query_interface_ method on your object to support the connection-point interfaces. In the meantime I will fix this in win32com - I'll mail the changed .py files personally. Mark From simon.j.hook at jpl.nasa.gov Wed Jun 8 05:50:56 2005 From: simon.j.hook at jpl.nasa.gov (Simon Hook) Date: Tue, 07 Jun 2005 20:50:56 -0700 Subject: [python-win32] import and asp-python and iis - strange behaviour In-Reply-To: <072801c56b21$5f4d4740$010a0a0a@enfoldsystems.local> References: <072801c56b21$5f4d4740$010a0a0a@enfoldsystems.local> Message-ID: <42A66B20.8020605@jpl.nasa.gov> Mark et al I cleaned up my example so you do not need to explicity define the directory that the .py script is in, provided it is in the same directory as the asp script. Is there any way to avoid the 2 import statements, "import somefunctions" in order to be able to use reload and "from somefunctions import *" to avoid having to say somefunctions.importthevalue(). --------------------filelisting1 gofetch.asp--------------------------------- <%@ LANGUAGE = Python%> <% # Add this scripts path to the system path so can import modules in this directory import sys sys.path.append(Server.MapPath(".")) # Import a module with a function returnthevalue import somefunctions # When no longer need to reload module set to 0 debug_mode = 1 # Force a reload to ensure any changes to .py files are included if debug_mode: reload(somefunctions) # Import again so can call by name without "somefuctions." from somefunctions import * %> <%=returnthevalue("okay it works")%> ------------------------------------------------------------------------- -----------file listing2 somefunctions.py---------------------------------- def returnthevalue(thevalue): return thevalue ------------------------------------------------------------------------- Many thanks, Simon Mark Hammond wrote: >>Also thanks for info on python versus asp. In my previous >>message using >>reload in a python file does work so you do not need to restart iis >>everytime but it is probably inefficient? >> > >Having something like: > >import foo, bar > >debug_mode = 1 > >if debug_mode: > reload(foo) > reload(bar) > >When finished dev, set debug_mode = 0, then the penalty is very small. > >Mark > From timr at probo.com Wed Jun 8 19:15:52 2005 From: timr at probo.com (Tim Roberts) Date: Wed, 08 Jun 2005 10:15:52 -0700 Subject: [python-win32] Interfacing to windows explorer In-Reply-To: References: Message-ID: <42A727C8.9070302@probo.com> On Tue, 7 Jun 2005 14:14:32 -0400 (EDT), Roop Mukherjee wrote: >I have a python app that runs on my machine. I want to use IE as a front >end to it. To that end I want to start up a new IE window when this >program is run, and respond to all events on the window (like clicks or >form submissions) by calling functions in a python module. I want this to >run on machine's that do not run web servers. > I'm going to check out some of the ActiveX proposals suggested here, but I wanted to point out that it is very easy to embed a small web server into a Python application. The standard library contains a simple but functional web server, but a package like CherryPy gives you a robust solution with built-in command handling and template support. I've delivered several internal GUI applications as CherryPy apps. People are comfortable using IE as a user interface, and it's a lot easier than wxPython (even though I like wxPython a lot). -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From radams at nassco.com Wed Jun 8 21:26:15 2005 From: radams at nassco.com (Robert Adams) Date: Wed, 8 Jun 2005 12:26:15 -0700 Subject: [python-win32] Editor Replace function limitation Message-ID: <000001c56c5f$eff6d0b0$8fe210ac@nassco.local> Hi, Do I have a setup issue or is the PythonWin editor Replace function limited to 30 characters ? Thanks in advance, Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050608/9b10a69d/attachment.html From graemeglass at gmail.com Wed Jun 8 23:12:00 2005 From: graemeglass at gmail.com (Graeme Glass) Date: Wed, 8 Jun 2005 23:12:00 +0200 Subject: [python-win32] Editor Replace function limitation In-Reply-To: <000001c56c5f$eff6d0b0$8fe210ac@nassco.local> References: <000001c56c5f$eff6d0b0$8fe210ac@nassco.local> Message-ID: On python 2.3.4 pythonwin build 203, i don't seem to have a problem. can replace much more than 30 chars. Not sure what your problem could be, but just thought that i would let you know it's must your setup not pythonwin. (you proberbly already tried this,) but try installing the a diffrent build. On 6/8/05, Robert Adams wrote: > > Hi, > > Do I have a setup issue or is the PythonWin editor Replace function limited > to 30 characters ? > > Thanks in advance, > Robert > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > From sjmachin at lexicon.net Wed Jun 8 23:45:15 2005 From: sjmachin at lexicon.net (John Machin) Date: Thu, 09 Jun 2005 07:45:15 +1000 Subject: [python-win32] Editor Replace function limitation In-Reply-To: References: <000001c56c5f$eff6d0b0$8fe210ac@nassco.local> Message-ID: <42A766EB.8020308@lexicon.net> Graeme Glass wrote: >On python 2.3.4 pythonwin build 203, i don't seem to have a problem. >can replace much more than 30 chars. >Not sure what your problem could be, but just thought that i would let >you know it's must your setup not pythonwin. > > Graeme, what "setup" do you refer to? PythonWin appears to have no configuration opportunity for changing the max size of a text replacement -- and indeed I can't imagine that any text editor would ever have had such an option, especially after malloc() was invented ... >(you proberbly already tried this,) but try installing the a diffrent build. > >On 6/8/05, Robert Adams wrote: > > >> >>Do I have a setup issue or is the PythonWin editor Replace function limited >>to 30 characters ? >> >> Robert, It worked for me on 2.4.1 / build 204. I typed in "abc" then replaced "b" by "ab....yzAB...JK". The size of the box for typing in the replacement string is only 30 characters, but it does scroll if you keep on typing -- have you tried this? What makes you think it is limited to 30 characters? Regards, John From radams at nassco.com Thu Jun 9 00:50:14 2005 From: radams at nassco.com (Robert Adams) Date: Wed, 8 Jun 2005 15:50:14 -0700 Subject: [python-win32] Editor Replace function limitation In-Reply-To: Message-ID: <000a01c56c7c$6f67b820$8fe210ac@nassco.local> Thanks for both your input on this. I can recreate the problem as follows: Create a script file with the following, 123456789012345678901234567890123456789. Cut/paste into the "Find What" window, I then only get 12345678901234567890123456, that is 26 characters not 30, so I obviously can not count either. Enter var_x, including a space after x into the "Replace with" window, then hit replace. And I end up with var_x 7890123456789 Also, if I keep typing my window does not scroll as you describe. I am running the following, Python 2.3.3, wxPython 2.4.2.4, PythonWin 2.3.3 win32all build 163, and FYI, I am forced to run this version in support of CAD system. Regards, Robert -----Original Message----- From: John Machin [mailto:sjmachin at lexicon.net] Sent: Wednesday, June 08, 2005 2:45 PM To: Graeme Glass; Robert Adams Cc: python-win32 Subject: Re: [python-win32] Editor Replace function limitation Graeme Glass wrote: >On python 2.3.4 pythonwin build 203, i don't seem to have a problem. >can replace much more than 30 chars. >Not sure what your problem could be, but just thought that i would let >you know it's must your setup not pythonwin. > > Graeme, what "setup" do you refer to? PythonWin appears to have no configuration opportunity for changing the max size of a text replacement -- and indeed I can't imagine that any text editor would ever have had such an option, especially after malloc() was invented ... >(you proberbly already tried this,) but try installing the a diffrent build. > >On 6/8/05, Robert Adams wrote: > > >> >>Do I have a setup issue or is the PythonWin editor Replace function limited >>to 30 characters ? >> >> Robert, It worked for me on 2.4.1 / build 204. I typed in "abc" then replaced "b" by "ab....yzAB...JK". The size of the box for typing in the replacement string is only 30 characters, but it does scroll if you keep on typing -- have you tried this? What makes you think it is limited to 30 characters? Regards, John From sjmachin at lexicon.net Thu Jun 9 01:05:13 2005 From: sjmachin at lexicon.net (John Machin) Date: Thu, 09 Jun 2005 09:05:13 +1000 Subject: [python-win32] Editor Replace function limitation In-Reply-To: <000a01c56c7c$6f67b820$8fe210ac@nassco.local> References: <000a01c56c7c$6f67b820$8fe210ac@nassco.local> Message-ID: <42A779A9.1050907@lexicon.net> Robert Adams [and everybody else] top-posted and I can't be bother rearranging so I'm going with the flow: What you tried works OK with my set-up (2.4.1, pywin32 build 204). >Thanks for both your input on this. > >I can recreate the problem as follows: > >Create a script file with the following, >123456789012345678901234567890123456789. >Cut/paste into the "Find What" window, I then only get >12345678901234567890123456, that is 26 characters not 30, so I obviously can >not count either. >Enter var_x, including a space after x into the "Replace with" window, then >hit replace. > >And I end up with var_x 7890123456789 > >Also, if I keep typing my window does not scroll as you describe. > >I am running the following, Python 2.3.3, wxPython 2.4.2.4, PythonWin 2.3.3 >win32all build 163, and FYI, I am forced to run this version in support of >CAD system. > >Regards, >Robert > >-----Original Message----- >From: John Machin [mailto:sjmachin at lexicon.net] >Sent: Wednesday, June 08, 2005 2:45 PM >To: Graeme Glass; Robert Adams >Cc: python-win32 >Subject: Re: [python-win32] Editor Replace function limitation > > >Graeme Glass wrote: > > > >>On python 2.3.4 pythonwin build 203, i don't seem to have a problem. >>can replace much more than 30 chars. >>Not sure what your problem could be, but just thought that i would let >>you know it's must your setup not pythonwin. >> >> >> >> >Graeme, what "setup" do you refer to? PythonWin appears to have no >configuration opportunity for changing the max size of a text >replacement -- and indeed I can't imagine that any text editor would >ever have had such an option, especially after malloc() was invented ... > > > >>(you proberbly already tried this,) but try installing the a diffrent >> >> >build. > > >>On 6/8/05, Robert Adams wrote: >> >> >> >> >>>Do I have a setup issue or is the PythonWin editor Replace function >>> >>> >limited > > >>>to 30 characters ? >>> >>> >>> >>> >Robert, > >It worked for me on 2.4.1 / build 204. I typed in "abc" then replaced >"b" by "ab....yzAB...JK". > >The size of the box for typing in the replacement string is only 30 >characters, but it does scroll if you keep on typing -- have you tried >this? What makes you think it is limited to 30 characters? > >Regards, >John > > > > > > From b.hall at irl.cri.nz Thu Jun 9 01:54:29 2005 From: b.hall at irl.cri.nz (Blair Hall) Date: Thu, 09 Jun 2005 11:54:29 +1200 Subject: [python-win32] 'Recent files' in IDE Message-ID: <5.2.0.9.1.20050609114720.0266a410@127.0.0.1> Having moved up to Python 2.4 (with pythonwin build 203), I was wondering how to get the File menu to remember files between openning and closing the IDE (it works fine as long the the IDE is open, but remembers nothing the next time you start it up again). Can anyone give me a hint? From python at kareta.de Thu Jun 9 05:39:56 2005 From: python at kareta.de (python@kareta.de) Date: Thu, 9 Jun 2005 05:39:56 +0200 Subject: [python-win32] getting global addressbook with extended mapi Message-ID: <1118288396.42a7ba0c4a13a@webmail.ldc.de> Hi all, Mark wrote: >Why? Is something missing, or it just tricky? > >Sadly, if you want easy, you use CDO/Simple MAPI. Extended MAPI is not for >the faint hearted (or for people with deadlines :) I think, that's not a matter of to be clench or not. Diving into a crazy organized library with poor and peripheral dokumentation is just waste of time. But anyway, if there are more faint hearted outside, here is the code working for me: from win32com.mapi.mapitags import * from win32com.mapi import mapi from win32com.mapi import mapiutil profileName = "Test" session = mapi.MAPIInitialize(None) session =mapi.MAPILogonEx(0,profileName,None, mapi.MAPI_EXTENDED | mapi.MAPI_LOGON_UI |\ mapi.MAPI_NO_MAIL |mapi.MAPI_USE_DEFAULT) hr=session.OpenAddressBook(0,None,mapi.AB_NO_DIALOG) ##open rootcontainer root=hr.OpenEntry(None,None,mapi.MAPI_BEST_ACCESS) ##get items root_htab=root.GetHierarchyTable(0) ##restrict for GAL ##SPropValue should be 'DT_GLOBAL' but not defined in mapitags DT_GLOBAL=131072 restriction = (mapi.RES_PROPERTY, (1, PR_DISPLAY_TYPE, (PR_DISPLAY_TYPE, DT_GLOBAL))) ## get GAL's entryid tuple gal_id = mapi.HrQueryAllRows(root_htab, (PR_ENTRYID), restriction, None, 0) ## extract GAL's entryid gal_id = gal_id[0][0][1] ## open GAL gal=hr.OpenEntry(gal_id,None,mapi.MAPI_BEST_ACCESS) ## get content gal_list=gal.GetContentsTable(0) ## no readable tagname for smpt PR_SMTP=972947486 rows = mapi.HrQueryAllRows(gal_list, (PR_ENTRYID, PR_DISPLAY_NAME_A,PR_ACCOUNT,PR_SMTP), None, None, 0) for eid,name,alias,smtp in rows: print name[1],alias[1],smtp[1] mapi.MAPIUninitialize() PS.: Expanding a distribution lists of the GAL needs to set the address type of that dl to 'MAPIPDL', but I'm lacking the permissions - crazy, crazy regards, J?rgen ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/ From mhammond at skippinet.com.au Thu Jun 9 08:16:53 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 9 Jun 2005 16:16:53 +1000 Subject: [python-win32] 'Recent files' in IDE In-Reply-To: <5.2.0.9.1.20050609114720.0266a410@127.0.0.1> Message-ID: <020501c56cba$d68b56e0$010a0a0a@enfoldsystems.local> > Having moved up to Python 2.4 (with pythonwin build 203), I Fixed in build 204. Mark From bmukherj at shoshin.uwaterloo.ca Thu Jun 9 17:29:00 2005 From: bmukherj at shoshin.uwaterloo.ca (Roop Mukherjee) Date: Thu, 9 Jun 2005 11:29:00 -0400 (EDT) Subject: [python-win32] Interfacing to windows explorer In-Reply-To: <000401c56b9c$00629ca0$0701a8c0@PORTABLES> References: <000401c56b9c$00629ca0$0701a8c0@PORTABLES> Message-ID: Thanks for the suggestions. I am debating which of the feasible methods will be easier. The javascript code calling a COM object was quite easy to get working: var obj = ActiveXObject(aa.bb); However it doesn't work with mozilla (which I expected). When loaded as HTML it gives a warning every time. Even when you run it as HTA, it generates a warning on the first run, but not after. The HTA option looks neat for a windows application (thanks Michel). For deployment I guess you would go something like this: pack an HTA file with your python com server exe. Write a bat file that to runs the application you are writing so that it can register with the local registry. Then open explorer passing it the HTA file. The option of running a web server locally whenever this application is fired can be used in lieu of running a com server and using HTA. The reason why the web server option looks attractive is becuasebecause it has object publishing that comes for free, with something like Cherry Pie. Without this, I would have to write some messy html scripting code that will intercept actions on the HTML/HTA file and then return with other HTML/HTA pages etc. I guess the happy middle would be to find a object publishing framework that generates HTML but runs inside a python COM server. Is there any? If not I guess one can try change cherry py a little bit so it can act as a com server instead of a webserver. -- Roop On Tue, 7 Jun 2005, Michel Claveau wrote: > Bonsoir ! > > > Je fais exactement ce que vous esp?rez : IE comme frontal d'un logiciel en > Python. > Au d?part, j'utilise un fichier .HTA, qui se connecte ? Python avec > Javascript : > var comlink = new ActiveXObject("Soft.Python"); > Entre les objets de l'interface, et le logiciel Python, j'ai ?tablit > plusieurs dizaines de liens COM. > Les ?v?nements sont intercept?s par javascript, et transmis au logiciel > Python. > De la m?me mani?re, les activeX peuvent ?tre t?l?guid?s par Python. > > A partir de ?a, je suis all? plus loin. Mais cela est difficile ? expliquer > avec un simple message... > > @-salutations > > Michel Claveau > m?l : http://cerbermail.com/?6J1TthIa8B > > > > ***** Translation with Babelfish ***** : > > > Good evening! > > I do exactly what you hope for: IE like frontal of a software in Python. > At the beginning, I use a file HTA, which is connected to Python with > Javascript: > var comlink = new ActiveXObject("Soft.Python"); > Between the objects of the interface, and the software Python, I have > establishes several tens of bonds COM. > The events are intercepted by Javascript, and transmitted to the Python > software. > Same manner, the activeX can be radio-controlled by Python. > >> From that, I went further. But that is difficult to explain with a simple > message... > > > > From mc at mclaveau.com Fri Jun 10 01:06:33 2005 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 10 Jun 2005 01:06:33 +0200 Subject: [python-win32] Interfacing to windows explorer References: <000401c56b9c$00629ca0$0701a8c0@PORTABLES> Message-ID: <000d01c56d47$e395d440$0701a8c0@PORTABLES> Hi ! If, by chance, you pass in Ardeche (*), France, I could show you interesting things. If not, I would have evil, by e-mail (my English is too bad). (*) See : http://www.marathon-ardeche.com/SiteMarathon/gorges_ardeche/gorges_htm/20001113_gorges_2.htm Michel Claveau __________________________________________________ Thanks for the suggestions. I am debating which of the feasible methods will be easier. The javascript code calling a COM object was quite easy to get working: var obj = ActiveXObject(aa.bb); However it doesn't work with mozilla (which I expected). When loaded as HTML it gives a warning every time. Even when you run it as HTA, it generates a warning on the first run, but not after. The HTA option looks neat for a windows application (thanks Michel). For deployment I guess you would go something like this: pack an HTA file with your python com server exe. Write a bat file that to runs the application you are writing so that it can register with the local registry. Then open explorer passing it the HTA file. The option of running a web server locally whenever this application is fired can be used in lieu of running a com server and using HTA. The reason why the web server option looks attractive is becuasebecause it has object publishing that comes for free, with something like Cherry Pie. Without this, I would have to write some messy html scripting code that will intercept actions on the HTML/HTA file and then return with other HTML/HTA pages etc. I guess the happy middle would be to find a object publishing framework that generates HTML but runs inside a python COM server. Is there any? If not I guess one can try change cherry py a little bit so it can act as a com server instead of a webserver. From bgailer at sbcglobal.net Thu Jun 9 19:14:38 2005 From: bgailer at sbcglobal.net (Bob Gailer) Date: Thu, 09 Jun 2005 10:14:38 -0700 Subject: [python-win32] COM access to Mozilla Firefox In-Reply-To: <1118288396.42a7ba0c4a13a@webmail.ldc.de> References: <1118288396.42a7ba0c4a13a@webmail.ldc.de> Message-ID: <6.1.2.0.0.20050609101121.034abf28@pop.sbcglobal.yahoo.com> What is the application name for Mozilla Firefox (to be used in win32com.client.Dispatch())? Where is documentation as to what properties/methods are available? Ditto on last question for Internet Explorer. Bob Gailer mailto:bgailer at alum.rpi.edu 510 558 3275 home 720 938 2625 cell -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050609/202ae25e/attachment.html From animesh at neolinuxsolutions.com Fri Jun 10 17:46:52 2005 From: animesh at neolinuxsolutions.com (Animesh Bansriyar) Date: 10 Jun 2005 21:16:52 +0530 Subject: [python-win32] NTService detecting if the Windows System is Idle Message-ID: <1118418450.2105.13.camel@laptop> Hi All, I don't have much knowledge about Windows Services but I have read about the Python Modules and seen the demo that comes with the py2exe package. I need to write an NTService which runs a process (an Executable) when the System (WinXP, Win2003) is Idle. Is it possible to do this from python. Could somebody send me some pointers or suggest ways to do this. Thanks in Advance, Animesh From chad.hughes at pnl.gov Fri Jun 10 18:21:22 2005 From: chad.hughes at pnl.gov (Hughes, Chad O) Date: Fri, 10 Jun 2005 09:21:22 -0700 Subject: [python-win32] NTService detecting if the Windows System is Idle Message-ID: <42C7E766869C42408F0360B7BF0CBD9B014B615A@pnlmse27.pnl.gov> Are you saying that you want to launch a program that waits until the CPU's idle time is at a given threshold and once the threshold is met the program does something until the threshold is no longer met after wich your app waits for the threshold again? -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Animesh Bansriyar Sent: Friday, June 10, 2005 8:47 AM To: python-win32 at python.org Subject: [python-win32] NTService detecting if the Windows System is Idle Hi All, I don't have much knowledge about Windows Services but I have read about the Python Modules and seen the demo that comes with the py2exe package. I need to write an NTService which runs a process (an Executable) when the System (WinXP, Win2003) is Idle. Is it possible to do this from python. Could somebody send me some pointers or suggest ways to do this. Thanks in Advance, Animesh _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From chad.hughes at pnl.gov Fri Jun 10 18:42:10 2005 From: chad.hughes at pnl.gov (Hughes, Chad O) Date: Fri, 10 Jun 2005 09:42:10 -0700 Subject: [python-win32] COM access to Mozilla Firefox Message-ID: <42C7E766869C42408F0360B7BF0CBD9B014B615C@pnlmse27.pnl.gov> In this example, I am using WScrip, so the available methods should be found by looking up WScript: from win32com.client import Dispatch from time import sleep s=Dispatch('WScript.Shell') s.Run('Explorer http://www.msn.com') or: from win32com.client import Dispatch from time import sleep s=Dispatch('WScript.Shell') s.Run('Mozilla http://www.msn.com') sleep(3) Chad -----Original Message----- From: python-win32-bounces+chad.hughes=pnl.gov at python.org [mailto:python-win32-bounces+chad.hughes=pnl.gov at python.org] On Behalf Of Bob Gailer Sent: Thursday, June 09, 2005 10:15 AM To: python-win32 at python.org Subject: [python-win32] COM access to Mozilla Firefox What is the application name for Mozilla Firefox (to be used in win32com.client.Dispatch())? Where is documentation as to what properties/methods are available? Ditto on last question for Internet Explorer. Bob Gailer mailto:bgailer at alum.rpi.edu 510 558 3275 home 720 938 2625 cell -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050610/d3bb53b3/attachment.html From degoor_python at dir.bg Fri Jun 10 19:13:00 2005 From: degoor_python at dir.bg (degoor_python@dir.bg) Date: Fri, 10 Jun 2005 20:13:00 +0300 Subject: [python-win32] How to overcome automatic cyrillic-to-/hex convert Message-ID: Hi friends, I am really sorry to bother you with such a simple stupid question but today it's my second day spent in searching manuals, mail-archives (I downloaded over 100MB from "python-list"), etc., and I could not find anything that can solve the matter. I am from Bulgaria and I use Python (+wxPython+Boa Constractor) as a front-end to database processing with Firebird. I use Python 2.4.1 over Windows 98 SE. My keyboard is set as default Bulgarian keyboard (keybg) so I can write in Bulgarian using win32 application as well in MS DOS prompt. Those should correspond to 'cp1251' (win32) and 'cp855' (DOS console) encodings. But when I enter some Bulgarian (actually cyrillic) text as a string, it seems that Python automatically converts it to '\x00..\x00 ' and once converted that way I can't get it back into its original look. The only way to get it right is using print : >>> a = '????' # 'Mam' in Bulgarian >>> print a '????' but >>> a '\xcc\xe0\xec\xe0' It is not such a great problem that the string enters or gets out of the database in that look as long as the user doesn't see it. But when it comes to data visualization I can't expect the user to know what '\xcc\xe0\xec\xe0' mean, neither can I use (at least as much as I know) 'print' for that job. To visualize data in the base I use table views created with wxGrid. In the grid instead of '????' I am getting '\xcc\xe0\xec\xe0'. To set the value of a particular cell in the grid I use wxGrid::SetCellValue : self.grid1.SetCellValue(row, column, string) In one of O'Reilly's Python books (Learning Python, chapter 8.3.2)there is a hint that it is possible to redirect the standard output to a user-defined object but it is not quite clear how that can be achived and if that is applicable in my case at all. Your help is of great need and would be truely appreciated! Thank you very much! degoor From chad.hughes at pnl.gov Fri Jun 10 22:32:43 2005 From: chad.hughes at pnl.gov (Hughes, Chad O) Date: Fri, 10 Jun 2005 13:32:43 -0700 Subject: [python-win32] NTService detecting if the Windows System is Idle Message-ID: <42C7E766869C42408F0360B7BF0CBD9B014B6167@pnlmse27.pnl.gov> I think this example is what you want to do. It is not a service, but you can turn it into one. import win32pdh from time import sleep import threading pdhQuery = win32pdh.OpenQuery(None, 0) class PDH_COUNTER_PATH_ELEMENTS(list): def __init__(self, l = None): if not l: l = ['127.0.0.1',None,None,None,-1,None] list.__init__(self,l) self.__machineName = self[0] self.__objectName = self[1] self.__instanceName = self[2] self.__parantInstance = self[3] self.__instanceIndex = self[4] self.__counterName = self[5] def __setMachineName(self,value): self.__machineName = value self[0] = value def __setObjectName(self,value): self.__objectName = value self[1] = value def __setInstanceName(self,value): self.__instanceName = value self[2] = value def __setParentInstance(self,value): self.__parentInstance = value self[3] = value def __setInstanceIndex(self,value): self.__instanceIndex = value self[4] = value def __setCounterName(self,value): self.__counterName = value self[5] = value def __getMachineName(self): return self.__machineName def __getObjectName(self): return self.__objectName def __getInstanceName(self): return self.__instanceName def __getParentInstance(self): return self.__parentInstance def __getInstanceIndex(self): return self.__instanceIndex def __getCounterName(self): return self.__counterName machineName = property(__getMachineName, __setMachineName) objectName = property(__getObjectName, __setObjectName) instanceName = property(__getInstanceName, __setInstanceName) instanceIndex = property(__getInstanceIndex, __setInstanceIndex) parentInstanceIndex = property(__getParentInstance, __setParentInstance) counterName = property(__getCounterName, __setCounterName) def makeCopy(self): return PDH_COUNTER_PATH_ELEMENTS(self) def __repr__(self): return 'machineName = %s\nobjectName = %s\nInstanceName = %s\nparentInstance = %s\ninstanceIndex = %s\ncounterName = %s'%tuple(self) class WorkerThread(threading.Thread): def __init__(self): threading.Thread.__init__(self, target = self.__runLoop) self.__pauseEvent = threading.Event() #when wait is called after clear the thread will pause until set self.__pauseEvent.clear() self.__stayAlive = True def stop(self): self.__stayAlive = False #loop until runLoop is exited while self.isAlive(): self.__pauseEvent.set() def pause(self): self.__pauseEvent.clear() def resume(self): self.__pauseEvent.set() def __runLoop(self): while self.__stayAlive: self.__pauseEvent.wait() #do what ever you want to do while the CPU is idle #example print that cpu is idle print 'The CPU is idle' #make paths cpe = PDH_COUNTER_PATH_ELEMENTS(( '127.0.0.1', "Processor", '_Total', None, -1, "% Idle Time" )) #you can replace _Total with a CPU id. #For example: replace it with 0 for the first CPU #Look up Perfmon for more details procPath = win32pdh.MakeCounterPath(cpe) procCounter = win32pdh.AddCounter(pdhQuery, procPath, 0) #For Windows to get a good statistic you must collect once first. #That way Windows can form a delta on the CPU usage. win32pdh.CollectQueryData(pdhQuery) sleep(.1) #Lets say that the CPU is idle if it has 60% or more idle time. threshold = 90 worker = WorkerThread() worker.start() while 1: #type CTRL-C to stop try: #Collect the percient idle time win32pdh.CollectQueryData(pdhQuery) format = win32pdh.PDH_FMT_LONG | win32pdh.PDH_FMT_NOSCALE idleTime = win32pdh.GetFormattedCounterValue(procCounter, format)[1] print idleTime if idleTime >= threshold: worker.resume() else: worker.pause() sleep(.1) except: print 'Stopping thread' worker.stop() worker.join() raise Chad -----Original Message----- From: Animesh Bansriyar [mailto:animesh at neolinuxsolutions.com] Sent: Friday, June 10, 2005 12:19 PM To: Hughes, Chad O Subject: RE: [python-win32] NTService detecting if the Windows System is Idle Chad, Thanks for the reply. What I mean here is something like say, "Google Desktop Search". The Indexer for Google Desktop Search doesn't run until the system is "IDLE". I am not too sure what the word IDLE means. On Fri, 2005-06-10 at 21:51, Hughes, Chad O wrote: > Are you saying that you want to launch a program that waits until the > CPU's idle time is at a given threshold and once the threshold is met > the program does something until the threshold is no longer met after > wich your app waits for the threshold again? > In my case the application uses both more memory and more CPU, hence if the application runs throughout, the systems become slow to use. So as you sugessted, we could have a threshold like say, the NTService runs when the System utilizes less than 5% of the RAM and 5% of CPU. Could you help in this regard. Does it make sense? Thanks in Advance, Animesh From gulilate09606 at itc.nl Mon Jun 13 12:34:37 2005 From: gulilate09606 at itc.nl (Habtamu Gulilate) Date: Mon, 13 Jun 2005 12:34:37 +0200 Subject: [python-win32] Openning the IDE from Windows Explorer Message-ID: <5B7E111ACDFCB04999891E46A2A6B15E010C1909@itcnt14.itc.nl> hello, I am student in ITC Netherlands in GIS i need to develope a model in land use suitablity by arcgis9 model builder and show that model in user interface created by python scripts. But i do not have an idea about how to create user interface by python.in rder to run in user interrface by users. so please if u have some examples how to create a user interface by using python send me. i thanks your coopartion thank you habtamu -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050613/fdc21e40/attachment.html From python at kareta.de Mon Jun 13 17:05:30 2005 From: python at kareta.de (=?ISO-8859-15?Q?J=FCrgen_Kareta?=) Date: Mon, 13 Jun 2005 17:05:30 +0200 Subject: [python-win32] pythons mapi support In-Reply-To: <00e301c56bb3$0674c0c0$010a0a0a@enfoldsystems.local> References: <00e301c56bb3$0674c0c0$010a0a0a@enfoldsystems.local> Message-ID: <42ADA0BA.7030204@kareta.de> Hello, the mapi api tells: The *IDistList* interface inherits from IMAPICONTAINER and includes the same methods as address book containers. PyIAddrBook contains 3 methods (ResolveName, Open Entry and CompareEntryIds) but PyIDistList has no methods. So I'm wondering if this is accidental lost, or is there a special reason for this difference. regards, J?rgen From chad.hughes at pnl.gov Mon Jun 13 18:19:30 2005 From: chad.hughes at pnl.gov (Hughes, Chad O) Date: Mon, 13 Jun 2005 09:19:30 -0700 Subject: [python-win32] NTService detecting if the Windows System is Idle Message-ID: <42C7E766869C42408F0360B7BF0CBD9B014B6170@pnlmse27.pnl.gov> -----Original Message----- From: python-list-bounces+chad.hughes=pnl.gov at python.org [mailto:python-list-bounces+chad.hughes=pnl.gov at python.org] On Behalf Of Hughes, Chad O Sent: Monday, June 13, 2005 9:11 AM To: python-list at python.org Subject: RE: [python-win32] NTService detecting if the Windows System is Idle -----Original Message----- From: Hughes, Chad O Sent: Monday, June 13, 2005 9:09 AM To: 'Fred Dixon' Subject: RE: [python-win32] NTService detecting if the Windows System is Idle There may be important processes running in the background (headless process with no user interaction) that need resources while the user may or may not be "using" the computer, possible when the user is logged out. I would use the system resource usage itself to define the idleness of your system. There are a great number of things that can be measured and you can even have general system measurements as well as process specific measurements. For example: lets say that you have your thresholds set to some logical value, and you have some process (call it processA) that is important. You can dynamically redefine your thresholds for when processA is running and then dynamically readjust them when it is not. Moreover, you can make your thresholds be a function of your general system usage combined with process specific usage. For example, you can dynamically adjust your thresholds based on linear functions of the usage of a list of processes and your system. This is a very flexible approach. My example is just a starting point. Do you fallow this? -----Original Message----- From: Fred Dixon [mailto:fred.dixon at gmail.com] Sent: Sunday, June 12, 2005 12:30 PM To: Hughes, Chad O Subject: Re: [python-win32] NTService detecting if the Windows System is Idle why not just run it when the screen saver is active On 6/10/05, Hughes, Chad O wrote: > I think this example is what you want to do. It is not a service, but > you can turn it into one. > > import win32pdh > from time import sleep > import threading > > pdhQuery = win32pdh.OpenQuery(None, 0) > > class PDH_COUNTER_PATH_ELEMENTS(list): > def __init__(self, l = None): > if not l: > l = ['127.0.0.1',None,None,None,-1,None] > list.__init__(self,l) > self.__machineName = self[0] > self.__objectName = self[1] > self.__instanceName = self[2] > self.__parantInstance = self[3] > self.__instanceIndex = self[4] > self.__counterName = self[5] > def __setMachineName(self,value): > self.__machineName = value > self[0] = value > def __setObjectName(self,value): > self.__objectName = value > self[1] = value > def __setInstanceName(self,value): > self.__instanceName = value > self[2] = value > def __setParentInstance(self,value): > self.__parentInstance = value > self[3] = value > def __setInstanceIndex(self,value): > self.__instanceIndex = value > self[4] = value > def __setCounterName(self,value): > self.__counterName = value > self[5] = value > def __getMachineName(self): > return self.__machineName > def __getObjectName(self): > return self.__objectName > def __getInstanceName(self): > return self.__instanceName > def __getParentInstance(self): > return self.__parentInstance > def __getInstanceIndex(self): > return self.__instanceIndex > def __getCounterName(self): > return self.__counterName > machineName = property(__getMachineName, __setMachineName) > objectName = property(__getObjectName, __setObjectName) > instanceName = property(__getInstanceName, __setInstanceName) > instanceIndex = property(__getInstanceIndex, __setInstanceIndex) > parentInstanceIndex = property(__getParentInstance, > __setParentInstance) > counterName = property(__getCounterName, __setCounterName) > def makeCopy(self): > return PDH_COUNTER_PATH_ELEMENTS(self) > def __repr__(self): > return 'machineName = %s\nobjectName = %s\nInstanceName = > %s\nparentInstance = %s\ninstanceIndex = %s\ncounterName = > %s'%tuple(self) > > class WorkerThread(threading.Thread): > def __init__(self): > threading.Thread.__init__(self, target = self.__runLoop) > self.__pauseEvent = threading.Event() > #when wait is called after clear the thread will pause until set > self.__pauseEvent.clear() > self.__stayAlive = True > def stop(self): > self.__stayAlive = False > #loop until runLoop is exited > while self.isAlive(): > self.__pauseEvent.set() > def pause(self): > self.__pauseEvent.clear() > def resume(self): > self.__pauseEvent.set() > def __runLoop(self): > while self.__stayAlive: > self.__pauseEvent.wait() > #do what ever you want to do while the CPU is idle > #example print that cpu is idle > print 'The CPU is idle' > > > #make paths > cpe = PDH_COUNTER_PATH_ELEMENTS(( > '127.0.0.1', > "Processor", > '_Total', > None, > -1, > "% Idle Time" > )) > #you can replace _Total with a CPU id. > #For example: replace it with 0 for the first CPU > #Look up Perfmon for more details > > procPath = win32pdh.MakeCounterPath(cpe) > procCounter = win32pdh.AddCounter(pdhQuery, procPath, 0) > > #For Windows to get a good statistic you must collect once first. > #That way Windows can form a delta on the CPU usage. > win32pdh.CollectQueryData(pdhQuery) > sleep(.1) > > #Lets say that the CPU is idle if it has 60% or more idle time. > threshold = 90 > > worker = WorkerThread() > worker.start() > while 1: > #type CTRL-C to stop > try: > #Collect the percient idle time > win32pdh.CollectQueryData(pdhQuery) > format = win32pdh.PDH_FMT_LONG | win32pdh.PDH_FMT_NOSCALE > idleTime = win32pdh.GetFormattedCounterValue(procCounter, format)[1] > print idleTime > if idleTime >= threshold: > worker.resume() > else: > worker.pause() > sleep(.1) > except: > print 'Stopping thread' > worker.stop() > worker.join() > raise > > > > Chad > > -----Original Message----- > From: Animesh Bansriyar [mailto:animesh at neolinuxsolutions.com] > Sent: Friday, June 10, 2005 12:19 PM > To: Hughes, Chad O > Subject: RE: [python-win32] NTService detecting if the Windows System > is Idle > > > > Chad, > > Thanks for the reply. What I mean here is something like say, "Google > Desktop Search". The Indexer for Google Desktop Search doesn't run > until the system is "IDLE". I am not too sure what the word IDLE > means. > > On Fri, 2005-06-10 at 21:51, Hughes, Chad O wrote: > > Are you saying that you want to launch a program that waits until > > the CPU's idle time is at a given threshold and once the threshold > > is met the program does something until the threshold is no longer > > met after wich your app waits for the threshold again? > > > > In my case the application uses both more memory and more CPU, hence > if the application runs throughout, the systems become slow to use. So > as you sugessted, we could have a threshold like say, the NTService > runs when the System utilizes less than 5% of the RAM and 5% of CPU. > Could you help in this regard. Does it make sense? > > Thanks in Advance, > Animesh > > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- contemplate yourself as surrounded by the conditions you wish to produce -- http://mail.python.org/mailman/listinfo/python-list From davidf at sjsoft.com Tue Jun 14 10:35:57 2005 From: davidf at sjsoft.com (David Fraser) Date: Tue, 14 Jun 2005 10:35:57 +0200 Subject: [python-win32] win32event.ReleaseMutex Message-ID: <42AE96ED.3010701@sjsoft.com> Hi I've been trying to test some locking code from http://rgruet.free.fr/ This expects win32event.ReleaseMutex to raise an error if the lock has not been acquired... However in my tests, win32event.ReleaseMutex always returns None, regardless of whether the lock had been acquired by the current process or not. If I use ctypes.windll.kernel32.ReleaseMutex then I get the expected return value from the function (0 if it had not been acquired, 1 if it had). Would it be possible to make win32event.ReleaseMutex do the same? This is with pywin32 version 204 on both Python 2.3.3 and Python 2.4 (As an aside; is it possible to determine the pywin32 version at all from within Python? I couldn't find a version attribute in any of the modules) Regards David From dcrespo at grupozoom.com Tue Jun 14 18:14:11 2005 From: dcrespo at grupozoom.com (Daniel Crespo) Date: Tue, 14 Jun 2005 12:14:11 -0400 Subject: [python-win32] adodb in py2exe Message-ID: Hi all... How can I put adodb (that in my case, uses psycopg for accessing postgres) in py2exe? Thanks :) From timr at probo.com Tue Jun 14 19:20:13 2005 From: timr at probo.com (Tim Roberts) Date: Tue, 14 Jun 2005 10:20:13 -0700 Subject: [python-win32] Openning the IDE from Windows Explorer In-Reply-To: References: Message-ID: <42AF11CD.8000903@probo.com> On Mon, 13 Jun 2005 12:34:37 +0200, "Habtamu Gulilate" > >I am student in ITC Netherlands in GIS i need to develope a model in >land use suitablity by arcgis9 model builder and show that model in user >interface created by python scripts. But i do not have an idea about how >to create user interface by python.in rder to run in user interrface by >users. so please if u have some examples how to create a user interface >by using python send me. > >i thanks your coopartion > One easy way to create a UI for a Python application is to make it a web application, and let Internet Explorer be your user interface. That way, you can even offer your application over the Internet. There are a couple of a simple web servers in the Python standard library, or you can use the CherryPy package, which also includes HTML templating. If you really need this to have a native user interface, there are several good options: wxPython, tkinter, and Qt are all possible. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From justin.mailinglists at gmail.com Wed Jun 15 12:43:28 2005 From: justin.mailinglists at gmail.com (Justin Ezequiel) Date: Wed, 15 Jun 2005 18:43:28 +0800 Subject: [python-win32] run external program but with timeout In-Reply-To: References: Message-ID: <3c671898050615034358ce1bfd@mail.gmail.com> Greetings, I want to run an executable but I need to be able to kill it if it has not completed after 5 or so minutes. Googling gets me signal.signal(signal.SIGALRM, handler) but I need to use this from Windows. I have Python 2.3.4 on WinXP Pro. Had a look at the Python for Windows Documentation and it seems that I can use the win32process module. I will have a go at this but if anybody has done this before and would be willing to share, please do. Thank you. From justin.mailinglists at gmail.com Wed Jun 15 12:49:17 2005 From: justin.mailinglists at gmail.com (Justin Ezequiel) Date: Wed, 15 Jun 2005 18:49:17 +0800 Subject: [python-win32] run external program but with timeout In-Reply-To: <3c671898050615034358ce1bfd@mail.gmail.com> References: <3c671898050615034358ce1bfd@mail.gmail.com> Message-ID: <3c67189805061503494f361b5a@mail.gmail.com> On 6/15/05, Justin Ezequiel wrote: > > I want to run an executable but I need to be able to kill it if > it has not completed after 5 or so minutes. > Forgive me. Just now found a Demos folder and a winprocess.py file that at first glance will be exactly what I need. From pjessop at gmail.com Wed Jun 15 14:55:50 2005 From: pjessop at gmail.com (Peter Jessop) Date: Wed, 15 Jun 2005 14:55:50 +0200 Subject: [python-win32] Excel automation Message-ID: Running python 2.4.1 with pywin32-204 (2.4) I am new to Python so this is probably an oversite on my part. We are evaluating Python with the idea of replacing VBScript for system administration. I have been impressed with the capabilities of Python and in general have found it easy to pick up. Encountered the following problem with Excel. >>> from win32com.client import Dispatch >>> objExcel = Dispatch("Excel.Application") >>> objExcel.Visible = 1 >>> objExcel.Workbooks.Add() >>> objExcel.ActiveCell.Value="XXXXXXXXXX" >>> objExcel.ActiveCell.Offset(1,0).Activate Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-00 0000000046x0x1x5.py", line 14615, in __call__ , ColumnIndex) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_( pywintypes.com_error: (-2147352567, 'Ocurri\xf3 una excepci\xf3n.', (0, None, No ne, None, 0, -2146827284), None) The problem occurs with both early and late binding. Regards Peter Jessop From tim.golden at viacom-outdoor.co.uk Wed Jun 15 15:05:44 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed, 15 Jun 2005 14:05:44 +0100 Subject: [python-win32] Excel automation Message-ID: <9A28C052FF32734DACB0A288A3533991EBB8DC@vogbs009.gb.vo.local> [Peter Jessop] | Running python 2.4.1 with pywin32-204 (2.4) | I am new to Python so this is probably an oversite on my part. | We are evaluating Python with the idea of replacing VBScript for | system administration. | I have been impressed with the capabilities of Python and in general | have found it easy to pick up. | Encountered the following problem with Excel. | [... snip error situation ...] | >>> objExcel.ActiveCell.Offset(1,0).Activate | Traceback (most recent call last): | File "", line 1, in ? | File | "C:\Python24\lib\site-packages\win32com\gen_py\00020813-0000-0 | 000-C000-00 | 0000000046x0x1x5.py", line 14615, in __call__ | , ColumnIndex) | File | "C:\Python24\Lib\site-packages\win32com\client\__init__.py", | line 446, in | _ApplyTypes_ | return self._get_good_object_( | pywintypes.com_error: (-2147352567, 'Ocurri\xf3 una | excepci\xf3n.', (0, None, No | ne, None, 0, -2146827284), None) | | The problem occurs with both early and late binding. Thanks for producing a reproducible situation, and the added info about early/late binding. All I've done is to reproduce at the interpreter, and then play around a bit, discovering that the problem lies in the offset values, which want to be 1-based and not zero-based. I don't know if this is a bug or a feature, or what, but if you do this (following on from your earlier code): c = objExcel.ActiveCell c01 = c.Offset (1, 0) you get an error, whereas c22 = c.Offset (2, 2) is ok, and c22.Value = 'XXX' performs as expected. I'm sure if you'd gone that little bit further with your test case, you'd have reached the same point pretty quickly. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From pjessop at gmail.com Wed Jun 15 15:15:16 2005 From: pjessop at gmail.com (Peter Jessop) Date: Wed, 15 Jun 2005 15:15:16 +0200 Subject: [python-win32] Excel automation Message-ID: Hi Tim Thanks for your quick response. I had determined that putting none zero values did not provoke the error, but did not realise the reason. However c.Offset (2, 2) should change the active cell (1 down and 1 right, if it is 1-based), but it doesn't Regards Peter From tim.golden at viacom-outdoor.co.uk Wed Jun 15 15:30:51 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed, 15 Jun 2005 14:30:51 +0100 Subject: [python-win32] Excel automation Message-ID: <9A28C052FF32734DACB0A288A3533991EBB8DD@vogbs009.gb.vo.local> [Peter Jessop] | Hi Tim | Thanks for your quick response. | I had determined that putting none zero values did not provoke the | error, but did not realise the reason. | However c.Offset (2, 2) should change the active cell (1 down and 1 | right, if it is 1-based), but it doesn't | | Regards | | Peter May be a misunderstanding on your part. According to MS: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/owcvba10/html/ocproOffset.asp and from my own experimentation, Offset doesn't affect which cell is active, but merely returns *another* cell, relative to the one you started with, which in your example is the Active cell. In other words, if you run this code, one line at a time, you will see A1 with "Active 1" in it, then B2 with "Active offset by (2,2)" in it, and then B2 (the *new* active cell) with "New active cell" in it. from win32com.client import Dispatch xl = Dispatch ("Excel.Application") xl.Visible = True xl.Workbooks.Add () active_cell = xl.ActiveCell active_cell.Value = 'Active 1' offset_cell = active_cell.Offset (2, 2) offset_cell.Value = 'Active offset by (2,2)' offset_cell.Activate () xl.ActiveCell.Value = 'New active cell' HTH TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From pjessop at gmail.com Wed Jun 15 16:47:14 2005 From: pjessop at gmail.com (Peter Jessop) Date: Wed, 15 Jun 2005 16:47:14 +0200 Subject: [python-win32] Excel automation Message-ID: Tim Thanks again for clearing that up. Now I get it! Regards Peter From Robert.Bielik at gyros.com Thu Jun 16 08:47:14 2005 From: Robert.Bielik at gyros.com (Bielik, Robert) Date: Thu, 16 Jun 2005 08:47:14 +0200 Subject: [python-win32] Pythonwin COM problem Message-ID: <4D1D834CF718FF43A04E60599A28453506BC2F@seuppms01.ad-gyrosmicro.com> I have a module where I use COM to communicate with some HW drivers. In my module I use CoInitializeEx to init COM in multithreaded mode. However, when I use PythonWin to debug/test my module, I get an error due to the fact that PythonWin has (implicitly) initialized COM in apartment threaded mode. Subsequently, my module crashes Python. How, when and where PythonWin initializes COM (apartment threaded) I don't know, but the fact is it does do that since even if I remove my modules CoInitializeEx, COM works up to the point where a different thread uses a marshalled COM interface (CRASH!) If I use my module via a .py script and run that directly, everything works fine! So, how do I make sure PythonWin (implictly) inits COM in multithreaded mode? TIA /Rob Ps. I've set the sys.coinit_flags (in localserver.py) to zero (value of COINIT_MULTITHREADED), recompiled it, but that didn't change anything... From hgulilat at yahoo.com Thu Jun 16 12:31:11 2005 From: hgulilat at yahoo.com (habtamu gulilat) Date: Thu, 16 Jun 2005 03:31:11 -0700 (PDT) Subject: [python-win32] (no subject) Message-ID: <20050616103111.41403.qmail@web52105.mail.yahoo.com> am habtamu from Netherlands I need to prepare userinterface for my Arc GIS model created by Modelbuilder. I want my userinterface to run my model. So would uyou please send me those syntax able me to create simple python based user interface to run my Model. If possible would you please send me some examples of userinterface by python. Thank you habtamu __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050616/26df1400/attachment.htm From Jim.Vickroy at noaa.gov Thu Jun 16 16:06:55 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu, 16 Jun 2005 08:06:55 -0600 Subject: [python-win32] (no subject) In-Reply-To: <20050616103111.41403.qmail@web52105.mail.yahoo.com> References: <20050616103111.41403.qmail@web52105.mail.yahoo.com> Message-ID: <42B1877F.8080009@noaa.gov> Assuming you have tkinter installed as part of your Python distribution, I have attached a demo (courtesy of Mark Hammond) that shows much of what is possible (e.g., menus, buttons, etc.). Hope this helps. -- jv habtamu gulilat wrote: > am habtamu from Netherlands > > I need to prepare userinterface for my Arc GIS model created by > Modelbuilder. I want my userinterface to run my model. So would uyou > please send me those syntax able me to create simple python based user > interface to run my Model. > > If possible would you please send me some examples of userinterface by > python. > > Thank you > > habtamu > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > >------------------------------------------------------------------------ > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: tkDemo.py Url: http://mail.python.org/pipermail/python-win32/attachments/20050616/e659c112/tkDemo.diff From arthur_hu at huawei.com Fri Jun 17 11:17:49 2005 From: arthur_hu at huawei.com (arthur) Date: Fri, 17 Jun 2005 17:17:49 +0800 Subject: [python-win32] Can not import win32ui module the second time! Message-ID: <000a01c5731d$6e9017b0$7a0e4e0a@china.huawei.com> Hello everyone, I embed python 2.4 in MFC application, and call PyRun_SimpleString function to import win32ui module, but it fails after undergoing a python initialize and cleanup process. The error info is : "System Error: dynamic module not initialized properly".If anyone know the reason,please tell me,thanks. The following is the code section: void Test() { Py_Initialize(); PyRun_SimpleString("import win32ui"); Py_Finalize(); Py_Initialize(); PyRun_SimpleString("import win32ui"); Py_Finalize(); } The first call to PyRun_SimpleString will success,but the second will fail. Arthur -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050617/d69cd0cc/attachment.htm From dave at excelsiorsystems.co.uk Fri Jun 17 19:53:00 2005 From: dave at excelsiorsystems.co.uk (Dave Nation) Date: Fri, 17 Jun 2005 18:53:00 +0100 Subject: [python-win32] Problem using MSComm Message-ID: <42B30DFC.6090300@excelsiorsystems.co.uk> Hello, I hope you can help me. I have a need to use the Microsoft MSComm control, and have written a program to do and it works fine on my PC. However, when I run this program on my target system it fails 'Class not Licensed for Use' when I try to Dispatch('MSCOMMLib.MSComm'). On my PC I have Visual Basic installed and so have access to the OCX. I've packaged a simple VB program that uses this control, and installed it on the target machine. The VB program works fine. Any thoughts you may have on how I can get the program to work on my target machine would be much appreciated. Thanks Dave From mc at mclaveau.com Fri Jun 17 20:49:05 2005 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 17 Jun 2005 20:49:05 +0200 Subject: [python-win32] Problem using MSComm References: <42B30DFC.6090300@excelsiorsystems.co.uk> Message-ID: <000401c5736d$3df8eb40$0701a8c0@PORTABLES> Hi ! I had the same problem. After search : MSComm is not a free componant. You must have a complete licence of VB ou VC++, and use the MS-install procedure. Perhaps, you can use Pyserial, or another Python-library ? @-salutations -- Michel Claveau From mhammond at skippinet.com.au Sat Jun 18 08:27:23 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 18 Jun 2005 16:27:23 +1000 Subject: [python-win32] Can not import win32ui module the second time! In-Reply-To: <000a01c5731d$6e9017b0$7a0e4e0a@china.huawei.com> Message-ID: <04dc01c573ce$ca77c030$010a0a0a@enfoldsystems.local> In general, finalizing and re-initializing Python has a number of issues - these functions were not designed to be called that way. (Please try and send plain-text mails to this list (for some reason my mailer refuses to even switch my reply back to plain-text)) Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of arthur Sent: Friday, 17 June 2005 7:18 PM To: python-win32 at python.org Subject: [python-win32] Can not import win32ui module the second time! Hello everyone, I embed python 2.4 in MFC application, and call PyRun_SimpleString function to import win32ui module, but it fails after undergoing a python initialize and cleanup process. The error info is : "System Error: dynamic module not initialized properly".If anyone know the reason,please tell me,thanks. The following is the code section: void Test() { Py_Initialize(); PyRun_SimpleString("import win32ui"); Py_Finalize(); Py_Initialize(); PyRun_SimpleString("import win32ui"); Py_Finalize(); } The first call to PyRun_SimpleString will success,but the second will fail. Arthur -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050618/be5d0ef1/attachment.htm From kimwaic888-pythonwin32 at yahoo.com Sat Jun 18 20:09:32 2005 From: kimwaic888-pythonwin32 at yahoo.com (kimwaic888-pythonwin32@yahoo.com) Date: Sat, 18 Jun 2005 11:09:32 -0700 (PDT) Subject: [python-win32] Word AddPicture problem Message-ID: <20050618180932.34224.qmail@web51402.mail.yahoo.com> I am trying to insert a bunch of picture files into a newly created Word document. I am encountering trouble setting the Height and Width of the inserted picture. The code is really very simple: ### ...set up list_of_doc_files_to_create wordApp = Dispatch("Word.Application") for y in list_of_doc_files_to_create: wordDoc=wordApp.Documents.Add(y) wordRange=wordDoc.Range(0,0).Select() ...set up files_to_insert... for x in files_to_insert: sel=wordApp.Selection.InlineShapes.AddPicture(x) per = 25 sel.Height = int(per*7.481) sel.Width = int(per*5.544) wordDoc.SaveAs(y) wordDoc.Close() ### The problems are: 1) The code works for some of the doc files created but not others (like half and half). The doc file gets creaetd fine but the inserted pictures in some of the files are not scaled. 2) I actually tried to set ScaleHeight but sel.ScaleHeight didn't work. That's why I am using the clumpsy way above. Any ideas? Does anybody have more detailed sample code for dealing with AddPicture? There are lots of code samples for inserting other things but I haven't found anything on AddPicture yet. Thanks, -- John From jbrunen at datasolid.de Mon Jun 20 16:30:55 2005 From: jbrunen at datasolid.de (Johannes Brunen) Date: Mon, 20 Jun 2005 16:30:55 +0200 Subject: [python-win32] Newbee problem on dispatch interface Message-ID: <23D83A07C60A0E47AD964F74DA96940104BD2C@mail.datasolid.de> Hi, I have a problem connecting to a COM server with a small test script using python 2.3.5 as well as 2.4.1: import win32com.client from win32com.client import gencache def main(): g1 = gencache.EnsureModule('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 3) theCADdy = win32com.client.Dispatch('CADdy.CADdy') print repr(theCADdy) # => theCADdy = g1.ICADdy(theCADdy) # => print repr(theCADdy) v1 = theCADdy.VersionNo if __name__ == '__main__': main() I got the following error message: C:\Programme\Python\lib\site-packages\win32com\client\__init__.py in __getattr__(self, attr) 453 if args is None: 454 raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) --> 455 return self._ApplyTypes_(*args) 456 457 def __setattr__(self, attr, value): C:\Programme\Python\lib\site-packages\win32com\client\__init__.py in _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args) 444 def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, 445 resultCLSID, *args): --> 446 return self._get_good_object_( 447 self._oleobj_.InvokeTypes( 448 dispid, 0, wFlags, retType, argTypes, *arg s), com_error: (-2147319779, 'Bibliothek nicht registriert.', None, None) WARNING: Failure executing file: I have no idea what is going wrong with my test program. Connecting to MS Excel is no problem. Can someone tell me how do I correctly use the pythonCOM module. I have no problem connecting the CADdy COM server from VB and C++. Is there anything wrong inside my COM type libraries? With best regards Johannes The following is the information about the type library provided by the OLE viewer: // Generated .IDL file (by the OLE/COM Object Viewer) // // typelib filename: CADdy.tlb [ uuid(9C3BB401-114D-11D4-AC72-00105A4925FC), version(1.3), helpstring("CADdyCOM 1.3 (CADdy) Type Library") ] library CADDYLib { // TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046} importlib("stdole2.tlb"); // Forward declare all types defined in this typelib interface ICADdyAddIn; interface ICADdy; interface IEnumCADdyAddIn; interface ICADdyAddIns; interface ISupportErrorInfo; typedef enum { ADDIN_E_ERRONEOUSADDIN = -2147220992, ADDIN_E_ALREADYSTARTED = -2147220991, ADDIN_E_INAPPROPRIATESERVER = -2147220990, ADDIN_E_CANTCREATESERVER = -2147220989 } ADDINHRESULTS; [ odl, uuid(14F65AE1-4671-11D4-8B1A-00105A49278B), helpstring("ICADdyAddIn Interface"), dual, oleautomation ] interface ICADdyAddIn : IDispatch { [id(0x00000001), helpstring("method Init")] HRESULT Init([in] ICADdy* theCADdy); [id(0x00000002), helpstring("method Exit")] HRESULT Exit(); [id(0x00000003), propget, helpstring("property CLSID")] HRESULT CLSID([out, retval] BSTR* pcCLSID); [id(0x00000004), propget, helpstring("property ProgID")] HRESULT ProgId([out, retval] BSTR* pcProgId); [id(0x00000005), propget, helpstring("property Description")] HRESULT Description([out, retval] BSTR* pcDescription); }; [ odl, uuid(D330F3E0-0F91-11D4-AC6E-00105A4925FC), helpstring("ICADdy Interface"), dual, oleautomation ] interface ICADdy : IDispatch { [id(0x00000001), propget, helpstring("property FrameManager")] HRESULT FrameManager([out, retval] IDispatch** ppICADdyFrameManager); [id(0x00000002), propget, helpstring("property ModelManager")] HRESULT ModelManager([out, retval] IDispatch** ppICADdyModelManager); [id(0x00000003), propget, helpstring("property UIManager")] HRESULT UIManager([out, retval] IDispatch** ppICADdyUIManager); [id(0x00000004), propget, helpstring("property Manager")] HRESULT Manager( [in] BSTR __MIDL_0025, [out, retval] IDispatch** ppICADdyDimensionManager); [id(0x00000005), propget, helpstring("property ExeDirectory")] HRESULT ExeDirectory([out, retval] BSTR* pbstrDirectory); [id(0x00000006), propget, helpstring("property HomeDirectory")] HRESULT HomeDirectory([out, retval] BSTR* pbstrDirectory); [id(0x00000007), propget, helpstring("property Name")] HRESULT Name([out, retval] BSTR* pbstrName); [id(0x00000008), propget, helpstring("property VersionNo")] HRESULT VersionNo([out, retval] long* lVersion); [id(0x00000009), propget, helpstring("property ReleaseNo")] HRESULT ReleaseNo([out, retval] long* lRelease); }; [ odl, uuid(14F65AE3-4671-11D4-8B1A-00105A49278B), helpstring("IEnumCADdyAddIn Interface"), oleautomation ] interface IEnumCADdyAddIn : IUnknown { [helpstring("Next")] HRESULT _stdcall Next( [in] unsigned long i4Count, [out] ICADdyAddIn** __MIDL_0015, [out] unsigned long* pi4Fetched); [helpstring("Skip")] HRESULT _stdcall Skip([in] unsigned long __MIDL_0016); [helpstring("Reset")] HRESULT _stdcall Reset(); [helpstring("Clone")] HRESULT _stdcall Clone([out] IEnumCADdyAddIn** __MIDL_0017); }; [ odl, uuid(14F65AE2-4671-11D4-8B1A-00105A49278B), helpstring("ICADdyAddIns Interface"), dual, nonextensible, oleautomation ] interface ICADdyAddIns : IDispatch { [id(00000000), propget, helpstring("Item")] HRESULT Item( [in] long __MIDL_0018, [out, retval] ICADdyAddIn** __MIDL_0019); [id(0xfffffffc), propget, restricted, helpstring("_NewEnum")] HRESULT _NewEnum([out, retval] IUnknown** __MIDL_0020); [id(0x00000001), propget, helpstring("property Count")] HRESULT Count([out, retval] long* __MIDL_0021); [id(0x00000002), helpstring("Start")] HRESULT Start( [in] BSTR __MIDL_0022, [out, retval] ICADdyAddIn** __MIDL_0023); [id(0x00000003), helpstring("Stop")] HRESULT Stop([in] ICADdyAddIn* __MIDL_0024); [id(0x00000004), helpstring("StopAll")] HRESULT StopAll(); }; [ uuid(D330F3E1-0F91-11D4-AC6E-00105A4925FC), helpstring("CADdy Class"), noncreatable ] coclass CoCADdy { [default] interface ICADdy; interface ISupportErrorInfo; }; [ odl, uuid(DF0B3D60-548F-101B-8E65-08002B2BD119) ] interface ISupportErrorInfo : IUnknown { HRESULT _stdcall InterfaceSupportsErrorInfo([in] GUID* riid); }; [ uuid(3F5B2591-4768-11D4-8B1C-00105A49278B), helpstring("CADdyAddIn Collection") ] coclass CADdyAddIns { [default] interface ICADdyAddIns; interface ISupportErrorInfo; }; }; And the python file generated by g1 = gencache.EnsureModule('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 3) # -*- coding: mbcs -*- # Created by makepy.py version 0.4.91 # By python version 2.3.5 (#62, Mar 22 2005, 21:53:13) [MSC v.1200 32 bit (Intel)] # From type library '{9C3BB401-114D-11D4-AC72-00105A4925FC}' # On Mon Jun 20 16:06:02 2005 """CADdyCOM 1.3 (CADdy) Type Library""" makepy_version = '0.4.91' python_version = 0x20305f0 import win32com.client.CLSIDToClass, pythoncom import win32com.client.util from pywintypes import IID from win32com.client import Dispatch # The following 3 lines may need tweaking for the particular server # Candidates are pythoncom.Missing and pythoncom.Empty defaultNamedOptArg=pythoncom.Empty defaultNamedNotOptArg=pythoncom.Empty defaultUnnamedArg=pythoncom.Empty CLSID = IID('{9C3BB401-114D-11D4-AC72-00105A4925FC}') MajorVersion = 1 MinorVersion = 3 LibraryFlags = 8 LCID = 0x0 class constants: ADDIN_E_ALREADYSTARTED =-2147220991 # from enum ADDINHRESULTS ADDIN_E_CANTCREATESERVER =-2147220989 # from enum ADDINHRESULTS ADDIN_E_ERRONEOUSADDIN =-2147220992 # from enum ADDINHRESULTS ADDIN_E_INAPPROPRIATESERVER =-2147220990 # from enum ADDINHRESULTS from win32com.client import DispatchBaseClass class ICADdy(DispatchBaseClass): """ICADdy Interface""" CLSID = IID('{D330F3E0-0F91-11D4-AC6E-00105A4925FC}') coclass_clsid = IID('{D330F3E1-0F91-11D4-AC6E-00105A4925FC}') # The method Manager is actually a property, but must be used as a method to correctly pass the arguments def Manager(self, _MIDL_0025_=defaultNamedNotOptArg): """property Manager""" ret = self._oleobj_.InvokeTypes(4, LCID, 2, (9, 0), ((8, 1),),_MIDL_0025_) if ret is not None: ret = Dispatch(ret, 'Manager', None, UnicodeToString=0) return ret _prop_map_get_ = { "ExeDirectory": (5, 2, (8, 0), (), "ExeDirectory", None), "FrameManager": (1, 2, (9, 0), (), "FrameManager", None), "HomeDirectory": (6, 2, (8, 0), (), "HomeDirectory", None), "ModelManager": (2, 2, (9, 0), (), "ModelManager", None), "Name": (7, 2, (8, 0), (), "Name", None), "ReleaseNo": (9, 2, (3, 0), (), "ReleaseNo", None), "UIManager": (3, 2, (9, 0), (), "UIManager", None), "VersionNo": (8, 2, (3, 0), (), "VersionNo", None), } _prop_map_put_ = { } class ICADdyAddIn(DispatchBaseClass): """ICADdyAddIn Interface""" CLSID = IID('{14F65AE1-4671-11D4-8B1A-00105A49278B}') coclass_clsid = None def Exit(self): """method Exit""" return self._oleobj_.InvokeTypes(2, LCID, 1, (24, 0), (),) def Init(self, theCADdy=defaultNamedNotOptArg): """method Init""" return self._oleobj_.InvokeTypes(1, LCID, 1, (24, 0), ((9, 1),),theCADdy) _prop_map_get_ = { "CLSID": (3, 2, (8, 0), (), "CLSID", None), "Description": (5, 2, (8, 0), (), "Description", None), "ProgId": (4, 2, (8, 0), (), "ProgId", None), } _prop_map_put_ = { } class ICADdyAddIns(DispatchBaseClass): """ICADdyAddIns Interface""" CLSID = IID('{14F65AE2-4671-11D4-8B1A-00105A49278B}') coclass_clsid = IID('{3F5B2591-4768-11D4-8B1C-00105A49278B}') # Result is of type ICADdyAddIn # The method Item is actually a property, but must be used as a method to correctly pass the arguments def Item(self, _MIDL_0018_=defaultNamedNotOptArg): """Item""" ret = self._oleobj_.InvokeTypes(0, LCID, 2, (9, 0), ((3, 1),),_MIDL_0018_) if ret is not None: ret = Dispatch(ret, 'Item', '{14F65AE1-4671-11D4-8B1A-00105A49278B}', UnicodeToString=0) return ret # Result is of type ICADdyAddIn def Start(self, _MIDL_0022_=defaultNamedNotOptArg): """Start""" ret = self._oleobj_.InvokeTypes(2, LCID, 1, (9, 0), ((8, 1),),_MIDL_0022_) if ret is not None: ret = Dispatch(ret, 'Start', '{14F65AE1-4671-11D4-8B1A-00105A49278B}', UnicodeToString=0) return ret def Stop(self, _MIDL_0024_=defaultNamedNotOptArg): """Stop""" return self._oleobj_.InvokeTypes(3, LCID, 1, (24, 0), ((9, 1),),_MIDL_0024_) def StopAll(self): """StopAll""" return self._oleobj_.InvokeTypes(4, LCID, 1, (24, 0), (),) _prop_map_get_ = { "Count": (1, 2, (3, 0), (), "Count", None), } _prop_map_put_ = { } # Default method for this class is 'Item' def __call__(self, _MIDL_0018_=defaultNamedNotOptArg): """Item""" ret = self._oleobj_.InvokeTypes(0, LCID, 2, (9, 0), ((3, 1),),_MIDL_0018_) if ret is not None: ret = Dispatch(ret, '__call__', '{14F65AE1-4671-11D4-8B1A-00105A49278B}', UnicodeToString=0) return ret # str(ob) and int(ob) will use __call__ def __unicode__(self, *args): try: return unicode(self.__call__(*args)) except pythoncom.com_error: return repr(self) def __str__(self, *args): return str(self.__unicode__(*args)) def __int__(self, *args): return int(self.__call__(*args)) def __iter__(self): "Return a Python iterator for this object" ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),'{14F65AE1-4671-11D4-8B1A-00105A49278B}') def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) #This class has Count() property - allow len(ob) to provide this def __len__(self): return self._ApplyTypes_(*(1, 2, (3, 0), (), "Count", None)) #This class has a __len__ - this is needed so 'if object:' always returns TRUE. def __nonzero__(self): return True from win32com.client import CoClassBaseClass # This CoClass is known by the name 'AddIns.CADdyAddIns.1' class CADdyAddIns(CoClassBaseClass): # A CoClass # CADdyAddIn Collection CLSID = IID('{3F5B2591-4768-11D4-8B1C-00105A49278B}') coclass_sources = [ ] coclass_interfaces = [ ICADdyAddIns, ] default_interface = ICADdyAddIns # This CoClass is known by the name 'CADdy.CADdy.1' class CoCADdy(CoClassBaseClass): # A CoClass # CADdy Class CLSID = IID('{D330F3E1-0F91-11D4-AC6E-00105A4925FC}') coclass_sources = [ ] coclass_interfaces = [ ICADdy, ] default_interface = ICADdy ICADdy_vtables_dispatch_ = 1 ICADdy_vtables_ = [ (('FrameManager', 'ppICADdyFrameManager'), 1, (1, (), [(16393, 10, None, None)], 1, 2, 4, 0, 28, (3, 0, None, None), 0)), (('ModelManager', 'ppICADdyModelManager'), 2, (2, (), [(16393, 10, None, None)], 1, 2, 4, 0, 32, (3, 0, None, None), 0)), (('UIManager', 'ppICADdyUIManager'), 3, (3, (), [(16393, 10, None, None)], 1, 2, 4, 0, 36, (3, 0, None, None), 0)), (('Manager', '__MIDL_0025', 'ppICADdyDimensionManager'), 4, (4, (), [(8, 1, None, None), (16393, 10, None, None)], 1, 2, 4, 0, 40, (3, 0, None, None), 0)), (('ExeDirectory', 'pbstrDirectory'), 5, (5, (), [(16392, 10, None, None)], 1, 2, 4, 0, 44, (3, 0, None, None), 0)), (('HomeDirectory', 'pbstrDirectory'), 6, (6, (), [(16392, 10, None, None)], 1, 2, 4, 0, 48, (3, 0, None, None), 0)), (('Name', 'pbstrName'), 7, (7, (), [(16392, 10, None, None)], 1, 2, 4, 0, 52, (3, 0, None, None), 0)), (('VersionNo', 'lVersion'), 8, (8, (), [(16387, 10, None, None)], 1, 2, 4, 0, 56, (3, 0, None, None), 0)), (('ReleaseNo', 'lRelease'), 9, (9, (), [(16387, 10, None, None)], 1, 2, 4, 0, 60, (3, 0, None, None), 0)), ] ICADdyAddIn_vtables_dispatch_ = 1 ICADdyAddIn_vtables_ = [ (('Init', 'theCADdy'), 1, (1, (), [(9, 1, None, "IID('{D330F3E0-0F91-11D4-AC6E-00105A4925FC}')")], 1, 1, 4, 0, 28, (3, 0, None, None), 0)), (('Exit',), 2, (2, (), [], 1, 1, 4, 0, 32, (3, 0, None, None), 0)), (('CLSID', 'pcCLSID'), 3, (3, (), [(16392, 10, None, None)], 1, 2, 4, 0, 36, (3, 0, None, None), 0)), (('ProgId', 'pcProgId'), 4, (4, (), [(16392, 10, None, None)], 1, 2, 4, 0, 40, (3, 0, None, None), 0)), (('Description', 'pcDescription'), 5, (5, (), [(16392, 10, None, None)], 1, 2, 4, 0, 44, (3, 0, None, None), 0)), ] ICADdyAddIns_vtables_dispatch_ = 1 ICADdyAddIns_vtables_ = [ (('Item', '__MIDL_0018', '__MIDL_0019'), 0, (0, (), [(3, 1, None, None), (16393, 10, None, "IID('{14F65AE1-4671-11D4-8B1A-00105A49278B}')")], 1, 2, 4, 0, 28, (3, 0, None, None), 0)), (('_NewEnum', '__MIDL_0020'), -4, (-4, (), [(16397, 10, None, None)], 1, 2, 4, 0, 32, (3, 0, None, None), 1)), (('Count', '__MIDL_0021'), 1, (1, (), [(16387, 10, None, None)], 1, 2, 4, 0, 36, (3, 0, None, None), 0)), (('Start', '__MIDL_0022', '__MIDL_0023'), 2, (2, (), [(8, 1, None, None), (16393, 10, None, "IID('{14F65AE1-4671-11D4-8B1A-00105A49278B}')")], 1, 1, 4, 0, 40, (3, 0, None, None), 0)), (('Stop', '__MIDL_0024'), 3, (3, (), [(9, 1, None, "IID('{14F65AE1-4671-11D4-8B1A-00105A49278B}')")], 1, 1, 4, 0, 44, (3, 0, None, None), 0)), (('StopAll',), 4, (4, (), [], 1, 1, 4, 0, 48, (3, 0, None, None), 0)), ] IEnumCADdyAddIn_vtables_dispatch_ = 0 IEnumCADdyAddIn_vtables_ = [ (('Next', 'i4Count', '__MIDL_0015', 'pi4Fetched'), 1, (1, (), [(19, 1, None, None), (16393, 2, None, "IID('{14F65AE1-4671-11D4-8B1A-00105A49278B}')"), (16403, 2, None, None)], 1, 1, 4, 0, 12, (3, 0, None, None), 0)), (('Skip', '__MIDL_0016'), 2, (2, (), [(19, 1, None, None)], 1, 1, 4, 0, 16, (3, 0, None, None), 0)), (('Reset',), 3, (3, (), [], 1, 1, 4, 0, 20, (3, 0, None, None), 0)), (('Clone', '__MIDL_0017'), 4, (4, (), [(16397, 2, None, "IID('{14F65AE3-4671-11D4-8B1A-00105A49278B}')")], 1, 1, 4, 0, 24, (3, 0, None, None), 0)), ] ISupportErrorInfo_vtables_dispatch_ = 0 ISupportErrorInfo_vtables_ = [ (('InterfaceSupportsErrorInfo', 'riid'), 1610678272, (1610678272, (), [(36, 1, None, None)], 1, 1, 4, 0, 12, (3, 0, None, None), 0)), ] RecordMap = { } CLSIDToClassMap = { '{14F65AE1-4671-11D4-8B1A-00105A49278B}' : ICADdyAddIn, '{D330F3E1-0F91-11D4-AC6E-00105A4925FC}' : CoCADdy, '{D330F3E0-0F91-11D4-AC6E-00105A4925FC}' : ICADdy, '{14F65AE2-4671-11D4-8B1A-00105A49278B}' : ICADdyAddIns, '{3F5B2591-4768-11D4-8B1C-00105A49278B}' : CADdyAddIns, } CLSIDToPackageMap = {} win32com.client.CLSIDToClass.RegisterCLSIDsFromDict( CLSIDToClassMap ) VTablesToPackageMap = {} VTablesToClassMap = { '{14F65AE2-4671-11D4-8B1A-00105A49278B}' : 'ICADdyAddIns', '{14F65AE3-4671-11D4-8B1A-00105A49278B}' : 'IEnumCADdyAddIn', '{D330F3E0-0F91-11D4-AC6E-00105A4925FC}' : 'ICADdy', '{DF0B3D60-548F-101B-8E65-08002B2BD119}' : 'ISupportErrorInfo', '{14F65AE1-4671-11D4-8B1A-00105A49278B}' : 'ICADdyAddIn', } NamesToIIDMap = { 'ICADdyAddIn' : '{14F65AE1-4671-11D4-8B1A-00105A49278B}', 'ICADdy' : '{D330F3E0-0F91-11D4-AC6E-00105A4925FC}', 'ISupportErrorInfo' : '{DF0B3D60-548F-101B-8E65-08002B2BD119}', 'IEnumCADdyAddIn' : '{14F65AE3-4671-11D4-8B1A-00105A49278B}', 'ICADdyAddIns' : '{14F65AE2-4671-11D4-8B1A-00105A49278B}', } win32com.client.constants.__dicts__.append(constants.__dict__) ____________ Virus checked by G DATA AntiVirusKit From chad.hughes at pnl.gov Tue Jun 21 00:23:40 2005 From: chad.hughes at pnl.gov (Hughes, Chad O) Date: Mon, 20 Jun 2005 15:23:40 -0700 Subject: [python-win32] Office constants Message-ID: <42C7E766869C42408F0360B7BF0CBD9B014B61A3@pnlmse27.pnl.gov> Is there a module that contains all of the constants for office (for example: xlRight, olOpen, and wdMAPI) in the pywin32 Windows extensions? I have created my own modules for these constants but I would rather use the pywin32 extensions if possible. Thanks, Chad -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050620/d0c7f7c3/attachment.htm From gijs at globaltrack.com Tue Jun 21 09:21:17 2005 From: gijs at globaltrack.com (Gijs Korremans) Date: Tue, 21 Jun 2005 09:21:17 +0200 Subject: [python-win32] The VARIANT type is not supported for SAFEARRAYS Message-ID: <200506210724.j5L7O3d5013027@rrba-146-71-179.telkomadsl.co.za> Hi, From a COM object (written in c++) I receive a struct: unsigned shord (2 bytes) BYTE (6 bytes) BYTE (512 bytes) I can use the first two in python, but when I try to acces the last on with python( i.e. test = struct.longbyte), Python stops doing anything and when I debug the code in boa constructor i get the message "The debugger process stopped prematurely." I asked the guy who made the COM object to change the last varibale of the struc to a string, but now the message shown is " The VARIANT type is not supported for SAFEARRAYS" Does anyone knows what's wrong? Kind regards, Gijs -- This message has been scanned for viruses and dangerous content by Network Sentry, and is believed to be clean. http://www.networksentry.co.za From simon.brunning at gmail.com Tue Jun 21 12:05:45 2005 From: simon.brunning at gmail.com (Simon Brunning) Date: Tue, 21 Jun 2005 11:05:45 +0100 Subject: [python-win32] Office constants In-Reply-To: <42C7E766869C42408F0360B7BF0CBD9B014B61A3@pnlmse27.pnl.gov> References: <42C7E766869C42408F0360B7BF0CBD9B014B61A3@pnlmse27.pnl.gov> Message-ID: <8c7f10c605062103053f8ffc83@mail.gmail.com> On 6/20/05, Hughes, Chad O wrote: > > > Is there a module that contains all of the constants for office (for > example: xlRight, olOpen, and wdMAPI) in the pywin32 Windows extensions? I > have created my own modules for these constants but I would rather use the > pywin32 extensions if possible. >>> import win32com.client >>> excel = win32com.client.gencache.EnsureDispatch("Excel.Application") >>> win32com.client.constants.xlRight -4152 -- Cheers, Simon B, simon at brunningonline.net, http://www.brunningonline.net/simon/blog/ From Tom_RobbinsMilne at swissre.com Mon Jun 20 23:47:29 2005 From: Tom_RobbinsMilne at swissre.com (Tom_RobbinsMilne@swissre.com) Date: Mon, 20 Jun 2005 17:47:29 -0400 Subject: [python-win32] Forcing win32com.client.dispatch to start up a fresh Excel Message-ID: Hi, I'm trying to use Python's win32com interface to drive an excel spreadsheet. I've managed to have it open the sheet, call a VBA function with arguments, and close it down cleanly. However, if Excel is already running, it closes the open instance. Which is not good. Is there a way I can do the equivalent of VBA's CreateObject() with win32com? I have purchased "Python Programming on Win32", and can't find anything. Soon I'll be reduced to running a short Perl script to do it, where I'd have Python kick off the Perl to get the job done, but I'd like to avoid that if possible. Thanks very much in advance. Regards, Tom This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050620/7a122a62/attachment.htm From tim.golden at viacom-outdoor.co.uk Tue Jun 21 17:52:32 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue, 21 Jun 2005 16:52:32 +0100 Subject: [python-win32] Forcing win32com.client.dispatch to start up a freshExcel Message-ID: <9A28C052FF32734DACB0A288A3533991EBB91B@vogbs009.gb.vo.local> [Tom_RobbinsMilne at swissre.com] | I'm trying to use Python's win32com interface to drive an excel spreadsheet. | I've managed to have it open the sheet, call a VBA function with arguments, and close it down cleanly. | However, if Excel is already running, it closes the open instance. Which is not good. | Is there a way I can do the equivalent of VBA's CreateObject() with win32com? I have purchased | "Python Programming on | Win32", and can't find anything. I'm not sure about the CreateObject bit, not being a VBA person, but I suspect you may want to use the DispatchEx method rather than simply Dispatch. eg, [some spreadsheet already open] import win32com.client xl = win32com.client.DispatchEx ("Excel.Application") wb = xl.Workbooks.Add () ws = xl.ActiveSheet ws.Cells (1, 1).Value = "Hello" wb.SaveAs ("c:/temp/temp.xls") wb.Close () xl.Quit () xl = None [original spreadsheet still open] TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From Benjamin.Schollnick at xerox.com Tue Jun 21 18:02:43 2005 From: Benjamin.Schollnick at xerox.com (Schollnick, Benjamin) Date: Tue, 21 Jun 2005 12:02:43 -0400 Subject: [python-win32] (no subject) Message-ID: <266589E1B9392B4C9195CC25A07C73B90183CE8A@usa0300ms04.na.xerox.net> Folks, I have run into a small problem, that I believe is a Win32net issue... My application has been running (via py2exe) on XP systems without a problem.... Just recently someone tried to use the application on a Windows 2000 system, and received: * The procedure entry point LsaLookupNames2 cound not be located in the dyanmic link library ADVAPI32.dll. I quickly checked on Google, and found this: http://groups-beta.google.com/group/comp.lang.python/browse_thread/threa d/83a4f8d5b6dc1b7d/1248f29c226e865a?q=lsalookupnames2+advapi32.dll&rnum= 1&hl=en#1248f29c226e865a This looks like the win32net Python extension requires the LsaLookupNames2 function in ADVAPI32, but this is only available in WinXP and Win2003 Server, according to MSDN, preventing to use win32net on win2k. You should report this to Mark Hammond, and maybe use a later version of pywin32 for now. Has anyone else seen this problem? I am running the latest pywin32 (204) for Python 2.4 that I have found.... 04/19/2005 09:00 AM 3,948,097 pywin32-204.win32-py2.4.exe I may have more information later.... I have not yet been able to get on to the machine that is causing this problem... But since it doesn't have Python loaded, it maybe difficult to isolate the line, etc that is causing this error.... I will have to see if Py2exe automatically captured the log... - Ben -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050621/6fa6592f/attachment.htm From Tom_RobbinsMilne at swissre.com Tue Jun 21 18:10:53 2005 From: Tom_RobbinsMilne at swissre.com (Tom_RobbinsMilne@swissre.com) Date: Tue, 21 Jun 2005 12:10:53 -0400 Subject: [python-win32] Forcing win32com.client.dispatch to start up a freshExcel In-Reply-To: <9A28C052FF32734DACB0A288A3533991EBB91B@vogbs009.gb.vo.local> Message-ID: Tim, That worked perfectly. Much obliged. Thanks very much, Tom "Tim Golden" Sent by: python-win32-bounces at python.org 06/21/2005 11:52 AM To cc Subject Re: [python-win32] Forcing win32com.client.dispatch to start up a freshExcel [Tom_RobbinsMilne at swissre.com] | I'm trying to use Python's win32com interface to drive an excel spreadsheet. | I've managed to have it open the sheet, call a VBA function with arguments, and close it down cleanly. | However, if Excel is already running, it closes the open instance. Which is not good. | Is there a way I can do the equivalent of VBA's CreateObject() with win32com? I have purchased | "Python Programming on | Win32", and can't find anything. I'm not sure about the CreateObject bit, not being a VBA person, but I suspect you may want to use the DispatchEx method rather than simply Dispatch. eg, [some spreadsheet already open] import win32com.client xl = win32com.client.DispatchEx ("Excel.Application") wb = xl.Workbooks.Add () ws = xl.ActiveSheet ws.Cells (1, 1).Value = "Hello" wb.SaveAs ("c:/temp/temp.xls") wb.Close () xl.Quit () xl = None [original spreadsheet still open] TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050621/5de8fd28/attachment-0001.htm From mli at deform.com Tue Jun 21 18:22:44 2005 From: mli at deform.com (Michael Li) Date: Tue, 21 Jun 2005 12:22:44 -0400 Subject: [python-win32] GUI analyzer of log file In-Reply-To: <266589E1B9392B4C9195CC25A07C73B90183CE8A@usa0300ms04.na.xerox.net> References: <266589E1B9392B4C9195CC25A07C73B90183CE8A@usa0300ms04.na.xerox.net> Message-ID: <42B83ED4.2070505@deform.com> Hi, all Is there a free reporting tool to generate a graphical report from log file, the format of the log file is similar as Apache log file, something like : 192.168.1.1 - - [06/Jun/2005:09:42:18 -0400] "GET / HTTP/1.1" 200 4779 "http://intranet.sftc/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)" If there is no such tool, I am going to use python/Tk, is this a good idea ? Can someone point me a direction ? Best regards, Michael Li From theller at python.net Tue Jun 21 19:15:57 2005 From: theller at python.net (Thomas Heller) Date: Tue, 21 Jun 2005 19:15:57 +0200 Subject: [python-win32] (no subject) References: <266589E1B9392B4C9195CC25A07C73B90183CE8A@usa0300ms04.na.xerox.net> Message-ID: "Schollnick, Benjamin" writes: > Folks, > > I have run into a small problem, that I believe is a Win32net > issue... > > My application has been running (via py2exe) on XP systems without > a problem.... Just recently someone tried to use the application on a > Windows 2000 system, and received: > > * The procedure entry point LsaLookupNames2 cound not be located in the > dyanmic link library ADVAPI32.dll. > > I quickly checked on Google, and found this: ... > > This looks like the win32net Python extension requires the > LsaLookupNames2 function in ADVAPI32, but this is only available in > WinXP and Win2003 Server, according to MSDN, preventing to use > win32net on win2k. You should report this to Mark Hammond, and maybe > use a later version of pywin32 for now. > > Has anyone else seen this problem? > > I am running the latest pywin32 (204) for Python 2.4 that I have > found.... > > 04/19/2005 09:00 AM 3,948,097 pywin32-204.win32-py2.4.exe > > I may have more information later.... I have not yet been able to get > on to the machine that is causing this problem... > > But since it doesn't have Python loaded, it maybe difficult to isolate > the line, etc that is causing this error.... Problems like this can be solved with dependencywalker (google for it). The walker displays binary dependencies for images. Using it I found this: win32net.pyd from build 204 does *not* use the LsaLookupNames2 function in advapi32.dll. However, win32net.pyd links to netapi32.dll (among others), and netapi32.dll links to advapi32.dll, using the name LsaLookupNames2. This was on WinXP. On win2k, netapi32.dll will not link to advapi32's LsaLookupNames2 - otherwise it would not work. So, your exe *should* be able to run on win2k - except if you distribute XP's netapi32.dll with your exe (I've checked this with a trivial py2exe'd script). py2exe isn't very good at determining which dlls belong to the operating system, and so must not be distributed - netapi32.dll is such a beast. You should remove netapi32.dll from the dist directory, and it should work on win2k. And sorry for the false alarm on the threads you mention above ;-) Thomas From Benjamin.Schollnick at xerox.com Tue Jun 21 19:33:02 2005 From: Benjamin.Schollnick at xerox.com (Schollnick, Benjamin) Date: Tue, 21 Jun 2005 13:33:02 -0400 Subject: [python-win32] LsaLookupNames2 Message-ID: <266589E1B9392B4C9195CC25A07C73B90183CE8D@usa0300ms04.na.xerox.net> > Problems like this can be solved with dependencywalker > (google for it). The walker displays binary dependencies for images. Thankfully dependency issues like this seem to be rare.... > Using it I found this: win32net.pyd from build 204 does *not* > use the LsaLookupNames2 function in advapi32.dll. However, > win32net.pyd links to netapi32.dll (among others), and > netapi32.dll links to advapi32.dll, using the name > LsaLookupNames2. This was on WinXP. > > On win2k, netapi32.dll will not link to advapi32's > LsaLookupNames2 - otherwise it would not work. > > So, your exe *should* be able to run on win2k - except if you > distribute XP's netapi32.dll with your exe (I've checked this > with a trivial py2exe'd script). I just checked... And guess what... Py2exe is bundling netapi32.dll... I am working on a new beta, so I'll test to see if it will work on XP without netapi32.dll being bundled... If so, then we should be kosher... Good catch... I'll have to grab dependencywalker to get some practice... > py2exe isn't very good at determining which dlls belong to > the operating system, and so must not be distributed - > netapi32.dll is such a beast. You should remove netapi32.dll > from the dist directory, and it should work on win2k. That's what I suspect.... > And sorry for the false alarm on the threads you mention above ;-) It's okay.... I just miss McMillian's installer... It's unsupported, so I've moved to py2exe... But McMillian's package seemed to be better with the dependency issues.... And offered a few features that don't exist in py2exe... (Or at least are not easily handled in py2exe...) On the plus side, py2exe has handled packages lately that I just could not get McMillian's installer to work reliably with... Which is why I switched... Oh well... Progress... - Benjamin From theller at python.net Tue Jun 21 20:36:59 2005 From: theller at python.net (Thomas Heller) Date: Tue, 21 Jun 2005 20:36:59 +0200 Subject: [python-win32] LsaLookupNames2 References: <266589E1B9392B4C9195CC25A07C73B90183CE8D@usa0300ms04.na.xerox.net> Message-ID: "Schollnick, Benjamin" writes: > It's okay.... I just miss McMillian's installer... > It's unsupported, so I've moved to py2exe... But > McMillian's package seemed to be better with > the dependency issues.... And offered a few > features that don't exist in py2exe... (Or at least > are not easily handled in py2exe...) > > On the plus side, py2exe has handled packages lately > that I just could not get McMillian's installer > to work reliably with... Which is why I switched... I always wondered why no one picked up McMillan and continued to develop or at least maintain it - it's open source after all, isn't it? Thomas PS: netapi32.dll is in the list of dlls to exclude in the py2exe cvs version. No date yet for a new release - but you can easily insert it in the current version yourself, the list is in lib/site-packages/py2exe/build_exe.py, should be easy to find. From Benjamin.Schollnick at xerox.com Tue Jun 21 20:52:14 2005 From: Benjamin.Schollnick at xerox.com (Schollnick, Benjamin) Date: Tue, 21 Jun 2005 14:52:14 -0400 Subject: [python-win32] McMillian Installer (Was LsaLookupNames2) Message-ID: <266589E1B9392B4C9195CC25A07C73B90183CE92@usa0300ms04.na.xerox.net> > > It's okay.... I just miss McMillian's installer... > > It's unsupported, so I've moved to py2exe... But > > McMillian's package seemed to be better with > > the dependency issues.... And offered a few > > features that don't exist in py2exe... (Or at least > > are not easily handled in py2exe...) > > > > On the plus side, py2exe has handled packages lately > > that I just could not get McMillian's installer > > to work reliably with... Which is why I switched... > > I always wondered why no one picked up McMillan and continued > to develop or at least maintain it - it's open source after > all, isn't it? Yes... It was... In my case, I never was motivated, and I suspect it's got quite complex code behind it... Py2exe is a good replacement... I'm generally happy, there's only a few issues that I have not been able to solve. For example, making a plugin based, expandable, generic build.py.... If I do, the typlibs that I attempt to import die... Plus right now, I have solved the LsaLookupNames2 issue, but it appears that I need different typelibs between W2000 & WinXp. But here I am on a development XP system, and can't generate the ones for 2000.... (Yes this isn't py2exe's fault... But....) - Ben From theller at python.net Tue Jun 21 21:09:34 2005 From: theller at python.net (Thomas Heller) Date: Tue, 21 Jun 2005 21:09:34 +0200 Subject: [python-win32] McMillian Installer References: <266589E1B9392B4C9195CC25A07C73B90183CE92@usa0300ms04.na.xerox.net> Message-ID: <3brb4jdd.fsf@python.net> "Schollnick, Benjamin" writes: >> > It's okay.... I just miss McMillian's installer... >> > It's unsupported, so I've moved to py2exe... But >> > McMillian's package seemed to be better with >> > the dependency issues.... And offered a few >> > features that don't exist in py2exe... (Or at least >> > are not easily handled in py2exe...) >> > >> > On the plus side, py2exe has handled packages lately >> > that I just could not get McMillian's installer >> > to work reliably with... Which is why I switched... >> >> I always wondered why no one picked up McMillan and continued >> to develop or at least maintain it - it's open source after >> all, isn't it? > > Yes... It was... > > In my case, I never was motivated, and I suspect it's got > quite complex code behind it... > > Py2exe is a good replacement... I'm generally happy, there's > only a few issues that I have not been able to solve. > > For example, making a plugin based, expandable, generic > build.py.... If I do, the typlibs that I attempt to import > die... > > Plus right now, I have solved the LsaLookupNames2 issue, but > it appears that I need different typelibs between W2000 & WinXp. > But here I am on a development XP system, and can't generate the > ones for 2000.... (Yes this isn't py2exe's fault... But....) (Should I change the subject, again, to py2exe ? ;-) We recently had this issue with wmi, which also needs different typelibs on XP and 2K, maybe you can look up the thread. Since Tim was only using the typelib wrapper to access some constants, it was possible to avoid the typelib at all by using some code I posted to find the constants at runtime. The best solution, imo, would be to let the frozen exe create the wrapper at runtime if it is not found in the exe - but this may require some nontrivial pywin32 hacking. Thomas From sjmachin at lexicon.net Tue Jun 21 22:15:14 2005 From: sjmachin at lexicon.net (John Machin) Date: Wed, 22 Jun 2005 06:15:14 +1000 Subject: [python-win32] Forcing win32com.client.dispatch to start up a fresh Excel In-Reply-To: References: Message-ID: <42B87552.7030704@lexicon.net> Tom_RobbinsMilne at swissre.com wrote: > > Hi, > > I'm trying to use Python's win32com interface to drive an excel > spreadsheet. > > I've managed to have it open the sheet, call a VBA function with > arguments, and close it down cleanly. > > However, if Excel is already running, it closes the open instance. > Which is not good. > > Is there a way I can do the equivalent of VBA's CreateObject() with > win32com? If this means "Can I create a totally different independant instance of Excel so that I don't run the risk of stuffing up what the user is doing with their existing instance", then I'd like to know too. From trodemaster at gmail.com Tue Jun 21 20:14:42 2005 From: trodemaster at gmail.com (Blake Garner) Date: Tue, 21 Jun 2005 11:14:42 -0700 Subject: [python-win32] manual Install of Python into Windows PE Message-ID: <55a5c7c50506211114a92363d@mail.gmail.com> I'm in the process of wirting some automation tools on top of Windows PE. I would like to start using python instead of windows command shell.. So I'm looking for details on how to manually install python into a windows OS. What I'm starting with is a os image in a folder that eventually get burned to CD. Options that I have looked at that won't work for me are using bartPE and compiling the scripts into executables... Thanks, Blake- From Tom_RobbinsMilne at swissre.com Tue Jun 21 22:27:01 2005 From: Tom_RobbinsMilne at swissre.com (Tom_RobbinsMilne@swissre.com) Date: Tue, 21 Jun 2005 16:27:01 -0400 Subject: [python-win32] Forcing win32com.client.dispatch to start up a fresh Excel In-Reply-To: <42B87552.7030704@lexicon.net> Message-ID: John, >> If this means "Can I create a totally different independant instance of >> Excel so that I don't run the risk of stuffing up what the user is doing >> with their existing instance", then I'd like to know too. That's exactly what it is. Actually a bit more complicated than that for me. I'm building a farm of XP boxes to run Excel spreadsheet based models. I have a bit of python to act as a server, reading a message over a socket, calling out to Excel, and returning the result. I expect to be running more than one server on a machine, and hence more than one "instance" of Excel. What Tim proposed worked for me in the simple test I ran (meaning it didn't kill the already-running-instance of excel when I ran it a few times). Soon I'll be doing the more involved thing, with a farm of one. I'll certainly let y'all know if it doesn't work! Thanks, Tom John Machin Sent by: python-win32-bounces+tom_robbinsmilne=swissre.com at python.org 06/21/2005 04:15 PM To cc python-win32 at python.org Subject Re: [python-win32] Forcing win32com.client.dispatch to start up a fresh Excel Tom_RobbinsMilne at swissre.com wrote: > > Hi, > > I'm trying to use Python's win32com interface to drive an excel > spreadsheet. > > I've managed to have it open the sheet, call a VBA function with > arguments, and close it down cleanly. > > However, if Excel is already running, it closes the open instance. > Which is not good. > > Is there a way I can do the equivalent of VBA's CreateObject() with > win32com? If this means "Can I create a totally different independant instance of Excel so that I don't run the risk of stuffing up what the user is doing with their existing instance", then I'd like to know too. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050621/1340da5e/attachment-0001.htm From trodemaster at gmail.com Tue Jun 21 23:10:43 2005 From: trodemaster at gmail.com (Blake Garner) Date: Tue, 21 Jun 2005 14:10:43 -0700 Subject: [python-win32] manual Install of Python into Windows PE Message-ID: <55a5c7c5050621141040d4aabe@mail.gmail.com> I'm in the process of wirting some automation tools on top of Windows PE. I would like to start using python instead of windows command shell.. So I'm looking for details on how to manually install python into a windows OS. What I'm starting with is a os image in a folder that eventually get burned to CD. Options that I have looked at that won't work for me are using bartPE and compiling the scripts into executables... Thanks, Blake- Windows PE info.. http://www.microsoft.com/licensing/programs/sa/support/winpe.mspx From gagenellina at softlab.com.ar Wed Jun 22 00:37:39 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Tue, 21 Jun 2005 19:37:39 -0300 Subject: [python-win32] Forcing win32com.client.dispatch to start up a fresh Excel In-Reply-To: References: <42B87552.7030704@lexicon.net> Message-ID: <6.2.1.2.0.20050621193618.02eb4d70@192.168.0.115> At Tuesday 21/6/2005 17:27, Tom_RobbinsMilne at swissre.com wrote: >Soon I'll be doing the more involved thing, with a farm of one. I'll >certainly let y'all know if it doesn't work! Might be interesting to know if it *does* work too! Gabriel Genellina Softlab SRL From rschroev_nospam_ml at fastmail.fm Wed Jun 22 11:04:35 2005 From: rschroev_nospam_ml at fastmail.fm (Roel Schroeven) Date: Wed, 22 Jun 2005 11:04:35 +0200 Subject: [python-win32] manual Install of Python into Windows PE In-Reply-To: <55a5c7c50506211114a92363d@mail.gmail.com> References: <55a5c7c50506211114a92363d@mail.gmail.com> Message-ID: Blake Garner wrote: > I'm in the process of wirting some automation tools on top of Windows PE. > I would like to start using python instead of windows command shell.. Perhaps Movable Python (http://sourceforge.net/projects/movpy) can prove useful in your case. -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven From trodemaster at gmail.com Wed Jun 22 18:50:28 2005 From: trodemaster at gmail.com (Blake Garner) Date: Wed, 22 Jun 2005 09:50:28 -0700 Subject: [python-win32] manual Install of Python into Windows PE In-Reply-To: References: <55a5c7c50506211114a92363d@mail.gmail.com> Message-ID: <55a5c7c505062209501438adce@mail.gmail.com> I will look into that... Although I would prefer to find out about all registry changes or files that get installed outside of the python24 directory. Thanks, Blake- On 6/22/05, Roel Schroeven wrote: > Blake Garner wrote: > > > I'm in the process of wirting some automation tools on top of Windows PE. > > I would like to start using python instead of windows command shell.. > > Perhaps Movable Python (http://sourceforge.net/projects/movpy) can prove > useful in your case. > > -- > If I have been able to see further, it was only because I stood > on the shoulders of giants. -- Isaac Newton > > Roel Schroeven > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From rschroev_nospam_ml at fastmail.fm Wed Jun 22 23:21:14 2005 From: rschroev_nospam_ml at fastmail.fm (Roel Schroeven) Date: Wed, 22 Jun 2005 23:21:14 +0200 Subject: [python-win32] manual Install of Python into Windows PE In-Reply-To: <55a5c7c505062209501438adce@mail.gmail.com> References: <55a5c7c50506211114a92363d@mail.gmail.com> <55a5c7c505062209501438adce@mail.gmail.com> Message-ID: Blake Garner wrote: > I will look into that... > > Although I would prefer to find out about all registry changes or > files that get installed outside of the python24 directory. I guess you could distill that information from the installer script -- I think there is a script that creates the .msi somewhere in the Python source tree. -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven From fred.dixon at gmail.com Wed Jun 22 23:42:09 2005 From: fred.dixon at gmail.com (Fred Dixon) Date: Wed, 22 Jun 2005 17:42:09 -0400 Subject: [python-win32] McMillian Installer In-Reply-To: <3brb4jdd.fsf@python.net> References: <266589E1B9392B4C9195CC25A07C73B90183CE92@usa0300ms04.na.xerox.net> <3brb4jdd.fsf@python.net> Message-ID: On 6/21/05, Thomas Heller wrote: > > "Schollnick, Benjamin" writes: > > >> > It's okay.... I just miss McMillian's installer... > >> > It's unsupported, so I've moved to py2exe... But > >> > McMillian's package seemed to be better with > >> > the dependency issues.... And offered a few > >> > features that don't exist in py2exe... (Or at least > >> > are not easily handled in py2exe...) > >> > > >> > On the plus side, py2exe has handled packages lately > >> > that I just could not get McMillian's installer > >> > to work reliably with... Which is why I switched... > >> > >> I always wondered why no one picked up McMillan and continued > >> to develop or at least maintain it - it's open source after > >> all, isn't it? > > > > Yes... It was... > > > > In my case, I never was motivated, and I suspect it's got > > quite complex code behind it... > > > > Py2exe is a good replacement... I'm generally happy, there's > > only a few issues that I have not been able to solve. > > > > For example, making a plugin based, expandable, generic > > build.py.... If I do, the typlibs that I attempt to import > > die... > > > > Plus right now, I have solved the LsaLookupNames2 issue, but > > it appears that I need different typelibs between W2000 & WinXp. > > But here I am on a development XP system, and can't generate the > > ones for 2000.... (Yes this isn't py2exe's fault... But....) > > (Should I change the subject, again, to py2exe ? ;-) > > We recently had this issue with wmi, which also needs different typelibs > on XP and 2K, maybe you can look up the thread. > Since Tim was only using the typelib wrapper to access some constants, > it was possible to avoid the typelib at all by using some code I posted > to find the constants at runtime. > > The best solution, imo, would be to let the frozen exe create the > wrapper at runtime if it is not found in the exe - but this may require > some nontrivial pywin32 hacking. > > Thomas > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > what ever happend to cx_freeze instead of McMillian's installer ? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050622/03a9ffc2/attachment.htm From kimwaic888-pythonwin32 at yahoo.com Thu Jun 23 01:29:21 2005 From: kimwaic888-pythonwin32 at yahoo.com (kimwaic888-pythonwin32@yahoo.com) Date: Wed, 22 Jun 2005 16:29:21 -0700 (PDT) Subject: [python-win32] Word hyperLink problem and PageSetup question Message-ID: <20050622232921.50998.qmail@web51403.mail.yahoo.com> Hi all, Appreciate it if anybody can help me with a couple of items: (1) When I use the InsertFile method to insert a .doc file into my current DOC file, all of the hyperlinks get messed up. In the original document, the hyperlink is stored as an fullpath. After InsertFile, all of the links lost the path portion of the name. This is obviously not the intended result. Any idea on how to fix this? (2)Exactly how should I translate the following into Python? (I tried but the result is not right - I don't think I am understanding the range code properly) Selection.MoveRight Unit:=wdCharacter, Count:=1 ActiveDocument.Range(Start:=Selection.Start, End:=Selection.Start). _ InsertBreak Type:=wdSectionBreakNextPage Selection.Start = Selection.Start + 1 With ActiveDocument.Range(Start:=Selection.Start, End:=ActiveDocument. _ Content.End).PageSetup .LineNumbering.Active = False .Orientation = wdOrientLandscape ...others... .GutterPos = wdGutterPosLeft End With Thanks, -- John From pjessop at gmail.com Thu Jun 23 08:13:15 2005 From: pjessop at gmail.com (Peter Jessop) Date: Thu, 23 Jun 2005 08:13:15 +0200 Subject: [python-win32] GUI analyzer of log file In-Reply-To: <42B83ED4.2070505@deform.com> References: <266589E1B9392B4C9195CC25A07C73B90183CE8A@usa0300ms04.na.xerox.net> <42B83ED4.2070505@deform.com> Message-ID: Hi Michael Are you using Windows? If so have you looked at logparser? It's an amazing tool. You can download it from http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en Regards Peter Jessop From martinkuner at gmx.de Thu Jun 23 21:48:08 2005 From: martinkuner at gmx.de (Martin Kuner) Date: Thu, 23 Jun 2005 21:48:08 +0200 Subject: [python-win32] Howto create Array of Variants by ref (win32com) Message-ID: <42BB11F8.6060105@gmx.de> Hi, I have to call a function via ActiveX whith the following interface object.Call(paramName, paramVals) where paramName: array of strings by ref paramVals : array of variants by ref How can I do that, when paramVals i.e. is an array of strings ? I tried it in the following way but without effort. oViLogPrint.call(["strEntry","Error"],["Hello World"]) but it doesn?t work. Has someone a plan for that ? BTW: That?s one function of the LabVIEW ActiveX interface Thanks, Martin From trodemaster at gmail.com Thu Jun 23 23:59:33 2005 From: trodemaster at gmail.com (Blake Garner) Date: Thu, 23 Jun 2005 14:59:33 -0700 Subject: [python-win32] manual Install of Python into Windows PE In-Reply-To: References: <55a5c7c50506211114a92363d@mail.gmail.com> <55a5c7c505062209501438adce@mail.gmail.com> Message-ID: <55a5c7c505062314591e04a503@mail.gmail.com> Ok, looks like this was fairly simple in the end.. python24.dll and msvcr71.dll need to be added to the \windows\system32 directory. Other than that I just copied the whole python24 directory onto my boot cd image. everything seems to work so far.. Blake- On 6/22/05, Roel Schroeven wrote: > Blake Garner wrote: > > > I will look into that... > > > > Although I would prefer to find out about all registry changes or > > files that get installed outside of the python24 directory. > > I guess you could distill that information from the installer script -- > I think there is a script that creates the .msi somewhere in the Python > source tree. > > -- > If I have been able to see further, it was only because I stood > on the shoulders of giants. -- Isaac Newton > > Roel Schroeven > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From rays at blue-cove.com Fri Jun 24 00:14:14 2005 From: rays at blue-cove.com (Ray Schumacher) Date: Thu, 23 Jun 2005 15:14:14 -0700 Subject: [python-win32] filling Windows properties "Summary" tab? Message-ID: <5.2.0.4.2.20050623151148.072f9958@blue-cove.com> The Summary tab of of a file's properties has Title, Subject, Author, etc. Could those be filled in via py2exe or ? I tried them as attributes of Target; no error, but no result. Ray -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050623/c7670d37/attachment.htm From mhammond at skippinet.com.au Fri Jun 24 01:09:37 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 24 Jun 2005 09:09:37 +1000 Subject: [python-win32] filling Windows properties "Summary" tab? In-Reply-To: <5.2.0.4.2.20050623151148.072f9958@blue-cove.com> Message-ID: <07ba01c57848$a13ff970$010a0a0a@enfoldsystems.local> These properties generally work for COM "structured storage" files. Microsoft Office documents and a number of others use this format, and the win32com functions allow you to get and set these properties. If the files are not these COM storage files, then you may need to look at creating a shell extension, so you can add your own custom dialog page (including any properties you like) to the explorer dialog. Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Ray Schumacher Sent: Friday, 24 June 2005 8:14 AM To: python-win32 at python.org Subject: [python-win32] filling Windows properties "Summary" tab? The Summary tab of of a file's properties has Title, Subject, Author, etc. Could those be filled in via py2exe or ? I tried them as attributes of Target; no error, but no result. Ray -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050624/1dc04cef/attachment.htm From martin.kuner at thomson.net Fri Jun 24 10:31:47 2005 From: martin.kuner at thomson.net (Kuner Martin) Date: Fri, 24 Jun 2005 10:31:47 +0200 Subject: [python-win32] win32com problem with LabVIEW Message-ID: <5FBC042194FEC54C9EFEA97D1EA8B3680140E5E6@villsmail01.eu.thmulti.com> I try to talk with Python to a LabVIEW-Application called "cbt" via ActiveX. Now I?m running into problem calling the "Call" method. Here?s the code: ------------ import win32com.client oLv = win32com.client.Dispatch("cbt.Application") strVi = oLv.ApplicationDirectory + "\\cbt.exe\\" + "cdcAxLogPrint.vi" # retrieving the reference to the VI to be called via "Call" oViLogPrint = oLv.GetVIReference(strVi,"",True) arIn = ["strEntry","Error"] arOut = ["Hello World",True] oViLogPrint.Call(arIn,arOut) ------------ The resulting error message: oViLogPrint.Call(arIn,arOut) TypeError: 'NoneType' object is not callable Does anyone has a glue ? Martin From upadhyay at gmail.com Fri Jun 24 13:26:37 2005 From: upadhyay at gmail.com (Amit Upadhyay) Date: Fri, 24 Jun 2005 16:56:37 +0530 Subject: [python-win32] win32com.client.Dispatch problem Message-ID: <349edb38050624042621e7793a@mail.gmail.com> Hi, So here is my problem, I have to implement a com server, that would be used by DotNet application, which can not work with late binding (apparently they don't have CreateObject of VB). So i am following the approach suggested by http://starship.python.net/crew/theller/ctypes/sum_sample.html, and things worked for a while but I am getting weird results now. Weird: python stops working, just shows the prompt. Python 2.3.5 (#62, Feb 8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import win32com.client >>> w = win32com.client.Dispatch("ctypes.asd") Traceback (most recent call last): File "", line 1, in ? File "C:\Python23\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c lsctx) File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 91, in _ GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 79, in _ GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II D_IDispatch) pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) >>> w = win32com.client.Dispatch("ctypes.SumObject") >>> w >>> w >>> 1+2 >>> Python 2.3.5 (#62, Feb 8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import win32com.client >>> w = win32com.client.Dispatch("PythonDemos.Utilities") >>> w >>> dir(w) ['_ApplyTypes_', '_FlagAsMethod', '_LazyAddAttr_', '_NewEnum', '_Release_', '__A ttrToID__', '__LazyMap__', '__call__', '__cmp__', '__doc__', '__getattr__', '__g etitem__', '__init__', '__int__', '__len__', '__module__', '__nonzero__', '__rep r__', '__setattr__', '__setitem__', '__str__', '_builtMethods_', '_enum_', '_fin d_dispatch_type_', '_get_good_object_', '_get_good_single_object_', '_lazydata_' , '_make_method_', '_mapCachedItems_', '_oleobj_', '_olerepr_', '_print_details_ ', '_proc_', '_unicode_to_string_', '_username_', '_wrap_dispatch_'] >>> w.SplitString("asd") (u'asd',) >>> w = win32com.client.Dispatch("ctypes.SumObject") >>> w.get(2,3) >>> w >>> 1+2 >>> Does it sound familiar? A bug in win32com.client.Dispatch or should I be looking at my com server code [which is almost what is presented in sum_sample page I linked above? GUID conflict? I am stuck, please help. TIA, -- Amit Upadhyay Blog: http://www.rootshell.be/~upadhyay +91-9820-859-701 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050624/497759b4/attachment.htm -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: sum.idl Url: http://mail.python.org/pipermail/python-win32/attachments/20050624/497759b4/sum.diff -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: sum_p.py Url: http://mail.python.org/pipermail/python-win32/attachments/20050624/497759b4/sum_p.diff -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: sumserver.py Url: http://mail.python.org/pipermail/python-win32/attachments/20050624/497759b4/sumserver.diff From mhammond at skippinet.com.au Fri Jun 24 16:11:52 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 25 Jun 2005 00:11:52 +1000 Subject: [python-win32] win32com problem with LabVIEW In-Reply-To: <5FBC042194FEC54C9EFEA97D1EA8B3680140E5E6@villsmail01.eu.thmulti.com> Message-ID: <09cd01c578c6$ac3a8060$010a0a0a@enfoldsystems.local> > I try to talk with Python to a LabVIEW-Application called > "cbt" via ActiveX. > > Now I?m running into problem calling the "Call" method. > > Here?s the code: > ------------ > import win32com.client > oLv = win32com.client.Dispatch("cbt.Application") Try either oLv = win32com.client.gencache.EnsureDispatch("cbt.Application") or: > strVi = oLv.ApplicationDirectory + "\\cbt.exe\\" + "cdcAxLogPrint.vi" > > # retrieving the reference to the VI to be called via "Call" > oViLogPrint = oLv.GetVIReference(strVi,"",True) > > arIn = ["strEntry","Error"] > arOut = ["Hello World",True] > obViLogPrint._FlagAsMethod("Call") > oViLogPrint.Call(arIn,arOut) > ------------ > The resulting error message: > oViLogPrint.Call(arIn,arOut) > TypeError: 'NoneType' object is not callable The problem is that .Call is being interpreted as a property reference rather than a method call. The former should trigger early-binding, which should avoid the problem. If that doesn't work, the latter is still using late-binding, but offering a hint to win32com that Call is a method rather than a property. Mark -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 2152 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050625/4856572f/winmail.bin From martin.kuner at thomson.net Fri Jun 24 17:13:00 2005 From: martin.kuner at thomson.net (Kuner Martin) Date: Fri, 24 Jun 2005 17:13:00 +0200 Subject: [python-win32] win32com problem with LabVIEW Message-ID: <5FBC042194FEC54C9EFEA97D1EA8B3680140E601@villsmail01.eu.thmulti.com> Hi Mark, It doesn?t work with the following code: ----------------- import win32com.client oLv = win32com.client.gencache.EnsureDispatch("LabView.Application") strVi = "D:\\Projects\\py.lv.test\\pytest.vi" oViTest = oLv.GetVIReference(strVi,"",True) obViTest._FlagAsMethod("Call") bError = True # to preset object strResult = "" # to preset object arParNames = ["strEntry","strOutput","bError"] # first and second are strings, third is bool arParVals = ["Hello World", strResult, bError] # first input, second+third output oViTest.Call(arParNames,arParVals) ------------------- I got the following error messages: Traceback (most recent call last): File "D:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "D:\Projects\py.lv.test\lv3.py", line 6, in ? oLv = win32com.client.gencache.EnsureDispatch("LabView.Application") File "D:\Python24\Lib\site-packages\win32com\client\gencache.py", line 529, in EnsureDispatch disp = win32com.client.Dispatch(prog_id) File "D:\Python24\Lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx) File "D:\Python24\Lib\site-packages\win32com\client\__init__.py", line 38, in __WrapDispatch klass = gencache.GetClassForCLSID(resultCLSID) File "D:\Python24\Lib\site-packages\win32com\client\gencache.py", line 179, in GetClassForCLSID mod = GetModuleForCLSID(clsid) File "D:\Python24\Lib\site-packages\win32com\client\gencache.py", line 240, in GetModuleForCLSID makepy.GenerateChildFromTypeLibSpec(sub_mod, info) File "D:\Python24\Lib\site-packages\win32com\client\makepy.py", line 306, in GenerateChildFromTypeLibSpec __import__("win32com.gen_py." + dir_name + "." + child) ImportError: No module named _Iapplication ----------------------------- In the meantime I found an article here http://www.talkaboutprogramming.com/group/comp.lang.python/messages/253859.html I tried it and it worked!! I used the following lines, changed the name of the makepy genereated .py file into labfiew.py, copied it into the dir of the script and it works. import labview oLv = labview.Application() But now I ran into another problem. There is no data coming back from LabVIEW via the Call method. The arParVals List is unchanged after the call. Normaly the last two elements should held the result of the VI call. In the other directon it?s working, I?m able to see the string "Hello World" in LabVIEW. -------------------------- >From LV-Doc object.Call([paramName, paramVals]) paramNames : array of strings by ref (Names of the front panel objects that act as input and output parameters to the call). paramVals: array of variants by ref (Input values for the input parameters and return values from the output parameters in the order in which the names were specified in paramNames) --------------------------- Is a list object at that point not the right thing on python side ?? Thanks in advance Martin -----Original Message----- From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: Friday, 24. June 2005 16:12 To: Kuner Martin; python-win32 at python.org Subject: RE: [python-win32] win32com problem with LabVIEW > I try to talk with Python to a LabVIEW-Application called "cbt" via > ActiveX. > > Now I?m running into problem calling the "Call" method. > > Here?s the code: > ------------ > import win32com.client > oLv = win32com.client.Dispatch("cbt.Application") Try either oLv = win32com.client.gencache.EnsureDispatch("cbt.Application") or: > strVi = oLv.ApplicationDirectory + "\\cbt.exe\\" + "cdcAxLogPrint.vi" > > # retrieving the reference to the VI to be called via "Call" > oViLogPrint = oLv.GetVIReference(strVi,"",True) > > arIn = ["strEntry","Error"] > arOut = ["Hello World",True] > obViLogPrint._FlagAsMethod("Call") > oViLogPrint.Call(arIn,arOut) > ------------ > The resulting error message: > oViLogPrint.Call(arIn,arOut) > TypeError: 'NoneType' object is not callable The problem is that .Call is being interpreted as a property reference rather than a method call. The former should trigger early-binding, which should avoid the problem. If that doesn't work, the latter is still using late-binding, but offering a hint to win32com that Call is a method rather than a property. Mark From rays at blue-cove.com Fri Jun 24 18:57:52 2005 From: rays at blue-cove.com (Ray Schumacher) Date: Fri, 24 Jun 2005 09:57:52 -0700 Subject: [python-win32] filling Windows properties "Summary" tab? In-Reply-To: <07ba01c57848$a13ff970$010a0a0a@enfoldsystems.local> References: <5.2.0.4.2.20050623151148.072f9958@blue-cove.com> Message-ID: <5.2.0.4.2.20050624094453.08c4cd10@blue-cove.com> Hi Mark, At 04:09 PM 6/23/2005, Mark Hammond wrote: >These properties generally work for COM "structured storage" files. Microsoft Office documents and a number of others use this format, and the win32com functions allow you to get and set these properties. > >If the files are not these COM storage files, then you may need to look at creating a shell extension, so you can add your own custom dialog page (including any properties you like) to the explorer dialog. I was just mystified about the utility of these Summary properties vs. versioninfo resources set with py2exe... They are per-file settings, but, if I filled them in for a .py file, they would persist only on this machine, but not if the file is copied to another Windows box, and are unavailable on the Samba server. Extra built-in info would be nice, but not worth more effort, to me at least. Thanks, Ray >-----Original Message----- >From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Ray Schumacher >Sent: Friday, 24 June 2005 8:14 AM >To: python-win32 at python.org >Subject: [python-win32] filling Windows properties "Summary" tab? > > > >The Summary tab of of a file's properties has Title, Subject, > >Author, etc. > >Could those be filled in via py2exe or ? > >I tried them as attributes of Target; no error, but no result. > > > > > >Ray > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050624/a1b63973/attachment-0001.htm From amonroe at columbus.rr.com Fri Jun 24 19:06:03 2005 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Fri, 24 Jun 2005 13:06:03 -0400 Subject: [python-win32] filling Windows properties "Summary" tab? In-Reply-To: <5.2.0.4.2.20050624094453.08c4cd10@blue-cove.com> References: <5.2.0.4.2.20050623151148.072f9958@blue-cove.com> <5.2.0.4.2.20050624094453.08c4cd10@blue-cove.com> Message-ID: <152523026812.20050624130603@columbus.rr.com> > They are per-file settings, but, if I filled them in for a .py file, > they would persist only on this machine, but not if the file is > copied to another Windows box, and are unavailable on the Samba > server. Try it with an .mp3 file. I bet it will survive being copied to another machine. They're saved in the id3 tags. Alan From jeffpeery at seametrics.com Fri Jun 24 19:23:55 2005 From: jeffpeery at seametrics.com (Jeff Peery) Date: Fri, 24 Jun 2005 10:23:55 -0700 Subject: [python-win32] win32com problem with LabVIEW (newbie question) In-Reply-To: Message-ID: <000001c578e1$80d2f1d0$7600000a@seametrics.local> Hello, I am fairly new to python. I use wx python at work to make different pieces of engineering code. I am very interested to learn about how to communicate between python and labView... this discussion caught my eye (Re: win32com problem with LabVIEW). Could someone give me an idea of where to start learning how to do this. Are there good examples somewhere or any documentation? Thanks! Jeff From gijs at globaltrack.com Fri Jun 24 19:08:45 2005 From: gijs at globaltrack.com (Gijs Korremans) Date: Fri, 24 Jun 2005 19:08:45 +0200 Subject: [python-win32] The VARIANT type is not supported for SAFEARRAYS Message-ID: <200506241711.j5OHBIJk026644@rrba-146-81-228.telkomadsl.co.za> Hi, From a COM object (written in c++) I receive a struct: unsigned shord (2 bytes) BYTE (6 bytes) BYTE (512 bytes) I can use the first two in python, but when I try to acces the last on with python( i.e. test = struct.longbyte), Python stops doing anything and when I debug the code in boa constructor i get the message "The debugger process stopped prematurely." I asked the guy who made the COM object to change the last varibale of the struc to a string, but now the message shown is " The VARIANT type is not supported for SAFEARRAYS" Does anyone knows what's wrong? Kind regards, Gijs -- This message has been scanned for viruses and dangerous content by Network Sentry, and is believed to be clean. http://www.networksentry.co.za From martin.kuner at thomson.net Fri Jun 24 19:55:48 2005 From: martin.kuner at thomson.net (Kuner Martin) Date: Fri, 24 Jun 2005 19:55:48 +0200 Subject: [python-win32] win32com problem with LabVIEW (newbie question) Message-ID: <5FBC042194FEC54C9EFEA97D1EA8B3680140E602@villsmail01.eu.thmulti.com> LabVIEW has an ActiveX interface. With that you can do nearly everything. The IMHO greatest thing is, that you don?t have to write (or draw) nothing additional to access your self written Vis via the ActiveX interface. The only thing you need is the name of the VI. (see LV doc -> ActiveX) With that it?s in principle possible to access a LabVIEW application (also apps which are build with the Application Builder) from every language which supports the ActiveX interface. In the past I did it with VBScript and Jscript. Now I want to do it with python, but it seems there is a problem with the most important method, which calls a VI (see thread). I hope there will be a solution otherwise I'm in big trouble. Martin -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Jeff Peery Sent: Friday, 24. June 2005 7:24 PM To: python-win32 at python.org Subject: Re: [python-win32] win32com problem with LabVIEW (newbie question) Hello, I am fairly new to python. I use wx python at work to make different pieces of engineering code. I am very interested to learn about how to communicate between python and labView... this discussion caught my eye (Re: win32com problem with LabVIEW). Could someone give me an idea of where to start learning how to do this. Are there good examples somewhere or any documentation? Thanks! Jeff _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From theller at python.net Fri Jun 24 21:01:51 2005 From: theller at python.net (Thomas Heller) Date: Fri, 24 Jun 2005 21:01:51 +0200 Subject: [python-win32] win32com.client.Dispatch problem References: <349edb38050624042621e7793a@mail.gmail.com> Message-ID: Amit Upadhyay writes: > Hi, > > So here is my problem, I have to implement a com server, that would be used > by DotNet application, which can not work with late binding (apparently they > don't have CreateObject of VB). So i am following the approach suggested by > http://starship.python.net/crew/theller/ctypes/sum_sample.html, and things > worked for a while but I am getting weird results now. Weird: python stops > working, just shows the prompt. No, I don't think it does stop working, although it seems so ;-) It is difficult to test inproc (DLL) com servers implemented in Python with Python as the exe client. There is no isolation between the client and the server - both use the same interpreter. What you see is probably a flaw in the ctypes.com server implementation - it redirects sys.stdout/sys.stderr to somewhere else (look into ctypes\com\server.py). You should either use different Python versions for the client and the server, or use normal Python for one and a debug compiled Python for the other, or - maybe that's the best and easiest - use an EXE COM server for testing. Since the exe server is a separate process, the isolation is perfect. Thomas From mhammond at skippinet.com.au Sat Jun 25 01:13:52 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 25 Jun 2005 09:13:52 +1000 Subject: [python-win32] The VARIANT type is not supported for SAFEARRAYS In-Reply-To: <200506241711.j5OHBIJk026644@rrba-146-81-228.telkomadsl.co.za> Message-ID: <0aa701c57912$64473e50$010a0a0a@enfoldsystems.local> > I asked the guy who made the COM object to change the last > varibale of the struc to a string, but now the message shown > is " The VARIANT type is not supported for SAFEARRAYS" > > Does anyone knows what's wrong? This means that win32com was asked to create a SAFEARRAY of a type it does not understand (The message should say "This VARIANT type..." - but I've changed it to read "The Variant type 0xXX is ...") win32com only supports SAFEARRAYS types supported by IDispatch. These are VT_VARIANT, VT_UI1, VT_I2, VT_I4, VT_R4, VT_R8, VT_BSTR, VT_DISPATCH, VT_UNKNOWN and VT_DATE. Mark From mhammond at skippinet.com.au Sat Jun 25 04:43:47 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 25 Jun 2005 12:43:47 +1000 Subject: [python-win32] win32com problem with LabVIEW In-Reply-To: <5FBC042194FEC54C9EFEA97D1EA8B3680140E601@villsmail01.eu.thmulti.com> Message-ID: <000701c5792f$b7253560$010a0a0a@enfoldsystems.local> > It doesn?t work with the following code: ... > "D:\Python24\Lib\site-packages\win32com\client\makepy.py", > line 306, in GenerateChildFromTypeLibSpec > __import__("win32com.gen_py." + dir_name + "." + child) > ImportError: No module named _Iapplication That is probably a bug related to tracking down dependent typelibs. Maybe you could add an entry at sourceforge? > But now I ran into another problem. > There is no data coming back from LabVIEW via the Call method. > The arParVals List is unchanged after the call. Normaly the > last two elements should held the result of the VI call. > In the other directon it?s working, I?m able to see the > string "Hello World" in LabVIEW. Note that in Python, "out" values (including in-out) are always *returned* from the function. Thus you probably want something like: rc, newVals = oViTest.Call(arParNames,arParVals) where 'rc' is whatever 'Call' returns - or, if 'Call' has no return value (ie a 'void' function, or 'procedure'), simply: newVals = oViTest.Call(arParNames,arParVals) Mark -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 2264 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050625/7d05aa25/winmail.bin From martin.kuner at thomson.net Sat Jun 25 09:50:10 2005 From: martin.kuner at thomson.net (Kuner Martin) Date: Sat, 25 Jun 2005 09:50:10 +0200 Subject: [python-win32] win32com problem with LabVIEW Message-ID: <5FBC042194FEC54C9EFEA97D1EA8B3680140E607@villsmail01.eu.thmulti.com> Great, it works !! Many thanks !! Is that behaviour with returnvalues only valid for COM accesses, or is it standard python ? Regarding the problem with the TLB-File and makepy: Is that a makepy problem or a win32com problem ? I?ve never entered a problem at sourceforge, so to which project belongs these problem ? Martin -----Original Message----- From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: Saturday, 25. June 2005 4:44 AM To: Kuner Martin; python-win32 at python.org Subject: RE: [python-win32] win32com problem with LabVIEW > It doesn?t work with the following code: ... > "D:\Python24\Lib\site-packages\win32com\client\makepy.py", > line 306, in GenerateChildFromTypeLibSpec > __import__("win32com.gen_py." + dir_name + "." + child) > ImportError: No module named _Iapplication That is probably a bug related to tracking down dependent typelibs. Maybe you could add an entry at sourceforge? > But now I ran into another problem. > There is no data coming back from LabVIEW via the Call method. > The arParVals List is unchanged after the call. Normaly the last two > elements should held the result of the VI call. > In the other directon it?s working, I?m able to see the string "Hello > World" in LabVIEW. Note that in Python, "out" values (including in-out) are always *returned* from the function. Thus you probably want something like: rc, newVals = oViTest.Call(arParNames,arParVals) where 'rc' is whatever 'Call' returns - or, if 'Call' has no return value (ie a 'void' function, or 'procedure'), simply: newVals = oViTest.Call(arParNames,arParVals) Mark From kveretennicov at gmail.com Sat Jun 25 12:24:26 2005 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Sat, 25 Jun 2005 12:24:26 +0200 Subject: [python-win32] win32com problem with LabVIEW In-Reply-To: <5FBC042194FEC54C9EFEA97D1EA8B3680140E607@villsmail01.eu.thmulti.com> References: <5FBC042194FEC54C9EFEA97D1EA8B3680140E607@villsmail01.eu.thmulti.com> Message-ID: <4660fe300506250324660c0a01@mail.gmail.com> On 6/25/05, Kuner Martin wrote: > Is that behaviour with returnvalues only valid for COM accesses, or is it standard python ? It is standard Python, of course, like the rest of win32com interface. Python has no "out" parameters per se, but any function can return tuple: >>> div_and_mod = divmod(9, 4) >>> div_and_mod (2, 1) A tuple can be unpacked to separate variables: >>> div, mod = div_and_mod >>> div 2 >>> mod 1 But you can always combine tuple unpacking with function call: >>> div, mod = divmod(9, 4) HTH, - kv From fabrice_capiez at yahoo.co.jp Tue Jun 28 11:03:17 2005 From: fabrice_capiez at yahoo.co.jp (Capiez Fabrice) Date: Tue, 28 Jun 2005 18:03:17 +0900 (JST) Subject: [python-win32] Unable to set an Excel chart's title through win32com : can you reproduce this problem ? Message-ID: <20050628090317.73422.qmail@web3413.mail.bbt.yahoo.co.jp> Hello List, I have searched the internet and this list's archives without success before writing this email. I apologise in advance if I neglected something obvious. (I googled the list's archives with "Excel" and "chart" as keywords) My problem is that I want to create or modify the title of an Excel chart through win32com, as well as axes labels. I am quite new to win32com and was initially enthousiastic about being able to take VBA out of my project, doing everything in python. Before starting to rewrite all the code plus some new features in python, I did a few tests and managed successfuly to create some charts, add and remove series etc. These tests showing good promised, I entered the main phase of my project, leaving all the cosmetics bits for the end. Now I need to take care of the afore-said cosmetic bits and just found out I could not access a chart's title which jeopardises the whole thing. The details are given underneath. My question is : "is this a problem with win32com that cannot access all the chart object's feantures ? or is it a problem with my system ? or am I doing somethin altogether wrong ?" here is a sample of code that reproduces the error on my computer : # coding=utf8 import win32com.client from win32com.client import constants import random import pythoncom xlApp = win32com.client.Dispatch("Excel.Application") xlApp.Visible = 1 wb=xlApp.Workbooks.Add() sheet = wb.Sheets(1) sheet.Name="toto" for i in range (25) : a=sheet.Cells(4+i,1) a.Value=i a=sheet.Cells(4+i,2) a.Value=i**0.5*random.random() chart = wb.Charts.Add() chart.ChartType = constants.xlXYScatterSmoothNoMarkers chart.Name = "Test" series = chart.SeriesCollection().NewSeries() Xval=sheet.Range("A4:A28") Yval=sheet.Range("B4:B28") series.XValues = Xval series.Values = Yval series.Name = "Data" xAxis = chart.Axes()[0] yAxis = chart.Axes()[1] xAxis.HasMajorGridlines = True yAxis.HasMajorGridlines = True chart.Location (Where=constants.xlLocationAsObject, Name=sheet.Name) try: chart.HasTitle = True chart.ChartTitle.Characters.Text ="title" except pythoncom.com_error, (hr,msg,exc,arg): print "Excel failed with code %d: %s" %(hr,msg) if exc is None: print "No extended information" else : wcode,source,text,helpFile,HelpId,scode=exc print "the source of error is", source print "message :", text The following produces: Excel failed with code -2146827864: OLE error 0x800a01a8 No extended information The same error occurs if I try to set an axis title instead of the chart's title. It also occurs whether I first set chart.HasTitle to True or not. I checked the chart object's model and I am using the method names given by the analysis of a VBA macro. The error occurs whether I use early or late binding (I tried once to add .dynamic. before the Dispatch method) Actually, this is not all, I discovered another side effect : Not being able to set the title and axis labels from Python, I decided to create some blank charts as templates with proper titles and labels and then import them, copy the sheet in my active workbook and insert my data series in them. This works as far as inserting the series is concerned, but the Axis labels are lost when copying the template sheet in the current workbook (template.Copy(Before=sheet)). Actually, the result is quite erratic since some Axis Labels are sometimes kept intact. (I have 12 charts on my template and sometimes the 12 charts loose their labels, sometimes 2 or 3 manage to keep them in the copy process). So that brings me back to my initial request : could someone try to reproduce the problem to see whether it has something to do with win32com that might not be able to access all legal methods or whether it is something on my system. By the way, I am using a Japanese system which explains the "# coding=utf8" at the begining of the script and might also be a source of problems. I hope that someone is able to give me some insight on this Best Regards, Fabrice Capiez __________________________________ Save the earth http://pr.mail.yahoo.co.jp/ondanka/ From x12345jp at yahoo.com.hk Tue Jun 28 11:30:07 2005 From: x12345jp at yahoo.com.hk (john taylor) Date: Tue, 28 Jun 2005 17:30:07 +0800 (CST) Subject: [python-win32] How to send an array of clusters to labview?? Message-ID: <20050628093007.38139.qmail@web50412.mail.yahoo.com> hi all, i am using win32com to call labview from python over COM and i am using early-bounding. i want to set the value of a control element "array of cluster" in a VI, and the control in the VI is an array of clusters, which has the structure (integer, integer, string). CODE: ... >>> paramNames = ["array of cluster"] >>> paramVals = [(2,3,"hello"), (4,5,"world")] >>> vi.Call(paramNames, paramVals) Traceback (most recent call last): File "", line 1, in ? File "labview.py", line 149, in Call , paramVals) File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_( com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (5002, 'LabVIEW', 'LabVIEW : paramVals Typenfehlanpassung. 1D-Array aus Variants wird erwartet.', None, 0, 0), None) it says, 1D-Array of Variants is expected. i've succeeded in sending 1d and 2d arrays, or a cluster. the only problem is to send an array of clusters (elements of different types). anybody with experience in python/com/labview has idea?? thanks a lot in advance? cheers, john From x12345jp at yahoo.com.hk Tue Jun 28 11:36:30 2005 From: x12345jp at yahoo.com.hk (john taylor) Date: Tue, 28 Jun 2005 17:36:30 +0800 (CST) Subject: [python-win32] threading in python Message-ID: <20050628093630.54620.qmail@web50411.mail.yahoo.com> hi, anybody has called two VIs in parallel?? somehow like this: ***************************************** import win32com.client import thread lv = win32com.client.Dispatch("LabVIEW.Application") def start(): vi2 = lv.GetVIReference("p2.vi") vi2.Run() thr = thread.start_new_thread(start, ()) vi1 = lv.GetVIReference("p1.vi") vi1.Run() ***************************************** it doesn't work. i've tried calling functions of usual objects in several threads like this and everything was fine. but in this case, there must be sth to take care of between COM objects and python. i've also tried the following: 1. construct two lv objects in the main thread. 2. construct lv objects in the main and the new threads respectively. 3. construct two vi objects in the main thread. 4. pass lv or vi as argument when calling new thread. none of them works. anybody can help? cheers, john From gagenellina at softlab.com.ar Tue Jun 28 12:43:50 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Tue, 28 Jun 2005 07:43:50 -0300 Subject: [python-win32] Unable to set an Excel chart's title through win32com : can you reproduce this problem ? In-Reply-To: <20050628090317.73422.qmail@web3413.mail.bbt.yahoo.co.jp> References: <20050628090317.73422.qmail@web3413.mail.bbt.yahoo.co.jp> Message-ID: <6.2.1.2.0.20050628072631.03222d10@192.168.0.115> At Tuesday 28/6/2005 06:03, Capiez Fabrice wrote: >chart.Location (Where=constants.xlLocationAsObject, >Name=sheet.Name) >try: > chart.HasTitle = True > chart.ChartTitle.Characters.Text ="title" > >The following produces: > >Excel failed with code -2146827864: OLE error 0x800a01a8 >No extended information > >The same error occurs if I try to set an axis title >instead of the chart's title. It also occurs whether I >first set chart.HasTitle to True or not. I Error 800a01a8 is "Object required" The error is triggered by the chart.HasTitle line, before setting the title text. So I guessed, chart does not point to a valid object on that line. Commenting out the previous line chart.Location(...) solved the problem. I was unable to find documentation on the Location() method, but I guess that moving the chart to another sheet invalidates the object reference (which may be tied to its current location...) Gabriel Genellina Softlab SRL From Cary.Fitzhugh at gd-ais.com Tue Jun 28 17:04:45 2005 From: Cary.Fitzhugh at gd-ais.com (Fitzhugh, Cary) Date: Tue, 28 Jun 2005 11:04:45 -0400 Subject: [python-win32] failure in makepy.py Message-ID: <9A48EF7239039B48834A3F6B644B0C71021F886A@vaff06-mail01.ad.gd-ais.com> I think I found the issue. There is some issue with dos file formats which caused my python interpreter to give a syntax error. Opened it in Gvim, saved in unix format, now it works fine.. Weird. Sorry to bug you all. Cary -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050628/eb7fac9a/attachment.htm From Cary.Fitzhugh at gd-ais.com Tue Jun 28 16:57:31 2005 From: Cary.Fitzhugh at gd-ais.com (Fitzhugh, Cary) Date: Tue, 28 Jun 2005 10:57:31 -0400 Subject: [python-win32] Failure in makepy.py Message-ID: <9A48EF7239039B48834A3F6B644B0C71021F8863@vaff06-mail01.ad.gd-ais.com> Hi all, I'm trying to get connected to Rhapsody 6.0 and found the rhapsody.tlb. If I try to run makepy on it, it gives me a Syntax Error on line 206. I guess I can paste the info... python c:\Python24\Lib\site-packages\win32com\client\makepy.py c:\Rhapsody60\rhapsody.tlb > "c:\Documents and Settings\cary.fitzhugh\working\xmitomdl"\rhap60.py Generating to C:\Python24\lib\site-packages\win32com\gen_py\47DBF9D5-F318-11D2-B825-00 104B3E6572x0x1x0\__init__.py Building definitions from type library... Generating... Importing module Traceback (most recent call last): File "c:\Python24\Lib\site-packages\win32com\client\makepy.py", line 370, in ? rc = main() File "c:\Python24\Lib\site-packages\win32com\client\makepy.py", line 363, in main GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, bForDemand = bForDemand, bBuildHidden = hiddenSpec) File "c:\Python24\Lib\site-packages\win32com\client\makepy.py", line 274, in GenerateFromTypeLibSpec gencache.AddModuleToCache(info.clsid, info.lcid, info.major, info.minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 555, in AddModuleToCache mod = _GetModule(fname) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 634, in _GetModule mod = __import__(mod_name) File "C:\Python24\lib\site-packages\win32com\gen_py\47DBF9D5-F318-11D2-B825-0 0104B3E6572x0x1x0\__init__.py", line 206 '{AB75C7F8-145D-439E-B02A-9E40E1807754}' : 'IRPRequirement', ^ SyntaxError: invalid syntax I'm hoping someone has seen something similar. Any ideas? Thanks. Cary -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050628/02e83304/attachment.htm From cappy2112 at gmail.com Tue Jun 28 18:49:13 2005 From: cappy2112 at gmail.com (Tony C) Date: Tue, 28 Jun 2005 09:49:13 -0700 Subject: [python-win32] Python-win32 Digest, Vol 27, Issue 34 In-Reply-To: References: Message-ID: <8249c4ac050628094970c505a5@mail.gmail.com> I would think a better approach would be to instantiate multiple instances like this. Have you tried something like this? lv1 = win32com.client.Dispatch("LabVIEW.Application") lv2 = win32com.client.Dispatch("LabVIEW.Application") hi, anybody has called two VIs in parallel?? somehow like this: ****************************** *********** import win32com.client import thread lv = win32com.client.Dispatch("LabVIEW.Application") def start(): vi2 = lv.GetVIReference("p2.vi ") vi2.Run() thr = thread.start_new_thread(start, ()) vi1 = lv.GetVIReference("p1.vi ") vi1.Run() -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050628/237b3d84/attachment.htm From rays at blue-cove.com Tue Jun 28 18:52:10 2005 From: rays at blue-cove.com (Ray Schumacher) Date: Tue, 28 Jun 2005 09:52:10 -0700 Subject: [python-win32] filling Windows properties "Summary" tab? In-Reply-To: <152523026812.20050624130603@columbus.rr.com> References: <5.2.0.4.2.20050624094453.08c4cd10@blue-cove.com> <5.2.0.4.2.20050623151148.072f9958@blue-cove.com> <5.2.0.4.2.20050624094453.08c4cd10@blue-cove.com> Message-ID: <5.2.0.4.2.20050628093721.03a64600@blue-cove.com> At 10:06 AM 6/24/2005, R. Alan Monroe wrote: >> They are per-file settings, but, if I filled them in for a .py file, >> they would persist only on this machine, but not if the file is >> copied to another Windows box, and are unavailable on the Samba >> server. > >Try it with an .mp3 file. I bet it will survive being copied to >another machine. They're saved in the id3 tags. Nope, I copied an mp3 to another PC in the workgroup, and it does not persist. I have found a dll for this though: http://www.microsoft.com/downloads/details.aspx?FamilyID=9ba6fac6-520b-4a0a-878a-53ec8300c4c2&DisplayLang=en http://support.microsoft.com/default.aspx?scid=kb;en-us;224351 The Dsofile.dll sample file is an in-process ActiveX component for programmers that use Microsoft Visual Basic .NET or the Microsoft .NET Framework. You can use this in your custom applications to read and to edit the OLE document properties that are associated with Microsoft Office files, such as the following: "Microsoft Excel workbooks "Microsoft PowerPoint presentations "Microsoft Word documents "Microsoft Project projects "Microsoft Visio drawings "Other files without those Office products installed and http://blogs.msdn.com/gstemp/archive/2004/02/25/79867.aspx that has some info. Ray From timr at probo.com Tue Jun 28 19:36:14 2005 From: timr at probo.com (Tim Roberts) Date: Tue, 28 Jun 2005 10:36:14 -0700 Subject: [python-win32] Unable to set an Excel chart's title through win32com : can you reproduce this problem ? In-Reply-To: References: Message-ID: <42C18A8E.9080100@probo.com> On Tue, 28 Jun 2005 18:03:17 +0900 (JST), Capiez Fabrice wrote: >Hello List, >I have searched the internet and this list's archives >without success before writing this email. I apologise in >advance if I neglected something obvious. (I googled the list's archives with "Excel" and >"chart" as keywords) > > Did you look for "ChartTitle"? That would be the sensible query, although I don't think it would have helped here. >The details are given underneath. My question is : "is >this a problem with win32com that cannot access all the >chart object's feantures ? or is it a >problem with my system ? or am I doing somethin altogether >wrong ?" > > >here is a sample of code that reproduces the error on my >computer : > ># coding=utf8 >import win32com.client >from win32com.client import constants >import random >import pythoncom > >xlApp = win32com.client.Dispatch("Excel.Application") >xlApp.Visible = 1 >wb=xlApp.Workbooks.Add() >sheet = wb.Sheets(1) >sheet.Name="toto" >for i in range (25) : > a=sheet.Cells(4+i,1) > a.Value=i > a=sheet.Cells(4+i,2) > a.Value=i**0.5*random.random() > >chart = wb.Charts.Add() >chart.ChartType = constants.xlXYScatterSmoothNoMarkers >chart.Name = "Test" >series = chart.SeriesCollection().NewSeries() >Xval=sheet.Range("A4:A28") >Yval=sheet.Range("B4:B28") >series.XValues = Xval >series.Values = Yval >series.Name = "Data" >xAxis = chart.Axes()[0] >yAxis = chart.Axes()[1] >xAxis.HasMajorGridlines = True >yAxis.HasMajorGridlines = True >chart.Location (Where=constants.xlLocationAsObject, >Name=sheet.Name) >try: > chart.HasTitle = True > chart.ChartTitle.Characters.Text ="title" > > Was the ".Characters" here an experiment? You should remove that. Text is a property of the ChartTitle object. > >except pythoncom.com_error, (hr,msg,exc,arg): > print "Excel failed with code %d: %s" >%(hr,msg) > if exc is None: > print "No extended information" > else : > >wcode,source,text,helpFile,HelpId,scode=exc > print "the source of error is", source > print "message :", text > > >The following produces: > >Excel failed with code -2146827864: OLE error 0x800a01a8 >No extended information > Error 800a01a8 is "object required". COM thinks that the "chart" object is no longer an object. Your try/except was masking the real problem. You thought the issue was with chart.ChartTitle, but if you had eliminated the try/except and allowed the normal error processing to occur, you would have seen that the error was, in fact, occurring at the "chart.HasTitle". I'm not sure I know why, but the issue is the "chart.Location" method. After that method, the chart object is no longer valid, and you can't manipulate anything. If you move the "chart.Location" call to the end, it works as expected: ... xAxis.HasMajorGridlines = True yAxis.HasMajorGridlines = True chart.HasTitle = True chart.ChartTitle.Text ="title" chart.Location (Where=constants.xlLocationAsObject, Name=sheet.Name) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rwupole at msn.com Tue Jun 28 20:23:16 2005 From: rwupole at msn.com (Roger Upole) Date: Tue, 28 Jun 2005 14:23:16 -0400 Subject: [python-win32] Re: filling Windows properties "Summary" tab? Message-ID: R. Alan Monroe wrote: > >>> They are per-file settings, but, if I filled them in for a .py file, >>> they would persist only on this machine, but not if the file is >>> copied to another Windows box, and are unavailable on the Samba >>> server. >> >>Try it with an .mp3 file. I bet it will survive being copied to >>another machine. They're saved in the id3 tags. > > Nope, I copied an mp3 to another PC in the workgroup, and it does not > persist. > I have found a dll for this though: > http://www.microsoft.com/downloads/details.aspx?FamilyID=9ba6fac6-520b-4a0a-878a-53ec8300c4c2&DisplayLang=en > http://support.microsoft.com/default.aspx?scid=kb;en-us;224351 > The Dsofile.dll sample file is an in-process ActiveX component for > programmers that use Microsoft Visual Basic .NET or the Microsoft .NET > Framework. You can use this in your custom applications to read and to > edit the OLE document properties that are associated with Microsoft Office > files, such as the following: > "Microsoft Excel workbooks > "Microsoft PowerPoint presentations > "Microsoft Word documents > "Microsoft Project projects > "Microsoft Visio drawings > "Other files without those Office products installed > > > and > http://blogs.msdn.com/gstemp/archive/2004/02/25/79867.aspx > that has some info. > > Ray There are actually 2 different implentations of document properties. The COM implementation embems them directly in the file itself, but this only works for documents created by COM applications. (Office, etc). On NTFS 5 (Win2k or later), you can add Summary info to any file, and it's stored in alternate data streams. However, if you copy the file to a filesystem that doesn't support alternate data streams, the properties are lost. Roger From mhammond at skippinet.com.au Wed Jun 29 02:17:50 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 29 Jun 2005 10:17:50 +1000 Subject: [python-win32] Failure in makepy.py In-Reply-To: <9A48EF7239039B48834A3F6B644B0C71021F8863@vaff06-mail01.ad.gd-ais.com> Message-ID: <01f401c57c3f$fcf0f1c0$090a0a0a@enfoldsystems.local> This sounds like a bug in Python 2.4 and you are using ActivePython. The recent pywin32 builds have a work-around for this problem, but ActivePython was built before this was in place. Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Fitzhugh, Cary Sent: Wednesday, 29 June 2005 12:58 AM To: python-win32 at python.org Subject: [python-win32] Failure in makepy.py Hi all, I'm trying to get connected to Rhapsody 6.0 and found the rhapsody.tlb. If I try to run makepy on it, it gives me a Syntax Error on line 206. I guess I can paste the info... python c:\Python24\Lib\site-packages\win32com\client\makepy.py c:\Rhapsody60\rhapsody.tlb > "c:\Documents and Settings\cary.fitzhugh\working\xmitomdl"\rhap60.py Generating to C:\Python24\lib\site-packages\win32com\gen_py\47DBF9D5-F318-11D2-B825-00104B 3E6572x0x1x0\__init__.py Building definitions from type library... Generating... Importing module Traceback (most recent call last): File "c:\Python24\Lib\site-packages\win32com\client\makepy.py", line 370, in ? rc = main() File "c:\Python24\Lib\site-packages\win32com\client\makepy.py", line 363, in main GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, bForDemand = bForDemand, bBuildHidden = hiddenSpec) File "c:\Python24\Lib\site-packages\win32com\client\makepy.py", line 274, in GenerateFromTypeLibSpec gencache.AddModuleToCache(info.clsid, info.lcid, info.major, info.minor) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 555, in AddModuleToCache mod = _GetModule(fname) File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 634, in _GetModule mod = __import__(mod_name) File "C:\Python24\lib\site-packages\win32com\gen_py\47DBF9D5-F318-11D2-B825-00104 B3E6572x0x1x0\__init__.py", line 206 '{AB75C7F8-145D-439E-B02A-9E40E1807754}' : 'IRPRequirement', ^ SyntaxError: invalid syntax I'm hoping someone has seen something similar. Any ideas? Thanks. Cary -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 7172 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050629/7b436ccb/winmail.bin From fabrice_capiez at yahoo.co.jp Wed Jun 29 14:16:48 2005 From: fabrice_capiez at yahoo.co.jp (Fabrice Capiez) Date: Wed, 29 Jun 2005 21:16:48 +0900 Subject: [python-win32] Unable to set an Excel chart's titl ethrough win32com : can you reproduce this problem ? In-Reply-To: <6.2.1.2.0.20050628072631.03222d10@192.168.0.115> References: <20050628090317.73422.qmail@web3413.mail.bbt.yahoo.co.jp>, <6.2.1.2.0.20050628072631.03222d10@192.168.0.115> Message-ID: <20050629211647835.fabrice_capiez@yahoo.co.jp> Thank you Gabriel and Tim Indeed the Chart.Location was causing a problem, and I had not suspected it was since I do not use this method in my main program (It was just something I had written as an example). Actually, it seems that the Copy method of either a chart or a sheet is also corrupting the original objects which thus cannot be congigured correctely after. In the case of Copy it is even more annoying since the copy itself is not perfect : some axis labels erradically disappear during the process. Well, at least I now have a way of continuing my project thanks to you. (I would have prefered to stick to the copy method since opening and copying a sheet with all the charts pre-formated takes only half a second whereas generating 11 charts and setting the appearence takes about 4 seconds.. but well, it's better than nothing) Thankyou once again then, Fabrice Capiez Tue, 28 Jun 2005 07:43:50 -0300 ?? ?Re: [python-win32] Unable to set an Excel chart's titlethrough win32com : can you reproduce this problem ????? Gabriel Genellina ????????: > At Tuesday 28/6/2005 06:03, Capiez Fabrice wrote: > > >chart.Location (Where=constants.xlLocationAsObject, > >Name=sheet.Name) > >try: > > chart.HasTitle = True > > chart.ChartTitle.Characters.Text ="title" > > > >The following produces: > > > >Excel failed with code -2146827864: OLE error 0x800a01a8 > >No extended information > > > >The same error occurs if I try to set an axis title > >instead of the chart's title. It also occurs whether I > >first set chart.HasTitle to True or not. I > > Error 800a01a8 is "Object required" > The error is triggered by the chart.HasTitle line, before setting the title > text. > So I guessed, chart does not point to a valid object on that line. > Commenting out the previous line chart.Location(...) solved the problem. > I was unable to find documentation on the Location() method, but I guess > that moving the chart to another sheet invalidates the object reference > (which may be tied to its current location...) > > > Gabriel Genellina > Softlab SRL __________________________________ Save the earth http://pr.mail.yahoo.co.jp/ondanka/ From rays at blue-cove.com Wed Jun 29 15:55:07 2005 From: rays at blue-cove.com (RayS) Date: Wed, 29 Jun 2005 06:55:07 -0700 Subject: [python-win32] filling Windows properties "Summary" tab? In-Reply-To: References: Message-ID: <6.2.1.2.2.20050629065234.02bb6a90@pop-server.san.rr.com> Hi Roger, At 11:23 AM 6/28/2005, Roger Upole wrote: >On NTFS 5 (Win2k or later), you can add Summary info to any file, >and it's stored in alternate data streams. However, if you copy the >file to a filesystem that doesn't support alternate data streams, the >properties are lost. I had also found that if I create them on Win2000 and copy to XP they are lost... Ray From jgrice at predictioncompany.com Wed Jun 29 14:57:30 2005 From: jgrice at predictioncompany.com (Jeff Grice) Date: Wed, 29 Jun 2005 07:57:30 -0500 Subject: [python-win32] PythonWin Script Editor Display Line Numbers? Message-ID: <92A5F85BE489974B9C9EECE6707B8BCD3BD605@root.chinatitech.com> Hello all, I have an easy question that I'm sure someone on the list can help with. Is there a way to display line numbers in the Python Script editor in PythonWin? I am using Python 2.4 pywin32 build 204 on WindowsXP. Any help would be much appreciated. Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050629/709f7d40/attachment.htm From rays at blue-cove.com Wed Jun 29 16:25:58 2005 From: rays at blue-cove.com (RayS) Date: Wed, 29 Jun 2005 07:25:58 -0700 Subject: [python-win32] system() fails, win32process succeeds Message-ID: <6.2.1.2.2.20050629065721.02b70230@pop-server.san.rr.com> Someone might be interested: I ran across an unexpected process issue this week. We have a converter app that is part of a suite, when it runs it needs to call an external DOS exe briefly (the exe does bit-shifting in a file etc.) I originally used system(), but found that _if_ one other particular app was running (a huge resource hog - 99% CPU usage polling the A/Ds) the call would fail to execute properly. I switched to win32process and SetPriorityClass() to REALTIME and the call always succeeds. win32con.SW_HIDE is also set in StartupInfo. http://wiki.wxpython.org/index.cgi/Capturing_20DOS_20Output_20in_20a_20wxWindow is a very helpful process example. Ray From python at kareta.de Wed Jun 29 17:26:21 2005 From: python at kareta.de (=?windows-1252?Q?J=FCrgen_Kareta?=) Date: Wed, 29 Jun 2005 17:26:21 +0200 Subject: [python-win32] PythonWin Script Editor Display Line Numbers? In-Reply-To: <92A5F85BE489974B9C9EECE6707B8BCD3BD605@root.chinatitech.com> References: <92A5F85BE489974B9C9EECE6707B8BCD3BD605@root.chinatitech.com> Message-ID: <42C2BD9D.6010201@kareta.de> Hello Jeff, > I have an easy question that I?m sure someone on the list can help > with. Is there a way to display line numbers in the Python Script > editor in PythonWin? > select view/options in the main menu; select tab editor set Line Numbers in the Margins Widths Frame to something more than 30 (30 display linenumbers up to 999 in my case) thats it. regards, J?rgen From rwupole at msn.com Wed Jun 29 21:29:01 2005 From: rwupole at msn.com (Roger Upole) Date: Wed, 29 Jun 2005 15:29:01 -0400 Subject: [python-win32] Re: filling Windows properties "Summary" tab? Message-ID: "RayS" wrote: > Hi Roger, > > At 11:23 AM 6/28/2005, Roger Upole wrote: >>On NTFS 5 (Win2k or later), you can add Summary info to any file, >>and it's stored in alternate data streams. However, if you copy the >>file to a filesystem that doesn't support alternate data streams, the >>properties are lost. > > I had also found that if I create them on Win2000 and copy to XP they are > lost... > > Ray How are you copying them ? Some means of copying files don't bring along alternate data streams. For example, shutil.copyfile doesn't. Also, are you sure the volume to which the files are being copied is NTFS 5 ? Roger From John.Gooch at echostar.com Wed Jun 29 21:42:04 2005 From: John.Gooch at echostar.com (Gooch, John) Date: Wed, 29 Jun 2005 13:42:04 -0600 Subject: [python-win32] ADSI and LDAP Searches Message-ID: <15A1FDA26DAD524DA7A7AF77313EBA8F0F60D504@riv-excha5.echostar.com> Hey, I am converting a Perl script into a Python script, and the part where the Perl script is searching Active Directory using the LDAP interface is throwing me a curve ball. Here is a search for a Windows Group in Perl: my $hdb = Win32::OLE->new("ADODB.Connection"); $hdb->{Provider} = "ADsDSOObject"; $hdb->Open("ADSI Provider"); $rs = $hdb->Execute("<$adsdomain>;(&(objectCategory=Group)(name=$groupname));adspa th;SubTree"); Here is what I have in Python so far: adsi = win32com.client.Dispatch('ADsNameSpaces') ldap = adsi.getobject('','LDAP:') DSO = ldap.OpenDSObject("","","", 0) It errors on the DSO line. I am guessing that the 'DSO' Python object is the equivalent of the Perl "$hdb" object, but I don't know the syntax. I could be complete off-base here as the document I have found via Google don't explain what the code is doing, so I am left guessing. Any help would be appreciated. Thank You, John A. Gooch Systems Administrator IT - Tools EchoStar Satellite L.L.C. 9601 S. Meridian Blvd. Englewood, CO 80112 Desk: 720-514-5708 -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Schollnick, Benjamin Sent: Tuesday, June 21, 2005 11:33 AM To: Thomas Heller; python-win32 at python.org Subject: Re: [python-win32] LsaLookupNames2 > Problems like this can be solved with dependencywalker > (google for it). The walker displays binary dependencies for images. Thankfully dependency issues like this seem to be rare.... > Using it I found this: win32net.pyd from build 204 does *not* > use the LsaLookupNames2 function in advapi32.dll. However, > win32net.pyd links to netapi32.dll (among others), and > netapi32.dll links to advapi32.dll, using the name > LsaLookupNames2. This was on WinXP. > > On win2k, netapi32.dll will not link to advapi32's > LsaLookupNames2 - otherwise it would not work. > > So, your exe *should* be able to run on win2k - except if you > distribute XP's netapi32.dll with your exe (I've checked this > with a trivial py2exe'd script). I just checked... And guess what... Py2exe is bundling netapi32.dll... I am working on a new beta, so I'll test to see if it will work on XP without netapi32.dll being bundled... If so, then we should be kosher... Good catch... I'll have to grab dependencywalker to get some practice... > py2exe isn't very good at determining which dlls belong to > the operating system, and so must not be distributed - > netapi32.dll is such a beast. You should remove netapi32.dll > from the dist directory, and it should work on win2k. That's what I suspect.... > And sorry for the false alarm on the threads you mention above ;-) It's okay.... I just miss McMillian's installer... It's unsupported, so I've moved to py2exe... But McMillian's package seemed to be better with the dependency issues.... And offered a few features that don't exist in py2exe... (Or at least are not easily handled in py2exe...) On the plus side, py2exe has handled packages lately that I just could not get McMillian's installer to work reliably with... Which is why I switched... Oh well... Progress... - Benjamin _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From rwupole at msn.com Wed Jun 29 21:42:19 2005 From: rwupole at msn.com (Roger Upole) Date: Wed, 29 Jun 2005 15:42:19 -0400 Subject: [python-win32] Re: system() fails, win32process succeeds Message-ID: "RayS" wrote: > Someone might be interested: I ran across an unexpected process issue this > week. > We have a converter app that is part of a suite, when it runs it needs to > call an external DOS exe briefly (the exe does bit-shifting in a file > etc.) I originally used system(), but found that _if_ one other > particular app was running (a huge resource hog - 99% CPU usage polling > the A/Ds) the call would fail to execute properly. I switched to > win32process and SetPriorityClass() to REALTIME and the call always > succeeds. > win32con.SW_HIDE is also set in StartupInfo. > http://wiki.wxpython.org/index.cgi/Capturing_20DOS_20Output_20in_20a_20wxWindow > is a very helpful process example. > > Ray I ran into something similar a while back that turned out to be a deficiency in the called program. It wasn't taking into account the fact that it might not be able to acquire resources in a timely manner. If you use os.popen to run the executable, can you get any kind of error message back ? Roger From bgailer at sbcglobal.net Wed Jun 29 21:24:24 2005 From: bgailer at sbcglobal.net (Bob Gailer) Date: Wed, 29 Jun 2005 12:24:24 -0700 Subject: [python-win32] Unable to set an Excel chart's titl ethrough win32com : can you reproduce this problem ? In-Reply-To: <20050629211647835.fabrice_capiez@yahoo.co.jp> References: <20050628090317.73422.qmail@web3413.mail.bbt.yahoo.co.jp> <6.2.1.2.0.20050628072631.03222d10@192.168.0.115> <20050629211647835.fabrice_capiez@yahoo.co.jp> Message-ID: <6.1.2.0.0.20050629122045.0286fd60@pop.sbcglobal.yahoo.com> At 05:16 AM 6/29/2005, Fabrice Capiez wrote: >Thank you Gabriel and Tim > >Indeed the Chart.Location was causing a problem, and I had not suspected it >was since I do not use this method in my main program (It was just something > I had written as an example). Actually, it seems that the Copy method of >either a chart or a sheet is also corrupting the original objects which thus > cannot be congigured correctely after. In the case of Copy it is even more >annoying since the copy itself is not perfect : some axis labels erradically > disappear during the process. >Well, at least I now have a way of continuing my project thanks to you. (I >would have prefered to stick to the copy method since opening and copying a >sheet with all the charts pre-formated takes only half a second whereas >generating 11 charts and setting the appearence takes about 4 seconds.. but >well, it's better than nothing) > >Thankyou once again then, > >Fabrice Capiez > > >Tue, 28 Jun 2005 07:43:50 -0300 $B:"$K(B >$B!X(BRe: [python-win32] Unable to set an Excel chart's titlethrough >win32com : >can you reproduce this problem ?$B!Y$NCf$G(B >Gabriel Genellina $B$5$s$O=q$-$^$7$?(B: > > > At Tuesday 28/6/2005 06:03, Capiez Fabrice wrote: > > > > >chart.Location (Where=constants.xlLocationAsObject, > > >Name=sheet.Name) > > >try: > > > chart.HasTitle = True > > > chart.ChartTitle.Characters.Text ="title" According to Excel Visual Basic Help: "Characters - Returns a Characters object that represents a range of characters within the object text. You can use the Characters object to format characters within a text string. Now look at the Text property "Returns or sets the text for the specified object. Read-only String for the Range object, read/write String for all other objects." So try chart.ChartTitle.Text ="title" > > > > > >The following produces: > > > > > >Excel failed with code -2146827864: OLE error 0x800a01a8 > > >No extended information > > > > > >The same error occurs if I try to set an axis title > > >instead of the chart's title. It also occurs whether I > > >first set chart.HasTitle to True or not. I > > > > Error 800a01a8 is "Object required" > > The error is triggered by the chart.HasTitle line, before setting the > title > > text. > > So I guessed, chart does not point to a valid object on that line. > > Commenting out the previous line chart.Location(...) solved the problem. > > I was unable to find documentation on the Location() method, but I guess > > that moving the chart to another sheet invalidates the object reference > > (which may be tied to its current location...) > > > > > > Gabriel Genellina > > Softlab SRL >__________________________________ >Save the earth >http://pr.mail.yahoo.co.jp/ondanka/ > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 Bob Gailer mailto:bgailer at alum.rpi.edu 510 558 3275 home 720 938 2625 cell -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050629/da7b585d/attachment-0001.htm From rays at blue-cove.com Wed Jun 29 23:06:58 2005 From: rays at blue-cove.com (Ray Schumacher) Date: Wed, 29 Jun 2005 14:06:58 -0700 Subject: [python-win32] system() fails, win32process succeeds In-Reply-To: Message-ID: <5.2.0.4.2.20050629135229.06d464b8@blue-cove.com> Hi Roger, At 12:42 PM 6/29/2005, Roger Upole wrote: >I ran into something similar a while back that turned out to be a deficiency >in the called >program. It wasn't taking into account the fact that it might not be able >to acquire resources in a timely manner. I think that is the case, but I didn't write the exe and so can't (won't) modify it; the Python program itself is in no hurry, wx just returns to mainloop() after the call. >If you use os.popen to run the executable, >can you get >any kind of error message back ? Thanks for the idea, I hadn't tried popen, if I have time I'll investigate. I was using: cmdLine = 'FixTRC.exe "'+outfilePath+'"' os.system(cmdLine) and switched to: StartupInfo = win32process.STARTUPINFO() StartupInfo.dwFlags = win32process.STARTF_USESHOWWINDOW StartupInfo.wShowWindow = win32con.SW_HIDE processHndl, primary_thread, pid, tid = win32process.CreateProcess( None, cmdLine, None, None, 0, win32process.REALTIME_PRIORITY_CLASS, None, None, StartupInfo) Thanks, Ray From fabrice_capiez at yahoo.co.jp Thu Jun 30 00:23:39 2005 From: fabrice_capiez at yahoo.co.jp (Fabrice Capiez) Date: Thu, 30 Jun 2005 07:23:39 +0900 Subject: [python-win32] Unable to set an Excel chart's titl ethrough win32com : can you reproduce this problem ? In-Reply-To: <6.1.2.0.0.20050629122045.0286fd60@pop.sbcglobal.ya hoo.com> References: <20050628090317.73422.qmail@web3413.mail.bbt.yahoo.co.jp><6.2.1.2.0.20050628072631.03222d10@192.168.0.115><20050629211647835.fabrice_capiez@yahoo.co.jp>, <6.1.2.0.0.20050629122045.0286fd60@pop.sbcglobal.yahoo.com> Message-ID: <20050630072338538.fabrice_capiez@yahoo.co.jp> > > According to Excel Visual Basic Help: "Characters - Returns a > Characters > object that represents a range of characters within the object text. You > can use the Characters object to format characters within a text string. > > Now look at the Text property "Returns or sets the text for the specified > object. Read-only String for the Range object, read/write String for all > other objects." > > So try chart.ChartTitle.Text ="title" > Actually I tried both ChartTitle.Text and ChartTitle.Characters.Text The VBA macro recorder uses Characters.Text to set the title but at first I thought that this object was only due to my Japanese version of Office, so I tried with both possibilities at every step of my testing. Now I think that the problem lies in copying a chart from one place to another since the problem arises with both Copy and Location methods.. Either there is a problem with win32com, or the com interface of the object is bugged, or I am not using things the right way altogether. Thank you for the insight anyway Fabrice Capiez __________________________________ Save the earth http://pr.mail.yahoo.co.jp/ondanka/ From mhammond at skippinet.com.au Thu Jun 30 01:02:48 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 30 Jun 2005 09:02:48 +1000 Subject: [python-win32] ADSI and LDAP Searches In-Reply-To: <15A1FDA26DAD524DA7A7AF77313EBA8F0F60D504@riv-excha5.echostar.com> Message-ID: <042901c57cfe$ab8bf220$090a0a0a@enfoldsystems.local> I've never used ADSI via ADODB, but have managed to use the raw ADSI interfaces directly. Check out your lib\site-packages\win32comext\adsi\demos directory. > Here is a search for a Windows Group in Perl: > my $hdb = Win32::OLE->new("ADODB.Connection"); > $hdb->{Provider} = "ADsDSOObject"; > $hdb->Open("ADSI Provider"); > $rs = > $hdb->Execute("<$adsdomain>;(&(objectCategory=Group)(name=$gro > upname));adspa > th;SubTree"); > > > Here is what I have in Python so far: > adsi = win32com.client.Dispatch('ADsNameSpaces') > ldap = adsi.getobject('','LDAP:') > DSO = ldap.OpenDSObject("","","", 0) > > It errors on the DSO line. What error exactly? Mark From simon.dahlbacka at gmail.com Thu Jun 30 09:38:17 2005 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Thu, 30 Jun 2005 10:38:17 +0300 Subject: [python-win32] detect mapped network path Message-ID: <571247205063000383376501c@mail.gmail.com> Hi, I'm having trouble with the fact that win32file.FindFirstChangeNotification seems to not like network paths. (Or at least that is what I concluded after getting the following traceback) Traceback (most recent call last): File "C:\Python23\lib\threading.py", line 436, in __bootstrap self.run() File "c:\GSP\Instr\Common\Utilities\LogBrowser\LogFileReaderThread.py", line 59, in run False, FILE_NOTIFY_CHANGE_SIZE) error: (1, 'FindFirstChangeNotification', 'Incorrect function.') Now, I what to indicate to the user that this is not possible. A direct UNC path is no problem \\foo\bar\blarg.baz ..but how do i find out if let's say X:\foo\bar\blarg.baz is a local path or in fact a mapped network path? /Simon From radovan.grznarik at gmail.com Thu Jun 30 09:43:35 2005 From: radovan.grznarik at gmail.com (Radovan Grznarik) Date: Thu, 30 Jun 2005 09:43:35 +0200 Subject: [python-win32] EasyDialogs - how to set initial path Message-ID: Hi, I am using EasyDialogs (AskFileForOpen) and I am not able to set the initial open path. I found in Python help that it should be 3rd parameter, then I tried this filename = EasyDialogs.AskFileForOpen("title","*.*","d:\\") but it does not work, and opens dialog in actual directory of running script. os.chdir("d:\\") before AskFileForOpen also does not work. Does anybody have some idea to solve this situation? I would be grateful. Radovan Grznarik From guy.lateur at b-b.be Thu Jun 30 10:52:57 2005 From: guy.lateur at b-b.be (Guy Lateur) Date: Thu, 30 Jun 2005 10:52:57 +0200 Subject: [python-win32] Outlook COM: how to create a MailItem from a .msg file Message-ID: Hi all, I've been writing some code to move some data into and out of Outlook (2003 + Exchange 2003). I have some email .msg files on our file server, and I can't seem to get them back into the Outlook object I need, ie a MailItem. I've tried to use App.CopyFile() to (temporarily) put the file in an OL folder. Problem is, however, this returns a DocumentItem and not a MailItem. Is there any way I could 'cast' this DItem into a MItem? Apparently, OL treats it as any general document - which, btw, shows in the view, too; it has another icon and you have to open it to view it). Or maybe there's another way to open it; I really only need the object in memory. Any ideas? TIA, g PS: This may get double-posted due to some subscription issues I was having earlier. Sorry for the inconvenience. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050630/379125df/attachment.htm From tim.golden at viacom-outdoor.co.uk Thu Jun 30 10:56:33 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu, 30 Jun 2005 09:56:33 +0100 Subject: [python-win32] detect mapped network path Message-ID: <9A28C052FF32734DACB0A288A3533991EBB959@vogbs009.gb.vo.local> [Simon Dahlbacka] | I'm having trouble with the fact that | win32file.FindFirstChangeNotification seems to not like network paths. | (Or at least that is what I concluded after getting the following | traceback) | | Traceback (most recent call last): | File "C:\Python23\lib\threading.py", line 436, in __bootstrap | self.run() | File | "c:\GSP\Instr\Common\Utilities\LogBrowser\LogFileReaderThread.py", | line 59, in run | False, FILE_NOTIFY_CHANGE_SIZE) | error: (1, 'FindFirstChangeNotification', 'Incorrect function.') | | | Now, I what to indicate to the user that this is not possible. A | direct UNC path is no problem \\foo\bar\blarg.baz | | ..but how do i find out if let's say X:\foo\bar\blarg.baz is a local | path or in fact a mapped network path? I don't quite understand why this is happening, but to answer your most direct question, here's a snippet of code which may help: import win32net def mapped_drives (): drives = {} resume = 0 while 1: (_drives, total, resume) = win32net.NetUseEnum (None, 0, resume) for drive in _drives: if drive['local']: yield drive['local'], drive['remote'] if not resume: break for letter, mapping in mapped_drives (): if mapping == r"\\voapps\d": print letter break TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From simon.dahlbacka at gmail.com Thu Jun 30 11:46:47 2005 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Thu, 30 Jun 2005 12:46:47 +0300 Subject: [python-win32] detect mapped network path In-Reply-To: <9A28C052FF32734DACB0A288A3533991EBB959@vogbs009.gb.vo.local> References: <9A28C052FF32734DACB0A288A3533991EBB959@vogbs009.gb.vo.local> Message-ID: <57124720506300246335a1989@mail.gmail.com> On 6/30/05, Tim Golden wrote: > [Simon Dahlbacka] > | I'm having trouble with the fact that > | win32file.FindFirstChangeNotification seems to not like network paths. > | (Or at least that is what I concluded after getting the following > | traceback) > | > | Traceback (most recent call last): > | File "C:\Python23\lib\threading.py", line 436, in __bootstrap > | self.run() > | File > | "c:\GSP\Instr\Common\Utilities\LogBrowser\LogFileReaderThread.py", > | line 59, in run > | False, FILE_NOTIFY_CHANGE_SIZE) > | error: (1, 'FindFirstChangeNotification', 'Incorrect function.') > | > | > | Now, I what to indicate to the user that this is not possible. A > | direct UNC path is no problem \\foo\bar\blarg.baz > | > | ..but how do i find out if let's say X:\foo\bar\blarg.baz is a local > | path or in fact a mapped network path? > > I don't quite understand why this is happening, but to > answer your most direct question, here's a snippet of > code which may help: > > > import win32net > > def mapped_drives (): > drives = {} > resume = 0 > while 1: > (_drives, total, resume) = win32net.NetUseEnum (None, 0, resume) > for drive in _drives: > if drive['local']: > yield drive['local'], drive['remote'] > if not resume: break > > for letter, mapping in mapped_drives (): > if mapping == r"\\voapps\d": > print letter > break > thanks, I tried your code, but it seems win32net.NetUseEnum(None, 0, resume) just returns ([], 0, 0) all the time !?! ..and thus it does not work. An ordinary "net use" issued in the cmd window yields the correct information though.. (they seem to be NetWare Services though, if that matters?) /Simon From tim.golden at viacom-outdoor.co.uk Thu Jun 30 11:57:43 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu, 30 Jun 2005 10:57:43 +0100 Subject: [python-win32] detect mapped network path Message-ID: <9A28C052FF32734DACB0A288A3533991EBB95A@vogbs009.gb.vo.local> [Simon Dahlbacka] | | On 6/30/05, Tim Golden wrote: | > [Simon Dahlbacka] | > | I'm having trouble with the fact that | > | win32file.FindFirstChangeNotification seems to not like | network paths. | > | > I don't quite understand why this is happening, but to | > answer your most direct question, here's a snippet of | > code which may help: | > [.. snip code using NetUseEnum ..] | thanks, I tried your code, but it seems | win32net.NetUseEnum(None, 0, resume) | just returns ([], 0, 0) all the time !?! ..and thus it does not work. | An ordinary "net use" issued in the cmd window yields the correct | information though.. (they seem to be NetWare Services though, if that | matters?) It works ok on my machine, so I can only imagine that the NetWare shares are to blame. If net use is working, it should be possible to parse its output fairly easily. Something like: import os net_use_lines = os.popen ("net use").read ().splitlines () useful_lines = net_use_lines[6:-2] for line in useful_lines: status, letter, share, backend = line[:13], line[13:23], line[23:49], line[49:] if share.startswith (r'\\voapps\d'): print letter break Bit crude, and obviously relies on the layout of the net use output, but at least it's a starting point. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From tim.golden at viacom-outdoor.co.uk Thu Jun 30 12:05:43 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu, 30 Jun 2005 11:05:43 +0100 Subject: [python-win32] detect mapped network path Message-ID: <9A28C052FF32734DACB0A288A3533991EBB95B@vogbs009.gb.vo.local> | [Simon Dahlbacka] | | | | On 6/30/05, Tim Golden wrote: | | > [Simon Dahlbacka] | | > | I'm having trouble with the fact that | | > | win32file.FindFirstChangeNotification seems to not like | | network paths. | | > | | > I don't quite understand why this is happening, but to | | > answer your most direct question, here's a snippet of | | > code which may help: | | > | | [.. snip code using NetUseEnum ..] | | | thanks, I tried your code, but it seems | | win32net.NetUseEnum(None, 0, resume) | | just returns ([], 0, 0) all the time !?! ..and thus it does | not work. | | An ordinary "net use" issued in the cmd window yields the correct | | information though.. (they seem to be NetWare Services | though, if that | | matters?) Or you could use WMI. The only trouble is that it seems dreadfully slow (on my Win2K box): import wmi c = wmi.WMI () for connection in c.Win32_NetworkConnection (LocalName="G:"): print connection.Name break else: print "Not a network drive" No idea how this will interact with NetWare shares. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From sjmachin at lexicon.net Thu Jun 30 13:29:23 2005 From: sjmachin at lexicon.net (John Machin) Date: Thu, 30 Jun 2005 21:29:23 +1000 Subject: [python-win32] EasyDialogs - how to set initial path In-Reply-To: References: Message-ID: <42C3D793.40102@lexicon.net> Radovan Grznarik wrote: >Hi, > >I am using EasyDialogs (AskFileForOpen) and I am not able to set the >initial open path. I found in Python help > Python help describes the *Mac* version; EasyDialogs for Windows by Jimmy Retzlaff has slightly different arguments; there is a readme.txt in .....\site-packages\EasyDialogs -- take a hint :-) > that it should be 3rd >parameter, > *should* be [you reading this, Jimmy???]. Here's another hint - this is _open source_ software, Luke :-) > then I tried this > >filename = EasyDialogs.AskFileForOpen("title","*.*","d:\\") > >but it does not work, and opens dialog in actual directory of running script. > >os.chdir("d:\\") before AskFileForOpen also does not work. > > It works, it just doesn't do what you think it should do. WinDOS has a current directory on *each* drive. Fire up a DOS box, unless you've meddled, the prompt will show C:\something> ... this means the current drive is C: and the current directory on C: is \something. If you type cd d:\, this sets the current directory on D: to \, but you'll notice that your prompt hasn't changed. >Does anybody have some idea to solve this situation? > > Yeah. two ideas, actually: ONE: try: rtfs() except NoSourceError: trashthesucker() TWO: Keyword arguments are a thing of beauty and a joy forever, even when they're in camelCase -- so bloody well stop counting arguments and use them!! >I would be grateful. > >Radovan Grznarik > > > From eric.powell at srs.gov Thu Jun 30 13:45:54 2005 From: eric.powell at srs.gov (eric.powell@srs.gov) Date: Thu, 30 Jun 2005 07:45:54 -0400 Subject: [python-win32] Unable to set an Excel chart's titl ethrough win32com : can you reproduce this problem ? In-Reply-To: <20050630072338538.fabrice_capiez@yahoo.co.jp> Message-ID: This worked for me.....the first function is called to create the copy, the second to format and rename it. def create_graph (filename,graph): #instatiate the Excel object xl = win32com.client.Dispatch("Excel.Application") #Open the workbook wb = xl.Workbooks.Open (filename) sh = wb.Sheets("charttemp")#Select the first worksheet in the workbook try: print graph[6] wb.Sheets("charttemp").Copy(None, After=wb.Sheets(wb.Sheets.Count)) #Rename the new chart and put this value in a return value for subsequent reference wb.Sheets(wb.Sheets.Count).Name = graph[6] xl.ActiveWorkbook.Close(SaveChanges=1) except: xl.ActiveWorkbook.Close(SaveChanges=1) #Quit Excel xl.Quit del xl def format_chart(filename, graph): #instatiate the Excel object xl = win32com.client.Dispatch("Excel.Application") #Open the workbook wb = xl.Workbooks.Open (filename) try: wb.Charts(graph[6]).ChartTitle.Characters.Text=graph[0] wb.Charts(graph[6]).Axes(1).MinimumScale=36530 #wb.Charts(graph[6]).Axes(1).MinimumScaleAuto=True #wb.Charts(graph[6]).Axes(1).MinorUnitsAuto=True #wb.Charts(graph[6]).Axes(1).MajorUnitsAuto=True #wb.Charts(graph[6]).Axes(1).Crosses=xlAutomatic xl.ActiveWorkbook.Close(SaveChanges=1) except: raise xl.ActiveWorkbook.Close(SaveChanges=1) #Quit Excel xl.Quit del xl HTHT Eric Eric B. Powell E&GIS BSRI (803)952-7783 When a true genius appears in this world you may know him by this sign, that the dunces are all in confederacy against him. (Swift) Fabrice Capiez Sent by: python-win32-bounces+eric.powell=srs.gov at python.org 06/29/2005 06:23 PM To Bob Gailer cc python-win32 at python.org Subject Re: [python-win32] Unable to set an Excel chart's titl ethrough win32com : can you reproduce this problem ? > > According to Excel Visual Basic Help: "Characters - Returns a > Characters > object that represents a range of characters within the object text. You > can use the Characters object to format characters within a text string. > > Now look at the Text property "Returns or sets the text for the specified > object. Read-only String for the Range object, read/write String for all > other objects." > > So try chart.ChartTitle.Text ="title" > Actually I tried both ChartTitle.Text and ChartTitle.Characters.Text The VBA macro recorder uses Characters.Text to set the title but at first I thought that this object was only due to my Japanese version of Office, so I tried with both possibilities at every step of my testing. Now I think that the problem lies in copying a chart from one place to another since the problem arises with both Copy and Location methods.. Either there is a problem with win32com, or the com interface of the object is bugged, or I am not using things the right way altogether. Thank you for the insight anyway Fabrice Capiez __________________________________ Save the earth http://pr.mail.yahoo.co.jp/ondanka/ _______________________________________________ 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/20050630/5587950b/attachment.htm From radovan.grznarik at gmail.com Thu Jun 30 14:07:53 2005 From: radovan.grznarik at gmail.com (Radovan Grznarik) Date: Thu, 30 Jun 2005 14:07:53 +0200 Subject: [python-win32] EasyDialogs - how to set initial path In-Reply-To: <42C3D793.40102@lexicon.net> References: <42C3D793.40102@lexicon.net> Message-ID: Thank you very much, I was so close, it's the 4th one:))) Next time before the question I will look at the code. now it works filename = EasyDialogs.AskFileForOpen("","","","d:\\") On 6/30/05, John Machin wrote: > Radovan Grznarik wrote: > > >Hi, > > > >I am using EasyDialogs (AskFileForOpen) and I am not able to set the > >initial open path. I found in Python help > > > *should* be [you reading this, Jimmy???]. Here's another hint - this is > _open source_ software, Luke :-) > > Yeah. two ideas, actually: > ONE: > > try: > rtfs() > except NoSourceError: > trashthesucker() > > TWO: > Keyword arguments are a thing of beauty and a joy forever, even when > they're in camelCase -- so bloody well stop counting arguments and use > them!! > From sjmachin at lexicon.net Thu Jun 30 15:01:47 2005 From: sjmachin at lexicon.net (John Machin) Date: Thu, 30 Jun 2005 23:01:47 +1000 Subject: [python-win32] EasyDialogs - how to set initial path In-Reply-To: References: <42C3D793.40102@lexicon.net> Message-ID: <42C3ED3B.4070308@lexicon.net> Radovan Grznarik wrote: >Thank you very much, I was so close, it's the 4th one:))) >Next time before the question I will look at the code. > >now it works >filename = EasyDialogs.AskFileForOpen("","","","d:\\") > > Bletch. Try this: filename = EasyDialogs.AskFileForOpen(defaultLocation="d:\\") (Re)read this: Keyword arguments are a thing of beauty and a joy forever, even when they're in camelCase -- so bloody well stop counting arguments and use them!! From guy.lateur at pandora.be Thu Jun 30 07:31:16 2005 From: guy.lateur at pandora.be (guy lateur) Date: Thu, 30 Jun 2005 07:31:16 +0200 Subject: [python-win32] Outlook COM: how to create a MailItem from a .msg file Message-ID: <001201c57d34$eff4dae0$0611e0d5@thuisbak> Hi all, I've been writing some code to move some data into and out of Outlook (2003 + Exchange 2003). I have some email .msg files on our file server, and I can't seem to get them back into the Outlook object I need, ie a MailItem. I've tried to use App.CopyFile() to (temporarily) put the file in an OL folder. Problem is, however, this returns a DocumentItem and not a MailItem. Is there any way I could 'cast' this DItem into a MItem? Apparently, OL treats it as any general document - which, btw, shows in the view, too; it has another icon and you have to open it to view it). Or maybe there's another way to open it; I really only need the object in memory. Any ideas? TIA, g -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050630/d15a160a/attachment-0001.htm From Benjamin.Schollnick at xerox.com Thu Jun 30 17:36:26 2005 From: Benjamin.Schollnick at xerox.com (Schollnick, Benjamin) Date: Thu, 30 Jun 2005 11:36:26 -0400 Subject: [python-win32] LsaLookupNames2 Message-ID: <266589E1B9392B4C9195CC25A07C73B90183CEBD@usa0300ms04.na.xerox.net> Thomas, Figured out a relatively simple way to deal with this TypeLib issue regarding Win XP & Win 2000.... 1) I created a py2exe "bundle" on a Windows 2000 system... 2) Since the Typelib issue was specific to win32com, I removed all NON win32com files from the 2000 created library.zip file. And renamed the zip to "Win2000_specific.zip". 3) I added the following code the absolute start of the application. import sys windows_version = sys.getwindowsversion() if windows_version[0] ==5 and windows_version[1] <> 1: # print "Windows 2000" # print "before: ",sys.path sys.path.insert (0, "win2000_specific.zip") else: pass # Windows XP The idea is that the zip file contains only Windows 2000 specific files, and since it is now at the absolute beginning of the sys.path the "Windows 2000 specific patches" will be found in the namespace before the "Win XP" library. But anything that is in common will eventually reach the standard library.zip.... The only drawback is the need to have a 2000 system to compile the win32com typelibs... - Benjamin > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org] On Behalf Of Thomas Heller > Sent: Tuesday, June 21, 2005 2:37 PM > To: python-win32 at python.org > Subject: Re: [python-win32] LsaLookupNames2 > > > "Schollnick, Benjamin" writes: > > > It's okay.... I just miss McMillian's installer... > > It's unsupported, so I've moved to py2exe... But > > McMillian's package seemed to be better with > > the dependency issues.... And offered a few > > features that don't exist in py2exe... (Or at least > > are not easily handled in py2exe...) > > > > On the plus side, py2exe has handled packages lately > > that I just could not get McMillian's installer > > to work reliably with... Which is why I switched... > > I always wondered why no one picked up McMillan and continued > to develop or at least maintain it - it's open source after > all, isn't it? > > Thomas > > PS: netapi32.dll is in the list of dlls to exclude in the > py2exe cvs version. No date yet for a new release - but you > can easily insert it in the current version yourself, the > list is in lib/site-packages/py2exe/build_exe.py, should be > easy to find. > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From jimmy at retzlaff.com Thu Jun 30 18:45:42 2005 From: jimmy at retzlaff.com (Jimmy Retzlaff) Date: Thu, 30 Jun 2005 09:45:42 -0700 Subject: [python-win32] EasyDialogs - how to set initial path Message-ID: John Machin wrote: > > Radovan Grznarik wrote: > > >Hi, > > > >I am using EasyDialogs (AskFileForOpen) and I am not able to set the > >initial open path. I found in Python help > > > Python help describes the *Mac* version; EasyDialogs for Windows by > Jimmy Retzlaff has slightly different arguments; there is a readme.txt > in .....\site-packages\EasyDialogs -- take a hint :-) > > > that it should be 3rd > >parameter, > > > *should* be [you reading this, Jimmy???]. Here's another hint - this is > _open source_ software, Luke :-) I'm reading this now. :) Thanks for copying me. Actually on the Mac it is not the 3rd parameter either. It is expected that keyword arguments will be used in all but the most basic cases. The Mac docs actually refer you to the source more than once just because of things like this. For the parameters supported, EasyDialogs for Windows uses the same order as the current Mac version. For reference you can see the Mac EasyDialogs sources at: http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Lib/plat-ma c/EasyDialogs.py?view=auto > > then I tried this > > > >filename = EasyDialogs.AskFileForOpen("title","*.*","d:\\") > > > >but it does not work, and opens dialog in actual directory of running > script. > > > >os.chdir("d:\\") before AskFileForOpen also does not work. > > > > > It works, it just doesn't do what you think it should do. WinDOS has a > current directory on *each* drive. Fire up a DOS box, unless you've > meddled, the prompt will show C:\something> ... this means the current > drive is C: and the current directory on C: is \something. If you type > cd d:\, this sets the current directory on D: to \, but you'll notice > that your prompt hasn't changed. > > >Does anybody have some idea to solve this situation? > > > > > > Yeah. two ideas, actually: > ONE: > > try: > rtfs() > except NoSourceError: > trashthesucker() > > TWO: > Keyword arguments are a thing of beauty and a joy forever, even when > they're in camelCase -- so bloody well stop counting arguments and use > them!! Don't you mean "**especially** when they're in camelCase"? :) You should definitely use: filename = EasyDialogs.AskFileForOpen("title","*.*", defaultLocation="d:\\") Just reiterating what John was saying... According to the source to both the Mac and Windows versions, only the order of the first two parameters to AskFileForOpen can be relied upon. So you don't want to rely on the fact that it is currently the fourth argument. Also, using keyword arguments makes the code easier to read. If you aren't familiar with keyword arguments, here are a few words about them: http://jefferson.blogs.com/jp/2003/04/more_python_key.html Jimmy