From kxroberto at googlemail.com Thu Jul 2 23:06:40 2009 From: kxroberto at googlemail.com (Robert) Date: Thu, 02 Jul 2009 23:06:40 +0200 Subject: [python-win32] File Time: win32file vs Python ? Message-ID: >>> os.path.getmtime('x.txt') 1193160881 >>> int(win32file.GetFileAttributesExW('x.txt')[-2]) 1193153681 >>> int(win32file.GetFileAttributesExW('x.txt')[-2]) - os.path.getmtime('x.txt') -7200 (Win XP) is this a bug, or is there a issue with timezones/summer time? aren't time.time() values absolute? R From timr at probo.com Fri Jul 3 00:45:34 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 02 Jul 2009 15:45:34 -0700 Subject: [python-win32] File Time: win32file vs Python ? In-Reply-To: References: Message-ID: <4A4D388E.6040408@probo.com> Robert wrote: > >>> os.path.getmtime('x.txt') > 1193160881 > >>> int(win32file.GetFileAttributesExW('x.txt')[-2]) > 1193153681 > >>> int(win32file.GetFileAttributesExW('x.txt')[-2]) - > os.path.getmtime('x.txt') > -7200 > > (Win XP) > is this a bug, or is there a issue with timezones/summer time? aren't > time.time() values absolute? The meaning of time.time isn't really relevant to this. GetFileAttributesExW returns values directly from the file system, and NTFS happens to store its timestamps in UTC. os.path.getmtime adjusts to local time. FAT file systems record timestamps in local time, which causes the reported times to change during summer time. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Paul_Koning at Dell.com Thu Jul 2 23:14:09 2009 From: Paul_Koning at Dell.com (Paul Koning) Date: Thu, 2 Jul 2009 17:14:09 -0400 Subject: [python-win32] File Time: win32file vs Python ? In-Reply-To: References: Message-ID: Maybe one is defined to return local time while the other returns the time value as UTC? I don't have the docs, but they should tell... paul > -----Original Message----- > From: python-win32-bounces+pkoning=equallogic.com at python.org > [mailto:python-win32-bounces+pkoning=equallogic.com at python.org] On > Behalf Of Robert > Sent: Thursday, July 02, 2009 5:07 PM > To: python-win32 at python.org > Subject: [python-win32] File Time: win32file vs Python ? > > > >>> os.path.getmtime('x.txt') > 1193160881 > >>> int(win32file.GetFileAttributesExW('x.txt')[-2]) > 1193153681 > >>> int(win32file.GetFileAttributesExW('x.txt')[-2]) - > os.path.getmtime('x.txt') > -7200 > > (Win XP) > is this a bug, or is there a issue with timezones/summer time? > aren't time.time() values absolute? > > R > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From marium.ahmad10 at gmail.com Fri Jul 3 11:18:53 2009 From: marium.ahmad10 at gmail.com (Marium Ahmad) Date: Fri, 3 Jul 2009 14:18:53 +0500 Subject: [python-win32] problem encounter in making exe of wxpython application Message-ID: <8fd4350e0907030218k50bc857dhbaa7208a90d092bb@mail.gmail.com> hi all, i m new to wx python.i found difficulty in making its exe.Although m using the code for exe as: # from distutils.core import setup import py2exe import sys,glob,os if len(sys.argv) == 1: sys.argv.append("py2exe") # creates a standalone .exe file, no zip files setup( options = {"py2exe": {"compressed": 1, "optimize": 2, "ascii": 1, "bundle_files": 1}}, zipfile = None, windows = [{"script": 'testing gui.py'}] ) but when i clicked gui.exe from dist folder then it raises module error as: Traceback (most recent call last): File "gui.py", line 1, in File "zipextimporter.pyo", line 82, in load_module File "wx\__init__.pyo", line 45, in File "zipextimporter.pyo", line 82, in load_module File "wx\_core.pyo", line 4, in File "zipextimporter.pyo", line 98, in load_module ImportError: MemoryLoadLibrary failed loading wx\_core_.pyd Although with the help of this exe code i have generated many exe files(not based on wxpython) Kindly help me in this regard.ur every suggestion will b honoured. Thanks in advance! Marium -------------- next part -------------- An HTML attachment was scrubbed... URL: From kxroberto at googlemail.com Fri Jul 3 12:58:46 2009 From: kxroberto at googlemail.com (Robert) Date: Fri, 03 Jul 2009 12:58:46 +0200 Subject: [python-win32] File Time: win32file vs Python ? In-Reply-To: <4A4D388E.6040408@probo.com> References: <4A4D388E.6040408@probo.com> Message-ID: Tim Roberts wrote: > Robert wrote: >>>>> os.path.getmtime('x.txt') >> 1193160881 >>>>> int(win32file.GetFileAttributesExW('x.txt')[-2]) >> 1193153681 >>>>> int(win32file.GetFileAttributesExW('x.txt')[-2]) - >> os.path.getmtime('x.txt') >> -7200 >> >> (Win XP) >> is this a bug, or is there a issue with timezones/summer time? aren't >> time.time() values absolute? > > The meaning of time.time isn't really relevant to this. > GetFileAttributesExW returns values directly from the file system, and > NTFS happens to store its timestamps in UTC. os.path.getmtime adjusts > to local time. > > FAT file systems record timestamps in local time, which causes the > reported times to change during summer time. > hmm.. here os.path.getmtime() delivers exactly time.time() without any shift (NTFS) >>> open('x.txt','w').close(); time.time(); os.path.getmtime('x.txt'); int(win32file.GetFileAttributesExW('x.txt')[-2]) 1246618638.25 1246618638.25 1246611438 and win32file/int(PyTime)has the -7200 time.altzone on it. Guess it doesn't make sense. Seems PyTime internally forces to "wall clock digits" only and __int__ doesn't even respect altzone. Guess int-time values should never have local/summer on it? - (unless info is missing like on FAT.) R From kxroberto at googlemail.com Fri Jul 3 13:01:54 2009 From: kxroberto at googlemail.com (Robert) Date: Fri, 03 Jul 2009 13:01:54 +0200 Subject: [python-win32] File Time: win32file vs Python ? In-Reply-To: References: Message-ID: time.time() / getmtime() is absolute / UTC. and win32file says: compatible with time.time. a int value doesn't make sense as localtime? It even picks up daylight saving, so the int file times would change in winter >>> time.timezone -3600 >>> time.altzone -7200 R Paul Koning wrote: > Maybe one is defined to return local time while the other returns the > time value as UTC? I don't have the docs, but they should tell... > > paul > >> -----Original Message----- >> From: python-win32-bounces+pkoning=equallogic.com at python.org >> [mailto:python-win32-bounces+pkoning=equallogic.com at python.org] On >> Behalf Of Robert >> Sent: Thursday, July 02, 2009 5:07 PM >> To: python-win32 at python.org >> Subject: [python-win32] File Time: win32file vs Python ? >> >> >> >>> os.path.getmtime('x.txt') >> 1193160881 >> >>> int(win32file.GetFileAttributesExW('x.txt')[-2]) >> 1193153681 >> >>> int(win32file.GetFileAttributesExW('x.txt')[-2]) - >> os.path.getmtime('x.txt') >> -7200 >> >> (Win XP) >> is this a bug, or is there a issue with timezones/summer time? >> aren't time.time() values absolute? >> >> R >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 From davea at ieee.org Fri Jul 3 13:50:45 2009 From: davea at ieee.org (Dave Angel) Date: Fri, 03 Jul 2009 07:50:45 -0400 Subject: [python-win32] File Time: win32file vs Python ? In-Reply-To: <4A4D388E.6040408@probo.com> References: <4A4D388E.6040408@probo.com> Message-ID: <4A4DF095.3020000@ieee.org> Tim Roberts wrote: > Robert wrote: > >>>>> os.path.getmtime('x.txt') >>>>> >> 1193160881 >> >>>>> int(win32file.GetFileAttributesExW('x.txt')[-2]) >>>>> >> 1193153681 >> >>>>> int(win32file.GetFileAttributesExW('x.txt')[-2]) - >>>>> >> os.path.getmtime('x.txt') >> -7200 >> >> (Win XP) >> is this a bug, or is there a issue with timezones/summer time? aren't >> time.time() values absolute? >> > > The meaning of time.time isn't really relevant to this. > GetFileAttributesExW returns values directly from the file system, and > NTFS happens to store its timestamps in UTC. os.path.getmtime adjusts > to local time. > > FAT file systems record timestamps in local time, which causes the > reported times to change during summer time. > > That's part of the explanation. That explains why the symptom doesn't show up on FAT systems, but not what the symptom is really about. When converting UCT to local time, there are two reasonable algorithms. For most people, one of them makes sense, so the other sounds like a bug. But people are very split as to which one is the "right" one. If you're converting the current time to local, it seems logical that you'd add the timezone offset, adjust for daylight-savings if it's "summer," and be done. And if two people do it in two different time zones they'd get different answers for "now." Likewise if one of them is in a state or country that doesn't honor dst, they'd be off by an hour. But what's the "right" answer for a file timestamp, or for any other historical date/time? If the file (on a laptop, NTFS, say) was created in California, and being examined in Maine a few months later, you'd expect that the Maine time zone would be used. After all, the file system doesn't store the fact that the laptop happened to be in California when the file was created. But what about the dst (daylight-savings) conversion? That's the problem. One philosophy says it should be the dst state that was in effect at the time the file was created, while the other applies the dst state at the time of the conversion. If I recall correctly, getmtime() uses the first approach, while GetFileAttributesExW() (and DIR) use the second. The net effect of this is that if last winter you created a file at 3pm, and you have NOT changed time zones, then when you look at that file now with GetFileAttributesExW() it'll tell you it was created at 4pm. Notice that remote file access can complicate this, as can programs that store the time stamp in local time. I ran into this problem many years ago when saving digests of files to later check for corruption. I suspect you'd have the same problem when restoring a file from CD, if daylight savings time has changed. It's time stamp would be recreated wrong. Similarly zip files or other archives. I've even run into something similar on a FAT drive, when I ran across a file that was created during the "impossible" time each spring between 2 and 3am on dst-day. From marium.ahmad10 at gmail.com Fri Jul 3 11:02:59 2009 From: marium.ahmad10 at gmail.com (Marium Ahmad) Date: Fri, 3 Jul 2009 14:02:59 +0500 Subject: [python-win32] problem in making exe of python Message-ID: <8fd4350e0907030202w1c720c78nc7c5ba391601261@mail.gmail.com> hi all, i m new to wx python.i found difficulty in making its exe.Although m using the code for exe as: # from distutils.core import setup import py2exe import sys,glob,os if len(sys.argv) == 1: sys.argv.append("py2exe") # creates a standalone .exe file, no zip files setup( options = {"py2exe": {"compressed": 1, "optimize": 2, "ascii": 1, "bundle_files": 1}}, zipfile = None, windows = [{"script": 'testing gui.py'}] ) but when i clicked gui.exe from dist folder then it raises module error as: Traceback (most recent call last): File "gui.py", line 1, in File "zipextimporter.pyo", line 82, in load_module File "wx\__init__.pyo", line 45, in File "zipextimporter.pyo", line 82, in load_module File "wx\_core.pyo", line 4, in File "zipextimporter.pyo", line 98, in load_module ImportError: MemoryLoadLibrary failed loading wx\_core_.pyd Although with the help of this exe code i have generated many exe files(not based on wxpython) Kindly help me in this regard.ur every suggestion will b honoured. Thanks in advance! Marium -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Sat Jul 4 08:20:47 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sat, 04 Jul 2009 16:20:47 +1000 Subject: [python-win32] Shell extension debugging In-Reply-To: <4A491161.9020609@probo.com> References: <6ime459249gditg4jvujth4gf4h5l9aujd@4ax.com> <4A48F874.80206@probo.com> <4A491161.9020609@probo.com> Message-ID: <4A4EF4BF.30100@gmail.com> On 30/06/2009 5:09 AM, Tim Roberts wrote: > Gertjan Klein wrote: >> It doesn't over here, but another poster has shown me how to circumvent >> this. If this is the only way to do that I will; there is no way to tell >> PyWin32 to reload the extension? (I know reloading in Python is tough, >> I'm expecting a "no" here. ;-)) >> > > I was going to respond "no" immediately, but now you've got me > thinking. Explorer loads the DLL, instantiates the COM object, and > keeps it loaded forever. I think that fact alone makes it impossible; > even if you added a backdoor to reload the module, you still have an > object in memory using the original implementation. I haven't caught up with the rest of the thread yet, but in my experience, the shell keeps objects alive for as shorter time as possible. So you may find a completely new instance is requested for each context menu request (or for each different item selected, or something), so arranging to 'reload' your implementation module may well work. I've even used the 'Python.Server' object to reload via Exec() calls. Cheers, Mark From kxroberto at googlemail.com Sat Jul 4 08:31:11 2009 From: kxroberto at googlemail.com (Robert) Date: Sat, 04 Jul 2009 08:31:11 +0200 Subject: [python-win32] File Time: win32file vs Python ? In-Reply-To: <4A4DF095.3020000@ieee.org> References: <4A4D388E.6040408@probo.com> <4A4DF095.3020000@ieee.org> Message-ID: Dave Angel wrote: > Tim Roberts wrote: >> Robert wrote: >> >>>>>> os.path.getmtime('x.txt') >>>>>> >>> 1193160881 >>> >>>>>> int(win32file.GetFileAttributesExW('x.txt')[-2]) >>>>>> >>> 1193153681 >>> >>>>>> int(win32file.GetFileAttributesExW('x.txt')[-2]) - >>>>>> >>> os.path.getmtime('x.txt') >>> -7200 >>> >>> (Win XP) >>> is this a bug, or is there a issue with timezones/summer time? aren't >>> time.time() values absolute? >>> >> >> The meaning of time.time isn't really relevant to this. >> GetFileAttributesExW returns values directly from the file system, and >> NTFS happens to store its timestamps in UTC. os.path.getmtime adjusts >> to local time. >> >> FAT file systems record timestamps in local time, which causes the >> reported times to change during summer time. >> >> > That's part of the explanation. That explains why the symptom doesn't > show up on FAT systems, but not what the symptom is really about. > > When converting UCT to local time, there are two reasonable algorithms. > For most people, one of them makes sense, so the other sounds like a > bug. But people are very split as to which one is the "right" one. > > > If you're converting the current time to local, it seems logical that > you'd add the timezone offset, adjust for daylight-savings if it's > "summer," and be done. And if two people do it in two different time > zones they'd get different answers for "now." Likewise if one of them > is in a state or country that doesn't honor dst, they'd be off by an hour. > > But what's the "right" answer for a file timestamp, or for any other > historical date/time? If the file (on a laptop, NTFS, say) was created > in California, and being examined in Maine a few months later, you'd > expect that the Maine time zone would be used. After all, the file > system doesn't store the fact that the laptop happened to be in > California when the file was created. > > But what about the dst (daylight-savings) conversion? That's the > problem. One philosophy says it should be the dst state that was in > effect at the time the file was created, while the other applies the dst > state at the time of the conversion. If I recall correctly, getmtime() > uses the first approach, while GetFileAttributesExW() (and DIR) use the > second. > > > The net effect of this is that if last winter you created a file at 3pm, > and you have NOT changed time zones, then when you look at that file now > with GetFileAttributesExW() it'll tell you it was created at 4pm. > > Notice that remote file access can complicate this, as can programs that > store the time stamp in local time. I ran into this problem many years > ago when saving digests of files to later check for corruption. I > suspect you'd have the same problem when restoring a file from CD, if > daylight savings time has changed. It's time stamp would be recreated > wrong. Similarly zip files or other archives. I've even run into > something similar on a FAT drive, when I ran across a file that was > created during the "impossible" time each spring between 2 and 3am on > dst-day. Well I think, the integer time does/should generally aim at a absolute value as good as possible - time.time() and os.path.getmtime() seem to do. Nothing with local/dst. No problem, no loss of information (e.g. on NTFS). Even the term "UTC" doesn't make sense so far ( except for defining *verbally* the absolute start point 1.1.1970 XX:XX UTC ) http://msdn.microsoft.com/en-us/library/ms724290(VS.85).aspx "A file time is a 64-bit value that represents the number of 100-nanosecond intervals that have elapsed since 12:00 A.M. January 1, 1601 Coordinated Universal Time (UTC). The system records file times when applications create, access, and write to files." -> just a fix offset to Python time.time() Guess this is wrong in win32file; or win32file looses info by early conversion to digits. "local/timezone/dst.." just makes sense for display values: "wall clock digits". When info is missing in time stamps / digits stored, like with FAT time stamps, then only the question arises, which assumptions to make on int-conversion - UTC/local time zone, or even DST. In that case its necessary to know (by an additional flag/attribute the assumption) R From gklein at xs4all.nl Sat Jul 4 12:06:02 2009 From: gklein at xs4all.nl (Gertjan Klein) Date: Sat, 04 Jul 2009 12:06:02 +0200 Subject: [python-win32] Shell extension debugging References: <6ime459249gditg4jvujth4gf4h5l9aujd@4ax.com> <4A48F874.80206@probo.com> <4A491161.9020609@probo.com> <4A4EF4BF.30100@gmail.com> Message-ID: Mark Hammond wrote: >I haven't caught up with the rest of the thread yet, but in my >experience, the shell keeps objects alive for as shorter time as >possible. So you may find a completely new instance is requested for >each context menu request (or for each different item selected, or >something), so arranging to 'reload' your implementation module may well >work. I've even used the 'Python.Server' object to reload via Exec() calls. A quick test (printing id(self) in the shell extention's Initialize method) seems to confirm that: it prints a different id each time. I wouldn't know how to exploit this though. Ideally, during development, I'd like the module to be reloaded for every invocation. The only way I can see to do that is to use __del__ on the instance to delete the module from sys.modules, but I've read that __del__ isn't all that reliable, and I have no idea what it would do for the interaction with pywin32. (I'm concerned about memory leaks for example.) Oh, and how does one "reload via Exec() calls"? Gertjan. From gklein at xs4all.nl Sat Jul 4 12:48:40 2009 From: gklein at xs4all.nl (Gertjan Klein) Date: Sat, 04 Jul 2009 12:48:40 +0200 Subject: [python-win32] Shell extension debugging References: <6ime459249gditg4jvujth4gf4h5l9aujd@4ax.com> <4A48F874.80206@probo.com> <4A491161.9020609@probo.com> <4A4EF4BF.30100@gmail.com> Message-ID: Mark Hammond wrote: >I haven't caught up with the rest of the thread yet, but in my >experience, the shell keeps objects alive for as shorter time as >possible. So you may find a completely new instance is requested for >each context menu request (or for each different item selected, or >something), so arranging to 'reload' your implementation module may well >work. I've even used the 'Python.Server' object to reload via Exec() calls. Another quick test confirms that the following works: def __del__(self): try: print "Deleting", self.__module__, "module." del sys.modules[self.__module__] except Exception, e: print "Failed:" print e Now every change I make to the module immediately gets picked up by the shell extension. No more killing Explorer! Can you (or anyone) see any problems with this? Gertjan. From leho at kraav.com Sat Jul 4 13:24:21 2009 From: leho at kraav.com (Leho Kraav) Date: Sat, 04 Jul 2009 14:24:21 +0300 Subject: [python-win32] DDE advise Message-ID: <4A4F3BE5.7060107@kraav.com> Hi http://mail.python.org/pipermail/python-win32/2008-October/008252.html Looks like I'm gravedigging a bit, but this one had no replies: > Hello everyone > Does anybody know how to use a DDE server that implements Advise mechanism > instead of Request? > > Best regards > Mani > I could also use the Advise mechanism with PyWin32 in a project, yet everything I tried to do in code failed to get any data sent back with Advise. Examining PyWin32 dde module source code showed there are some references to the Advise mechanism, but no clear explanation whether it is or is not fully supported. Can anyone clarify? -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Sun Jul 5 02:06:40 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sun, 05 Jul 2009 10:06:40 +1000 Subject: [python-win32] Shell extension debugging In-Reply-To: References: <6ime459249gditg4jvujth4gf4h5l9aujd@4ax.com> <4A48F874.80206@probo.com> <4A491161.9020609@probo.com> <4A4EF4BF.30100@gmail.com> Message-ID: <4A4FEE90.7050001@gmail.com> On 4/07/2009 8:48 PM, Gertjan Klein wrote: > Mark Hammond wrote: > >> I haven't caught up with the rest of the thread yet, but in my >> experience, the shell keeps objects alive for as shorter time as >> possible. So you may find a completely new instance is requested for >> each context menu request (or for each different item selected, or >> something), so arranging to 'reload' your implementation module may well >> work. I've even used the 'Python.Server' object to reload via Exec() calls. > > Another quick test confirms that the following works: > > def __del__(self): > try: > print "Deleting", self.__module__, "module." > del sys.modules[self.__module__] > except Exception, e: > print "Failed:" > print e > > Now every change I make to the module immediately gets picked up by the > shell extension. No more killing Explorer! Can you (or anyone) see any > problems with this? I'd be inclined to explicitly 'reload(mod)' rather than simply deleting it, but yeah, that is the general idea. Cheers, Mark From skippy.hammond at gmail.com Sun Jul 5 02:07:36 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sun, 05 Jul 2009 10:07:36 +1000 Subject: [python-win32] DDE advise In-Reply-To: <4A4F3BE5.7060107@kraav.com> References: <4A4F3BE5.7060107@kraav.com> Message-ID: <4A4FEEC8.6090100@gmail.com> On 4/07/2009 9:24 PM, Leho Kraav wrote: > Hi > > http://mail.python.org/pipermail/python-win32/2008-October/008252.html > > Looks like I'm gravedigging a bit, but this one had no replies: >> Hello everyone >> Does anybody know how to use a DDE server that implements Advise mechanism >> instead of Request? >> >> Best regards >> Mani >> > > I could also use the Advise mechanism with PyWin32 in a project, yet > everything I tried to do in code failed to get any data sent back with > Advise. Examining PyWin32 dde module source code showed there are some > references to the Advise mechanism, but no clear explanation whether it > is or is not fully supported. Can anyone clarify? That code hasn't been touched in a long, long time. I'm afraid you probably need to do further digging on your own :( Cheers, Mark From gagsl-py2 at yahoo.com.ar Mon Jul 6 02:14:52 2009 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 05 Jul 2009 21:14:52 -0300 Subject: [python-win32] File Time: win32file vs Python ? References: <4A4D388E.6040408@probo.com> <4A4DF095.3020000@ieee.org> Message-ID: En Sat, 04 Jul 2009 03:31:11 -0300, Robert escribi?: > Guess this is wrong in win32file; or win32file looses info by early > conversion to digits. There is certainly something fishy with win32file. GetFileTime/SetFileTime don't even agree about the times being local or UTC: from win32file import CreateFile, SetFileTime, GetFileTime, CloseHandle from win32file import GENERIC_READ, GENERIC_WRITE, OPEN_EXISTING fn = "test.txt" fh = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING, 0, 0) sts, creationTime, accessTime, writeTime = GetFileTime(fh) print creationTime, accessTime, writeTime SetFileTime(fh, creationTime, accessTime, writeTime) CloseHandle(fh) fh = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING, 0, 0) sts, creationTime, accessTime, writeTime = GetFileTime(fh) print creationTime, accessTime, writeTime CloseHandle(fh) Each time the script is executed, the file's times advances by 3 hours (I am located at GMT-3). D:\temp>python testfiletime.py 07/06/09 04:13:12 07/06/09 04:50:36 06/10/07 09:38:26 07/06/09 07:13:12 07/06/09 07:50:36 06/10/07 12:38:26 D:\temp>python testfiletime.py 07/06/09 07:13:12 07/06/09 07:50:36 06/10/07 12:38:26 07/06/09 10:13:12 07/06/09 10:50:36 06/10/07 15:38:26 D:\temp>dir test.txt El volumen de la unidad D es Dardo El n?mero de serie del volumen es: 9884-7F48 Directorio de D:\temp 10/06/2007 12:38 21.468 test.txt 1 archivos 21.468 bytes 0 dirs 204.499.968 bytes libres To restore the same date/time, I have to use: from pywintypes import Time creationTime, accessTime, writeTime = [Time(timegm(localtime(int(t)))) for t in GetFileTime(fh)[1:]] -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Mon Jul 6 04:17:42 2009 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 05 Jul 2009 23:17:42 -0300 Subject: [python-win32] File Time: win32file vs Python ? References: <4A4D388E.6040408@probo.com> <4A4DF095.3020000@ieee.org> Message-ID: En Sat, 04 Jul 2009 03:31:11 -0300, Robert escribi?: > Guess this is wrong in win32file; or win32file looses info by early > conversion to digits. There is certainly something fishy with win32file. GetFileTime/SetFileTime don't even agree about the times being local or UTC: from win32file import CreateFile, SetFileTime, GetFileTime, CloseHandle from win32file import GENERIC_READ, GENERIC_WRITE, OPEN_EXISTING fn = "test.txt" fh = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING, 0, 0) sts, creationTime, accessTime, writeTime = GetFileTime(fh) print creationTime, accessTime, writeTime SetFileTime(fh, creationTime, accessTime, writeTime) CloseHandle(fh) fh = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING, 0, 0) sts, creationTime, accessTime, writeTime = GetFileTime(fh) print creationTime, accessTime, writeTime CloseHandle(fh) Each time the script is executed, the file's times advances by 3 hours (I am located at GMT-3). D:\temp>python testfiletime.py 07/06/09 04:13:12 07/06/09 04:50:36 06/10/07 09:38:26 07/06/09 07:13:12 07/06/09 07:50:36 06/10/07 12:38:26 D:\temp>python testfiletime.py 07/06/09 07:13:12 07/06/09 07:50:36 06/10/07 12:38:26 07/06/09 10:13:12 07/06/09 10:50:36 06/10/07 15:38:26 D:\temp>dir test.txt El volumen de la unidad D es Dardo El n?mero de serie del volumen es: 9884-7F48 Directorio de D:\temp 10/06/2007 12:38 21.468 test.txt 1 archivos 21.468 bytes 0 dirs 204.499.968 bytes libres To restore the same date/time, I have to use: from pywintypes import Time creationTime, accessTime, writeTime = [Time(timegm(localtime(int(t)))) for t in GetFileTime(fh)[1:]] -- Gabriel Genellina From sabdelrazak at symbyo.com Mon Jul 6 09:40:55 2009 From: sabdelrazak at symbyo.com (Sarah Abdel Razak) Date: Mon, 6 Jul 2009 00:40:55 -0700 Subject: [python-win32] using registered python com server dll from .NET Message-ID: Hi all, I implemented a python com server and generate an executable and dll using py2exe tool. then I used regsvr32.exe to register the dll.I got a message that the registration was successful. Then I tried to add reference to that dll in .NET. But I can not find my server on the com tab of adding a reference. I want to mention that I can run the server as a python script and consume it from .net using late binding. Is there something I'm missing or doing wrong? I would appreciate any help. #hello.py import pythoncom import sys class HelloWorld: #pythoncom.frozen = 1 if hasattr(sys, 'importers'): _reg_class_spec_ = "__main__.HelloWorld" _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER _reg_clsid_ = '{CDBA816B-E80F-4545-BB68-5A3270C92A74}' _reg_desc_ = "Python Test COM Server" _reg_progid_ = "Python.TestServer" _public_methods_ = ['Hello'] _public_attrs_ = ['softspace', 'noCalls'] _readonly_attrs_ = ['noCalls'] def __init__(self): self.softspace = 1 self.noCalls = 0 def Hello(self, who): self.noCalls = self.noCalls + 1 # insert "softspace" number of spaces print "Hello" + " " * self.softspace + str(who) return "Hello" + " " * self.softspace + str(who) if __name__=='__main__': import sys if hasattr(sys, 'importers'): # running as packed executable. if '--register' in sys.argv[1:] or '--unregister' in sys.argv[1:]: # --register and --unregister work as usual import win32com.server.register win32com.server.register.UseCommandLine(HelloWorld) else: # start the server. from win32com.server import localserver localserver.serve('CDBA816B-E80F-4545-BB68-5A3270C92A74') else: import win32com.server.register win32com.server.register.UseCommandLine(HelloWorld) # setup.py from distutils.core import setup import py2exe setup(com_server = ["hello"]) Thanks -- Sarah Abdelrazak -------------- next part -------------- An HTML attachment was scrubbed... URL: From Fadhley.Salim at uk.calyon.com Mon Jul 6 11:29:35 2009 From: Fadhley.Salim at uk.calyon.com (Fadhley Salim) Date: Mon, 6 Jul 2009 10:29:35 +0100 Subject: [python-win32] Please help me find the correct way to call win32inet.WinHttpGetProxyForUrl Message-ID: I'm trying to use a feature of the Microsoft WinHttp library that has been exposed by the developers of Win32com. Unfortunately most of the library does not seem to be documented and there are no examples of the correct way to use the win32inet features via the win32com library. This is what I have so far: import win32inet hinternet = win32inet.InternetOpen("foo 1.0", 0, "", "", 0) # Does not work!!! proxy = win32inet.WinHttpGetProxyForUrl( hinternet, u"http://www.foo.com", 0 ) As you can see, all I am trying to do is use the win32inet feature to find out which proxy is the appropriate one to use for a given URL, int his case foo.com. Can you help me correct the syntax of the last line? MSN has some good documentation for the function being wrapped ( http://msdn.microsoft.com/en-us/library/aa384097%28VS.85%29.aspx ) but: * the args do not seem to map the to those of the python library perfectly. * and the python win32inet library seems to be missing the constants which are required in order to call the functions properly. Can somebody point me to the correct way to use these objects? Thanks! I'm using Python2.4.4 with Win32Com on Windows XP. -------------- next part -------------- Disclaimer CALYON UK: This email does not create a legal relationship between any member of the Cr=E9dit Agricole group and the recipient or constitute investment advice. The content of this email should not be copied or disclosed (in whole or part) to any other person. It may contain information which is confidential, privileged or otherwise protected from disclosure. If you are not the intended recipient, you should notify us and delete it from your system. Emails may be monitored, are not secure and may be amended, destroyed or contain viruses and in communicating with us such conditions are accepted. Any content which does not relate to business matters is not endorsed by us. Calyon is authorised by the Comit=e9 des Etablissements de Cr=e9dit et des Entreprises d'Investissement (CECEI) and supervised by the Commission Bancaire in France and subject to limited regulation by the Financial Services Authority. Details about the extent of our regulation by the Financial Services Authority are available from us on request. Calyon is incorporated in France with limited liability and registered in England & Wales. Registration number: FC008194. Registered office: Broadwalk House, 5 Appold Street, London, EC2A 2DA. Disclaimer CALYON France: This message and/or any attachments is intended for the sole use of its addressee. If you are not the addressee, please immediately notify the sender and then destroy the message. As this message and/or any attachments may have been altered without our knowledge, its content is not legally binding on CALYON Cr?dit Agricole CIB. All rights reserved. Ce message et ses pi?ces jointes est destin? ? l'usage exclusif de son destinataire. Si vous recevez ce message par erreur, merci d'en aviser imm?diatement l'exp?diteur et de le d?truire ensuite. Le pr?sent message pouvant ?tre alt?r? ? notre insu, CALYON Cr?dit Agricole CIB ne peut pas ?tre engag? par son contenu. Tous droits r?serv?s. From mc at mclaveau.com Mon Jul 6 13:02:36 2009 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 6 Jul 2009 13:02:36 +0200 Subject: [python-win32] using registered python com server dll from .NET In-Reply-To: References: Message-ID: <0A237C8E7B844106B4A8266A526376DF@MCI1330> Hi! It is normal. COM servers made with Python no have TLB. dotNET, for read info on a COM server need TLB. In the same way, dotNET cannot use dynamic COM server (like Python can do and use it). Except: IronPython (the last beta version) & JScript.Net (the old, no the recent "manageable" version) can use it. IMO, it is a dotNET problem, and no a Python problem. @+ -- Michel Claveau From mdriscoll at co.marshall.ia.us Mon Jul 6 15:59:27 2009 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Mon, 06 Jul 2009 08:59:27 -0500 Subject: [python-win32] problem in making exe of python In-Reply-To: <8fd4350e0907030202w1c720c78nc7c5ba391601261@mail.gmail.com> References: <8fd4350e0907030202w1c720c78nc7c5ba391601261@mail.gmail.com> Message-ID: <4A52033F.6020201@co.marshall.ia.us> Marium, > hi all, > i m new to wx python.i found difficulty in making its exe.Although m > using the code for exe as: > # > from distutils.core import setup > import py2exe > import sys,glob,os > > > if len(sys.argv) == 1: > sys.argv.append("py2exe") > > # creates a standalone .exe file, no zip files > > setup( options = {"py2exe": {"compressed": 1, "optimize": 2, "ascii": > 1, "bundle_files": 1}}, > zipfile = None, > windows = [{"script": 'testing gui.py'}] ) > > > but when i clicked gui.exe from dist folder then it raises module > error as: > > Traceback (most recent call last): > File "gui.py", line 1, in > File "zipextimporter.pyo", line 82, in load_module > File "wx\__init__.pyo", line 45, in > File "zipextimporter.pyo", line 82, in load_module > File "wx\_core.pyo", line 4, in > File "zipextimporter.pyo", line 98, in load_module > ImportError: MemoryLoadLibrary failed loading wx\_core_.pyd > > > Although with the help of this exe code i have generated many exe > files(not based on wxpython) > > Kindly help me in this regard.ur every suggestion will b honoured. > Thanks in advance! > > Marium > This list is for developers that use the PyWin32 package or similar packages. You really want the wxPython or py2exe mailing list. I have seen this error before though. I think it's related to not having one or more of the required dlls on your system. Make sure you have msvcp71.dll and MSVCR71.dll and (maybe) gdiplus.dll. - Mike From kevin.horn at gmail.com Mon Jul 6 23:22:32 2009 From: kevin.horn at gmail.com (Kevin Horn) Date: Mon, 6 Jul 2009 16:22:32 -0500 Subject: [python-win32] problem in making exe of python In-Reply-To: <4A52033F.6020201@co.marshall.ia.us> References: <8fd4350e0907030202w1c720c78nc7c5ba391601261@mail.gmail.com> <4A52033F.6020201@co.marshall.ia.us> Message-ID: <562bcc10907061422w6e79a335q7ea46f59f0e2bfd6@mail.gmail.com> you might look at this thread... http://aspn.activestate.com/ASPN/Mail/Message/wxpython-users/3652025 On Mon, Jul 6, 2009 at 8:59 AM, Mike Driscoll wrote: > Marium, > > hi all, >> i m new to wx python.i found difficulty in making its exe.Although m using >> the code for exe as: >> # >> from distutils.core import setup >> import py2exe >> import sys,glob,os >> >> if len(sys.argv) == 1: >> sys.argv.append("py2exe") >> # creates a standalone .exe file, no zip files >> >> setup( options = {"py2exe": {"compressed": 1, "optimize": 2, "ascii": 1, >> "bundle_files": 1}}, >> zipfile = None, >> windows = [{"script": 'testing gui.py'}] ) >> >> >> but when i clicked gui.exe from dist folder then it raises module error >> as: >> >> Traceback (most recent call last): >> File "gui.py", line 1, in >> File "zipextimporter.pyo", line 82, in load_module >> File "wx\__init__.pyo", line 45, in >> File "zipextimporter.pyo", line 82, in load_module >> File "wx\_core.pyo", line 4, in >> File "zipextimporter.pyo", line 98, in load_module >> ImportError: MemoryLoadLibrary failed loading wx\_core_.pyd >> >> >> Although with the help of this exe code i have generated many exe >> files(not based on wxpython) >> >> Kindly help me in this regard.ur every suggestion will b honoured. >> Thanks in advance! >> >> Marium >> >> > This list is for developers that use the PyWin32 package or similar > packages. You really want the wxPython or py2exe mailing list. > > I have seen this error before though. I think it's related to not having > one or more of the required dlls on your system. Make sure you have > msvcp71.dll and MSVCR71.dll and (maybe) gdiplus.dll. > > - Mike > _______________________________________________ > 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 Fadhley.Salim at uk.calyon.com Tue Jul 7 10:16:03 2009 From: Fadhley.Salim at uk.calyon.com (Fadhley Salim) Date: Tue, 7 Jul 2009 09:16:03 +0100 Subject: [python-win32] Sourceforge pywin32 site seems to be down In-Reply-To: References: Message-ID: https://sourceforge.net/projects/pywin32/ The Sourceforge PyWin32 download site seems to have been down for a very long time. Is there an alternate source of downloads? Thanks -------------- next part -------------- Disclaimer CALYON UK: This email does not create a legal relationship between any member of the Cr=E9dit Agricole group and the recipient or constitute investment advice. The content of this email should not be copied or disclosed (in whole or part) to any other person. It may contain information which is confidential, privileged or otherwise protected from disclosure. If you are not the intended recipient, you should notify us and delete it from your system. Emails may be monitored, are not secure and may be amended, destroyed or contain viruses and in communicating with us such conditions are accepted. Any content which does not relate to business matters is not endorsed by us. Calyon is authorised by the Comit=e9 des Etablissements de Cr=e9dit et des Entreprises d'Investissement (CECEI) and supervised by the Commission Bancaire in France and subject to limited regulation by the Financial Services Authority. Details about the extent of our regulation by the Financial Services Authority are available from us on request. Calyon is incorporated in France with limited liability and registered in England & Wales. Registration number: FC008194. Registered office: Broadwalk House, 5 Appold Street, London, EC2A 2DA. Disclaimer CALYON France: This message and/or any attachments is intended for the sole use of its addressee. If you are not the addressee, please immediately notify the sender and then destroy the message. As this message and/or any attachments may have been altered without our knowledge, its content is not legally binding on CALYON Cr?dit Agricole CIB. All rights reserved. Ce message et ses pi?ces jointes est destin? ? l'usage exclusif de son destinataire. Si vous recevez ce message par erreur, merci d'en aviser imm?diatement l'exp?diteur et de le d?truire ensuite. Le pr?sent message pouvant ?tre alt?r? ? notre insu, CALYON Cr?dit Agricole CIB ne peut pas ?tre engag? par son contenu. Tous droits r?serv?s. From mail at timgolden.me.uk Tue Jul 7 10:31:08 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 07 Jul 2009 09:31:08 +0100 Subject: [python-win32] Sourceforge pywin32 site seems to be down In-Reply-To: References: Message-ID: <4A5307CC.3050604@timgolden.me.uk> Fadhley Salim wrote: > https://sourceforge.net/projects/pywin32/ Works for me. > The Sourceforge PyWin32 download site seems to have been down for a very > long time. Is there an alternate source of downloads? sf has just changed their entire site, it appears. There have been grumbles about it breaking easy_install as well... Try this: http://sourceforge.net/projects/pywin32/files/ If you can't get through, let me know and I can pull something for you and drop it somewhere else. TJG From graemeglass at gmail.com Tue Jul 7 10:31:56 2009 From: graemeglass at gmail.com (Graeme Glass) Date: Tue, 7 Jul 2009 10:31:56 +0200 Subject: [python-win32] Sourceforge pywin32 site seems to be down In-Reply-To: References: Message-ID: On Tue, Jul 7, 2009 at 10:16 AM, Fadhley Salim wrote: > https://sourceforge.net/projects/pywin32/ > > > The Sourceforge PyWin32 download site seems to have been down for a very > long time. Is there an alternate source of downloads? > > Thanks > Site working fine for me. I think it might be something your side. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dalius at sandbox.lt Tue Jul 7 11:02:32 2009 From: dalius at sandbox.lt (Dalius Dobravolskas) Date: Tue, 07 Jul 2009 12:02:32 +0300 Subject: [python-win32] MemoryError: CreatingSafeArray Message-ID: <4A530F28.7000302@sandbox.lt> Hello, I'm trying to use Bentley MicroStation using COM and I met this problem. It looks like I have met the same or very similar problem as here: http://mail.python.org/pipermail/python-win32/2007-January/005453.html Required argument is 24612 but if I pass list (or tuple) of required records it fails. Here is excerpt from python prompt: >>> o1 = win32com.client.Record("Point3d", ms) >>> o1.x = 0 >>> o1.y = 0 >>> o2 = win32com.client.Record("Point3d", ms) >>> o2.x = 1 >>> o2.y = 0 >>> o3 = win32com.client.Record("Point3d", ms) >>> o3.x = 0 >>> o3.y = 1 >>> ms.CreateShapeElement1(None, [o1, o2, o3], 1) Traceback (most recent call last): File "", line 1, in File "c:\Python26\lib\site-packages\win32com\gen_py\CF9F97BF-39F2-4B8E-835C-8B E9E99DAF5Bx0x8x0.py", line 2403, in CreateShapeElement1 , Vertices, FillMode) File "c:\Python26\lib\site-packages\win32com\client\__init__.py", line 456, in _ApplyTypes_ self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), MemoryError: CreatingSafeArray Any ideas where I could start? What information from my side would help? I know this stuff works both with C# and VBA. Related entries from gen_py/*.py file: def CreateShapeElement1(self, Template=defaultNamedNotOptArg, Vertices=defaultNamedNotOptArg, FillMode=-1): return self._ApplyTypes_(1610743983, 1, (9, 0), ((9, 1), (24612, 3), (3, 49)), u'CreateShapeElement1', '{EA775B29-7513-482D-8260-47B8B2E5E1A8}',Template , Vertices, FillMode) (( u'CreateShapeElement1' , u'Template' , u'Vertices' , u'FillMode' , u'pVal' , ), 1610743983, (1610743983, (), [ (9, 1, None, "IID('{C9F8AC07-4FD2-496B-B9F0-EDD75A0551C0}')") , (24612, 3, None, None) , (3, 49, '-1', None) , (16393, 10, None, "IID('{EA775B29-7513-482D-8260-47B8B2E5E1A8}')") , ], 1 , 1 , 4 , 0 , 728 , (3, 0, None, None) , 0 , )), Regards, Dalius From Fadhley.Salim at uk.calyon.com Tue Jul 7 11:49:25 2009 From: Fadhley.Salim at uk.calyon.com (Fadhley Salim) Date: Tue, 7 Jul 2009 10:49:25 +0100 Subject: [python-win32] Examples of Win32Inet use In-Reply-To: References: Message-ID: Now that SF seems to be back online, could somebody point me to some examples for how to use the win32inet functions? There's almost no documentation for this library, and I have not managed to find any examples working code which actually uses these functions. FYI, I'm still struggling to get win32inet.InternetOpen and win32inet.WinHttpGetProxyForUrl to do anything sensible for me. I'd be particularly delighted to see an example of how to use those functions. Thanks -------------- next part -------------- Disclaimer CALYON UK: This email does not create a legal relationship between any member of the Cr=E9dit Agricole group and the recipient or constitute investment advice. The content of this email should not be copied or disclosed (in whole or part) to any other person. It may contain information which is confidential, privileged or otherwise protected from disclosure. If you are not the intended recipient, you should notify us and delete it from your system. Emails may be monitored, are not secure and may be amended, destroyed or contain viruses and in communicating with us such conditions are accepted. Any content which does not relate to business matters is not endorsed by us. Calyon is authorised by the Comit=e9 des Etablissements de Cr=e9dit et des Entreprises d'Investissement (CECEI) and supervised by the Commission Bancaire in France and subject to limited regulation by the Financial Services Authority. Details about the extent of our regulation by the Financial Services Authority are available from us on request. Calyon is incorporated in France with limited liability and registered in England & Wales. Registration number: FC008194. Registered office: Broadwalk House, 5 Appold Street, London, EC2A 2DA. Disclaimer CALYON France: This message and/or any attachments is intended for the sole use of its addressee. If you are not the addressee, please immediately notify the sender and then destroy the message. As this message and/or any attachments may have been altered without our knowledge, its content is not legally binding on CALYON Cr?dit Agricole CIB. All rights reserved. Ce message et ses pi?ces jointes est destin? ? l'usage exclusif de son destinataire. Si vous recevez ce message par erreur, merci d'en aviser imm?diatement l'exp?diteur et de le d?truire ensuite. Le pr?sent message pouvant ?tre alt?r? ? notre insu, CALYON Cr?dit Agricole CIB ne peut pas ?tre engag? par son contenu. Tous droits r?serv?s. From rwupole at msn.com Tue Jul 7 14:17:08 2009 From: rwupole at msn.com (Roger Upole) Date: Tue, 7 Jul 2009 08:17:08 -0400 Subject: [python-win32] Examples of Win32Inet use Message-ID: The handle returned by InternetOpen isn't compatible with the WinHttp* functions. Try using win32inet.WinHttpOpen instead. Roger From mdriscoll at co.marshall.ia.us Tue Jul 7 16:33:35 2009 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Tue, 07 Jul 2009 09:33:35 -0500 Subject: [python-win32] Examples of Win32Inet use In-Reply-To: References: Message-ID: <4A535CBF.6020003@co.marshall.ia.us> Fadhley Salim wrote: > Now that SF seems to be back online, could somebody point me to some > examples for how to use the win32inet functions? > > There's almost no documentation for this library, and I have not managed > to find any examples working code which actually uses these functions. > > FYI, I'm still struggling to get win32inet.InternetOpen and > win32inet.WinHttpGetProxyForUrl to do anything sensible for me. I'd be > particularly delighted to see an example of how to use those functions. > > Thanks > There are lots of docs: http://docs.activestate.com/activepython/2.4/pywin32/win32_modules.html http://timgolden.me.uk/python-on-windows/ http://timgolden.me.uk/python/win32_how_do_i.html However, there aren't tons of examples out there in the wild. What you should probably do is look up the functions you're interested in on MSDN. You can usually translate the examples there directly into Python code. - Mike From Fadhley.Salim at uk.calyon.com Tue Jul 7 16:47:28 2009 From: Fadhley.Salim at uk.calyon.com (Fadhley Salim) Date: Tue, 7 Jul 2009 15:47:28 +0100 Subject: [python-win32] Examples of Win32Inet use In-Reply-To: References: Message-ID: Thanks Roger, Would you care to comment about how to get the 3rd line of my script working? I'm guessing that the fault lies with my use of the Proxy options (the tuple argument) - this is supposed to map onto WINHTTP_AUTOPROXY_OPTIONS ( http://msdn.microsoft.com/en-us/library/aa384123(VS.85).aspx ) - I'm just not sure how to make this work in Python! import win32inet hSession = win32inet.WinHttpOpen ("foo 1.0", 0, "", "", 0) proxy = win32inet.WinHttpGetProxyForUrl( hSession, "http://www.foo.com", (0,0,u"",None,0,1) ) print proxy Sal -----Original Message----- From: python-win32-bounces+fadhley.salim=uk.calyon.com at python.org [mailto:python-win32-bounces+fadhley.salim=uk.calyon.com at python.org] On Behalf Of Roger Upole Sent: 07 July 2009 13:17 To: python-win32 at python.org Subject: [python-win32] Examples of Win32Inet use The handle returned by InternetOpen isn't compatible with the WinHttp* functions. Try using win32inet.WinHttpOpen instead. Roger _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- Disclaimer CALYON UK: This email does not create a legal relationship between any member of the Cr=E9dit Agricole group and the recipient or constitute investment advice. The content of this email should not be copied or disclosed (in whole or part) to any other person. It may contain information which is confidential, privileged or otherwise protected from disclosure. If you are not the intended recipient, you should notify us and delete it from your system. Emails may be monitored, are not secure and may be amended, destroyed or contain viruses and in communicating with us such conditions are accepted. Any content which does not relate to business matters is not endorsed by us. Calyon is authorised by the Comit=e9 des Etablissements de Cr=e9dit et des Entreprises d'Investissement (CECEI) and supervised by the Commission Bancaire in France and subject to limited regulation by the Financial Services Authority. Details about the extent of our regulation by the Financial Services Authority are available from us on request. Calyon is incorporated in France with limited liability and registered in England & Wales. Registration number: FC008194. Registered office: Broadwalk House, 5 Appold Street, London, EC2A 2DA. Disclaimer CALYON France: This message and/or any attachments is intended for the sole use of its addressee. If you are not the addressee, please immediately notify the sender and then destroy the message. As this message and/or any attachments may have been altered without our knowledge, its content is not legally binding on CALYON Cr?dit Agricole CIB. All rights reserved. Ce message et ses pi?ces jointes est destin? ? l'usage exclusif de son destinataire. Si vous recevez ce message par erreur, merci d'en aviser imm?diatement l'exp?diteur et de le d?truire ensuite. Le pr?sent message pouvant ?tre alt?r? ? notre insu, CALYON Cr?dit Agricole CIB ne peut pas ?tre engag? par son contenu. Tous droits r?serv?s. From timr at probo.com Tue Jul 7 18:44:28 2009 From: timr at probo.com (Tim Roberts) Date: Tue, 07 Jul 2009 09:44:28 -0700 Subject: [python-win32] Examples of Win32Inet use In-Reply-To: References: Message-ID: <4A537B6C.2000906@probo.com> Fadhley Salim wrote: > Thanks Roger, > > Would you care to comment about how to get the 3rd line of my script > working? I'm guessing that the fault lies with my use of the Proxy > options (the tuple argument) - this is supposed to map onto > WINHTTP_AUTOPROXY_OPTIONS ( > http://msdn.microsoft.com/en-us/library/aa384123(VS.85).aspx ) - I'm > just not sure how to make this work in Python! > > import win32inet > hSession = win32inet.WinHttpOpen ("foo 1.0", 0, "", "", 0) > proxy = win32inet.WinHttpGetProxyForUrl( hSession, "http://www.foo.com", > (0,0,u"",None,0,1) ) > print proxy > Are you sure this works in C? Have you tried it? In WINHTTP_AUTOPROXY_OPTIONS, you aren't telling it which mechanisms to try in order to get the proxy auto-config file. I would have guess you need to specify at least WINHTTP_AUTOPROXY_AUTO_DETECT. > Disclaimer CALYON UK: > This email does not create a legal relationship between any member of the ... > I have to say, your messages carry the most obnoxious legal disclaimer I've encountered in a long, long time. The efficacy of such disclaimers has never been established in court, to my knowledge. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Fadhley.Salim at uk.calyon.com Tue Jul 7 19:19:29 2009 From: Fadhley.Salim at uk.calyon.com (Fadhley Salim) Date: Tue, 7 Jul 2009 18:19:29 +0100 Subject: [python-win32] Examples of Win32Inet use In-Reply-To: <4A537B6C.2000906@probo.com> References: <4A537B6C.2000906@probo.com> Message-ID: Tim, Thanks for the advice. Unfortunately I'm not a C developer - I would have no idea how to go about this. I was hoping that there would be an easy way to use these functions purely in Python. The problem is I've no idea how to use the syntax - I'm quite unfamiliar with how you provide a value for AUTOPROXY_OPTIONS - I had hoped that I could provide a tuple of values which match the arguments expected by the function (as desctribed by MSDN) however there seems to be some other trick I am missing. PS. Unfortunately I have no control over the legal disclaimers - I work for an institution which is overly fond of such things. I'm sure they are nonsense in all but a few very spesific circumstances. -----Original Message----- From: python-win32-bounces+fadhley.salim=uk.calyon.com at python.org [mailto:python-win32-bounces+fadhley.salim=uk.calyon.com at python.org] On Behalf Of Tim Roberts Sent: 07 July 2009 17:44 To: Python-Win32 List Subject: Re: [python-win32] Examples of Win32Inet use Fadhley Salim wrote: > Thanks Roger, > > Would you care to comment about how to get the 3rd line of my script > working? I'm guessing that the fault lies with my use of the Proxy > options (the tuple argument) - this is supposed to map onto > WINHTTP_AUTOPROXY_OPTIONS ( > http://msdn.microsoft.com/en-us/library/aa384123(VS.85).aspx ) - I'm > just not sure how to make this work in Python! > > import win32inet > hSession = win32inet.WinHttpOpen ("foo 1.0", 0, "", "", 0) proxy = > win32inet.WinHttpGetProxyForUrl( hSession, "http://www.foo.com", > (0,0,u"",None,0,1) ) > print proxy > Are you sure this works in C? Have you tried it? In WINHTTP_AUTOPROXY_OPTIONS, you aren't telling it which mechanisms to try in order to get the proxy auto-config file. I would have guess you need to specify at least WINHTTP_AUTOPROXY_AUTO_DETECT. > Disclaimer CALYON UK: > This email does not create a legal relationship between any member of the ... > I have to say, your messages carry the most obnoxious legal disclaimer I've encountered in a long, long time. The efficacy of such disclaimers has never been established in court, to my knowledge. -- 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 -------------- Disclaimer CALYON UK: This email does not create a legal relationship between any member of the Cr=E9dit Agricole group and the recipient or constitute investment advice. The content of this email should not be copied or disclosed (in whole or part) to any other person. It may contain information which is confidential, privileged or otherwise protected from disclosure. If you are not the intended recipient, you should notify us and delete it from your system. Emails may be monitored, are not secure and may be amended, destroyed or contain viruses and in communicating with us such conditions are accepted. Any content which does not relate to business matters is not endorsed by us. Calyon is authorised by the Comit=e9 des Etablissements de Cr=e9dit et des Entreprises d'Investissement (CECEI) and supervised by the Commission Bancaire in France and subject to limited regulation by the Financial Services Authority. Details about the extent of our regulation by the Financial Services Authority are available from us on request. Calyon is incorporated in France with limited liability and registered in England & Wales. Registration number: FC008194. Registered office: Broadwalk House, 5 Appold Street, London, EC2A 2DA. Disclaimer CALYON France: This message and/or any attachments is intended for the sole use of its addressee. If you are not the addressee, please immediately notify the sender and then destroy the message. As this message and/or any attachments may have been altered without our knowledge, its content is not legally binding on CALYON Cr?dit Agricole CIB. All rights reserved. Ce message et ses pi?ces jointes est destin? ? l'usage exclusif de son destinataire. Si vous recevez ce message par erreur, merci d'en aviser imm?diatement l'exp?diteur et de le d?truire ensuite. Le pr?sent message pouvant ?tre alt?r? ? notre insu, CALYON Cr?dit Agricole CIB ne peut pas ?tre engag? par son contenu. Tous droits r?serv?s. From timr at probo.com Tue Jul 7 20:04:34 2009 From: timr at probo.com (Tim Roberts) Date: Tue, 07 Jul 2009 11:04:34 -0700 Subject: [python-win32] Examples of Win32Inet use In-Reply-To: References: <4A537B6C.2000906@probo.com> Message-ID: <4A538E32.2090407@probo.com> Fadhley Salim wrote: > Thanks for the advice. Unfortunately I'm not a C developer - I would > have no idea how to go about this. I was hoping that there would be an > easy way to use these functions purely in Python. > Yes, there is. I am convinced the path you are on will lead to eventual happiness. The issue is that all of the documentation and all of the examples on the web are for C and C++. When you begin exploring an area like this that hasn't had a lot of exercise in Python, you end up spending a lot of time trying to figure out how to spell those C recipes in Python. I suspect your next steps are to go pore through the MSDN documentation on the API and the structure, and try playing with some of the flag values in AUTOPROXY_OPTIONS. You will stumble upon the answer eventually. > The problem is I've no idea how to use the syntax - I'm quite unfamiliar > with how you provide a value for AUTOPROXY_OPTIONS - I had hoped that I > could provide a tuple of values which match the arguments expected by > the function (as desctribed by MSDN) however there seems to be some > other trick I am missing. > I checked the source code for the Wininet module, and the implementation is exactly what you describe. It expects a tuple or list, and each item in the object is assigned in order to the members of the structure. > PS. Unfortunately I have no control over the legal disclaimers - I work > for an institution which is overly fond of such things. I'm sure they > are nonsense in all but a few very spesific circumstances. > ;) Those kind of long disclaimers used to be rather common. After a while, most companies dropped them because their employees griped about complaints from their correspondents, and the lawyers couldn't really assert that they had any value at all. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ckaynor at zindagigames.com Tue Jul 7 20:17:51 2009 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Tue, 7 Jul 2009 11:17:51 -0700 Subject: [python-win32] Unable to install PyWin32 with Python 2.6.2 Message-ID: I have an install of Python 2.6.2 and am trying to get a copy of PyWin32 (version 213) installed under the site-packages folder. The install process always gives the following error: Traceback (most recent call last): ??File "", line 601, in ??File "", line 311, in install ??File "", line 149, in LoadSystemModule ImportError: DLL load failed: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. during the post install scripts. Effectively the same error also occurs if I just ignore the installer's error and attempt to import PyWin32. After digging around, I suspect the problem may be related to the manifest files embedded into the pyd files, however I have not been able to find out what the proper manifest files should be (this is related to issue 4566 for Python). In addition, I have tried to compile from source, and have consistently received the error: error: Unable to find vcvarsall.bat despite adding the path to this file to the path, and running it from within the same command prompt. This occurs when I run the command python setup.py -q build as well as, just to test it, replacing the build with install. Various Google searches have turned up nothing related to PyWin32, and little else besides. Searching the files included with the PyWin32 213 source release turns up no instances of this file being used. Any help on getting either of these issues resolved is appreciated. From mhammond at skippinet.com.au Wed Jul 8 06:00:56 2009 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 08 Jul 2009 14:00:56 +1000 Subject: [python-win32] pywin32 build 214 released Message-ID: <4A5419F8.50405@skippinet.com.au> Hi all, I'm happy to announce the release of pywin32 build 214. This release has relatively few changes since build 213, and should, in general, be considered stable. Builds for Python 3.1 are also available. Get it now via https://sourceforge.net/projects/pywin32/files/ Cheers, Mark. Release Notes: -------------- There have been very few changes in this release since build 213, and should be considered stable. Now includes Python 2.7 (ie, svn trunk) and Python 3.1 binaries. Change Log: ----------- * pythoncom gets better support for 64bit integers, including in arrays. * pythoncom may fail to import on Windows 2000 installs with a default IE (Roger) * Fix Pythonwin when backspacing over an extended character (from markt (metolone), via bug 2618277) * Fixed a regression which would cause an error if you compared a PyTime object to any other type, including None From efotinis at yahoo.com Wed Jul 8 09:41:43 2009 From: efotinis at yahoo.com (Elias Fotinis) Date: Wed, 8 Jul 2009 10:41:43 +0300 Subject: [python-win32] pywin32 build 214 released In-Reply-To: <4A5419F8.50405@skippinet.com.au> References: <4A5419F8.50405@skippinet.com.au> Message-ID: <904A0B8F53C34AA2B491FEA30946FDA1@efcore> From: "Mark Hammond" > I'm happy to announce the release of pywin32 build 214. Thanks, Mark. Last night I wanted to try Python 3.1 and was wondering when PythonWin will come out. Nice timing! By the way, there's a bug (causing a triple exception) in the display of syntax errors in the interactive prompt. Seems to be a bytes/str mismatch in winout.py (only in Python 3.x of course; the 2.x version works fine). Here's an example while trying to eval u'' (some paths trimmed for brevity): ========== PythonWin 3.1 (r31:73574, Jun 26 2009, 17:50:52) [MSC v.1500 64 bit (AMD64)] on win32. Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyright information. >>> u'' Firing event 'ProcessEnter' failed. Traceback (most recent call last): File "...\Python31\lib\code.py", line 63, in runsource code = self.compile(source, filename, symbol) File "...\Python31\lib\codeop.py", line 168, in __call__ return _maybe_compile(self.compiler, source, filename, symbol) File "...\Python31\lib\codeop.py", line 99, in _maybe_compile raise SyntaxError(err1) File "", line None SyntaxError: invalid syntax (, line 1) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "...\pywin\framework\interact.py", line 485, in ProcessEnterEvent if self.interp.runsource(source, ""): # Need more input! File "...\Python31\lib\code.py", line 66, in runsource self.showsyntaxerror(filename) File "...\pywin\framework\interact.py", line 261, in showsyntaxerror sys.stderr.write(tracebackHeader) # So the color syntaxer recognises it. File "...\pywin\framework\winout.py", line 177, in write return self.template.write(msg) File "...\pywin\framework\winout.py", line 487, in write self.HandleOutput(message) File "...\pywin\framework\winout.py", line 465, in HandleOutput pos = message.rfind('\n') TypeError: expected an object with the buffer interface During handling of the above exception, another exception occurred: Traceback (most recent call last): File "...\pywin\scintilla\bindings.py", line 142, in fire rc = binding.handler(*args) File "...\pywin\framework\interact.py", line 495, in ProcessEnterEvent self.OutputRelease() File "...\pywin\framework\interact.py", line 435, in OutputRelease self.flush() File "...\pywin\framework\winout.py", line 182, in flush self.template.flush() File "...\pywin\framework\winout.py", line 490, in flush self.QueueFlush() File "...\pywin\framework\winout.py", line 455, in QueueFlush self.currentView.dowrite(''.join(items)) TypeError: sequence item 0: expected str instance, bytes found ========== From skippy.hammond at gmail.com Wed Jul 8 10:40:12 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 08 Jul 2009 18:40:12 +1000 Subject: [python-win32] pywin32 build 214 released In-Reply-To: <904A0B8F53C34AA2B491FEA30946FDA1@efcore> References: <4A5419F8.50405@skippinet.com.au> <904A0B8F53C34AA2B491FEA30946FDA1@efcore> Message-ID: <4A545B6C.1010401@gmail.com> Thanks for the note - can someone with build 213 for Python 3.0 installed check if they have the same problem or not (ie, if it is a regression or just the first report of a problem existing for a few months)? Ideally an issue should be opened at sourceforge too - I'm busy at the moment, so may end up forgetting about then when I next find pywin32 time... Thanks, Mark On 8/07/2009 5:41 PM, Elias Fotinis wrote: > From: "Mark Hammond" >> I'm happy to announce the release of pywin32 build 214. > > Thanks, Mark. > > Last night I wanted to try Python 3.1 and was wondering when PythonWin > will come out. Nice timing! > > By the way, there's a bug (causing a triple exception) in the display of > syntax errors in the interactive prompt. Seems to be a bytes/str > mismatch in winout.py (only in Python 3.x of course; the 2.x version > works fine). > > Here's an example while trying to eval u'' (some paths trimmed for > brevity): > ========== > PythonWin 3.1 (r31:73574, Jun 26 2009, 17:50:52) [MSC v.1500 64 bit > (AMD64)] on win32. > Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' > for further copyright information. >>>> u'' > Firing event 'ProcessEnter' failed. > Traceback (most recent call last): > File "...\Python31\lib\code.py", line 63, in runsource > code = self.compile(source, filename, symbol) > File "...\Python31\lib\codeop.py", line 168, in __call__ > return _maybe_compile(self.compiler, source, filename, symbol) > File "...\Python31\lib\codeop.py", line 99, in _maybe_compile > raise SyntaxError(err1) > File "", line None > SyntaxError: invalid syntax (, line 1) > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > File "...\pywin\framework\interact.py", line 485, in ProcessEnterEvent > if self.interp.runsource(source, ""): # Need more input! > File "...\Python31\lib\code.py", line 66, in runsource > self.showsyntaxerror(filename) > File "...\pywin\framework\interact.py", line 261, in showsyntaxerror > sys.stderr.write(tracebackHeader) # So the color syntaxer recognises it. > File "...\pywin\framework\winout.py", line 177, in write > return self.template.write(msg) > File "...\pywin\framework\winout.py", line 487, in write > self.HandleOutput(message) > File "...\pywin\framework\winout.py", line 465, in HandleOutput > pos = message.rfind('\n') > TypeError: expected an object with the buffer interface > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > File "...\pywin\scintilla\bindings.py", line 142, in fire > rc = binding.handler(*args) > File "...\pywin\framework\interact.py", line 495, in ProcessEnterEvent > self.OutputRelease() > File "...\pywin\framework\interact.py", line 435, in OutputRelease > self.flush() > File "...\pywin\framework\winout.py", line 182, in flush > self.template.flush() > File "...\pywin\framework\winout.py", line 490, in flush > self.QueueFlush() > File "...\pywin\framework\winout.py", line 455, in QueueFlush > self.currentView.dowrite(''.join(items)) > TypeError: sequence item 0: expected str instance, bytes found > > ========== > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From efotinis at yahoo.com Wed Jul 8 12:22:27 2009 From: efotinis at yahoo.com (Elias Fotinis) Date: Wed, 8 Jul 2009 13:22:27 +0300 Subject: [python-win32] pywin32 build 214 released In-Reply-To: <4A545B6C.1010401@gmail.com> References: <4A5419F8.50405@skippinet.com.au> <904A0B8F53C34AA2B491FEA30946FDA1@efcore> <4A545B6C.1010401@gmail.com> Message-ID: From: "Mark Hammond" > Thanks for the note - can someone with build 213 for Python 3.0 installed > check if they have the same problem or not (ie, if it is a regression or > just the first report of a problem existing for a few months)? I just tried 213 for 3.0.1 and it works OK, so it looks like a 214/3.1 regression. > Ideally an issue should be opened at sourceforge too - I'm busy at the > moment, so may end up forgetting about then when I next find pywin32 > time... Done: http://sourceforge.net/tracker/?func=detail&aid=2818443&group_id=78018&atid=551954 From dana_at_work at yahoo.com Wed Jul 8 13:19:47 2009 From: dana_at_work at yahoo.com (Dana N) Date: Wed, 8 Jul 2009 04:19:47 -0700 (PDT) Subject: [python-win32] dbi module deprecated at 2.5. What to use in its place in 2.5, 2.6, and 3.0? Message-ID: <619131.98816.qm@web112204.mail.gq1.yahoo.com> I have a variety of Python 2.4 scripts that utilitize the?dbi and?odbc modules together. Although I don't have Python 2.5, I've been informed the?dbi module has been deprecated at pywin32 2.5. ? What do I use in place of?dbi for my Python 2.4 scripts that import modules?dbi and?odbc together.I don't use DBI directly. It was simply a dependency for the?odbc module as best I knew. We're still using?pywin32 2.5 because that's what our software vendor (ESRI / ArcGIS Desktop 9.3) supports. ? Thanks. ? Dana -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Wed Jul 8 14:31:41 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 08 Jul 2009 22:31:41 +1000 Subject: [python-win32] dbi module deprecated at 2.5. What to use in its place in 2.5, 2.6, and 3.0? In-Reply-To: <619131.98816.qm@web112204.mail.gq1.yahoo.com> References: <619131.98816.qm@web112204.mail.gq1.yahoo.com> Message-ID: <4A5491AD.40001@gmail.com> On 8/07/2009 9:19 PM, Dana N wrote: > I have a variety of Python 2.4 scripts that utilitize the dbi and odbc > modules together. Although I don't have Python 2.5, I've been informed > the dbi module has been deprecated at pywin32 2.5. > What do I use in place of dbi for my Python 2.4 scripts that > import modules dbi and odbc together.I don't use DBI directly. It was > simply a dependency for the odbc module as best I knew. > We're still using pywin32 2.5 because that's what our software vendor > (ESRI / ArcGIS Desktop 9.3) supports. dbi and odbc have been integrated - if you don't directly use dbi, just stop importing it, and eventually you will never notice it going away. If you do use it directly, everything you used is now available directly in the odbc module. Cheers, Mark \ From vernondcole at gmail.com Wed Jul 8 16:14:34 2009 From: vernondcole at gmail.com (Vernon Cole) Date: Wed, 8 Jul 2009 08:14:34 -0600 Subject: [python-win32] dbi module deprecated at 2.5. What to use in its place in 2.5, 2.6, and 3.0? In-Reply-To: <4A5491AD.40001@gmail.com> References: <619131.98816.qm@web112204.mail.gq1.yahoo.com> <4A5491AD.40001@gmail.com> Message-ID: odbc is compliant with PEP 248, the db api specification v1.0. PEP 248 has been superseded by PEP 249 which is version 2.0 of the db api specification. adodbapi is fully compliant with PEP 249. You may want to consider using the newer version in your new work. Or, if you don't wish to use any of the newer features of PEP 249, you can keep using the old one. Both are part of pywin32 and will be maintained for the foreseeable future. The other difference between them is that odbc is implemented in C code, while adodbapi is pure Python and uses the heavier Microsoft ADO interface, and therefore may be slightly slower. ADO is fussy about re-using a cursor, you have to close the old one and open a new one for each transaction. On the other hand, perhaps re-using cursors is why odbc seemed to crash sometimes for me. YMMV. -- Vernon Cole On Wed, Jul 8, 2009 at 6:31 AM, Mark Hammond wrote: > On 8/07/2009 9:19 PM, Dana N wrote: > >> I have a variety of Python 2.4 scripts that utilitize the dbi and odbc >> modules together. Although I don't have Python 2.5, I've been informed >> the dbi module has been deprecated at pywin32 2.5. >> What do I use in place of dbi for my Python 2.4 scripts that >> import modules dbi and odbc together.I don't use DBI directly. It was >> simply a dependency for the odbc module as best I knew. >> We're still using pywin32 2.5 because that's what our software vendor >> (ESRI / ArcGIS Desktop 9.3) supports. >> > > dbi and odbc have been integrated - if you don't directly use dbi, just > stop importing it, and eventually you will never notice it going away. If > you do use it directly, everything you used is now available directly in the > odbc module. > > Cheers, > > Mark > \ > _______________________________________________ > 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 ckaynor at zindagigames.com Wed Jul 8 18:08:50 2009 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Wed, 8 Jul 2009 09:08:50 -0700 Subject: [python-win32] Unable to install PyWin32 with Python 2.6.2 In-Reply-To: References: Message-ID: This issue was resolved with the release of PyWin32 version 214. Chris On Tue, Jul 7, 2009 at 11:17 AM, Chris Kaynor wrote: > I have an install of Python 2.6.2 and am trying to get a copy of > PyWin32 (version 213) installed under the site-packages folder. The > install process always gives the following error: > > Traceback (most recent call last): > ??File "", line 601, in > ??File "", line 311, in install > ??File "", line 149, in LoadSystemModule > ImportError: DLL load failed: This application has failed to start > because the application configuration is incorrect. Reinstalling the > application may fix this problem. > > during the post install scripts. Effectively the same error also > occurs if I just ignore the installer's error and attempt to import > PyWin32. > > After digging around, I suspect the problem may be related to the > manifest files embedded into the pyd files, however I have not been > able to find out what the proper manifest files should be (this is > related to issue 4566 for Python). > > > > > In addition, I have tried to compile from source, and have > consistently received the error: > > error: Unable to find vcvarsall.bat > > despite adding the path to this file to the path, and running it from > within the same command prompt. This occurs when I run the command > > python setup.py -q build > > as well as, just to test it, replacing the build with install. Various > Google searches have turned up nothing related to PyWin32, and little > else besides. Searching the files included with the PyWin32 213 source > release turns up no instances of this file being used. > > > > Any help on getting either of these issues resolved is appreciated. > -- Chris From chef at ghum.de Wed Jul 8 16:17:33 2009 From: chef at ghum.de (Massa, Harald Armin) Date: Wed, 8 Jul 2009 16:17:33 +0200 Subject: [python-win32] patch to makepy.py / genpy.py In-Reply-To: References: Message-ID: Hello, in Version 213 of pywin32 within win32com\client\genpy.py on line 814, within def do_gen_file_header(self): there is the assertion: # You must provide a file correctly configured for writing unicode. # We assert this is it may indicate somewhere in pywin32 that needs # upgrading. assert self.file.encoding, self.file But using makepy.py via makepy.py -v -o OLE_Excel11.py "Microsoft Excel 11.0 Object Library" this assertion fails ... as self.file.encoding is None The culprit is makepy.py itself: starting at line 367ff there is: if outputName is not None: path = os.path.dirname(outputName) if path is not '' and not os.path.exists(path): os.makedirs(path) f = open(outputName, "w") else: f = None and this "f" will have encoding=None I patched this to: if outputName is not None: path = os.path.dirname(outputName) if path is not '' and not os.path.exists(path): os.makedirs(path) #~ f = open(outputName, "w") import codecs f= codecs.open(outputName, mode="w",encoding="mbcs") else: f = None use codecs to create a file with mbcs encoding. After this, I get a nice create ole_excel11.py file, with the good line # -*- coding: mbcs -*- at the beginning. I propose to put this fix into makepy.py for everybody; (any rights you need are hereby granted) best wishes, Harald -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 no fx, no carrier pigeon - LASIK good, steroids bad? -------------- next part -------------- An HTML attachment was scrubbed... URL: From sabdelrazak at symbyo.com Thu Jul 9 12:20:55 2009 From: sabdelrazak at symbyo.com (Sarah Abdel Razak) Date: Thu, 9 Jul 2009 06:20:55 -0400 Subject: [python-win32] using python com object implemented as Local Server from .NET Message-ID: Hi all, I implemented a python com object and generated an exe for it . How can I use this exe to create an object for my server from .NET. I would appreciate your help. Thanks in advance. Regards -- Sarah Abdelrazak -------------- next part -------------- An HTML attachment was scrubbed... URL: From cappy2112 at gmail.com Thu Jul 9 17:50:14 2009 From: cappy2112 at gmail.com (Tony Cappellini) Date: Thu, 9 Jul 2009 08:50:14 -0700 Subject: [python-win32] Python parser for Windows Event Logs Message-ID: <8249c4ac0907090850o6a03db52nbdf552a3486de876@mail.gmail.com> Does anyone know if there is a Python module which will parse Windows Event Logs? Using the EventViewer is tedious, and I'd rather be abel to do this programmatically. Thanks From jaime.blasco at alienvault.com Thu Jul 9 18:09:43 2009 From: jaime.blasco at alienvault.com (Jaime Blasco) Date: Thu, 9 Jul 2009 18:09:43 +0200 Subject: [python-win32] Python parser for Windows Event Logs In-Reply-To: <8249c4ac0907090850o6a03db52nbdf552a3486de876@mail.gmail.com> References: <8249c4ac0907090850o6a03db52nbdf552a3486de876@mail.gmail.com> Message-ID: <53834cf20907090909k58e85b6crd57bd1f9c1d4c7e7@mail.gmail.com> Check wmi module: http://timgolden.me.uk/python/wmi.html It has some functions to access windows logs.. Regards 2009/7/9 Tony Cappellini > Does anyone know if there is a Python module which will parse Windows > Event Logs? > Using the EventViewer is tedious, and I'd rather be abel to do this > programmatically. > > > Thanks > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- _______________________________ Jaime Blasco www.ossim.com www.alienvault.com Email: jaime.blasco at alienvault.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin.horn at gmail.com Thu Jul 9 18:33:27 2009 From: kevin.horn at gmail.com (Kevin Horn) Date: Thu, 9 Jul 2009 11:33:27 -0500 Subject: [python-win32] Fwd: Python parser for Windows Event Logs In-Reply-To: <562bcc10907090933o783bdd98ka726fe2a1694081b@mail.gmail.com> References: <8249c4ac0907090850o6a03db52nbdf552a3486de876@mail.gmail.com> <53834cf20907090909k58e85b6crd57bd1f9c1d4c7e7@mail.gmail.com> <562bcc10907090926w7c58e146meb7cab2839dfb1da@mail.gmail.com> <562bcc10907090933o783bdd98ka726fe2a1694081b@mail.gmail.com> Message-ID: <562bcc10907090933v587a8970u68fb5c3348c75649@mail.gmail.com> ---------- Forwarded message ---------- From: Kevin Horn Date: Thu, Jul 9, 2009 at 11:26 AM Subject: Re: [python-win32] Python parser for Windows Event Logs To: Jaime Blasco Or just use pywin32... http://timgolden.me.uk/pywin32-docs/Windows_NT_Eventlog.html On Thu, Jul 9, 2009 at 11:09 AM, Jaime Blasco wrote: > Check wmi module: > > http://timgolden.me.uk/python/wmi.html > > It has some functions to access windows logs.. > > Regards > > 2009/7/9 Tony Cappellini > > Does anyone know if there is a Python module which will parse Windows >> Event Logs? >> Using the EventViewer is tedious, and I'd rather be abel to do this >> programmatically. >> >> >> Thanks >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> > > > > -- > _______________________________ > > Jaime Blasco > > www.ossim.com > www.alienvault.com > Email: jaime.blasco at alienvault.com > > > _______________________________________________ > 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 kevin.horn at gmail.com Thu Jul 9 18:33:10 2009 From: kevin.horn at gmail.com (Kevin Horn) Date: Thu, 9 Jul 2009 11:33:10 -0500 Subject: [python-win32] Fwd: Python parser for Windows Event Logs In-Reply-To: <562bcc10907090926w7c58e146meb7cab2839dfb1da@mail.gmail.com> References: <8249c4ac0907090850o6a03db52nbdf552a3486de876@mail.gmail.com> <53834cf20907090909k58e85b6crd57bd1f9c1d4c7e7@mail.gmail.com> <562bcc10907090926w7c58e146meb7cab2839dfb1da@mail.gmail.com> Message-ID: <562bcc10907090933o783bdd98ka726fe2a1694081b@mail.gmail.com> ---------- Forwarded message ---------- From: Kevin Horn Date: Thu, Jul 9, 2009 at 11:26 AM Subject: Re: [python-win32] Python parser for Windows Event Logs To: Jaime Blasco Or just use pywin32... http://timgolden.me.uk/pywin32-docs/Windows_NT_Eventlog.html On Thu, Jul 9, 2009 at 11:09 AM, Jaime Blasco wrote: > Check wmi module: > > http://timgolden.me.uk/python/wmi.html > > It has some functions to access windows logs.. > > Regards > > 2009/7/9 Tony Cappellini > > Does anyone know if there is a Python module which will parse Windows >> Event Logs? >> Using the EventViewer is tedious, and I'd rather be abel to do this >> programmatically. >> >> >> Thanks >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> > > > > -- > _______________________________ > > Jaime Blasco > > www.ossim.com > www.alienvault.com > Email: jaime.blasco at alienvault.com > > > _______________________________________________ > 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 cappy2112 at gmail.com Thu Jul 9 20:49:49 2009 From: cappy2112 at gmail.com (Tony Cappellini) Date: Thu, 9 Jul 2009 11:49:49 -0700 Subject: [python-win32] Python parser for Windows Event Logs In-Reply-To: <53834cf20907090909k58e85b6crd57bd1f9c1d4c7e7@mail.gmail.com> References: <8249c4ac0907090850o6a03db52nbdf552a3486de876@mail.gmail.com> <53834cf20907090909k58e85b6crd57bd1f9c1d4c7e7@mail.gmail.com> Message-ID: <8249c4ac0907091149o34056cfdq22e0df07ed8014ff@mail.gmail.com> Thanks, but those just monitor events. I need to pull some very specific data from an event log file, after I know the event has already occurred. Tim has another module called winsys, and there is an object which handles some aspects of reading event logs. http://timgolden.me.uk/python/winsys/event_logs.html#module-event_logs Tim - what I need to is pull this structure http://msdn.microsoft.com/en-us/library/ms810313.aspx from the event log, AFTER an event 51 has already occurred. http://support.microsoft.com/kb/244780 I can easily look at the Event Viewer to determine if the event has occurred. I don't see it at a glance, but does your winsys module have a way to do this? If not, I'll just have to hard code offsets and use the struct module to get it. From mail at timgolden.me.uk Thu Jul 9 23:20:56 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 09 Jul 2009 22:20:56 +0100 Subject: [python-win32] Python parser for Windows Event Logs In-Reply-To: <8249c4ac0907091149o34056cfdq22e0df07ed8014ff@mail.gmail.com> References: <8249c4ac0907090850o6a03db52nbdf552a3486de876@mail.gmail.com> <53834cf20907090909k58e85b6crd57bd1f9c1d4c7e7@mail.gmail.com> <8249c4ac0907091149o34056cfdq22e0df07ed8014ff@mail.gmail.com> Message-ID: <4A565F38.40602@timgolden.me.uk> Tony Cappellini wrote: > Thanks, but those just monitor events. > > I need to pull some very specific data from an event log file, after I > know the event has already occurred. > > Tim has another module called winsys, and there is an object which > handles some aspects of reading event logs. > http://timgolden.me.uk/python/winsys/event_logs.html#module-event_logs > > Tim - what I need to is pull this structure > http://msdn.microsoft.com/en-us/library/ms810313.aspx > > from the event log, AFTER an event 51 has already occurred. > http://support.microsoft.com/kb/244780 > > I can easily look at the Event Viewer to determine if the event has occurred. > > I don't see it at a glance, but does your winsys module have a way to do this? > > If not, I'll just have to hard code offsets and use the struct module to get it. You can certainly get hold of the event log record via WMI or via WinSys (which just wraps the pywin32 module someone else referred to). But there's not special code for reconstructing the rather specific data structure you refer to. You'll need to use struct or ctypes for that. Let me know if you need help getting the data out in the first place; I'm not clear whether you've got that covered or not. (And whether you want to be notified when the event fires or whether you're merely scanning historically). TJG From cappy2112 at gmail.com Fri Jul 10 19:56:20 2009 From: cappy2112 at gmail.com (Tony Cappellini) Date: Fri, 10 Jul 2009 10:56:20 -0700 Subject: [python-win32] python-win32 Digest, Vol 76, Issue 13 In-Reply-To: References: Message-ID: <8249c4ac0907101056x2cb45bf3i4c2ba9f9b9d8eeb1@mail.gmail.com> > Message: 1 > Date: Thu, 09 Jul 2009 22:20:56 +0100 > From: Tim Golden > Cc: python-win32 at python.org > Subject: Re: [python-win32] Python parser for Windows Event Logs > Message-ID: <4A565F38.40602 at timgolden.me.uk> > Content-Type: text/plain; charset=UTF-8; format=flowed > > Let me know if you need help getting the data out in > the first place; I'm not clear whether you've got that > covered or not. (And whether you want to be notified > when the event fires or whether you're merely scanning > historically). I can get the data with the struct module, but would prefer your wrapper if possible. The systems which I am testing do not have network connections, so I have to save the system logs manually to a USB drive and copy them to my development system. Is there a way with winsys to open a logfile, WITHOUT having to pass a system name as the first argument? I don't want to process the system log of my development system, I want to process a system log that I've copied from the test system. That logfile is in some arbitrary directory, on my development system. From timr at probo.com Fri Jul 10 21:04:04 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 10 Jul 2009 12:04:04 -0700 Subject: [python-win32] Python parser for Windows Event Logs In-Reply-To: <8249c4ac0907101157x3f7437c1i3b0ad9cdb2b22cca@mail.gmail.com> References: <8249c4ac0907101056x2cb45bf3i4c2ba9f9b9d8eeb1@mail.gmail.com> <4A578E18.4030108@probo.com> <8249c4ac0907101157x3f7437c1i3b0ad9cdb2b22cca@mail.gmail.com> Message-ID: <4A5790A4.2090604@probo.com> Tony Cappellini wrote: >> Tim G's "winsys" wrapper will only read the live event logs. However, >> the native Win32 event log APIs can all read a saved .evt file just as >> well as a live log. >> >> You need to look into the win32evtlog module. >> win32evtlog.OpenBackupEventLog should let you access arbitrary evt files. >> > > This call also requires the system name as the first argument. > int = OpenBackupEventLog(serverName, fileName ) > Or "None". You have to read the documentation. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From cappy2112 at gmail.com Sat Jul 11 05:38:08 2009 From: cappy2112 at gmail.com (Tony Cappellini) Date: Fri, 10 Jul 2009 20:38:08 -0700 Subject: [python-win32] Python parser for Windows Event Logs In-Reply-To: <4A578E18.4030108@probo.com> References: <8249c4ac0907101056x2cb45bf3i4c2ba9f9b9d8eeb1@mail.gmail.com> <4A578E18.4030108@probo.com> Message-ID: <8249c4ac0907102038m7e177e53v3fe3245fa3582e15@mail.gmail.com> Ok, I'm able to parse Event51 logs now. However, there seems to be a problem with the object returned from ReadEventLogs() GetNumberOfEvents() tells me there are 6 events. I can see all sixe events using the EventViewer in Control Panle, on Widnwos XP. However, the iterator returned from RedEvent Log() is consumned after only 3 events. hand=win32evtlog.OpenBackupEventLog(None,logFilename) numEvents=win32evtlog.GetNumberOfEventLogRecords(hand) print'\n\t%lu events were found' % numEvents flags = win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ events=win32evtlog.ReadEventLog(hand,flags,0) for ev_obj in events: #stops iterating after only 3 events Would someone verify this? I see this problem on Python 2.3 and 2.5.4, with Pywin32 Build 213 Thanks Tony From skippy.hammond at gmail.com Sun Jul 12 03:32:53 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sun, 12 Jul 2009 11:32:53 +1000 Subject: [python-win32] Python parser for Windows Event Logs In-Reply-To: <8249c4ac0907102038m7e177e53v3fe3245fa3582e15@mail.gmail.com> References: <8249c4ac0907101056x2cb45bf3i4c2ba9f9b9d8eeb1@mail.gmail.com> <4A578E18.4030108@probo.com> <8249c4ac0907102038m7e177e53v3fe3245fa3582e15@mail.gmail.com> Message-ID: <4A593D45.7030708@gmail.com> Check out the ReadEventLog code in win32evtlogutil.py - you will notice you need a loop like: while 1: objects = win32evtlog.ReadEventLog(h, readFlags, 0) if not objects: break Mark On 11/07/2009 1:38 PM, Tony Cappellini wrote: > Ok, I'm able to parse Event51 logs now. > > However, there seems to be a problem with the object returned from > ReadEventLogs() > > GetNumberOfEvents() tells me there are 6 events. > > I can see all sixe events using the EventViewer in Control Panle, on Widnwos XP. > > However, the iterator returned from RedEvent Log() is consumned after > only 3 events. > > hand=win32evtlog.OpenBackupEventLog(None,logFilename) > numEvents=win32evtlog.GetNumberOfEventLogRecords(hand) > print'\n\t%lu events were found' % numEvents > flags = win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ > events=win32evtlog.ReadEventLog(hand,flags,0) > > for ev_obj in events: > #stops iterating after only 3 events > > Would someone verify this? > > I see this problem on Python 2.3 and 2.5.4, with Pywin32 Build 213 > > > Thanks > > Tony > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From cappy2112 at gmail.com Sun Jul 12 06:41:04 2009 From: cappy2112 at gmail.com (Tony Cappellini) Date: Sat, 11 Jul 2009 21:41:04 -0700 Subject: [python-win32] Python parser for Windows Event Logs In-Reply-To: <4A593D45.7030708@gmail.com> References: <8249c4ac0907101056x2cb45bf3i4c2ba9f9b9d8eeb1@mail.gmail.com> <4A578E18.4030108@probo.com> <8249c4ac0907102038m7e177e53v3fe3245fa3582e15@mail.gmail.com> <4A593D45.7030708@gmail.com> Message-ID: <8249c4ac0907112141t679cab96of915255699cc66bc@mail.gmail.com> I'll give that a try. I was using this for my reference http://timgolden.me.uk/pywin32-docs/Windows_NT_Eventlog.html On 7/11/09, Mark Hammond wrote: > Check out the ReadEventLog code in win32evtlogutil.py - you will notice you > need a loop like: > > while 1: > objects = win32evtlog.ReadEventLog(h, readFlags, 0) > if not objects: > break > > Mark > > > On 11/07/2009 1:38 PM, Tony Cappellini wrote: > > > > > Ok, I'm able to parse Event51 logs now. > > > > However, there seems to be a problem with the object returned from > > ReadEventLogs() > > > > GetNumberOfEvents() tells me there are 6 events. > > > > I can see all sixe events using the EventViewer in Control Panle, on > Widnwos XP. > > > > However, the iterator returned from RedEvent Log() is consumned after > > only 3 events. > > > > > hand=win32evtlog.OpenBackupEventLog(None,logFilename) > > > numEvents=win32evtlog.GetNumberOfEventLogRecords(hand) > > print'\n\t%lu events were found' % numEvents > > flags = > win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ > > events=win32evtlog.ReadEventLog(hand,flags,0) > > > > for ev_obj in events: > > #stops iterating after only 3 events > > > > Would someone verify this? > > > > I see this problem on Python 2.3 and 2.5.4, with Pywin32 Build 213 > > > > > > Thanks > > > > Tony > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > From patrick at janssen.name Mon Jul 13 12:38:52 2009 From: patrick at janssen.name (Patrick Janssen) Date: Mon, 13 Jul 2009 18:38:52 +0800 Subject: [python-win32] timeout in DDE function call Message-ID: Hi all, We are having some trouble with a DDE timeout. When we call a function through DDE like this (see below), then we get an "Exec failed" error. The function being called takes a few minutes to execute, and my guess is that this is a timeout error - it seems to occur after one minute. Does anyone know how to reset this timeout? We would like to set it to infinity. import win32ui import win32api import dde server = dde.CreateServer() server.Create("Ecotect-Server") conversation = dde.CreateConversation(server) conversation.ConnectTo("Ecotect", "request") #set arg_str conversation.Exec(arg_str) Thanks Patrick From cappy2112 at gmail.com Mon Jul 13 22:54:53 2009 From: cappy2112 at gmail.com (Tony Cappellini) Date: Mon, 13 Jul 2009 13:54:53 -0700 Subject: [python-win32] Python parser for Windows Event Logs In-Reply-To: <4A593D45.7030708@gmail.com> References: <8249c4ac0907101056x2cb45bf3i4c2ba9f9b9d8eeb1@mail.gmail.com> <4A578E18.4030108@probo.com> <8249c4ac0907102038m7e177e53v3fe3245fa3582e15@mail.gmail.com> <4A593D45.7030708@gmail.com> Message-ID: <8249c4ac0907131354k33dbe4fdkff27eefe87c045ec@mail.gmail.com> That didn't really change anything. GetNumberOfEventLogRecords() tells me there are 6 events, However the object returned from ReadEvenLog() still only contains 3 objects flags = win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ events = win32evtlog.ReadEventLog(hand, flags, 0) >>> events [, , ] The next call to ReadeventLog() returns None On 7/11/09, Mark Hammond wrote: > Check out the ReadEventLog code in win32evtlogutil.py - you will notice you > need a loop like: > > while 1: > objects = win32evtlog.ReadEventLog(h, readFlags, 0) > if not objects: > break > > Mark > > > On 11/07/2009 1:38 PM, Tony Cappellini wrote: > > > > > Ok, I'm able to parse Event51 logs now. > > > > However, there seems to be a problem with the object returned from > > ReadEventLogs() > > > > GetNumberOfEvents() tells me there are 6 events. > > > > I can see all sixe events using the EventViewer in Control Panle, on > Widnwos XP. > > > > However, the iterator returned from RedEvent Log() is consumned after > > only 3 events. > > > > > hand=win32evtlog.OpenBackupEventLog(None,logFilename) > > > numEvents=win32evtlog.GetNumberOfEventLogRecords(hand) > > print'\n\t%lu events were found' % numEvents > > flags = > win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ > > events=win32evtlog.ReadEventLog(hand,flags,0) > > > > for ev_obj in events: > > #stops iterating after only 3 events > > > > Would someone verify this? > > > > I see this problem on Python 2.3 and 2.5.4, with Pywin32 Build 213 > > > > > > Thanks > > > > Tony > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > From cappy2112 at gmail.com Fri Jul 17 00:15:21 2009 From: cappy2112 at gmail.com (Tony Cappellini) Date: Thu, 16 Jul 2009 15:15:21 -0700 Subject: [python-win32] Python parser for Windows Event Logs Message-ID: <8249c4ac0907161515o25560a78i69890227b9f3ec26@mail.gmail.com> I've added the While loop Mark suggested but still see the same issue. GetNumberOfEventLogRecords() still returns 6 events, However the object returned from ReadEvenLog() still only contains 3 objects The next call to ReadeventLog() returns None flags = win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ events = win32evtlog.ReadEventLog(hand, flags, 0) >>> events [, , ] Would anyone be willing to try parsing their own SystemEvent log to see if they have the same issue (or parse min log and see if the results are the same) ? On 7/11/09, Mark Hammond wrote: > Check out the ReadEventLog code in win32evtlogutil.py - you will notice you > need a loop like: > > while 1: > objects = win32evtlog.ReadEventLog(h, readFlags, 0) > if not objects: > break > > Mark From timr at probo.com Fri Jul 17 00:57:31 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 16 Jul 2009 15:57:31 -0700 Subject: [python-win32] Python parser for Windows Event Logs In-Reply-To: <8249c4ac0907161515o25560a78i69890227b9f3ec26@mail.gmail.com> References: <8249c4ac0907161515o25560a78i69890227b9f3ec26@mail.gmail.com> Message-ID: <4A5FB05B.2060705@probo.com> Tony Cappellini wrote: > I've added the While loop Mark suggested but still see the same issue. > GetNumberOfEventLogRecords() still returns 6 events, > However the object returned from ReadEvenLog() still only contains 3 objects > The next call to ReadeventLog() returns None > ... > > Would anyone be willing to try parsing their own SystemEvent log to > see if they have the same issue (or parse min log and see if the > results are the same) ? > Similar. I saved one of the application event logs, and although GetNumberOfEventLogRecords returns 35 (which is right), the enumeration only returns 1 entry if I read backwards, and 2 if I read forwards. I shall experiment. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Jul 17 01:08:51 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 16 Jul 2009 16:08:51 -0700 Subject: [python-win32] Python parser for Windows Event Logs In-Reply-To: <8249c4ac0907161515o25560a78i69890227b9f3ec26@mail.gmail.com> References: <8249c4ac0907161515o25560a78i69890227b9f3ec26@mail.gmail.com> Message-ID: <4A5FB303.7010303@probo.com> Tony Cappellini wrote: > I've added the While loop Mark suggested but still see the same issue. > GetNumberOfEventLogRecords() still returns 6 events, > However the object returned from ReadEvenLog() still only contains 3 objects > The next call to ReadeventLog() returns None > OK, in my test, repeated calls to ReadEventLog eventually fetch all of the events. Each call to ReadEventLog will return however many events will fit in 1024 bytes, which is the buffer in the pywin32 code. If I change your code to this: while 1: events=win32evtlog.ReadEventLog(hand,flags,0) if not events: break for event in events: print event.EventID, event.StringInserts then it all works as expected. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From cappy2112 at gmail.com Fri Jul 17 14:46:31 2009 From: cappy2112 at gmail.com (Tony Cappellini) Date: Fri, 17 Jul 2009 05:46:31 -0700 Subject: [python-win32] Python parser for Windows Event Logs Message-ID: <8249c4ac0907170546g5c04f25ajda1a2d60d9139352@mail.gmail.com> Message: 3 Date: Thu, 16 Jul 2009 16:08:51 -0700 From: Tim Roberts To: python-win32 at python.org Subject: Re: [python-win32] Python parser for Windows Event Logs Message-ID: <4A5FB303.7010303 at probo.com> Content-Type: text/plain; charset=ISO-8859-1 Tony Cappellini wrote: > I've added the While loop Mark suggested but still see the same issue. > GetNumberOfEventLogRecords() still returns 6 events, > However the object returned from ReadEvenLog() still only contains 3 objects > The next call to ReadeventLog() returns None > >OK, in my test, repeated calls to ReadEventLog eventually fetch all of >the events. Each call to ReadEventLog will return however many events >will fit in 1024 bytes, which is the buffer in the pywin32 code. If I >change your code to this: >while 1: > events=win32evtlog.ReadEventLog(hand,flags,0) > if not events: > break > for event in events: > print event.EventID, event.StringInserts >then it all works as expected. This is what I'm doing. I have added the while 1 last week, after Mark had suggested it. It did not change anything. ReadEventLog() returns None on successive calls. Which versions of Python and Pywin32 are you using? From cappy2112 at gmail.com Fri Jul 17 14:49:55 2009 From: cappy2112 at gmail.com (Tony Cappellini) Date: Fri, 17 Jul 2009 05:49:55 -0700 Subject: [python-win32] python-win32 Digest, Vol 76, Issue 17 In-Reply-To: References: Message-ID: <8249c4ac0907170549s66d57f5ck9b315bca36d432b9@mail.gmail.com> Message: 2 Date: Thu, 16 Jul 2009 15:57:31 -0700 From: Tim Roberts To: Python-Win32 List Subject: Re: [python-win32] Python parser for Windows Event Logs Message-ID: <4A5FB05B.2060705 at probo.com> Content-Type: text/plain; charset=ISO-8859-1 > Would anyone be willing to try parsing their own SystemEvent log to > see if they have the same issue (or parse min log and see if the > results are the same) ? > >>Similar. I saved one of the application event logs, and although Tim, would you try parsing the "SystemEventLog" (from Windows XP)? This is the one I'm having problems with, not the application log. There are other complications with Vista Logs, that i don't even want to get involved with. From timr at probo.com Fri Jul 17 18:22:47 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 17 Jul 2009 09:22:47 -0700 Subject: [python-win32] Python parser for Windows Event Logs In-Reply-To: <8249c4ac0907170546g5c04f25ajda1a2d60d9139352@mail.gmail.com> References: <8249c4ac0907170546g5c04f25ajda1a2d60d9139352@mail.gmail.com> Message-ID: <4A60A557.60906@probo.com> Tony Cappellini wrote: > >> while 1: >> events=win32evtlog.ReadEventLog(hand,flags,0) >> if not events: >> break >> for event in events: >> print event.EventID, event.StringInserts >> >> then it all works as expected. >> > > This is what I'm doing. I have added the while 1 last week, after Mark > had suggested it. > It did not change anything. ReadEventLog() returns None on successive calls. > > Which versions of Python and Pywin32 are you using? > XP SP3, Python 2.4.1, pywin32 214. Perhaps I should send you the C version of the same program that I wrote for testing, to see if it behaves differently. The code in pywin32 doesn't do that much processing -- it's mostly passthrough. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Jul 17 18:24:37 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 17 Jul 2009 09:24:37 -0700 Subject: [python-win32] Python parser for Windows Event Logs In-Reply-To: <8249c4ac0907170549s66d57f5ck9b315bca36d432b9@mail.gmail.com> References: <8249c4ac0907170549s66d57f5ck9b315bca36d432b9@mail.gmail.com> Message-ID: <4A60A5C5.9070903@probo.com> Tony Cappellini wrote: > >>> Similar. I saved one of the application event logs, and although >>> > > Tim, would you try parsing the "SystemEventLog" (from Windows XP)? > This is the one I'm having problems with, not the application log. > It shouldn't make one whit of difference. The format of the .evt file is the same, no matter which log it came from. You are reading an .evt file, and not the live log, right? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Jul 17 19:56:12 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 17 Jul 2009 10:56:12 -0700 Subject: [python-win32] Python parser for Windows Event Logs In-Reply-To: <8249c4ac0907161515o25560a78i69890227b9f3ec26@mail.gmail.com> References: <8249c4ac0907161515o25560a78i69890227b9f3ec26@mail.gmail.com> Message-ID: <4A60BB3C.8000508@probo.com> Tony Cappellini wrote: > I've added the While loop Mark suggested but still see the same issue. > GetNumberOfEventLogRecords() still returns 6 events, > However the object returned from ReadEvenLog() still only contains 3 objects > The next call to ReadeventLog() returns None > I tried to send this in a private email, but Google's fascist mail server evidently will not allow zip attachments. http://timr.probo.com/testevt.zip This zip contains a C++ program that does basically what my Python program does. Try running this on your .evt file (with a command line like "testevt xxx.evt") and see if it reads all 6 messages. If it only gets 3, then there is some fundamental issue below the Python stuff. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Jul 17 20:02:31 2009 From: timr at probo.com (Tim Roberts) Date: Fri, 17 Jul 2009 11:02:31 -0700 Subject: [python-win32] python-win32 Digest, Vol 76, Issue 17 In-Reply-To: <8249c4ac0907170549s66d57f5ck9b315bca36d432b9@mail.gmail.com> References: <8249c4ac0907170549s66d57f5ck9b315bca36d432b9@mail.gmail.com> Message-ID: <4A60BCB7.4000000@probo.com> Tony Cappellini wrote: > Tim, would you try parsing the "SystemEventLog" (from Windows XP)? > This is the one I'm having problems with, not the application log. > I saved a copy of my system event log with 2,383 events, and I'm able to read all 2,383 events. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From cappy2112 at gmail.com Sat Jul 18 01:21:31 2009 From: cappy2112 at gmail.com (Tony Cappellini) Date: Fri, 17 Jul 2009 16:21:31 -0700 Subject: [python-win32] Python parser for Windows Event Logs In-Reply-To: <4A6104B8.3080509@probo.com> References: <8249c4ac0907171455naeb7307i632fd4779e7ed3b0@mail.gmail.com> <4A60F7EF.3060105@probo.com> <8249c4ac0907171554v175dc69aqb416985050884dab@mail.gmail.com> <4A6104B8.3080509@probo.com> Message-ID: <8249c4ac0907171621s3010e0c0td59d99a816b7c2d1@mail.gmail.com> Ok- I've figured out the problem. After Mark suggested doing the call to ReadEventLog() inside of the while loop, I had accidentally left a call to ReadEventLog() outside of the loop. So the data coming back from that was just thrown away. The reason I didn't see that call is because all of the lines before and after it were commented out- and I guess my eyes looked that line looked the same. Problem solved! (operator error) From jdmain at comcast.net Sat Jul 18 17:59:50 2009 From: jdmain at comcast.net (J.D. Main) Date: Sat, 18 Jul 2009 09:59:50 -0600 Subject: [python-win32] Python COM Server and VB6 Integration Message-ID: <4A619D16.4728.2734BC5B@jdmain.comcast.net> Hi Folks, Hopefully this is the place to ask this question. I have written a COM server with a few trivial string methods to test the integration of Python and VB6 (and Visual Studio). I have "compiled" it with py2exe and created a DLL that can actually register with Windows. Nice. I have successfully accessed the method of this COM Server from VBA (using MS Word) and also with Python (thanks Mark Hammond for the examples). In addition, with some simple copy and paste, the VBA code will execute within the VB6 environment. So my code and my COM interface does actually work. BTW - I am not a VB guy. I just want to create Python DLLs to do useful things in the programs of others. However, my DLL can not be added as a reference to a VB6 or a VS2003 project. Both say it's not a valid DLL and thus it does not show up in any of their "reference object" lists. That basically means it's not available for use in that environment like other DLLs and OCXs. In addition, any sort of "intellisense" or call tips doesn't work. So my question is this: is there some special interface vodoo that needs to be put in my code or my py2exe setup in order to get this COM server truly visible and accessible within VB6 or Visual Studio? I would love to hear about any experience you may have with all this. Best Regards, J.D. From mc at mclaveau.com Sat Jul 18 23:54:34 2009 From: mc at mclaveau.com (Michel Claveau) Date: Sat, 18 Jul 2009 23:54:34 +0200 Subject: [python-win32] Python COM Server and VB6 Integration In-Reply-To: <4A619D16.4728.2734BC5B@jdmain.comcast.net> References: <4A619D16.4728.2734BC5B@jdmain.comcast.net> Message-ID: Hi! By default, dotNET (& Visual-Studio) need COM servers with TLB. But Python's COM servers no have TLB. For a solution from dotNET, search the expression "Late Binding" @-salutations -- Michel Claveau From skippy.hammond at gmail.com Sun Jul 19 15:18:55 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Sun, 19 Jul 2009 23:18:55 +1000 Subject: [python-win32] Python COM Server and VB6 Integration In-Reply-To: <4A619D16.4728.2734BC5B@jdmain.comcast.net> References: <4A619D16.4728.2734BC5B@jdmain.comcast.net> Message-ID: <4A631D3F.7010205@gmail.com> On 19/07/2009 1:59 AM, J.D. Main wrote: > So my question is this: is there some special interface vodoo that needs > to be put in my code or my py2exe setup in order to get this COM server truly > visible and accessible within VB6 or Visual Studio? > > I would love to hear about any experience you may have with all this. As Michel mentioned, the issue is that there is no type library for python COM servers - but they still work just fine. Cheers, Mark From jdmain at comcast.net Sun Jul 19 16:56:09 2009 From: jdmain at comcast.net (J.D. Main) Date: Sun, 19 Jul 2009 08:56:09 -0600 Subject: [python-win32] Python COM Server and VB6 Integration In-Reply-To: <4A631D3F.7010205@gmail.com> References: <4A619D16.4728.2734BC5B@jdmain.comcast.net>, <4A631D3F.7010205@gmail.com> Message-ID: <4A62DFA9.23543.2C20C8ED@jdmain.comcast.net> Thanks guys. I guess my next obvious question is: What would it take to create a python COM server with a Type Library such that VB6 or VS2003 would be happy with it? If I register my simple COM server, run makepy and select: "Microsoft Sisual Studio .NET VB and C# Project Model" Will that do it? From mc at mclaveau.com Mon Jul 20 01:21:42 2009 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 20 Jul 2009 01:21:42 +0200 Subject: [python-win32] Python COM Server and VB6 Integration In-Reply-To: <4A62DFA9.23543.2C20C8ED@jdmain.comcast.net> References: <4A619D16.4728.2734BC5B@jdmain.comcast.net>, <4A631D3F.7010205@gmail.com> <4A62DFA9.23543.2C20C8ED@jdmain.comcast.net> Message-ID: <70110818ECCE4F18AC0210DE04953F4F@MCI1330> Hi! TLB is static, fixed, congealed. Python ('s COM servers) is dynamic. With it, you can create (add) new functions/methods, after opening ; during use. (for info, I use Python-dynamic-COM-servers every day that God (and M. Hammond) made). TLB cannot follow, nor be adapted in the air. With dotNET, several language can use COM without TLB : IronPython (last release ; easy), JScript.Net (the old release ; easy), C# (via LateBinding ; not easy). I do not know, for VBxxx. @-salutations -- Michel Claveau From sudheer_87 at hotmail.com Tue Jul 21 04:48:19 2009 From: sudheer_87 at hotmail.com (sudheer sivathasan) Date: Tue, 21 Jul 2009 10:48:19 +0800 Subject: [python-win32] Trying to grab exe of foreground window Message-ID: Hi guys, Normally I?m able to find the answers I?m looking for on the net?but this time, either I haven?t searched hard enough or no one has attempted this before, so I would really like to request some help with this. I?m trying to write a program to locate the directory of the .exe of the foreground window and search for a file within that directory...I know this sounds ambitious but I believe there has to be a way to do it. So far, all I've managed to do is grab the name of the foreground window. Oh yeah, I'm pretty new to python actually...about 3 weeks into learning it. Any help you guys can provide would be greatly appreciated!! Thanks!! Regards, Sudheer With Windows Live, you can organize, edit, and share your photos. _________________________________________________________________ More than messages?check out the rest of the Windows Live?. http://www.microsoft.com/windows/windowslive/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From rwupole at msn.com Tue Jul 21 07:46:04 2009 From: rwupole at msn.com (Roger Upole) Date: Tue, 21 Jul 2009 01:46:04 -0400 Subject: [python-win32] Trying to grab exe of foreground window Message-ID: A sequence like this should get you there. win32gui.GetForegroundWindow win32process.GetWindowThreadProcessId win32api.OpenProcess win32process.EnumProcessModules win32process.GetModuleFileNameEx hth Roger From patrick at janssen.name Tue Jul 21 10:11:28 2009 From: patrick at janssen.name (Patrick Janssen) Date: Tue, 21 Jul 2009 16:11:28 +0800 Subject: [python-win32] timeout in DDE function call In-Reply-To: References: Message-ID: Hi all, We are still struggling to find a solution to this DDE timeout problem. I came across some sites talking about asynchronous DDE with callback functions. With this approach, the the DDE server executes a callback function when it has finished processing its long job. Does anyone know if this can be done with PyWin32? Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: From phudson1442 at gmail.com Tue Jul 21 20:28:07 2009 From: phudson1442 at gmail.com (Paul Hudson) Date: Tue, 21 Jul 2009 11:28:07 -0700 Subject: [python-win32] EOFError in gencache.py Message-ID: <17632efd0907211128kc923d22sa1f412fe366774ab@mail.gmail.com> Hi, I am having a similar problem when launching multiple instances of an Application that allows Python scripting via COM. (Yes, I am launching these instances at the same time.) The error I get is: File "C:\Python26\Lib\site-packages\win32com\client\makepy.py", line 288, in GenerateFromTypeLibSpec os.rename(outputName + ".temp", outputName) : [Error 32] The process cannot access the file because it is being used by another process pythoncom error: Unexpected exception in gateway method 'AddTypeLib' As stated below, I understand the gen_py folder is not thread-safe. The behavior I am seeing suggests many of the __init__.py files are being rewritten every time an instance of my App initiates Python. Is this normal win32com.client implementation? If I am using the same App day after day, do the gen_py folders and files need rewritten constantly? Is there a way to tuck away the gen_py files for this App into a more permanent location? Thanks, Paul > ---------------Original Message---------------------- > On 5/02/2009 9:40 AM, Zdenek Mejzlik wrote: > >* File "c:\python25\lib\site-packages\win32com\client\gencache.py", line > *>* 109, in _LoadDicts > *>* version = p.load() > *>* EOFError > * > This is an error loading 'dicts.dat' from the win32com\gen_py directory. > The management of this file is very crude and doesn't protect against > threads or processes stomping on other. > > Does you app create COM objects on different threads, or are there > multiple instances of your app starting at the same time? If so, we > might like to instrument the code to see if this indeed the problem. > > >* If I uninstall both pywin and Python and install them again the problem > *>* disappears. But it is only temporary > *>* solution the problem returns back after several days. Please, help me to > *>* find the definitive solution. > * > A quicker workaround should be to remove dicts.dat, or indeed, the > contents of the entire gen_py directory (but don't remove the directory > itself, or makepy will assume it can't write to win32com and use a > gen_py under %TEMP%.) > > Cheers, > > Mark > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sudheer_87 at hotmail.com Tue Jul 21 11:17:23 2009 From: sudheer_87 at hotmail.com (sudheer sivathasan) Date: Tue, 21 Jul 2009 17:17:23 +0800 Subject: [python-win32] handle is invalid? Message-ID: Hey guys, Another quick question. I'm still trying to do the thing in the email below. But this time im trying to use the win32api.GetModuleFileName function. It requires a PyHandle as an input which I think I've managed to get by using the function handle = w.FindWindow(0,str(w.GetWindowText(w.GetForegroundWindow()))) where handle would serve as the input to the win32api.GetModuleFileName function and w = win32gui. However I'm getting a 'the handle is invalid' error. Something I'm doing must be wrong. I figure if I can get the filename associated with the open window, I can just run a search for it through python. I'm sure there is an easier way to perform the stuff in the email below though. Could any of you guys please help me out with this? Thanks. Regards, Sudheer PS: Is there a way to use GetFullPathName to find the path of the .exe file? From: sudheer_87 at hotmail.com To: python-win32 at python.org Subject: Trying to grab exe of foreground window Date: Tue, 21 Jul 2009 10:48:19 +0800 Hi guys, Normally I?m able to find the answers I?m looking for on the net?but this time, either I haven?t searched hard enough or no one has attempted this before, so I would really like to request some help with this. I?m trying to write a program to locate the directory of the .exe of the foreground window and search for a file within that directory...I know this sounds ambitious but I believe there has to be a way to do it. So far, all I've managed to do is grab the name of the foreground window. Oh yeah, I'm pretty new to python actually...about 3 weeks into learning it. Any help you guys can provide would be greatly appreciated!! Thanks!! Regards, Sudheer With Windows Live, you can organize, edit, and share your photos. check out the rest of the Windows Live?. More than mail?Windows Live? goes way beyond your inbox. More than messages _________________________________________________________________ With Windows Live, you can organize, edit, and share your photos. http://www.microsoft.com/malaysia/windows/windowslive/products/photo-gallery-edit.aspx -------------- next part -------------- An HTML attachment was scrubbed... URL: From sudheer_87 at hotmail.com Wed Jul 22 04:34:11 2009 From: sudheer_87 at hotmail.com (reehdus) Date: Tue, 21 Jul 2009 19:34:11 -0700 (PDT) Subject: [python-win32] Trying to grab exe of foreground window In-Reply-To: References: Message-ID: <24599109.post@talk.nabble.com> I tried that but I get stuck at EnumProcessModules. It tells me my access is denied. I'm not sure if I'm doing it right. My code is below: import win32gui import win32api import win32con from time import sleep import win32process sleep(2) name = win32gui.GetForegroundWindow() t,p = win32process.GetWindowThreadProcessId(name) handle = win32api.OpenProcess(1,False,p) sleep(1) whee = win32process.EnumProcessModules(handle) nama = win32process.GetModuleFileNameEx(whee, 0) print nama Thanks! Roger Upole wrote: > > A sequence like this should get you there. > > win32gui.GetForegroundWindow > win32process.GetWindowThreadProcessId > win32api.OpenProcess > win32process.EnumProcessModules > win32process.GetModuleFileNameEx > > hth > Roger > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- View this message in context: http://www.nabble.com/Trying-to-grab-exe-of-foreground-window-tp24582049p24599109.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From rwupole at msn.com Wed Jul 22 13:38:21 2009 From: rwupole at msn.com (Roger Upole) Date: Wed, 22 Jul 2009 07:38:21 -0400 Subject: [python-win32] Trying to grab exe of foreground window Message-ID: reehdus wrote: > I tried that but I get stuck at EnumProcessModules. It tells me my access > is > denied. I'm not sure if I'm doing it right. My code is below: > > import win32gui > import win32api > import win32con > from time import sleep > import win32process > > sleep(2) > name = win32gui.GetForegroundWindow() > t,p = win32process.GetWindowThreadProcessId(name) > handle = win32api.OpenProcess(1,False,p) > sleep(1) > whee = win32process.EnumProcessModules(handle) > nama = win32process.GetModuleFileNameEx(whee, 0) > print nama > > Thanks! > > Roger Upole wrote: >> >> A sequence like this should get you there. >> >> win32gui.GetForegroundWindow >> win32process.GetWindowThreadProcessId >> win32api.OpenProcess >> win32process.EnumProcessModules >> win32process.GetModuleFileNameEx >> >> hth >> Roger You'll need to use a different access mask for OpenProcess. handle = win32api.OpenProcess(win32con.PROCESS_VM_READ|win32con.PROCESS_QUERY_INFORMATION,False,p) Also, GetModuleFileNameEx needs the process handle: nama = win32process.GetModuleFileNameEx(handle, whee[0]) Roger From Jonathan.Shelley at inl.gov Wed Jul 22 15:00:20 2009 From: Jonathan.Shelley at inl.gov (Jonathan K Shelley) Date: Wed, 22 Jul 2009 07:00:20 -0600 Subject: [python-win32] Jonathan K Shelley is out of the office. Message-ID: I will be out of the office starting 07/21/2009 and will not return until 07/27/2009. I will respond to your message when I return. For assistance please contact Blaik Beattie (blaik.beattie at inl.gov) -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Jul 22 20:02:30 2009 From: timr at probo.com (Tim Roberts) Date: Wed, 22 Jul 2009 11:02:30 -0700 Subject: [python-win32] handle is invalid? In-Reply-To: References: Message-ID: <4A675436.4080308@probo.com> sudheer sivathasan wrote: > Hey guys, > > Another quick question. I'm still trying to do the thing in the email > below. But this time im trying to use the win32api.GetModuleFileName > function. It requires a PyHandle as an input which I think I've > managed to get by using the function handle = > w.FindWindow(0,str(w.GetWindowText(w.GetForegroundWindow()))) where > handle would serve as the input to the win32api.GetModuleFileName > function and w = win32gui. However I'm getting a 'the handle is > invalid' error. Yes, because FindWindow returns a window handle, and GetModuleFileName expects a module handle. Handles are not all alike. Roger Upole gave you exactly the recipe you need. Was there something about his reply that you didn't like? By the way, your code there is somewhat silly: the FindWindow call will return exactly the same handle that GetForegroundWindow already gave you. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Jul 22 20:10:32 2009 From: timr at probo.com (Tim Roberts) Date: Wed, 22 Jul 2009 11:10:32 -0700 Subject: [python-win32] Trying to grab exe of foreground window In-Reply-To: <24599109.post@talk.nabble.com> References: <24599109.post@talk.nabble.com> Message-ID: <4A675618.9000605@probo.com> reehdus wrote: > I tried that but I get stuck at EnumProcessModules. It tells me my access is > denied. I'm not sure if I'm doing it right. My code is below: > > import win32gui > import win32api > import win32con > from time import sleep > import win32process > > sleep(2) > name = win32gui.GetForegroundWindow() > t,p = win32process.GetWindowThreadProcessId(name) > handle = win32api.OpenProcess(1,False,p) > The 1 there means PROCESS_TERMINATE. That means you are only asking for permission to terminate the process, not to enumerate its contents. For EnumProcessModules, you need PROCESS_QUERY_INFORMATION and PROCESS_VM_READ, which would be 0x0410. > sleep(1) > whee = win32process.EnumProcessModules(handle) > nama = win32process.GetModuleFileNameEx(whee, 0) > print nama > Why are those "sleeps" in there? EnumProcessModules returns a tuple, containing all of the modules currently loaded in the process. You would need to choose one. However, in this particular case, you don't need that call at all. GetModuleFileNameEx takes a process handle, plus a module handle, or "0" to mean the processes original exe. So, you can replace those last four lines with: print win32process.GetModuleFileNameEx( handle, 0 ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gary.smith28 at comcast.net Wed Jul 22 21:59:30 2009 From: gary.smith28 at comcast.net (Gary Smith) Date: Wed, 22 Jul 2009 15:59:30 -0400 Subject: [python-win32] (no subject) Message-ID: Hi All, I built a Python com server to solve regular expressions for use in a VBA application. Here's the code: import pythoncom import re import string class reObj: _public_methods_ = ["re"] _reg_progid_ = "Python.reObj" _reg_clsid_ = pythoncom.CreateGuid() def __init__ (self): pass def re(self, pattern, str): result='' matchGroup=re.search(pattern,str) while matchGroup<>None: (start,end)=matchGroup.span() result = result + ", " + str[start:end] str=str.replace(str[start:end],'',1) matchGroup=re.search(pattern,str) return result[2:] def listem(self, list): for item in list: print item, r.re(p,item) if __name__ == '__main__': import win32com.server.register win32com.server.register.UseCommandLine(reObj) The last few lines register the com server, so all that is necessary is to execute the code. Calling from VBA is: Dim re As Object Set reObj = CreateObject("Python.reObj") Result = reObj(pattern, string) _ I got the basic idea from something I found on the web. Cheers, Gary __________________________________ "Even for practical purposes theory generally turns out the most important thing in the end." Oliver Wendell Holmes. -------------- next part -------------- An HTML attachment was scrubbed... URL: From sudheer_87 at hotmail.com Thu Jul 23 02:26:12 2009 From: sudheer_87 at hotmail.com (reehdus) Date: Wed, 22 Jul 2009 17:26:12 -0700 (PDT) Subject: [python-win32] handle is invalid? In-Reply-To: <4A675436.4080308@probo.com> References: <4A675436.4080308@probo.com> Message-ID: <24617252.post@talk.nabble.com> ahha...that would explain a lot...nope...roger's method was excellent...I was trying this out before I saw his recipe. I see...well...pardon my ignorance since I'm pretty new at Python...it didn't really occur to me that FindWindow was redundant. Well, now I know better...hahaha. Thanks! Tim Roberts wrote: > > sudheer sivathasan wrote: >> Hey guys, >> >> Another quick question. I'm still trying to do the thing in the email >> below. But this time im trying to use the win32api.GetModuleFileName >> function. It requires a PyHandle as an input which I think I've >> managed to get by using the function handle = >> w.FindWindow(0,str(w.GetWindowText(w.GetForegroundWindow()))) where >> handle would serve as the input to the win32api.GetModuleFileName >> function and w = win32gui. However I'm getting a 'the handle is >> invalid' error. > > Yes, because FindWindow returns a window handle, and GetModuleFileName > expects a module handle. Handles are not all alike. Roger Upole gave > you exactly the recipe you need. Was there something about his reply > that you didn't like? > > By the way, your code there is somewhat silly: the FindWindow call will > return exactly the same handle that GetForegroundWindow already gave you. > > -- > 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 > > -- View this message in context: http://www.nabble.com/handle-is-invalid--tp24599116p24617252.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From sudheer_87 at hotmail.com Thu Jul 23 02:36:39 2009 From: sudheer_87 at hotmail.com (reehdus) Date: Wed, 22 Jul 2009 17:36:39 -0700 (PDT) Subject: [python-win32] Trying to grab exe of foreground window In-Reply-To: <4A675618.9000605@probo.com> References: <24599109.post@talk.nabble.com> <4A675618.9000605@probo.com> Message-ID: <24617345.post@talk.nabble.com> Excellent...it works! Thanks...I put in the first sleep so I could test the program with various other applications, so it'd give me enough time to open up internet explorer or something...the second sleep was a typo...leftover from a bit of earlier code i did. I see...I tried looking for documentation onw win32con to see what I needed but I couldn't muster up anything. All i got were win32con.PROCESS_TERMINATE and process query information so I assumed one of this was what I needed. Again...thanks so much for enlightening me. Sudheer Tim Roberts wrote: > > reehdus wrote: >> I tried that but I get stuck at EnumProcessModules. It tells me my access >> is >> denied. I'm not sure if I'm doing it right. My code is below: >> >> import win32gui >> import win32api >> import win32con >> from time import sleep >> import win32process >> >> sleep(2) >> name = win32gui.GetForegroundWindow() >> t,p = win32process.GetWindowThreadProcessId(name) >> handle = win32api.OpenProcess(1,False,p) >> > > The 1 there means PROCESS_TERMINATE. That means you are only asking for > permission to terminate the process, not to enumerate its contents. For > EnumProcessModules, you need PROCESS_QUERY_INFORMATION and > PROCESS_VM_READ, which would be 0x0410. > >> sleep(1) >> whee = win32process.EnumProcessModules(handle) >> nama = win32process.GetModuleFileNameEx(whee, 0) >> print nama >> > > Why are those "sleeps" in there? > > EnumProcessModules returns a tuple, containing all of the modules > currently loaded in the process. You would need to choose one. > However, in this particular case, you don't need that call at all. > GetModuleFileNameEx takes a process handle, plus a module handle, or "0" > to mean the processes original exe. So, you can replace those last four > lines with: > print win32process.GetModuleFileNameEx( handle, 0 ) > > -- > 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 > > -- View this message in context: http://www.nabble.com/Trying-to-grab-exe-of-foreground-window-tp24582049p24617345.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From timr at probo.com Thu Jul 23 19:06:01 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 23 Jul 2009 10:06:01 -0700 Subject: [python-win32] Trying to grab exe of foreground window In-Reply-To: <24617345.post@talk.nabble.com> References: <24599109.post@talk.nabble.com> <4A675618.9000605@probo.com> <24617345.post@talk.nabble.com> Message-ID: <4A689879.4080308@probo.com> reehdus wrote: > > I see...I tried looking for documentation onw win32con to see what I > needed but I couldn't muster up anything. All i got were > win32con.PROCESS_TERMINATE and process query information so I assumed one of > this was what I needed. Again...thanks so much for enlightening me. > Remember that virtually all of the calls in the "win32" modules are direct mappings to the Win32 APIs of the same name. For the most part, the best source of technical information is the MSDN pages for the APIs. You sometimes have to spend a few minutes trying to map the C parameters into Python code, but once you get the pattern, that's not so hard. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From blade.eric at gmail.com Fri Jul 24 02:03:24 2009 From: blade.eric at gmail.com (Eric Blade) Date: Thu, 23 Jul 2009 20:03:24 -0400 Subject: [python-win32] trying to grab exe of foreground window Message-ID: <59ce684e0907231703r2d1f783v59e369731d8e829d@mail.gmail.com> I've done some pretty extensive work with determining name of executeables belonging to a window by Window Handle .. and here's what I've come up with ,that seems to work 100% of the time, even on Vista: # Request privileges to enable "debug process", so we can later use PROCESS_VM_READ, retardedly required to GetModuleFileNameEx() priv_flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY hToken = win32security.OpenProcessToken (win32api.GetCurrentProcess(), priv_flags) # enable "debug process" privilege_id = win32security.LookupPrivilegeValue (None, win32security.SE_DEBUG_NAME) old_privs = win32security.AdjustTokenPrivileges (hToken, 0, [(privilege_id, win32security.SE_PRIVILEGE_ENABLED)]) # Open the process, and query it's filename processid = win32process.GetWindowThreadProcessId(hwnd) pshandle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, False, processid[1]) exename = win32process.GetModuleFileNameEx(pshandle, 0) # clean up win32api.CloseHandle(pshandle) win32api.CloseHandle(hToken) The first block of code got it working in 100% of our users cases on Vista (whereas previously, we could only get it if they were both admin, and had the python executeable and the executeable we were trying to query stored outside of the Program Files hierarchy). Also, without the two calls to CloseHandle, we would eventually leak resources until the system was completely depleted of handles, and then every other operation would fail, not just by our program, but by every program, and even the Windows swapper would eventually crash and bring the system down. Lesson I've learned: Always clean up after yourself when you're mucking about with the Windows API, Python won't do it for you. (I imagine others haven't mentioned to do this because others probably don't need to run this routine bajillions of times, therefore don't see their programs leaking like the proverbial sieves) On Thu, Jul 23, 2009 at 6:00 AM, wrote: > Send python-win32 mailing list submissions to > ? ? ? ?python-win32 at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > ? ? ? ?http://mail.python.org/mailman/listinfo/python-win32 > or, via email, send a message with subject or body 'help' to > ? ? ? ?python-win32-request at python.org > > You can reach the person managing the list at > ? ? ? ?python-win32-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of python-win32 digest..." > > > Today's Topics: > > ? 1. Re: handle is invalid? (reehdus) > ? 2. Re: Trying to grab exe of foreground window (reehdus) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 22 Jul 2009 17:26:12 -0700 (PDT) > From: reehdus > To: python-win32 at python.org > Subject: Re: [python-win32] handle is invalid? > Message-ID: <24617252.post at talk.nabble.com> > Content-Type: text/plain; charset=us-ascii > > > ahha...that would explain a lot...nope...roger's method was excellent...I was > trying this out before I saw his recipe. I see...well...pardon my ignorance > since I'm pretty new at Python...it didn't really occur to me that > FindWindow was redundant. Well, now I know better...hahaha. Thanks! > > > Tim Roberts wrote: >> >> sudheer sivathasan wrote: >>> Hey guys, >>> >>> Another quick question. I'm still trying to do the thing in the email >>> below. But this time im trying to use the win32api.GetModuleFileName >>> function. It requires a PyHandle as an input which I think I've >>> managed to get by using the function handle = >>> w.FindWindow(0,str(w.GetWindowText(w.GetForegroundWindow()))) where >>> handle would serve as the input to the win32api.GetModuleFileName >>> function and w = win32gui. However I'm getting a 'the handle is >>> invalid' error. >> >> Yes, because FindWindow returns a window handle, and GetModuleFileName >> expects a module handle. ?Handles are not all alike. ?Roger Upole gave >> you exactly the recipe you need. ?Was there something about his reply >> that you didn't like? >> >> By the way, your code there is somewhat silly: the FindWindow call will >> return exactly the same handle that GetForegroundWindow already gave you. >> >> -- >> 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 >> >> > > -- > View this message in context: http://www.nabble.com/handle-is-invalid--tp24599116p24617252.html > Sent from the Python - python-win32 mailing list archive at Nabble.com. > > > > ------------------------------ > > Message: 2 > Date: Wed, 22 Jul 2009 17:36:39 -0700 (PDT) > From: reehdus > To: python-win32 at python.org > Subject: Re: [python-win32] Trying to grab exe of foreground window > Message-ID: <24617345.post at talk.nabble.com> > Content-Type: text/plain; charset=us-ascii > > > ? ? ?Excellent...it works! Thanks...I put in the first sleep so I could test > the program with various other applications, so it'd give me enough time to > open up internet explorer or something...the second sleep was a > typo...leftover from a bit of earlier code i did. > ? ? ?I see...I tried looking for documentation onw win32con to see what I > needed but I couldn't muster up anything. All i got were > win32con.PROCESS_TERMINATE and process query information so I assumed one of > this was what I needed. Again...thanks so much for enlightening me. > > Sudheer > > > Tim Roberts wrote: >> >> reehdus wrote: >>> I tried that but I get stuck at EnumProcessModules. It tells me my access >>> is >>> denied. I'm not sure if I'm doing it right. My code is below: >>> >>> import win32gui >>> import win32api >>> import win32con >>> from time import sleep >>> import win32process >>> >>> sleep(2) >>> name = win32gui.GetForegroundWindow() >>> t,p = win32process.GetWindowThreadProcessId(name) >>> handle = win32api.OpenProcess(1,False,p) >>> >> >> The 1 there means PROCESS_TERMINATE. ?That means you are only asking for >> permission to terminate the process, not to enumerate its contents. ?For >> EnumProcessModules, you need PROCESS_QUERY_INFORMATION and >> PROCESS_VM_READ, which would be 0x0410. >> >>> sleep(1) >>> whee = win32process.EnumProcessModules(handle) >>> nama = win32process.GetModuleFileNameEx(whee, 0) >>> print nama >>> >> >> Why are those "sleeps" in there? >> >> EnumProcessModules returns a tuple, containing all of the modules >> currently loaded in the process. ?You would need to choose one. >> However, in this particular case, you don't need that call at all. >> GetModuleFileNameEx takes a process handle, plus a module handle, or "0" >> to mean the processes original exe. ?So, you can replace those last four >> lines with: >> ? ? print win32process.GetModuleFileNameEx( handle, 0 ) >> >> -- >> 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 >> >> > > -- > View this message in context: http://www.nabble.com/Trying-to-grab-exe-of-foreground-window-tp24582049p24617345.html > Sent from the Python - python-win32 mailing list archive at Nabble.com. > > > > ------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > End of python-win32 Digest, Vol 76, Issue 24 > ******************************************** > -- Cheers, - Eric From mc at mclaveau.com Fri Jul 24 09:54:18 2009 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 24 Jul 2009 09:54:18 +0200 Subject: [python-win32] trying to grab exe of foreground window In-Reply-To: <59ce684e0907231703r2d1f783v59e369731d8e829d@mail.gmail.com> References: <59ce684e0907231703r2d1f783v59e369731d8e829d@mail.gmail.com> Message-ID: Hi, Eric! Below, derived from your code, an exemple for to found modules in memory (useful for "scan memory" with clamwin, or other usages) @-salutations -- Michel Claveau import win32api,win32con,win32process,win32security # Request privileges to enable "debug process", so we can later use PROCESS_VM_READ, retardedly required to GetModuleFileNameEx() priv_flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY hToken = win32security.OpenProcessToken(win32api.GetCurrentProcess(), priv_flags) # enable "debug process" privilege_id = win32security.LookupPrivilegeValue (None,win32security.SE_DEBUG_NAME) old_privs = win32security.AdjustTokenPrivileges (hToken, 0,[(privilege_id, win32security.SE_PRIVILEGE_ENABLED)]) # get all filenames of all modules from all processes (dict for no doublons & count instances) lm={} for pid in win32process.EnumProcesses(): try: pshandle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ, False, pid) exename = win32process.GetModuleFileNameEx(pshandle, 0) for module in win32process.EnumProcessModules(pshandle): fname=win32process.GetModuleFileNameEx(pshandle, module) lm[fname]=lm.setdefault(fname,0)+1 win32api.CloseHandle(pshandle) except: pass # clean up win32api.CloseHandle(hToken) for filename in lm: print "Nb:",lm[filename],'\t filename:',filename -------------- next part -------------- An HTML attachment was scrubbed... URL: From sudheer_87 at hotmail.com Fri Jul 24 02:44:44 2009 From: sudheer_87 at hotmail.com (reehdus) Date: Thu, 23 Jul 2009 17:44:44 -0700 (PDT) Subject: [python-win32] trying to grab exe of foreground window In-Reply-To: <59ce684e0907231703r2d1f783v59e369731d8e829d@mail.gmail.com> References: <59ce684e0907231703r2d1f783v59e369731d8e829d@mail.gmail.com> Message-ID: <24636956.post@talk.nabble.com> Awesome, thanks Eric, Roger and Tim for your help. Everything's been working fine so far. Here's what I've been using. It works on Vista too but I have admin access to that though. t,p = win32process.GetWindowThreadProcessId(hwnd)#find out PID to window handle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION|win32con.PROCESS_VM_READ,0,p)#use PID to get process handle path = win32process.GetModuleFileNameEx(handle, 0)#use process handle to get path of window path = '\\'.join(path.split('\\')[0:-1])#delete all terms after final '\' including '\' path = path + '\\'#append '\' to path Seems to be working fine so far. Thanks a lot guys! Really appreciate the help -- View this message in context: http://www.nabble.com/Trying-to-grab-exe-of-foreground-window-tp24582049p24636956.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From lemaire.adrien at gmail.com Fri Jul 24 15:18:43 2009 From: lemaire.adrien at gmail.com (Adrien LEMAIRE) Date: Fri, 24 Jul 2009 15:18:43 +0200 Subject: [python-win32] Problem with Python win32com while loading facebook homepage Message-ID: Hi dear members of the python-win32 python mailing list, I'm trying to connect to my facebook account.. I'd like to automate some tasks like closing applications requests, and why not automate task for application games of facebook, if I arrive to do this. But I can't arrive to connect to homepage.. First, without win32com, the code page return by the script was a javascript script : > > > After reading a little on the web ( I searched a solution to execute javascript code from python), I've found the next added lines, which use win32com. I have installed pywin32-214 (I use python 2.6.2). See below my code : > # -*- coding:Utf-8 -*- > #!/usr/bin/python > import httplib > import urllib > > Connexion = httplib.HTTP('www.facebook.com') > Connexion.putrequest('GET', '/home.php') > Connexion.putheader('Host', 'www.facebook.com') > Connexion.putheader('Accept', 'text/html') > Connexion.putheader('Cookie', 'the_long_cookie_from_facebook') > Connexion.endheaders() > ErrCode, ErrMsg, Headers = Connexion.getreply() > Handle = Connexion.getfile() > Buffer = Handle.read() > > from win32com.client.gencache import EnsureDispatch > ie = EnsureDispatch('InternetExplorer.Application') > ie.Navigate('http://www.facebook.com') > print ie.Document.documentElement.innerHTML When I execute the script, I have this error : > >>> > Traceback (most recent call last): > File "C:\Documents and Settings\adlemair\Bureau\exos\connectFacebook.py", > line 18, in > from win32com.client.gencache import EnsureDispatch > File "C:\Python26\lib\site-packages\win32com\__init__.py", line 5, in > > import win32api, sys, os > ImportError: DLL load failed: Le module sp?cifi? est introuvable. Do you know why ? Do you arrive to execute this script on your side ? Thank you so much for your advise Best regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From stef.mientki at gmail.com Sat Jul 25 11:44:24 2009 From: stef.mientki at gmail.com (Stef Mientki) Date: Sat, 25 Jul 2009 11:44:24 +0200 Subject: [python-win32] bluetooth communication ? Message-ID: <4A6AD3F8.8000109@gmail.com> hello, I want to make a program that synchronizes (automatically in the backgroud) a netbook with a desktop PC through bluetooth. I tried pybluez, but on 2 of the 3 computers it gave an error message, bluetooth device not found. And that problem comes from the compiled pyd library, so I'm stuck there. Are there any other ways (Windows only), to enumerate the bluetooth network and transfer a few files ? thanks, Stef Mientki I From mc at mclaveau.com Sat Jul 25 17:51:23 2009 From: mc at mclaveau.com (Michel Claveau) Date: Sat, 25 Jul 2009 17:51:23 +0200 Subject: [python-win32] Problem with Python win32com while loading facebookhomepage In-Reply-To: References: Message-ID: <1107272FAE2E4298B81F736DD93C758C@MCI1330> Hi! The code below run OK for me. (Do not remove the sleep) @+ -- Michel Claveau # -*- coding: utf-8 -*- import win32com.client import time ie = win32com.client.Dispatch('InternetExplorer.Application') time.sleep(4) ie.Visible=1 ie.Navigate('http://www.facebook.com') time.sleep(4) txt=ie.Document.Body.innerHTML ie.Quit() time.sleep(0.250) del(ie) print type(txt) print print txt.encode('cp850','replace') From oxydol010 at hotmail.com Sun Jul 26 23:25:31 2009 From: oxydol010 at hotmail.com (Christopher Chapman) Date: Sun, 26 Jul 2009 23:25:31 +0200 Subject: [python-win32] subprocess and stdout Message-ID: I'm trying to write a "module" to a larger program. This module eventually needs to reference a config file with setup information in it, but I'm not there yet. I'm using the subprocess module to run an external antivirus program and trying to get the output written to a log file, but I keep getting a weird return. My code is listed below. I'm a noob to Python so I'm not sure if this is a windows specific issue or not, but I'm programming on windows and more then likely what I'm working on won't be on anything other then a windows machine. I'm also writing my code for 3.1 if that makes any difference. # Pass target path to scanners command line and write output to a file # Currently "scan" only targets the McAfee Command Line Scanner print() print ("Begining scan of " + target) print() scan = "scan /all " + target s = subprocess.Popen(scan, stdout=subprocess.PIPE) out = s.communicate()[0] chgout = str(out) s.wait() scanlog.write(chgout) scanlog.close " If I change my stdout in s subprocess to None then everything gets written to the terminal as if I had just run the program straight from the command line, but when I try piping it to my file "scanlog" then literally the only return I get in the file is '' or two single quotes. I've even tried piping the output and then printing it instead of writing it to a file and I get the same result. I've experimented with standard windows command line commands and using the same syntax was able to pipe directory listings and other things to my file. Any ideas what I'm missing here? Thanks in advance Chris Chapman From davea at ieee.org Mon Jul 27 14:28:51 2009 From: davea at ieee.org (Dave Angel) Date: Mon, 27 Jul 2009 08:28:51 -0400 Subject: [python-win32] subprocess and stdout In-Reply-To: References: Message-ID: <4A6D9D83.6050505@ieee.org> Christopher Chapman wrote: > I'm trying to write a "module" to a larger program. This module eventually > needs to reference a config file with setup information in it, but I'm not > there yet. I'm using the subprocess module to run an external antivirus > program and trying to get the output written to a log file, but I keep > getting a weird return. My code is listed below. I'm a noob to Python so > I'm not sure if this is a windows specific issue or not, but I'm programming > on windows and more then likely what I'm working on won't be on anything > other then a windows machine. I'm also writing my code for 3.1 if that > makes any difference. > > # Pass target path to scanners command line and write output to a file > # Currently "scan" only targets the McAfee Command Line Scanner > print() > print ("Begining scan of " + target) > print() > scan = "scan /all " + target > s = subprocess.Popen(scan, > stdout=subprocess.PIPE) > out = s.communicate()[0] > chgout = str(out) > s.wait() > scanlog.write(chgout) > scanlog.close > " > If I change my stdout in s subprocess to None then everything gets written > to the terminal as if I had just run the program straight from the command > line, but when I try piping it to my file "scanlog" then literally the only > return I get in the file is '' or two single quotes. I've even tried piping > the output and then printing it instead of writing it to a file and I get > the same result. I've experimented with standard windows command line > commands and using the same syntax was able to pipe directory listings and > other things to my file. Any ideas what I'm missing here? Thanks in > advance > > Chris Chapman > > > I suspect it's because of the way the antivirus program is written. I can't be sure what you tried at the command prompt, but have you tried this: c:\>scan /all > scanlog.txt If this does not capture to the file, then scan.exe isn't written in the way you're expecting. There are several ways to write directly to a console that do not redirect or pipe. You might also look to see whether scan has any other commandline options. One of them might be to create a log file. DaveA From mdriscoll at co.marshall.ia.us Mon Jul 27 20:31:18 2009 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Mon, 27 Jul 2009 13:31:18 -0500 Subject: [python-win32] Problem with Python win32com while loading facebook homepage In-Reply-To: References: Message-ID: <4A6DF276.7050009@co.marshall.ia.us> Adrien, > Hi dear members of the python-win32 python mailing list, > > I'm trying to connect to my facebook account.. I'd like to automate > some tasks like closing applications requests, and why not automate > task for application games of facebook, if I arrive to do this. > > But I can't arrive to connect to homepage.. > First, without win32com, the code page return by the script was a > javascript script : > > > > > > > After reading a little on the web ( I searched a solution to execute > javascript code from python), I've found the next added lines, which > use win32com. I have installed pywin32-214 (I use python 2.6.2). > > See below my code : > > # -*- coding:Utf-8 -*- > #!/usr/bin/python > import httplib > import urllib > > Connexion = httplib.HTTP('www.facebook.com ') > Connexion.putrequest('GET', '/home.php') > Connexion.putheader('Host', 'www.facebook.com > ') > Connexion.putheader('Accept', 'text/html') > Connexion.putheader('Cookie', 'the_long_cookie_from_facebook') > Connexion.endheaders() > ErrCode, ErrMsg, Headers = Connexion.getreply() > Handle = Connexion.getfile() > Buffer = Handle.read() > > from win32com.client.gencache import EnsureDispatch > ie = EnsureDispatch('InternetExplorer.Application') > ie.Navigate('http://www.facebook.com') > print ie.Document.documentElement.innerHTML > > > When I execute the script, I have this error : > > >>> > Traceback (most recent call last): > File "C:\Documents and > Settings\adlemair\Bureau\exos\connectFacebook.py", line 18, in > > from win32com.client.gencache import EnsureDispatch > File "C:\Python26\lib\site-packages\win32com\__init__.py", line > 5, in > import win32api, sys, os > ImportError: DLL load failed: Le module sp?cifi? est introuvable. > > > Do you know why ? Do you arrive to execute this script on your side ? > > > Thank you so much for your advise > > Best regards, > Why not just use the pyFacebook module? It wraps Facebook's API and would probably be more reliable for communicating with their services. Here's a link: http://wiki.developers.facebook.com/index.php/Python - Mike From mikegraham at gmail.com Mon Jul 27 21:30:45 2009 From: mikegraham at gmail.com (Mike Graham) Date: Mon, 27 Jul 2009 14:30:45 -0500 Subject: [python-win32] By-reference COM method arguments not being treated as outputs Message-ID: <3f588a650907271230s33f94ee9n20da071b713d4024@mail.gmail.com> I used MakePy on a COM library with some success, but it does not seem to work with methods with passed-by-reference arguments. The documentation, as I understand it, says that the c_fun(in1, in2, *out1, *out2) should transform into (out1, out2) = py_fun(in1, in2). For example, MakePy makes me the method def PickObject(self, obj=defaultNamedNotOptArg, x=defaultNamedNotOptArg, y=defaultNamedNotOptArg, z=defaultNamedNotOptArg , obj_num=defaultNamedNotOptArg, entity_num=defaultNamedNotOptArg, tolerance=9.9999997473787516e-06, PType=0): """Retrieve an object ID and face or edge number by giving an object type and global coordinates""" return self._ApplyTypes_(76, 1, (24, 0), ((16387, 3), (12, 1), (12, 1), (12, 1), (16387, 3), (16387, 3), (5, 49), (3, 49)), u'PickObject', None,obj , x, y, z, obj_num, entity_num , tolerance, PType) where obj_num and entity_num are outputs. I cannot call this with object.PickObject(10, 0, 0, 0) like I should be able to or with object.PickObject(10, 0, 0, 0, pythoncom.Empty, pythoncom.Empty), which I've seen suggested (or with anything else I've tried in the last spots). How do I get this to treat these arguments right? From greg.antal at ata-e.com Mon Jul 27 23:20:04 2009 From: greg.antal at ata-e.com (Greg Antal) Date: Mon, 27 Jul 2009 14:20:04 -0700 Subject: [python-win32] By-reference COM method arguments not being treated as outputs In-Reply-To: <3f588a650907271230s33f94ee9n20da071b713d4024@mail.gmail.com> References: <3f588a650907271230s33f94ee9n20da071b713d4024@mail.gmail.com> Message-ID: <4A6E1A04.40007@ata-e.com> Mike: When I ran into this, it was because the type library on which I ran makepy was not quite correctly defined. You could check the archives of this mailing list starting at http://www.mail-archive.com/python-win32 at python.org/msg05578.html to see if maybe you have the same problem. If so, go to the next item in the thread to see Mark Hammond's suggested workaround. That worked, and would have been fine with me, but the TLB's authors actually fixed the TLB as soon as I showed them the problem, so I didn't have to do anything funny. Good luck. - Greg Antal Gregory W. Antal Senior Technical Advisor ATA Engineering, Inc. 11995 El Camino Real, Suite 200 San Diego, CA 92130 www.ata-e.com greg.antal at ata-e.com 858-480-2072 (Phone) 858-792-8932 (Fax) Mike Graham wrote, On 7/27/2009 12:30 PM: > I used MakePy on a COM library with some success, but it does not seem > to work with methods with passed-by-reference arguments. The > documentation, as I understand it, says that the c_fun(in1, in2, > *out1, *out2) should transform into (out1, out2) = py_fun(in1, in2). > > For example, MakePy makes me the method > > def PickObject(self, obj=defaultNamedNotOptArg, > x=defaultNamedNotOptArg, y=defaultNamedNotOptArg, > z=defaultNamedNotOptArg > , obj_num=defaultNamedNotOptArg, entity_num=defaultNamedNotOptArg, > tolerance=9.9999997473787516e-06, PType=0): > """Retrieve an object ID and face or edge number by giving an object > type and global coordinates""" > return self._ApplyTypes_(76, 1, (24, 0), ((16387, 3), (12, 1), (12, > 1), (12, 1), (16387, 3), (16387, 3), (5, 49), (3, 49)), u'PickObject', > None,obj > , x, y, z, obj_num, entity_num > , tolerance, PType) > > where obj_num and entity_num are outputs. I cannot call this with > object.PickObject(10, 0, 0, 0) like I should be able to or with > object.PickObject(10, 0, 0, 0, pythoncom.Empty, pythoncom.Empty), > which I've seen suggested (or with anything else I've tried in the > last spots). > > How do I get this to treat these arguments right? > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From sebastian.venus at uk.bnpparibas.com Tue Jul 28 09:20:14 2009 From: sebastian.venus at uk.bnpparibas.com (sebastian.venus at uk.bnpparibas.com) Date: Tue, 28 Jul 2009 08:20:14 +0100 Subject: [python-win32] Copying a MS Access Table Message-ID: Hi, how can I make a copy of a table in an Access database using Python? The VBA command would be 'DoCmd.CopyObject'. If there is no such command for Python, then alternatively I could request Python to call a VBA function that does that, but I don't know how to do that either. Many thanks for your help. -------- This communication is confidential, may be privileged and is meant only for the intended recipient. If you are not the intended recipient, please notify the sender by reply and delete the message from your system. Any unauthorised dissemination, distribution or copying hereof is prohibited. BNP Paribas Trust Corporation UK Limited, BNP Paribas UK Limited, BNP Paribas Commodity Futures Limited, BNP Paribas Asset Management UK Limited and Investment Fund Services Limited are authorised and regulated by the Financial Services Authority. BNP Paribas London Branch and BNP Paribas Wealth Management London Branch are authorised by the CECEI and supervised by the Commission Bancaire. BNP Paribas London Branch is authorised and subject to limited regulation by the Financial Services Authority. Details about the extent of our authorisation and regulation by the Financial Services Authority are available from us on request. BNP Paribas is also a member of the London Stock Exchange. BNP Paribas Wealth Management London Branch is subject to limited regulation by the Financial Services Authority. Details about the extent of our authorisation and regulation by the Financial Services Authority are available from us on request. BNP Paribas Securities Services London Branch is authorised by the CECEI and supervised by the AMF, and subject to limited regulation by the Financial Services Authority. Details on the extent of our regulation by the Financial Services Authority are available from us on request. BNP Paribas Securities Services is also a member of the London Stock Exchange. BNP Paribas Trust Corporation UK Limited is registered in England and Wales (registered no. 4042668) at registered office 55 Moorgate, London EC2R 6PA. BNP Paribas UK Limited is registered in England and Wales (registered no. 1488108) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Commodity Futures Limited is registered in England and Wales (registered no. 2391477) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Asset Management UK Limited is registered in England and Wales (registered no. 2474627) at registered office 10 Harewood Avenue, London NW1 6AA. Investment Fund Services Limited is registered in England and Wales (registered no. 6110770) at registered office 55 Moorgate, London EC2R 6PA. BNP Paribas London Branch is registered in England and Wales (registered no. FC13447) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Wealth Management London Branch is registered in England and Wales (registered no. FC023926) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Securities Services London Branch is registered in England and Wales (registered no. BR006393) at registered office 55 Moorgate, London, EC2R 6PA. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Jul 28 12:35:33 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 28 Jul 2009 11:35:33 +0100 Subject: [python-win32] Copying a MS Access Table In-Reply-To: References: Message-ID: <4A6ED475.10708@timgolden.me.uk> sebastian.venus at uk.bnpparibas.com wrote: > Hi, how can I make a copy of a table in an Access database using Python? > The VBA command would be 'DoCmd.CopyObject'. If there is no such command > for Python, then alternatively I could request Python to call a VBA > function that does that, but I don't know how to do that either. [... snips longest signature in the known universe ...] Depends on where you're starting from. You can use the win32com.client modules from the pywin32 package to automate pretty much anything in the COM world, including Access. At the same time, you can use the adodbapi module in that same package to access the db directly. You only need to look around the web for examples of what you want to do in any language and then translate them into Python. If you're still stuck, feel free to post back here. (I'm pretty sure there isn't an MSAccess-specific package for Python). TJG From kr_krack at yahoo.com Tue Jul 28 13:00:01 2009 From: kr_krack at yahoo.com (kk kk) Date: Tue, 28 Jul 2009 04:00:01 -0700 (PDT) Subject: [python-win32] How to read all tags from a specific event in Event Viewer ? Message-ID: <619226.7555.qm@web63507.mail.re1.yahoo.com> Hi, I'm new to python, i want to read some specific events form Event Viewer and then compare it with something else. For example I want to read event 552 and all o fits' properties: Date, Time, Type, User, Computer, Source, Category, EventID and all description and put it in a file.I've tried something with win32evtlogutil but i think i'm missing something. Can someone help me here ? I know that isn't diffcult, maybe someone can point me to the right direction I found this, it's working for a few events , but I need to read info about specific events, for example 18,19, 1014, 206 Thank you. import win32evtlog import win32evtlogutil flags = win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ hand=win32evtlog.OpenEventLog("test", "System") try: events=1 while events: events=win32evtlog.ReadEventLog(hand,flags,0) for ev_obj in events: ? #data is recent enough, so print it out computer=str(ev_obj.ComputerName) cat=str(ev_obj.EventCategory) level=str(ev_obj.EventType ) src=str(ev_obj.SourceName) record=str(ev_obj.RecordNumber) evt_id=str(winerror.HRESULT_CODE(ev_obj.EventID)) evt_type=str(evt_dict[ev_obj.EventType]) msg = str(win32evtlogutil.SafeFormatMessage(ev_obj, logtype)) ? print evt_id print msg win32evtlog.CloseEventLog(hand) except: print traceback.print_exc(sys.exc_info()) -------------- next part -------------- An HTML attachment was scrubbed... URL: From mikegraham at gmail.com Tue Jul 28 16:00:06 2009 From: mikegraham at gmail.com (Mike Graham) Date: Tue, 28 Jul 2009 09:00:06 -0500 Subject: [python-win32] By-reference COM method arguments not being treated as outputs In-Reply-To: <4A6E1A04.40007@ata-e.com> References: <3f588a650907271230s33f94ee9n20da071b713d4024@mail.gmail.com> <4A6E1A04.40007@ata-e.com> Message-ID: <3f588a650907280700u748b8c7ch8e87d76b32e5ba49@mail.gmail.com> Hi Greg, Thanks for your reply. I went back through the mailing list archives to try to find someone else who had the same problem I did and found your posts, but I couldn't quite understand your and Hammond's solutions well enough to apply it. Perhaps you or someone else can help me understand what's going on better. You present what looks like an item from a dict: "feSelector": (10349, 2, (9, 0), (), "feSelector", None) and explain that the None in the tuple should be replaced by the CLSID of the class to which "feSelector" belongs. The method I posted as an example's name does not occur in any dicts. It occurs in two places in the generated source. The first is the method definition I posted, in which it is part of a class _IDualModelItem(DispatchBaseClass) with the member CLSID=IID('{976FAFC8-96FD-11D4-A09D-0050DA1AC1A8}'). I am not aware of any particular python class from which this should be associated with. In my definition, I have a tuple that appears to be laid out the same as yours, so I tried replacing None with '{976FAFC8-96FD-11D4-A09D-0050DA1AC1A8}', but this didn't change anything. The other occurrence is in the list _IDualModelItem_vtables_, where one item is: (( u'PickObject' , u'obj' , u'x' , u'y' , u'z' , u'obj_num' , u'entity_num' , u'tolerance' , u'PType' , ), 76, (76, (), [(16387, 3, None, None), (12, 1, None, None), (12, 1, None, None), (12, 1, None, None), (16387, 3, None, None), (16387, 3, None, None), (5, 49, '9.9999997473787516e-06', None), (3, 49, '0', None)], 1, 1, 4, 0, 332, (3, 0, None, None), 0) ) To tell the truth, I have no idea what _IDualModelItem_vtables_ does. I think I've examined these as close as I can without disecting the win32com.client module itself or finding some documentation (if there is documentation of any depth somewhere, I would love a link; I was unable to find any.) Can anyone provide any further insight? Mike From mikegraham at gmail.com Tue Jul 28 16:20:51 2009 From: mikegraham at gmail.com (Mike Graham) Date: Tue, 28 Jul 2009 09:20:51 -0500 Subject: [python-win32] By-reference COM method arguments not being treated as outputs In-Reply-To: <3f588a650907280700u748b8c7ch8e87d76b32e5ba49@mail.gmail.com> References: <3f588a650907271230s33f94ee9n20da071b713d4024@mail.gmail.com> <4A6E1A04.40007@ata-e.com> <3f588a650907280700u748b8c7ch8e87d76b32e5ba49@mail.gmail.com> Message-ID: <3f588a650907280720w19611a24ob14703f0ce343a7e@mail.gmail.com> I see with a bit more inspection you must have posted the and item from _prop_map_get_. My method isn't in there. I would not think it is supposed to be, as it is a method, not a member. I am unable to figure out what the equivalent operation for methods is in the call to _ApplyTypes_ or _oleobj_.InvokeTypes or wherever. Mike On Tue, Jul 28, 2009 at 9:00 AM, Mike Graham wrote: > Hi Greg, > > Thanks for your reply. I went back through the mailing list archives > to try to find someone else who had the same problem I did and found > your posts, but I couldn't quite understand your and Hammond's > solutions well enough to apply it. Perhaps you or someone else can > help me understand what's going on better. > > You present what looks like an item from a dict: > "feSelector": (10349, 2, (9, 0), (), "feSelector", None) > and explain that the None in the tuple should be replaced by the CLSID > of the class to which "feSelector" belongs. > > The method I posted as an example's name does not occur in any dicts. > It occurs in two places in the generated source. The first is the > method definition I posted, in which it is part of a class > _IDualModelItem(DispatchBaseClass) with the member > CLSID=IID('{976FAFC8-96FD-11D4-A09D-0050DA1AC1A8}'). I am not aware of > any particular python class from which this should be associated with. > > In my definition, I have a tuple that appears to be laid out the same > as yours, so I tried replacing None with > '{976FAFC8-96FD-11D4-A09D-0050DA1AC1A8}', but this didn't change > anything. > > The other occurrence is in the list _IDualModelItem_vtables_, where one item is: > ? ?(( u'PickObject' , u'obj' , u'x' , u'y' , u'z' , u'obj_num' , > u'entity_num' , u'tolerance' , u'PType' , ), > ? ? ? 76, > ? ? ? (76, (), > ? ? ? [(16387, 3, None, None), (12, 1, None, None), (12, 1, None, None), > ? ? ? ?(12, 1, None, None), (16387, 3, None, None), (16387, 3, None, None), > ? ? ? ?(5, 49, '9.9999997473787516e-06', None), (3, 49, '0', None)], > ? ? ? 1, > ? ? ? 1, > ? ? ? 4, > ? ? ? 0, > ? ? ? 332, > ? ? ? (3, 0, None, None), > ? ? ? 0) > ? ?) > > To tell the truth, I have no idea what _IDualModelItem_vtables_ does. > I think I've examined these as close as I can without disecting the > win32com.client module itself or finding some documentation (if there > is documentation of any depth somewhere, I would love a link; I was > unable to find any.) > > Can anyone provide any further insight? > > Mike From mikegraham at gmail.com Tue Jul 28 16:38:02 2009 From: mikegraham at gmail.com (Mike Graham) Date: Tue, 28 Jul 2009 09:38:02 -0500 Subject: [python-win32] By-reference COM method arguments not being treated as outputs In-Reply-To: <3f588a650907280700u748b8c7ch8e87d76b32e5ba49@mail.gmail.com> References: <3f588a650907271230s33f94ee9n20da071b713d4024@mail.gmail.com> <4A6E1A04.40007@ata-e.com> <3f588a650907280700u748b8c7ch8e87d76b32e5ba49@mail.gmail.com> Message-ID: <3f588a650907280738w533bbd85g231bb8a75bb40e4a@mail.gmail.com> I'm very sorry for all the noise to the list, but being so clueless about what is going on, I keep stumbling into what is going on. I am trying to access Dispatch("My Application").Document.Model.PickObject. _IDualModelItem has the CLSID '{976FAFC8-96FD-11D4-A09D-0050DA1AC1A8}' and provides the PickObject method. _IDualStressDoc has the CLSID '{684A3F63-0408-11D4-A05F-0050DA1AC1A8}', which is the ID for my TLB, and _IDualStressDoc._prop_map_get_ has the item "Model": (6, 2, (9, 0), (), "Model", '{976FAFC8-96FD-11D4-A09D-0050DA1AC1A8}'), _IDualModelItem has the coclass_clsid {976FAFC9-96FD-11D4-A09D-0050DA1AC1A8}, which is the CLSID of the class "Model". I believe this means I'm not suffering from the same issue Greg was, but I am not sure, in large part because it is difficult to navigate the way all these constructs fit together. Mike On Tue, Jul 28, 2009 at 9:00 AM, Mike Graham wrote: > Hi Greg, > > Thanks for your reply. I went back through the mailing list archives > to try to find someone else who had the same problem I did and found > your posts, but I couldn't quite understand your and Hammond's > solutions well enough to apply it. Perhaps you or someone else can > help me understand what's going on better. > > You present what looks like an item from a dict: > "feSelector": (10349, 2, (9, 0), (), "feSelector", None) > and explain that the None in the tuple should be replaced by the CLSID > of the class to which "feSelector" belongs. > > The method I posted as an example's name does not occur in any dicts. > It occurs in two places in the generated source. The first is the > method definition I posted, in which it is part of a class > _IDualModelItem(DispatchBaseClass) with the member > CLSID=IID('{976FAFC8-96FD-11D4-A09D-0050DA1AC1A8}'). I am not aware of > any particular python class from which this should be associated with. > > In my definition, I have a tuple that appears to be laid out the same > as yours, so I tried replacing None with > '{976FAFC8-96FD-11D4-A09D-0050DA1AC1A8}', but this didn't change > anything. > > The other occurrence is in the list _IDualModelItem_vtables_, where one item is: > ? ?(( u'PickObject' , u'obj' , u'x' , u'y' , u'z' , u'obj_num' , > u'entity_num' , u'tolerance' , u'PType' , ), > ? ? ? 76, > ? ? ? (76, (), > ? ? ? [(16387, 3, None, None), (12, 1, None, None), (12, 1, None, None), > ? ? ? ?(12, 1, None, None), (16387, 3, None, None), (16387, 3, None, None), > ? ? ? ?(5, 49, '9.9999997473787516e-06', None), (3, 49, '0', None)], > ? ? ? 1, > ? ? ? 1, > ? ? ? 4, > ? ? ? 0, > ? ? ? 332, > ? ? ? (3, 0, None, None), > ? ? ? 0) > ? ?) > > To tell the truth, I have no idea what _IDualModelItem_vtables_ does. > I think I've examined these as close as I can without disecting the > win32com.client module itself or finding some documentation (if there > is documentation of any depth somewhere, I would love a link; I was > unable to find any.) > > Can anyone provide any further insight? > > Mike > From reinier at heeres.eu Tue Jul 28 20:29:39 2009 From: reinier at heeres.eu (Reinier Heeres) Date: Tue, 28 Jul 2009 20:29:39 +0200 Subject: [python-win32] COM array problem Message-ID: Hi everybody, I have a problem with a function of a COM object that is supposed to return an array of data. The function prototype generated by win32com's EnsureDispatch is as follows: def GetFrame(self, frame=defaultNamedNotOptArg, FrameVariant=defaultNamedNotOptArg): """Get Frame Data""" return self._ApplyTypes_(10, 1, (24, 0), ((2, 1), (16396, 3)), u'GetFrame', None,frame , FrameVariant) which from my understanding means that the type which gives the problem is VT_R4 | VT_BSTR | VT_BYREF. (I've seen problems with byref return values before on the mailing list archives, but I don't know if they apply here). The error is slightly undescriptive (snipped a part): 454 def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args): 455 return self._get_good_object_( --> 456 self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), 457 user, resultCLSID) 458 com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147024809), None) I don't exactly understand where the problem is: is it before the call to the actual COM function while creating an empty object, in the COM call, or after the call casting the result? Any ideas on how to fix this would be welcome; I could try to make patches for win32com. BTW: I can get it to work with comtypes (but that gives problems on some other calls), so in principle it should be possible. Unfortunately I don't have access to the source of the COM object I'm using. I'm using pywin32-212 and python 2.5.1. Regards, -- Reinier Heeres Tel: +31 6 10852639 From mikegraham at gmail.com Tue Jul 28 23:30:25 2009 From: mikegraham at gmail.com (Mike Graham) Date: Tue, 28 Jul 2009 16:30:25 -0500 Subject: [python-win32] By-reference COM method arguments not being treated as outputs In-Reply-To: <3f588a650907280700u748b8c7ch8e87d76b32e5ba49@mail.gmail.com> References: <3f588a650907271230s33f94ee9n20da071b713d4024@mail.gmail.com> <4A6E1A04.40007@ata-e.com> <3f588a650907280700u748b8c7ch8e87d76b32e5ba49@mail.gmail.com> Message-ID: <3f588a650907281430v19917ee3wee20e36966e3ce8a@mail.gmail.com> Upon some further investigation, I have come to understand the method a bit better def PickObject(self, obj=defaultNamedNotOptArg, x=defaultNamedNotOptArg, y=defaultNamedNotOptArg, z=defaultNamedNotOptArg, obj_num=defaultNamedNotOptArg, entity_num=defaultNamedNotOptArg, tolerance=9.9999997473787516e-06, PType=0): """Retrieve an object ID and face or edge number by giving an object type and global coordinates""" return self._ApplyTypes_(76, 1, (24, 0), ( (16387, 3), (12, 1), (12, 1), (12, 1), (16387, 3), (16387, 3), (5, 49), (3, 49) ), u'PickObject', None, obj, x, y, z, obj_num, entity_num, tolerance, PType) The tuple of tuples in the _ApplyTypes_ call is of flags for each obj, x, y,...PType. For example, (type, input_or_output_flag) = (16387, 3) where 3 I believe indicates an input/output parameter. I can change these to 1 (for input) and 2 (for output for obj_num and entity_num), but it still does not work. I suspect there might have to be other changes in order (obj_num and entity_num shouldn't ==defaultNamedNotOptArg, for example, and I am not sure if they should be passed to _ApplyTypes_ at all). I think this is the basis of the problem, but I still cannot solve it. Nowhere else in my generated file can I find an example of this working right to follow. I am really hoping to get this working. Thanks, Mike On Tue, Jul 28, 2009 at 9:00 AM, Mike Graham wrote: > Hi Greg, > > Thanks for your reply. I went back through the mailing list archives > to try to find someone else who had the same problem I did and found > your posts, but I couldn't quite understand your and Hammond's > solutions well enough to apply it. Perhaps you or someone else can > help me understand what's going on better. > > You present what looks like an item from a dict: > "feSelector": (10349, 2, (9, 0), (), "feSelector", None) > and explain that the None in the tuple should be replaced by the CLSID > of the class to which "feSelector" belongs. > > The method I posted as an example's name does not occur in any dicts. > It occurs in two places in the generated source. The first is the > method definition I posted, in which it is part of a class > _IDualModelItem(DispatchBaseClass) with the member > CLSID=IID('{976FAFC8-96FD-11D4-A09D-0050DA1AC1A8}'). I am not aware of > any particular python class from which this should be associated with. > > In my definition, I have a tuple that appears to be laid out the same > as yours, so I tried replacing None with > '{976FAFC8-96FD-11D4-A09D-0050DA1AC1A8}', but this didn't change > anything. > > The other occurrence is in the list _IDualModelItem_vtables_, where one item is: > ? ?(( u'PickObject' , u'obj' , u'x' , u'y' , u'z' , u'obj_num' , > u'entity_num' , u'tolerance' , u'PType' , ), > ? ? ? 76, > ? ? ? (76, (), > ? ? ? [(16387, 3, None, None), (12, 1, None, None), (12, 1, None, None), > ? ? ? ?(12, 1, None, None), (16387, 3, None, None), (16387, 3, None, None), > ? ? ? ?(5, 49, '9.9999997473787516e-06', None), (3, 49, '0', None)], > ? ? ? 1, > ? ? ? 1, > ? ? ? 4, > ? ? ? 0, > ? ? ? 332, > ? ? ? (3, 0, None, None), > ? ? ? 0) > ? ?) > > To tell the truth, I have no idea what _IDualModelItem_vtables_ does. > I think I've examined these as close as I can without disecting the > win32com.client module itself or finding some documentation (if there > is documentation of any depth somewhere, I would love a link; I was > unable to find any.) > > Can anyone provide any further insight? > > Mike > From skippy.hammond at gmail.com Wed Jul 29 06:49:00 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 29 Jul 2009 14:49:00 +1000 Subject: [python-win32] COM array problem In-Reply-To: References: Message-ID: <4A6FD4BC.9020209@gmail.com> On 29/07/2009 4:29 AM, Reinier Heeres wrote: > Hi everybody, > > I have a problem with a function of a COM object that is supposed to > return an array of data. The function prototype generated by > win32com's EnsureDispatch is as follows: > > def GetFrame(self, frame=defaultNamedNotOptArg, > FrameVariant=defaultNamedNotOptArg): > """Get Frame Data""" > return self._ApplyTypes_(10, 1, (24, 0), ((2, 1), (16396, 3)), This is declaring the function has a return type of 24 (VT_VOID), and takes 2 params - one in param of type 2 (VT_I2) and the other a 'retval' param of 16396 == 0x400c == VT_BYREF | VT_VARIANT. > u'GetFrame', None,frame > , FrameVariant) > > which from my understanding means that the type which gives the > problem is VT_R4 | VT_BSTR | VT_BYREF. (I've seen problems with byref > return values before on the mailing list archives, but I don't know if > they apply here). > > The error is slightly undescriptive (snipped a part): > > 454 def _ApplyTypes_(self, dispid, wFlags, retType, > argTypes, user, resultCLSID, *args): > 455 return self._get_good_object_( > --> 456 self._oleobj_.InvokeTypes(dispid, 0, > wFlags, retType, argTypes, *args), > 457 user, resultCLSID) > 458 > > com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, > 0, -2147024809), None) > > I don't exactly understand where the problem is: is it before the call > to the actual COM function while creating an empty object, in the COM > call, or after the call casting the result? Any ideas on how to fix > this would be welcome; I could try to make patches for win32com. The problem is the COM object returning DISP_E_EXCEPTION with an scode value of -2147024809 - which in turn is E_INVALIDARG. > BTW: I can get it to work with comtypes (but that gives problems on > some other calls), so in principle it should be possible. > Unfortunately I don't have access to the source of the COM object I'm > using. I suspect pythoncom is passing the variants described above - but maybe the variant isn't initialized as expected or something. Do you know exactly how the variants passed by ctypes were laid out? Cheers, Mark From skippy.hammond at gmail.com Wed Jul 29 07:30:47 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 29 Jul 2009 15:30:47 +1000 Subject: [python-win32] By-reference COM method arguments not being treated as outputs In-Reply-To: <3f588a650907281430v19917ee3wee20e36966e3ce8a@mail.gmail.com> References: <3f588a650907271230s33f94ee9n20da071b713d4024@mail.gmail.com> <4A6E1A04.40007@ata-e.com> <3f588a650907280700u748b8c7ch8e87d76b32e5ba49@mail.gmail.com> <3f588a650907281430v19917ee3wee20e36966e3ce8a@mail.gmail.com> Message-ID: <4A6FDE87.9090602@gmail.com> On 29/07/2009 7:30 AM, Mike Graham wrote: > Upon some further investigation, I have come to understand the method > a bit better > > def PickObject(self, > obj=defaultNamedNotOptArg, > x=defaultNamedNotOptArg, > y=defaultNamedNotOptArg, > z=defaultNamedNotOptArg, > obj_num=defaultNamedNotOptArg, > entity_num=defaultNamedNotOptArg, > tolerance=9.9999997473787516e-06, > PType=0): > """Retrieve an object ID and face or edge number by giving an object > type and global coordinates""" > return self._ApplyTypes_(76, > 1, > (24, 0), > ( > (16387, 3), > (12, 1), > (12, 1), > (12, 1), > (16387, 3), > (16387, 3), > (5, 49), > (3, 49) > ), > u'PickObject', > None, > obj, x, y, z, obj_num, entity_num, tolerance, PType) > > > The tuple of tuples in the _ApplyTypes_ call is of flags for each obj, > x, y,...PType. For example, > (type, input_or_output_flag) = (16387, 3) > where 3 I believe indicates an input/output parameter. Actually, I made this mistake in the last message I sent too. These are the "param flags", and they have the values: OAIdl.Idl:const USHORT PARAMFLAG_NONE = 0x00; OAIdl.Idl:const USHORT PARAMFLAG_FIN = 0x01; OAIdl.Idl:const USHORT PARAMFLAG_FOUT = 0x02; OAIdl.Idl:const USHORT PARAMFLAG_FLCID = 0x04; OAIdl.Idl:const USHORT PARAMFLAG_FRETVAL = 0x08; OAIdl.Idl:const USHORT PARAMFLAG_FOPT = 0x10; OAIdl.Idl:const USHORT PARAMFLAG_FHASDEFAULT = 0x20; OAIdl.Idl:const USHORT PARAMFLAG_FHASCUSTDATA = 0x40; So we appear to have 3 params defined as "in out" and, as hex(49)=='0x31', we have 2 "optional" params at the end. > I can change > these to 1 (for input) and 2 (for output for obj_num and entity_num), > but it still does not work. I suspect there might have to be other > changes in order (obj_num and entity_num shouldn't > ==defaultNamedNotOptArg, for example, and I am not sure if they should > be passed to _ApplyTypes_ at all). > > I think this is the basis of the problem, but I still cannot solve it. > Nowhere else in my generated file can I find an example of this > working right to follow. I am really hoping to get this working. I don't think you've ever pasted the exception you get. From the signature above, it appears you need to pass 6 params, and can expect 3 back. Cheers, Mark > > Thanks, > Mike > > On Tue, Jul 28, 2009 at 9:00 AM, Mike Graham wrote: >> Hi Greg, >> >> Thanks for your reply. I went back through the mailing list archives >> to try to find someone else who had the same problem I did and found >> your posts, but I couldn't quite understand your and Hammond's >> solutions well enough to apply it. Perhaps you or someone else can >> help me understand what's going on better. >> >> You present what looks like an item from a dict: >> "feSelector": (10349, 2, (9, 0), (), "feSelector", None) >> and explain that the None in the tuple should be replaced by the CLSID >> of the class to which "feSelector" belongs. >> >> The method I posted as an example's name does not occur in any dicts. >> It occurs in two places in the generated source. The first is the >> method definition I posted, in which it is part of a class >> _IDualModelItem(DispatchBaseClass) with the member >> CLSID=IID('{976FAFC8-96FD-11D4-A09D-0050DA1AC1A8}'). I am not aware of >> any particular python class from which this should be associated with. >> >> In my definition, I have a tuple that appears to be laid out the same >> as yours, so I tried replacing None with >> '{976FAFC8-96FD-11D4-A09D-0050DA1AC1A8}', but this didn't change >> anything. >> >> The other occurrence is in the list _IDualModelItem_vtables_, where one item is: >> (( u'PickObject' , u'obj' , u'x' , u'y' , u'z' , u'obj_num' , >> u'entity_num' , u'tolerance' , u'PType' , ), >> 76, >> (76, (), >> [(16387, 3, None, None), (12, 1, None, None), (12, 1, None, None), >> (12, 1, None, None), (16387, 3, None, None), (16387, 3, None, None), >> (5, 49, '9.9999997473787516e-06', None), (3, 49, '0', None)], >> 1, >> 1, >> 4, >> 0, >> 332, >> (3, 0, None, None), >> 0) >> ) >> >> To tell the truth, I have no idea what _IDualModelItem_vtables_ does. >> I think I've examined these as close as I can without disecting the >> win32com.client module itself or finding some documentation (if there >> is documentation of any depth somewhere, I would love a link; I was >> unable to find any.) >> >> Can anyone provide any further insight? >> >> Mike >> > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From mail at timgolden.me.uk Wed Jul 29 10:23:51 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 29 Jul 2009 09:23:51 +0100 Subject: [python-win32] Copying a MS Access Table In-Reply-To: References: Message-ID: <4A700717.9020006@timgolden.me.uk> [copying back to the list] > Not sure how to reply to the thread, since I thought that if I reply to > "python-win32 at python.org" then it would start a new thread? Replying to python-win32 at python.org is the right thing to do; the mailing list software should recognise all the clues it needs to continue the thread. sebastian.venus at uk.bnpparibas.com wrote: > Hi Tim, > > I tried this: >>>> a = win32com.client.Dispatch("access.application") >>>> connStr = 'Driver={PostgreSQL > Unicode};Server=%s;Database=%s;Uid=%s;Pwd=%s;ConnSettings="set TimeZone to > -8; set search_path to pid,public;"' Well that surprised me: you're using Access as a frontend to PostgreSQL? >>>> a.OpenCurrentDatabase(r'C:/TEMP/db1.mdb') >>>> a.DoCmd.CopyObject(connStr,'MyTable2',0,'MyTable1') > > but it threw an exception that I couldn't interpret. Can you please help? This is obviously tricky with two different databases in the equation, one of them PostgreSQL, but what will be most helpful is for you to produce an easily reproducible sample which someone else can run, plus the traceback you get. Going through this exercise may even cause you to track down the problem yourself. In particular, try to eliminate external dependencies: try to do the copy table thing between two Access databases, or within the same one (if that's possible; I haven't used Access in earnest for a while now). TJG From iman.darabi at gmail.com Wed Jul 29 10:52:06 2009 From: iman.darabi at gmail.com (Iman Darabi) Date: Wed, 29 Jul 2009 11:52:06 +0300 Subject: [python-win32] ImportError: No module named win32file Message-ID: <87f58ae10907290152q4bc28641nd8cbc5cb6a8b2d54@mail.gmail.com> hi . i'm using pyserial 2.4 to work with some device via serial port . in linux have no prob with that ( because no pywin32 is needed ) but because i should write my program portable on both win and linux so tried to test it in win ... . installed python2.6 and pywin32-214 . but when i try to run my app i get this error : ... "C:\Python26\lib\site-packages\serial\serialwin32.py", line 9, in import win32file ImportError : No module named win32file i tried to search win32file in pywin32 but couldn't find it ! i just copied content of build directory to site-packages ... does win32file renamed/moved to another module ? BTW : i'm not so familiar with windows package installations thanks for your attentions ... -- ????? ??? ?????? ????? ??? ?????? ???? ??? ??? ???? ????? http://twitter.com/imandarabi http://iman.darabi.googlepages.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From gerdusvanzyl at gmail.com Wed Jul 29 14:16:10 2009 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Wed, 29 Jul 2009 14:16:10 +0200 Subject: [python-win32] Copying a MS Access Table In-Reply-To: <4A700717.9020006@timgolden.me.uk> References: <4A700717.9020006@timgolden.me.uk> Message-ID: <91882ea90907290516i70d4d5e6r193793f603179be@mail.gmail.com> Are you trying to copy a table from an access database to a postgres database? Because that's the impression I get, in which case do you need to do it once or do you need to do it regularly? In both cases Python might not be an optimal choice. You might have more luck using TransferDatabase and ODBC, and first prototype in VBA then transfer to Python. Also if you could explain what you are trying to do, we might be better able to help. ~Gerdus On Wed, Jul 29, 2009 at 10:23 AM, Tim Golden wrote: > [copying back to the list] > >> Not sure how to reply to the thread, since I thought that if I reply to >> "python-win32 at python.org" then it would start a new thread? > > Replying to python-win32 at python.org is the right thing to > do; the mailing list software should recognise all the > clues it needs to continue the thread. > > > sebastian.venus at uk.bnpparibas.com wrote: >> >> Hi Tim, >> >> I tried this: >>>>> >>>>> a = win32com.client.Dispatch("access.application") >>>>> connStr = 'Driver={PostgreSQL >> >> Unicode};Server=%s;Database=%s;Uid=%s;Pwd=%s;ConnSettings="set TimeZone to >> -8; set search_path to pid,public;"' > > Well that surprised me: you're using Access as a frontend > to PostgreSQL? >>>>> >>>>> a.OpenCurrentDatabase(r'C:/TEMP/db1.mdb') >>>>> a.DoCmd.CopyObject(connStr,'MyTable2',0,'MyTable1') >> >> but it threw an exception that I couldn't interpret. Can you please help? > > This is obviously tricky with two different databases in the equation, one > of them PostgreSQL, but what will be > most helpful is for you to produce an easily reproducible > sample which someone else can run, plus the traceback you > get. Going through this exercise may even cause you to > track down the problem yourself. In particular, try to > eliminate external dependencies: try to do the copy table > thing between two Access databases, or within the same > one (if that's possible; I haven't used Access in earnest > for a while now). > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From efotinis at yahoo.com Wed Jul 29 14:24:31 2009 From: efotinis at yahoo.com (Elias Fotinis) Date: Wed, 29 Jul 2009 15:24:31 +0300 Subject: [python-win32] ImportError: No module named win32file In-Reply-To: <87f58ae10907290152q4bc28641nd8cbc5cb6a8b2d54@mail.gmail.com> References: <87f58ae10907290152q4bc28641nd8cbc5cb6a8b2d54@mail.gmail.com> Message-ID: First, check if the file ("\Lib\site-packages\win32\win32file.pyd") really exists. Then check the Python module search path. Put a "print sys.path" before the "import win32file" and check whether it contains the "...site-packages\win32" dir. Either pywin32 didn't install properly or some module messes with your sys.path. ----- Original Message ----- From: Iman Darabi To: python-win32 at python.org Sent: Wednesday, July 29, 2009 11:52 Subject: [python-win32] ImportError: No module named win32file > i'm using pyserial 2.4 to work with some device via serial port . in linux > have no prob with that ( because no pywin32 is needed ) but because i > should write my program portable on both win and linux so tried to test it > in win ... . installed python2.6 and pywin32-214 > . but when i try to run my app i get this error : > ... "C:\Python26\lib\site-packages\serial\serialwin32.py", line 9, in > > import win32file > ImportError : No module named win32file > > i tried to search win32file in pywin32 but couldn't find it ! > i just copied content of build directory to site-packages ... > does win32file renamed/moved to another module ? > BTW : i'm not so familiar with windows package installations From mikegraham at gmail.com Wed Jul 29 15:51:24 2009 From: mikegraham at gmail.com (Mike Graham) Date: Wed, 29 Jul 2009 08:51:24 -0500 Subject: [python-win32] By-reference COM method arguments not being treated as outputs In-Reply-To: <4A6FDE87.9090602@gmail.com> References: <3f588a650907271230s33f94ee9n20da071b713d4024@mail.gmail.com> <4A6E1A04.40007@ata-e.com> <3f588a650907280700u748b8c7ch8e87d76b32e5ba49@mail.gmail.com> <3f588a650907281430v19917ee3wee20e36966e3ce8a@mail.gmail.com> <4A6FDE87.9090602@gmail.com> Message-ID: <3f588a650907290651j69e076a6o7b16391c150811ae@mail.gmail.com> On Wed, Jul 29, 2009 at 12:30 AM, Mark Hammond wrote: > On 29/07/2009 7:30 AM, Mike Graham wrote: >> >> Upon some further investigation, I have come to understand the method >> a bit better >> >> def PickObject(self, >> obj=defaultNamedNotOptArg, >> x=defaultNamedNotOptArg, >> y=defaultNamedNotOptArg, >> z=defaultNamedNotOptArg, >> obj_num=defaultNamedNotOptArg, >> entity_num=defaultNamedNotOptArg, >> tolerance=9.9999997473787516e-06, >> PType=0): >> """Retrieve an object ID and face or edge number by giving an >> object >> type and global coordinates""" >> return self._ApplyTypes_(76, >> 1, >> (24, 0), >> ( >> (16387, 3), >> (12, 1), >> (12, 1), >> (12, 1), >> (16387, 3), >> (16387, 3), >> (5, 49), >> (3, 49) >> ), >> u'PickObject', >> None, >> obj, x, y, z, obj_num, entity_num, tolerance, >> PType) >> >> >> The tuple of tuples in the _ApplyTypes_ call is of flags for each obj, >> x, y,...PType. For example, >> (type, input_or_output_flag) = (16387, 3) >> where 3 I believe indicates an input/output parameter. > > Actually, I made this mistake in the last message I sent too. These are the > "param flags", and they have the values: > > OAIdl.Idl:const USHORT PARAMFLAG_NONE = 0x00; > OAIdl.Idl:const USHORT PARAMFLAG_FIN = 0x01; > OAIdl.Idl:const USHORT PARAMFLAG_FOUT = 0x02; > OAIdl.Idl:const USHORT PARAMFLAG_FLCID = 0x04; > OAIdl.Idl:const USHORT PARAMFLAG_FRETVAL = 0x08; > OAIdl.Idl:const USHORT PARAMFLAG_FOPT = 0x10; > OAIdl.Idl:const USHORT PARAMFLAG_FHASDEFAULT = 0x20; > OAIdl.Idl:const USHORT PARAMFLAG_FHASCUSTDATA = 0x40; > So we appear to have 3 params defined as "in out" and, as hex(49)=='0x31', > we have 2 "optional" params at the end. Right, I now understand this is what those numbers mean. This isn't consistent with what I want the function to do, and more importantly isn't working. >> I can change >> these to 1 (for input) and 2 (for output for obj_num and entity_num), >> but it still does not work. I suspect there might have to be other >> changes in order (obj_num and entity_num shouldn't >> ==defaultNamedNotOptArg, for example, and I am not sure if they should >> be passed to _ApplyTypes_ at all). >> >> I think this is the basis of the problem, but I still cannot solve it. >> Nowhere else in my generated file can I find an example of this >> working right to follow. I am really hoping to get this working. > > I don't think you've ever pasted the exception you get. From the signature > above, it appears you need to pass 6 params, and can expect 3 back. > > Cheers, > > Mark Sorry about that. It doesn't provide much to go on (I don't think): model.PickObject(5, 0.5, 0, 0, 0, 0) Traceback (most recent call last): File "", line 1, in model.PickObject(opSystem, 0, 0, 0, 0, 0) File "C:\Python26\lib\site-packages\win32com\gen_py\684A3F60-0408-11D4-A05F-0050DA1AC1A8x0x2x0.py", line 6985, in PickObject , tolerance, PType) File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 456, in _ApplyTypes_ self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147467259), None) The 5, 0.5, 0, 0 make sense. The last two zeros don't because I don't know them ahead of time. (The purpose of the function is to retrieve them.) If I omit the parameters that don't mean anything to me on input, I get com_error: (-2147352561, 'Parameter not optional.', None, None). Regards, Mike From mdriscoll at co.marshall.ia.us Wed Jul 29 16:30:00 2009 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Wed, 29 Jul 2009 09:30:00 -0500 Subject: [python-win32] Copying a MS Access Table In-Reply-To: <4A700717.9020006@timgolden.me.uk> References: <4A700717.9020006@timgolden.me.uk> Message-ID: <4A705CE8.2000006@co.marshall.ia.us> Tim Golden wrote: >
[copying > back to the list] > >> Not sure how to reply to the thread, since I thought that if I reply >> to "python-win32 at python.org" then it would start a new thread? > > Replying to python-win32 at python.org is the right thing to > do; the mailing list software should recognise all the > clues it needs to continue the thread. > > > sebastian.venus at uk.bnpparibas.com wrote: >> Hi Tim, >> >> I tried this: >>>>> a = win32com.client.Dispatch("access.application") >>>>> connStr = 'Driver={PostgreSQL >> Unicode};Server=%s;Database=%s;Uid=%s;Pwd=%s;ConnSettings="set >> TimeZone to -8; set search_path to pid,public;"' > > Well that surprised me: you're using Access as a frontend > to PostgreSQL? >>>>> a.OpenCurrentDatabase(r'C:/TEMP/db1.mdb') >>>>> a.DoCmd.CopyObject(connStr,'MyTable2',0,'MyTable1') >> >> but it threw an exception that I couldn't interpret. Can you please >> help? > > This is obviously tricky with two different databases in the equation, > one of them PostgreSQL, but what will be > most helpful is for you to produce an easily reproducible > sample which someone else can run, plus the traceback you > get. Going through this exercise may even cause you to > track down the problem yourself. In particular, try to > eliminate external dependencies: try to do the copy table > thing between two Access databases, or within the same > one (if that's possible; I haven't used Access in earnest > for a while now). > > TJG > > This may be a stupid idea, but I've used SqlAlchemy to get information out of Access before. Since SqlAlchemy is database-agnostic, you should be able to grab the info from Access, connect to another database with a pre-created matched db schema and just tell SqlAlchemy to put the data into it. For the most part, it can translate db differences such that this will work without any (or few) issues. Note that SqlAlchemy's support of Access is experimental. See the following thread: http://www.mail-archive.com/sqlalchemy at googlegroups.com/msg06112.html - Mike Mike From vernondcole at gmail.com Wed Jul 29 16:35:44 2009 From: vernondcole at gmail.com (Vernon Cole) Date: Wed, 29 Jul 2009 08:35:44 -0600 Subject: [python-win32] Copying a MS Access Table In-Reply-To: <91882ea90907290516i70d4d5e6r193793f603179be@mail.gmail.com> References: <4A700717.9020006@timgolden.me.uk> <91882ea90907290516i70d4d5e6r193793f603179be@mail.gmail.com> Message-ID: Sebastian: You have what looks (to a non-Postgres user) like a proper ADO connection string for PostgreSQL. Open the Postgres database using adodbapi. I have already done all of the tricky COM stuff for you. You can also open the ACCESS database using adodbapi. There is an example in C:\python{your version number here}\Lib\site-packages\adodbapi\tests\db_print.py . Given that your databases are so completly different, you will most likely need to copy the data field-by-field. I think you will find no pre-packaged move-this-whole-table shortcut for this job. If the Postgres will not work for you, please let me know. I am planning to add Postgres tests and examples to the adodbapi test suite, and have set up a test server, but have not made the time to get further. We could work together on Postgres support. By the way, I disagree with Gerdus. I personally find Python much easier to use than VBA for prototyping and quickie jobs. -- Vernon Cole On Wed, Jul 29, 2009 at 6:16 AM, Gerdus van Zyl wrote: > Are you trying to copy a table from an access database to a postgres > database? Because that's the impression I get, in which case do you > need to do it once or do you need to do it regularly? In both cases > Python might not be an optimal choice. > You might have more luck using TransferDatabase and ODBC, and first > prototype in VBA then transfer to Python. Also if you could explain > what you are trying to do, we might be better able to help. > > ~Gerdus > > On Wed, Jul 29, 2009 at 10:23 AM, Tim Golden wrote: > > [copying back to the list] > > > >> Not sure how to reply to the thread, since I thought that if I reply to > >> "python-win32 at python.org" then it would start a new thread? > > > > Replying to python-win32 at python.org is the right thing to > > do; the mailing list software should recognise all the > > clues it needs to continue the thread. > > > > > > sebastian.venus at uk.bnpparibas.com wrote: > >> > >> Hi Tim, > >> > >> I tried this: > >>>>> > >>>>> a = win32com.client.Dispatch("access.application") > >>>>> connStr = 'Driver={PostgreSQL > >> > >> Unicode};Server=%s;Database=%s;Uid=%s;Pwd=%s;ConnSettings="set TimeZone > to > >> -8; set search_path to pid,public;"' > > > > Well that surprised me: you're using Access as a frontend > > to PostgreSQL? > >>>>> > >>>>> a.OpenCurrentDatabase(r'C:/TEMP/db1.mdb') > >>>>> a.DoCmd.CopyObject(connStr,'MyTable2',0,'MyTable1') > >> > >> but it threw an exception that I couldn't interpret. Can you please > help? > > > > This is obviously tricky with two different databases in the equation, > one > > of them PostgreSQL, but what will be > > most helpful is for you to produce an easily reproducible > > sample which someone else can run, plus the traceback you > > get. Going through this exercise may even cause you to > > track down the problem yourself. In particular, try to > > eliminate external dependencies: try to do the copy table > > thing between two Access databases, or within the same > > one (if that's possible; I haven't used Access in earnest > > for a while now). > > > > TJG > > _______________________________________________ > > python-win32 mailing list > > python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sebastian.venus at uk.bnpparibas.com Wed Jul 29 16:23:01 2009 From: sebastian.venus at uk.bnpparibas.com (sebastian.venus at uk.bnpparibas.com) Date: Wed, 29 Jul 2009 15:23:01 +0100 Subject: [python-win32] Copying a MS Access Table In-Reply-To: <4A700717.9020006@timgolden.me.uk> Message-ID: Thanks. I solved this now. The first argument in CopyObject should simply be the file path to the database being accessed. Internet mail at timgolden.me.uk 29/07/2009 09:23 To Sebastian VENUS, python-win32 at python.org cc Subject Re: [python-win32] Copying a MS Access Table [copying back to the list] > Not sure how to reply to the thread, since I thought that if I reply to > "python-win32 at python.org" then it would start a new thread? Replying to python-win32 at python.org is the right thing to do; the mailing list software should recognise all the clues it needs to continue the thread. sebastian.venus at uk.bnpparibas.com wrote: > Hi Tim, > > I tried this: >>>> a = win32com.client.Dispatch("access.application") >>>> connStr = 'Driver={PostgreSQL > Unicode};Server=%s;Database=%s;Uid=%s;Pwd=%s;ConnSettings="set TimeZone to > -8; set search_path to pid,public;"' Well that surprised me: you're using Access as a frontend to PostgreSQL? >>>> a.OpenCurrentDatabase(r'C:/TEMP/db1.mdb') >>>> a.DoCmd.CopyObject(connStr,'MyTable2',0,'MyTable1') > > but it threw an exception that I couldn't interpret. Can you please help? This is obviously tricky with two different databases in the equation, one of them PostgreSQL, but what will be most helpful is for you to produce an easily reproducible sample which someone else can run, plus the traceback you get. Going through this exercise may even cause you to track down the problem yourself. In particular, try to eliminate external dependencies: try to do the copy table thing between two Access databases, or within the same one (if that's possible; I haven't used Access in earnest for a while now). TJG -------- This communication is confidential, may be privileged and is meant only for the intended recipient. If you are not the intended recipient, please notify the sender by reply and delete the message from your system. Any unauthorised dissemination, distribution or copying hereof is prohibited. BNP Paribas Trust Corporation UK Limited, BNP Paribas UK Limited, BNP Paribas Commodity Futures Limited, BNP Paribas Asset Management UK Limited and Investment Fund Services Limited are authorised and regulated by the Financial Services Authority. BNP Paribas London Branch and BNP Paribas Wealth Management London Branch are authorised by the CECEI and supervised by the Commission Bancaire. BNP Paribas London Branch is authorised and subject to limited regulation by the Financial Services Authority. Details about the extent of our authorisation and regulation by the Financial Services Authority are available from us on request. BNP Paribas is also a member of the London Stock Exchange. BNP Paribas Wealth Management London Branch is subject to limited regulation by the Financial Services Authority. Details about the extent of our authorisation and regulation by the Financial Services Authority are available from us on request. BNP Paribas Securities Services London Branch is authorised by the CECEI and supervised by the AMF, and subject to limited regulation by the Financial Services Authority. Details on the extent of our regulation by the Financial Services Authority are available from us on request. BNP Paribas Securities Services is also a member of the London Stock Exchange. BNP Paribas Trust Corporation UK Limited is registered in England and Wales (registered no. 4042668) at registered office 55 Moorgate, London EC2R 6PA. BNP Paribas UK Limited is registered in England and Wales (registered no. 1488108) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Commodity Futures Limited is registered in England and Wales (registered no. 2391477) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Asset Management UK Limited is registered in England and Wales (registered no. 2474627) at registered office 10 Harewood Avenue, London NW1 6AA. Investment Fund Services Limited is registered in England and Wales (registered no. 6110770) at registered office 55 Moorgate, London EC2R 6PA. BNP Paribas London Branch is registered in England and Wales (registered no. FC13447) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Wealth Management London Branch is registered in England and Wales (registered no. FC023926) at registered office 10 Harewood Avenue, London NW1 6AA. BNP Paribas Securities Services London Branch is registered in England and Wales (registered no. BR006393) at registered office 55 Moorgate, London, EC2R 6PA. -------------- next part -------------- An HTML attachment was scrubbed... URL: From pwestphal at mcn.net Wed Jul 29 19:14:34 2009 From: pwestphal at mcn.net (Pam Westphal) Date: Wed, 29 Jul 2009 13:14:34 -0400 (EDT) Subject: [python-win32] calling python as process from vb.net Message-ID: <18808478.1248887674707.JavaMail.root@mswamui-andean.atl.sa.earthlink.net> I have a great python script that does quite a bit of statistical smoothing after reading data from a SQL table and then writes the results to a table. I don't really want to convert it into C. Currently I call the python script as a process from vb.net. About 1/2 of the time Python stops running with a "pythonw.exe - Application error" "The instruction at 'xxx' referenced memory at 'xxx'. The memory could nto be 'read'" error. When I run the same python script from the command line it is fine. If I run it from vb.net in debug mode and step through, it is fine too. Should I make the python script into an executable? Should I make the Python script into a com (I tried this but vb.net wouldn't accept it as a valid com). **** starting the process *********** dim p as new process p.StartInfo.FileName = "pythonw.exe" p.StartInfo.WorkingDirectory = "C:\Python25\work\" p.StartInfo.Arguments = "smooth_data_kiosk2.py " & datafields.Trim p.StartInfo.RedirectStandardOutput = True p.StartInfo.UseShellExecute = False p.StartInfo.CreateNoWindow = True p.Start() Thank you for any ideas/help. Pam From skippy.hammond at gmail.com Thu Jul 30 08:53:00 2009 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 30 Jul 2009 16:53:00 +1000 Subject: [python-win32] By-reference COM method arguments not being treated as outputs In-Reply-To: <3f588a650907290651j69e076a6o7b16391c150811ae@mail.gmail.com> References: <3f588a650907271230s33f94ee9n20da071b713d4024@mail.gmail.com> <4A6E1A04.40007@ata-e.com> <3f588a650907280700u748b8c7ch8e87d76b32e5ba49@mail.gmail.com> <3f588a650907281430v19917ee3wee20e36966e3ce8a@mail.gmail.com> <4A6FDE87.9090602@gmail.com> <3f588a650907290651j69e076a6o7b16391c150811ae@mail.gmail.com> Message-ID: <4A71434C.50602@gmail.com> On 29/07/2009 11:51 PM, Mike Graham wrote: > If I omit the parameters that don't mean anything to me on input, I > get com_error: (-2147352561, 'Parameter not optional.', None, None). I'm afraid about my last idea is to pass pythoncom.ArgNotFound (as mentioned at the top of the generated files) for those args... Cheers, Mark From iman.darabi at gmail.com Thu Jul 30 09:11:46 2009 From: iman.darabi at gmail.com (Iman Darabi) Date: Thu, 30 Jul 2009 10:11:46 +0300 Subject: [python-win32] ImportError: No module named win32file In-Reply-To: References: <87f58ae10907290152q4bc28641nd8cbc5cb6a8b2d54@mail.gmail.com> Message-ID: <87f58ae10907300011m78dae502t466f49ee4295cf3f@mail.gmail.com> thanks elias . my problem solved . i installed pywin32 again but this time got the exact version for python2.6 ( pywin32-214.win32-py2.6.exe) now every thing is ok . On Wed, Jul 29, 2009 at 3:24 PM, Elias Fotinis wrote: > First, check if the file > ("\Lib\site-packages\win32\win32file.pyd") really exists. Then > check the Python module search path. Put a "print sys.path" before the > "import win32file" and check whether it contains the > "...site-packages\win32" dir. > > Either pywin32 didn't install properly or some module messes with your > sys.path. > > > > ----- Original Message ----- From: Iman Darabi > To: python-win32 at python.org > Sent: Wednesday, July 29, 2009 11:52 > Subject: [python-win32] ImportError: No module named win32file > > > i'm using pyserial 2.4 to work with some device via serial port . in linux >> have no prob with that ( because no pywin32 is needed ) but because i should >> write my program portable on both win and linux so tried to test it in win >> ... . installed python2.6 and pywin32-214 >> . but when i try to run my app i get this error : >> ... "C:\Python26\lib\site-packages\serial\serialwin32.py", line 9, in >> >> import win32file >> ImportError : No module named win32file >> >> i tried to search win32file in pywin32 but couldn't find it ! >> i just copied content of build directory to site-packages ... >> does win32file renamed/moved to another module ? >> BTW : i'm not so familiar with windows package installations >> > > > -- ????? ??? ?????? ????? ??? ?????? ???? ??? ??? ???? ????? http://twitter.com/imandarabi http://iman.darabi.googlepages.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From niki at vintech.bg Thu Jul 30 10:08:44 2009 From: niki at vintech.bg (niki) Date: Thu, 30 Jul 2009 11:08:44 +0300 Subject: [python-win32] calling python as process from vb.net In-Reply-To: <18808478.1248887674707.JavaMail.root@mswamui-andean.atl.sa.earthlink.net> References: <18808478.1248887674707.JavaMail.root@mswamui-andean.atl.sa.earthlink.net> Message-ID: <4A71550C.2020109@vintech.bg> Pam Westphal wrote: > **** starting the process *********** > dim p as new process > p.StartInfo.FileName = "pythonw.exe" > p.StartInfo.WorkingDirectory = "C:\Python25\work\" > p.StartInfo.Arguments = "smooth_data_kiosk2.py " & datafields.Trim > p.StartInfo.RedirectStandardOutput = True > p.StartInfo.UseShellExecute = False > p.StartInfo.CreateNoWindow = True > p.Start() You can try UseShellExecute = True or start cmd.exe /c python.exe ... Niki From reinier at heeres.eu Thu Jul 30 15:13:49 2009 From: reinier at heeres.eu (Reinier Heeres) Date: Thu, 30 Jul 2009 15:13:49 +0200 Subject: [python-win32] COM array problem In-Reply-To: <4A6FD4BC.9020209@gmail.com> References: <4A6FD4BC.9020209@gmail.com> Message-ID: Hi Mark, Thanks for your quick reply. On Wed, Jul 29, 2009 at 6:49 AM, Mark Hammond wrote: > On 29/07/2009 4:29 AM, Reinier Heeres wrote: >> >> Hi everybody, >> >> I have a problem with a function of a COM object that is supposed to >> return an array of data. The function prototype generated by >> win32com's EnsureDispatch is as follows: >> >> def GetFrame(self, frame=defaultNamedNotOptArg, >> FrameVariant=defaultNamedNotOptArg): >> ? ? """Get Frame Data""" >> ? ? return self._ApplyTypes_(10, 1, (24, 0), ((2, 1), (16396, 3)), > > This is declaring the function has a return type of 24 (VT_VOID), and takes > 2 params - one in param of type 2 (VT_I2) and the other a 'retval' param of > 16396 == 0x400c == VT_BYREF | VT_VARIANT. > >> u'GetFrame', None,frame >> ? ? ? ? , FrameVariant) >> >> which from my understanding means that the type which gives the >> problem is VT_R4 | VT_BSTR | VT_BYREF. (I've seen problems with byref >> return values before on the mailing list archives, but I don't know if >> they apply here). >> >> The error is slightly undescriptive (snipped a part): >> >> ? ? 454 ? ? ? ? def _ApplyTypes_(self, dispid, wFlags, retType, >> argTypes, user, resultCLSID, *args): >> ? ? 455 ? ? ? ? ? ? ? ? return self._get_good_object_( >> --> ?456 ? ? ? ? ? ? ? ? ? ? ? ? self._oleobj_.InvokeTypes(dispid, 0, >> wFlags, retType, argTypes, *args), >> ? ? 457 ? ? ? ? ? ? ? ? ? ? ? ? user, resultCLSID) >> ? ? 458 >> >> com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, >> 0, -2147024809), None) >> >> I don't exactly understand where the problem is: is it before the call >> to the actual COM function while creating an empty object, in the COM >> call, or after the call casting the result? Any ideas on how to fix >> this would be welcome; I could try to make patches for win32com. > > The problem is the COM object returning DISP_E_EXCEPTION with an scode value > of -2147024809 - which in turn is E_INVALIDARG. > >> BTW: I can get it to work with comtypes (but that gives problems on >> some other calls), so in principle it should be possible. >> Unfortunately I don't have access to the source of the COM object I'm >> using. > > I suspect pythoncom is passing the variants described above - but maybe the > variant isn't initialized as expected or something. ?Do you know exactly how > the variants passed by ctypes were laid out? comtypes generates the following python code to create the function: COMMETHOD([dispid(10), helpstring(u'Get Frame Data')], HRESULT, 'GetFrame', ( ['in'], c_short, 'frame' ), ( ['in', 'out'], POINTER(VARIANT), 'FrameVariant' )), I'm not sure how exactly it calls the method though (the code is not easy to debug if you're unfamiliar with!). In the win32com generated python code I tried all 3 candidates I could give: pythoncom.Missing, .Empty and .ArgNotFound to initialize the empty parameters. Does this help or should I try to dig deeper? > Cheers, > Mark Regards, -- Reinier Heeres Tel: +31 6 10852639 From mikegraham at gmail.com Thu Jul 30 17:08:54 2009 From: mikegraham at gmail.com (Mike Graham) Date: Thu, 30 Jul 2009 10:08:54 -0500 Subject: [python-win32] By-reference COM method arguments not being treated as outputs In-Reply-To: <4A71434C.50602@gmail.com> References: <3f588a650907271230s33f94ee9n20da071b713d4024@mail.gmail.com> <4A6E1A04.40007@ata-e.com> <3f588a650907280700u748b8c7ch8e87d76b32e5ba49@mail.gmail.com> <3f588a650907281430v19917ee3wee20e36966e3ce8a@mail.gmail.com> <4A6FDE87.9090602@gmail.com> <3f588a650907290651j69e076a6o7b16391c150811ae@mail.gmail.com> <4A71434C.50602@gmail.com> Message-ID: <3f588a650907300808n1afa4e87q7b699fe768b3a008@mail.gmail.com> On Thu, Jul 30, 2009 at 1:53 AM, Mark Hammond wrote: > On 29/07/2009 11:51 PM, Mike Graham wrote: > >> If I omit the parameters that don't mean anything to me on input, I >> get com_error: (-2147352561, 'Parameter not optional.', None, None). > > I'm afraid about my last idea is to pass pythoncom.ArgNotFound (as mentioned > at the top of the generated files) for those args... > > Cheers, > > Mark > Ah, I saw that note in the file and had tried that to no avail, I should have noted. model.PickObject(5, 0.5, 0, 0, pythoncom.ArgNotFound, pythoncom.ArgNotFound) Traceback (most recent call last): File "", line 1, in model.PickObject(5, 0.5, 0, 0, pythoncom.ArgNotFound, pythoncom.ArgNotFound) File "C:\Python26\lib\site-packages\win32com\gen_py\684A3F60-0408-11D4-A05F-0050DA1AC1A8x0x2x0.py", line 6985, in PickObject , tolerance, PType) File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 456, in _ApplyTypes_ self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), TypeError: int() argument must be a string or a number, not 'ArgNotFound' and also model.PickObject(5, 0.5, 0, 0, pythoncom.Missing, pythoncom.Missing) Traceback (most recent call last): File "", line 1, in model.PickObject(5, 0.5, 0, 0, pythoncom.Missing, pythoncom.Missing) File "C:\Python26\lib\site-packages\win32com\gen_py\684A3F60-0408-11D4-A05F-0050DA1AC1A8x0x2x0.py", line 6985, in PickObject , tolerance, PType) File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 456, in _ApplyTypes_ self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147467259), None) Thanks for the help and all your work on these modules. I managed a workaround, but I would still love to know how to get this going. Mike From personrp at UPMC.EDU Thu Jul 30 19:20:03 2009 From: personrp at UPMC.EDU (Person, Roderick) Date: Thu, 30 Jul 2009 13:20:03 -0400 Subject: [python-win32] Dict, List and Com Object...oh my! In-Reply-To: References: <4A6FD4BC.9020209@gmail.com> Message-ID: <1AE59099C6D80E41BEB64A1768AFB4EA25D82948@msxmbxnsprd18.acct.upmchs.net> I'm connecting to a MS SQL 2005 database using ADO com objects and getting a dataset from a stored procedure -- Works great. I'm placing that dataset into a dictionary -- works. I'm placing that dictionary into a list -- problem!! When I move to the next record in the dataset and place the dictionary created from that into the list all the members that are in the list change to that record. here is that portion of the code: prv640_records = [] while not rtn.EOF: prv640_dict['promise_id'] = rtn.Fields.Item('promise_id').Value prv640_dict['service_location'] = rtn.Fields.Item('service_location').Value prv640_dict['mco_code'] = rtn.Fields.Item('subnetwork_id').Value prv640_dict['begin_date'] = rtn.Fields.Item('begin_date').Value prv640_dict['end_date'] = rtn.Fields.Item('end_date').Value prv640_dict['mco_prov_number'] = rtn.Fields.Item('provider_id').Value prv640_dict['action'] = rtn.Fields.Item('STATUS').Value rtn.MoveNext() prv640_records.append(prv640_dict) So the first time through the while loop, prv640_records will contain one dictionary that is the first record in rtn. The second time through the loop prv640_records will contain 2 dictionaries that are both the 2nd record in rtn. The first dictionary in prv640_records is somehow replaced. So in testing this with a record set of 402 records, at the end of the while loop, the list prv640_records will contain 402 dictionaries that are all the last record of rtn. I hope this is a clear explanation of the problem. Does anyone have an idea why? I been trying to figure this out for 3 hours now. Rod Person Sr. Programmer (412)454-2616 http://www.ccbh.com Just because it can be done, doesn't it mean it should be done. - Anon From Andrew.MacIntyre at acma.gov.au Fri Jul 31 08:14:33 2009 From: Andrew.MacIntyre at acma.gov.au (Andrew MacIntyre) Date: Fri, 31 Jul 2009 16:14:33 +1000 Subject: [python-win32] Dict, List and Com Object...oh my! [SEC=PERSONAL] In-Reply-To: <1AE59099C6D80E41BEB64A1768AFB4EA25D82948@msxmbxnsprd18.acct.upmchs.net> References: <4A6FD4BC.9020209@gmail.com> <1AE59099C6D80E41BEB64A1768AFB4EA25D82948@msxmbxnsprd18.acct.upmchs.net> Message-ID: <7B01D7143C4AD54899EA079D4557562AFEF773@ACT01EXC02.internal.govt> > Does anyone have an idea why? I been trying to figure this out for > 3 hours now. You appear to be re-using the same dictionary for each record; allocate a new one for each record before starting to populate it. -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre National Licensing and Allocations Branch tel: +61 2 6219 5356 Inputs to Industry Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: andrew.macintyre at acma.gov.au http://www.acma.gov.au/ If you have received this email in error, please notify the sender immediately and erase all copies of the email and any attachments to it. The information contained in this email and any attachments may be private, confidential and legally privileged or the subject of copyright. If you are not the addressee it may be illegal to review, disclose, use, forward, or distribute this email and/or its contents. Unless otherwise specified, the information in the email and any attachments is intended as a guide only and should not be relied upon as legal or technical advice or regarded as a substitute for legal or technical advice in individual cases. Opinions contained in this email or any of its attachments do not necessarily reflect the opinions of ACMA. From waldemar.osuch at gmail.com Fri Jul 31 08:37:11 2009 From: waldemar.osuch at gmail.com (Waldemar Osuch) Date: Fri, 31 Jul 2009 00:37:11 -0600 Subject: [python-win32] Dict, List and Com Object...oh my! In-Reply-To: <1AE59099C6D80E41BEB64A1768AFB4EA25D82948@msxmbxnsprd18.acct.upmchs.net> References: <4A6FD4BC.9020209@gmail.com> <1AE59099C6D80E41BEB64A1768AFB4EA25D82948@msxmbxnsprd18.acct.upmchs.net> Message-ID: <6fae95540907302337o33857c69qb6e6fd2d62f0b2ce@mail.gmail.com> On Thu, Jul 30, 2009 at 11:20 AM, Person, Roderick wrote: > I'm connecting to a MS SQL 2005 database using ADO com objects and getting a dataset from a stored procedure -- Works great. > > I'm placing that dataset into a dictionary -- works. > I'm placing that dictionary into a list -- problem!! When I move to the next record in the dataset and place the dictionary created from that into the list all the members that are in the list change to that record. Not really a pywin32 related by I will bite :) For every iteration of the while loop you have to create a new dictionary, fill it up with data and append to the list. > > here is that portion of the code: > > ? ?prv640_records = [] > ? ?while not rtn.EOF: prv640_dic = {} > ? ? ?prv640_dict['promise_id'] = rtn.Fields.Item('promise_id').Value > ? ? ?prv640_dict['service_location'] = rtn.Fields.Item('service_location').Value > ? ? ?prv640_dict['mco_code'] = rtn.Fields.Item('subnetwork_id').Value > ? ? ?prv640_dict['begin_date'] = rtn.Fields.Item('begin_date').Value > ? ? ?prv640_dict['end_date'] = rtn.Fields.Item('end_date').Value > ? ? ?prv640_dict['mco_prov_number'] = rtn.Fields.Item('provider_id').Value > ? ? ?prv640_dict['action'] = rtn.Fields.Item('STATUS').Value > > ? ? ?rtn.MoveNext() > ? ? ?prv640_records.append(prv640_dict) > > So the first time through the while loop, prv640_records will contain one dictionary that is the first record in rtn. The second time through the loop prv640_records will contain 2 dictionaries that are both the 2nd record in rtn. The first dictionary in prv640_records is somehow replaced. > > So in testing this with a record set of 402 records, at the end of the while loop, the list prv640_records will contain 402 dictionaries that are all the last record of rtn. > It really is the same dictionary referenced 402 times. In a debugger type >>> id(prv640_records[0]), d(prv640_records[1]) It will display two identical identifiers. Also I would recommend using adodbapi or pyodbc module for talking to SQL Server. adodbapi is already included in pywin32 distribution. The API of both those extensions follow DBAPI 2 http://www.python.org/dev/peps/pep-0249/ Much nicer IMHO. Waldemar From durumdara at gmail.com Fri Jul 31 12:39:26 2009 From: durumdara at gmail.com (durumdara at gmail.com) Date: Fri, 31 Jul 2009 12:39:26 +0200 Subject: [python-win32] Please suggest me a good Python MAPI module... Message-ID: Hi! I'm searching a good Python MAPI module... I wanna send many pictures, I wanna split them into 5 MB sized mails, and I wanna see them in default mailer as new mails. The sending is not needed, only mapi call with "New mail/Mailto" and with attachments. Thanks for your help: dd -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From personrp at UPMC.EDU Fri Jul 31 12:53:28 2009 From: personrp at UPMC.EDU (Person, Roderick) Date: Fri, 31 Jul 2009 06:53:28 -0400 Subject: [python-win32] Dict, List and Com Object...oh my! In-Reply-To: <6fae95540907302337o33857c69qb6e6fd2d62f0b2ce@mail.gmail.com> References: <4A6FD4BC.9020209@gmail.com> <1AE59099C6D80E41BEB64A1768AFB4EA25D82948@msxmbxnsprd18.acct.upmchs.net>, <6fae95540907302337o33857c69qb6e6fd2d62f0b2ce@mail.gmail.com> Message-ID: <1AE59099C6D80E41BEB64A1768AFB4EA2550A476@msxmbxnsprd18.acct.upmchs.net> >Not really a pywin32 related by I will bite :) >For every iteration of the while loop you have to create a new >dictionary, fill it up with data and append to the list. I posted here because this has never happened to me before, only with the COM object thrown in does it do this. So I assumed it was some kind of windows COM issue. >> >> here is that portion of the code: >> >> prv640_records = [] >> while not rtn.EOF: >> prv640_dic = {} >> prv640_dict['promise_id'] = rtn.Fields.Item('promise_id').Value >> prv640_dict['service_location'] = rtn.Fields.Item('service_location').Value >> prv640_dict['mco_code'] = rtn.Fields.Item('subnetwork_id').Value >> prv640_dict['begin_date'] = rtn.Fields.Item('begin_date').Value >> prv640_dict['end_date'] = rtn.Fields.Item('end_date').Value >> prv640_dict['mco_prov_number'] = rtn.Fields.Item('provider_id').Value >> prv640_dict['action'] = rtn.Fields.Item('STATUS').Value >> >> rtn.MoveNext() >> prv640_records.append(prv640_dict) >> I made this work by adding prv640_dict = None after the list append. >It really is the same dictionary referenced 402 times. >In a debugger type >>> id(prv640_records[0]), d(prv640_records[1]) >It will display two identical identifiers. As soon as I get in the office I will check this out. >Also I would recommend using adodbapi or pyodbc module for talking to >SQL Server. >adodbapi is already included in pywin32 distribution. >The API of both those extensions follow DBAPI 2 >http://www.python.org/dev/peps/pep-0249/ >Much nicer IMHO. I looked at this a few years ago but for me it was easier to use COM with stored procedures, but I will look at it again. Thanks Rod Waldemar