From srsy70 at gmail.com Wed Nov 1 08:35:50 2006 From: srsy70 at gmail.com (S.Ramaswamy) Date: Wed, 1 Nov 2006 13:05:50 +0530 Subject: [python-win32] win32pdh problem on Windows Server 2003 In-Reply-To: <45478C73.8040807@probo.com> References: <45478C73.8040807@probo.com> Message-ID: > > Windows error messages are better handled in hex. -1073738810 is > C0000BC6, and a quick Google on that shows it is basically "performance > counter not found". > Thanks for the tip. > You can use "perfmon" to explore what counters are really present. > Perhaps the "privileged time" counter was renamed in 2003. In your > particular case: > I doubt if that is the case - I downloaded a vbs script from MSDN that does the same, and it doesn't fail. In any case let me check again. Regards Ramaswamy From nytrokiss at gmail.com Thu Nov 2 05:21:57 2006 From: nytrokiss at gmail.com (James Matthews) Date: Wed, 1 Nov 2006 23:21:57 -0500 Subject: [python-win32] How to get windows basic system informations like "Organization", and "User" In-Reply-To: <4546234E.7020707@gmail.com> References: <4546234E.7020707@gmail.com> Message-ID: <8a6b8e350611012021r63776142s5656a13b6076bb40@mail.gmail.com> Thanks! On 10/30/06, durumdara wrote: > > Hi ! > > Many programs can present these basic informations: who's the user that > install OS, and what is the name of it's organization. > I want to get these infos. > > Can anyone help me how can I do it ? > > Thanks for it: > dd > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061101/0a11bfd2/attachment.htm From nytrokiss at gmail.com Thu Nov 2 05:24:43 2006 From: nytrokiss at gmail.com (James Matthews) Date: Wed, 1 Nov 2006 23:24:43 -0500 Subject: [python-win32] win32pdh problem on Windows Server 2003 In-Reply-To: References: <45478C73.8040807@probo.com> Message-ID: <8a6b8e350611012024m3ade28d9i8fb7471357a86eae@mail.gmail.com> You can just use the keyword native if you want none english version! On 11/1/06, S.Ramaswamy wrote: > > > > > Windows error messages are better handled in hex. -1073738810 is > > C0000BC6, and a quick Google on that shows it is basically "performance > > counter not found". > > > > Thanks for the tip. > > > You can use "perfmon" to explore what counters are really present. > > Perhaps the "privileged time" counter was renamed in 2003. In your > > particular case: > > > > I doubt if that is the case - I downloaded a vbs script from MSDN that > does the same, and it doesn't fail. In any case let me check again. > > Regards > Ramaswamy > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061101/36e1c0fc/attachment.html From torerik81 at gmail.com Thu Nov 2 10:27:43 2006 From: torerik81 at gmail.com (=?iso-8859-1?Q?Tor_Erik_S=F8nvisen?=) Date: Thu, 2 Nov 2006 10:27:43 +0100 Subject: [python-win32] FW: Python script as a windows service Message-ID: <000001c6fe61$275da850$7741279e@nett.npolar> Hi, I'm trying to execute a python script as a windows service. I found some information at: http://agiletesting.blogspot.com/2005/09/running-python-script-as-windows.ht ml The steps I've taken are the following: 1. Downloaded Windows Resource Kits 2. Executed instsrv.exe nameOfService srvany.exe 3. In registry added a key Parameters in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\nameOfService entry 4. Under Parameters added three string values: 4.1: Application REG_SZ C:\Python25\pythonw.exe 4.2: AppDirectory REG_SZ C:\Python25 4.3: AppParameters REG_SZ C:\Documents and Settings\torerik\My Documents\Apps\SARImageProcessing\time.py 5. Started nameOfService in Control Panel --> Adminstrative Tools --> Services This is not working however as the python script (time.py) looks like this: import time i = 0 while True: f = open(r'C:\testService.txt', 'wb') f.write(str(i)) f.close() i += 1 time.sleep(1) and no file named testService.txt is created. I've tried executing the script normally, and it works like a charm... Any ideas? regards -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061102/dcda95d7/attachment.html From mc at mclaveau.com Thu Nov 2 14:02:55 2006 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 2 Nov 2006 14:02:55 +0100 Subject: [python-win32] FW: Python script as a windows service References: <000001c6fe61$275da850$7741279e@nett.npolar> Message-ID: <002401c6fe7f$39aabbb0$0701a8c0@PORTABLES> Hi! Have you use a batch, for define the service? Is the name in the list of services? @-salutations Michel Claveau From torerik81 at gmail.com Thu Nov 2 14:23:11 2006 From: torerik81 at gmail.com (=?iso-8859-1?Q?Tor_Erik_S=F8nvisen?=) Date: Thu, 2 Nov 2006 14:23:11 +0100 Subject: [python-win32] FW: Python script as a windows service In-Reply-To: <002401c6fe7f$39aabbb0$0701a8c0@PORTABLES> Message-ID: <000501c6fe82$0c0251c0$7741279e@nett.npolar> Hi, No, I did not use a batch file. As I understand, it should be possible to do this without a batch file. The name of my script is not the same as the service name, if that's what you are asking... Installing the service is not a problem, and it gets listed in the services menu. -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Michel Claveau Sent: 2. november 2006 14:03 To: python-win32 at python.org Subject: Re: [python-win32] FW: Python script as a windows service Hi! Have you use a batch, for define the service? Is the name in the list of services? @-salutations Michel Claveau _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From Jim.Vickroy at noaa.gov Thu Nov 2 17:39:46 2006 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu, 02 Nov 2006 09:39:46 -0700 Subject: [python-win32] FW: Python script as a windows service In-Reply-To: <000001c6fe61$275da850$7741279e@nett.npolar> References: <000001c6fe61$275da850$7741279e@nett.npolar> Message-ID: <454A1F52.2040605@noaa.gov> I am not familiar with this approach (and I am working on a machine where I do not have admin privileges), but an alternative is to download the Windows extensions for Python by Mark Hammond (et. al.) at: http://sourceforge.net/projects/pywin32/ which makes writing a Windows service simple as the following example illustrates: ===================================================== # SmallestService.py # # A sample demonstrating the smallest possible service written in Python. import win32serviceutil import win32service import win32event class SmallestPythonService(win32serviceutil.ServiceFramework): _svc_name_ = "SmallestPythonService" _svc_display_name_ = "The smallest possible Python Service" def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) # Create an event which we will use to wait on. # The "service stop" request will set this event. self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) def SvcStop(self): # Before we do anything, tell the SCM we are starting the stop process. self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) # And set my event. win32event.SetEvent(self.hWaitStop) def SvcDoRun(self): # We do nothing other than wait to be stopped! win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE) if __name__=='__main__': win32serviceutil.HandleCommandLine(SmallestPythonService) ===================================================== Just type: SmallestService.py -h at a shell prompt to see the options for installing/removing etc. -- jv Tor Erik S?nvisen wrote: > Hi, > > I'm trying to execute a python script as a windows service. > I found some information at: > http://agiletesting.blogspot.com/2005/09/running-python-script-as-windows.html > > The steps I've taken are the following: > > 1. Downloaded Windows Resource Kits > 2. Executed instsrv.exe nameOfService srvany.exe > 3. In registry added a key Parameters in > HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\nameOfService entry > 4. Under Parameters added three string values: > 4.1: Application REG_SZ > C:\Python25\pythonw.exe > 4.2: AppDirectory REG_SZ C:\Python25 > 4.3: AppParameters REG_SZ C:\Documents > and Settings\torerik\My Documents\Apps\SARImageProcessing\time.py > 5. Started nameOfService in Control Panel --> Adminstrative Tools --> > Services > > This is not working however as the python script (time.py) looks like > this: > > import time > > i = 0 > while True: > f = open(r'C:\testService.txt', 'wb') > f.write(str(i)) > f.close() > i += 1 > time.sleep(1) > > and no file named testService.txt is created. > I've tried executing the script normally, and it works like a charm... > Any ideas? > > regards > > > >------------------------------------------------------------------------ > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061102/68b2238c/attachment.html From timr at probo.com Thu Nov 2 19:58:03 2006 From: timr at probo.com (Tim Roberts) Date: Thu, 02 Nov 2006 10:58:03 -0800 Subject: [python-win32] FW: Python script as a windows service In-Reply-To: <000001c6fe61$275da850$7741279e@nett.npolar> References: <000001c6fe61$275da850$7741279e@nett.npolar> Message-ID: <454A3FBB.20909@probo.com> Tor Erik S?nvisen wrote: > > I'm trying to execute a python script as a windows service. > I found some information at: > http://agiletesting.blogspot.com/2005/09/running-python-script-as-windows.html > > The steps I've taken are the following: > > 1. Downloaded Windows Resource Kits > 2. Executed instsrv.exe nameOfService srvany.exe > 3. In registry added a key Parameters in > HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\nameOfService entry > 4. Under Parameters added three string values: > 4.1: Application REG_SZ > C:\Python25\pythonw.exe > 4.2: AppDirectory REG_SZ C:\Python25 > 4.3: AppParameters REG_SZ C:\Documents > and Settings\torerik\My Documents\Apps\SARImageProcessing\time.py You may need to surround that whole path with quote marks because of the embedded spaces. > 5. Started nameOfService in Control Panel --> Adminstrative Tools --> > Services > > This is not working however as the python script (time.py) looks like > this: Don't ever give your own scripts the same filename as a standard library module. If you happen to move that into a directory that is on your Python path, "import time" will grab your script instead of the standard one. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gbrunick at andrew.cmu.edu Thu Nov 2 22:31:50 2006 From: gbrunick at andrew.cmu.edu (Gerard Brunick) Date: Thu, 02 Nov 2006 16:31:50 -0500 Subject: [python-win32] Suggested change to document.py Message-ID: <454A63C6.6030900@andrew.cmu.edu> The problem is much more involved to describe than the solution. I run windows XP, and I keep python scripts all over my drive. Rather than adding all sorts of subdirectory's to my path, i create hardlinks to the scripts that I need to use from the command line in a single \bin directory. The problem is that when I edit a file with PythonWin, the code to save the file first renames the current version of the file to a backup version, and then saves new file with same name. This is a problem, because the hardlink now connects the backup copy to the copy living in my bin directory, so when I try to run it, the backup runs instead of the current version. The solution seems to be change pythonwin\pywin\framework\editor\document.py line 70 from: os.rename(fileName, bakFileName) to: something like shutil.copy(fileName, bakFileName) and adding "import shutil" at the top This seems to work for me. That said, I do not have CVS, and I am unwilling to invest the time and effort to install it to make this change. If this email is worthless, since I am too lazy to install cvs and make the change myself, then please feel free to ignore me. Have a good one everybody, Gerard From timr at probo.com Thu Nov 2 22:52:19 2006 From: timr at probo.com (Tim Roberts) Date: Thu, 02 Nov 2006 13:52:19 -0800 Subject: [python-win32] Suggested change to document.py In-Reply-To: <454A63C6.6030900@andrew.cmu.edu> References: <454A63C6.6030900@andrew.cmu.edu> Message-ID: <454A6893.5040305@probo.com> Gerard Brunick wrote: > ...I run windows XP, and I keep > python scripts all over my drive. Rather than adding all sorts of > subdirectory's to my path, i create > hardlinks to the scripts that I need to use from the command line in a > single \bin directory. > ... > The solution seems to be change > pythonwin\pywin\framework\editor\document.py line 70 > from: os.rename(fileName, bakFileName) > to: something like shutil.copy(fileName, bakFileName) > and adding "import shutil" at the top > > This seems to work for me. Very interesting. This is a problem that Unix folks have faced since time immemorial, but virtually no one uses hard links in Windows. The advantage of the os.rename method is performance, but since Python scripts are always too small to worry about, I'd be in favor of this change, assuming we used shutil.copy2 to retain the dates and times. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gagsl-p32 at yahoo.com.ar Thu Nov 2 23:21:16 2006 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 02 Nov 2006 19:21:16 -0300 Subject: [python-win32] Suggested change to document.py In-Reply-To: <454A6893.5040305@probo.com> References: <454A63C6.6030900@andrew.cmu.edu> <454A6893.5040305@probo.com> Message-ID: <7.0.1.0.0.20061102191731.05c06d68@yahoo.com.ar> At Thursday 2/11/2006 18:52, Gerard Brunick wrote: > > ...I run windows XP, and I keep > > python scripts all over my drive. Rather than adding all sorts of > > subdirectory's to my path, i create > > hardlinks to the scripts that I need to use from the command line in a > > single \bin directory. I don't even knew hard links existed on Windows! Thanks... -- Gabriel Genellina Softlab SRL __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ?gratis! ?Abr? tu cuenta ya! - http://correo.yahoo.com.ar From nytrokiss at gmail.com Fri Nov 3 05:41:23 2006 From: nytrokiss at gmail.com (James Matthews) Date: Thu, 2 Nov 2006 23:41:23 -0500 Subject: [python-win32] Suggested change to document.py In-Reply-To: <7.0.1.0.0.20061102191731.05c06d68@yahoo.com.ar> References: <454A63C6.6030900@andrew.cmu.edu> <454A6893.5040305@probo.com> <7.0.1.0.0.20061102191731.05c06d68@yahoo.com.ar> Message-ID: <8a6b8e350611022041g324b8b73w8bffcb96f1036d17@mail.gmail.com> Yep alot of things from *nix are in windows but they are not very accepted! On 11/2/06, Gabriel Genellina wrote: > > At Thursday 2/11/2006 18:52, Gerard Brunick wrote: > > > > ...I run windows XP, and I keep > > > python scripts all over my drive. Rather than adding all sorts of > > > subdirectory's to my path, i create > > > hardlinks to the scripts that I need to use from the command line in a > > > single \bin directory. > > I don't even knew hard links existed on Windows! Thanks... > > > -- > Gabriel Genellina > Softlab SRL > > __________________________________________________ > Correo Yahoo! > Espacio para todos tus mensajes, antivirus y antispam ?gratis! > ?Abr? tu cuenta ya! - http://correo.yahoo.com.ar > > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061102/f294998b/attachment.html From gbrunick at andrew.cmu.edu Fri Nov 3 08:22:53 2006 From: gbrunick at andrew.cmu.edu (Gerard Brunick) Date: Fri, 03 Nov 2006 02:22:53 -0500 Subject: [python-win32] Suggested change to document.py Message-ID: <454AEE4D.5030304@andrew.cmu.edu> Please ignore my suggestion. It turns out that things are not as simple as I thought, and the change I suggested does not play well with the debugger or new files in PythonWin. To get your hands on hard links in windows use fsutil or the windows api function CreateHardLink as in win32file.CreateHardLink(). Cheers, Gerard > Yep alot of things from *nix are in windows but they are not very accepted! > > On 11/2/06, Gabriel Genellina > wrote: > >/ /> >/ At Thursday 2/11/2006 18:52, Gerard Brunick wrote: /> >/ /> >/ > > ...I run windows XP, and I keep /> >/ > > python scripts all over my drive. Rather than adding all sorts of /> >/ > > subdirectory's to my path, i create /> >/ > > hardlinks to the scripts that I need to use from the command line in a /> >/ > > single \bin directory. /> >/ /> >/ I don't even knew hard links existed on Windows! Thanks... /> >/ /> >/ /> >/ -- /> >/ Gabriel Genellina /> >/ Softlab SRL/ From mc at mclaveau.com Fri Nov 3 09:38:29 2006 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 3 Nov 2006 09:38:29 +0100 Subject: [python-win32] Suggested change to document.py References: <454AEE4D.5030304@andrew.cmu.edu> Message-ID: <003c01c6ff23$752e88c0$0701a8c0@PORTABLES> Hi! Hard links (in windows) is great. I use it often. Another interesting thing is "junction point" (a few like harlink for directories). I work junction-point with linkd.exe & Delrp.exe (see also http://support.microsoft.com/Default.aspx?kbid=205524) But... where is equivalents functions in pywin32? Thank for answer @-salutations Michel Claveau From mc at mclaveau.com Fri Nov 3 10:53:18 2006 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 3 Nov 2006 10:53:18 +0100 Subject: [python-win32] Suggested change to document.py References: <454AEE4D.5030304@andrew.cmu.edu> <003c01c6ff23$752e88c0$0701a8c0@PORTABLES> Message-ID: <000601c6ff2d$e6543f90$0701a8c0@PORTABLES> Hi! >> junction point >> But... where is equivalents functions in pywin32? I had (perhaps) found: SetVolumeMountPoint (http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/win32file_.28more.29__SetVolumeMountPoint_meth.html) Thanks Michel Claveau From rwupole at msn.com Fri Nov 3 12:30:07 2006 From: rwupole at msn.com (Roger Upole) Date: Fri, 3 Nov 2006 06:30:07 -0500 Subject: [python-win32] Suggested change to document.py Message-ID: Michel Claveau wrote: > Hi! > > Hard links (in windows) is great. I use it often. > > Another interesting thing is "junction point" (a few like harlink for > directories). > I work junction-point with linkd.exe & Delrp.exe > (see also http://support.microsoft.com/Default.aspx?kbid=205524) > > But... where is equivalents functions in pywin32? You can use win32file.DeviceIoControl with FSCTL_SET_REPARSE_POINT to create NTFS junctions. Roger From davtiupy at gmail.com Thu Nov 9 21:15:23 2006 From: davtiupy at gmail.com (d tiu) Date: Thu, 9 Nov 2006 15:15:23 -0500 Subject: [python-win32] OnItemSend cancel help Message-ID: <26e30ca10611091215p66d925c4rf6467b35a5968b3c@mail.gmail.com> Hi all, I'm writing an outlook addin, trying to stop email sends on certain conditions. I'm using OnItemSend callbacks that has a cancel parameter which if set to True, will cancel the send. It's not working :(. I'm calling: self.applicationEvents = DispatchWithEvents(application, ApplicationEvent) with class ApplicationEvent: def OnItemSend(self, item, cancel): print "OnItemSend" cancel = True and desperate, also tried: class ApplicationEvent: def OnItemSend(self, item, cancel): print "OnItemSend" cancel = True return cancel I've confirmed that the handler is getting called, but the cancel parameter seems like it's not getting back to outlook. The makepy has # def OnItemSend(self, Item=defaultNamedNotOptArg, Cancel=defaultNamedNotOptArg): as the prototype on gen_py\ApplicationEvents.py. Any ideas? One thing is that the VB call is Sub object_ItemSend(ByVal Item As Object, Cancel As Boolean) which I suspect Cancel is passed by reference? If so, is this handled by the mechanisms in DispathWithEvents? If not, how does one do it? Thanks Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061109/c5a58b89/attachment.html From mhammond at skippinet.com.au Fri Nov 10 00:01:15 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 10 Nov 2006 10:01:15 +1100 Subject: [python-win32] OnItemSend cancel help In-Reply-To: <26e30ca10611091215p66d925c4rf6467b35a5968b3c@mail.gmail.com> Message-ID: <209b01c70452$f71c87e0$0c0a0a0a@enfoldsystems.local> In general, you should simply return the value of that variable. You didn't include the next line of the makepy snippet which includes the types, but a possibility is that the event handler is actually a function rather than a "sub" - so maybe something like: return 0, True should be used - returning 0 for the function itself, with the True being for cancel. Wish I could be more help... Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of d tiu Sent: Friday, 10 November 2006 7:15 AM To: python-win32 at python.org Subject: [python-win32] OnItemSend cancel help Hi all, I'm writing an outlook addin, trying to stop email sends on certain conditions. I'm using OnItemSend callbacks that has a cancel parameter which if set to True, will cancel the send. It's not working :(. I'm calling: self.applicationEvents = DispatchWithEvents(application, ApplicationEvent) with class ApplicationEvent: def OnItemSend(self, item, cancel): print "OnItemSend" cancel = True and desperate, also tried: class ApplicationEvent: def OnItemSend(self, item, cancel): print "OnItemSend" cancel = True return cancel I've confirmed that the handler is getting called, but the cancel parameter seems like it's not getting back to outlook. The makepy has # def OnItemSend(self, Item=defaultNamedNotOptArg, Cancel=defaultNamedNotOptArg): as the prototype on gen_py\ApplicationEvents.py. Any ideas? One thing is that the VB call is Sub object_ItemSend(ByVal Item As Object, Cancel As Boolean) which I suspect Cancel is passed by reference? If so, is this handled by the mechanisms in DispathWithEvents? If not, how does one do it? Thanks Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061110/edc975e9/attachment.html From nathan.jeffrey at gmail.com Mon Nov 13 17:23:51 2006 From: nathan.jeffrey at gmail.com (Nathan) Date: Mon, 13 Nov 2006 16:23:51 +0000 GMT Subject: [python-win32] Win32_GroupUser Message-ID: <1760710902-1163435031-cardhu_blackberry.rim.net-5907-@engine27-cell01.bwc.produk.on.blackberry> Hey all, Has anyone had any successes with Tim Golden's wmi module and the somewhat evil Win32_GroupUser WMI object? Working off a large-ish domain, I can't seem to find a form of: import wmi conn = wmi.WMI () stuff = conn.Win32_GroupUser () ... that doesn't enumerate the entire domain. That includes : conn.Win32_GroupUser (GroupComponent = "Win32_Group.SID=sid_number") ... and quite a few conceiveable permutations. If anyone has working example code, I promise to buy you a beer and post a summary. -- - Nathan From Tim.Golden at viacom-outdoor.co.uk Mon Nov 13 18:11:09 2006 From: Tim.Golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon, 13 Nov 2006 17:11:09 -0000 Subject: [python-win32] Win32_GroupUser In-Reply-To: <1760710902-1163435031-cardhu_blackberry.rim.net-5907-@engine27-cell01.bwc.produk.on.blackberry> Message-ID: | Has anyone had any successes with Tim Golden's wmi module and | the somewhat evil Win32_GroupUser WMI object? Well I can't say that I had, but I started to look around when you asked and there do seem to be a few caveats: 1) Win32_GroupUser is an association between Win32_Group and Win32_Account, just in case you didn't realise. 2) There's a warning here: http://support.microsoft.com/kb/302857 which suggests that it's less than optimal because of what happens behind the scenes. [But that seems to apply only to NT4 & early Win2K] | Working off a large-ish domain, I can't seem to find a form of: | | import wmi | conn = wmi.WMI () | stuff = conn.Win32_GroupUser () | | ... that doesn't enumerate the entire domain. I'm going to assume that you didn't intend the double-negative in the above. 3) I suggest that the easiest way to use it is this following: import wmi c = wmi.WMI () sql_group = c.Win32_Group (Name="SQL_Adminstrators") sql_users1 = sql_group.associators (wmi_result_class="Win32_Account") # or, if you prefer sql_users2 = sql_group.associators (wmi_association_class="Win32_GroupUser") But that doesn't answer your question. I ran that against my domain and returned all 15 users in that particular group, albeit after about a minute or something. I'm running it against our Domain Users group now... ... and that came back with 726 (after about 2 minutes) which, my sysadmins tell me, is about the right number. Can you post a specific bit of code, just so I can see what you're doing, and indicate how many users you're expecting to get back and how many you actually get? Thanks TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From timr at probo.com Mon Nov 13 18:47:05 2006 From: timr at probo.com (Tim Roberts) Date: Mon, 13 Nov 2006 09:47:05 -0800 Subject: [python-win32] Win32_GroupUser In-Reply-To: References: Message-ID: <4558AF99.6020305@probo.com> Tim Golden wrote: > | Working off a large-ish domain, I can't seem to find a form of: > | > | import wmi > | conn = wmi.WMI () > | stuff = conn.Win32_GroupUser () > | > | ... that doesn't enumerate the entire domain. > > I'm going to assume that you didn't intend the > double-negative in the above. > Actually, I think he did. Everything he tried enumerated the entire domain, which is not what he wanted. He wanted to query a subset only. > Can you post a specific bit of code, just so I can > see what you're doing, and indicate how many users > you're expecting to get back and how many you actually > get? > What he posted was: conn.Win32_GroupUser (GroupComponent = "Win32_Group.SID=sid_number") Suggesting, perhaps, that he wanted only the users within a group with a given SID. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From nathan.jeffrey at gmail.com Mon Nov 13 19:11:30 2006 From: nathan.jeffrey at gmail.com (Nathan Jeffrey) Date: Mon, 13 Nov 2006 18:11:30 +0000 Subject: [python-win32] Win32_GroupUser In-Reply-To: References: <1760710902-1163435031-cardhu_blackberry.rim.net-5907-@engine27-cell01.bwc.produk.on.blackberry> Message-ID: <775d0e220611131011s3b518704gd586fa3babe824f@mail.gmail.com> On 11/13/06, Tim Golden wrote: > > import wmi > > c = wmi.WMI () > sql_group = c.Win32_Group (Name="SQL_Adminstrators") > sql_users1 = sql_group.associators (wmi_result_class="Win32_Account") > # or, if you prefer > sql_users2 = sql_group.associators > (wmi_association_class="Win32_GroupUser") > Although it may not answer the question I posted, it does answer an unasked question about the way Windows WMI Does Stuff. I shall attempt it tomorrow and see if it works, and how fast on our W2K domain. Cheers! -- - Nathan From mail at timgolden.me.uk Mon Nov 13 20:32:31 2006 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 13 Nov 2006 19:32:31 +0000 (UTC) Subject: [python-win32] =?utf-8?q?Win32=5FGroupUser?= References: <4558AF99.6020305@probo.com> Message-ID: Tim Roberts probo.com> writes: > > Tim Golden wrote: > > | Working off a large-ish domain, I can't seem to find a form of: > > | > > | import wmi > > | conn = wmi.WMI () > > | stuff = conn.Win32_GroupUser () > > | > > | ... that doesn't enumerate the entire domain. > > > > I'm going to assume that you didn't intend the > > double-negative in the above. > > > > Actually, I think he did. Everything he tried enumerated the entire > domain, which is not what he wanted. He wanted to query a subset only. Ah yes, my misunderstanding. Thanks for pointing out. > What he posted was: > > conn.Win32_GroupUser (GroupComponent = "Win32_Group.SID=sid_number") > > Suggesting, perhaps, that he wanted only the users within > a group with a given SID. I imagine you're right. Hopefully my example gave a way of doing that, but I'll just repost slightly here: import wmi c = wmi.WMI () sid_number = "whatever" group = c.Win32_Group (SID=sid_number) # # and then as before, using group.associators (...) # TJG From nytrokiss at gmail.com Tue Nov 14 05:01:53 2006 From: nytrokiss at gmail.com (James Matthews) Date: Mon, 13 Nov 2006 23:01:53 -0500 Subject: [python-win32] Win32_GroupUser In-Reply-To: References: <4558AF99.6020305@probo.com> Message-ID: <8a6b8e350611132001t117cfc21y9571e972df683dce@mail.gmail.com> There should be a central site with all this information! On 11/13/06, Tim Golden wrote: > > Tim Roberts probo.com> writes: > > > > > Tim Golden wrote: > > > | Working off a large-ish domain, I can't seem to find a form of: > > > | > > > | import wmi > > > | conn = wmi.WMI () > > > | stuff = conn.Win32_GroupUser () > > > | > > > | ... that doesn't enumerate the entire domain. > > > > > > I'm going to assume that you didn't intend the > > > double-negative in the above. > > > > > > > Actually, I think he did. Everything he tried enumerated the entire > > domain, which is not what he wanted. He wanted to query a subset only. > > Ah yes, my misunderstanding. Thanks for pointing out. > > > What he posted was: > > > > conn.Win32_GroupUser (GroupComponent = "Win32_Group.SID=sid_number") > > > > Suggesting, perhaps, that he wanted only the users within > > a group with a given SID. > > I imagine you're right. Hopefully my example gave > a way of doing that, but I'll just repost slightly > here: > > > import wmi > c = wmi.WMI () > sid_number = "whatever" > group = c.Win32_Group (SID=sid_number) > # > # and then as before, using group.associators (...) > # > > > > TJG > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061113/c1c4685a/attachment.htm From bruce.who.hk at gmail.com Tue Nov 14 06:23:15 2006 From: bruce.who.hk at gmail.com (Bruce Who) Date: Tue, 14 Nov 2006 13:23:15 +0800 Subject: [python-win32] how to get the interface of an COM object? Message-ID: Hi, all I am trying to use win32com to interact with a proprietary COM object. progID of the coclass is "SomeObj2.SomeObj.1", I can create the coclass but am not able to access other interfaces via win32com.client.CastTo(). For example ISomeInterface is one of this COM object's interfaces. But no classes are generated for this interface in the file made by makepy.py. I can only find things like this: ISomeInterface_vtables_dispatch_, ISomeInterface_vtables_ this is my code: te = win32com.client.Dispatch("SomeObj2.SomeObj.1") # fail! Error message is: # ... # return mapCLSIDToClass[clsid] # KeyError: '{84AE9D10-95AD-13D5-88C1-0003025952C1}' ISomeInterface_ = win32com.client.CastTo(te, 'ISomeInterface') in the file generated by makepy.py, the class is very simple: class SomeObj(CoClassBaseClass): # A CoClass CLSID = IID('{7A4F5191-68A8-14D5-82C1-0001083952C1}') coclass_sources = [ _SomeObjEvents2, _SomeObjEvents, _SomeObjEvents4, _SomeObjEvents5, _SomeObjEvents3, ] default_source = _SomeObjEvents5 coclass_interfaces = [ ] I googled the web and find some old posts in this maillist, it seems that only interfaces inherit from IDispatch can be used by pythonCOM, and interfaces here inherits from IUnknown. But I just need to use these interfaces, so could anybody tell me how to do it? And this control and its interfaces are all available to VBScript or Visual Bacis: Set ISomeInterface_ = SomeObj.interface("ISomeInterface") ... Since VBScript and python are both script languages, I guess python can also access these interfaces. Any help would be appreciated! Bruce From mhammond at skippinet.com.au Tue Nov 14 06:43:11 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 14 Nov 2006 16:43:11 +1100 Subject: [python-win32] how to get the interface of an COM object? In-Reply-To: Message-ID: <2d2d01c707af$c5eb4570$0c0a0a0a@enfoldsystems.local> > I googled the web and find some old posts in this maillist, it seems > that only interfaces inherit from IDispatch can be used by pythonCOM, > and interfaces here inherits from IUnknown. But I just need to use > these interfaces, so could anybody tell me how to do it? I'm afraid that what you googled is still correct - only interfaces implemented using IDispatch can be called by pywin32. > And this control and its interfaces are all available to VBScript or > Visual Bacis: > > Set ISomeInterface_ = SomeObj.interface("ISomeInterface") > ... > CLASSID="CLSID:7A4F5191-68A8-14D5-82C1-0001083952C1" > > > Since VBScript and python are both script languages, I guess python > can also access these interfaces. VB can use all interfaces, but I believe VBScript can not. Can you show me some VBScript code that runs under the Windows Scripting Host (WSH - ie, wscript.exe/cscript.exe) that does what you need? Cheers, Mark From rikard.bosnjakovic at gmail.com Tue Nov 14 07:19:44 2006 From: rikard.bosnjakovic at gmail.com (Rikard Bosnjakovic) Date: Tue, 14 Nov 2006 07:19:44 +0100 Subject: [python-win32] COM interface specs Message-ID: Greetings I'm a Python-programmer since 6 years, and now is the first time I'm about to program under the Windows environment. What I am about to do now is to play around with COM. I read a very brief tutor (the one found at http://www.oreilly.com/catalog/python2/chapter/ch15.html#21248) and in there it says that I should see "Word's COM interface specs" if I need more information about the COM-functions and similiar. Question: Where do I find these? I have googled and browsed http://msdn.microsoft.com for hours without any luck. The only thing I finally managed to find at Microsoft was some C#-code for interfacing Word through COM. Not much of a reference though. -- - Rikard. From mc at mclaveau.com Tue Nov 14 07:36:42 2006 From: mc at mclaveau.com (Michel Claveau) Date: Tue, 14 Nov 2006 07:36:42 +0100 Subject: [python-win32] COM interface specs References: Message-ID: <000201c707b7$42d98630$0701a8c0@PORTABLES> Hi! Just a little way: http://wikipython.flibuste.net/ see the section "CodeWindows" This wiki is in french ; but the (exemples of) code is in python. @-salutations -- Michel Claveau From theller at ctypes.org Tue Nov 14 08:09:44 2006 From: theller at ctypes.org (Thomas Heller) Date: Tue, 14 Nov 2006 08:09:44 +0100 Subject: [python-win32] how to get the interface of an COM object? In-Reply-To: References: Message-ID: <45596BB8.6060009@ctypes.org> Bruce Who schrieb: > I googled the web and find some old posts in this maillist, it seems > that only interfaces inherit from IDispatch can be used by pythonCOM, > and interfaces here inherits from IUnknown. But I just need to use > these interfaces, so could anybody tell me how to do it? > > And this control and its interfaces are all available to VBScript or > Visual Bacis: > > Set ISomeInterface_ = SomeObj.interface("ISomeInterface") > ... > CLASSID="CLSID:7A4F5191-68A8-14D5-82C1-0001083952C1" > > > Since VBScript and python are both script languages, I guess python > can also access these interfaces. comtypes can call custom com interfaces: http://www.python.org/pypi/comtypes The downside is that there are no docs, yet. Thomas From bruce.who.hk at gmail.com Tue Nov 14 09:06:03 2006 From: bruce.who.hk at gmail.com (Bruce Who) Date: Tue, 14 Nov 2006 16:06:03 +0800 Subject: [python-win32] how to get the interface of an COM object? In-Reply-To: <2d2d01c707af$c5eb4570$0c0a0a0a@enfoldsystems.local> References: <2d2d01c707af$c5eb4570$0c0a0a0a@enfoldsystems.local> Message-ID: Hi, Mark All the sample VBScript codes I have are embeded in html. I donnot know if this is different from VBScript code that runs under the Windows Scripting Host, I'm not familiar with VBScript, :-( On 11/14/06, Mark Hammond wrote: > > I googled the web and find some old posts in this maillist, it seems > > that only interfaces inherit from IDispatch can be used by pythonCOM, > > and interfaces here inherits from IUnknown. But I just need to use > > these interfaces, so could anybody tell me how to do it? > > I'm afraid that what you googled is still correct - only interfaces > implemented using IDispatch can be called by pywin32. > > > And this control and its interfaces are all available to VBScript or > > Visual Bacis: > > > > Set ISomeInterface_ = SomeObj.interface("ISomeInterface") > > ... > > > CLASSID="CLSID:7A4F5191-68A8-14D5-82C1-0001083952C1" > > > > > Since VBScript and python are both script languages, I guess python > > can also access these interfaces. > > VB can use all interfaces, but I believe VBScript can not. Can you show me > some VBScript code that runs under the Windows Scripting Host (WSH - ie, > wscript.exe/cscript.exe) that does what you need? > > Cheers, > > Mark > > Bruce From bruce.who.hk at gmail.com Tue Nov 14 09:17:53 2006 From: bruce.who.hk at gmail.com (Bruce Who) Date: Tue, 14 Nov 2006 16:17:53 +0800 Subject: [python-win32] how to get the interface of an COM object? In-Reply-To: <45596BB8.6060009@ctypes.org> References: <45596BB8.6060009@ctypes.org> Message-ID: Hi, Thomas, Thanks, I'll give it a try. On 11/14/06, Thomas Heller wrote: > Bruce Who schrieb: > > > I googled the web and find some old posts in this maillist, it seems > > that only interfaces inherit from IDispatch can be used by pythonCOM, > > and interfaces here inherits from IUnknown. But I just need to use > > these interfaces, so could anybody tell me how to do it? > > > > And this control and its interfaces are all available to VBScript or > > Visual Bacis: > > > > Set ISomeInterface_ = SomeObj.interface("ISomeInterface") > > ... > > > CLASSID="CLSID:7A4F5191-68A8-14D5-82C1-0001083952C1" > > > > > Since VBScript and python are both script languages, I guess python > > can also access these interfaces. > > comtypes can call custom com interfaces: > > http://www.python.org/pypi/comtypes > > The downside is that there are no docs, yet. > > Thomas > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From Tim.Golden at viacom-outdoor.co.uk Tue Nov 14 09:47:43 2006 From: Tim.Golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue, 14 Nov 2006 08:47:43 -0000 Subject: [python-win32] Win32_GroupUser In-Reply-To: <8a6b8e350611132001t117cfc21y9571e972df683dce@mail.gmail.com> Message-ID: [James Matthews] [... re WMI Win32_GroupUser etc. ] > There should be a central site with all this information! Well, not that I disagree with you as such, but it depends on what exactly your "all this" encompasses. ;) Nearly all of the questions to the list about WMI are really WMI questions, and not Python or Python/WMI specific. This one was a bit different because the answer relied somewhat on the workings of the wmi module. If you're after WMI info in general, msdn is the place I start for simple "How do I use this class?" or "What are the methods / parameters for this class?" queries: http://www.microsoft.com/whdc/system/pnppwr/wmi/default.mspx Then it's down to the Google Group: http://groups.google.com/group/microsoft.public.win32.programmer.wmi?lnk =lr or any one of the myriad other resources and examples around the internet: http://www.google.com/search?q=wmi+enumerate+group+members If it's specifics about the Python wmi module, then obviously I *do* have to bow my head in shame somewhat and admit that my fledgeling tutorial is taking a *very* long time to come up with. Meanwhile, though, there is the cookbook on my site, which does at least give a certain range of examples: http://timgolden.me.uk/python/wmi_cookbook.html I generally try to use the questions to the list as the starting point for cookbook "recipes". I'll try to put this one in. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From rwupole at msn.com Tue Nov 14 11:04:44 2006 From: rwupole at msn.com (Roger Upole) Date: Tue, 14 Nov 2006 05:04:44 -0500 Subject: [python-win32] Re: COM interface specs Message-ID: Rikard Bosnjakovic wrote: > Greetings > > I'm a Python-programmer since 6 years, and now is the first time I'm > about to program under the Windows environment. > > What I am about to do now is to play around with COM. I read a very > brief tutor (the one found at > http://www.oreilly.com/catalog/python2/chapter/ch15.html#21248) and in > there it says that I should see "Word's COM interface specs" if I need > more information about the COM-functions and similiar. > > Question: Where do I find these? I have googled and browsed > http://msdn.microsoft.com for hours without any luck. The only thing I > finally managed to find at Microsoft was some C#-code for interfacing > Word through COM. Not much of a reference though. > > > -- > - Rikard. Try googling "microsoft word object model". This turns up the VBA docs on MSDN, and a lot of other tutorials and such. Also, searching on "python word.application" should get you a good bit of sample code. hth Roger From bruce.who.hk at gmail.com Tue Nov 14 11:43:27 2006 From: bruce.who.hk at gmail.com (Bruce Who) Date: Tue, 14 Nov 2006 18:43:27 +0800 Subject: [python-win32] how to get the interface of an COM object? In-Reply-To: <45596BB8.6060009@ctypes.org> References: <45596BB8.6060009@ctypes.org> Message-ID: Hi, Thomas Finally I make it to create a COM object: class EventSink: def OnLoadFinished(self): print 'load finished' o = comtypes.client.CreateObject("SomeObj2.SomeObj.1", sink=EventSink()) but the EventSink.OnLoadFinished() is never called, and I still donnot know how to get an interface, :-( On 11/14/06, Thomas Heller wrote: > > comtypes can call custom com interfaces: > > http://www.python.org/pypi/comtypes > > The downside is that there are no docs, yet. > > Thomas > Bruce Who From theller at ctypes.org Tue Nov 14 13:19:05 2006 From: theller at ctypes.org (Thomas Heller) Date: Tue, 14 Nov 2006 13:19:05 +0100 Subject: [python-win32] how to get the interface of an COM object? In-Reply-To: References: <45596BB8.6060009@ctypes.org> Message-ID: <4559B439.3050103@ctypes.org> Bruce Who schrieb: > Hi, Thomas > > Finally I make it to create a COM object: > > class EventSink: > def OnLoadFinished(self): > print 'load finished' > > o = comtypes.client.CreateObject("SomeObj2.SomeObj.1", sink=EventSink()) > > but the EventSink.OnLoadFinished() is never called, and I still donnot > know how to get an interface, :-( Well, comtypes.client.CreateObject /returns/ a pointer to a COM interface. If it is not the interface you want, you can call o.QueryInterface(IOtherInterface) on it - how you get or create the IOtherInterface Python class that 'describes' the interface is another question. If the COM object supplies type information then comtypes generates a Python wrapper for the type library automatically in the 'comtypes.gen' package. The module name is derived from the type library, for example for InternetExplorer the typelib is name comtypes.gen.SHDocVw (Note that this is a very shallow module, it imports everything from another module that is named after the GUID and version from the typelib; for IE it is 'comtypes.gen._EAB22AC0_30C1_11CF_A7EB_0000C05BAE0B_0_1_1'). You can import the interfaces from any of these modules. For the events: First, the event handler methods receive an additional argument 'this' just after the 'self', this is an implementation detail of comtypes; which mirrors that COM methods you *implement* also receive this argument. Then, it could be that the name of the method is wrong; comtypes does *not* prepend an 'On' to the method name. A useful event sink for COM objects is one that responds to __getattr__ by dynamically creating event handlers, the attached script demonstrates this (for IE, again). Oh, there 'may* be a totally different reason why you don't receive events: By default, comtypes (like pythoncom) creates a single-threaded COM appartment, in which you usually should run a message pump. Thomas -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: test_events.py Url: http://mail.python.org/pipermail/python-win32/attachments/20061114/9e0490d3/attachment.pot From andrea.gavana at gmail.com Tue Nov 14 16:28:10 2006 From: andrea.gavana at gmail.com (Andrea Gavana) Date: Tue, 14 Nov 2006 15:28:10 +0000 Subject: [python-win32] py2exe and winxptheme Message-ID: Hi all, I am having some troubles mixing py2exe and winxptheme. Basically, I am using wxPython 2.7.2.0 with Python 2.5, and painting some window background using the UxTheme via winxptheme. This is what I am doing: hwnd = MyWindow.GetHandle() self.hTheme = winxptheme.OpenThemeData(hwnd, "Window") winxptheme.DrawThemeBackground(self.hTheme, dc.GetHDC(), 5, 1, (rc.top, rc.left, rc.right, rc.bottom), None) This works very well using python directly, but when I generate and executable file with py2exe, I get this error when executing that last line: TypeError: an integer is required This is because self.hTheme is *None*. It seems like OpenThemeData can not be initialized in an executable, or at least that I am not able to do it. Does anyone have a possible solution to this problem? I have tried all the possibilities with py2exe, meaning bundle=1, bundle=2, bundle=3, compressed=1, compressed=2, every possible combination. But it doesn't work :-( I attach my setup file, if it can be of any help. Thank you very much for every pointer. Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.virgilio.it/infinity77/ -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Setup.py Url: http://mail.python.org/pipermail/python-win32/attachments/20061114/5d60280c/attachment.asc From theller at ctypes.org Tue Nov 14 16:42:30 2006 From: theller at ctypes.org (Thomas Heller) Date: Tue, 14 Nov 2006 16:42:30 +0100 Subject: [python-win32] py2exe and winxptheme In-Reply-To: References: Message-ID: <4559E3E6.4000602@ctypes.org> Andrea Gavana schrieb: > Hi all, > > I am having some troubles mixing py2exe and winxptheme. Basically, > I am using wxPython 2.7.2.0 with Python 2.5, and painting some window > background using the UxTheme via winxptheme. This is what I am doing: > > hwnd = MyWindow.GetHandle() > self.hTheme = winxptheme.OpenThemeData(hwnd, "Window") > > winxptheme.DrawThemeBackground(self.hTheme, dc.GetHDC(), 5, 1, > (rc.top, rc.left, rc.right, rc.bottom), None) > > > This works very well using python directly, but when I generate and > executable file with py2exe, I get this error when executing that last > line: > > TypeError: an integer is required > > This is because self.hTheme is *None*. It seems like OpenThemeData can > not be initialized in an executable, or at least that I am not able to > do it. Let me try to guess: Do you have an XP-style manifest for the exe? Thomas From andrea.gavana at gmail.com Tue Nov 14 16:50:04 2006 From: andrea.gavana at gmail.com (Andrea Gavana) Date: Tue, 14 Nov 2006 15:50:04 +0000 Subject: [python-win32] [Py2exe-users] py2exe and winxptheme In-Reply-To: <4559E3E6.4000602@ctypes.org> References: <4559E3E6.4000602@ctypes.org> Message-ID: Hi Thomas, > > Let me try to guess: Do you have an XP-style manifest for the exe? > Yes, I have it, embedded in the setup.py script. I have removed it from the file I sent to the mailing list because I thought it was redundant, but if you need to see it I can attach it to my e-mail. Is it a problem if I have a XP-Style manifest file? Sorry to be so ignorant in py2exe/WinXP things... I attach the complete setup.py file. Thank you so much. Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.virgilio.it/infinity77/ -------------- next part -------------- from distutils.core import setup import py2exe import glob import os import matplotlib import shutil manifest = """ KPObject """ shutil.rmtree("build", ignore_errors=True) mplfiles = glob.glob(os.sep.join([matplotlib.get_data_path(), '*'])) # Need to explicitly remove cocoa_agg nib folder or py2exe complains mplfiles.remove(os.sep.join([matplotlib.get_data_path(), 'Matplotlib.nib'])) lst = os.listdir(os.getcwd()) incl = [] for files in lst: if files.endswith(".py") or files.endswith(".PY"): incl.append(files[:-3]) includes = incl packages = ['matplotlib.numerix','pytz'] excludes = ["Tkconstants", "Tkinter", "tcl", '_gtkagg', '_tkagg'] excludes.extend(['_gtkagg','_tkagg','Tkconstants','pywin.debugger', 'pywin.debugger.dbgcon','pywin.dialogs', 'bsddb', 'curses','email','distutil','logging','readline', 'setuptools']) dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll', 'tk84.dll', 'gdiplus.dll'] setup( version = "0.1", description = "KPObject", name = "KPObject", data_files = [('matplotlibdata', mplfiles)], options = {"py2exe": {"compressed": 2, "optimize": 1, "includes": includes, "excludes": excludes, "packages": packages, "dll_excludes": dll_excludes, "bundle_files": 1, }}, zipfile = None, windows = [{"script": "KPObject.py", "icon_resources": [(1, "icons/eni.ico")], "other_resources": [(24,1,manifest)]}] ) From andrea.gavana at gmail.com Tue Nov 14 16:55:48 2006 From: andrea.gavana at gmail.com (Andrea Gavana) Date: Tue, 14 Nov 2006 15:55:48 +0000 Subject: [python-win32] [Py2exe-users] py2exe and winxptheme In-Reply-To: References: <4559E3E6.4000602@ctypes.org> Message-ID: Sorry, I just would like to add that I also have a file called: MyExecutable.exe.manifest in the dist directory. Andrea. On 11/14/06, Andrea Gavana wrote: > Hi Thomas, > > > > > Let me try to guess: Do you have an XP-style manifest for the exe? > > > > Yes, I have it, embedded in the setup.py script. I have removed it > from the file I sent to the mailing list because I thought it was > redundant, but if you need to see it I can attach it to my e-mail. Is > it a problem if I have a XP-Style manifest file? Sorry to be so > ignorant in py2exe/WinXP things... > > I attach the complete setup.py file. Thank you so much. > > Andrea. > > "Imagination Is The Only Weapon In The War Against Reality." > http://xoomer.virgilio.it/infinity77/ > > > -- Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.virgilio.it/infinity77/ From theller at ctypes.org Tue Nov 14 17:40:35 2006 From: theller at ctypes.org (Thomas Heller) Date: Tue, 14 Nov 2006 17:40:35 +0100 Subject: [python-win32] py2exe and winxptheme In-Reply-To: References: <4559E3E6.4000602@ctypes.org> Message-ID: <4559F183.6060700@ctypes.org> Andrea Gavana schrieb: > Hi Thomas, > >> >> Let me try to guess: Do you have an XP-style manifest for the exe? >> > > Yes, I have it, embedded in the setup.py script. I have removed it > from the file I sent to the mailing list because I thought it was > redundant, but if you need to see it I can attach it to my e-mail. Is > it a problem if I have a XP-Style manifest file? Sorry to be so > ignorant in py2exe/WinXP things... The manifest file is used to provide the app with the XP-native look and feel. I thought it could also be related to the OpenTheme stuff... > I attach the complete setup.py file. Thank you so much. Seems I have to disappoint you - I have no idea anymore. But then, I've never used these theme functions. Sorry, Thomas From it at crummock.com Tue Nov 14 17:49:39 2006 From: it at crummock.com (Ross McKerchar) Date: Tue, 14 Nov 2006 16:49:39 +0000 Subject: [python-win32] Unpackaged binary version of pywin32 Message-ID: <4559F3A3.3020102@crummock.com> Is there anywhere I can download a compiled but unpackaged version of pywin32? I would like to repackage the win32 extensions as an msi using the the bdist_msi distutils extension, allowing me to deploy the package to multiple clients using group policy. The sourceforge project page only lists executable installers and the source distribution (which isn't much use without MS Visual Studio). Feel free to shoot me down to earth if there's any reason why this approach will never work - the bdist_msi extension does seem quite "bleeding edge". Thanks for all your help! -ross From p.f.moore at gmail.com Tue Nov 14 17:56:11 2006 From: p.f.moore at gmail.com (Paul Moore) Date: Tue, 14 Nov 2006 16:56:11 +0000 Subject: [python-win32] Unpackaged binary version of pywin32 In-Reply-To: <4559F3A3.3020102@crummock.com> References: <4559F3A3.3020102@crummock.com> Message-ID: <79990c6b0611140856x5e42dbf0g5572fd81cd9fb8ed@mail.gmail.com> On 11/14/06, Ross McKerchar wrote: > Is there anywhere I can download a compiled but unpackaged version of > pywin32? > > I would like to repackage the win32 extensions as an msi using the the > bdist_msi distutils extension, allowing me to deploy the package to > multiple clients using group policy. > > The sourceforge project page only lists executable installers and the > source distribution (which isn't much use without MS Visual Studio). > > Feel free to shoot me down to earth if there's any reason why this > approach will never work - the bdist_msi extension does seem quite > "bleeding edge". > > Thanks for all your help! The executable installer (bdist_wininst) format is basically a zip file with an executable header added, so you can unzip it using something like winzip. Having said that, the installer runs a postinstall script to do a lot of the setup actions - I don't know if bdist_msi handles postinstall scripts. Have fun! Paul. From fuzzyman at voidspace.org.uk Tue Nov 14 18:01:28 2006 From: fuzzyman at voidspace.org.uk (Fuzzyman) Date: Tue, 14 Nov 2006 17:01:28 +0000 Subject: [python-win32] Unpackaged binary version of pywin32 In-Reply-To: <79990c6b0611140856x5e42dbf0g5572fd81cd9fb8ed@mail.gmail.com> References: <4559F3A3.3020102@crummock.com> <79990c6b0611140856x5e42dbf0g5572fd81cd9fb8ed@mail.gmail.com> Message-ID: <4559F668.7080607@voidspace.org.uk> Paul Moore wrote: >On 11/14/06, Ross McKerchar wrote: > > >>Is there anywhere I can download a compiled but unpackaged version of >>pywin32? >> >>I would like to repackage the win32 extensions as an msi using the the >>bdist_msi distutils extension, allowing me to deploy the package to >>multiple clients using group policy. >> >>The sourceforge project page only lists executable installers and the >>source distribution (which isn't much use without MS Visual Studio). >> >>Feel free to shoot me down to earth if there's any reason why this >>approach will never work - the bdist_msi extension does seem quite >>"bleeding edge". >> >>Thanks for all your help! >> >> > >The executable installer (bdist_wininst) format is basically a zip >file with an executable header added, so you can unzip it using >something like winzip. Having said that, the installer runs a >postinstall script to do a lot of the setup actions - I don't know if >bdist_msi handles postinstall scripts. > > If you have Visual Studio installed, you should be able to use distutils to generate the msi in the usual way from the source archive. It would be nice to be able to do the same thing using precompiled DLLs. Anyone know if that is possible ? Fuzzyman http://www.voidspace.org.uk/index2.shtml >Have fun! >Paul. >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > > From andrea.gavana at gmail.com Tue Nov 14 18:03:42 2006 From: andrea.gavana at gmail.com (Andrea Gavana) Date: Tue, 14 Nov 2006 17:03:42 +0000 Subject: [python-win32] [Py2exe-users] py2exe and winxptheme In-Reply-To: <4559F183.6060700@ctypes.org> References: <4559E3E6.4000602@ctypes.org> <4559F183.6060700@ctypes.org> Message-ID: Hi Thomas, > Seems I have to disappoint you - I have no idea anymore. But then, > I've never used these theme functions. > > Sorry, > Thomas Thank you for your help... I guess it is a bit an obscure problem. I don't really want to abandon that really nice interface, so I hope that some PyWin32 guru could help me... Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.virgilio.it/infinity77/ From fuzzyman at voidspace.org.uk Tue Nov 14 18:56:35 2006 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 14 Nov 2006 17:56:35 +0000 Subject: [python-win32] Building from Source Message-ID: <455A0353.8070909@voidspace.org.uk> Hello all, I have just tried to build the Pywin32 extensions from source - using the "pywin32-210.zip" archive. I have Visual Studio 2005 installed and have built Pywin32 from source before. I'm using Python 2.4 under Windows XP. The build fails as follows, can anyone suggest a reason ? C:\Python Binaries\pywin32-210>setup.py bdist_wininst Building pywin32 2.4.210.0 running bdist_wininst running build running build_py creating build creating build\lib.win32-2.4 creating build\lib.win32-2.4\win32 creating build\lib.win32-2.4\win32\lib copying win32\lib\afxres.py -> build\lib.win32-2.4\win32\lib [snip ..] copying isapi\simple.py -> build\lib.win32-2.4\isapi copying isapi\threaded_extension.py -> build\lib.win32-2.4\isapi copying isapi\__init__.py -> build\lib.win32-2.4\isapi running build_ext Warning - can't find an installed platform SDK Traceback (most recent call last): File "C:\Python Binaries\pywin32-210\setup.py", line 1496, in ? data_files=[('', (os.path.join(os.environ['temp'],'pywin32.version.txt'),)) + File "C:\Python24\lib\distutils\core.py", line 149, in setup dist.run_commands() File "C:\Python24\lib\distutils\dist.py", line 946, in run_commands self.run_command(cmd) File "C:\Python24\lib\distutils\dist.py", line 966, in run_command cmd_obj.run() File "C:\Python24\lib\distutils\command\bdist_wininst.py", line 107, in run self.run_command('build') File "C:\Python24\lib\distutils\cmd.py", line 333, in run_command self.distribution.run_command(command) File "C:\Python24\lib\distutils\dist.py", line 966, in run_command cmd_obj.run() File "C:\Python Binaries\pywin32-210\setup.py", line 359, in run build.run(self) File "C:\Python24\lib\distutils\command\build.py", line 112, in run self.run_command(cmd_name) File "C:\Python24\lib\distutils\cmd.py", line 333, in run_command self.distribution.run_command(command) File "C:\Python24\lib\distutils\dist.py", line 966, in run_command cmd_obj.run() File "C:\Python24\lib\distutils\command\build_ext.py", line 279, in run self.build_extensions() File "C:\Python Binaries\pywin32-210\setup.py", line 490, in build_extensions self.build_extension(ext) File "C:\Python Binaries\pywin32-210\setup.py", line 678, in build_extension why = self._why_cant_build_extension(ext) File "C:\Python Binaries\pywin32-210\setup.py", line 426, in _why_cant_build_ xtension raise RuntimeError, "Can't find a version in Windows.h" RuntimeError: Can't find a version in Windows.h All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.14.5/533 - Release Date: 13/11/2006 From mhammond at skippinet.com.au Tue Nov 14 23:56:44 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 15 Nov 2006 09:56:44 +1100 Subject: [python-win32] Building from Source In-Reply-To: <455A0353.8070909@voidspace.org.uk> Message-ID: <2fb701c70840$28f67c80$0c0a0a0a@enfoldsystems.local> Hi Michael, > raise RuntimeError, "Can't find a version in Windows.h" > RuntimeError: Can't find a version in Windows.h I've no idea why that would happen unless the Windows.h we found isn't the correct one - no one else has ever reported it before. All I can suggest is to add some 'print' statements to try and diagnose what is going on. Cheers, Mark From nytrokiss at gmail.com Wed Nov 15 03:48:54 2006 From: nytrokiss at gmail.com (James Matthews) Date: Tue, 14 Nov 2006 21:48:54 -0500 Subject: [python-win32] COM interface specs In-Reply-To: References: Message-ID: <8a6b8e350611141848p5ee6bb6i4130512af87b4bd4@mail.gmail.com> There should be a mediawiki on this stuff already! On 11/14/06, Roger Upole wrote: > > Rikard Bosnjakovic wrote: > > Greetings > > > > I'm a Python-programmer since 6 years, and now is the first time I'm > > about to program under the Windows environment. > > > > What I am about to do now is to play around with COM. I read a very > > brief tutor (the one found at > > http://www.oreilly.com/catalog/python2/chapter/ch15.html#21248) and in > > there it says that I should see "Word's COM interface specs" if I need > > more information about the COM-functions and similiar. > > > > Question: Where do I find these? I have googled and browsed > > http://msdn.microsoft.com for hours without any luck. The only thing I > > finally managed to find at Microsoft was some C#-code for interfacing > > Word through COM. Not much of a reference though. > > > > > > -- > > - Rikard. > > Try googling "microsoft word object model". This turns up the VBA docs on > MSDN, and a lot of other tutorials and such. Also, searching on > "python word.application" should get you a good bit of sample code. > > hth > Roger > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061114/4eea6d1b/attachment.htm From arve.knudsen at gmail.com Wed Nov 15 16:54:45 2006 From: arve.knudsen at gmail.com (Arve Knudsen) Date: Wed, 15 Nov 2006 16:54:45 +0100 Subject: [python-win32] Determine admin rights Message-ID: Hi Is there a way I can determine whether a user is a local administrator using pywin32? I've used NetUserGetLocalGroups to see if the user is in the "Administrators" group, but this breaks on non-English versions of Windows. As far as I can see there exists a function IsUserAnAdmin in shell32.lib ( shlobj.h), would it be possible to expose this through pywin32? Thanks, Arve Knudsen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061115/e0730cc7/attachment.html From theller at ctypes.org Wed Nov 15 21:39:30 2006 From: theller at ctypes.org (Thomas Heller) Date: Wed, 15 Nov 2006 21:39:30 +0100 Subject: [python-win32] Determine admin rights In-Reply-To: References: Message-ID: <455B7B02.60201@ctypes.org> Arve Knudsen schrieb: > Hi > Is there a way I can determine whether a user is a local administrator using > pywin32? I've used NetUserGetLocalGroups to see if the user is in the > "Administrators" group, but this breaks on non-English versions of Windows. > As far as I can see there exists a function IsUserAnAdmin in shell32.lib ( > shlobj.h), would it be possible to expose this through pywin32? > Maybe this works? import ctypes print ctypes.windll.shell32.IsUserAnAdmin() Thomas From nytrokiss at gmail.com Fri Nov 17 05:53:58 2006 From: nytrokiss at gmail.com (James Matthews) Date: Thu, 16 Nov 2006 23:53:58 -0500 Subject: [python-win32] Retaining a value during a recursive function Message-ID: <8a6b8e350611162053n1c6a8682w7c1d20ef8dc9c07f@mail.gmail.com> The function just overwrites the list in my function is there anyway i can fix this! def find_all_items(site): site = urllib.urlopen(site).read() all_items = re.findall(r'watch\.asp\?\w+\=\w*\&\w*\=\w+',site) next_page = re.findall(r'Watches\.asp\?\w+\=[0-9]+\&pg\=\w+',site) try: find_all_items(urllib.basejoin("",next_page[0])) except IndexError: pass return remove_dups(all_items) # ,<---- this removes all the duplicate items -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061116/795935a6/attachment.html From mschulz at webgis.de Fri Nov 17 09:10:07 2006 From: mschulz at webgis.de (Michael Schulz) Date: Fri, 17 Nov 2006 09:10:07 +0100 Subject: [python-win32] passing image as string/stream from python to vb Message-ID: Hi, I'm a beginner on the python-win32 field, so please excuse stupid questions ;-) We have an vb application that uses a python com server. This python module generates images in a stringio object. We want to pass the image as a string / stream to the vb application. This is in a way working, as we get the data in vb, but the image cannot be rendered there due to an exception from system.drawing.dll "invalid parameter used". The server has a drawing method the returns the image from a stringio via getvalue(). The relevant vb code, that should take the string and show it in an image object: Dim bSPil As Object = CreateObject("Python.BSPil") Dim imageString As String imageString = bSPil.return_image() Dim imageBytes() As Byte = (New UTF8Encoding()).GetBytes(imageString) Dim ms As New IO.MemoryStream(imageBytes) pb1.Image = System.Drawing.Image.FromStream(ms) The error is raised at the last line. When saving the image from python to a file and reading it as a filestream in vb, the image is displayed correctly. Can anybody shed some light on this. Thanks, Michael -- ----------------------------------------------------------- Michael Schulz mschulz at webgis.de ----------------------------------------------------------- From it at crummock.com Fri Nov 17 09:55:36 2006 From: it at crummock.com (Ross McKerchar) Date: Fri, 17 Nov 2006 08:55:36 +0000 Subject: [python-win32] Unpackaged binary version of pywin32 In-Reply-To: <79990c6b0611140856x5e42dbf0g5572fd81cd9fb8ed@mail.gmail.com> References: <4559F3A3.3020102@crummock.com> <79990c6b0611140856x5e42dbf0g5572fd81cd9fb8ed@mail.gmail.com> Message-ID: <455D7908.60804@crummock.com> Paul Moore wrote: > On 11/14/06, Ross McKerchar wrote: >> I would like to repackage the win32 extensions as an msi using the the >> bdist_msi distutils extension, allowing me to deploy the package to >> multiple clients using group policy. > > The executable installer (bdist_wininst) format is basically a zip > file with an executable header added, so you can unzip it using > something like winzip. Having said that, the installer runs a > postinstall script to do a lot of the setup actions - I don't know if > bdist_msi handles postinstall scripts. Thanks for the info. Unfortunately I didn't manage to get distutils working on the extracted binaries (I couldn't get it to skip trying to compile, a step doomed to failure if you dont have a compiler installed). However, I did manage to manually repackage the install as a (fairly primitive) msi. If anyone would like this (build 210 for python 2.5) please email me. If there's enough interest I'll post it for download. -ross From nytrokiss at gmail.com Fri Nov 17 10:30:12 2006 From: nytrokiss at gmail.com (James Matthews) Date: Fri, 17 Nov 2006 04:30:12 -0500 Subject: [python-win32] RE working in interactive but not in regular code Message-ID: <8a6b8e350611170130q19173bf4y537a1f42d7538249@mail.gmail.com> I have this RE things= re.findall(r'\?Brand\=\w+\&pg=\w+',site) now when i run it against a site it returns everything in a list ( in the interactive interpreter however when i run it start alone it won't work?? Why? -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061117/57a0ae24/attachment.htm From davidf at sjsoft.com Fri Nov 17 13:51:39 2006 From: davidf at sjsoft.com (David Fraser) Date: Fri, 17 Nov 2006 14:51:39 +0200 Subject: [python-win32] Unpackaged binary version of pywin32 In-Reply-To: <455D7908.60804@crummock.com> References: <4559F3A3.3020102@crummock.com> <79990c6b0611140856x5e42dbf0g5572fd81cd9fb8ed@mail.gmail.com> <455D7908.60804@crummock.com> Message-ID: <455DB05B.1070601@sjsoft.com> Ross McKerchar wrote: > Paul Moore wrote: > > On 11/14/06, Ross McKerchar wrote: > >> I would like to repackage the win32 extensions as an msi using the the > >> bdist_msi distutils extension, allowing me to deploy the package to > >> multiple clients using group policy. > > > > The executable installer (bdist_wininst) format is basically a zip > > file with an executable header added, so you can unzip it using > > something like winzip. Having said that, the installer runs a > > postinstall script to do a lot of the setup actions - I don't know if > > bdist_msi handles postinstall scripts. > > Thanks for the info. > > Unfortunately I didn't manage to get distutils working on the extracted > binaries (I couldn't get it to skip trying to compile, a step doomed to > failure if you dont have a compiler installed). > > However, I did manage to manually repackage the install as a (fairly > primitive) msi. If anyone would like this (build 210 for python 2.5) > please email me. If there's enough interest I'll post it for download. I guess me asking would count as enough interest then? I'd be interested in the setup script used for it as well... Cheers David From robertoedwins at gmail.com Fri Nov 17 15:55:11 2006 From: robertoedwins at gmail.com (rieh25) Date: Fri, 17 Nov 2006 06:55:11 -0800 (PST) Subject: [python-win32] Listing query results Message-ID: <7402743.post@talk.nabble.com> Hello, I would like to know how to list query results. I've found usefull information about insert/update queries... conn = odbc.odbc("test1_Data") cursor = conn.cursor() cursor.execute("INSERT INTO local_cmgenadm (Application,Run_Date,Run_DateYMD,status) values (\'rimDev2PrdMdbDistrictPermit\',\'%s\', \'20060731\' , \'Good\')")%mytime cursor.close() conn.close() ...and now I need to know how to list the results of a select query thanks -- View this message in context: http://www.nabble.com/Listing-query-results-tf2652842.html#a7402743 Sent from the Python - python-win32 mailing list archive at Nabble.com. From robertoedwins at gmail.com Fri Nov 17 16:41:03 2006 From: robertoedwins at gmail.com (rieh25) Date: Fri, 17 Nov 2006 07:41:03 -0800 (PST) Subject: [python-win32] Does pywin32-odbc support several users? Message-ID: <7403865.post@talk.nabble.com> I'm thinking of implementing pywin32 to implement access to an Oracle database, to users of an application built in Zope . Is this a good idea, or is pywin32's odbc feature intended for a single user? Thanks -- View this message in context: http://www.nabble.com/Does-pywin32-odbc-support-several-users--tf2653373.html#a7403865 Sent from the Python - python-win32 mailing list archive at Nabble.com. From Jim.Vickroy at noaa.gov Fri Nov 17 16:52:16 2006 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri, 17 Nov 2006 08:52:16 -0700 Subject: [python-win32] Does pywin32-odbc support several users? In-Reply-To: <7403865.post@talk.nabble.com> References: <7403865.post@talk.nabble.com> Message-ID: <455DDAB0.9020808@noaa.gov> rieh25 wrote: >I'm thinking of implementing pywin32 to implement access to an Oracle >database, to users of an application built in Zope . Is this a good idea, or >is pywin32's odbc feature intended for a single user? > >Thanks > > pywin32's odbc interface provides connection objects -- as many as your database back end allows -- so it is fine for multiple users -- jv From robertoedwins at gmail.com Fri Nov 17 17:30:48 2006 From: robertoedwins at gmail.com (rieh25) Date: Fri, 17 Nov 2006 08:30:48 -0800 (PST) Subject: [python-win32] Does pywin32-odbc support several users? In-Reply-To: <455DDAB0.9020808@noaa.gov> References: <7403865.post@talk.nabble.com> <455DDAB0.9020808@noaa.gov> Message-ID: <7405319.post@talk.nabble.com> Ok, thanks... Jim Vickroy wrote: > > rieh25 wrote: > >>I'm thinking of implementing pywin32 to implement access to an Oracle >>database, to users of an application built in Zope . Is this a good idea, or >>is pywin32's odbc feature intended for a single user? >> >>Thanks >> >> > pywin32's odbc interface provides connection objects -- as many as your > database back end allows -- so it is fine for multiple users -- jv > _______________________________________________ > 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/Does-pywin32-odbc-support-several-users--tf2653373.html#a7405319 Sent from the Python - python-win32 mailing list archive at Nabble.com. From timr at probo.com Fri Nov 17 20:21:40 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 17 Nov 2006 11:21:40 -0800 Subject: [python-win32] Listing query results In-Reply-To: <7402743.post@talk.nabble.com> References: <7402743.post@talk.nabble.com> Message-ID: <455E0BC4.1020404@probo.com> rieh25 wrote: > Hello, I would like to know how to list query results. I've found usefull > information about insert/update queries... > > conn = odbc.odbc("test1_Data") > cursor = conn.cursor() > cursor.execute("INSERT INTO local_cmgenadm > (Application,Run_Date,Run_DateYMD,status) values > (\'rimDev2PrdMdbDistrictPermit\',\'%s\', \'20060731\' , > \'Good\')")%mytime > cursor.close() > conn.close() > There is no need to escape the quote marks. You're inside double quotes, so there is no issue with single quotes. However, it's better to let the database layer do the quoting: cursor.execute( "INSERT INTO local_cmgenadm (Application,Run_Date,Run_DateYMD,status) " "VALUES (%s,%s,%s,%s)", ('rimDev2PrdMdbDistrictPermit', mytime, '20060731', 'Good') ) > ...and now I need to know how to list the results of a select query > cursor.execute( "SELECT Application,Run_Date FROM local_cmgenadm WHERE status='Good'") for row in cursor.fetchall(): print row[0], row[1] -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Nov 17 20:25:35 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 17 Nov 2006 11:25:35 -0800 Subject: [python-win32] RE working in interactive but not in regular code In-Reply-To: <8a6b8e350611170130q19173bf4y537a1f42d7538249@mail.gmail.com> References: <8a6b8e350611170130q19173bf4y537a1f42d7538249@mail.gmail.com> Message-ID: <455E0CAF.6060906@probo.com> James Matthews wrote: > I have this RE things= re.findall(r'\?Brand\=\w+\&pg=\w+',site) now > when i run it against a site it returns everything in a list ( in the > interactive interpreter however when i run it start alone it won't > work?? Why? Show us an example, including what you expect and what you see. We can't read minds, yet. There's no need to quote the =. It isn't special. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Nov 17 21:02:09 2006 From: timr at probo.com (Tim Roberts) Date: Fri, 17 Nov 2006 12:02:09 -0800 Subject: [python-win32] Retaining a value during a recursive function In-Reply-To: <8a6b8e350611162053n1c6a8682w7c1d20ef8dc9c07f@mail.gmail.com> References: <8a6b8e350611162053n1c6a8682w7c1d20ef8dc9c07f@mail.gmail.com> Message-ID: <455E1541.2040602@probo.com> James Matthews wrote: > The function just overwrites the list in my function is there anyway i > can fix this! > def find_all_items(site): > site = urllib.urlopen(site).read() > all_items = re.findall(r'watch\.asp\?\w+\=\w*\&\w*\=\w+',site) > next_page = re.findall(r'Watches\.asp\?\w+\=[0-9]+\&pg\=\w+',site) > try: > find_all_items(urllib.basejoin("",next_page[0])) > except IndexError: > pass > return remove_dups(all_items) # ,<---- this removes all the > duplicate items Actually, it doesn't overwrite the list. You just don't do anything with the list that is returned from the call inside the function. Remember that site, all_items, and next_page are LOCAL variable; they exist only inside that one function call. Every time you call find_all_items, you get a brand new instance of all_items. try: all_items.extend( find_all_items( urllib.basejoin("",next_page[0] ) ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From bgailer at alum.rpi.edu Fri Nov 17 21:37:46 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Fri, 17 Nov 2006 12:37:46 -0800 Subject: [python-win32] RE working in interactive but not in regular code In-Reply-To: <8a6b8e350611170130q19173bf4y537a1f42d7538249@mail.gmail.com> References: <8a6b8e350611170130q19173bf4y537a1f42d7538249@mail.gmail.com> Message-ID: <455E1D9A.7090705@alum.rpi.edu> James Matthews wrote: > I have this RE things= re.findall(r'\?Brand\=\w+\&pg=\w+',site) now > when i run it against a site it returns everything in a list ( in the > interactive interpreter however when i run it start alone it won't > work?? Why? You will probably get more help if you tell us what behavior you expect and what you get. "won't work" does not help us understand. -- Bob Gailer 510-978-4454 From rwupole at msn.com Sat Nov 18 17:28:30 2006 From: rwupole at msn.com (Roger Upole) Date: Sat, 18 Nov 2006 11:28:30 -0500 Subject: [python-win32] Re: COM interface specs Message-ID: James Matthews wrote: > There should be a mediawiki on this stuff already! There used to be a collection of Office/COM scripts at win32com.de, but that site appears to be gone. Anybody know if it's moved or if there's a mirror anywhere ? Roger From nytrokiss at gmail.com Sun Nov 19 00:52:05 2006 From: nytrokiss at gmail.com (James Matthews) Date: Sat, 18 Nov 2006 18:52:05 -0500 Subject: [python-win32] RE working in interactive but not in regular code In-Reply-To: <455E1D9A.7090705@alum.rpi.edu> References: <8a6b8e350611170130q19173bf4y537a1f42d7538249@mail.gmail.com> <455E1D9A.7090705@alum.rpi.edu> Message-ID: <8a6b8e350611181552o5993625ftbf3f3e58d9766b18@mail.gmail.com> Sorry i was in a bit or a rush.... def next_page_finder(site): site = urlopen(site).read() next_site_pages = findall(r'\?Brand=\d+\&pg=\d+',site) return next_site_pages On 11/17/06, Bob Gailer wrote: > > James Matthews wrote: > > I have this RE things= re.findall(r'\?Brand\=\w+\&pg=\w+',site) now > > when i run it against a site it returns everything in a list ( in the > > interactive interpreter however when i run it start alone it won't > > work?? Why? > You will probably get more help if you tell us what behavior you expect > and what you get. "won't work" does not help us understand. > > -- > Bob Gailer > 510-978-4454 > > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061118/825c6579/attachment.htm From waldemar.osuch at gmail.com Sun Nov 19 08:04:18 2006 From: waldemar.osuch at gmail.com (Waldemar Osuch) Date: Sun, 19 Nov 2006 00:04:18 -0700 Subject: [python-win32] Does pywin32-odbc support several users? In-Reply-To: <7405319.post@talk.nabble.com> References: <7403865.post@talk.nabble.com> <455DDAB0.9020808@noaa.gov> <7405319.post@talk.nabble.com> Message-ID: <6fae95540611182304q24da0fcfn49ef0f4b4e6eac6e@mail.gmail.com> On 11/17/06, rieh25 wrote: > > Ok, thanks... > > > Jim Vickroy wrote: > > > > rieh25 wrote: > > > >>I'm thinking of implementing pywin32 to implement access to an Oracle > >>database, to users of an application built in Zope . Is this a good idea, > or > >>is pywin32's odbc feature intended for a single user? > >> > >>Thanks > >> > >> > > pywin32's odbc interface provides connection objects -- as many as your > > database back end allows -- so it is fine for multiple users -- jv If you are talking to Oracle DB I would recommend using cx_Oracle and skipping odbc altogether. From mhammond at skippinet.com.au Mon Nov 20 00:13:53 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 20 Nov 2006 10:13:53 +1100 Subject: [python-win32] passing image as string/stream from python to vb In-Reply-To: Message-ID: <3df901c70c30$627903d0$0c0a0a0a@enfoldsystems.local> It may be that the Unicode characters used by COM are to blame. From the Python side of the world, try returning 'buffer(ob.getvalue())' - Python will try and return a buffer object as an array of characters, rather than a 'string' (which is Unicode). The end result is to try and ensure that 'imageBytes' is *identical* to the string passed by Python - I suspect it is not, which is the root of the problem. Cheers, Mark > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of Michael Schulz > Sent: Friday, 17 November 2006 7:10 PM > To: python-win32 at python.org > Subject: [python-win32] passing image as string/stream from > python to vb > > > Hi, > > I'm a beginner on the python-win32 field, so please excuse > stupid questions ;-) > > We have an vb application that uses a python com server. This python > module generates images in a stringio object. We want to pass the > image as a string / stream to the vb application. This is in a way > working, as we get the data in vb, but the image cannot be rendered > there due to an exception from system.drawing.dll "invalid parameter > used". > > The server has a drawing method the returns the image from a stringio > via getvalue(). > The relevant vb code, that should take the string and show it in an > image object: > > Dim bSPil As Object = CreateObject("Python.BSPil") > Dim imageString As String > imageString = bSPil.return_image() > Dim imageBytes() As Byte = (New UTF8Encoding()).GetBytes(imageString) > Dim ms As New IO.MemoryStream(imageBytes) > pb1.Image = System.Drawing.Image.FromStream(ms) > > The error is raised at the last line. When saving the image from > python to a file and reading it as a filestream in vb, the image is > displayed correctly. Can anybody shed some light on this. > > Thanks, Michael > > -- > ----------------------------------------------------------- > Michael Schulz > mschulz at webgis.de > ----------------------------------------------------------- > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From nytrokiss at gmail.com Mon Nov 20 05:52:01 2006 From: nytrokiss at gmail.com (James Matthews) Date: Sun, 19 Nov 2006 23:52:01 -0500 Subject: [python-win32] RE Explained With screenshot Message-ID: <8a6b8e350611192052l4cba0022ia180ff111e75dd81@mail.gmail.com> This is the code i am dealing with.. Code: def next_page_finder(site): site = urlopen(site).read() next_site_pages = [] next_site_pages.extend(findall(r'\?Brand=\d+\&pg=\d+',site)) new_pages = [] for _ in next_site_pages: new_pages.append(basejoin("http://www.goldwatches.com/watches.asp",_)) return new_pages The issue is that when i run the RE Code: next_site_pages.extend(findall(r'\?Brand=\d+\&pg=\d+',site)) it returns me an empty list however in the interactive input i run something akin to it Code: >>> from re import findall >>> from urllib import basejoin,urlopen >>> site = urlopen("http://www.goldwatches.com/watches.asp?Brand=11").read() >>> findall(r'\?Brand=\d+\&pg=\d+',site) Now as you see in the screen shot the interactive interpreter returns me a list of values however when i run it in regular python i get an empty list why?? Screen Shot: http://static.flickr.com/109/301613265_484a49929d_o.jpg http://www.goldwatches.com From simon.dahlbacka at gmail.com Mon Nov 20 07:25:15 2006 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Mon, 20 Nov 2006 08:25:15 +0200 Subject: [python-win32] passing image as string/stream from python to vb In-Reply-To: <3df901c70c30$627903d0$0c0a0a0a@enfoldsystems.local> References: <3df901c70c30$627903d0$0c0a0a0a@enfoldsystems.local> Message-ID: <57124720611192225i2668fdacw795e85eb2e75a1f7@mail.gmail.com> converting the bytes to strig via utf-8 smells like it could be a problem, in case the byte sequence happens to map into a multibyte character somewhere On 11/20/06, Mark Hammond wrote: > > It may be that the Unicode characters used by COM are to blame. From the > Python side of the world, try returning 'buffer(ob.getvalue())' - Python > will try and return a buffer object as an array of characters, rather than > a > 'string' (which is Unicode). > > The end result is to try and ensure that 'imageBytes' is *identical* to > the > string passed by Python - I suspect it is not, which is the root of the > problem. > > Cheers, > > Mark > > > -----Original Message----- > > From: python-win32-bounces at python.org > > [mailto:python-win32-bounces at python.org]On Behalf Of Michael Schulz > > Sent: Friday, 17 November 2006 7:10 PM > > To: python-win32 at python.org > > Subject: [python-win32] passing image as string/stream from > > python to vb > > > > > > Hi, > > > > I'm a beginner on the python-win32 field, so please excuse > > stupid questions ;-) > > > > We have an vb application that uses a python com server. This python > > module generates images in a stringio object. We want to pass the > > image as a string / stream to the vb application. This is in a way > > working, as we get the data in vb, but the image cannot be rendered > > there due to an exception from system.drawing.dll "invalid parameter > > used". > > > > The server has a drawing method the returns the image from a stringio > > via getvalue(). > > The relevant vb code, that should take the string and show it in an > > image object: > > > > Dim bSPil As Object = CreateObject("Python.BSPil") > > Dim imageString As String > > imageString = bSPil.return_image() > > Dim imageBytes() As Byte = (New UTF8Encoding()).GetBytes(imageString) > > Dim ms As New IO.MemoryStream(imageBytes) > > pb1.Image = System.Drawing.Image.FromStream(ms) > > > > The error is raised at the last line. When saving the image from > > python to a file and reading it as a filestream in vb, the image is > > displayed correctly. Can anybody shed some light on this. > > > > Thanks, Michael > > > > -- > > ----------------------------------------------------------- > > Michael Schulz > > mschulz at webgis.de > > ----------------------------------------------------------- > > _______________________________________________ > > 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: http://mail.python.org/pipermail/python-win32/attachments/20061120/af97ccf2/attachment.htm From mmorisak at risc.uni-linz.ac.at Mon Nov 20 12:07:28 2006 From: mmorisak at risc.uni-linz.ac.at (Michael Morisak) Date: Mon, 20 Nov 2006 12:07:28 +0100 Subject: [python-win32] python-win32 on windows 64Bit Platform Message-ID: <45618C70.80308@risc.uni-linz.ac.at> Hi Does anybody know if there is a 64Bit Version of pywin32. I am currently doing some automation stuff with Python and SolidEdge and i have heared that SolidEdge V19 will be available as a 64Bit version and it would be nice to use 64Bit Python with pywin32 (64Bit) thx Michael From mhammond at skippinet.com.au Mon Nov 20 12:51:59 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 20 Nov 2006 22:51:59 +1100 Subject: [python-win32] python-win32 on windows 64Bit Platform In-Reply-To: <45618C70.80308@risc.uni-linz.ac.at> Message-ID: <40cd01c70c9a$49ac6440$0c0a0a0a@enfoldsystems.local> > Does anybody know if there is a 64Bit Version of pywin32. > I am currently doing some automation stuff with Python and > SolidEdge and > i have heared that SolidEdge V19 will be available as a 64Bit version > and it would be nice to use 64Bit Python with pywin32 (64Bit) Not that I am aware of. Sadly, the 'donate' button on sourceforge isn't quite generating enough revenue to get myself such a box , and I'm not aware of anyone else offering such a build. Cheers, Mark. From niki at vintech.bg Mon Nov 20 14:45:46 2006 From: niki at vintech.bg (Niki Spahiev) Date: Mon, 20 Nov 2006 15:45:46 +0200 Subject: [python-win32] bug in FILE_NOTIFY_INFORMATION handling for single char filenames Message-ID: <4561B18A.6020601@vintech.bg> Apparently change messages for single char filenames are too short for current code. Proposed untested patch should fix that. Niki Spahiev P.S. There is no b210 tag in sf.net CVS -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: win32file.diff Url: http://mail.python.org/pipermail/python-win32/attachments/20061120/fd94087a/attachment.diff From mhammond at skippinet.com.au Mon Nov 20 23:23:06 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 21 Nov 2006 09:23:06 +1100 Subject: [python-win32] bug in FILE_NOTIFY_INFORMATION handling for singlechar filenames In-Reply-To: <4561B18A.6020601@vintech.bg> Message-ID: <431501c70cf2$7441b270$0c0a0a0a@enfoldsystems.local> > Apparently change messages for single char filenames are too > short for > current code. Proposed untested patch should fix that. A quick change to test_win32file.py confirms it is a bug. I've committed your patch - thanks! > P.S. There is no b210 tag in sf.net CVS hrm.... Mark From bgailer at alum.rpi.edu Tue Nov 21 00:19:16 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Mon, 20 Nov 2006 15:19:16 -0800 Subject: [python-win32] RE Explained With screenshot In-Reply-To: <8a6b8e350611192052l4cba0022ia180ff111e75dd81@mail.gmail.com> References: <8a6b8e350611192052l4cba0022ia180ff111e75dd81@mail.gmail.com> Message-ID: <456237F4.5030301@alum.rpi.edu> James Matthews wrote: > This is the code i am dealing with.. > Code: > def next_page_finder(site): > site = urlopen(site).read() > next_site_pages = [] > next_site_pages.extend(findall(r'\?Brand=\d+\&pg=\d+',site)) > new_pages = [] > for _ in next_site_pages: > new_pages.append(basejoin("http://www.goldwatches.com/watches.asp",_)) > return new_pages > > The issue is that when i run the RE > Code: > next_site_pages.extend(findall(r'\?Brand=\d+\&pg=\d+',site)) > it returns me an empty list however in the interactive input i run > something akin to it > > Code: > >>>> from re import findall >>>> from urllib import basejoin,urlopen >>>> site = urlopen("http://www.goldwatches.com/watches.asp?Brand=11").read() >>>> findall(r'\?Brand=\d+\&pg=\d+',site) >>>> > Now as you see in the screen shot the interactive interpreter returns > me a list of values however when i run it in regular python i get an > empty list why?? > > > Screen Shot: http://static.flickr.com/109/301613265_484a49929d_o.jpg > Thank you for the clarification. Running under my IDE (PythonWIn) I get the desired results in debug mode and in the interactive window. So I can't help. Must be something in the IDE? -- Bob Gailer 510-978-4454 From timr at probo.com Tue Nov 21 00:57:16 2006 From: timr at probo.com (Tim Roberts) Date: Mon, 20 Nov 2006 15:57:16 -0800 Subject: [python-win32] RE Explained With screenshot In-Reply-To: <456237F4.5030301@alum.rpi.edu> References: <8a6b8e350611192052l4cba0022ia180ff111e75dd81@mail.gmail.com> <456237F4.5030301@alum.rpi.edu> Message-ID: <456240DC.2030105@probo.com> James Matthews wrote: >> Code: >> >> >>>>> from re import findall >>>>> from urllib import basejoin,urlopen >>>>> site = urlopen("http://www.goldwatches.com/watches.asp?Brand=11").read() >>>>> findall(r'\?Brand=\d+\&pg=\d+',site) >>>>> >>>>> >> Now as you see in the screen shot the interactive interpreter returns >> me a list of values however when i run it in regular python i get an >> empty list why?? >> It works for me inside Pythonwin, in a command line in a .py file, and in the command line interactive interpreter. You should copy "site" to a file so you can look at it and make sure it is exactly as you expect. The "Brand=11" file should be 41,251 bytes. Also, it is possible you are confusing the debugger by having your parameter and your result list both called "site". Why don't you change the parameter to "url" so there is no confusion. Can you post the entire program?> -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From nytrokiss at gmail.com Tue Nov 21 03:14:32 2006 From: nytrokiss at gmail.com (James Matthews) Date: Mon, 20 Nov 2006 21:14:32 -0500 Subject: [python-win32] RE Explained With screenshot In-Reply-To: <456240DC.2030105@probo.com> References: <8a6b8e350611192052l4cba0022ia180ff111e75dd81@mail.gmail.com> <456237F4.5030301@alum.rpi.edu> <456240DC.2030105@probo.com> Message-ID: <8a6b8e350611201814s11b7e549jd28c8dcb50e914ef@mail.gmail.com> The issue has something to do with the way the B wasn't escaped ( don't ask me......) all i did for now is lowered the site sting inline but thanks guys On 11/20/06, Tim Roberts wrote: > James Matthews wrote: > >> Code: > >> > >> > >>>>> from re import findall > >>>>> from urllib import basejoin,urlopen > >>>>> site = urlopen("http://www.goldwatches.com/watches.asp?Brand=11").read() > >>>>> findall(r'\?Brand=\d+\&pg=\d+',site) > >>>>> > >>>>> > >> Now as you see in the screen shot the interactive interpreter returns > >> me a list of values however when i run it in regular python i get an > >> empty list why?? > >> > > It works for me inside Pythonwin, in a command line in a .py file, and > in the command line interactive interpreter. > > You should copy "site" to a file so you can look at it and make sure it > is exactly as you expect. The "Brand=11" file should be 41,251 bytes. > > Also, it is possible you are confusing the debugger by having your > parameter and your result list both called "site". Why don't you change > the parameter to "url" so there is no confusion. > > Can you post the entire program?> > > -- > 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 > -- http://www.goldwatches.com From mschulz at webgis.de Tue Nov 21 09:47:57 2006 From: mschulz at webgis.de (Michael Schulz) Date: Tue, 21 Nov 2006 09:47:57 +0100 Subject: [python-win32] passing image as string/stream from python to vb In-Reply-To: <3df901c70c30$627903d0$0c0a0a0a@enfoldsystems.local> References: <3df901c70c30$627903d0$0c0a0a0a@enfoldsystems.local> Message-ID: Hi Mark, thanks for your help - the use of buffer did the trick. We can pass the resulting buffer directly to MemoryStream: Dim bSPil As Object = CreateObject("Python.BSPil") Dim imageBytes() As Byte = bSPil.return_image() Dim ms As New IO.MemoryStream(imageBytes) pb1.Image = System.Drawing.Image.FromStream(ms) Thanks a lot, Michael On 11/20/06, Mark Hammond wrote: > It may be that the Unicode characters used by COM are to blame. From the > Python side of the world, try returning 'buffer(ob.getvalue())' - Python > will try and return a buffer object as an array of characters, rather than a > 'string' (which is Unicode). > > The end result is to try and ensure that 'imageBytes' is *identical* to the > string passed by Python - I suspect it is not, which is the root of the > problem. > > Cheers, > > Mark > > > -----Original Message----- > > From: python-win32-bounces at python.org > > [mailto:python-win32-bounces at python.org]On Behalf Of Michael Schulz > > Sent: Friday, 17 November 2006 7:10 PM > > To: python-win32 at python.org > > Subject: [python-win32] passing image as string/stream from > > python to vb > > > > > > Hi, > > > > I'm a beginner on the python-win32 field, so please excuse > > stupid questions ;-) > > > > We have an vb application that uses a python com server. This python > > module generates images in a stringio object. We want to pass the > > image as a string / stream to the vb application. This is in a way > > working, as we get the data in vb, but the image cannot be rendered > > there due to an exception from system.drawing.dll "invalid parameter > > used". > > > > The server has a drawing method the returns the image from a stringio > > via getvalue(). > > The relevant vb code, that should take the string and show it in an > > image object: > > > > Dim bSPil As Object = CreateObject("Python.BSPil") > > Dim imageString As String > > imageString = bSPil.return_image() > > Dim imageBytes() As Byte = (New UTF8Encoding()).GetBytes(imageString) > > Dim ms As New IO.MemoryStream(imageBytes) > > pb1.Image = System.Drawing.Image.FromStream(ms) > > > > The error is raised at the last line. When saving the image from > > python to a file and reading it as a filestream in vb, the image is > > displayed correctly. Can anybody shed some light on this. > > > > Thanks, Michael > > > > -- > > ----------------------------------------------------------- > > Michael Schulz > > mschulz at webgis.de > > ----------------------------------------------------------- > > _______________________________________________ > > Python-win32 mailing list > > Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > -- ----------------------------------------------------------- Michael Schulz mschulz at webgis.de in medias res Gesellschaft f?r Informationstechnologie mbH In den Weihermatten 66 79108 Freiburg Tel +49 (0)761 556959-5 Fax +49 (0)761 556959-6 http://www.webgis.de / http://www.zopecms.de ----------------------------------------------------------- From bokverket at hotmail.com Tue Nov 21 17:50:01 2006 From: bokverket at hotmail.com (Bokverket) Date: Tue, 21 Nov 2006 17:50:01 +0100 Subject: [python-win32] Compiling a Python Windows application References: Message-ID: Hello gurus, If you don't want to distribute the Python interpreter along with your app, Is there a well-working way of compiling/byte-coding/whatever a Python app and call it from within Microsoft Word? What run-time is needed? All the best, Goran Fagerstrom From emlynj at gmail.com Tue Nov 21 18:03:41 2006 From: emlynj at gmail.com (Emlyn Jones) Date: Tue, 21 Nov 2006 17:03:41 +0000 Subject: [python-win32] Non memory sessions with ASP Message-ID: Hello, I'm currently running a web app using win32 python and ASP on an IIS6 server. Every now and then the dll I'm using will go into a very busy loop and tie up ~100% cpu. This server has two cpus so my plan was to run two worker processes (one on each cpu) so that one can continue while the other gets busy (I'm not in a position to modify the dll at the moment and even if I was it would be nice to know the server is a bit more immune to this type of thing). The problem with that plan is that ASP sessions are held in memory so can't be shared between two worker processes; so I have two questions if that's ok: i) I've read that ASP.NET can utilize external storage for it's sessions, what are my chances of being able to use the functionality without running the whole app in ASP.NET? (which I can't, because it's all written in Python). ii)Does anyone have an example of a custom session handler written in Python? I'm thinking the bsdb module might be good for this but I'm worried about concurrency issues. Thanks, Emlyn. From timr at probo.com Tue Nov 21 19:20:21 2006 From: timr at probo.com (Tim Roberts) Date: Tue, 21 Nov 2006 10:20:21 -0800 Subject: [python-win32] Compiling a Python Windows application In-Reply-To: References: Message-ID: <45634365.40605@probo.com> Bokverket wrote: > Hello gurus, > > If you don't want to distribute the Python interpreter along with your app, > Is there a well-working way of compiling/byte-coding/whatever a Python app > and call it from within Microsoft Word? What run-time is needed? > The Python interpreter *is* the run-time. You need to deploy the interpreter in order to run Python scripts. Packages like py2exe allow you to that in a way that is largely transparent to the end user. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From it at crummock.com Wed Nov 22 12:39:25 2006 From: it at crummock.com (Ross McKerchar) Date: Wed, 22 Nov 2006 11:39:25 +0000 Subject: [python-win32] Unpackaged binary version of pywin32 In-Reply-To: <455DB05B.1070601@sjsoft.com> References: <4559F3A3.3020102@crummock.com> <79990c6b0611140856x5e42dbf0g5572fd81cd9fb8ed@mail.gmail.com> <455D7908.60804@crummock.com> <455DB05B.1070601@sjsoft.com> Message-ID: <456436ED.7070406@crummock.com> David Fraser wrote: > Ross McKerchar wrote: >> If there's enough interest I'll post it for download. > I guess me asking would count as enough interest then? I'd be interested > in the setup script used for it as well... Sorry for the delay. It's all available at http://www2.crummock.com/public/rossblog.nsf/d6plinks/RCMK-6VRM2S I didn't use a setup script - just called the existing one as an "msi custom action". -ross From rikard.bosnjakovic at gmail.com Thu Nov 23 02:16:05 2006 From: rikard.bosnjakovic at gmail.com (Rikard Bosnjakovic) Date: Thu, 23 Nov 2006 02:16:05 +0100 Subject: [python-win32] Excel COM-object for cursor position Message-ID: I am going to add data row wise to Excel. Doing it manually, it would be like this: TAB TAB RETURN TAB TAB RETURN The TAB makes the cursor go to the next cell in the row, and the RETURN makes the cursor go to the next row, in the same column as the first cell. Now I need to do this in Python, but I cannot find any docs of how to get the x,y-coords of the cursor, nor how to move the cursor one cell at a time (i.e. in a relatively way). Anyone got some pointers for me? -- - Rikard. From bgailer at alum.rpi.edu Thu Nov 23 03:18:24 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Wed, 22 Nov 2006 18:18:24 -0800 Subject: [python-win32] Excel COM-object for cursor position In-Reply-To: References: Message-ID: <456504F0.5030808@alum.rpi.edu> Rikard Bosnjakovic wrote: > I am going to add data row wise to Excel. Doing it manually, it would > be like this: > > TAB TAB RETURN > TAB TAB RETURN > > The TAB makes the cursor go to the next cell in the row, and the > RETURN makes the cursor go to the next row, in the same column as the > first cell. > > Now I need to do this in Python, but I cannot find any docs of how to > get the x,y-coords of the cursor, nor how to move the cursor one cell > at a time (i.e. in a relatively way). > > Anyone got some pointers for me? > There are several ways to get stuff from Python into Excel. They include (but not limited to) running Excel as a com object or creating a file that will be read by Excel. What steps have you taken so far? We can help better if we know what route you're taking and how far along you are. -- Bob Gailer 510-978-4454 From bgailer at alum.rpi.edu Thu Nov 23 04:54:45 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Wed, 22 Nov 2006 19:54:45 -0800 Subject: [python-win32] Excel COM-object for cursor position UPDATE In-Reply-To: References: Message-ID: <45651B85.8070007@alum.rpi.edu> Rikard Bosnjakovic wrote: > I am going to add data row wise to Excel. Doing it manually, it would > be like this: > > TAB TAB RETURN > TAB TAB RETURN > > The TAB makes the cursor go to the next cell in the row, and the > RETURN makes the cursor go to the next row, in the same column as the > first cell. > > Now I need to do this in Python, but I cannot find any docs of how to > get the x,y-coords of the cursor, nor how to move the cursor one cell > at a time (i.e. in a relatively way). > I just noticed in your subject line you referred to COM-object. Sorry I overlooked that. When you work with an Office program such as Excel, you work with its DOM (Document Object Model). So please show us how far you have come with the COM program. How well you understand the DOM? You need a handle on the range and selections objects. AFAIK there is no easy way to simulate keyboard behavior, and the DOM is far more powerful. Bob Gailer 510-978-4454 From bgailer at alum.rpi.edu Thu Nov 23 20:41:11 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Thu, 23 Nov 2006 11:41:11 -0800 Subject: [python-win32] Excel COM-object for cursor position UPDATE In-Reply-To: References: <45651B85.8070007@alum.rpi.edu> Message-ID: <4565F957.5000805@alum.rpi.edu> Please reply to the list as well as me. Others learn and sometimes offer help. Rikard Bosnjakovic wrote: > > I'm an utter novice of COM/DOM and I really don't have much knowledge > about it. I know how to launch Word/Excel from Python by using > Dispatch("Excel.Application"), but that's about it. I haven't found > any reference manual for the (DOM?-)commands I can use within Excel, > except for the ones I found in a couple of tutorials similiar to this > one: http://www.markcarter.me.uk/computing/python/excel.html Where you see exactly what you want.: xlApp = Dispatch("Excel.Application") xlApp.Visible = 1 xlApp.Workbooks.Add() xlApp.ActiveSheet.Cells(1,1).Value = 'Python Rules!' The last line enters the text 'Python Rules!' in the upper left cell of the worksheet. Where do you need help with that? > > I have browsed MSDN with the hope of finding any references/short > tutorials or what so ever, but I was out of luck. I am also aware > that COM is "dead" Dead? As in no longer functioning? No way. And .NET AFAIK is no replacement for COM. > now that .NET is growing, but again; the only thing > I'm after is a bunch of small commands for me to try out so I can > automate Excel from within Python. So try the above code sample and see what happens. The DOM is documented in MSDN at: See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrcore/html/wrconexcelobjectmodeloverview.asp -- Bob Gailer 510-978-4454 From bokverket at hotmail.com Fri Nov 24 08:57:56 2006 From: bokverket at hotmail.com (Bokverket) Date: Fri, 24 Nov 2006 08:57:56 +0100 Subject: [python-win32] Compiling a Python Windows application References: Message-ID: I wrote: If you don't want to distribute the Python interpreter along with your app, Is there a well-working way of compiling/byte-coding/whatever a Python app and call it from within Microsoft Word? What run-time is needed? Tim replied: The Python interpreter *is* the run-time. You need to deploy the interpreter in order to run Python scripts. Packages like py2exe allow you to that in a way that is largely transparent to the end user. Thanks Tim for your answer, what about reaching Python from within Word? What I would like is a new menu in Word, clicking on a menu item would bring up a dialog box where the user sets some parameters , clicking OK is to start the Python app. The open Word document and the parameters need to be made available to the app. Do I have to go through Visual Basic macros to do this or is there a _good_ way?! All the best, Goran Fagerstrom From bgailer at alum.rpi.edu Fri Nov 24 18:49:52 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Fri, 24 Nov 2006 09:49:52 -0800 Subject: [python-win32] Compiling a Python Windows application In-Reply-To: References: Message-ID: <456730C0.7020105@alum.rpi.edu> Bokverket wrote: > I wrote: > > If you don't want to distribute the Python interpreter along with your app, > Is there a well-working way of compiling/byte-coding/whatever a Python app > and call it from within Microsoft Word? What run-time is needed? > > Tim replied: > The Python interpreter *is* the run-time. You need to deploy the > interpreter in order to run Python scripts. Packages like py2exe allow > you to that in a way that is largely transparent to the end user. > > > Thanks Tim for your answer, what about reaching Python from within Word? > What I would like is a new menu in Word, clicking on a menu item would bring > up a dialog box where the user sets some parameters , clicking OK is to > start the Python app. The open Word document and the parameters need to be > made available to the app. > > Do I have to go through Visual Basic macros to do this One does Word automation using VB. AFAIK there is no other way. We can help guide you thru the steps (this is how I would do it): - create UserForm(s) to collect parameters - create a custom menu using Tools -> Customize with each item tied to a macro Each macro would open a userform. The click event of the OK button on the UserForm would shell Python. A slight alternative would be to have the macros call Windows Scripting Host files that would present the dialog and shell Python. A bigger alternative would be to have the macros shell Python and write the parameter collecting mechanism in Python. > or is there a _good_ way?! I take it that you don't enjoy VB programming. It certainly is more wordy and less flexible than Python, but for relatively small tasks like this not a big deal. I've written 10s of thousands of lines of VBA for Word and Access. Of course I prefer Python when I can use it. -- Bob Gailer 510-978-4454 From nytrokiss at gmail.com Fri Nov 24 21:35:39 2006 From: nytrokiss at gmail.com (James Matthews) Date: Fri, 24 Nov 2006 15:35:39 -0500 Subject: [python-win32] Excel COM-object for cursor position UPDATE In-Reply-To: <4565F957.5000805@alum.rpi.edu> References: <45651B85.8070007@alum.rpi.edu> <4565F957.5000805@alum.rpi.edu> Message-ID: <8a6b8e350611241235s1aaf9f49m61fe30b005f37094@mail.gmail.com> Thanks helped me i was just working on that also! On 11/23/06, Bob Gailer wrote: > > Please reply to the list as well as me. Others learn and sometimes offer > help. > Rikard Bosnjakovic wrote: > > > > I'm an utter novice of COM/DOM and I really don't have much knowledge > > about it. I know how to launch Word/Excel from Python by using > > Dispatch("Excel.Application"), but that's about it. I haven't found > > any reference manual for the (DOM?-)commands I can use within Excel, > > except for the ones I found in a couple of tutorials similiar to this > > one: http://www.markcarter.me.uk/computing/python/excel.html > Where you see exactly what you want.: > > xlApp = Dispatch("Excel.Application") > xlApp.Visible = 1 > xlApp.Workbooks.Add() > xlApp.ActiveSheet.Cells(1,1).Value = 'Python Rules!' > > The last line enters the text 'Python Rules!' in the upper left cell of > the worksheet. > > Where do you need help with that? > > > > I have browsed MSDN with the hope of finding any references/short > > tutorials or what so ever, but I was out of luck. I am also aware > > that COM is "dead" > Dead? As in no longer functioning? No way. And .NET AFAIK is no > replacement for COM. > > now that .NET is growing, but again; the only thing > > I'm after is a bunch of small commands for me to try out so I can > > automate Excel from within Python. > So try the above code sample and see what happens. > > The DOM is documented in MSDN at: > > See > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrcore/html/wrconexcelobjectmodeloverview.asp > > -- > Bob Gailer > 510-978-4454 > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061124/8b5fa869/attachment.html From nytrokiss at gmail.com Sun Nov 26 00:51:43 2006 From: nytrokiss at gmail.com (James Matthews) Date: Sat, 25 Nov 2006 18:51:43 -0500 Subject: [python-win32] Compiling a Python Windows application In-Reply-To: <456730C0.7020105@alum.rpi.edu> References: <456730C0.7020105@alum.rpi.edu> Message-ID: <8a6b8e350611251551v6c5ad634uf1a5c3b797a7064b@mail.gmail.com> Try pypy On 11/24/06, Bob Gailer wrote: > > Bokverket wrote: > > I wrote: > > > > If you don't want to distribute the Python interpreter along with your > app, > > Is there a well-working way of compiling/byte-coding/whatever a Python > app > > and call it from within Microsoft Word? What run-time is needed? > > > > Tim replied: > > The Python interpreter *is* the run-time. You need to deploy the > > interpreter in order to run Python scripts. Packages like py2exe allow > > you to that in a way that is largely transparent to the end user. > > > > > > Thanks Tim for your answer, what about reaching Python from within Word? > > What I would like is a new menu in Word, clicking on a menu item would > bring > > up a dialog box where the user sets some parameters , clicking OK is to > > start the Python app. The open Word document and the parameters need > to be > > made available to the app. > > > > Do I have to go through Visual Basic macros to do this > One does Word automation using VB. AFAIK there is no other way. > We can help guide you thru the steps (this is how I would do it): > - create UserForm(s) to collect parameters > - create a custom menu using Tools -> Customize with each item tied to a > macro > Each macro would open a userform. The click event of the OK button on > the UserForm would shell Python. > > A slight alternative would be to have the macros call Windows Scripting > Host files that would present the dialog and shell Python. > > A bigger alternative would be to have the macros shell Python and write > the parameter collecting mechanism in Python. > > > or is there a _good_ way?! > I take it that you don't enjoy VB programming. It certainly is more > wordy and less flexible than Python, but for relatively small tasks like > this not a big deal. I've written 10s of thousands of lines of VBA for > Word and Access. Of course I prefer Python when I can use it. > > -- > Bob Gailer > 510-978-4454 > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061125/2062ea2a/attachment.htm From kostas.eleftheriou at gmail.com Mon Nov 27 14:05:13 2006 From: kostas.eleftheriou at gmail.com (Kostas Eleftheriou) Date: Mon, 27 Nov 2006 13:05:13 +0000 Subject: [python-win32] pythoncom multithread troubles Message-ID: <87f63b400611270505i7d71ea5ei7cd2d041ceeef980@mail.gmail.com> Hi, I have built a python application that uses a COM server from multiple threads, and despite some initial problems, I got it to work. I found out (the hard way) that the COM server would have undefined behaviour if some of its functions were called at the same time form multiple threads (so it was not thread-safe, although from the registry keys it looked as if it was), so I made the calls from my application sequential using locks etc. Although that is now working fine, I would be really happy if I could drop this sequential performance hit, from within my multithreaded python process. After some experimenting, it seems that launching mulitple python *processes* and using the COM server, works without any issues (as it was expected, since my understanding is that no matter what the threading model of a COM server is, when used by different processes there should be no interference. note I am new to COM and likely to be wrong). I need to do this without launching seperate processes, or if thats the only way, then to easily be able to do inter-proc communication (last resort only) The COM server is inproc (dll), and I can not modify it. What I have tried: - Use DispatchEx instead of Dispatch: this works with other COM servers, like MS Word and Excel, but not with mine. Probalby has to do with the fact that they are local servers, whereas mine is inproc. - CoInitialize, CoInitializeEx with flags: no luck - using CoGetClassObject instead of CoCreateInstance in pythoncom, since I read that this would be the way to go if you require multiple instances of a server: I didnt manage to get it working because the return type is different to that of CoCreateInstance and I dont know how to deal with this (ctypes) - CoCreateInstanceEx: no luck In short I am looking for a way to always get a new instance of the COM server when using dispatch, even if it is inproc. I am open to any suggestions and corrections to my limited COM knowledge From andrea.gavana at gmail.com Mon Nov 27 14:07:57 2006 From: andrea.gavana at gmail.com (Andrea Gavana) Date: Mon, 27 Nov 2006 13:07:57 +0000 Subject: [python-win32] Pythoncom error with Excel Message-ID: Hi all, I have built a script that communicates with Excel and plots some data using win32com. Everything goes fine as long as the data series do not contain many points. If I have more that few points (let's say 50 points to plot), I get this error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Office Excel', 'Unable to set the XValues property of the Series class', 'C:\\Program Files\\Microsoft Office\\OFFICE11\\1033\\xlmain11.chm', 0, -2146827284), None) I am trying to plot 50 dates (from 2006 to 2060) with their corresponding data point. Is there a maximum number of points that can be passed to Excel? Is there any limitation in this sense? What could I do to overcome this limitations? Thank you very much. -- Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.virgilio.it/infinity77/ From theller at ctypes.org Mon Nov 27 15:39:07 2006 From: theller at ctypes.org (Thomas Heller) Date: Mon, 27 Nov 2006 15:39:07 +0100 Subject: [python-win32] pythoncom multithread troubles In-Reply-To: <87f63b400611270505i7d71ea5ei7cd2d041ceeef980@mail.gmail.com> References: <87f63b400611270505i7d71ea5ei7cd2d041ceeef980@mail.gmail.com> Message-ID: <456AF88B.1010506@ctypes.org> Kostas Eleftheriou schrieb: > Hi, > > I have built a python application that uses a COM server from multiple > threads, and despite some initial problems, I got it to work. I found > out (the hard way) that the COM server would have undefined behaviour > if some of its functions were called at the same time form multiple > threads (so it was not thread-safe, although from the registry keys it > looked as if it was), so I made the calls from my application > sequential using locks etc. The most important thing to remember is that you *MUST* marshal com pointers correctly between the different com apartments. Thomas From kostas.eleftheriou at gmail.com Mon Nov 27 16:49:08 2006 From: kostas.eleftheriou at gmail.com (Kostas Eleftheriou) Date: Mon, 27 Nov 2006 15:49:08 +0000 Subject: [python-win32] pythoncom multithread troubles In-Reply-To: <456AF88B.1010506@ctypes.org> References: <87f63b400611270505i7d71ea5ei7cd2d041ceeef980@mail.gmail.com> <456AF88B.1010506@ctypes.org> Message-ID: <87f63b400611270749g2934fa71r2b77924d5881f6ad@mail.gmail.com> Hello Thomas, Thanks for your quick reply. I do not marshal anything because I don't need to pass objects between threads, each thread currently only deals with its own objects. I have also tried using a surrogate process to host the dll server (dllhost.exe) through the registry, but although the server is now launched in a seperate process, I still only get one process no matter how many DispatchEx calls I make from different threads. On 11/27/06, Thomas Heller wrote: > Kostas Eleftheriou schrieb: > > Hi, > > > > I have built a python application that uses a COM server from multiple > > threads, and despite some initial problems, I got it to work. I found > > out (the hard way) that the COM server would have undefined behaviour > > if some of its functions were called at the same time form multiple > > threads (so it was not thread-safe, although from the registry keys it > > looked as if it was), so I made the calls from my application > > sequential using locks etc. > > The most important thing to remember is that you *MUST* marshal com pointers > correctly between the different com apartments. > > Thomas > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From bokverket at hotmail.com Mon Nov 27 21:56:10 2006 From: bokverket at hotmail.com (Bokverket) Date: Mon, 27 Nov 2006 21:56:10 +0100 Subject: [python-win32] Compiling a Python Windows application References: <456730C0.7020105@alum.rpi.edu> Message-ID: > Do I have to go through Visual Basic macros to do this One does Word automation using VB. AFAIK there is no other way. We can help guide you thru the steps (this is how I would do it): - create UserForm(s) to collect parameters - create a custom menu using Tools -> Customize with each item tied to a macro Each macro would open a userform. The click event of the OK button on the UserForm would shell Python. A slight alternative would be to have the macros call Windows Scripting Host files that would present the dialog and shell Python. A bigger alternative would be to have the macros shell Python and write the parameter collecting mechanism in Python. > or is there a _good_ way?! I take it that you don't enjoy VB programming. It certainly is more wordy and less flexible than Python, but for relatively small tasks like this not a big deal. I've written 10s of thousands of lines of VBA for Word and Access. Of course I prefer Python when I can use it. ------------- ME: Thanks very much for responding, Bob and James! I did program a lot in VB's earlier versions, but it has grown... My reason for not considering VB was that the actual processing would make excellent use of the Python collection objects /dictionaries/, which in my mind would hold words of the Microsoft Word document. (The app's purpose is to analyze words of possibly very large Word documents.) Plus I suppose that a macro which would loop with a few lines over each word of the doc will be slow, although I don't if there is a compiling or byte-code mechanism. Am I wrong? I don't know if having a VB as glue to shelling Python is perfectly fine performance-wise, and it certainly would be a simple way to handle the dialog boxes that collect the parameters. Maybe that is a much better way than wondering about calling Python /shelling, calling a DLL, whatever/ directly. Next question: Is Microsoft Word's API for Python published like for VB and easy to use? Best, G?ran /Goran with two dots/ :-) Stockholm, Sweden From bgailer at alum.rpi.edu Mon Nov 27 23:56:53 2006 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Mon, 27 Nov 2006 14:56:53 -0800 Subject: [python-win32] Compiling a Python Windows application In-Reply-To: References: <456730C0.7020105@alum.rpi.edu> Message-ID: <456B6D35.3070401@alum.rpi.edu> Bokverket wrote: > I did program a lot in VB's earlier versions, but it has grown... My > reason > for not considering VB was that the actual processing would make excellent > use of the Python collection objects /dictionaries/, which in my mind would > hold words of the Microsoft Word document. Are you aware that VBA with the scripting runtime offers dictionary object almost identical to Python's dict? Here is a VB Sub that counts the words in the document: Sub test() Dim d As Document, w As Variant, w2 As String Set dict = CreateObject("Scripting.Dictionary") Set d = Documents(1) For Each w In d.Range().Words w2 = Trim(w) If dict.Exists(w2) Then dict(w2) = dict(w2) + 1 Else dict(w2) = 0 End If Next End Sub For my test document of about 21000 occurrences of 120 words this took about 5 seconds. The Python equivalent takes 0.15 seconds. >>> import time >>> import win32com.client >>> a = win32com.client.Dispatch("word.application") >>> d = a.Documents(1) # wrap the process to get the text from the document, split it into words and build the dictionary >>> def f(): ... t=time.time() ... s=d.Range().Text ... w=s.split() ... wd={} ... for i in w: ... wd[i]=wd.setdefault(i,0)+1 ... print time.time()-t ... >>> f() 0.15700006485 > (The app's purpose is to analyze words of possibly very large Word documents.) Plus I suppose that a macro which would loop with a few lines over each word of the doc will be slow, although I don't if there is a compiling or byte-code mechanism. Am I wrong? > > I don't know if having a VB as glue to shelling Python is perfectly fine > performance-wise, and it certainly would be a simple way to handle the > dialog boxes that collect the parameters. Maybe that is a much better way > than wondering about calling Python /shelling, calling a DLL, whatever/ > directly. > > Next question: Is Microsoft Word's API for Python published like for VB and > easy to use? > Word has one API. It is what is published for VB. Your Python program would use win32com.client to launch Word as a COM server, then interact with it the same as a VB program (well, almost the same). For this you need pywin32 http://sourceforge.net/projects/pywin32/. import win32com.client application = win32com.client.Dispatch("word.application") # application is the same as the application object you see at the top of the word DOM in VB. document = application.Documents.Add() # to create a new document OR .Documents.Open(filename) to open an existing document. # OR if word is already running you can access an existing document using .Documents(indexno OR name) # how is different from VB? objects do not have default properties. Must be explicit. No set statement. Functions and subs must have the () appended. Hope that's enough to get you started. Since your goal seems to be text processing I'd think you'd want to read the entire document text into a Python string, then manipulate that. text = document.Range().Text will get all the text of the document body. (excludes header/footer). Note that paragraph breaks are \r, and that table cells end in \r\x07. -- Bob Gailer 510-978-4454 From mhammond at skippinet.com.au Tue Nov 28 02:52:20 2006 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 28 Nov 2006 12:52:20 +1100 Subject: [python-win32] pythoncom multithread troubles In-Reply-To: <87f63b400611270505i7d71ea5ei7cd2d041ceeef980@mail.gmail.com> Message-ID: <603c01c7128f$d8362980$0c0a0a0a@enfoldsystems.local> > What I have tried: > > - Use DispatchEx instead of Dispatch: this works with other COM > servers, like MS Word and Excel, but not with mine. Probalby has to do > with the fact that they are local servers, whereas mine is inproc. > > - CoInitialize, CoInitializeEx with flags: no luck > > - using CoGetClassObject instead of CoCreateInstance in pythoncom, > since I read that this would be the way to go if you require multiple > instances of a server: I didnt manage to get it working because the > return type is different to that of CoCreateInstance and I dont know > how to deal with this (ctypes) > > - CoCreateInstanceEx: no luck > > In short I am looking for a way to always get a new instance of the > COM server when using dispatch, even if it is inproc. I am open to any > suggestions and corrections to my limited COM knowledge Try looking at the source to win32com.client.Dispatch, and see how it first tries GetActiveObject() - try just calling CoCreateInstance() without the check for GetActiveObject. If that doesn't work, I'm afraid you are probably SOL - it would be the object itself implementing these semantics and therefore hard to defeat. HTH, Mark From Avery.Andrews at anu.edu.au Tue Nov 28 03:35:56 2006 From: Avery.Andrews at anu.edu.au (Avery.Andrews at anu.edu.au) Date: Tue, 28 Nov 2006 13:35:56 +1100 (EST) Subject: [python-win32] _winreg.LoadKey Message-ID: Does anyone know how to use _winreg.Loadkey, or whether it is even implemented properly, in 2.4.2 and 2.5 (the fact that it is named wrong in the Docs and not covered in the test suites doesn't inspire confidence). I find that I can use it to load a key into the top level (HKEY_LOCAL_MACHINE), but that various things don't appear to be released properly when Python exits, in that neither the key itself can be changed with regedt32, nor the file it was read in from deleted (due to being in use by another process), until the system is rebooted. This happens under both Win2000 and Win XP Pro. And I can't find any way to load a subkey, e.g. code like this fails: key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE') _winreg.LoadKey( key, 'My key', 'mykey' ) as does: key = _winreg.LoadKey( _winreg.HKEY_LOCAL_MACHINE, 'Software\\My key', 'mykey' ) both producing Access Denied errors. - thanks From rwupole at msn.com Tue Nov 28 04:25:04 2006 From: rwupole at msn.com (Roger Upole) Date: Mon, 27 Nov 2006 22:25:04 -0500 Subject: [python-win32] Re: _winreg.LoadKey Message-ID: Avery.Andrews wrote: > Does anyone know how to use _winreg.Loadkey, or whether it is even > implemented properly, in 2.4.2 and 2.5 (the fact that it is named > wrong in the Docs and not covered in the test suites doesn't inspire > confidence). > > I find that I can use it to load a key into the top level > (HKEY_LOCAL_MACHINE), but that various things don't appear > to be released properly when Python exits, in that neither the > key itself can be changed with regedt32, nor the file it > was read in from deleted (due to being in use by another process), > until the system is rebooted. You'll need to call RegUnloadKey yourself to release it. This doesn't seem to be wrapped in _winreg, but you can use win32api.RegUnloadKey. > This happens under both Win2000 and Win XP Pro. > > And I can't find any way to load a subkey, e.g. code like this > fails: > > key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE') > > _winreg.LoadKey( > key, 'My key', > 'mykey' > ) > > as does: > > key = _winreg.LoadKey( > _winreg.HKEY_LOCAL_MACHINE, 'Software\\My key', > 'mykey' > ) > > both producing Access Denied errors. According to the docs, you can only load a key directly under HKEY_USERS or HKLM. Roger From nytrokiss at gmail.com Tue Nov 28 05:50:55 2006 From: nytrokiss at gmail.com (James Matthews) Date: Mon, 27 Nov 2006 23:50:55 -0500 Subject: [python-win32] Compiling a Python Windows application In-Reply-To: <456B6D35.3070401@alum.rpi.edu> References: <456730C0.7020105@alum.rpi.edu> <456B6D35.3070401@alum.rpi.edu> Message-ID: <8a6b8e350611272050r160fa8fex27ce29d96ac69106@mail.gmail.com> thanks always here to help On 11/27/06, Bob Gailer wrote: > > Bokverket wrote: > > I did program a lot in VB's earlier versions, but it has grown... My > > reason > > for not considering VB was that the actual processing would make > excellent > > use of the Python collection objects /dictionaries/, which in my mind > would > > hold words of the Microsoft Word document. > Are you aware that VBA with the scripting runtime offers dictionary > object almost identical to Python's dict? Here is a VB Sub that counts > the words in the document: > > Sub test() > Dim d As Document, w As Variant, w2 As String > Set dict = CreateObject("Scripting.Dictionary") > Set d = Documents(1) > For Each w In d.Range().Words > w2 = Trim(w) > If dict.Exists(w2) Then > dict(w2) = dict(w2) + 1 > Else > dict(w2) = 0 > End If > Next > End Sub > > For my test document of about 21000 occurrences of 120 words this took > about 5 seconds. The Python equivalent takes 0.15 seconds. > >>> import time > >>> import win32com.client > >>> a = win32com.client.Dispatch("word.application") > >>> d = a.Documents(1) > # wrap the process to get the text from the document, split it into > words and build the dictionary > >>> def f(): > ... t=time.time() > ... s=d.Range().Text > ... w=s.split() > ... wd={} > ... for i in w: > ... wd[i]=wd.setdefault(i,0)+1 > ... print time.time()-t > ... > >>> f() > 0.15700006485 > > > (The app's purpose is to analyze words of possibly very large Word > documents.) Plus I suppose that a macro which would loop with a few lines > over each word of the doc will be slow, although I don't if there is a > compiling or byte-code mechanism. Am I wrong? > > > > > I don't know if having a VB as glue to shelling Python is perfectly fine > > performance-wise, and it certainly would be a simple way to handle the > > dialog boxes that collect the parameters. Maybe that is a much better > way > > than wondering about calling Python /shelling, calling a DLL, whatever/ > > directly. > > > > Next question: Is Microsoft Word's API for Python published like for VB > and > > easy to use? > > > Word has one API. It is what is published for VB. Your Python program > would use win32com.client to launch Word as a COM server, then interact > with it the same as a VB program (well, almost the same). For this you > need pywin32 http://sourceforge.net/projects/pywin32/. > > import win32com.client > application = win32com.client.Dispatch("word.application") > # application is the same as the application object you see at the top > of the word DOM in VB. > document = application.Documents.Add() # to create a new document OR > .Documents.Open(filename) to open an existing document. > # OR if word is already running you can access an existing document > using .Documents(indexno OR name) > > # how is different from VB? objects do not have default properties. Must > be explicit. No set statement. Functions and subs must have the () > appended. > > Hope that's enough to get you started. > > Since your goal seems to be text processing I'd think you'd want to read > the entire document text into a Python string, then manipulate that. > text = document.Range().Text will get all the text of the document body. > (excludes header/footer). Note that paragraph breaks are \r, and that > table cells end in \r\x07. > > -- > Bob Gailer > 510-978-4454 > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- http://www.goldwatches.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061127/b3dc0377/attachment.html From bruce.who.hk at gmail.com Tue Nov 28 06:08:52 2006 From: bruce.who.hk at gmail.com (Bruce Who) Date: Tue, 28 Nov 2006 13:08:52 +0800 Subject: [python-win32] how to get the interface of an COM object? In-Reply-To: References: Message-ID: HI,all Finally, I make it work with comtypes. All COM interfaces are available and events can also be handled. Thanks for Thomas's help, :-) On 11/14/06, Bruce Who wrote: > Hi, all > > I am trying to use win32com to interact with a proprietary COM object. > progID of the coclass is "SomeObj2.SomeObj.1", I can create the > coclass but am not able to access other interfaces via > win32com.client.CastTo(). > > For example ISomeInterface is one of this COM object's interfaces. But > no classes are generated for this interface in the file made by > makepy.py. I can only find things like this: > > ISomeInterface_vtables_dispatch_, ISomeInterface_vtables_ > > this is my code: > > te = win32com.client.Dispatch("SomeObj2.SomeObj.1") > # fail! Error message is: > # ... > # return mapCLSIDToClass[clsid] > # KeyError: '{84AE9D10-95AD-13D5-88C1-0003025952C1}' > ISomeInterface_ = win32com.client.CastTo(te, 'ISomeInterface') > > > in the file generated by makepy.py, the class is very simple: > > class SomeObj(CoClassBaseClass): # A CoClass > CLSID = IID('{7A4F5191-68A8-14D5-82C1-0001083952C1}') > coclass_sources = [ > _SomeObjEvents2, > _SomeObjEvents, > _SomeObjEvents4, > _SomeObjEvents5, > _SomeObjEvents3, > ] > default_source = _SomeObjEvents5 > coclass_interfaces = [ > ] > > I googled the web and find some old posts in this maillist, it seems > that only interfaces inherit from IDispatch can be used by pythonCOM, > and interfaces here inherits from IUnknown. But I just need to use > these interfaces, so could anybody tell me how to do it? > > And this control and its interfaces are all available to VBScript or > Visual Bacis: > > Set ISomeInterface_ = SomeObj.interface("ISomeInterface") > ... > CLASSID="CLSID:7A4F5191-68A8-14D5-82C1-0001083952C1" > > > Since VBScript and python are both script languages, I guess python > can also access these interfaces. > > Any help would be appreciated! > > Bruce > From axiomx11 at gmail.com Tue Nov 28 14:47:13 2006 From: axiomx11 at gmail.com (Axiom X11) Date: Tue, 28 Nov 2006 08:47:13 -0500 Subject: [python-win32] Bring EasyDialogs into focus Message-ID: <70b542190611280547j38ffc739xc6cb93cb81ba9b54@mail.gmail.com> I have started using EasyDialogs instead of GTK to open a file on Windows. It works great, but my problem is, when the dialog is spawned, it goes behind all the current open windows, so that the user doesn't see it. This is my code: file = EasyDialogs.AskFileForOpen(defaultLocation="c:\\") Any way to force it to come to the front? (The python program I am doing here is part of a larger program that has no interface of its own, and runs silently until the file dialog is called.) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20061128/d6ccb616/attachment.htm From gagsl-p32 at yahoo.com.ar Wed Nov 29 11:49:46 2006 From: gagsl-p32 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 29 Nov 2006 07:49:46 -0300 Subject: [python-win32] Compiling a Python Windows application In-Reply-To: <8a6b8e350611251551v6c5ad634uf1a5c3b797a7064b@mail.gmail.co m> References: <456730C0.7020105@alum.rpi.edu> <8a6b8e350611251551v6c5ad634uf1a5c3b797a7064b@mail.gmail.com> Message-ID: <7.0.1.0.0.20061129074822.053bcc60@yahoo.com.ar> At Saturday 25/11/2006 20:51, James Matthews wrote: >Try pypy In what way would PyPy help? > > Thanks Tim for your answer, what about reaching Python from within Word? > > What I would like is a new menu in Word, clicking on a menu item > would bring > > up a dialog box where the user sets some parameters , clicking OK is to > > start the Python app. The open Word document and the parameters > need to be > > made available to the app.> -- Gabriel Genellina Softlab SRL __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ?gratis! ?Abr? tu cuenta ya! - http://correo.yahoo.com.ar From timr at probo.com Thu Nov 30 19:13:33 2006 From: timr at probo.com (Tim Roberts) Date: Thu, 30 Nov 2006 10:13:33 -0800 Subject: [python-win32] _winreg.LoadKey In-Reply-To: References: Message-ID: <456F1F4D.7060500@probo.com> Avery.Andrews at anu.edu.au wrote: > Does anyone know how to use _winreg.Loadkey, or whether it is even > implemented properly, in 2.4.2 and 2.5 (the fact that it is named > wrong in the Docs and not covered in the test suites doesn't inspire > confidence). > > I find that I can use it to load a key into the top level > (HKEY_LOCAL_MACHINE), but that various things don't appear > to be released properly when Python exits, in that neither the > key itself can be changed with regedt32, nor the file it > was read in from deleted (due to being in use by another process), > until the system is rebooted. > That last item is to be expected. When you load a key like this, your file becomes part of the live registry. The registry service will map the file into memory and keep it open until the key is unloaded. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc.