From skippy.hammond at gmail.com Tue Sep 1 15:12:51 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 01 Sep 2009 23:12:51 +1000 Subject: [python-win32] bug with CastTo and py2exe In-Reply-To: References: Message-ID: <4A9D1DD3.90402@gmail.com> On 31/08/2009 10:39 AM, Patricio Stegmann wrote: > Hi to all, > > I am encountering a problem which seems like a bug when using the CastTo > method. Ack - for the benefit of others, this was 'silently' cross-posted to the py2exe mailing list with no indication it has been asked elsewhere - it is being followed up on that list... Mark From skippy.hammond at gmail.com Tue Sep 1 15:10:52 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 01 Sep 2009 23:10:52 +1000 Subject: [python-win32] Exception when manipulating paths containing non-ASCII characters In-Reply-To: References: <20090828110410.9AB2F11EB638@montanaro.dyndns.org> Message-ID: <4A9D1D5C.7050102@gmail.com> On 28/08/2009 10:38 PM, Massa, Harald Armin wrote: > Skip, > > self.unique_name = os.path.join(dirname, > "%s.%s%s" % (self.hostname, > tname, > self.pid)) > > raising a UnicodeDecodeError: > > UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in > position 3: ordinal not in range(128) > > on a WIndows system when the hostname contains non-ASCII data. (All the > other elements involved in the os.path.join call are ASCII or numbers.) > > > A quite common pain within the non-ASCII-World of Python on Windows > programming. Actually, Windows is better than many in this regard - at least the file-system has a canonical encoding! > The quickest soliution I found is to switch the sys.setdefaultencoding > to UTF-8, follower on slot 2 is to switch default-encoding to latin-1. > > Both solutions are productive in real world projects for 5 (utf-8) and 9 > years (latin-1) with various apps by me; and a similiar solution is > reported by Chris Withers for running productive for 5 years. > > Both solutions were called being highly dangerous by MvL and others on > c.p.dev; esp. pointing out problems that can happen concerning hashes / > dict-keys not comparing as expected. Yes, this is very dangerous advice. Chris is dealing with Zope which has long been confused wrt unicode, but there simply is no single encoding suitable as a default if you have code confused about unicode. In skip's case, the closest advice to this should be to use the 'mbcs' encoding - functions which are not unicode-aware (either in pywin32 or python itself) which call the win32 api will return strings in the 'mbcs' encoding. Ideally we would work out where such a string is originating and convert it to unicode as soon as it is received. For example, consider the tempfile module: >>> tempfile.gettempdir() 'c:\\users\\skip\\appdata\\local\\temp' >>> Note the result is a string and not unicode. If logged in with a user with an extended char in their username, you may well find an invalid ascii string is returned (I'm not at my main PC, so can't quickly demonstrate). Attempting to pass such a string, along with a unicode arg as received from some other unicode-aware function, to os.path.joim() will then cause such an error. In that case the correct solution would be to dec0de the string as soon as gettempdir() is called, as only at that point can you be sure what the encoding is. HTH, Mark From jeffpeery at yahoo.com Wed Sep 2 20:42:11 2009 From: jeffpeery at yahoo.com (Jeff Peery) Date: Wed, 2 Sep 2009 11:42:11 -0700 (PDT) Subject: [python-win32] dispatchwithevents not catching events Message-ID: <132851.29010.qm@web43132.mail.sp1.yahoo.com> Hello, I'm having trouble catching events when I use dispatchwithevents. ? I have a wxapp that?uses com?and I catch OPCDataChangeEvents (OPC, OLE for process automation) from an opc server. things work quite well in this case, i.e., I?am able to?catch the data change events.? ? The problem happened when I?separated my logic from the wxGUI (I'm trying to keep my code clean and maintainable). So now I have a wxApp, within the wxApp is a thread that runs my logic,?and within this thread I try to catch the OPCDataChangeEvents. In this case, it appears that the OPC thread is working properly, ie. if I test writeItem or readItem or connect or disconnect everything works well... until I try to catch the datachange events. I don't seem to catch them in this configuration. ? What might be happening here? Should this work? If so how do I fix this? ? thanks, Jeff ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From sbonam at gmail.com Thu Sep 3 19:28:00 2009 From: sbonam at gmail.com (Steve Bonam) Date: Thu, 3 Sep 2009 13:28:00 -0400 Subject: [python-win32] Ctypes and PdhMakeCounterPath Message-ID: <2ee3028b0909031028l37cc9c97if22fc403892705b8@mail.gmail.com> I'm trying to learn ctypes so I figured I'd reproduce something I did earlier with pywin32 but it seems I fail it. I'm sure I'm missing something here PdhMakeCounterPath Doc on msdn: http://msdn.microsoft.com/en-us/library/aa372649%28VS.85%29.aspx [code] from ctypes import * from ctypes.wintypes import * pdh = windll.pdh class PDH_COUNTER_PATH_ELEMENTS_A(Structure): _fields_ = [("szMachineName",LPSTR), ("szObjectName",LPSTR), ("szInstanceName", LPSTR), ("szParentInstance",LPSTR), ("dwInstanceIndex", DWORD), ("szCounterName",LPSTR)] pCounterPathElements = PDH_COUNTER_PATH_ELEMENTS_A(LPSTR(None), LPSTR('Network Interface'), LPSTR("Realtek RTL8168C[P]_8111C[P] Family PCI-E GBE NIC") , LPSTR(None), DWORD(-1), LPSTR("Bytes Received/sec")) szFullPathBuffer = LPCSTR(0) pcchbufferSize = DWORD(0) dwFlags = DWORD(0) result = pdh.PdhMakeCounterPathA(pCounterPathElements, pointer(szFullPathBuffer), pointer(pcchbufferSize), dwFlags) #szFullPathBuffer = create_string_buffer(pcchbufferSize.value) #result = pdh.PdhMakeCounterPathA(pCounterPathElements, # pointer(szFullPathBuffer), # pointer(pcchbufferSize), dwFlags) [/code] this is where I am stuck: >>> result -2147481646 or 0x800007d2L Which is PDH_MORE_DATA but pcchbufferSize does not change (i'm pretty sure it's supposed to be updated with the correct amount to allocate for szFullPathBuffer) and upon running the function again python freezes and windows kills it (probably access violation?). -- -steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Sep 3 20:21:48 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 03 Sep 2009 11:21:48 -0700 Subject: [python-win32] Ctypes and PdhMakeCounterPath In-Reply-To: <2ee3028b0909031028l37cc9c97if22fc403892705b8@mail.gmail.com> References: <2ee3028b0909031028l37cc9c97if22fc403892705b8@mail.gmail.com> Message-ID: <4AA0093C.1050606@probo.com> Steve Bonam wrote: > > I'm trying to learn ctypes so I figured I'd reproduce something I did earlier with pywin32 but it seems I fail it. > I'm sure I'm missing something here > > PdhMakeCounterPath Doc on msdn: http://msdn.microsoft.com/en-us/library/aa372649%28VS.85%29.aspx > > [code] > > from ctypes import * > from ctypes.wintypes import * > pdh = windll.pdh > class PDH_COUNTER_PATH_ELEMENTS_A(Structure): > _fields_ = [("szMachineName",LPSTR), > ("szObjectName",LPSTR), > ("szInstanceName", LPSTR), > ("szParentInstance",LPSTR), > ("dwInstanceIndex", DWORD), > ("szCounterName",LPSTR)] > > pCounterPathElements = PDH_COUNTER_PATH_ELEMENTS_A(LPSTR(None), LPSTR('Network Interface'), LPSTR("Realtek RTL8168C[P]_8111C[P] Family PCI-E GBE NIC") , LPSTR(None), DWORD(-1), LPSTR("Bytes Received/sec")) > szFullPathBuffer = LPCSTR(0) > pcchbufferSize = DWORD(0) > > dwFlags = DWORD(0) > > result = pdh.PdhMakeCounterPathA(pCounterPathElements, > pointer(szFullPathBuffer), > pointer(pcchbufferSize), dwFlags) > I get an error when I run this: C:\tmp>x.py Traceback (most recent call last): File "C:\tmp\x.py", line 32, in pointer(pcchbufferSize), dwFlags) ValueError: Procedure probably called with too many arguments (20 bytes in excess) The reason is that Python is trying to pass the elements of the tuple as individual parameters, resulting in too many arguments. You need "pointer(pCounterPathElements)". After that, pcchbufferSize is 89 for me. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From sbonam at gmail.com Fri Sep 4 01:38:51 2009 From: sbonam at gmail.com (Steve Bonam) Date: Thu, 3 Sep 2009 19:38:51 -0400 Subject: [python-win32] Ctypes and PdhMakeCounterPath Message-ID: <2ee3028b0909031638g5dd3509fmb9207567aa25a71f@mail.gmail.com> That's simple and intersting, I mistakenly thought it was being passed as a C structure with the python class as wrapper for it. Thank you. On Thu, Sep 3, 2009 at 2:21 PM, Tim Roberts wrote: > Steve Bonam wrote: > > > > I'm trying to learn ctypes so I figured I'd reproduce something I did > earlier with pywin32 but it seems I fail it. > > I'm sure I'm missing something here > > > > PdhMakeCounterPath Doc on msdn: > http://msdn.microsoft.com/en-us/library/aa372649%28VS.85%29.aspx > > > > [code] > > > > from ctypes import * > > from ctypes.wintypes import * > > pdh = windll.pdh > > class PDH_COUNTER_PATH_ELEMENTS_A(Structure): > > _fields_ = [("szMachineName",LPSTR), > > ("szObjectName",LPSTR), > > ("szInstanceName", LPSTR), > > ("szParentInstance",LPSTR), > > ("dwInstanceIndex", DWORD), > > ("szCounterName",LPSTR)] > > > > pCounterPathElements = PDH_COUNTER_PATH_ELEMENTS_A(LPSTR(None), > LPSTR('Network Interface'), LPSTR("Realtek RTL8168C[P]_8111C[P] Family PCI-E > GBE NIC") , LPSTR(None), DWORD(-1), LPSTR("Bytes Received/sec")) > > szFullPathBuffer = LPCSTR(0) > > pcchbufferSize = DWORD(0) > > > > dwFlags = DWORD(0) > > > > result = pdh.PdhMakeCounterPathA(pCounterPathElements, > > pointer(szFullPathBuffer), > > pointer(pcchbufferSize), dwFlags) > > > > I get an error when I run this: > > C:\tmp>x.py > Traceback (most recent call last): > File "C:\tmp\x.py", line 32, in > pointer(pcchbufferSize), dwFlags) > ValueError: Procedure probably called with too many arguments (20 bytes > in excess) > > The reason is that Python is trying to pass the elements of the tuple as > individual parameters, resulting in too many arguments. You need > "pointer(pCounterPathElements)". > > After that, pcchbufferSize is 89 for me. > > -- > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Sep 4 02:04:59 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 03 Sep 2009 17:04:59 -0700 Subject: [python-win32] Ctypes and PdhMakeCounterPath In-Reply-To: <2ee3028b0909031638g5dd3509fmb9207567aa25a71f@mail.gmail.com> References: <2ee3028b0909031638g5dd3509fmb9207567aa25a71f@mail.gmail.com> Message-ID: <4AA059AB.2090801@probo.com> Steve Bonam wrote: > That's simple and intersting, I mistakenly thought it was being passed > as a C structure with the python class as wrapper for it. Thank you. Ctypes really tries to map C conventions pretty closely. Because it is possible to pass a C structure by value (that is, directly on the stack, not through a pointer), ctypes also supports it. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From sbonam at gmail.com Fri Sep 4 03:28:30 2009 From: sbonam at gmail.com (Steve Bonam) Date: Thu, 3 Sep 2009 21:28:30 -0400 Subject: [python-win32] Ctypes and PdhMakeCounterPath In-Reply-To: <4AA059AB.2090801@probo.com> References: <2ee3028b0909031638g5dd3509fmb9207567aa25a71f@mail.gmail.com> <4AA059AB.2090801@probo.com> Message-ID: <2ee3028b0909031828m2dd653bey1d85f54a823ccd92@mail.gmail.com> I won't lie that made my brain hurt for a bit but I think I understand what happened there. Thanks for explaining On Thu, Sep 3, 2009 at 8:04 PM, Tim Roberts wrote: > > Steve Bonam wrote: > > That's simple and intersting, I mistakenly thought it was being passed > > as a C structure with the python class as wrapper for it. Thank you. > > Ctypes really tries to map C conventions pretty closely. ?Because it is > possible to pass a C structure by value (that is, directly on the stack, > not through a pointer), ctypes also supports it. > > -- > 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 chungdr at gmail.com Fri Sep 4 23:56:46 2009 From: chungdr at gmail.com (Dennis Chung) Date: Fri, 4 Sep 2009 17:56:46 -0400 Subject: [python-win32] Problems with QuickTest Automation Object Model Message-ID: Hi, I am having problems using win32com.client with the HP QTP COM libraries. QTP is just another windows based application like Excel that exposes a COM type library for automation. In vbscript the COM library works fine as follows: Set qtp = CreateObject("QuickTest.Application") qtp.Launch MsgBox qtp.Launched ' Prints True Using python: >>> import win32com.client >>> o = win32com.client.Dispatch("QuickTest.Application") >>> o.Launch > >>> o.Launched False >>> Any idea as to why the application fails to launch when invoked with the python com libraries? In both instances I have ensured the application was closed and no processes remained in task manager. This does not appear to be a QTP issue since the COM libraries are fine when invoked via vbscript. I have installed Python 3.1.1 on win32 along with pywin32-214. I am using QTP 9.5. Any help is greatly appreciated. Best Regards, Dennis -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sat Sep 5 02:11:06 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 04 Sep 2009 17:11:06 -0700 Subject: [python-win32] Problems with QuickTest Automation Object Model In-Reply-To: References: Message-ID: <4AA1AC9A.4080508@probo.com> Dennis Chung wrote: > Hi, > > I am having problems using win32com.client with the HP QTP COM > libraries. QTP is just another windows based application like Excel > that exposes a COM type library for automation. > > In vbscript the COM library works fine as follows: > > Set qtp = CreateObject("QuickTest.Application") > qtp.Launch > MsgBox qtp.Launched ' Prints True > > > Using python: > >>> import win32com.client > >>> o = win32com.client.Dispatch("QuickTest.Application") > >>> o.Launch > > > >>> o.Launched > False > >>> > > Any idea as to why the application fails to launch when invoked with > the python com libraries? Yes, because you are not invoking Launch You are printing the address of Launch. VB does not require parens on a function with no parameters. Python does. Use this: o.Launch( ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From efotinis at yahoo.com Sat Sep 5 13:06:23 2009 From: efotinis at yahoo.com (Elias Fotinis) Date: Sat, 5 Sep 2009 14:06:23 +0300 Subject: [python-win32] win32api.FindWindow returns 0 sometimes Message-ID: <376B08E71ABB42A9BB7F00EADD2912D5@efcore> Running Vista x64, PythonWin 2.6.1 x64, pywin32 214 x64. win32api.FindWindow sometimes returns 0 instead of raising an exception. I suppose that's a bug and will submit it if so. Can anyone verify? I tried peeking into the code, but I have no clue about SWIG. :o) Example code: import win32api import subprocess subprocess.Popen('notepad') while True: try: w = win32gui.FindWindow('Notepad', None) print w if w: break except win32gui.error: print 'not found' Sometimes it works as expected: not found not found not found 10684490 but sometimes it produces this: not found not found not found 0 0 2623920 From mc at mclaveau.com Sun Sep 6 08:45:22 2009 From: mc at mclaveau.com (Michel Claveau) Date: Sun, 6 Sep 2009 08:45:22 +0200 Subject: [python-win32] win32api.FindWindow returns 0 sometimes In-Reply-To: <376B08E71ABB42A9BB7F00EADD2912D5@efcore> References: <376B08E71ABB42A9BB7F00EADD2912D5@efcore> Message-ID: <6DD62C33293340DE90E480ADD9ACD9A5@MCI1330> Hi! Try to put a time.sleep(0.001) inside the while, for give some time to work to Windows... @+ -- Michel Claveau From skippy.hammond at gmail.com Sun Sep 6 13:42:51 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sun, 06 Sep 2009 21:42:51 +1000 Subject: [python-win32] win32api.FindWindow returns 0 sometimes In-Reply-To: <376B08E71ABB42A9BB7F00EADD2912D5@efcore> References: <376B08E71ABB42A9BB7F00EADD2912D5@efcore> Message-ID: <4AA3A03B.1080809@gmail.com> On 5/09/2009 9:06 PM, Elias Fotinis wrote: > Running Vista x64, PythonWin 2.6.1 x64, pywin32 214 x64. > > win32api.FindWindow sometimes returns 0 instead of raising an exception. > I suppose that's a bug and will submit it if so. Can anyone verify? I > tried peeking into the code, but I have no clue about SWIG. :o) Yes, this looks like a bug - the generated swig code also checks if GetLastError()==0 before deciding if to return the 0 or raise an exception, and nothing in the docs imply this is correct... Cheers, Mark From stef.mientki at gmail.com Mon Sep 7 10:24:17 2009 From: stef.mientki at gmail.com (Stef Mientki) Date: Mon, 07 Sep 2009 10:24:17 +0200 Subject: [python-win32] how to find / kill child process ? Message-ID: <4AA4C331.7070104@gmail.com> hello, I start a number of python files with subproces.Popen and keep a list of these processes. Something like this: arguments = [ 'python', self.Source_File ] Proces = subprocess.Popen ( arguments, cwd = source_path , shell = ( os.name == 'nt') ) self.Desktop_Processes.append ( Proces ) Now when I close my program, I also want to kill all the processes this program has launched. The processes that I've started, always consists of a command window (invisible), and Python as a child process of that command window. Now killing the the processes in my list, only kills the command windows and not the python python process. So how can I kill a process and all it's child processes ? thanks, Stef Mientki From jcanto at hispasec.com Mon Sep 7 10:27:08 2009 From: jcanto at hispasec.com (Julio Canto) Date: Mon, 07 Sep 2009 10:27:08 +0200 Subject: [python-win32] how to find / kill child process ? In-Reply-To: <4AA4C331.7070104@gmail.com> References: <4AA4C331.7070104@gmail.com> Message-ID: <4AA4C3DC.1020500@hispasec.com> Stef Mientki escribi?: > hello, > > I start a number of python files with subproces.Popen > and keep a list of these processes. > Something like this: > > arguments = [ 'python', self.Source_File ] > Proces = subprocess.Popen ( arguments, > cwd = source_path , > shell = ( os.name == 'nt') ) > > self.Desktop_Processes.append ( Proces ) > > Now when I close my program, > I also want to kill all the processes this program has launched. > > The processes that I've started, > always consists of a command window (invisible), > and Python as a child process of that command window. > > Now killing the the processes in my list, > only kills the command windows > and not the python python process. > > So how can I kill a process and all it's child processes ? > > t You can check the process parent id, and create the process tree so you can kill them all. -- Regards, Julio Canto | VirusTotal.com | Hispasec Sistemas Lab | Tlf: +34.902.161.025 | Fax: +34.952.028.694 | PGP Key ID: EF618D2B | jcanto at hispasec.com From jcanto at hispasec.com Mon Sep 7 10:51:51 2009 From: jcanto at hispasec.com (Julio Canto) Date: Mon, 07 Sep 2009 10:51:51 +0200 Subject: [python-win32] how to find / kill child process ? In-Reply-To: <4AA4C331.7070104@gmail.com> References: <4AA4C331.7070104@gmail.com> Message-ID: <4AA4C9A7.3080003@hispasec.com> Stef Mientki escribi?: > hello, > > I start a number of python files with subproces.Popen > and keep a list of these processes. > Something like this: > > arguments = [ 'python', self.Source_File ] > Proces = subprocess.Popen ( arguments, > cwd = source_path , > shell = ( os.name == 'nt') ) > > self.Desktop_Processes.append ( Proces ) > > Now when I close my program, > I also want to kill all the processes this program has launched. > > The processes that I've started, > always consists of a command window (invisible), > and Python as a child process of that command window. > > Now killing the the processes in my list, > only kills the command windows > and not the python python process. > > So how can I kill a process and all it's child processes ? import win32com.client WMI = win32com.client.GetObject('winmgmts:') processes = WMI.InstancesOf('Win32_Process') for process in processes: pid = process.Properties_('ProcessID').Value parent = process.Properties_('ParentProcessId') print pid, parent -- Regards, Julio Canto | VirusTotal.com | Hispasec Sistemas Lab | Tlf: +34.902.161.025 | Fax: +34.952.028.694 | PGP Key ID: EF618D2B | jcanto at hispasec.com From stef.mientki at gmail.com Mon Sep 7 12:10:42 2009 From: stef.mientki at gmail.com (Stef Mientki) Date: Mon, 07 Sep 2009 12:10:42 +0200 Subject: [python-win32] how to find / kill child process ? In-Reply-To: <4AA4C9A7.3080003@hispasec.com> References: <4AA4C331.7070104@gmail.com> <4AA4C9A7.3080003@hispasec.com> Message-ID: <4AA4DC22.8030608@gmail.com> thanks Julio, that works perfectly. One small note: the parent seems to be an instance, so to compare it with a integer PID (as returned from the Popen call, you have to take the Value property, like this: import win32com.client WMI = win32com.client.GetObject('winmgmts:') processes = WMI.InstancesOf('Win32_Process') for process in processes: pid = process.Properties_('ProcessID').Value parent = process.Properties_('ParentProcessId').Value print pid, parent thanks, Stef Julio Canto wrote: > Stef Mientki escribi?: > >> hello, >> >> I start a number of python files with subproces.Popen >> and keep a list of these processes. >> Something like this: >> >> arguments = [ 'python', self.Source_File ] >> Proces = subprocess.Popen ( arguments, >> cwd = source_path , >> shell = ( os.name == 'nt') ) >> >> self.Desktop_Processes.append ( Proces ) >> >> Now when I close my program, >> I also want to kill all the processes this program has launched. >> >> The processes that I've started, >> always consists of a command window (invisible), >> and Python as a child process of that command window. >> >> Now killing the the processes in my list, >> only kills the command windows >> and not the python python process. >> >> So how can I kill a process and all it's child processes ? >> > > import win32com.client > > WMI = win32com.client.GetObject('winmgmts:') > processes = WMI.InstancesOf('Win32_Process') > for process in processes: > pid = process.Properties_('ProcessID').Value > parent = process.Properties_('ParentProcessId') > print pid, parent > > > > > From jcanto at hispasec.com Mon Sep 7 12:22:13 2009 From: jcanto at hispasec.com (Julio Canto) Date: Mon, 07 Sep 2009 12:22:13 +0200 Subject: [python-win32] how to find / kill child process ? In-Reply-To: <4AA4DC22.8030608@gmail.com> References: <4AA4C331.7070104@gmail.com> <4AA4C9A7.3080003@hispasec.com> <4AA4DC22.8030608@gmail.com> Message-ID: <4AA4DED5.9040700@hispasec.com> Stef Mientki escribi?: > thanks Julio, > > that works perfectly. > One small note: > the parent seems to be an instance, > so to compare it with a integer PID (as returned from the Popen call, > you have to take the Value property, like this: > > Yep, I only pretended to show it as a simple example :) Thans a lot anyway for the hint. -- Regards, Julio Canto | VirusTotal.com | Hispasec Sistemas Lab | Tlf: +34.902.161.025 | Fax: +34.952.028.694 | PGP Key ID: EF618D2B | jcanto at hispasec.com From arve.knudsen at gmail.com Mon Sep 7 15:00:34 2009 From: arve.knudsen at gmail.com (Arve Knudsen) Date: Mon, 7 Sep 2009 15:00:34 +0200 Subject: [python-win32] PyIDispatch representinggl DATE Message-ID: Hi I am trying to query the PasswordLastChanged property, which is supposed to be of the DATE type, of a PyIADsUser object. Calling Get('passwordLastChanged') I get a PyIDispatch object. How can I turn the latter into a sensible Python representation (e.g. datetime)? Thanks, Arve -------------- next part -------------- An HTML attachment was scrubbed... URL: From arve.knudsen at gmail.com Mon Sep 7 16:16:02 2009 From: arve.knudsen at gmail.com (Arve Knudsen) Date: Mon, 7 Sep 2009 16:16:02 +0200 Subject: [python-win32] How to build installer? Message-ID: Hi How do I build an installer from pywin32 sources? When I try the 'bdist_msi' command to setup.py it seems to attempt an installation, since it complains that it can't install pythoncom26.dll (due to it already being in use). Also, I get an error from distutils complaining that the package's version number (214) is invalid. Thanks, Arve -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Sep 8 00:19:49 2009 From: timr at probo.com (Tim Roberts) Date: Mon, 07 Sep 2009 15:19:49 -0700 Subject: [python-win32] how to find / kill child process ? In-Reply-To: <4AA4C331.7070104@gmail.com> References: <4AA4C331.7070104@gmail.com> Message-ID: <4AA58705.8050606@probo.com> Stef Mientki wrote: > hello, > > I start a number of python files with subproces.Popen > and keep a list of these processes. > Something like this: > > arguments = [ 'python', self.Source_File ] > Proces = subprocess.Popen ( arguments, > cwd = source_path , > shell = ( os.name == 'nt') ) > > self.Desktop_Processes.append ( Proces ) > > Now when I close my program, > I also want to kill all the processes this program has launched. > > The processes that I've started, > always consists of a command window (invisible), > and Python as a child process of that command window. If you don't want the command window at all, just call "pythonw" instead of "python". Then, you should be able to kill the Python process directly. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From arve.knudsen at gmail.com Tue Sep 8 13:55:37 2009 From: arve.knudsen at gmail.com (Arve Knudsen) Date: Tue, 8 Sep 2009 13:55:37 +0200 Subject: [python-win32] How to wrap VARIANT_BOOL Message-ID: Hi I don't know if this will get me much in terms of a response, considering my questions about PyWin32 and ADSI up till now, but I'll give it a shot :p I am trying to extend win32com.adsi.PyIADsUser (through PyIADsUser.i) with a couple of methods that use the VARIANT_BOOL type, how can I wrap this (VARIANT_BOOL) in PyWin32/swig? Thanks in advance, Arve -------------- next part -------------- An HTML attachment was scrubbed... URL: From chungdr at gmail.com Tue Sep 8 16:34:02 2009 From: chungdr at gmail.com (Dennis Chung) Date: Tue, 8 Sep 2009 10:34:02 -0400 Subject: [python-win32] Problems with QuickTest Automation Object Model Message-ID: Thanks Tim. I apologize in advance if this doesnt thread properly; I'm on the digest list and am not sure how to properly reply to individual messages. I am now able to launch the application via python win32com however I am still having an issue. The QuickTest.Application object allows me to run open test scripts and run as follows: import win32com.client o = win32com.client.Dispatch("QuickTest.Application") o.Launch() o.Open("V:\tests\mytest") o.Test.Run(o.Test) In vbscript, I am able to call the Run method of the Test object without any parameters and the it appears that "self" is passed implicitly. Calling Run without any parameters in python yields: >>>o.Test.Run() Traceback (most recent call last): File "", line 1, in o.Test.Run() File ">", line 3, in Run TypeError: The Python instance can not be converted to a COM object Could it be that python is passing the python instance to Run method rather than the COM instance? The Run Method documentation is as follows: *Syntax* object.Run [ResultsOptions], [WaitOnReturn], [Parameters] *Syntax Details* *Argument - Description * object - An expression evaluating to an object of type Test. ResultsOptions Optional. - A RunResultsOptions object. If no RunResultsOptions object is specified, the default value for the RunResultsOptions object is used (the results are saved in a unique folder within the test's or component's folder). WaitOnReturn Optional. - A Boolean value. Indicates whether the Test.Run statement waits until the end of the of the run before performing the next statement in the automation script. Default=True. Note: Set this property to False only if the steps following the Test.Run statement can be performed even while the test or component is running. Parameters Optional. - A Parameters object. The Parameters collection containing the values you want to pass to the test or component. Return Type None -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Sep 8 19:36:11 2009 From: timr at probo.com (Tim Roberts) Date: Tue, 08 Sep 2009 10:36:11 -0700 Subject: [python-win32] Problems with QuickTest Automation Object Model In-Reply-To: References: Message-ID: <4AA6960B.7000709@probo.com> Dennis Chung wrote: > Thanks Tim. > > I apologize in advance if this doesnt thread properly; I'm on the > digest list and am not sure how to properly reply to individual messages. > > I am now able to launch the application via python win32com however I > am still having an issue. The QuickTest.Application object allows me > to run open test scripts and run as follows: > > import win32com.client > o = win32com.client.Dispatch("QuickTest.Application") > o.Launch() > o.Open("V:\tests\mytest") > o.Test.Run(o.Test) I hope that's not really what your code says, because the file name you are passing contains a "tab" character. You need one of these instead: o.Open( "V:/tests/mytest" ) o.Open( r"V:\tests\mytest" ) o.Open( "V:\\tests\\mytest" ) > In vbscript, I am able to call the Run method of the Test object > without any parameters and the it appears that "self" is passed > implicitly. Calling Run without any parameters in python yields: > > >>>o.Test.Run() > Traceback (most recent call last): > File "", line 1, in > o.Test.Run() > File ">", line 3, in Run > TypeError: The Python instance can not be converted to a COM object > > Could it be that python is passing the python instance to Run method > rather than the COM instance? No. The more likely answer is that the Run command failed because the file name was invalid, so o.Test is not returning a real object. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From chungdr at gmail.com Tue Sep 8 20:19:47 2009 From: chungdr at gmail.com (Dennis Chung) Date: Tue, 8 Sep 2009 14:19:47 -0400 Subject: [python-win32] Problems with QuickTest Automation Object Model In-Reply-To: <4AA6960B.7000709@probo.com> References: <4AA6960B.7000709@probo.com> Message-ID: I am running this code on the python shell the test was loaded successfully. I will illustrate my problem more clearly. I currently have a work around by explicitly passing "self" but I'd like to better understand the issue. As you can probably tell, I am new to python. The following code allows me to successfully run a test: --- import win32com.client o = win32com.client.Dispatch("QuickTest.Application") o.Launch() # i've escaped the \ this time but it also worked the first time o.Open("C:\\Documents and Settings\\DChung\\Desktop\\XMLRequest") o.Visible = True o.Test.Run(o.Test) # this works fine, o.Test.Run() does not. --- Using "o.Test.Run()" I get the following: Traceback (most recent call last): File "", line 1, in o.Test.Run() File "C:\Python31\lib\site-packages\win32com\gen_py\5BF80934-AEDA-4463-B199-B83285266562x0x1x0.py", line 1717, in Run , WaitOnReturn, Parameters) TypeError: The Python instance can not be converted to a COM object According to the documentation I should be able to invoke Run() with no parameters (See below). I have explicitly passed "self" to the Run method otherwise I run into the above problem. When invoking other methods from this library, i.e. Launch() and Open(), I do not need to pass "self". I have since run makepy but the original error I received was: Traceback (most recent call last): File "C:\Documents and Settings\DChung\Desktop\qtptest.py", line 9, in o.Test.Run() File ">", line 3, in Run TypeError: The Python instance can not be converted to a COM object Could it be a problem with the COM object? Why do I need to explicitly pass a reference to "self" when calling Run (or any other Test object method for that matter)? ---- Run method signature: object.Run [ResultsOptions], [WaitOnReturn], [Parameters] Here is the relevant output of makepy for the QTP Type Library: class Test(DispatchBaseClass): ... def Run(self, ResultsOptions=0, WaitOnReturn=True, Parameters=None): """Runs the open test or business component and creates results in the specified file or Quality Center path.""" return self._oleobj_.InvokeTypes(15, LCID, 1, (24, 0), ((9, 49), (11, 49), (9, 49)),ResultsOptions , WaitOnReturn, Parameters) -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Sep 8 20:45:45 2009 From: timr at probo.com (Tim Roberts) Date: Tue, 08 Sep 2009 11:45:45 -0700 Subject: [python-win32] Problems with QuickTest Automation Object Model In-Reply-To: References: <4AA6960B.7000709@probo.com> Message-ID: <4AA6A659.5060604@probo.com> Dennis Chung wrote: > I am running this code on the python shell the test was loaded > successfully. I will illustrate my problem more clearly. I currently > have a work around by explicitly passing "self" but I'd like to better > understand the issue. As you can probably tell, I am new to python. > > The following code allows me to successfully run a test: > --- > import win32com.client > o = win32com.client.Dispatch("QuickTest.Application") > o.Launch() > > # i've escaped the \ this time but it also worked the first time > o.Open("C:\\Documents and Settings\\DChung\\Desktop\\XMLRequest") > o.Visible = True > o.Test.Run(o.Test) # this works fine, o.Test.Run() does not. > --- > > Using "o.Test.Run()" I get the following: > Traceback (most recent call last): > File "", line 1, in > o.Test.Run() > File > "C:\Python31\lib\site-packages\win32com\gen_py\5BF80934-AEDA-4463-B199-B83285266562x0x1x0.py", > line 1717, in Run > , WaitOnReturn, Parameters) > TypeError: The Python instance can not be converted to a COM object > > According to the documentation I should be able to invoke Run() with > no parameters (See below). I have explicitly passed "self" to the Run > method otherwise I run into the above problem. When invoking other > methods from this library, i.e. Launch() and Open(), I do not need to > pass "self". Yes, but there's a big difference between those. With Launch and Open, you are working with the "o" object. But with o.Test.Run(), you aren't working with "o", you are working with whatever object is returned from the Test property of "o". That's a brand new object of a different type, and I'm guessing that's where the problem lies. Try printing o.Test to see what you get. Then, try: tst = o.Test tst.Run() > Could it be a problem with the COM object? Why do I need to > explicitly pass a reference to "self" when calling Run (or any other > Test object method for that matter)? You should not need to. Self is always passed as the first parameter in any method invocation. It is interesting that the property has the same name as the class itself. That's a little disconcerting. For example, **IF** o.Test were mapping to the class instead of being a property that returned an object, you might see the results you are seeing. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From chungdr at gmail.com Tue Sep 8 21:45:35 2009 From: chungdr at gmail.com (Dennis Chung) Date: Tue, 8 Sep 2009 15:45:35 -0400 Subject: [python-win32] Problems with QuickTest Automation Object Model In-Reply-To: <4AA6A659.5060604@probo.com> References: <4AA6960B.7000709@probo.com> <4AA6A659.5060604@probo.com> Message-ID: > > Yes, but there's a big difference between those. With Launch and Open, > you are working with the "o" object. But with o.Test.Run(), you aren't > working with "o", you are working with whatever object is returned from > the Test property of "o". That's a brand new object of a different > type, and I'm guessing that's where the problem lies. > > Try printing o.Test to see what you get. Then, try: > tst = o.Test > tst.Run() > The above fails with the same error. Printing o.Test produces the following: o.Test > Printing o yields: o It looks like the Test object is not properly recognized but I've been able to call other methods and properties of the Test object successfully without passing "self". o.Test.Stop() o.Test.Save() o.Test.SaveAs("abc") o.Test.Close() o.Test.Location o.Test.Description > You should not need to. Self is always passed as the first parameter in > any method invocation. It is interesting that the property has the same > name as the class itself. That's a little disconcerting. For example, > **IF** o.Test were mapping to the class instead of being a property that > returned an object, you might see the results you are seeing. > > It doesn't seem likely that o.Test is mapping to the class since other methods are working. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Sep 9 01:30:59 2009 From: timr at probo.com (Tim Roberts) Date: Tue, 08 Sep 2009 16:30:59 -0700 Subject: [python-win32] Problems with QuickTest Automation Object Model In-Reply-To: References: <4AA6960B.7000709@probo.com> Message-ID: <4AA6E933.1050507@probo.com> Dennis Chung wrote: > > ---- > > Run method signature: > object.Run [ResultsOptions], [WaitOnReturn], [Parameters] > > Here is the relevant output of makepy for the QTP Type Library: > class Test(DispatchBaseClass): > ... > def Run(self, ResultsOptions=0, WaitOnReturn=True, Parameters=None): > """Runs the open test or business component and creates > results in the specified file or Quality Center path.""" > return self._oleobj_.InvokeTypes(15, LCID, 1, (24, 0), ((9, > 49), (11, 49), (9, 49)),ResultsOptions > , WaitOnReturn, Parameters) The three type records are a COM interface, a boolean, and a COM interface, returning void. The parameter you're passing is getting sent in as the ResultsOption. Is there any change if you pass None as the first parameter? (There shouldn't be...) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Wed Sep 9 13:36:44 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 09 Sep 2009 21:36:44 +1000 Subject: [python-win32] How to wrap VARIANT_BOOL In-Reply-To: References: Message-ID: <4AA7934C.2090300@gmail.com> On 8/09/2009 9:55 PM, Arve Knudsen wrote: > Hi > > I don't know if this will get me much in terms of a response, > considering my questions about PyWin32 and ADSI up till now, but I'll > give it a shot :p I am trying to extend win32com.adsi.PyIADsUser > (through PyIADsUser.i) with a couple of methods that use the > VARIANT_BOOL type, how can I wrap this (VARIANT_BOOL) in PyWin32/swig? I'm afraid I don't understand the question... Mark From arve.knudsen at gmail.com Wed Sep 9 16:55:19 2009 From: arve.knudsen at gmail.com (Arve Knudsen) Date: Wed, 9 Sep 2009 16:55:19 +0200 Subject: [python-win32] How to wrap VARIANT_BOOL In-Reply-To: <4AA7934C.2090300@gmail.com> References: <4AA7934C.2090300@gmail.com> Message-ID: On Wed, Sep 9, 2009 at 1:36 PM, Mark Hammond wrote: > On 8/09/2009 9:55 PM, Arve Knudsen wrote: > >> Hi >> >> I don't know if this will get me much in terms of a response, >> considering my questions about PyWin32 and ADSI up till now, but I'll >> give it a shot :p I am trying to extend win32com.adsi.PyIADsUser >> (through PyIADsUser.i) with a couple of methods that use the >> VARIANT_BOOL type, how can I wrap this (VARIANT_BOOL) in PyWin32/swig? >> > > I'm afraid I don't understand the question... > I meant that I want to extend PyIADsUser.i to wrap also methods getPasswordRequired(VARIANT_BOOL*) and putPasswordRequired(VARIANT_BOOL). How do I go about this? Apparently, VARIANT_BOOL is not directly supported, since simply declaring the function signatures in PyIADsUser.i does not work (can't test here, but I recall it was in relation to the VARIANT_BOOL type). Arve -------------- next part -------------- An HTML attachment was scrubbed... URL: From chungdr at gmail.com Wed Sep 9 17:21:50 2009 From: chungdr at gmail.com (Dennis Chung) Date: Wed, 9 Sep 2009 11:21:50 -0400 Subject: [python-win32] Problems with QuickTest Automation Object Model In-Reply-To: <4AA6E933.1050507@probo.com> References: <4AA6960B.7000709@probo.com> <4AA6E933.1050507@probo.com> Message-ID: That makes sense, the default value of the first parameter is 0 where it should be None. I'm assume this is a problem in the COM object definition in which case I can raise an issue with HP. o.Test.Run(0) Traceback (most recent call last): File "", line 1, in o.Test.Run(0) File ">", line 3, in Run TypeError: The Python instance can not be converted to a COM object o.Test.Run(None) is successful as is o.Test.Run(o.Test) or any COM object reference for that matter. Looks like the Run method does not report errors if an incorrect object is passed. Thanks for all your help! On Tue, Sep 8, 2009 at 7:30 PM, Tim Roberts wrote: > Dennis Chung wrote: > > > > ---- > > > > Run method signature: > > object.Run [ResultsOptions], [WaitOnReturn], [Parameters] > > > > Here is the relevant output of makepy for the QTP Type Library: > > class Test(DispatchBaseClass): > > ... > > def Run(self, ResultsOptions=0, WaitOnReturn=True, Parameters=None): > > """Runs the open test or business component and creates > > results in the specified file or Quality Center path.""" > > return self._oleobj_.InvokeTypes(15, LCID, 1, (24, 0), ((9, > > 49), (11, 49), (9, 49)),ResultsOptions > > , WaitOnReturn, Parameters) > > The three type records are a COM interface, a boolean, and a COM > interface, returning void. The parameter you're passing is getting sent > in as the ResultsOption. Is there any change if you pass None as the > first parameter? (There shouldn't be...) > > -- > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Sep 9 19:05:07 2009 From: timr at probo.com (Tim Roberts) Date: Wed, 09 Sep 2009 10:05:07 -0700 Subject: [python-win32] Problems with QuickTest Automation Object Model In-Reply-To: References: <4AA6960B.7000709@probo.com> <4AA6E933.1050507@probo.com> Message-ID: <4AA7E043.1010508@probo.com> Dennis Chung wrote: > That makes sense, the default value of the first parameter is 0 where > it should be None. I'm assume this is a problem in the COM object > definition in which case I can raise an issue with HP. > > o.Test.Run(0) > Traceback (most recent call last): > File "", line 1, in > o.Test.Run(0) > File ">", line 3, in Run > TypeError: The Python instance can not be converted to a COM object > > o.Test.Run(None) is successful as is o.Test.Run(o.Test) or any COM > object reference for that matter. Looks like the Run method does not > report errors if an incorrect object is passed. I'm hoping Mark will find this interesting and investigate. I don't quite understand how makepy.py let this slip by. The first and third parameters are both VT_DISPATCH, so why would the first come up with a default of 0, when the third comes up with a default of None? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Sep 9 20:15:06 2009 From: timr at probo.com (Tim Roberts) Date: Wed, 09 Sep 2009 11:15:06 -0700 Subject: [python-win32] Problems with QuickTest Automation Object Model In-Reply-To: References: <4AA6960B.7000709@probo.com> <4AA6E933.1050507@probo.com> <4AA7E043.1010508@probo.com> Message-ID: <4AA7F0AA.4030303@probo.com> Dennis Chung wrote: > > I assume these default values are coming from the COM library itself > and makepy.py is simply pulling these defaults. COM doesn't know anything about None. That's strictly a Python invention. > According to Python Object Browser, the first argument for Run is > "Pointer User Defined" with default value of 0 (See below). I have > identified another method, UpdateRun, that exhibits the same > problems. A common element between the two methods is the > ResultsOptions parameter. UpdateRun also includes an UpdateOptions > parameter which is similar. Infact they should both be collections. > What's interesting is that these two classes appear to be named > _RunResultsOptions and _UpdateRunOptions (see makepy gen output > below). Is this an issue with win32com or HP QTP or both? Very interesting! So, in the type library, it's NOT declared as an IDispatch *, but rather as a void *. If the parameter is allowed to take arbitrary pointers, and not just COM objects, then I'm not sure there is a good solution for this. You can certainly modify the makepy-generated wrapper file by hand and change the defaults from 0 to None. If it's supposed to be a COM object always, then HP should probably update their type library. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From chungdr at gmail.com Wed Sep 9 19:55:08 2009 From: chungdr at gmail.com (Dennis Chung) Date: Wed, 9 Sep 2009 13:55:08 -0400 Subject: [python-win32] Problems with QuickTest Automation Object Model In-Reply-To: <4AA7E043.1010508@probo.com> References: <4AA6960B.7000709@probo.com> <4AA6E933.1050507@probo.com> <4AA7E043.1010508@probo.com> Message-ID: > I'm hoping Mark will find this interesting and investigate. I don't > quite understand how makepy.py let this slip by. The first and third > parameters are both VT_DISPATCH, so why would the first come up with a > default of 0, when the third comes up with a default of None? > > I assume these default values are coming from the COM library itself and makepy.py is simply pulling these defaults. According to Python Object Browser, the first argument for Run is "Pointer User Defined" with default value of 0 (See below). I have identified another method, UpdateRun, that exhibits the same problems. A common element between the two methods is the ResultsOptions parameter. UpdateRun also includes an UpdateOptions parameter which is similar. Infact they should both be collections. What's interesting is that these two classes appear to be named _RunResultsOptions and _UpdateRunOptions (see makepy gen output below). Is this an issue with win32com or HP QTP or both? *Function definition for Run and UpdateRun Python Object Browser* Run Named Params = 'ResultsOptions, WaitOnReturn, Parameters' Return Type = 'Void' *Argument = 'Pointer User Defined (Flags=49) (Default=0)'* Argument = 'BOOL (Flags=49) (Default=True)' Argument = 'IDispatch (Flags=49)' Function Kind = 'Dispatch' Invoke Kind = 'Function' Number Optional Params = 0 UpdateRun Named Params = 'UpdateOptions, ResultsOptions, WaitOnReturn, Parameters' Return Type = 'Void' *Argument = 'Pointer User Defined (Flags=49) (Default=0)' Argument = 'Pointer User Defined (Flags=49) (Default=0)'* Argument = 'BOOL (Flags=49) (Default=True)' Argument = 'IDispatch (Flags=49)' Function Kind = 'Dispatch' Invoke Kind = 'Function' Number Optional Params = 0 *Class Def From makepy* class _RunResultsOptions(DispatchBaseClass): """A collection of properties that indicate preferences for the test run results.""" CLSID = IID('{38B2828E-E64B-4D95-B0EF-0A1C74396FF9}') coclass_clsid = IID('{29E73840-B66F-4930-9345-139090CD1D16}') _prop_map_get_ = { "ResultsLocation": (1, 2, (8, 0), (), "ResultsLocation", None), "TDRunName": (2, 2, (8, 0), (), "TDRunName", None), "TDTestInstance": (4, 2, (3, 0), (), "TDTestInstance", None), "TDTestSet": (3, 2, (8, 0), (), "TDTestSet", None), } _prop_map_put_ = { "ResultsLocation": ((1, LCID, 4, 0),()), "TDRunName": ((2, LCID, 4, 0),()), "TDTestInstance": ((4, LCID, 4, 0),()), "TDTestSet": ((3, LCID, 4, 0),()), } class _UpdateRunOptions(DispatchBaseClass): """A collection of properties that indicate preferences for the Update Run.""" CLSID = IID('{B0160C94-5EAD-42AD-846E-F82BA4186994}') coclass_clsid = IID('{4F8D498E-CEC8-4DB1-B128-A73A3C0A36FF}') _prop_map_get_ = { "UpdateActiveScreen": (1, 2, (11, 0), (), "UpdateActiveScreen", None), "UpdateCheckpoints": (2, 2, (11, 0), (), "UpdateCheckpoints", None), "UpdateTestObjectDescriptions": (3, 2, (11, 0), (), "UpdateTestObjectDescriptions", None), } _prop_map_put_ = { "UpdateActiveScreen": ((1, LCID, 4, 0),()), "UpdateCheckpoints": ((2, LCID, 4, 0),()), "UpdateTestObjectDescriptions": ((3, LCID, 4, 0),()), } *Method def from **makepy* def UpdateRun(self, UpdateOptions=0, ResultsOptions=0, WaitOnReturn=True, Parameters=None): """Runs the test or business component in update mode.""" return self._oleobj_.InvokeTypes(16, LCID, 1, (24, 0), ((9, 49), (9, 49), (11, 49), (9, 49)),UpdateOptions , ResultsOptions, WaitOnReturn, Parameters) def Run(self, ResultsOptions=0, WaitOnReturn=True, Parameters=None): """Runs the open test or business component and creates results in the specified file or Quality Center path.""" return self._oleobj_.InvokeTypes(15, LCID, 1, (24, 0), ((9, 49), (11, 49), (9, 49)),ResultsOptions , WaitOnReturn, Parameters) -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Thu Sep 10 01:19:57 2009 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 10 Sep 2009 09:19:57 +1000 Subject: [python-win32] How to wrap VARIANT_BOOL In-Reply-To: References: <4AA7934C.2090300@gmail.com> Message-ID: <4AA8381D.8020801@skippinet.com.au> On 10/09/2009 12:55 AM, Arve Knudsen wrote: > > > On Wed, Sep 9, 2009 at 1:36 PM, Mark Hammond > wrote: > > On 8/09/2009 9:55 PM, Arve Knudsen wrote: > > Hi > > I don't know if this will get me much in terms of a response, > considering my questions about PyWin32 and ADSI up till now, but > I'll > give it a shot :p I am trying to extend win32com.adsi.PyIADsUser > (through PyIADsUser.i) with a couple of methods that use the > VARIANT_BOOL type, how can I wrap this (VARIANT_BOOL) in > PyWin32/swig? > > > I'm afraid I don't understand the question... > > > I meant that I want to extend PyIADsUser.i to wrap also methods > getPasswordRequired(VARIANT_BOOL*) and > putPasswordRequired(VARIANT_BOOL). How do I go about this? Apparently, > VARIANT_BOOL is not directly supported, since simply declaring the > function signatures in PyIADsUser.i does not work (can't test here, but > I recall it was in relation to the VARIANT_BOOL type). I'm afraid you still need to be more specific. Note that VARIANT_BOOL is typedef'd to a 'short' in WTypes.h... Cheers, Mark From jeffpeery at yahoo.com Thu Sep 10 05:15:48 2009 From: jeffpeery at yahoo.com (Jeff Peery) Date: Wed, 9 Sep 2009 20:15:48 -0700 (PDT) Subject: [python-win32] thread not posting events woes Message-ID: <930406.34461.qm@web43133.mail.sp1.yahoo.com> Hello, I'm having trouble catching events from my multi threaded app. I'm using wxpython and running several threads under the main wxApp thread. One of the threads creates a COM object for an OPC server.? I'm using dispatchWithEvents() to get the COM object. When I do this the server will post an event to the OnDataChange() method in my application. ? Everything runs wonderfully when I create the COM object within the main thread (wxApp). However if I create it from within a sub thread then the OnDataChange is not being called. ? My understanding of how multithreaded applications work is basic. I'm using queue's and threading.locks to safely manage data. However I don't understand how messages and events are handled in multi threaded apps with different apartments. The COM object I created is a client to an OPC server. I suspect the server lives in a different apartment and that I must handle how messages and events are passed between different threads/apartments. ? Where should I start reading to learn more and/or is there a standard way to assure my events get posted across apartments/threads? ? thanks, Jeff ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From arve.knudsen at gmail.com Thu Sep 10 07:47:02 2009 From: arve.knudsen at gmail.com (Arve Knudsen) Date: Thu, 10 Sep 2009 07:47:02 +0200 Subject: [python-win32] How to wrap VARIANT_BOOL In-Reply-To: <4AA8381D.8020801@skippinet.com.au> References: <4AA7934C.2090300@gmail.com> <4AA8381D.8020801@skippinet.com.au> Message-ID: On Thu, Sep 10, 2009 at 1:19 AM, Mark Hammond wrote: > On 10/09/2009 12:55 AM, Arve Knudsen wrote: > >> >> >> On Wed, Sep 9, 2009 at 1:36 PM, Mark Hammond > > wrote: >> >> On 8/09/2009 9:55 PM, Arve Knudsen wrote: >> >> Hi >> >> I don't know if this will get me much in terms of a response, >> considering my questions about PyWin32 and ADSI up till now, but >> I'll >> give it a shot :p I am trying to extend win32com.adsi.PyIADsUser >> (through PyIADsUser.i) with a couple of methods that use the >> VARIANT_BOOL type, how can I wrap this (VARIANT_BOOL) in >> PyWin32/swig? >> >> >> I'm afraid I don't understand the question... >> >> >> I meant that I want to extend PyIADsUser.i to wrap also methods >> getPasswordRequired(VARIANT_BOOL*) and >> putPasswordRequired(VARIANT_BOOL). How do I go about this? Apparently, >> VARIANT_BOOL is not directly supported, since simply declaring the >> function signatures in PyIADsUser.i does not work (can't test here, but >> I recall it was in relation to the VARIANT_BOOL type). >> > > I'm afraid you still need to be more specific. Note that VARIANT_BOOL is > typedef'd to a 'short' in WTypes.h... > I'm not quite sure how I can be more specific .. I've stated the problem, i.e. modify PyWin32 to also wrap IADsUser methods getPasswordRequired(VARIANT_BOOL*) and putPasswordRequired(VARIANT_BOOL). If VARIANT_BOOL in reality corresponds to short though, I guess I should solve this by declaring this typedef to swig (in PyIADsUser.i). Thanks, Arve -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Thu Sep 10 15:16:10 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 10 Sep 2009 23:16:10 +1000 Subject: [python-win32] thread not posting events woes In-Reply-To: <930406.34461.qm@web43133.mail.sp1.yahoo.com> References: <930406.34461.qm@web43133.mail.sp1.yahoo.com> Message-ID: <4AA8FC1A.4020400@gmail.com> Your thread probably needs to be running an event loop - I'm not sure how this is usually spelt in wx, but the 'usual' pythoncom.PumpMessages or similar might be enough. Cheers, Mark On 10/09/2009 1:15 PM, Jeff Peery wrote: > Hello, > I'm having trouble catching events from my multi threaded app. I'm using > wxpython and running several threads under the main wxApp thread. One of > the threads creates a COM object for an OPC server. I'm using > dispatchWithEvents() to get the COM object. When I do this the server > will post an event to the OnDataChange() method in my application. > Everything runs wonderfully when I create the COM object within the main > thread (wxApp). However if I create it from within a sub thread then the > OnDataChange is not being called. > My understanding of how multithreaded applications work is basic. I'm > using queue's and threading.locks to safely manage data. However I don't > understand how messages and events are handled in multi threaded apps > with different apartments. The COM object I created is a client to an > OPC server. I suspect the server lives in a different apartment and that > I must handle how messages and events are passed between different > threads/apartments. > Where should I start reading to learn more and/or is there a standard > way to assure my events get posted across apartments/threads? > thanks, > Jeff > > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From sbonam at gmail.com Thu Sep 10 21:09:27 2009 From: sbonam at gmail.com (Steve Bonam) Date: Thu, 10 Sep 2009 15:09:27 -0400 Subject: [python-win32] Drawing on the desktop and window creation problems Message-ID: <2ee3028b0909101209v67bffcanb32af326475a7edd@mail.gmail.com> I'd like to draw some text ON the desktop, I've heard of three ways to do this so far, Drawing it directly to the desktop with GetDesktopWindow() (so far this only puts text above everything and is erased as soon as things are redrawn), Making A child of the desktop with GetDesktopWindow(), or Making inactive window and placing at the bottom of everything and using PaintDesktop(), I've opted for the second of the three but I've run into some weird behavior. I create a new window but as soon it's drawn it is invisible, no titlebar, no anything. I draw text on it and it becomes white still has no titlebar and puts the text on twice. when I kill it from the interpeter the window finally becomes visible but not repsonsive as I've killed it's handling? I've gathered this from some sample code on line: http://www.theroyweb.com/getpage.php?pageID=21 which has about the same errors. [code] from win32api import * from win32gui import * import win32ui import win32con # Create and register new window class def WndProc(hWnd, msg, wparam, lparam): print msg if msg == win32con.WM_PAINT: print "Painting" hdc,paintstruct = BeginPaint(hWnd) PaintDesktop(hdc) #ExtTextOut(hdc, 100,100,win32con.ETO_OPAQUE,None, "TEST") EndPaint(hWnd,paintstruct) return 0 if msg == 522: PostQuitMessage(0) return 0 hInst = GetModuleHandle(None) wc = WNDCLASS() wc.style = win32con.CS_HREDRAW | win32con.CS_VREDRAW wc.lpfnWndProc = WndProc wc.hInstance = hInst wc.hIcon = LoadIcon(0, win32con.IDI_APPLICATION) wc.hCursor = LoadCursor(0, win32con.IDC_ARROW) wc.hbrBackground = GetStockObject(win32con.GRAY_BRUSH) wc.lpszClassName = "SimpleWin" #"SimpleWin" try: RegisterClass(wc) except error: # most probably class is already registered pass hWnd = CreateWindow( "SimpleWin", # class # title "Hello Win32 World!", # style win32con.WS_OVERLAPPED, # location win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, # size 300, 300, # parent 0, # menu 0, # instance handle hInst, # reserved - must be None None) ShowWindow(hWnd,win32con.SW_SHOWNORMAL) UpdateWindow(hWnd) PumpMessages() [/code] From timr at probo.com Thu Sep 10 21:32:14 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 10 Sep 2009 12:32:14 -0700 Subject: [python-win32] thread not posting events woes In-Reply-To: <930406.34461.qm@web43133.mail.sp1.yahoo.com> References: <930406.34461.qm@web43133.mail.sp1.yahoo.com> Message-ID: <4AA9543E.3020305@probo.com> Jeff Peery wrote: > Hello, > I'm having trouble catching events from my multi threaded app. I'm > using wxpython and running several threads under the main wxApp > thread. One of the threads creates a COM object for an OPC server. > I'm using dispatchWithEvents() to get the COM object. When I do this > the server will post an event to the OnDataChange() method in my > application. > > Everything runs wonderfully when I create the COM object within the > main thread (wxApp). However if I create it from within a sub thread > then the OnDataChange is not being called. > > My understanding of how multithreaded applications work is basic. I'm > using queue's and threading.locks to safely manage data. However I > don't understand how messages and events are handled in multi threaded > apps with different apartments. The COM object I created is a client > to an OPC server. I suspect the server lives in a different apartment > and that I must handle how messages and events are passed between > different threads/apartments. > Every thread in a Windows application has its own message queue. If you create a COM object in a different thread, then its messages will all be delivered to that thread's queue. However, wxPython is only responding to messages on the main thread, where you created the window. Is there a way you can organize things to create your object in the main thread? If not, you need to have a message pump in the second thread dispatching messages. I can do that in C, but I honestly don't know how to do that in Python. You might ask this question on the wxPython mailing list, although it may be a bit obscure for them. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Sep 10 21:43:15 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 10 Sep 2009 12:43:15 -0700 Subject: [python-win32] Drawing on the desktop and window creation problems In-Reply-To: <2ee3028b0909101209v67bffcanb32af326475a7edd@mail.gmail.com> References: <2ee3028b0909101209v67bffcanb32af326475a7edd@mail.gmail.com> Message-ID: <4AA956D3.8080509@probo.com> Steve Bonam wrote: > I create a new window but as soon it's drawn it is invisible, no > titlebar, no anything. I draw text on it and it becomes white still > has no titlebar and puts the text on twice. when I kill it from the > interpeter the window finally becomes visible but not repsonsive as > I've killed it's handling? > ... > > > # Create and register new window class > def WndProc(hWnd, msg, wparam, lparam): > print msg > if msg == win32con.WM_PAINT: > print "Painting" > hdc,paintstruct = BeginPaint(hWnd) > PaintDesktop(hdc) > #ExtTextOut(hdc, 100,100,win32con.ETO_OPAQUE,None, "TEST") > EndPaint(hWnd,paintstruct) > return 0 > if msg == 522: > PostQuitMessage(0) > return 0 > In a window proc, if you do not handle a message, you must forward it to the default window proc. This is not done automatically, so you aren't getting the non-client painting and normal window management. You should add this as the last line in your WndProc: return DefWindowProc( hWnd, msg, wparam, lparam) With that, you get a title bar and a border. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Sep 10 21:57:30 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 10 Sep 2009 12:57:30 -0700 Subject: [python-win32] Drawing on the desktop and window creation problems In-Reply-To: <2ee3028b0909101209v67bffcanb32af326475a7edd@mail.gmail.com> References: <2ee3028b0909101209v67bffcanb32af326475a7edd@mail.gmail.com> Message-ID: <4AA95A2A.2070801@probo.com> Steve Bonam wrote: > # Create and register new window class > def WndProc(hWnd, msg, wparam, lparam): > print msg > if msg == win32con.WM_PAINT: > print "Painting" > hdc,paintstruct = BeginPaint(hWnd) > PaintDesktop(hdc) > #ExtTextOut(hdc, 100,100,win32con.ETO_OPAQUE,None, "TEST") > EndPaint(hWnd,paintstruct) > return 0 > if msg == 522: > PostQuitMessage(0) > return 0 > 522 is WM_MOUSEWHEEL. Was that your "escape hatch" -- twiddle the wheel to kill the app? If you change that to win32con.WM_CLOSE, you can kill it with Alt-F4, like normal. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From sbonam at gmail.com Thu Sep 10 22:15:49 2009 From: sbonam at gmail.com (Steve Bonam) Date: Thu, 10 Sep 2009 16:15:49 -0400 Subject: [python-win32] Drawing on the desktop and window creation problems In-Reply-To: <4AA95A2A.2070801@probo.com> References: <2ee3028b0909101209v67bffcanb32af326475a7edd@mail.gmail.com> <4AA95A2A.2070801@probo.com> Message-ID: <2ee3028b0909101315u4cfae143v4a5d0b65d6613ae2@mail.gmail.com> yes, it was my escape hatch, I see now that i also forgot to destroy the window. Also any thoughts or insights into writing on the desktop? On Thu, Sep 10, 2009 at 3:57 PM, Tim Roberts wrote: > Steve Bonam wrote: >> # Create and register new window class >> def WndProc(hWnd, msg, wparam, lparam): >> ? ? print msg >> ? ? if msg == win32con.WM_PAINT: >> ? ? ? ? print "Painting" >> ? ? ? ? hdc,paintstruct = BeginPaint(hWnd) >> ? ? ? ? PaintDesktop(hdc) >> ? ? ? ? #ExtTextOut(hdc, 100,100,win32con.ETO_OPAQUE,None, "TEST") >> ? ? ? ? EndPaint(hWnd,paintstruct) >> ? ? ? ? return 0 >> ? ? if msg == 522: >> ? ? ? ? PostQuitMessage(0) >> ? ? ? ? return 0 >> > > 522 is WM_MOUSEWHEEL. ?Was that your "escape hatch" -- twiddle the wheel > to kill the app? ?If you change that to win32con.WM_CLOSE, you can kill > it with Alt-F4, like normal. > > -- > 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 > -- -steve From jacky830 at gmail.com Sat Sep 12 13:23:15 2009 From: jacky830 at gmail.com (Jacky Lam) Date: Sat, 12 Sep 2009 19:23:15 +0800 Subject: [python-win32] Does anyone know how to compile pywin32 for 64bit operating system? Message-ID: I would like to compile a 64 bit version of pywin. I am currently using MingGW for that, but I fail to do so. Does anyone know how to compile pywin32 for 64bit operating system? In addition, any examples for that? Thanks. Jacky From metolone+gmane at gmail.com Sat Sep 12 16:37:14 2009 From: metolone+gmane at gmail.com (Mark Tolonen) Date: Sat, 12 Sep 2009 07:37:14 -0700 Subject: [python-win32] Does anyone know how to compile pywin32 for 64bitoperating system? References: Message-ID: "Jacky Lam" wrote in message news:d9dcd20c0909120423y4a27ffadk5a26a4e9af1c1ea1 at mail.gmail.com... >I would like to compile a 64 bit version of pywin. > I am currently using MingGW for that, but I fail to do so. > Does anyone know how to compile pywin32 for 64bit operating system? > In addition, any examples for that? Look at README.txt in the pywin32 sources, and in particular run "setup.py --help". -Mark From mc at mclaveau.com Sat Sep 12 21:10:18 2009 From: mc at mclaveau.com (Michel Claveau) Date: Sat, 12 Sep 2009 21:10:18 +0200 Subject: [python-win32] Does anyone know how to compile pywin32 for 64bitoperating system? In-Reply-To: References: Message-ID: Hi! Easy: push 64 times the key [compile] ;o) Warning: 63 or minus give a modulo 32 bits... (sorry: je sors d'un big ap?ritif...) @+ Michel Claveau From jacky830 at gmail.com Sun Sep 13 05:53:09 2009 From: jacky830 at gmail.com (Jacky Lam) Date: Sun, 13 Sep 2009 11:53:09 +0800 Subject: [python-win32] Does anyone know how to compile pywin32 for 64bitoperating system? In-Reply-To: References: Message-ID: could you further elabarate on it? As pywin32 onlys has 32bit version for python 2.5, so I want to compile a 64 bit version for 64 bit os. On Sun, Sep 13, 2009 at 3:10 AM, Michel Claveau wrote: > Hi! > > Easy: ?push 64 times the key [compile] ?;o) > Warning: 63 or minus give a modulo 32 bits... > (sorry: je sors d'un big ap?ritif...) > > @+ > > Michel Claveau > > > From metolone+gmane at gmail.com Sun Sep 13 08:27:42 2009 From: metolone+gmane at gmail.com (Mark Tolonen) Date: Sat, 12 Sep 2009 23:27:42 -0700 Subject: [python-win32] Does anyone know how to compile pywin32 for64bitoperating system? References: Message-ID: "Jacky Lam" wrote in message news:d9dcd20c0909122053w772941b7q82fea3920e856d37 at mail.gmail.com... > could you further elabarate on it? > As pywin32 onlys has 32bit version for python 2.5, so I want to > compile a 64 bit version for 64 bit os. > Then definitely read the latest sources setup.py. To quote: To build 64bit versions of this: * py2.5 and earlier - sorry, I've given up in disgust. Using VS2003 with the Vista SDK is just too painful to make work, and VS2005 is not used for any released versions of Python. See revision 1.69 of this file for the last version that attempted to support and document this process. -Mark From mdriscoll at co.marshall.ia.us Mon Sep 14 16:10:23 2009 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Mon, 14 Sep 2009 09:10:23 -0500 Subject: [python-win32] thread not posting events woes In-Reply-To: <4AA9543E.3020305@probo.com> References: <930406.34461.qm@web43133.mail.sp1.yahoo.com> <4AA9543E.3020305@probo.com> Message-ID: <4AAE4ECF.30703@co.marshall.ia.us> Tim Roberts wrote: > Jeff Peery wrote: > >> Hello, >> I'm having trouble catching events from my multi threaded app. I'm >> using wxpython and running several threads under the main wxApp >> thread. One of the threads creates a COM object for an OPC server. >> I'm using dispatchWithEvents() to get the COM object. When I do this >> the server will post an event to the OnDataChange() method in my >> application. >> >> Everything runs wonderfully when I create the COM object within the >> main thread (wxApp). However if I create it from within a sub thread >> then the OnDataChange is not being called. >> >> My understanding of how multithreaded applications work is basic. I'm >> using queue's and threading.locks to safely manage data. However I >> don't understand how messages and events are handled in multi threaded >> apps with different apartments. The COM object I created is a client >> to an OPC server. I suspect the server lives in a different apartment >> and that I must handle how messages and events are passed between >> different threads/apartments. >> >> > > Every thread in a Windows application has its own message queue. If you > create a COM object in a different thread, then its messages will all be > delivered to that thread's queue. However, wxPython is only responding > to messages on the main thread, where you created the window. > > Is there a way you can organize things to create your object in the main > thread? If not, you need to have a message pump in the second thread > dispatching messages. I can do that in C, but I honestly don't know how > to do that in Python. > > You might ask this question on the wxPython mailing list, although it > may be a bit obscure for them. > > I'm probably being naive, but I think using wx.CallAfter or wx.CallLater in combination with pubsub (http://wiki.wxpython.org/PubSub) would be one of the easiest ways to send messages back to your application. ------------------- Mike Driscoll Blog: http://blog.pythonlibrary.org From timr at probo.com Mon Sep 14 19:17:28 2009 From: timr at probo.com (Tim Roberts) Date: Mon, 14 Sep 2009 10:17:28 -0700 Subject: [python-win32] thread not posting events woes In-Reply-To: <4AAE4ECF.30703@co.marshall.ia.us> References: <930406.34461.qm@web43133.mail.sp1.yahoo.com> <4AA9543E.3020305@probo.com> <4AAE4ECF.30703@co.marshall.ia.us> Message-ID: <4AAE7AA8.3050802@probo.com> Mike Driscoll wrote: > Tim Roberts wrote: >> Jeff Peery wrote: >> >>> I'm having trouble catching events from my multi threaded app. I'm >>> using wxpython and running several threads under the main wxApp >>> thread. One of the threads creates a COM object for an OPC server. >>> I'm using dispatchWithEvents() to get the COM object. When I do this >>> the server will post an event to the OnDataChange() method in my >>> application. >>> >>> Everything runs wonderfully when I create the COM object within the >>> main thread (wxApp). However if I create it from within a sub thread >>> then the OnDataChange is not being called. >> >> Every thread in a Windows application has its own message queue. If you >> create a COM object in a different thread, then its messages will all be >> delivered to that thread's queue. However, wxPython is only responding >> to messages on the main thread, where you created the window. > > I'm probably being naive, but I think using wx.CallAfter or > wx.CallLater in combination with pubsub > (http://wiki.wxpython.org/PubSub) would be one of the easiest ways to > send messages back to your application. That's good advice in general, but the issue, I think, is that it's not his app that is generating these events. He has what I assumed was a foreign COM object being created in a secondary thread. He's going to need to have someone listening to events on that thread to forward them back to his app's main thread. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From puneet.singh at vichara.com Thu Sep 17 07:01:59 2009 From: puneet.singh at vichara.com (Puneet Singh) Date: Wed, 16 Sep 2009 22:01:59 -0700 Subject: [python-win32] problem in calling excel object quit method Message-ID: <3BB80B485F285644884761B6AAA862B801183E25B0@EXVMBX018-10.exch018.msoutlookonline.net> Hi, I am calling quit() from a thread but its not working Regards, Puneet Singh -------------- next part -------------- An HTML attachment was scrubbed... URL: From siddhartha.veedaluru at gmail.com Thu Sep 17 14:34:15 2009 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Thu, 17 Sep 2009 18:04:15 +0530 Subject: [python-win32] Connection to remote machine registry fails. Message-ID: <424b71ec0909170534i36c31653ic277b39699e38300@mail.gmail.com> Hi , I'm trying to connect to a remote windows machine's registry using ConnectRegistry and try to get the process architecture information. Here is the code snippet for it #processRegKey = "System\CurrentControlSet\Control\Session Manager\Environment" #processRegValue = "PROCESSOR_ARCHITECTURE" #try: # regHandle = ConnectRegistry(r"\\atom",HKEY_LOCAL_MACHINE ) # regHandleObj = OpenKey(regHandle, processRegKey) # processType = QueryValueEx(regHandleObj, processRegValue)[0].split(" ")[0] # print processType #except Exception, erno: # print "Exception:" # print erno but it fails with access denied errors. I assume that there is credentials issue. but i have the credential, but where should i have to provide this. Please help in accesing remote machine adderss. Also the machine might be in another domain. i know that we have wmi module. just try to achive it with win32 Api. Thanks, sid. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Sep 17 18:49:26 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 17 Sep 2009 09:49:26 -0700 Subject: [python-win32] Connection to remote machine registry fails. In-Reply-To: <424b71ec0909170534i36c31653ic277b39699e38300@mail.gmail.com> References: <424b71ec0909170534i36c31653ic277b39699e38300@mail.gmail.com> Message-ID: <4AB26896.70207@probo.com> siddhartha veedaluru wrote: > > I'm trying to connect to a remote windows machine's registry using > ConnectRegistry and try to get the process architecture information. > > Here is the code snippet for it > #processRegKey = "System\CurrentControlSet\Control\Session > Manager\Environment" > #processRegValue = "PROCESSOR_ARCHITECTURE" > #try: > # regHandle = ConnectRegistry(r"\\atom",HKEY_LOCAL_MACHINE > ) > # regHandleObj = OpenKey(regHandle, processRegKey) > # processType = QueryValueEx(regHandleObj, > processRegValue)[0].split(" ")[0] > # print processType > #except Exception, erno: > # print "Exception:" > # print erno > > but it fails with access denied errors. > I assume that there is credentials issue. > but i have the credential, but where should i have to provide this. If the user you are currently logged in as is valid on the other machine, this should just work. Otherwise, you will have to call win32security.LogonUser and win32security.ImpersonateLoggedOnUser before calling ConnectRegistry. handle = win32Security.LogonUser( 'username', 'domain', 'password', win32con.LOGON32_LOGON_INTERACTIVE, win32con.LOGON32_PROVIDER_DEFAULT ) win32security.ImpersonateLoggonOnUser( handle ) # ... connect to to registry here ... win32security.RevertToSelf() handle.Close() -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Sep 17 18:51:19 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 17 Sep 2009 09:51:19 -0700 Subject: [python-win32] problem in calling excel object quit method In-Reply-To: <3BB80B485F285644884761B6AAA862B801183E25B0@EXVMBX018-10.exch018.msoutlookonline.net> References: <3BB80B485F285644884761B6AAA862B801183E25B0@EXVMBX018-10.exch018.msoutlookonline.net> Message-ID: <4AB26907.7050408@probo.com> Puneet Singh wrote: > > Hi, > > I am calling quit() from a thread but its not working > You need to call Quit from the thread that created the Excel object. Are you doing that? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From antoine at nagafix.co.uk Thu Sep 17 21:14:33 2009 From: antoine at nagafix.co.uk (Antoine Martin) Date: Fri, 18 Sep 2009 02:14:33 +0700 Subject: [python-win32] window events via SetWindowsHookExA Message-ID: <4AB28A99.5000407@nagafix.co.uk> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Hi, I am trying to use SetWindowsHookExA via ctypes to be notified when Windows are mapped/unmapped, to get the same functionality as SUBSTRUCTURE_MASK events on the root X-window (or is there a better way that I have missed?) Here is the code: WIN_HOOK = CFUNCTYPE(c_long, c_int, c_uint, c_long) def register_hook() WH_CALLWNDPROCRET = 4 dll_handle = ctypes.windll.user32._handle self.call_next_hook = ctypes.windll.user32.CallNextHookEx self.hook_handle = types.windll.user32.SetWindowsHookExA(WH_CALLWNDPROCRET, WIN_HOOK(window_hook), dll_handle, 0) def window_hook(self, nCode, wParam, lParam): print "hello" return self.call_next_hook(self.hook_handle, nCode, wParam, lParam) Something with the callback signature must be wrong because the hook does get registered (hook_handle>0), but as soon as a window event fires, my application is terminated. It does not even get to say hello... Here's what I used to figure out the C method signature: http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx Apologies if this is not the right list (please let me know which one is), it definitely looks like people here are most likely to be able to help me. Thanks Antoine -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEAREKAAYFAkqyipIACgkQGK2zHPGK1rsYnACfSmX8S99kF0JZbvjRAeFSMAGU hIMAniBF8mbW3/9xbhSU3zD0c+xluf/p =rWxJ -----END PGP SIGNATURE----- From timr at probo.com Thu Sep 17 23:03:48 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 17 Sep 2009 14:03:48 -0700 Subject: [python-win32] window events via SetWindowsHookExA In-Reply-To: <4AB28A99.5000407@nagafix.co.uk> References: <4AB28A99.5000407@nagafix.co.uk> Message-ID: <4AB2A434.4000701@probo.com> Antoine Martin wrote: > > I am trying to use SetWindowsHookExA via ctypes to be notified when > Windows are mapped/unmapped, to get the same functionality as > SUBSTRUCTURE_MASK events on the root X-window (or is there a better way > that I have missed?) WH_CALLWNDPROC is a bit extreme. The equivalent to mapping and unmapping in the Windows world is activation, done with the WM_ACTIVATE and WM_DEACTIVATE messages. You should be able to monitor those with WH_CBT, which is a bit lighter weight than the WH_CALLWNDPROC hooks. There is a problem with your code, however: > Here is the code: > > WIN_HOOK = CFUNCTYPE(c_long, c_int, c_uint, c_long) > def register_hook() > WH_CALLWNDPROCRET = 4 > dll_handle = ctypes.windll.user32._handle > self.call_next_hook = ctypes.windll.user32.CallNextHookEx > self.hook_handle = > types.windll.user32.SetWindowsHookExA(WH_CALLWNDPROCRET, > WIN_HOOK(window_hook), dll_handle, 0) You are telling it that the function to be called is inside of user32.dll. When you install an invasive hook like this, the operating system actually injects that DLL into every process that owns a window. Your hook function is then called in the context of those other processes. That's why they tell you that most hook procedures must reside in a DLL. In your case, the function address you gave is local to your EXE. It won't exist in other processes (or it will point to random memory). When the first event occurs, your callback will be called in a thread in some other process. That thread gets an exception, because that address points into random space, and your app is terminated. There used to be a great project at the University of North Carolina called pyAA that could do this, but it hasn't been updated past Python 2.4. At this point, I do not know of a way to implement Windows hooks in straight Python. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From threaderslash at gmail.com Fri Sep 18 06:17:09 2009 From: threaderslash at gmail.com (Threader Slash) Date: Fri, 18 Sep 2009 14:17:09 +1000 Subject: [python-win32] python-win32 : cross database automation Message-ID: Hello Everybody... I working on a client-server database solution. The system is normalized and is using MySQL. To automate some of processes I using Python. Part of the old database will be still running on Lotus Notes. After working on it, it seems that the best choice to directly manipulate Lotus is to use Python with win32COM - http://www.boddie.org.uk/python/COM.html . I installed ActivePython 2.6 compiler, which comes with integrated win32com. However, when I try to run.. it gives me the error: --x--x-- ActivePython 2.6.2.2 (ActiveState Software Inc.) based on Python 2.6.2 (r262:71600, Apr 21 2009, 15:05:37) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import win32com.client >>> sess=win32com.client.Dispatch("Lotus.NotesSession") Traceback (most recent call last): File "", line 1, in File "C:\dev\python\Py26\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\dev\python\Py26\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserN ame return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\dev\python\Py26\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) --x--x-- Any suggestions? Some help is mostly appreciated. I will keep working to get it fixed, after I post the working solution here. -------------- next part -------------- An HTML attachment was scrubbed... URL: From siddhartha.veedaluru at gmail.com Fri Sep 18 13:53:00 2009 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Fri, 18 Sep 2009 17:23:00 +0530 Subject: [python-win32] Connection to remote machine registry fails. Message-ID: <424b71ec0909180453p11cccb9ag4e90caa4c9b8719c@mail.gmail.com> Thanks Tim, That worked, Also i wrote few lines of code to reboot a remote machine. Here is it ------------------------------------------------ import win32api, win32security hdl = win32security.LogonUser(userName,domain,password,win32security.LOGON32_LOGON_NEW_CREDENTIALS,win32security.LOGON32_PROVIDER_WINNT50) win32security.ImpersonateLoggedOnUser(hdl) win32api.InitiateSystemShutdown(hostName, "This Machine will reboot in 5 seconds", 5, False, True) win32security.RevertToSelf() hdl.close() ------------------------------------------------------ issues here is: when i place this code in if __name__ == "__main__": it runs successfully(reboots the remote machine). But if i place this code in a function of a module ( like logon part in a function and initiateshutdown in other fuction) or whole code in a function it fails giving this error: error: (5, 'InitiateSystemShutdown', 'Access is denied.') I'm i missing anything or any window's way of doing this kind of things. Thank you very much for the responce. Thanks, Siddhartha > 1. Connection to remote machine registry fails. > (siddhartha veedaluru) > 2. Re: Connection to remote machine registry fails. (Tim Roberts) > 3. Re: problem in calling excel object quit method (Tim Roberts) > 4. window events via SetWindowsHookExA (Antoine Martin) > 5. Re: window events via SetWindowsHookExA (Tim Roberts) > 6. python-win32 : cross database automation (Threader Slash) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 17 Sep 2009 18:04:15 +0530 > From: siddhartha veedaluru > To: python-win32 at python.org > Subject: [python-win32] Connection to remote machine registry fails. > Message-ID: > <424b71ec0909170534i36c31653ic277b39699e38300 at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > Hi , > > I'm trying to connect to a remote windows machine's registry using > ConnectRegistry and try to get the process architecture information. > > > Here is the code snippet for it > #processRegKey = "System\CurrentControlSet\Control\Session > Manager\Environment" > #processRegValue = "PROCESSOR_ARCHITECTURE" > #try: > # regHandle = > > ConnectRegistry(r"\\atom",HKEY_LOCAL_MACHINE > ) > # regHandleObj = OpenKey(regHandle, processRegKey) > # processType = QueryValueEx(regHandleObj, processRegValue)[0].split(" > ")[0] > # print processType > #except Exception, erno: > # print "Exception:" > # print erno > > but it fails with access denied errors. > I assume that there is credentials issue. > but i have the credential, but where should i have to provide this. > > > Please help in accesing remote machine adderss. > Also the machine might be in another domain. > > i know that we have wmi module. just try to achive it with win32 Api. > > Thanks, > sid. > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/python-win32/attachments/20090917/daf021f3/attachment-0001.htm > > > > ------------------------------ > > Message: 2 > Date: Thu, 17 Sep 2009 09:49:26 -0700 > From: Tim Roberts > To: Python-Win32 List > Subject: Re: [python-win32] Connection to remote machine registry > fails. > Message-ID: <4AB26896.70207 at probo.com> > Content-Type: text/plain; charset=ISO-8859-1 > > siddhartha veedaluru wrote: > > > > I'm trying to connect to a remote windows machine's registry using > > ConnectRegistry and try to get the process architecture information. > > > > Here is the code snippet for it > > #processRegKey = "System\CurrentControlSet\Control\Session > > Manager\Environment" > > #processRegValue = "PROCESSOR_ARCHITECTURE" > > #try: > > # regHandle = ConnectRegistry(r"\\atom",HKEY_LOCAL_MACHINE > > ) > > # regHandleObj = OpenKey(regHandle, processRegKey) > > # processType = QueryValueEx(regHandleObj, > > processRegValue)[0].split(" ")[0] > > # print processType > > #except Exception, erno: > > # print "Exception:" > > # print erno > > > > but it fails with access denied errors. > > I assume that there is credentials issue. > > but i have the credential, but where should i have to provide this. > > If the user you are currently logged in as is valid on the other > machine, this should just work. > > Otherwise, you will have to call win32security.LogonUser and > win32security.ImpersonateLoggedOnUser before calling ConnectRegistry. > > handle = win32Security.LogonUser( 'username', 'domain', 'password', > win32con.LOGON32_LOGON_INTERACTIVE, > win32con.LOGON32_PROVIDER_DEFAULT ) > win32security.ImpersonateLoggonOnUser( handle ) > > # ... connect to to registry here ... > > win32security.RevertToSelf() > handle.Close() > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > > > ------------------------------ > > Message: 3 > Date: Thu, 17 Sep 2009 09:51:19 -0700 > From: Tim Roberts > To: Python-Win32 List > Subject: Re: [python-win32] problem in calling excel object quit > method > Message-ID: <4AB26907.7050408 at probo.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Puneet Singh wrote: > > > > Hi, > > > > I am calling quit() from a thread but its not working > > > > You need to call Quit from the thread that created the Excel object. > Are you doing that? > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > > > ------------------------------ > > Message: 4 > Date: Fri, 18 Sep 2009 02:14:33 +0700 > From: Antoine Martin > To: python-win32 at python.org > Subject: [python-win32] window events via SetWindowsHookExA > Message-ID: <4AB28A99.5000407 at nagafix.co.uk> > Content-Type: text/plain; charset=UTF-8 > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA512 > > Hi, > > I am trying to use SetWindowsHookExA via ctypes to be notified when > Windows are mapped/unmapped, to get the same functionality as > SUBSTRUCTURE_MASK events on the root X-window (or is there a better way > that I have missed?) > > Here is the code: > > WIN_HOOK = CFUNCTYPE(c_long, c_int, c_uint, c_long) > def register_hook() > WH_CALLWNDPROCRET = 4 > dll_handle = ctypes.windll.user32._handle > self.call_next_hook = ctypes.windll.user32.CallNextHookEx > self.hook_handle = > types.windll.user32.SetWindowsHookExA(WH_CALLWNDPROCRET, > WIN_HOOK(window_hook), dll_handle, 0) > > def window_hook(self, nCode, wParam, lParam): > print "hello" > return self.call_next_hook(self.hook_handle, nCode, wParam, lParam) > > Something with the callback signature must be wrong because the hook > does get registered (hook_handle>0), but as soon as a window event > fires, my application is terminated. It does not even get to say hello... > > Here's what I used to figure out the C method signature: > http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx > > Apologies if this is not the right list (please let me know which one > is), it definitely looks like people here are most likely to be able to > help me. > > Thanks > Antoine > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEAREKAAYFAkqyipIACgkQGK2zHPGK1rsYnACfSmX8S99kF0JZbvjRAeFSMAGU > hIMAniBF8mbW3/9xbhSU3zD0c+xluf/p > =rWxJ > -----END PGP SIGNATURE----- > > > ------------------------------ > > Message: 5 > Date: Thu, 17 Sep 2009 14:03:48 -0700 > From: Tim Roberts > To: Python-Win32 List > Subject: Re: [python-win32] window events via SetWindowsHookExA > Message-ID: <4AB2A434.4000701 at probo.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Antoine Martin wrote: > > > > I am trying to use SetWindowsHookExA via ctypes to be notified when > > Windows are mapped/unmapped, to get the same functionality as > > SUBSTRUCTURE_MASK events on the root X-window (or is there a better way > > that I have missed?) > > WH_CALLWNDPROC is a bit extreme. The equivalent to mapping and > unmapping in the Windows world is activation, done with the WM_ACTIVATE > and WM_DEACTIVATE messages. You should be able to monitor those with > WH_CBT, which is a bit lighter weight than the WH_CALLWNDPROC hooks. > > There is a problem with your code, however: > > > > Here is the code: > > > > WIN_HOOK = CFUNCTYPE(c_long, c_int, c_uint, c_long) > > def register_hook() > > WH_CALLWNDPROCRET = 4 > > dll_handle = ctypes.windll.user32._handle > > self.call_next_hook = ctypes.windll.user32.CallNextHookEx > > self.hook_handle = > > types.windll.user32.SetWindowsHookExA(WH_CALLWNDPROCRET, > > WIN_HOOK(window_hook), dll_handle, 0) > > You are telling it that the function to be called is inside of > user32.dll. When you install an invasive hook like this, the operating > system actually injects that DLL into every process that owns a window. > Your hook function is then called in the context of those other > processes. That's why they tell you that most hook procedures must > reside in a DLL. > > In your case, the function address you gave is local to your EXE. It > won't exist in other processes (or it will point to random memory). > When the first event occurs, your callback will be called in a thread in > some other process. That thread gets an exception, because that address > points into random space, and your app is terminated. > > There used to be a great project at the University of North Carolina > called pyAA that could do this, but it hasn't been updated past Python > 2.4. At this point, I do not know of a way to implement Windows hooks > in straight Python. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > > > ------------------------------ > > Message: 6 > Date: Fri, 18 Sep 2009 14:17:09 +1000 > From: Threader Slash > To: python-win32 at python.org > Subject: [python-win32] python-win32 : cross database automation > Message-ID: > > Content-Type: text/plain; charset="iso-8859-1" > > Hello Everybody... > > I working on a client-server database solution. The system is normalized > and > is using MySQL. To automate some of processes I using Python. Part of the > old database will be still running on Lotus Notes. > > After working on it, it seems that the best choice to directly manipulate > Lotus is to use Python with win32COM - > http://www.boddie.org.uk/python/COM.html . I installed ActivePython 2.6 > compiler, which comes with integrated win32com. > > However, when I try to run.. it gives me the error: > > --x--x-- > > ActivePython 2.6.2.2 (ActiveState Software Inc.) based on > Python 2.6.2 (r262:71600, Apr 21 2009, 15:05:37) [MSC v.1500 32 bit > (Intel)] > on > win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import win32com.client > >>> sess=win32com.client.Dispatch("Lotus.NotesSession") > Traceback (most recent call last): > File "", line 1, in > File "C:\dev\python\Py26\lib\site-packages\win32com\client\__init__.py", > line 95, in Dispatch > dispatch, userName = > dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > File "C:\dev\python\Py26\lib\site-packages\win32com\client\dynamic.py", > line > 98, in _GetGoodDispatchAndUserN > ame > return (_GetGoodDispatch(IDispatch, clsctx), userName) > File "C:\dev\python\Py26\lib\site-packages\win32com\client\dynamic.py", > line > 78, in _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > pythoncom.IID_IDispatch) > pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) > > --x--x-- > > Any suggestions? Some help is mostly appreciated. > > I will keep working to get it fixed, after I post the working solution > here. > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/python-win32/attachments/20090918/6c4af594/attachment.htm > > > > ------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > End of python-win32 Digest, Vol 78, Issue 16 > ******************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: From antoine at nagafix.co.uk Fri Sep 18 18:53:55 2009 From: antoine at nagafix.co.uk (Antoine Martin) Date: Fri, 18 Sep 2009 23:53:55 +0700 Subject: [python-win32] window events via SetWindowsHookExA In-Reply-To: <4AB2A434.4000701@probo.com> References: <4AB28A99.5000407@nagafix.co.uk> <4AB2A434.4000701@probo.com> Message-ID: <4AB3BB23.6040307@nagafix.co.uk> Hi Tim, Tim Roberts wrote: > Antoine Martin wrote: >> I am trying to use SetWindowsHookExA via ctypes to be notified when >> Windows are mapped/unmapped, to get the same functionality as >> SUBSTRUCTURE_MASK events on the root X-window (or is there a better way >> that I have missed?) > > WH_CALLWNDPROC is a bit extreme. The equivalent to mapping and > unmapping in the Windows world is activation, done with the WM_ACTIVATE > and WM_DEACTIVATE messages. You should be able to monitor those with > WH_CBT, which is a bit lighter weight than the WH_CALLWNDPROC hooks. Hah, ok. > There is a problem with your code, however: > > >> Here is the code: >> >> WIN_HOOK = CFUNCTYPE(c_long, c_int, c_uint, c_long) >> def register_hook() >> WH_CALLWNDPROCRET = 4 >> dll_handle = ctypes.windll.user32._handle >> self.call_next_hook = ctypes.windll.user32.CallNextHookEx >> self.hook_handle = >> types.windll.user32.SetWindowsHookExA(WH_CALLWNDPROCRET, >> WIN_HOOK(window_hook), dll_handle, 0) > > You are telling it that the function to be called is inside of > user32.dll. When you install an invasive hook like this, the operating > system actually injects that DLL into every process that owns a window. > Your hook function is then called in the context of those other > processes. That's why they tell you that most hook procedures must > reside in a DLL. Yes, I used "dll_handle" without really understanding it... It just refused to register the hook otherwise, as it is a "global" one. I'll use another technique I think, but just for my own knowledge: if I made a DLL with my hook, how would it get loaded into the other processes' address space? Just by calling SetWindowsHookExA()? > In your case, the function address you gave is local to your EXE. It > won't exist in other processes (or it will point to random memory). > When the first event occurs, your callback will be called in a thread in > some other process. That thread gets an exception, because that address > points into random space, and your app is terminated. Yup! > There used to be a great project at the University of North Carolina > called pyAA that could do this, but it hasn't been updated past Python > 2.4. At this point, I do not know of a way to implement Windows hooks > in straight Python. Yes, I looked at that, there's a nice WindowWatcher class, but unfortunately it is not in pure python. Thanks a lot for the explanation. Antoine From timr at probo.com Fri Sep 18 19:50:38 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 18 Sep 2009 10:50:38 -0700 Subject: [python-win32] python-win32 : cross database automation In-Reply-To: References: Message-ID: <4AB3C86E.5060709@probo.com> Threader Slash wrote: > > I working on a client-server database solution. The system is > normalized and is using MySQL. To automate some of processes I using > Python. Part of the old database will be still running on Lotus Notes. > > After working on it, it seems that the best choice to directly > manipulate Lotus is to use Python with win32COM - > http://www.boddie.org.uk/python/COM.html . I installed ActivePython > 2.6 compiler, which comes with integrated win32com. > > However, when I try to run.. it gives me the error: > ... > --x--x-- > >>> sess=win32com.client.Dispatch("Lotus.NotesSession") > ...Traceback (most recent call last): > File > "C:\dev\python\Py26\lib\site-packages\win32com\client\dynamic.py", > line 78, in _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > pythoncom.IID_IDispatch) > pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) I'll ask the obvious question first. You're sure Lotus Notes is installed on this computer? The Google implication is that "Lotus.NotesSession" is the proper class name, so if Notes is installed, this should work. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Sep 18 20:24:26 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 18 Sep 2009 11:24:26 -0700 Subject: [python-win32] window events via SetWindowsHookExA In-Reply-To: <4AB3BB23.6040307@nagafix.co.uk> References: <4AB28A99.5000407@nagafix.co.uk> <4AB2A434.4000701@probo.com> <4AB3BB23.6040307@nagafix.co.uk> Message-ID: <4AB3D05A.6070603@probo.com> Antoine Martin wrote: > > Yes, I used "dll_handle" without really understanding it... It just > refused to register the hook otherwise, as it is a "global" one. > I'll use another technique I think, but just for my own knowledge: if I > made a DLL with my hook, how would it get loaded into the other > processes' address space? Just by calling SetWindowsHookExA()? > Yes. Windows handles that automatically. People don't always realize how much overhead is involved in a Windows hook, but there's a lot going on there. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From threaderslash at gmail.com Mon Sep 21 10:00:26 2009 From: threaderslash at gmail.com (Threader Slash) Date: Mon, 21 Sep 2009 18:00:26 +1000 Subject: [python-win32] python-win32 Digest, Vol 78, Issue 18 In-Reply-To: References: Message-ID: Hi Tim, Thanks for your comments. I find out going through IBM web pages that the Lotus Notes works on win32com just for versin 7.0 and 8.0. The version that was intalled in my development environment is Lotus Notes 6.0. This week I will get a Lotus Notes 7.0 Installed into my development pc. This should hopefully make it works. Threader ------------------------------ > > Message: 2 > Date: Fri, 18 Sep 2009 10:50:38 -0700 > From: Tim Roberts > To: Python-Win32 List > Subject: Re: [python-win32] python-win32 : cross database automation > Message-ID: <4AB3C86E.5060709 at probo.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Threader Slash wrote: > > > > I working on a client-server database solution. The system is > > normalized and is using MySQL. To automate some of processes I using > > Python. Part of the old database will be still running on Lotus Notes. > > > > After working on it, it seems that the best choice to directly > > manipulate Lotus is to use Python with win32COM - > > http://www.boddie.org.uk/python/COM.html . I installed ActivePython > > 2.6 compiler, which comes with integrated win32com. > > > > However, when I try to run.. it gives me the error: > > ... > > --x--x-- > > >>> sess=win32com.client.Dispatch("Lotus.NotesSession") > > ...Traceback (most recent call last): > > File > > "C:\dev\python\Py26\lib\site-packages\win32com\client\dynamic.py", > > line 78, in _GetGoodDispatch > > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > > pythoncom.IID_IDispatch) > > pywintypes.com_error: (-2147221005, 'Invalid class string', None, None) > > I'll ask the obvious question first. You're sure Lotus Notes is > installed on this computer? > > The Google implication is that "Lotus.NotesSession" is the proper class > name, so if Notes is installed, this should work. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ah.kode at gmail.com Wed Sep 23 12:12:37 2009 From: ah.kode at gmail.com (a h) Date: Wed, 23 Sep 2009 15:42:37 +0530 Subject: [python-win32] regarding ftp api call Message-ID: Hi all i have created an ftp client using ftp api provided in python. whenever i disconnect my ftp client with the ftp server by removing the wired connection, my ftp application get hanged, i traced with prints and find that whenever call made to ftp api, it never came back. How do i resolve this as it does not return any error or value. Plz help, thanks in advance ah -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Wed Sep 23 12:18:47 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 23 Sep 2009 11:18:47 +0100 Subject: [python-win32] regarding ftp api call In-Reply-To: References: Message-ID: <4AB9F607.8050501@timgolden.me.uk> a h wrote: > Hi all > i have created an ftp client using ftp api provided in python. whenever i > disconnect my ftp client with the ftp server by removing the wired > connection, my ftp application get hanged, i traced with prints and find > that whenever call made to ftp api, it never came back. How do i > resolve this as it does not return any error or value. > Plz help, thanks in advance It always helps if you provide some sort of code sample which shows the problem (or at least, where the problem occurs). But I would imagine that you've got an open socket with no timeout. As a quick workaround, try adding this before your FTP code: import socket socket.setdefaulttimeout (1.0) which will cause a socket to time out in 1 second. You'll then have to catch whatever exception it raises and do something meaningful within the context of your code. TJG From mail at timgolden.me.uk Wed Sep 23 14:04:27 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 23 Sep 2009 13:04:27 +0100 Subject: [python-win32] regarding ftp api call In-Reply-To: References: <4AB9F607.8050501@timgolden.me.uk> Message-ID: <4ABA0ECB.5090601@timgolden.me.uk> [copying back to the list] Please keep the conversation on-list, a h. We're all happy to help you, but none of us is a private consultant -- at least not an unpaid one! Also, the more people who see what you post, the more people there are who might be able to answer. a h wrote: > I have wriiten this piece of code which works fine. which retrieve files > from server and dumping to the local folder > > import ftplib > f = ftplib.FTP("server_host_name") > while True: > f.pwd() > ... > ...my logic > f.retrbinary("RETR %s"% fname, myFile.write) > ... > > but when disconnected say wire remove then it hang in loop, it does not > throw any exception or any error. I traced by putting prints, and find that > it hanged in ftp api call like "f.pwd() OR f.retrbinary()" and never return > back Did you try my suggestion of setting a socket timeout? TJG From ah.kode at gmail.com Thu Sep 24 13:33:41 2009 From: ah.kode at gmail.com (a h) Date: Thu, 24 Sep 2009 17:03:41 +0530 Subject: [python-win32] regarding ftp api call In-Reply-To: <4ABA0ECB.5090601@timgolden.me.uk> References: <4AB9F607.8050501@timgolden.me.uk> <4ABA0ECB.5090601@timgolden.me.uk> Message-ID: hi thanks for the replies. setting socket timeout works fine. I also find alternate way that perform the same thing,ie ftp connection timeout. import ftplib f = ftplib.FTP("server_host_name", "TIMEOUT") thanks & regards ah On Wed, Sep 23, 2009 at 5:34 PM, Tim Golden wrote: > [copying back to the list] > > Please keep the conversation on-list, a h. We're all > happy to help you, but none of us is a private > consultant -- at least not an unpaid one! Also, > the more people who see what you post, the more > people there are who might be able to answer. > > a h wrote: > >> I have wriiten this piece of code which works fine. which retrieve files >> from server and dumping to the local folder >> >> import ftplib >> f = ftplib.FTP("server_host_name") >> while True: >> f.pwd() >> ... >> ...my logic >> f.retrbinary("RETR %s"% fname, myFile.write) >> ... >> >> but when disconnected say wire remove then it hang in loop, it does not >> throw any exception or any error. I traced by putting prints, and find >> that >> it hanged in ftp api call like "f.pwd() OR f.retrbinary()" and never >> return >> back >> > > > Did you try my suggestion of setting a socket timeout? > > > TJG > _______________________________________________ > 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: From mail at timgolden.me.uk Thu Sep 24 13:43:45 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 24 Sep 2009 12:43:45 +0100 Subject: [python-win32] regarding ftp api call In-Reply-To: References: <4AB9F607.8050501@timgolden.me.uk> <4ABA0ECB.5090601@timgolden.me.uk> Message-ID: <4ABB5B71.5040504@timgolden.me.uk> a h wrote: > hi > thanks for the replies. > setting socket timeout works fine. > I also find alternate way that perform the same thing,ie ftp connection > timeout. > > import ftplib > f = ftplib.FTP("server_host_name", "TIMEOUT") Thanks for posting back. And I learnt something new: that the FTP initialiser takes a timeout parameter, so thanks for educating me. I would point out, tho', that your quick example above obviously *won't* set the timeout; it will connect to the server with a username of "TIMEOUT". Hopefully you knew that and were just jotting quickly, but for any future readers, the timeout is most easily specified as a named param to the FTP constructor: f = ftplib.FTP ("mail.python.org", timeout=2.0) TJG From gerdusvanzyl at gmail.com Thu Sep 24 15:24:46 2009 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Thu, 24 Sep 2009 15:24:46 +0200 Subject: [python-win32] Windows 7 taskbar api Message-ID: <91882ea90909240624x5e412d3brf2d4e99c96497ac5@mail.gmail.com> Hi, Has anybody played with the win7 taskbar api? I just love the taskbar progress bar and would like it in my little app. But since win7 isn't even commercially available (i got mine from msdn) samples are scarce. Working from some pascal examples /vb.net interop examples /msdn docs I made the following: class ITaskbarList3(IDispatch): #_idlflags_ = ['dual', 'oleautomation'] #_case_insensitive_ = True _iid_ = comtypes.GUID('{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}') _methods_ = [ COMMETHOD([], HRESULT, "SetProgressValue", ( ['in'], HWND, "hwnd" ), ( ['in'], c_longlong, "ullCompleted" ), ( ['in'], c_longlong, "ullTotal" ) ), COMMETHOD([], HRESULT, "SetProgressState", ( ['in'], c_int, "hwnd" ), ( ['in'], c_short, "tbpFlags" ) ), COMMETHOD([], HRESULT, "HrInit" ) ] taskbar =cc.CreateObject("{56FDF344-FD6D-11d0-958A-006097C9A090}",interface=ITaskbarList3) print taskbar.SetProgressValue(hWnd,50,100) which of course does not work it gives the following error: ValueError: Procedure probably called with too many arguments (16 bytes in excess) Or if I could get some advice on how to find out what to gen via GetModule since the 3 different files mentioned actxprxy.dll,explorerframe.dll,shell32 gives Error loading type library/DLL or in shell32's case doesn't have ITaskbarList3. any help in seeing what's wrong is appreciated. thank you. ~Gerdus From antoine at nagafix.co.uk Sat Sep 26 22:13:53 2009 From: antoine at nagafix.co.uk (Antoine Martin) Date: Sun, 27 Sep 2009 03:13:53 +0700 Subject: [python-win32] daemonized child Message-ID: <4ABE7601.3000808@nagafix.co.uk> Hi list, What is the best way to ensure that a child started with subprocess.Popen does not get killed when its parent terminates on win32? On Linux I can daemonize the child with fork()s and dup2()s But what about windows? What about a child process that I cannot re-write, is there anything I can do in that case? (without wrapping it in a script if possible) I do not want a windows service (unless I misunderstand the concept), just the ability to start a normal app (say Notepad) and make sure it survives if/when its parent terminates. Thanks Antoine From efotinis at yahoo.com Sun Sep 27 09:51:18 2009 From: efotinis at yahoo.com (Elias Fotinis) Date: Sun, 27 Sep 2009 10:51:18 +0300 Subject: [python-win32] daemonized child In-Reply-To: <4ABE7601.3000808@nagafix.co.uk> References: <4ABE7601.3000808@nagafix.co.uk> Message-ID: <7E1E01F7B2FB492480B692F609A56B51@efcore> From: "Antoine Martin" > What is the best way to ensure that a child started with > subprocess.Popen does not get killed when its parent terminates on win32? > On Linux I can daemonize the child with fork()s and dup2()s > But what about windows? You don't have to do anything. The lifetime of a child process in Windows is not affected by that of its parent. From gerdusvanzyl at gmail.com Sun Sep 27 16:57:46 2009 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Sun, 27 Sep 2009 16:57:46 +0200 Subject: [python-win32] Windows 7 taskbar api In-Reply-To: <91882ea90909240624x5e412d3brf2d4e99c96497ac5@mail.gmail.com> References: <91882ea90909240624x5e412d3brf2d4e99c96497ac5@mail.gmail.com> Message-ID: <91882ea90909270757q809c52dwafd2c303736314a6@mail.gmail.com> Thanks to this post http://www.neowin.net/forum/index.php?s=6352ade29ce66f2b51506c64e455d2f4&showtopic=716968&st=0&p=590434472&#entry590434472 I got the idl that I could convert to a typelib and then use cc.GetModule("taskbar.tlb"); The only trouble is you have to specify the import comtypes.gen.TaskbarLib as tbl taskbar =cc.CreateObject("{56FDF344-FD6D-11d0-958A-006097C9A090}",interface=tbl.ITaskbarList3) instead of just: taskbar = tbl.TaskbarList() because the typelib from the IDL is missing, I am assuming it comes with the Win7 SDK. This is a problem since I would have to ship the generated interface if I decide to use this code. Anyway usage is then straightforward: taskbar.HrInit() taskbar.SetProgressValue(hWnd,25,100) Anyway I'm guessing/hoping there will be Windows 7 support in a future version of win32com :-) ~G On Thu, Sep 24, 2009 at 3:24 PM, Gerdus van Zyl wrote: > Hi, > > Has anybody played with the win7 taskbar api? I just love the taskbar > progress bar and would like it in my little app. But since win7 isn't > even commercially available (i got mine from msdn) samples are scarce. > > Working from some pascal examples /vb.net interop examples /msdn docs > I made the following: > > ? ? ? ?class ITaskbarList3(IDispatch): > ? ? ? ? ? ?#_idlflags_ = ['dual', 'oleautomation'] > ? ? ? ? ? ?#_case_insensitive_ = True > ? ? ? ? ? ?_iid_ = comtypes.GUID('{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}') > ? ? ? ? ? ?_methods_ = [ > ? ? ? ? ? ? ? ?COMMETHOD([], > ? ? ? ? ? ? ? ? ? ? ? ? ? ?HRESULT, > ? ? ? ? ? ? ? ? ? ? ? ? ? ?"SetProgressValue", > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?( ['in'], HWND, "hwnd" ), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?( ['in'], c_longlong, "ullCompleted" ), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?( ['in'], c_longlong, "ullTotal" ) > ? ? ? ? ? ? ? ? ? ? ? ? ?), > ? ? ? ? ? ? ? ?COMMETHOD([], > ? ? ? ? ? ? ? ? ? ? ? ? ? ?HRESULT, > ? ? ? ? ? ? ? ? ? ? ? ? ? ?"SetProgressState", > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?( ['in'], c_int, "hwnd" ), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?( ['in'], c_short, "tbpFlags" ) > ? ? ? ? ? ? ? ? ? ? ? ? ?), > ? ? ? ? ? ? ? ?COMMETHOD([], > ? ? ? ? ? ? ? ? ? ? ? ? ? ?HRESULT, > ? ? ? ? ? ? ? ? ? ? ? ? ? ?"HrInit" > ? ? ? ? ? ? ? ? ? ? ? ? ?) > ? ? ? ? ? ? ? ?] > > ? ? ? ?taskbar > =cc.CreateObject("{56FDF344-FD6D-11d0-958A-006097C9A090}",interface=ITaskbarList3) > ? ? ? ?print taskbar.SetProgressValue(hWnd,50,100) > > which of course does not work it gives the following error: > ValueError: Procedure probably called with too many arguments (16 > bytes in excess) > > Or if I could get some advice on how to find out what to gen via > GetModule since the 3 different files mentioned > actxprxy.dll,explorerframe.dll,shell32 gives ?Error loading type > library/DLL or in shell32's case doesn't have ITaskbarList3. > > any help in seeing what's wrong is appreciated. > > thank you. > > ~Gerdus > From antoine at nagafix.co.uk Mon Sep 28 06:32:24 2009 From: antoine at nagafix.co.uk (Antoine Martin) Date: Mon, 28 Sep 2009 11:32:24 +0700 Subject: [python-win32] daemonized child In-Reply-To: <7E1E01F7B2FB492480B692F609A56B51@efcore> References: <4ABE7601.3000808@nagafix.co.uk> <7E1E01F7B2FB492480B692F609A56B51@efcore> Message-ID: <4AC03C58.6040305@nagafix.co.uk> Elias Fotinis wrote: > From: "Antoine Martin" >> What is the best way to ensure that a child started with >> subprocess.Popen does not get killed when its parent terminates on win32? >> On Linux I can daemonize the child with fork()s and dup2()s >> But what about windows? > > You don't have to do anything. The lifetime of a child process in > Windows is not affected by that of its parent. > Hah, that's easier than I thought! I had forgotten about the pipes (doh), I guess I should start the child with stdin=stdout=stderr=None then? Antoine From efotinis at yahoo.com Mon Sep 28 12:32:05 2009 From: efotinis at yahoo.com (Elias Fotinis) Date: Mon, 28 Sep 2009 13:32:05 +0300 Subject: [python-win32] daemonized child In-Reply-To: <4AC03C58.6040305@nagafix.co.uk> References: <4ABE7601.3000808@nagafix.co.uk> <7E1E01F7B2FB492480B692F609A56B51@efcore> <4AC03C58.6040305@nagafix.co.uk> Message-ID: <795A622307E44D959F945AF2D9C96793@efcore> From: "Antoine Martin" > Hah, that's easier than I thought! Sure is. The hard part is terminating a bunch of processes as group (either manually with PIDs or using job objects). > I had forgotten about the pipes (doh), I guess I should start the child > with stdin=stdout=stderr=None then? Yes, if you don't want any special handling. The child will then inherit the parent's handles. These are, by default, the STDIN/OUT/ERR for console programs and NUL for GUI programs. From theller at ctypes.org Mon Sep 28 19:47:21 2009 From: theller at ctypes.org (Thomas Heller) Date: Mon, 28 Sep 2009 19:47:21 +0200 Subject: [python-win32] Windows 7 taskbar api In-Reply-To: <91882ea90909270757q809c52dwafd2c303736314a6@mail.gmail.com> References: <91882ea90909240624x5e412d3brf2d4e99c96497ac5@mail.gmail.com> <91882ea90909270757q809c52dwafd2c303736314a6@mail.gmail.com> Message-ID: Gerdus van Zyl schrieb: > Thanks to this post > http://www.neowin.net/forum/index.php?s=6352ade29ce66f2b51506c64e455d2f4&showtopic=716968&st=0&p=590434472&#entry590434472 > > I got the idl that I could convert to a typelib and then use > cc.GetModule("taskbar.tlb"); > > The only trouble is you have to specify the > import comtypes.gen.TaskbarLib as tbl > taskbar =cc.CreateObject("{56FDF344-FD6D-11d0-958A-006097C9A090}",interface=tbl.ITaskbarList3) > > instead of just: > taskbar = tbl.TaskbarList() > because the typelib from the IDL is missing, I am assuming it comes > with the Win7 SDK. This is a problem since I would have to ship the > generated interface if I decide to use this code. It should not be a problem if you ship the generated file, as long as the ITaskbarList* interfaces do not change (they should never change). You would probably rename the comtypes.gen._683BF642_E9CA_4124_BE43_67065B2FA653_0_1_0 to something more sensible, and move out of the comtypes\gen directory so that it doesn't get replaced or deleted by accident. Creating an instance would be easier if you use code like this which uses the _reg_clsid_ attribute from the generated CoClass: from somewhere import ITaskbarList3, TaskbarList taskbar = CreateObject(TaskbarList._reg_clsid_, interface=ITaskbarList3) -- Thanks, Thomas From timr at probo.com Mon Sep 28 20:04:54 2009 From: timr at probo.com (Tim Roberts) Date: Mon, 28 Sep 2009 11:04:54 -0700 Subject: [python-win32] Windows 7 taskbar api In-Reply-To: <91882ea90909270757q809c52dwafd2c303736314a6@mail.gmail.com> References: <91882ea90909240624x5e412d3brf2d4e99c96497ac5@mail.gmail.com> <91882ea90909270757q809c52dwafd2c303736314a6@mail.gmail.com> Message-ID: <4AC0FAC6.6070708@probo.com> Gerdus van Zyl wrote: > Thanks to this post > http://www.neowin.net/forum/index.php?s=6352ade29ce66f2b51506c64e455d2f4&showtopic=716968&st=0&p=590434472&#entry590434472 > > I got the idl that I could convert to a typelib and then use > cc.GetModule("taskbar.tlb"); > > The only trouble is you have to specify the > import comtypes.gen.TaskbarLib as tbl > taskbar =cc.CreateObject("{56FDF344-FD6D-11d0-958A-006097C9A090}",interface=tbl.ITaskbarList3) > > instead of just: > taskbar = tbl.TaskbarList() > > because the typelib from the IDL is missing, I am assuming it comes > with the Win7 SDK. This is a problem since I would have to ship the > generated interface if I decide to use this code. > The IDL ships with the Win 7 SDK. The typelib does not. You should be able to ship a copy of TaskbarLib with your project. Further, you could modify it to include the CLSID_TaskbarList constant so you don't have to embed the GUID every time. > Anyway I'm guessing/hoping there will be Windows 7 support in a future > version of win32com :-) > Comtypes is not part of win32com. Further, win32com does not include implementations for every conceivable COM object in the system. Indeed, the code you have there is very similar to what the equivalent C++ code would look like for this task. The only difference is that I would be able to use CLSID_TaskbarList instead of "{56FDF344-...}". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gerdusvanzyl at gmail.com Mon Sep 28 21:50:06 2009 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Mon, 28 Sep 2009 21:50:06 +0200 Subject: [python-win32] Windows 7 taskbar api In-Reply-To: References: <91882ea90909240624x5e412d3brf2d4e99c96497ac5@mail.gmail.com> <91882ea90909270757q809c52dwafd2c303736314a6@mail.gmail.com> Message-ID: <91882ea90909281250i516d9c9al45a541bb27a7e27@mail.gmail.com> >You would probably rename the comtypes.gen._683BF642_E9CA_4124_BE43_67065B2FA653_0_1_0 >to something more sensible > Creating an instance would be easier if you use code like > this which uses the _reg_clsid_ attribute from the generated CoClass:> > from win7taskbar import ITaskbarList3, TaskbarList > taskbar = CreateObject(TaskbarList._reg_clsid_, interface=ITaskbarList3)> Good suggestion, I have done so. If anyone wants something similar the code lives here: http://code.google.com/p/uxpython/source/browse/#svn/trunk/uxpy/platforms From greg.ewing at canterbury.ac.nz Tue Sep 29 01:23:08 2009 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Tue, 29 Sep 2009 11:23:08 +1200 Subject: [python-win32] daemonized child In-Reply-To: <795A622307E44D959F945AF2D9C96793@efcore> References: <4ABE7601.3000808@nagafix.co.uk> <7E1E01F7B2FB492480B692F609A56B51@efcore> <4AC03C58.6040305@nagafix.co.uk> <795A622307E44D959F945AF2D9C96793@efcore> Message-ID: <4AC1455C.3090600@canterbury.ac.nz> Elias Fotinis wrote: > From: "Antoine Martin" > >> I had forgotten about the pipes (doh), I guess I should start the child >> with stdin=stdout=stderr=None then? That won't necessarily close the OS-level file descriptors, though. If you want that, you need to do something like for i in xrange(3): os.close(i) -- Greg From davea at ieee.org Wed Sep 30 19:10:20 2009 From: davea at ieee.org (Dave Angel) Date: Wed, 30 Sep 2009 13:10:20 -0400 Subject: [python-win32] Unable to install PyWin32 with Python 2.6.2 In-Reply-To: <4A9879A9.40300@nsidc.org> References: <4A9879A9.40300@nsidc.org> Message-ID: <4AC390FC.2030400@ieee.org> Terry Haran wrote: >
Hi Chris: > > I'm getting: > error: Unable to find vcvarsall.bat > when running > setup.py install > with pywin32-214 > and Python 2.6.2 > under > Microsoft Windows XP [Version 5.1.2600] > on a > Panasonic CF-19 Series Toughbook. > > Any help would be greatly appreciated. > > Thanks, > --Terry > vcvarsall.bat is a batch file installed as part of Microsoft C (recent versions). So presumably you're trying to install pywin32 from C sources. Do you have a compatible version of MSC? Have you considered installing pywin32 from binary? http://sourceforge.net/projects/pywin32/ DaveA From cappy2112 at gmail.com Wed Sep 30 20:19:41 2009 From: cappy2112 at gmail.com (Tony Cappellini) Date: Wed, 30 Sep 2009 11:19:41 -0700 Subject: [python-win32] Talking to the parallel port Message-ID: <8249c4ac0909301119n520649aaq40405eecd47590fd@mail.gmail.com> I'm looking for some way to wiggle the data lines on the parallel port- and possibly even to use some of them as input lines. Googling for python parallel port revealed an old project which hasn't been updated since 2003. http://pyserial.sourceforge.net/pyparallel.html Is there anything that is more current? Thanks Tony -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Sep 30 20:56:01 2009 From: timr at probo.com (Tim Roberts) Date: Wed, 30 Sep 2009 11:56:01 -0700 Subject: [python-win32] Talking to the parallel port In-Reply-To: <8249c4ac0909301119n520649aaq40405eecd47590fd@mail.gmail.com> References: <8249c4ac0909301119n520649aaq40405eecd47590fd@mail.gmail.com> Message-ID: <4AC3A9C1.4000209@probo.com> Tony Cappellini wrote: > > I'm looking for some way to wiggle the data lines on the parallel > port- and possibly even to use some of them as input lines. > > Googling for python parallel port revealed an old project which hasn't > been updated since 2003. > http://pyserial.sourceforge.net/pyparallel.html > Is there anything that is more current? Why would you expect any updates? The technology behind the parallel port has not changed since 1994. Actually, the web page has remained the same, but the code base has been updated more recently. On the down side, this implements only the SPP interface. It doesn't do ECP or EPP, which means you can only input from the 4 status lines; you can't do true bidirectional stuff. Also, you'll have to locate the "giveio.sys" driver in order to access the I/O ports, which probably excludes 64-bit systems. It's getting more and more difficult to find machines with real parallel ports. (Pyparallel won't work with a parallel/USB adapter.) If it were me, I would forget about the parallel port and get a simple USB experimenter's board. Many of them come with a large set of GPIO lines. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc.