From janssen at parc.com Sat May 1 00:43:09 2010 From: janssen at parc.com (Bill Janssen) Date: Fri, 30 Apr 2010 15:43:09 PDT Subject: [python-win32] CPython on Windows Azure? Message-ID: <42809.1272667389@parc.com> Has anyone looked into getting CPython and pywin32 installed on a Windows Azure service platform? I foresee some difficulties here; for one thing, you can't run an installer, and for another, you can't install into C:/WINDOWS/system32/. Bill From lewispusey at earthlink.net Sun May 2 01:48:10 2010 From: lewispusey at earthlink.net (Lewis Pusey) Date: Sat, 1 May 2010 19:48:10 -0400 Subject: [python-win32] MFCC71.DLL Errors Message-ID: Weh trying to run pythonwin in windows 7 64 I get "program cannot start because of missing MFCC71.DLL" error. I tried reinstalling pythonwin after addingy the DLL to my system 32 folder but am still getting the same error. I wondered if anyone one the board would know what the fix might be? Thanks, Lewis -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sun May 2 20:51:24 2010 From: timr at probo.com (Tim Roberts) Date: Sun, 02 May 2010 11:51:24 -0700 Subject: [python-win32] MFCC71.DLL Errors In-Reply-To: References: Message-ID: <4BDDC9AC.9050809@probo.com> Lewis Pusey wrote: > Weh trying to run pythonwin in windows 7 64 I get "program cannot > start because of missing MFCC71.DLL" error. > I tried reinstalling pythonwin after addingy the DLL to my system 32 > folder but am still getting the same error. > I wondered if anyone one the board would know what the fix might be? If you are running the 32-bit Pythonwin, then you need to add the 32-bit MFC71.DLL to the \Windows\SysWow64 folder, not System32. Yes, 64-bit things go in System32, and 32-bit things go in SysWow64. Believe it or not. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mc at mclaveau.com Mon May 3 12:21:26 2010 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 3 May 2010 12:21:26 +0200 Subject: [python-win32] Saving (publishing) an Excel or Word 2007 file as aPDF document. In-Reply-To: References: Message-ID: Hi! Try (Excel_2007): xlTypePDF=0 objExcel.ActiveWorkbook.ExportAsFixedFormat(xlTypePDF,"C:\\monexcel.pdf") @-salutations -- Michel Claveau From lewispusey at earthlink.net Mon May 3 13:57:44 2010 From: lewispusey at earthlink.net (Lewis Pusey) Date: Mon, 3 May 2010 07:57:44 -0400 Subject: [python-win32] python-win32 Digest, Vol 86, Issue 3 In-Reply-To: References: Message-ID: Thanks for the reply, I'll give it a whirl. I thought WOW was world of warcraft for some reason. Lewis On Mon, May 3, 2010 at 6:00 AM, wrote: > Send python-win32 mailing list submissions to > python-win32 at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-win32 > or, via email, send a message with subject or body 'help' to > python-win32-request at python.org > > You can reach the person managing the list at > python-win32-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of python-win32 digest..." > > > Today's Topics: > > 1. Re: MFCC71.DLL Errors (Tim Roberts) > 2. Saving (publishing) an Excel or Word 2007 file as a PDF > document. (Andrew Spagnoletti) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 02 May 2010 11:51:24 -0700 > From: Tim Roberts > To: Python-Win32 List > Subject: Re: [python-win32] MFCC71.DLL Errors > Message-ID: <4BDDC9AC.9050809 at probo.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Lewis Pusey wrote: > > Weh trying to run pythonwin in windows 7 64 I get "program cannot > > start because of missing MFCC71.DLL" error. > > I tried reinstalling pythonwin after addingy the DLL to my system 32 > > folder but am still getting the same error. > > I wondered if anyone one the board would know what the fix might be? > > If you are running the 32-bit Pythonwin, then you need to add the 32-bit > MFC71.DLL to the \Windows\SysWow64 folder, not System32. > > Yes, 64-bit things go in System32, and 32-bit things go in SysWow64. > Believe it or not. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > > > ------------------------------ > > Message: 2 > Date: Fri, 30 Apr 2010 15:59:29 +0200 > From: Andrew Spagnoletti > To: python-win32 at python.org > Subject: [python-win32] Saving (publishing) an Excel or Word 2007 file > as a PDF document. > Message-ID: > > Content-Type: text/plain; charset="iso-8859-1" > > Hi, > > Can anyone help me with the correct Python (2.5.4) syntax for the above? > > In my program I currently use > > "self.workbook.SaveAs(self.saveName)" (which saves it as a normal Excel > file) > > after opening Excel with Dispatch and managing it from within my program - > where 'saveName' has the suffix '.xlsx', > > but I want to save this file as a PDF file (the functions is installed in > Excel and can be saved from Excel directly, by selection PDF from the Save > option). > > Regards, > > Andrew. > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/python-win32/attachments/20100430/8b290b94/attachment-0001.html > > > > ------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > End of python-win32 Digest, Vol 86, Issue 3 > ******************************************* > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdriscoll at co.marshall.ia.us Mon May 3 17:31:46 2010 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Mon, 03 May 2010 10:31:46 -0500 Subject: [python-win32] Setting UserInitials in Office In-Reply-To: <4BD837EB.6030002@timgolden.me.uk> References: <4BD60631.70104@co.marshall.ia.us> <4BD61A23.4010900@probo.com> <4BD6979A.4000002@timgolden.me.uk> <4BD75A7E.90906@probo.com> <4BD7E6B6.1070704@timgolden.me.uk> <4BD836D8.5050005@co.marshall.ia.us> <4BD837EB.6030002@timgolden.me.uk> Message-ID: <4BDEEC62.9020308@co.marshall.ia.us> On 1:59 PM, Tim Golden wrote: > On 28/04/2010 14:23, Mike Driscoll wrote: >> >> Sorry for the delay in checking this out. I was out of the office >> yesterday. Your code almost worked for reading the key, but I get a >> tuple back: > > [goes back to check what he wrote...] > > That's why my code does this (note the nearly-invisible > underscore before the equals), discarding the datatype > value which is the second item of the tuple returned: > > username, _ = _winreg.QueryValueEx (k, "UserName") > > TJG > Ah...I must have had something in my eye at the time. Anyway, I figured out how to get the information from it, but not how to write it. I tried writing to the Registry using _winreg.SetValueEx and passed a plain string and then various encoded strings (like utf16, utf32, etc). It writes just fine, but if I open Microsoft Word and check for the new initials or Full Name, Word just shows junk. - Mike From timr at probo.com Mon May 3 18:34:39 2010 From: timr at probo.com (Tim Roberts) Date: Mon, 03 May 2010 09:34:39 -0700 Subject: [python-win32] MFCC71.DLL Errors In-Reply-To: References: Message-ID: <4BDEFB1F.5040804@probo.com> Lewis Pusey wrote: > Thanks for the reply, I'll give it a whirl. I thought WOW was world of > warcraft for some reason. "Windows On Windows". They used the same name to describe 16-bit Windows applications running in the Win32 subsystem. And please note the instructions: > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of python-win32 digest..." > -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon May 3 18:43:56 2010 From: timr at probo.com (Tim Roberts) Date: Mon, 03 May 2010 09:43:56 -0700 Subject: [python-win32] Setting UserInitials in Office In-Reply-To: <4BDEEC62.9020308@co.marshall.ia.us> References: <4BD60631.70104@co.marshall.ia.us> <4BD61A23.4010900@probo.com> <4BD6979A.4000002@timgolden.me.uk> <4BD75A7E.90906@probo.com> <4BD7E6B6.1070704@timgolden.me.uk> <4BD836D8.5050005@co.marshall.ia.us> <4BD837EB.6030002@timgolden.me.uk> <4BDEEC62.9020308@co.marshall.ia.us> Message-ID: <4BDEFD4C.8000206@probo.com> Mike Driscoll wrote: > > Ah...I must have had something in my eye at the time. Anyway, I > figured out how to get the information from it, but not how to write > it. I tried writing to the Registry using _winreg.SetValueEx and > passed a plain string and then various encoded strings (like utf16, > utf32, etc). It writes just fine, but if I open Microsoft Word and > check for the new initials or Full Name, Word just shows junk. This works: _winreg.SetValueEx( k, "UserInitials", 0, _winreg.REG_BINARY, u"timr\0" ) Note the trailing 0. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jn.ml.pyw32.88 at wingsandbeaks.org.uk Mon May 3 22:28:44 2010 From: jn.ml.pyw32.88 at wingsandbeaks.org.uk (Jeremy Nicoll - ml pyw32) Date: Mon, 3 May 2010 21:28:44 +0100 Subject: [python-win32] Finding DLL's which are in use (loaded) In-Reply-To: References: Message-ID: Tony Cappellini wrote: > I need to write a program which copies some dlls from one location to > another. However, if any applications which use these dll's are > running, > Windows won't let the dll copy complete, until the apps which have the > dlls loaded have terminated. > I'm looking for a way to scan/probe to see if any apps are running > which have these dll's loaded. > How would I go about this with Python ? I might be inclined to use something else, for example SysInternals' 'handle' program. Here for example executing handle -a .dll looks for all handles that are for something which includes ".dll" in its name. Here, now, for example, that gives: System pid: 4 350: C:\WINDOWS\system32\ntdll.dll lsass.exe pid: 740 8C: HKLM\SYSTEM\ControlSet005\Control\Lsa\SspiCache\msapsspc.dll lsass.exe pid: 740 90: HKLM\SYSTEM\ControlSet005\Control\Lsa\SspiCache\msnsspc.dll lsass.exe pid: 740 98: HKLM\SYSTEM\ControlSet005\Control\Lsa\SspiCache\digest.dll Dropbox.exe pid: 2828 534: C:\WINDOWS\system32\hnetcfg.dll (as those lines were too long for my email client's write window, and wrapped, I've spaced them out) Executing the handle command and redirecting its output to a file which you then read might work for you. -- Jeremy C B Nicoll - my opinions are my own. From stef.mientki at gmail.com Mon May 3 22:40:27 2010 From: stef.mientki at gmail.com (Stef Mientki) Date: Mon, 03 May 2010 22:40:27 +0200 Subject: [python-win32] how to get access to someone's else Outlook Calendar ? In-Reply-To: <4BD93060.3060301@gmail.com> References: <4BD88DB3.6070605@gmail.com> <4BD93060.3060301@gmail.com> Message-ID: <4BDF34BB.6020206@gmail.com> On 29-04-2010 09:08, Mark Hammond wrote: > IIRC, the outlook application doesn't support a Logon. Your best bet > is probably to try and find some examples in VBScript or any other > language and then translate the knowledge that gives you into Python. thanks Mark, that was a very good hint. I found this VB script: http://www.outlookcode.com/codedetail.aspx?id=43 rewritten into Python (see code below, needs some refactoring), works great !! Now one small question, how do I get those constants, like constants.olFolderCalendar (=9) ? thanks, Stef Mientki outlook = win32com.client.Dispatch("Outlook.Application") namespace = outlook.GetNamespace("MAPI") print dir(constants) Item = outlook.CreateItem ( 1 ) #constants.olAppointmentItem ) #olMailItem) Recip = Item.Recipients.Add ( 'Klaasen, Jan' ) # <== this is not me, but some other !! Recip.Resolve () if Recip.Resolved : Folder = namespace.GetSharedDefaultFolder ( Recip, 9 ) #constants.olFolderCalendar ) print Folder afspraken = Folder.Items afspraken.Sort("[Start]") ##afspraken.IncludeRecurrences = "True" #Possible columns are Subject, Location, Start, End, Recurrence Pattern, Categories afspraak = afspraken.GetFirst() while afspraak: start = datetime.datetime.fromtimestamp (int (afspraak.Start)) subject = afspraak.Subject.encode("utf-8") print '===', start, subject afspraak = afspraken.GetNext() if start.year >2011: #nextYear: #avoid to loop until 2038 :-) break > > HTH, > > Mark > > On 29/04/2010 5:34 AM, Stef Mientki wrote: >> hello, >> >> I want to control a number Outlook Calendars from different persons, >> and I have access privilges and can manipulate them through Outlook. >> Now I want to control them through Python. From contact at vaidabogdan.com Mon May 3 16:06:05 2010 From: contact at vaidabogdan.com (Vaida Bogdan) Date: Mon, 3 May 2010 17:06:05 +0300 Subject: [python-win32] problems with win32comext\taskscheduler on windows 2008 References: Message-ID: > Hi, I have a problem with my taskscheduler library: it works on Windows XP but upon entering the 2008 land my task gets created without any triggers. I've ran the same commands I ran on XP but the task doesn't get created. > > http://pastebin.com/bmg847hw > > This on XP (and 2003 Server) creates a task with a trigger to execute daily while on Server 2008 I get the task created but with no triggers. > > The account on 2008 has Administrator privileges and UAC are disabled. > > I'd very much appreciate any ideas on how to solve this. -------------- next part -------------- An HTML attachment was scrubbed... URL: From janssen at parc.com Tue May 4 00:42:59 2010 From: janssen at parc.com (Bill Janssen) Date: Mon, 3 May 2010 15:42:59 PDT Subject: [python-win32] finding pythonXX.dll? Message-ID: <91956.1272926579@parc.com> Is there anyway to tell, from inside Python, where the python26.dll file is? I've got to install the win32 dlls in the same directory. I see that sys contains a symbol "dllhandle", but that's just a numeric handle. Bill From rwupole at msn.com Tue May 4 05:00:28 2010 From: rwupole at msn.com (Roger Upole) Date: Mon, 3 May 2010 23:00:28 -0400 Subject: [python-win32] finding pythonXX.dll? Message-ID: Bill Janssen wrote: > Is there anyway to tell, from inside Python, where the python26.dll file > is? I've got to install the win32 dlls in the same directory. > > I see that sys contains a symbol "dllhandle", but that's just a numeric > handle. > > Bill win32api.GetModuleFileName(sys.dllhandle) Roger From rwupole at msn.com Tue May 4 06:08:13 2010 From: rwupole at msn.com (Roger Upole) Date: Tue, 4 May 2010 00:08:13 -0400 Subject: [python-win32] problems with win32comext\taskscheduler on windows Message-ID: Does job.GetTriggerCount() return 1 ? If it does, but the trigger doesn't appear in the Task Scheduler UI, most likely there's something it doesn't like about the trigger's flags. Roger From contact at vaidabogdan.com Tue May 4 11:29:06 2010 From: contact at vaidabogdan.com (Vaida Bogdan) Date: Tue, 4 May 2010 12:29:06 +0300 Subject: [python-win32] problems with win32comext\taskscheduler on windows In-Reply-To: References: Message-ID: It seems that the Task Scheduler 2.0 enum types in TASK_TRIGGER_TYPE2 are not implemented: These are for Task Scheduler 1.0 $ grep -rni TASK_TIME_TRIGGER_DAILY * com/win32comext/taskscheduler/src/PyITaskTrigger.cpp:129: "TASK_TIME_TRIGGER_ONCE,TASK_TIME_TRIGGER_DAILY,\n" com/win32comext/taskscheduler/src/PyITaskTrigger.cpp:133: {"Daily_DaysInterval", T_USHORT, OFF(task_trigger.Type.Daily.DaysInterval),0,"TASK_TIME_TRIGGER_DAILY"}, com/win32comext/taskscheduler/src/taskscheduler.cpp:40: PyModule_AddIntConstant(module,"TASK_TIME_TRIGGER_DAILY", TASK_TIME_TRIGGER_DAILY); These are for Task Scheduler 2.0 $ grep -rni TASK_TRIGGER_DAILY * $ http://msdn.microsoft.com/en-us/library/aa383915(v=VS.85).aspx Is Task Scheduler 2.0 supported in pywin32 or can you provide me with some ideas on how to make it work? (my code is located here: http://pastebin.com/bmg847hw ) Thanks in advance, Bogdan On 4, May, 2010, at 7:08 AM, Roger Upole wrote: > Does job.GetTriggerCount() return 1 ? > If it does, but the trigger doesn't appear in the > Task Scheduler UI, most likely there's > something it doesn't like about the trigger's > flags. > > Roger > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From janssen at parc.com Tue May 4 18:58:49 2010 From: janssen at parc.com (Bill Janssen) Date: Tue, 4 May 2010 09:58:49 PDT Subject: [python-win32] finding pythonXX.dll? In-Reply-To: References: Message-ID: <98270.1272992329@parc.com> Roger Upole wrote: > Bill Janssen wrote: > > Is there anyway to tell, from inside Python, where the python26.dll file > > is? I've got to install the win32 dlls in the same directory. > > > > I see that sys contains a symbol "dllhandle", but that's just a > > numeric handle. > > > > Bill > > win32api.GetModuleFileName(sys.dllhandle) > > Roger Sorry, I wasn't clear enough. I'm trying to figure out where to install the win32 dlls, so I can't use them in that determination. Bill From theller at ctypes.org Tue May 4 19:40:20 2010 From: theller at ctypes.org (Thomas Heller) Date: Tue, 04 May 2010 19:40:20 +0200 Subject: [python-win32] finding pythonXX.dll? In-Reply-To: <98270.1272992329@parc.com> References: <98270.1272992329@parc.com> Message-ID: Bill Janssen schrieb: > Roger Upole wrote: > >> Bill Janssen wrote: >> > Is there anyway to tell, from inside Python, where the python26.dll file >> > is? I've got to install the win32 dlls in the same directory. >> > >> > I see that sys contains a symbol "dllhandle", but that's just a >> > numeric handle. >> > >> > Bill >> >> win32api.GetModuleFileName(sys.dllhandle) >> >> Roger > > Sorry, I wasn't clear enough. I'm trying to figure out where to install > the win32 dlls, so I can't use them in that determination. Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from ctypes import * >>> buf = create_string_buffer(256) >>> windll.kernel32.GetModuleFileNameA <_FuncPtr object at 0x00B44B70> >>> import sys >>> windll.kernel32.GetModuleFileNameA(sys.dllhandle, byref(buf), 256) 32 >>> buf.value 'C:\\WINDOWS\\system32\\python26.dll' >>> -- Thomas From janssen at parc.com Tue May 4 20:31:34 2010 From: janssen at parc.com (Bill Janssen) Date: Tue, 4 May 2010 11:31:34 PDT Subject: [python-win32] finding pythonXX.dll? In-Reply-To: References: <98270.1272992329@parc.com> Message-ID: <99718.1272997894@parc.com> Thomas Heller wrote: > Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> from ctypes import * > >>> buf = create_string_buffer(256) > >>> windll.kernel32.GetModuleFileNameA > <_FuncPtr object at 0x00B44B70> > >>> import sys > >>> windll.kernel32.GetModuleFileNameA(sys.dllhandle, byref(buf), 256) > 32 > >>> buf.value > 'C:\\WINDOWS\\system32\\python26.dll' > >>> Excellent -- just what I need! Thanks. Bill From Marc-Andre.Belzile at autodesk.com Tue May 4 21:33:18 2010 From: Marc-Andre.Belzile at autodesk.com (Marc-Andre Belzile) Date: Tue, 4 May 2010 12:33:18 -0700 Subject: [python-win32] Boot strap mechanism for ActiveX Python engines Message-ID: Hi, I'm trying to execute some python code when a new ActiveX Python engine is instantiated. I thought I could use sitecustomize.py to put my code in but this module seems to get executed only for the first engine created (probably when pythoncomXX.dll is loaded for the first time). Is there a different python module I can rely on when a new engine is created ? Or maybe there is another way to call a python script when a new engine is created ? Thanks for your help -mab -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Wed May 5 06:55:06 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 05 May 2010 14:55:06 +1000 Subject: [python-win32] Boot strap mechanism for ActiveX Python engines In-Reply-To: References: Message-ID: <4BE0FA2A.4060100@gmail.com> On 5/05/2010 5:33 AM, Marc-Andre Belzile wrote: > Hi, > > I'm trying to execute some python code when a new ActiveX Python engine > is instantiated. I thought I could use sitecustomize.py to put my code > in but this module seems to get executed only for the first engine > created (probably when pythoncomXX.dll is loaded for the first time). > > Is there a different python module I can rely on when a new engine is > created ? Or maybe there is another way to call a python script when a > new engine is created ? Your best bet is probably to create your own subclass of the axscript implementation (with different CLSID) and override (eg) InitNew to take some action as the engine is initialized. Cheers, Mark From theller at ctypes.org Wed May 5 21:33:53 2010 From: theller at ctypes.org (Thomas Heller) Date: Wed, 05 May 2010 21:33:53 +0200 Subject: [python-win32] Walking the shell namespace in Python Message-ID: Does someone have example code snippets how to walk the shell namespace in Python? I'm lost in all these pidls and folders. Basically I want to implement a combobox similar to the 'explorer bar' in Windows explorer; given a certain directory - say 'c:\Python26\lib\site-packages' I want to find the names (and laster also the icons) for the files and folders in it, and (more important) the anchestor names and icons like this (using a german windows): Desktop Eigene Dateien Arbeitsplatz WD320 (C:) Python26 Lib site-packages DVD-RAM Laufwerk (D:) ... Netzwerk Papierkorb ... -- Thanks, Thomas From mail at timgolden.me.uk Thu May 6 10:53:34 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 06 May 2010 09:53:34 +0100 Subject: [python-win32] Walking the shell namespace in Python In-Reply-To: References: Message-ID: <4BE2838E.4050007@timgolden.me.uk> On 05/05/2010 20:33, Thomas Heller wrote: > Does someone have example code snippets how to walk the shell namespace in Python? > I'm lost in all these pidls and folders. The code below uses the pywin32 functions to walk. Because there's all sorts of things which can happen, I've implemented a v. broad except: clause just to keep things going. Since this uses the pywin32 wrappers, it's hiding a certain amount of the PIDL/SHITEM stuff, but the functions are pretty much the underlying win32 ones. One thing I don't know how to do without using comtypes is to find the parent. the SHBindToParent function would be the way to go but it's not exposed and I don't have the energy to set up all the comtypes boilerplate to make it happen: I'm sure you can manage, though :) http://msdn.microsoft.com/en-us/library/bb762114%28VS.85%29.aspx The upside of the pywin32 wrappers (lots of stuff done for you) is also its downside (you can't take complete control if you need to). import os, sys import pythoncom from win32com.shell import shell, shellcon def walk (root=None, parent=None): try: if root is None: root_folder = shell.SHGetDesktopFolder () root_name = root_folder.GetDisplayNameOf ([], shellcon.SHGDN_NORMAL) else: root_folder = parent.BindToObject (root, None, shell.IID_IShellFolder) root_name = parent.GetDisplayNameOf (root, shellcon.SHGDN_NORMAL) folders = list (root_folder.EnumObjects (None, shellcon.SHCONTF_FOLDERS)) items = list (root_folder.EnumObjects (None, shellcon.SHCONTF_NONFOLDERS)) yield ( root_name, [root_folder.GetDisplayNameOf (f, shellcon.SHGDN_NORMAL) for f in folders], [root_folder.GetDisplayNameOf (i, shellcon.SHGDN_NORMAL) for i in items] ) for folder in folders: for info in walk (folder, root_folder): yield info except pythoncom.com_error: pass if __name__ == '__main__': for root, folders, items in walk (): print root, folders, items TJG From Guenter.Leonhardt at men.de Thu May 6 16:20:12 2010 From: Guenter.Leonhardt at men.de (=?iso-8859-1?Q?Leonhardt=2C_G=FCnter?=) Date: Thu, 6 May 2010 16:20:12 +0200 Subject: [python-win32] Windows freeze Message-ID: Hi all, I'am using python-win32 for communication with 2 terminalservers. There 16 parallel connection handled, each in a seperate thread. Sporadically the Windows PC is frozen. Maybe this could be syncing problem. Have anyone seen such a behaviour? It is running python-win32 214 on Windows XP single core machine. Thanks for any hint G?nter From theller at ctypes.org Fri May 7 08:29:54 2010 From: theller at ctypes.org (Thomas Heller) Date: Fri, 07 May 2010 08:29:54 +0200 Subject: [python-win32] Walking the shell namespace in Python In-Reply-To: <4BE2838E.4050007@timgolden.me.uk> References: <4BE2838E.4050007@timgolden.me.uk> Message-ID: Tim Golden schrieb: > On 05/05/2010 20:33, Thomas Heller wrote: >> Does someone have example code snippets how to walk the shell namespace in Python? >> I'm lost in all these pidls and folders. > > The code below uses the pywin32 functions to walk. Because there's all > sorts of things which can happen, I've implemented a v. broad except: > clause just to keep things going. Since this uses the pywin32 wrappers, > it's hiding a certain amount of the PIDL/SHITEM stuff, but the functions > are pretty much the underlying win32 ones. > > One thing I don't know how to do without using comtypes is to find the parent. > the SHBindToParent function would be the way to go but it's not exposed and > I don't have the energy to set up all the comtypes boilerplate to make it happen: > I'm sure you can manage, though :) > > http://msdn.microsoft.com/en-us/library/bb762114%28VS.85%29.aspx Thanks Tim, your script gave me a good start. It seems that pywin32 wraps pidls as list of strings, so getting the parent is as simple as removing the last part: >>> from win32com.shell.shell import * >>> from win32com.shell.shellcon import * >>> desktop = SHGetDesktopFolder() >>> desktop.ParseDisplayName(0, None, r"c:\python26\lib\site-packages") (0, ['\x1fP\xe0O\xd0 \xea:i\x10\xa2\xd8\x08\x00+00\x9d', '/C:\\\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0 0\x00\x00', '1\x00\x00\x00\x00\x00\x9c<\xb82\x10\x00Python26\x00\x00(\x00\x03\x00\x04\x00\xef\xbe\x97:\x108\x9c<\xb82\x14\x00\x00\ x00P\x00y\x00t\x00h\x00o\x00n\x002\x006\x00\x00\x00\x18\x00', '1\x00\x00\x00\x00\x00\x9d<\x02D\x10\x00Lib\x00\x1e\x00\x03\x00\x04\ x00\xef\xbe\xfb:eQ\x9d<\x02D\x14\x00\x00\x00L\x00i\x00b\x00\x00\x00\x12\x00', '1\x00\x00\x00\x00\x00\x9c<\xafD\x10\x00SITE-P~1\x00 \x002\x00\x03\x00\x04\x00\xef\xbe\xfb:uQ\x9c<\xafD\x14\x00\x00\x00s\x00i\x00t\x00e\x00-\x00p\x00a\x00c\x00k\x00a\x00g\x00e\x00s\x0 0\x00\x00\x18\x00'], 0) >>> eaten, pidl, attr = desktop.ParseDisplayName(0, None, r"c:\python26\lib\site-packages") >>> desktop.GetDisplayNameOf(pidl, SHGDN_FORPARSING) u'C:\\Python26\\Lib\\site-packages' >>> desktop.GetDisplayNameOf(pidl[:-1], SHGDN_FORPARSING) u'C:\\Python26\\Lib' >>> desktop.GetDisplayNameOf(pidl[:-2], SHGDN_FORPARSING) u'C:\\Python26' >>> desktop.GetDisplayNameOf(pidl[:-3], SHGDN_FORPARSING) u'C:\\' >>> desktop.GetDisplayNameOf(pidl[:-4], SHGDN_FORPARSING) u'::{20D04FE0-3AEA-1069-A2D8-08002B30309D}' >>> What I find strange if this: >>> desktop.GetDisplayNameOf(pidl, SHGDN_FORPARSING) u'C:\\Python26\\Lib\\site-packages' >>> desktop.GetDisplayNameOf(pidl, SHGDN_NORMAL) u'Python26' >>> I would have expected that the last command would have returned 'site-packages' instead of 'Python26'. But I can probably work around it by doing a little parsing on the output of SHGDN_FORPARSING myself. -- Thanks again, Thomas From mail at timgolden.me.uk Fri May 7 10:54:37 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 07 May 2010 09:54:37 +0100 Subject: [python-win32] Walking the shell namespace in Python In-Reply-To: References: <4BE2838E.4050007@timgolden.me.uk> Message-ID: <4BE3D54D.4030607@timgolden.me.uk> On 07/05/2010 07:29, Thomas Heller wrote: > Thanks Tim, your script gave me a good start. > > It seems that pywin32 wraps pidls as list of strings, so getting the parent > is as simple as removing the last part Didn't think of that! TJG From theller at ctypes.org Fri May 7 12:00:44 2010 From: theller at ctypes.org (Thomas Heller) Date: Fri, 07 May 2010 12:00:44 +0200 Subject: [python-win32] Walking the shell namespace in Python In-Reply-To: References: <4BE2838E.4050007@timgolden.me.uk> Message-ID: Thomas Heller schrieb: [...] > > What I find strange if this: What I fond strange is this: > >>>> desktop.GetDisplayNameOf(pidl, SHGDN_FORPARSING) > u'C:\\Python26\\Lib\\site-packages' >>>> desktop.GetDisplayNameOf(pidl, SHGDN_NORMAL) > u'Python26' >>>> > > I would have expected that the last command would have returned > 'site-packages' instead of 'Python26'. But I can probably work around > it by doing a little parsing on the output of SHGDN_FORPARSING myself. > Addendum: SHGetFileInfo() is able to retrive the string that I expected: >>> name = desktop.GetDisplayNameOf(pidl, SHGDN_FORPARSING) >>> SHGetFileInfo(name, 0, SHGFI_DISPLAYNAME) (1L, (0, 0, 0, 'site-packages', '')) >>> -- Thanks, Thomas From vernondcole at gmail.com Fri May 7 16:26:40 2010 From: vernondcole at gmail.com (Vernon Cole) Date: Fri, 7 May 2010 08:26:40 -0600 Subject: [python-win32] Windows freeze In-Reply-To: References: Message-ID: Well, MY Windows PC freezes sporadically even when nothing is running. I think that's considered a feature in Redmond, Washington. ;-) 2010/5/6 Leonhardt, G?nter > Hi all, > I'am using python-win32 for communication with 2 terminalservers. > There 16 parallel connection handled, each in a seperate thread. > Sporadically the Windows PC is frozen. > Maybe this could be syncing problem. > > Have anyone seen such a behaviour? > > It is running python-win32 214 on Windows XP single core machine. > > Thanks for any hint > G?nter > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From janssen at parc.com Fri May 7 23:35:12 2010 From: janssen at parc.com (Bill Janssen) Date: Fri, 7 May 2010 14:35:12 PDT Subject: [python-win32] mapping from a service to its class file? In-Reply-To: References: Message-ID: <46896.1273268112@parc.com> I'm enumerating some service running under XP with mgr = win32service.OpenSCManager(None, None, 4) try: svcinfo = win32service.EnumServicesStatus(mgr) for svc in svcinfo: svch = win32service.OpenService(mgr, svc[0], win32service.SERVICE_QUERY_CONFIG) try: config = win32service.QueryServiceConfig(svch) if config[3].endswith('PythonService.exe"'): # pythonic print config finally: win32service.CloseServiceHandle(svch) finally: win32service.CloseServiceHandle(mgr) For the ones that are using PythonService.exe, I'd like to check to see whether the Python module for the service is still present. Is there any way to retrieve the information about that from the service? Bill From mico_siahaan at yahoo.com Sat May 8 10:58:06 2010 From: mico_siahaan at yahoo.com (Mico Siahaan) Date: Sat, 8 May 2010 01:58:06 -0700 (PDT) Subject: [python-win32] Tutorial Developing GUI using python-win32 Message-ID: <345150.58781.qm@web56908.mail.re3.yahoo.com> Hi all, are there any tutorials in developing GUI using python-win32? rgds, Mico From graemeglass at gmail.com Sat May 8 13:08:18 2010 From: graemeglass at gmail.com (Graeme Glass) Date: Sat, 8 May 2010 13:08:18 +0200 Subject: [python-win32] Tutorial Developing GUI using python-win32 In-Reply-To: <345150.58781.qm@web56908.mail.re3.yahoo.com> References: <345150.58781.qm@web56908.mail.re3.yahoo.com> Message-ID: On Sat, May 8, 2010 at 10:58 AM, Mico Siahaan wrote: > Hi all, are there any tutorials in developing GUI using python-win32? > > rgds, > Mico > > If you going to be doing win32 programming I highly recommend you buy this book. http://oreilly.com/catalog/pythonwin32/chapter/ch20.html a web search for "python +win32gu" brings up loads too. hth. Graeme From rsyring at inteli-com.com Sat May 8 15:40:28 2010 From: rsyring at inteli-com.com (Randy Syring) Date: Sat, 08 May 2010 09:40:28 -0400 Subject: [python-win32] Tutorial Developing GUI using python-win32 In-Reply-To: <345150.58781.qm@web56908.mail.re3.yahoo.com> References: <345150.58781.qm@web56908.mail.re3.yahoo.com> Message-ID: <4BE569CC.70406@inteli-com.com> You may also want to look at pygui: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ (sorry for the dup, Mico, forgot to CC the list) -------------------------------------- Randy Syring Intelicom 502-644-4776 "Whether, then, you eat or drink or whatever you do, do all to the glory of God." 1 Cor 10:31 Mico Siahaan wrote: > Hi all, are there any tutorials in developing GUI using python-win32? > > rgds, > Mico > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From janssen at parc.com Sun May 9 20:31:16 2010 From: janssen at parc.com (Bill Janssen) Date: Sun, 9 May 2010 11:31:16 PDT Subject: [python-win32] mapping from a service to its class file? In-Reply-To: <46896.1273268112@parc.com> References: <46896.1273268112@parc.com> Message-ID: <48938.1273429876@parc.com> Bill Janssen wrote: > For the [services] that are using PythonService.exe, I'd like to check > to see whether the Python module for the service is still present. Is > there any way to retrieve the information about that from the service? Here's what I came up with: import sys, os, win32api, win32con, win32service services = {} mgr = win32service.OpenSCManager(None, None, 4) try: svcinfo = win32service.EnumServicesStatus(mgr) for svc in svcinfo: svch = win32service.OpenService(mgr, svc[0], win32service.SERVICE_QUERY_CONFIG) try: config = win32service.QueryServiceConfig(svch) if config[3].endswith('PythonService.exe"'): klass = win32api.RegQueryValue( win32con.HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Services\\%s\\PythonClass" % (svc[0],)) classfile = os.path.splitext(klass)[0] + ".py" sys.stdout.write("%s %s\n" % (svc[0], os.path.exists(classfile)) finally: win32service.CloseServiceHandle(svch) finally: win32service.CloseServiceHandle(mgr) Bill From janssen at parc.com Sun May 9 23:08:21 2010 From: janssen at parc.com (Bill Janssen) Date: Sun, 9 May 2010 14:08:21 PDT Subject: [python-win32] Running a Windows Python service without pythonservice.exe? Message-ID: <50716.1273439301@parc.com> A few weeks ago, Mark mentioned that there's now a way to run a Windows service without pythonservice.exe. I'd like to hear more about that. Right now, I'm stuck with my UpLib system on Windows. I'd like to be able to install everything in the UpLib directory, including a private copy of Python and PyWin32. But then there's no way to tell pythonservice.exe where the modules are, and so Python services don't start. I'm thinking the problem is this code in PythonService.cpp: // Our EXE entry point. 1540 1541 int _tmain(int argc, TCHAR **argv) 1542 { 1543 PyObject *module, *f; 1544 PyThreadState *threadState; 1545 HMODULE hmod; 1546 FARPROC proc; 1547 Py_Initialize(); 1548 PyEval_InitThreads(); 1549 module = PyImport_ImportModule("servicemanager"); 1550 if (!module) goto failed; I've got the PyWin32 extensions installed in a private site-packages directory under my stuff, which isn't the same as the Python site-packages site. I need a way to set PYTHONPATH, or in some other way initialize the DLL load path and Python sys.path, before running the pythonservice.exe, don't I? Otherwise, this load of "servicemanager" will fail (and Py_Initialize() will fail if I don't copy pythonservice.exe to the same location as python.exe and python26.dll). Bill From skippy.hammond at gmail.com Tue May 11 03:33:37 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 11 May 2010 11:33:37 +1000 Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <50716.1273439301@parc.com> References: <50716.1273439301@parc.com> Message-ID: <4BE8B3F1.7010700@gmail.com> On 10/05/2010 7:08 AM, Bill Janssen wrote: > A few weeks ago, Mark mentioned that there's now a way to run a Windows > service without pythonservice.exe. > > I'd like to hear more about that. Right now, I'm stuck with my UpLib > system on Windows. I'd like to be able to install everything in the > UpLib directory, including a private copy of Python and PyWin32. But > then there's no way to tell pythonservice.exe where the modules are, and > so Python services don't start. > > I'm thinking the problem is this code in PythonService.cpp: > > // Our EXE entry point. > 1540 > 1541 int _tmain(int argc, TCHAR **argv) > 1542 { > 1543 PyObject *module, *f; > 1544 PyThreadState *threadState; > 1545 HMODULE hmod; > 1546 FARPROC proc; > 1547 Py_Initialize(); > 1548 PyEval_InitThreads(); > 1549 module = PyImport_ImportModule("servicemanager"); > 1550 if (!module) goto failed; > > I've got the PyWin32 extensions installed in a private site-packages > directory under my stuff, which isn't the same as the Python > site-packages site. I need a way to set PYTHONPATH, or in some other > way initialize the DLL load path and Python sys.path, before running the > pythonservice.exe, don't I? Otherwise, this load of "servicemanager" > will fail (and Py_Initialize() will fail if I don't copy > pythonservice.exe to the same location as python.exe and python26.dll). That's correct. Using python.exe as the host will involve having a .py script which imports the servicemanager module then call PrepareToHostSingle and instantiate the service class - or something like that :) Another alternative is to ship a slightly modified pythonxx.dll - it has a feature where a certain string resource contains the basename of the registry key used at runtime to load the pythonpath - eg, you will find the resource has "2.6" for Python 2.6 builds. Using a resource editor (or even a script using pywin32) to change this to some custom value will mean the pythonpath can be loaded from a private key in the registry, meaning you still get isolation from other installed Python versions. HTH, Mark > > Bill > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From skippy.hammond at gmail.com Tue May 11 03:39:13 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 11 May 2010 11:39:13 +1000 Subject: [python-win32] Walking the shell namespace in Python In-Reply-To: References: <4BE2838E.4050007@timgolden.me.uk> Message-ID: <4BE8B541.6010307@gmail.com> On 7/05/2010 4:29 PM, Thomas Heller wrote: > Tim Golden schrieb: >> On 05/05/2010 20:33, Thomas Heller wrote: >>> Does someone have example code snippets how to walk the shell namespace in Python? >>> I'm lost in all these pidls and folders. >> >> The code below uses the pywin32 functions to walk. Because there's all >> sorts of things which can happen, I've implemented a v. broad except: >> clause just to keep things going. Since this uses the pywin32 wrappers, >> it's hiding a certain amount of the PIDL/SHITEM stuff, but the functions >> are pretty much the underlying win32 ones. >> >> One thing I don't know how to do without using comtypes is to find the parent. >> the SHBindToParent function would be the way to go but it's not exposed and >> I don't have the energy to set up all the comtypes boilerplate to make it happen: >> I'm sure you can manage, though :) >> >> http://msdn.microsoft.com/en-us/library/bb762114%28VS.85%29.aspx > > Thanks Tim, your script gave me a good start. > > It seems that pywin32 wraps pidls as list of strings, so getting the parent > is as simple as removing the last part: > >>>> from win32com.shell.shell import * >>>> from win32com.shell.shellcon import * >>>> desktop = SHGetDesktopFolder() >>>> desktop.ParseDisplayName(0, None, r"c:\python26\lib\site-packages") > (0, ['\x1fP\xe0O\xd0 \xea:i\x10\xa2\xd8\x08\x00+00\x9d', '/C:\\\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0 > 0\x00\x00', '1\x00\x00\x00\x00\x00\x9c<\xb82\x10\x00Python26\x00\x00(\x00\x03\x00\x04\x00\xef\xbe\x97:\x108\x9c<\xb82\x14\x00\x00\ > x00P\x00y\x00t\x00h\x00o\x00n\x002\x006\x00\x00\x00\x18\x00', '1\x00\x00\x00\x00\x00\x9d<\x02D\x10\x00Lib\x00\x1e\x00\x03\x00\x04\ > x00\xef\xbe\xfb:eQ\x9d<\x02D\x14\x00\x00\x00L\x00i\x00b\x00\x00\x00\x12\x00', '1\x00\x00\x00\x00\x00\x9c<\xafD\x10\x00SITE-P~1\x00 > \x002\x00\x03\x00\x04\x00\xef\xbe\xfb:uQ\x9c<\xafD\x14\x00\x00\x00s\x00i\x00t\x00e\x00-\x00p\x00a\x00c\x00k\x00a\x00g\x00e\x00s\x0 > 0\x00\x00\x18\x00'], 0) >>>> eaten, pidl, attr = desktop.ParseDisplayName(0, None, r"c:\python26\lib\site-packages") >>>> desktop.GetDisplayNameOf(pidl, SHGDN_FORPARSING) > u'C:\\Python26\\Lib\\site-packages' >>>> desktop.GetDisplayNameOf(pidl[:-1], SHGDN_FORPARSING) > u'C:\\Python26\\Lib' >>>> desktop.GetDisplayNameOf(pidl[:-2], SHGDN_FORPARSING) > u'C:\\Python26' >>>> desktop.GetDisplayNameOf(pidl[:-3], SHGDN_FORPARSING) > u'C:\\' >>>> desktop.GetDisplayNameOf(pidl[:-4], SHGDN_FORPARSING) > u'::{20D04FE0-3AEA-1069-A2D8-08002B30309D}' >>>> > > What I find strange if this: > >>>> desktop.GetDisplayNameOf(pidl, SHGDN_FORPARSING) > u'C:\\Python26\\Lib\\site-packages' >>>> desktop.GetDisplayNameOf(pidl, SHGDN_NORMAL) > u'Python26' IIRC, GetDisplayNameOf returns the name of a direct child - not the child of a child. So the "correct" way to do this would be to find the direct parent of the PIDL you are interested in and ask that. Also IIRC, the lack of SHBindToParent can be worked around with IShellFolder::BindToObject - SHBindToParent is just a helper around doing exactly that. HTH, Mark From skippy.hammond at gmail.com Tue May 11 04:01:40 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 11 May 2010 12:01:40 +1000 Subject: [python-win32] how to get access to someone's else Outlook Calendar ? In-Reply-To: <4BDF34BB.6020206@gmail.com> References: <4BD88DB3.6070605@gmail.com> <4BD93060.3060301@gmail.com> <4BDF34BB.6020206@gmail.com> Message-ID: <4BE8BA84.1010806@gmail.com> On 4/05/2010 6:40 AM, Stef Mientki wrote: > Now one small question, how do I get those constants, like > constants.olFolderCalendar (=9) ? makepy needs to have been run for the object in question before the constants magically appear. It should be as simple as using win32com.client.gencache.EnsureDispatch() instead of a 'plain' Dispatch. Mark > > thanks, > Stef Mientki > > outlook = win32com.client.Dispatch("Outlook.Application") > namespace = outlook.GetNamespace("MAPI") > print dir(constants) > Item = outlook.CreateItem ( 1 ) #constants.olAppointmentItem ) #olMailItem) > Recip = Item.Recipients.Add ( 'Klaasen, Jan' ) #<== this is not me, > but some other !! > Recip.Resolve () > if Recip.Resolved : > Folder = namespace.GetSharedDefaultFolder ( Recip, 9 ) > #constants.olFolderCalendar ) > print Folder > > afspraken = Folder.Items > afspraken.Sort("[Start]") > ##afspraken.IncludeRecurrences = "True" > > #Possible columns are Subject, Location, Start, End, Recurrence > Pattern, Categories > afspraak = afspraken.GetFirst() > while afspraak: > start = datetime.datetime.fromtimestamp (int (afspraak.Start)) > subject = afspraak.Subject.encode("utf-8") > print '===', start, subject > afspraak = afspraken.GetNext() > if start.year>2011: #nextYear: > #avoid to loop until 2038 :-) > break > > > >> >> HTH, >> >> Mark >> >> On 29/04/2010 5:34 AM, Stef Mientki wrote: >>> hello, >>> >>> I want to control a number Outlook Calendars from different persons, >>> and I have access privilges and can manipulate them through Outlook. >>> Now I want to control them through Python. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From janssen at parc.com Tue May 11 04:50:47 2010 From: janssen at parc.com (Bill Janssen) Date: Mon, 10 May 2010 19:50:47 PDT Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <4BE8B3F1.7010700@gmail.com> References: <50716.1273439301@parc.com> <4BE8B3F1.7010700@gmail.com> Message-ID: <60830.1273546247@parc.com> Mark Hammond wrote: > That's correct. Using python.exe as the host will involve having a > .py script which imports the servicemanager module then call > PrepareToHostSingle and instantiate the service class - or something > like that :) How definitive :-). I'm already generating a python script for each service, so this could easily be incorporated, if I knew exactly what it was I have to do. 1. Set up the sys.path and os.environ["Path"] properly. 2. import servicemanager 3. define my class 4. call servicemanager.PrepareToHostSingle(my class name) Seem right? > Another alternative is to ship a slightly modified pythonxx.dll - it > has a feature where a certain string resource contains the basename of > the registry key used at runtime to load the pythonpath - eg, you will > find the resource has "2.6" for Python 2.6 builds. Using a resource > editor (or even a script using pywin32) to change this to some custom > value will mean the pythonpath can be loaded from a private key in the > registry, meaning you still get isolation from other installed Python > versions. I could do that, I guess. I'd like to be able to script all the preparations, so if it's a GUI step that would be a Bad Thing. But a script using pywin32 would be great. So, I need to know a couple of things: 1. What's the name of this "certain string resource"? 2. How would one write such a pywin32 script :-)? I wrote this script to answer question #1: ----------------------------------------------------------------- import sys, os import win32api, win32con handle = win32api.LoadLibrary(sys.argv[1]) for rname in win32api.EnumResourceNames(handle, win32con.RT_STRING): rvalue = win32api.LoadResource(handle, win32con.RT_STRING, rname) print rname, rvalue ----------------------------------------------------------------- $ python resource.py python26.dll 63 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^C^@2^@.^@6^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ $ So, the "name" is 63, and it's a 38-byte value with a lot of nul characters in it. I'm unsure of just how to hack it with UpdateResource -- do I just center the replacement text and pad with nul characters? And what's the registry key this works against, anyway? I'd have to update that as part of my installer, too. Bill From mhammond at skippinet.com.au Tue May 11 08:22:28 2010 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 11 May 2010 16:22:28 +1000 Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <60830.1273546247@parc.com> References: <50716.1273439301@parc.com> <4BE8B3F1.7010700@gmail.com> <60830.1273546247@parc.com> Message-ID: <4BE8F7A4.8060201@skippinet.com.au> On 11/05/2010 12:50 PM, Bill Janssen wrote: > Mark Hammond wrote: > >> That's correct. Using python.exe as the host will involve having a >> .py script which imports the servicemanager module then call >> PrepareToHostSingle and instantiate the service class - or something >> like that :) > > How definitive :-). I'm already generating a python script for each > service, so this could easily be incorporated, if I knew exactly what it > was I have to do. > > 1. Set up the sys.path and os.environ["Path"] properly. > > 2. import servicemanager > > 3. define my class > > 4. call servicemanager.PrepareToHostSingle(my class name) > > Seem right? Sounds about right - but reading pythonservice.cpp is really the definitive source to what needs to be done. Sadly I can't find anything more specific, such as a sample. >> Another alternative is to ship a slightly modified pythonxx.dll - it >> has a feature where a certain string resource contains the basename of >> the registry key used at runtime to load the pythonpath - eg, you will >> find the resource has "2.6" for Python 2.6 builds. Using a resource >> editor (or even a script using pywin32) to change this to some custom >> value will mean the pythonpath can be loaded from a private key in the >> registry, meaning you still get isolation from other installed Python >> versions. > > I could do that, I guess. I'd like to be able to script all the > preparations, so if it's a GUI step that would be a Bad Thing. But a > script using pywin32 would be great. So, I need to know a couple of > things: > > 1. What's the name of this "certain string resource"? > > 2. How would one write such a pywin32 script :-)? > > I wrote this script to answer question #1: > > ----------------------------------------------------------------- > import sys, os > > import win32api, win32con > > handle = win32api.LoadLibrary(sys.argv[1]) > for rname in win32api.EnumResourceNames(handle, win32con.RT_STRING): > rvalue = win32api.LoadResource(handle, win32con.RT_STRING, rname) > print rname, rvalue > ----------------------------------------------------------------- > > $ python resource.py python26.dll > 63 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^C^@2^@.^@6^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ > $ > > So, the "name" is 63, and it's a 38-byte value with a lot of nul > characters in it. I'm unsure of just how to hack it with UpdateResource > -- do I just center the replacement text and pad with nul characters? > And what's the registry key this works against, anyway? I'd have to > update that as part of my installer, too. I think the above loaded a string *table*. The resource ID is 1000, and py2exe has some code to deal with updating this for a file. It does: from py2exe.resources.StringTables import StringTable, RT_STRING from py2exe_util import add_resource, load_resource from py2exe.resources.VersionInfo import RT_VERSION ... # OK - do the strings. s = StringTable() # 1000 is the resource ID Python loads for its winver. s.add_string(1000, new_winver) for id, data in s.binary(): add_resource(ensure_unicode(dll_name), data, RT_STRING, id, False) While this could be done with pywin32 and the win32api.UpdateResource function, that would probably require some struct magic - the StringTable object in py2exe hides some of this from you. HTH, Mark From tbrown at snapsurveys.com Tue May 11 12:17:38 2010 From: tbrown at snapsurveys.com (Tim Brown) Date: Tue, 11 May 2010 11:17:38 +0100 Subject: [python-win32] ASP, IIS, win32 and Python 3.1 Message-ID: Hi, Is it possible to get Python 3.1 with the win32 extensions working with IIS ? I've got 2.5 and 2.6 (with Mark's fix) working, but even a simple "Hello world" .asp page gives me HTTP 500 error. This is on Windows XP and IIS 5.1. If it only works on later versions of IIS that's fine I just need to know which ones :) Thanks Tim. From janssen at parc.com Tue May 11 18:12:04 2010 From: janssen at parc.com (Bill Janssen) Date: Tue, 11 May 2010 09:12:04 PDT Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <4BE8F7A4.8060201@skippinet.com.au> References: <50716.1273439301@parc.com> <4BE8B3F1.7010700@gmail.com> <60830.1273546247@parc.com> <4BE8F7A4.8060201@skippinet.com.au> Message-ID: <56678.1273594324@parc.com> Thanks, Mark. I suppose I could run regsetup.py, but that would make my private Python globally known, not really what I want to do. I'll soldier on with option (a), using python.exe to run the service, and see if I can get that to work on a simple example. Bill From janssen at parc.com Tue May 11 19:32:08 2010 From: janssen at parc.com (Bill Janssen) Date: Tue, 11 May 2010 10:32:08 PDT Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <4BE8F7A4.8060201@skippinet.com.au> References: <50716.1273439301@parc.com> <4BE8B3F1.7010700@gmail.com> <60830.1273546247@parc.com> <4BE8F7A4.8060201@skippinet.com.au> Message-ID: <58841.1273599128@parc.com> Mark Hammond wrote: > Sounds about right - but reading pythonservice.cpp is really the > definitive source to what needs to be done. Sadly I can't find > anything more specific, such as a sample. OK. pythonservice.exe has a lot of stuff in it -- for instance, there seems to be a standalone implementation of servicemanager. And don't I have to hack InstallService somewhere, too? Otherwise the Service Manager will try to use PythonService.exe instead of python.exe, won't it? A simple example would sure be a help :-). Bill From janssen at parc.com Tue May 11 20:28:22 2010 From: janssen at parc.com (Bill Janssen) Date: Tue, 11 May 2010 11:28:22 PDT Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <4BE8F7A4.8060201@skippinet.com.au> References: <50716.1273439301@parc.com> <4BE8B3F1.7010700@gmail.com> <60830.1273546247@parc.com> <4BE8F7A4.8060201@skippinet.com.au> Message-ID: <59251.1273602502@parc.com> OK, so I wrote my own InstallService: -------------------------------------------------------------------------------- import sys, os, win32service def InstallService(pythonClassFile, serviceName, displayName, startType = None, errorControl = None, bRunInteractive = 0, serviceDeps = None, userName = None, password = None, exeArgs = None, description = None): # Handle the default arguments. if startType is None: startType = win32service.SERVICE_DEMAND_START serviceType = win32service.SERVICE_WIN32_OWN_PROCESS if bRunInteractive: serviceType = serviceType | win32service.SERVICE_INTERACTIVE_PROCESS if errorControl is None: errorControl = win32service.SERVICE_ERROR_NORMAL pythonClassFile = os.path.abspath(pythonClassFile) commandLine = '"%s" "%s"' % (sys.executable, pythonClassFile) if exeArgs: commandLine = commandLine + " " + exeArgs hscm = win32service.OpenSCManager(None,None,win32service.SC_MANAGER_ALL_ACCESS) try: hs = win32service.CreateService( hscm, serviceName, displayName, win32service.SERVICE_ALL_ACCESS, # desired access serviceType, # service type startType, errorControl, # error control type commandLine, None, 0, serviceDeps, userName, password) if description is not None: try: win32service.ChangeServiceConfig2(hs,win32service.SERVICE_CONFIG_DESCRIPTION,description) except NotImplementedError: pass ## ChangeServiceConfig2 and description do not exist on NT win32service.CloseServiceHandle(hs) finally: win32service.CloseServiceHandle(hscm) if __name__ == "__main__": if len(sys.argv) > 1 and os.path.exists(sys.argv[1]): InstallService(sys.argv[1], os.path.basename(sys.argv[1]), os.path.basename(sys.argv[1])) -------------------------------------------------------------------------------- Note that it doesn't try to register the class string. Seems to work: $ python myinstallservice.py test2.py $ sc query test2.py SERVICE_NAME: test2.py TYPE : 10 WIN32_OWN_PROCESS STATE : 1 STOPPED (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0 $ sc qc test2.py [SC] GetServiceConfig SUCCESS SERVICE_NAME: test2.py TYPE : 10 WIN32_OWN_PROCESS START_TYPE : 3 DEMAND_START ERROR_CONTROL : 1 NORMAL BINARY_PATH_NAME : "c:\UpLib\1.7.9\python\python.exe" "c:\testrepo2\overhead\test2.py" LOAD_ORDER_GROUP : TAG : 0 DISPLAY_NAME : test2.py DEPENDENCIES : SERVICE_START_NAME : LocalSystem $ Although I think I should be crunching those paths to the "short" form. However, it doesn't start: $ sc start test2.py [SC] StartService FAILED 1053: The service did not respond to the start or control request in a timely fashion. $ Here's what's in test2.py: -------------------------------------------------------------------------------- import win32serviceutil import win32service import win32event import win32evtlogutil import servicemanager class MyService(win32serviceutil.ServiceFramework): _svc_name_ = "test2.py" _svc_display_name_ = "test2.py" def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event.SetEvent(self.hWaitStop) def SvcDoRun(self): servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTING, (self._svc_name_, "")) while True: win32event.WaitForSingleObject(self.hWaitStop, 500) servicemanager.Initialize() servicemanager.PrepareToHostSingle(MyService) win32serviceutil.HandleCommandLine(MyService) -------------------------------------------------------------------------------- What am I missing here? Bill From stef.mientki at gmail.com Tue May 11 21:07:32 2010 From: stef.mientki at gmail.com (Stef Mientki) Date: Tue, 11 May 2010 21:07:32 +0200 Subject: [python-win32] how to get access to someone's else Outlook Calendar ? In-Reply-To: <4BE8BA84.1010806@gmail.com> References: <4BD88DB3.6070605@gmail.com> <4BD93060.3060301@gmail.com> <4BDF34BB.6020206@gmail.com> <4BE8BA84.1010806@gmail.com> Message-ID: <4BE9AAF4.6020006@gmail.com> On 11-05-2010 04:01, Mark Hammond wrote: > On 4/05/2010 6:40 AM, Stef Mientki wrote: >> Now one small question, how do I get those constants, like >> constants.olFolderCalendar (=9) ? > > makepy needs to have been run for the object in question before the > constants magically appear. It should be as simple as using > win32com.client.gencache.EnsureDispatch() instead of a 'plain' Dispatch. > > Mark thanks very much Mark, works like a charm. cheers, Stef From mhammond at skippinet.com.au Wed May 12 04:43:45 2010 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 12 May 2010 12:43:45 +1000 Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <59251.1273602502@parc.com> References: <50716.1273439301@parc.com> <4BE8B3F1.7010700@gmail.com> <60830.1273546247@parc.com> <4BE8F7A4.8060201@skippinet.com.au> <59251.1273602502@parc.com> Message-ID: <4BEA15E1.7070006@skippinet.com.au> On 12/05/2010 4:28 AM, Bill Janssen wrote: > OK, so I wrote my own InstallService: That actually isn't necessary - the class can provide _exe_name_ and _exe_args_ attributes to override the defaults. See attached sample which works for me - be sure to place it in the same directory as the pipeTestService.py sample (win32/Demos/service). I'm afraid I did mislead you a little in the steps necessary to get things going, but I'm checking this sample into pywin32 so it doesn't get lost again :) Cheers, Mark -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: nativePipeTestService.py URL: From skippy.hammond at gmail.com Wed May 12 08:51:55 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 11 May 2010 23:51:55 -0700 (PDT) Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <4BE8B3F1.7010700@gmail.com> References: 50716.1273439301@parc.com <4BE8B3F1.7010700@gmail.com> Message-ID: <4bea500b.1da5720a.4a4e.6fa7@mx.google.com> test From skippy.hammond at gmail.com Wed May 12 08:57:54 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 11 May 2010 23:57:54 -0700 (PDT) Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <4BE8B3F1.7010700@gmail.com> References: 50716.1273439301@parc.com <4BE8B3F1.7010700@gmail.com> Message-ID: <4bea5172.1664730a.4435.fffff925@mx.google.com> test From skippy.hammond at gmail.com Wed May 12 09:00:17 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 12 May 2010 00:00:17 -0700 (PDT) Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <4BE8B3F1.7010700@gmail.com> References: <50716.1273439301@parc.com> <4BE8B3F1.7010700@gmail.com> Message-ID: <4bea5201.20a5720a.390d.ffffed39@mx.google.com> test From skippy.hammond at gmail.com Wed May 12 09:01:28 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 12 May 2010 17:01:28 +1000 Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <4bea500b.1da5720a.4a4e.6fa7@mx.google.com> References: 50716.1273439301@parc.com <4BE8B3F1.7010700@gmail.com> <4bea500b.1da5720a.4a4e.6fa7@mx.google.com> Message-ID: <4BEA5248.2030502@gmail.com> On 12/05/2010 4:51 PM, Mark Hammond wrote: > test Oops - sorry about the noise :( One-of-the-risks-when-working-on-email-clients ly, Mark From janssen at parc.com Wed May 12 17:16:34 2010 From: janssen at parc.com (Bill Janssen) Date: Wed, 12 May 2010 08:16:34 PDT Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <4BEA15E1.7070006@skippinet.com.au> References: <50716.1273439301@parc.com> <4BE8B3F1.7010700@gmail.com> <60830.1273546247@parc.com> <4BE8F7A4.8060201@skippinet.com.au> <59251.1273602502@parc.com> <4BEA15E1.7070006@skippinet.com.au> Message-ID: <67901.1273677394@parc.com> Mark Hammond wrote: > See attached sample which works for me - be sure to place it in the > same directory as the pipeTestService.py sample (win32/Demos/service). All right, I put it in a file called nativePipeTestService.py, in that directory, and tried it. Here's what I get: $ pwd -W c:/UpLib/1.7.9/python/Lib/site-packages/win32/Demos/service $ python nativePipeTestService.py install Installing service PyNativePipeTestService Service installed $ sc query PyNativePipeTestService SERVICE_NAME: PyNativePipeTestService TYPE : 10 WIN32_OWN_PROCESS STATE : 1 STOPPED (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN) WIN32_EXIT_CODE : 1077 (0x435) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0 $ sc qc PyNativePipeTestService [SC] GetServiceConfig SUCCESS SERVICE_NAME: PyNativePipeTestService TYPE : 10 WIN32_OWN_PROCESS START_TYPE : 3 DEMAND_START ERROR_CONTROL : 1 NORMAL BINARY_PATH_NAME : "c:\UpLib\1.7.9\python\python.exe" "c:\UpLib\1.7.9\python\Lib\site-packages\win32\Demos\service\nativePipeTestService.py" LOAD_ORDER_GROUP : TAG : 0 DISPLAY_NAME : Python Native Pipe Test Service DEPENDENCIES : SERVICE_START_NAME : LocalSystem $ python nativePipeTestService.py start Starting service PyNativePipeTestService [] Error starting service: The service did not respond to the start or control request in a timely fashion. $ What should I try next? Bill From janssen at parc.com Wed May 12 18:08:30 2010 From: janssen at parc.com (Bill Janssen) Date: Wed, 12 May 2010 09:08:30 PDT Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <67901.1273677394@parc.com> References: <50716.1273439301@parc.com> <4BE8B3F1.7010700@gmail.com> <60830.1273546247@parc.com> <4BE8F7A4.8060201@skippinet.com.au> <59251.1273602502@parc.com> <4BEA15E1.7070006@skippinet.com.au> <67901.1273677394@parc.com> Message-ID: <68655.1273680510@parc.com> Bill Janssen wrote: > $ python nativePipeTestService.py start > Starting service PyNativePipeTestService [] > Error starting service: The service did not respond to the start or control request in a timely fashion. > $ I rebooted and tried again, same result. Then I tried setting up a win32trace window first, and ran $ python nativePipeTestService.py Redirecting output to win32trace remote collector $ What shows up in the trace window is this: > C:\UpLib\1.7.9\python\Lib\site-packages\win32\lib>python win32traceutil.py Collecting Python Trace Output... service is starting... (execute this script with '--help' if that isn't what you want) Something went bad! Traceback (most recent call last): File "nativePipeTestService.py", line 51, in main() File "nativePipeTestService.py", line 44, in main servicemanager.StartServiceCtrlDispatcher() error: (1063, 'StartServiceCtrlDispatcher', 'The service process could not connect to the service controller.') This smacks of a registry problem, but I'm unsure where to go from here... Bill From skippy.hammond at gmail.com Thu May 13 00:55:23 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 13 May 2010 08:55:23 +1000 Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <68655.1273680510@parc.com> References: <50716.1273439301@parc.com> <4BE8B3F1.7010700@gmail.com> <60830.1273546247@parc.com> <4BE8F7A4.8060201@skippinet.com.au> <59251.1273602502@parc.com> <4BEA15E1.7070006@skippinet.com.au> <67901.1273677394@parc.com> <68655.1273680510@parc.com> Message-ID: <4BEB31DB.6040408@gmail.com> On 13/05/2010 2:08 AM, Bill Janssen wrote: > Bill Janssen wrote: > >> $ python nativePipeTestService.py start >> Starting service PyNativePipeTestService [] >> Error starting service: The service did not respond to the start or control request in a timely fashion. >> $ > > I rebooted and tried again, same result. > > Then I tried setting up a win32trace window first, and ran > > $ python nativePipeTestService.py > Redirecting output to win32trace remote collector > $ > > What shows up in the trace window is this: > >> C:\UpLib\1.7.9\python\Lib\site-packages\win32\lib>python win32traceutil.py > Collecting Python Trace Output... > service is starting... > (execute this script with '--help' if that isn't what you want) > Something went bad! > Traceback (most recent call last): > File "nativePipeTestService.py", line 51, in > main() > File "nativePipeTestService.py", line 44, in main > servicemanager.StartServiceCtrlDispatcher() > error: (1063, 'StartServiceCtrlDispatcher', 'The service process could not connect to the service controller.') > > This smacks of a registry problem, but I'm unsure where to go from here... When run with no args, the program assumes it is being started as the service - see the first 3 output lines. Execute 'python nativePipeTestService.py install' to install it, then start it as normal (ie, don't run it manually with no args). If you want different cmdline behaviour, the script can be re-worked to catch the error calling StartServiceCtrlDispatcher(), assume the user is running it interactively and take some different action. Mark From Doug.Feist at lsi.com Thu May 13 00:51:38 2010 From: Doug.Feist at lsi.com (Feist, Doug) Date: Wed, 12 May 2010 16:51:38 -0600 Subject: [python-win32] Windows Error 126 - PyVisa related?? Message-ID: Hi, Please excuse my ignorance as I am a user of just 2 weeks. I just received a new PC with XP 64-bit OS installed. I am having difficulties with running our applications and it appears to be PyVisa related. I have installed the following: Python 2.5.1 (due to our internal software apps support level) pywin32-210.win32-py2.5.exe vcredist_x64.exe (64-bit DLL library?) PyVisa-1.2.win32.exe However, I continue to get the following error stream: Command: python msetup_u Within Python, ^Z exits, ^B or ^S interrupts Initializing Arctic Python . . . . Complete. Traceback (most recent call last): File "c:\arctic\pyscripts\msetup_u.py", line 11, in import GPIB.arb File "c:\arctic\pyscripts\GPIB\__init__.py", line 11, in from visa import * File "C:\Python25\Lib\site-packages\visa.py", line 1, in from pyvisa.visa import * File "C:\Python25\Lib\site-packages\pyvisa\visa.py", line 216, in resource_manager = ResourceManager() File "C:\Python25\Lib\site-packages\pyvisa\vpp43.py", line 97, in __new__ it.init(*args, **kwds) File "C:\Python25\Lib\site-packages\pyvisa\visa.py", line 212, in init self.session = self.vi = vpp43.open_default_resource_manager() File "C:\Python25\Lib\site-packages\pyvisa\vpp43.py", line 750, in open_default_resource_manager visa_library().viOpenDefaultRM(byref(session)) File "C:\Python25\Lib\site-packages\pyvisa\vpp43.py", line 167, in __call__ self.load_library() File "C:\Python25\Lib\site-packages\pyvisa\vpp43.py", line 133, in load_library self.__lib = windll.visa32 File "C:\Python25\Lib\ctypes\__init__.py", line 415, in __getattr__ dll = self._dlltype(name) File "C:\Python25\Lib\ctypes\__init__.py", line 340, in __init__ self._handle = _dlopen(self._name, mode) WindowsError: [Error 126] The specified module could not be found Command: Any insight would be greatly appreciated. Thanks, Doug -------------- next part -------------- An HTML attachment was scrubbed... URL: From janssen at parc.com Thu May 13 01:25:09 2010 From: janssen at parc.com (Bill Janssen) Date: Wed, 12 May 2010 16:25:09 PDT Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <4BEB31DB.6040408@gmail.com> References: <50716.1273439301@parc.com> <4BE8B3F1.7010700@gmail.com> <60830.1273546247@parc.com> <4BE8F7A4.8060201@skippinet.com.au> <59251.1273602502@parc.com> <4BEA15E1.7070006@skippinet.com.au> <67901.1273677394@parc.com> <68655.1273680510@parc.com> <4BEB31DB.6040408@gmail.com> Message-ID: <79746.1273706709@parc.com> Mark Hammond wrote: > Execute 'python nativePipeTestService.py install' to install it, then > start it as normal (ie, don't run it manually with no args). Yes, that's what I tried first. See my message <67901.1273677394 at parc.com>, just previous to the one you replied to. $ sc start PyNativePipeTestService [SC] StartService FAILED 1053: The service did not respond to the start or control request in a timely fashion. $ Same thing if I try to start it from the System Management GUI tool. Bill From timr at probo.com Thu May 13 01:48:03 2010 From: timr at probo.com (Tim Roberts) Date: Wed, 12 May 2010 16:48:03 -0700 Subject: [python-win32] Windows Error 126 - PyVisa related?? In-Reply-To: References: Message-ID: <4BEB3E33.2070709@probo.com> Feist, Doug wrote: > > > > Please excuse my ignorance as I am a user of just 2 weeks. I just > received a new PC with XP 64-bit OS installed. I am having > difficulties with running our applications and it appears to be PyVisa > related. I have installed the following: > > Python 2.5.1 (due to our internal software apps support level) > > pywin32-210.win32-py2.5.exe > > vcredist_x64.exe (64-bit DLL library?) > > PyVisa-1.2.win32.exe > Did you install the 32-bit version of Python? (I'm guessing you did.) You seem to have the 32-bit versions of both pywin32 and PyVisa there. If so, you need the 32-bit Visual C++ redistributable (vcredist_x86.exe), not 64-bit. The 64-bit operating systems can run either 32-bit programs or 64-bit programs, but a 32-bit program must use all 32-bit DLLs. There is no way to cross between the two. How did you get a "new PC" with XP 64? XP 64 is a weird beast. Microsoft never actually built a 64-bit version of XP. What you have there is the Windows Server 2003 64-bit kernel, but they took a text editor to change the version name to "XP". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Thu May 13 01:53:11 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 13 May 2010 09:53:11 +1000 Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <79746.1273706709@parc.com> References: <50716.1273439301@parc.com> <4BE8B3F1.7010700@gmail.com> <60830.1273546247@parc.com> <4BE8F7A4.8060201@skippinet.com.au> <59251.1273602502@parc.com> <4BEA15E1.7070006@skippinet.com.au> <67901.1273677394@parc.com> <68655.1273680510@parc.com> <4BEB31DB.6040408@gmail.com> <79746.1273706709@parc.com> Message-ID: <4BEB3F67.2040709@gmail.com> On 13/05/2010 9:25 AM, Bill Janssen wrote: > Mark Hammond wrote: > >> Execute 'python nativePipeTestService.py install' to install it, then >> start it as normal (ie, don't run it manually with no args). > > Yes, that's what I tried first. See my message > <67901.1273677394 at parc.com>, just previous to the one you replied to. Sorry - I missed that 'install' command in that message. > $ sc start PyNativePipeTestService > [SC] StartService FAILED 1053: > > The service did not respond to the start or control request in a timely fashion. > > $ > > Same thing if I try to start it from the System Management GUI tool. I'm not sure what the problem could be. It appears Python is finding all the modules OK and I can't think of why the service request would be failing. Does the standard old pipeTestService.py still work for you? Mark From cappy2112 at gmail.com Thu May 13 19:04:03 2010 From: cappy2112 at gmail.com (Tony Cappellini) Date: Thu, 13 May 2010 10:04:03 -0700 Subject: [python-win32] Enable/disable Remote Desktop via Python Message-ID: On WinXP, under Control Panel/System/Remote - there is a check box to enable/disable Remote Desktop access. I need to toggle this- so I don't get disconnected by other users, when I'm connected to a system remotely. The desktop version of Windows- still doesn't allow concurrent multi-user logins in the year 2010. I'd like to be to write a program to toggle this for me. Would someone point me to a resource which describes how to do this? Thanks From mc at mclaveau.com Thu May 13 19:40:38 2010 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 13 May 2010 19:40:38 +0200 Subject: [python-win32] Enable/disable Remote Desktop via Python In-Reply-To: References: Message-ID: <8673E42094334C1C84F6E0F32761531D@MCI1330> Hi! It is easy to stop/restart the service "TermService" under Windows 7 (or equivalent under other windows). @-salutations -- Michel Claveau From rsyring at inteli-com.com Thu May 13 20:06:46 2010 From: rsyring at inteli-com.com (Randy Syring) Date: Thu, 13 May 2010 14:06:46 -0400 Subject: [python-win32] Enable/disable Remote Desktop via Python In-Reply-To: <8673E42094334C1C84F6E0F32761531D@MCI1330> References: <8673E42094334C1C84F6E0F32761531D@MCI1330> Message-ID: <4BEC3FB6.30908@inteli-com.com> I think the OP was wanting to prevent other users from logging in while he is logged in remotely. He said he doesn't want to get "disconnected." If that is the case, disabling TermService would kill his current session and be worse than a disconnect. :) -------------------------------------- Randy Syring Intelicom 502-644-4776 "Whether, then, you eat or drink or whatever you do, do all to the glory of God." 1 Cor 10:31 Michel Claveau wrote: > Hi! > > It is easy to stop/restart the service "TermService" under Windows 7 > (or equivalent under other windows). > > @-salutations From timr at probo.com Fri May 14 19:07:57 2010 From: timr at probo.com (Tim Roberts) Date: Fri, 14 May 2010 10:07:57 -0700 Subject: [python-win32] Enable/disable Remote Desktop via Python In-Reply-To: References: Message-ID: <4BED836D.50309@probo.com> Tony Cappellini wrote: > under Control Panel/System/Remote - there is a check box to > enable/disable Remote Desktop access. > > I need to toggle this- so I don't get disconnected by other users, > when I'm connected to a system remotely. > Are you saying that when you are remotely logged into system X, you want to disable Remote Desktop access to system X? Isn't that going to prevent YOU from accessing system X as well? It's a little like sawing off the tree branch on which you are sitting, isn't it? > The desktop version of Windows- still doesn't allow concurrent > multi-user logins in the year 2010. > Yes, but FWIW, this is an artificial licensing restriction, not a technical restriction. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From janssen at parc.com Fri May 14 21:06:17 2010 From: janssen at parc.com (Bill Janssen) Date: Fri, 14 May 2010 12:06:17 PDT Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <4BEB3F67.2040709@gmail.com> References: <50716.1273439301@parc.com> <4BE8B3F1.7010700@gmail.com> <60830.1273546247@parc.com> <4BE8F7A4.8060201@skippinet.com.au> <59251.1273602502@parc.com> <4BEA15E1.7070006@skippinet.com.au> <67901.1273677394@parc.com> <68655.1273680510@parc.com> <4BEB31DB.6040408@gmail.com> <79746.1273706709@parc.com> <4BEB3F67.2040709@gmail.com> Message-ID: <90386.1273863977@parc.com> Mark Hammond wrote: > On 13/05/2010 9:25 AM, Bill Janssen wrote: > > Mark Hammond wrote: > > > >> Execute 'python nativePipeTestService.py install' to install it, then > >> start it as normal (ie, don't run it manually with no args). > > > > Yes, that's what I tried first. See my message > > <67901.1273677394 at parc.com>, just previous to the one you replied to. > > Sorry - I missed that 'install' command in that message. > > > $ sc start PyNativePipeTestService > > [SC] StartService FAILED 1053: > > > > The service did not respond to the start or control request in a timely fashion. > > > > $ > > > > Same thing if I try to start it from the System Management GUI tool. > > I'm not sure what the problem could be. It appears Python is finding > all the modules OK and I can't think of why the service request would > be failing. Does the standard old pipeTestService.py still work for > you? No, it fails the same way. Is there a test suite for PyWin32 that I could run to verify my installation is good? Bill From mhammond at skippinet.com.au Sat May 15 02:27:11 2010 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 15 May 2010 10:27:11 +1000 Subject: [python-win32] Running a Windows Python service without pythonservice.exe? In-Reply-To: <90386.1273863977@parc.com> References: <50716.1273439301@parc.com> <4BE8B3F1.7010700@gmail.com> <60830.1273546247@parc.com> <4BE8F7A4.8060201@skippinet.com.au> <59251.1273602502@parc.com> <4BEA15E1.7070006@skippinet.com.au> <67901.1273677394@parc.com> <68655.1273680510@parc.com> <4BEB31DB.6040408@gmail.com> <79746.1273706709@parc.com> <4BEB3F67.2040709@gmail.com> <90386.1273863977@parc.com> Message-ID: <4BEDEA5F.1050205@skippinet.com.au> On 15/05/2010 5:06 AM, Bill Janssen wrote: > Mark Hammond wrote: > >> On 13/05/2010 9:25 AM, Bill Janssen wrote: >>> Mark Hammond wrote: >>> >>>> Execute 'python nativePipeTestService.py install' to install it, then >>>> start it as normal (ie, don't run it manually with no args). >>> >>> Yes, that's what I tried first. See my message >>> <67901.1273677394 at parc.com>, just previous to the one you replied to. >> >> Sorry - I missed that 'install' command in that message. >> >>> $ sc start PyNativePipeTestService >>> [SC] StartService FAILED 1053: >>> >>> The service did not respond to the start or control request in a timely fashion. >>> >>> $ >>> >>> Same thing if I try to start it from the System Management GUI tool. >> >> I'm not sure what the problem could be. It appears Python is finding >> all the modules OK and I can't think of why the service request would >> be failing. Does the standard old pipeTestService.py still work for >> you? > > No, it fails the same way. Is there a test suite for PyWin32 that I > could run to verify my installation is good? win32\test\testall.py is probably the closest, but it only checks the pywin32 implementation and doesn't do much in the way of 'environment' checking - indeed, nothing related to services is automatically tested at all. It might be worth checking your windows event log - pythonservice may have written something there... Mark From cappy2112 at gmail.com Sat May 15 16:44:19 2010 From: cappy2112 at gmail.com (Tony Cappellini) Date: Sat, 15 May 2010 07:44:19 -0700 Subject: [python-win32] Enable/disable Remote Desktop via Python Message-ID: Message: 1 Date: Fri, 14 May 2010 10:07:57 -0700 From: Tim Roberts To: Python-Win32 List Subject: Re: [python-win32] Enable/disable Remote Desktop via Python Message-ID: <4BED836D.50309 at probo.com> Content-Type: text/plain; charset=ISO-8859-1 >>Are you saying that when you are remotely logged into system X, you want >>to disable Remote Desktop access to system X? Yes >>Isn't that going to prevent YOU from accessing system X as well? It's a little like sawing >>off the tree branch on which you are sitting, isn't it? No It doesn't terminate my connection, It just stops other users from trying to connect remotely while I'm, connected. Attempts to connect by other users would log me off with no warning, an possibly cause a loss of data. >Yes, but FWIW, this is an artificial licensing restriction, not a >>technical restriction. This IS a technical question. It is no different than someone posting a question like "How do I ??? with Tim's WMI module ?" There is a checkbox in Control Panel to do this microsoft has provided it for the user. I want to enable/disable that checkbox via Python, and want to know how it can be done. When you run the Remote Desktop Client, there is an option to execute a program on the remote machine. This would be the perfect place to do call the program from, so it would be done automatically. From malaclypse2 at gmail.com Sun May 16 17:26:44 2010 From: malaclypse2 at gmail.com (Jerry Hill) Date: Sun, 16 May 2010 11:26:44 -0400 Subject: [python-win32] Enable/disable Remote Desktop via Python In-Reply-To: References: Message-ID: On Sat, May 15, 2010 at 10:44 AM, Tony Cappellini wrote: > There is a checkbox in Control Panel to do this microsoft has provided > it for the user. > I want to enable/disable that checkbox via Python, and want to know > how it can be done. You'll probably need to figure out what checking that checkbox does under the covers. Does it change a value in the registry? Does it write an option to a file someplace? Does it start or stop a service? Once you know what the checkbox is doing, you can probably do the same thing via your python code. I certainly don't know which of those it is, or if it's something else entirely. It sounds like no one else here does either, so you'll need to figure it out for yourself. The other option is to automate opening the control panel and clicking the checkbox, as if you were clicking on things yourself. This tends to be a pretty complex and fragile process in my experience, though. You're almost always better off just performing the underlying action yourself. If you decide to go the former route, there are some tools that might help you figure out what's going on under the covers. Process monitor ( http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx ) allows you to watch processes, and all of the registry and file activity they perform. That's probably your best bet for seeing what's going on. If you decide to go the latter route and automate clicking buttons and such, check out the pywinauto project. The third option is to find a piece of code in some other language that does what you want, and show us where to find it. We can probably help translate that into python with you. -- Jerry From steven.james at gmail.com Sun May 16 20:45:30 2010 From: steven.james at gmail.com (Steven James) Date: Sun, 16 May 2010 14:45:30 -0400 Subject: [python-win32] Enable/disable Remote Desktop via Python In-Reply-To: References: Message-ID: http://thebackroomtech.com/2007/05/18/how-to-enable-remote-desktop-on-a-windows-xp-machine-remotely/ That link explains how to do this remotely from a command line and by modifying a registry entry. I've scripted this with python before but can't find the code right now. Steven James On Sun, May 16, 2010 at 11:26 AM, Jerry Hill wrote: > On Sat, May 15, 2010 at 10:44 AM, Tony Cappellini > wrote: > > There is a checkbox in Control Panel to do this microsoft has provided > > it for the user. > > I want to enable/disable that checkbox via Python, and want to know > > how it can be done. > > You'll probably need to figure out what checking that checkbox does > under the covers. Does it change a value in the registry? Does it > write an option to a file someplace? Does it start or stop a service? > Once you know what the checkbox is doing, you can probably do the > same thing via your python code. I certainly don't know which of > those it is, or if it's something else entirely. It sounds like no > one else here does either, so you'll need to figure it out for > yourself. > > The other option is to automate opening the control panel and clicking > the checkbox, as if you were clicking on things yourself. This tends > to be a pretty complex and fragile process in my experience, though. > You're almost always better off just performing the underlying action > yourself. > > If you decide to go the former route, there are some tools that might > help you figure out what's going on under the covers. Process monitor > ( http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx ) > allows you to watch processes, and all of the registry and file > activity they perform. That's probably your best bet for seeing > what's going on. > > If you decide to go the latter route and automate clicking buttons and > such, check out the pywinauto project. > > The third option is to find a piece of code in some other language > that does what you want, and show us where to find it. We can > probably help translate that into python with you. > > -- > Jerry > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From batuoc20047 at yahoo.com Sat May 15 13:25:24 2010 From: batuoc20047 at yahoo.com (Trong Hai) Date: Sat, 15 May 2010 18:25:24 +0700 Subject: [python-win32] adodbapi-2.1 release candidate 1 ready for testing Message-ID: <000001caf421$52262490$f6726db0$@com> Hello! Excuse me, I have a problem with python program, I don't know fix it . Do you can help me? I very thank you. My problem is " ImportError: No module named adodbapi " when I run file "test_tsqlunit.py" and another. I hope you can help me to solution this fix. Thank you very much! -------------- next part -------------- An HTML attachment was scrubbed... URL: From d_vineet at yahoo.com Mon May 17 08:25:46 2010 From: d_vineet at yahoo.com (Vineet Deodhar) Date: Sun, 16 May 2010 23:25:46 -0700 (PDT) Subject: [python-win32] ide for python 3.x Message-ID: <959241.98442.qm@web32007.mail.mud.yahoo.com> Hi ! Recently I have started learning python. Till now, I have been programming with VFP & MySQL. ? I explored the web looking for the IDE for Python. Dabo is an excellent framework. (but the IDE is still?to be?developed, I think). ? As far as open-source IDE's are considered, I couldn't locate one having UI design toolkit. (by UI design,?what I mean is that -- e.g. click on a form control, and drag it to the designer area, resize it visually, without writing any code manually).? Further, tools like wxPython are supporting only upto Python 2.6 Same case with Netbeans 6.8. ? Does anybody know?whether?an IDE (open-source) is available which supports Python 3.x and GUI toolkit? ? Vineet Deodhar -------------- next part -------------- An HTML attachment was scrubbed... URL: From werner.bruhin at free.fr Mon May 17 08:45:53 2010 From: werner.bruhin at free.fr (Werner F. Bruhin) Date: Mon, 17 May 2010 08:45:53 +0200 Subject: [python-win32] ide for python 3.x In-Reply-To: <959241.98442.qm@web32007.mail.mud.yahoo.com> References: <959241.98442.qm@web32007.mail.mud.yahoo.com> Message-ID: <4BF0E621.3040105@free.fr> Hi, On 17/05/2010 08:25, Vineet Deodhar wrote: > Hi ! > > Recently I have started learning python. > > Till now, I have been programming with VFP & MySQL. > > I explored the web looking for the IDE for Python. > > _Dabo is an excellent framework. (but the IDE is still to be developed, > I think)._ > > As far as open-source IDE's are considered, I couldn't locate one having > UI design toolkit. > > (by UI design, what I mean is that -- e.g. click on a form control, and > drag it to the designer area, resize it visually, without writing any > code manually). > > Further, tools like wxPython are supporting only upto Python 2.6 > > Same case with Netbeans 6.8. > > Does anybody know whether an IDE (open-source) is available which > supports Python 3.x and GUI toolkit? Note that there quit a few libraries not yet supporting 3.x, unless you have an absolute need for 3.x I would suggest that you go with 2.6. With regards to IDE, you might want to look at Boa (https://sourceforge.net/projects/boa-constructor/), not supporting 3.x either, I use it on Py 2.5 and 2.6 with wxPython 2.8. Werner From torriem at gmail.com Mon May 17 09:05:47 2010 From: torriem at gmail.com (Michael Torrie) Date: Mon, 17 May 2010 01:05:47 -0600 Subject: [python-win32] ide for python 3.x In-Reply-To: <959241.98442.qm@web32007.mail.mud.yahoo.com> References: <959241.98442.qm@web32007.mail.mud.yahoo.com> Message-ID: <4BF0EACB.8070701@gmail.com> Vineet Deodhar wrote: > Does anybody know whether an IDE (open-source) is available which > supports Python 3.x and GUI toolkit? Depends on what GUI toolkit you want to use. If you want to use PyQt, then Qt's own Designer (or upcoming Qt Creator) and then do python in any IDE of your choice. There's very little need to integrate GUI development with coding in my opinion given how well Qt Designer works standalone. From graemeglass at gmail.com Mon May 17 10:18:03 2010 From: graemeglass at gmail.com (Graeme Glass) Date: Mon, 17 May 2010 10:18:03 +0200 Subject: [python-win32] adodbapi-2.1 release candidate 1 ready for testing In-Reply-To: <000001caf421$52262490$f6726db0$@com> References: <000001caf421$52262490$f6726db0$@com> Message-ID: On Sat, May 15, 2010 at 1:25 PM, Trong Hai wrote: > Hello! > > Excuse me, I have a problem with python program, I don?t know fix it . Do > you can help me? I very thank you. My problem is ? ImportError: No module > named adodbapi ? when I run file ?test_tsqlunit.py? and another. I hope you > can help me to solution this fix. Thank you very much! > You either don't have adodbapi installed, or it is not in your path. The python interpreter can not find module, hence the error ? ImportError: No module named adodbapi ? From python at bdurham.com Mon May 17 13:30:36 2010 From: python at bdurham.com (python at bdurham.com) Date: Mon, 17 May 2010 07:30:36 -0400 Subject: [python-win32] ide for python 3.x In-Reply-To: <4BF0E621.3040105@free.fr> References: <959241.98442.qm@web32007.mail.mud.yahoo.com> <4BF0E621.3040105@free.fr> Message-ID: <1274095836.13299.1375437949@webmail.messagingengine.com> Vineet, > > Till now, I have been programming with VFP & MySQL. Check out dabodev.org. Malcolm From cappy2112 at gmail.com Mon May 17 16:16:18 2010 From: cappy2112 at gmail.com (Tony Cappellini) Date: Mon, 17 May 2010 07:16:18 -0700 Subject: [python-win32] Enable/disable Remote Desktop via Python Message-ID: Message: 2 Date: Sun, 16 May 2010 14:45:30 -0400 From: Steven James To: python-win32 at python.org Subject: Re: [python-win32] Enable/disable Remote Desktop via Python Message-ID: Content-Type: text/plain; charset="iso-8859-1" http://thebackroomtech.com/2007/05/18/how-to-enable-remote-desktop-on-a-windows-xp-machine-remotely/ That link explains how to do this remotely from a command line and by modifying a registry entry. I've scripted this with python before but can't find the code right now. Thanks But I need to enable/disable Remote Desktop login on the current machine, not a remote machine. I''ll play around with this "set service remotedesktop enable" Steven James From timr at probo.com Mon May 17 19:31:59 2010 From: timr at probo.com (Tim Roberts) Date: Mon, 17 May 2010 10:31:59 -0700 Subject: [python-win32] Enable/disable Remote Desktop via Python In-Reply-To: References: Message-ID: <4BF17D8F.1060502@probo.com> Tony Cappellini wrote: > But I need to enable/disable Remote Desktop login on the current > machine, not a remote machine. > I''ll play around with this "set service remotedesktop enable" > But you said you needed to do this while you were remotely logged in yourself, right? If so, you need to be careful how you do this. If you actually stop the service, then YOUR session will be closed as well, and you won't be able to get back in without going physically to the machine. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From skippy.hammond at gmail.com Tue May 18 02:19:28 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 18 May 2010 10:19:28 +1000 Subject: [python-win32] Enable/disable Remote Desktop via Python In-Reply-To: <4BF17D8F.1060502@probo.com> References: <4BF17D8F.1060502@probo.com> Message-ID: <4BF1DD10.2020502@gmail.com> On 18/05/2010 3:31 AM, Tim Roberts wrote: > Tony Cappellini wrote: >> But I need to enable/disable Remote Desktop login on the current >> machine, not a remote machine. >> I''ll play around with this "set service remotedesktop enable" >> > > But you said you needed to do this while you were remotely logged in > yourself, right? If so, you need to be careful how you do this. If you > actually stop the service, then YOUR session will be closed as well, and > you won't be able to get back in without going physically to the machine. Or even if you do manage to do this without stopping the service and immediately losing your connection, what happens when the network drops out etc and you lose your existing connection without the opportunity of re-enabling future remote connections? Mark From pacopyc at gmail.com Tue May 18 09:22:57 2010 From: pacopyc at gmail.com (pacopyc) Date: Tue, 18 May 2010 09:22:57 +0200 Subject: [python-win32] set wait time max Message-ID: <4BF24051.2020308@gmail.com> Hi, I've a question for you. I'd like to call a function and waiting its return value for a time max (30 sec). The function could not respond and then I must avoid to wait for infinite time. Can you help me? Thanks From graemeglass at gmail.com Tue May 18 13:10:03 2010 From: graemeglass at gmail.com (Graeme Glass) Date: Tue, 18 May 2010 13:10:03 +0200 Subject: [python-win32] set wait time max In-Reply-To: <4BF24051.2020308@gmail.com> References: <4BF24051.2020308@gmail.com> Message-ID: On Tue, May 18, 2010 at 9:22 AM, pacopyc wrote: > Hi, I've a question for you. I'd like to call a function and waiting its > return value for a time max (30 sec). > The function could not respond and then I must avoid to wait for infinite > time. > Can you help me? > > Thanks It depends on what method you are calling? From what module? Some methods, take a timeout parameter (aka socket). You could call your method in a thread and a timeout on the thread. http://docs.python.org/library/threading.html#module-threading This very much depends on what you trying to do, as to what is the best way to go. Maybe you could give a little bit more information about what you are trying to achieve and what modules/methods you trying to access. Since you posted to win32 mailing list, I am assuming you are running this windows. hth. Graeme From pacopyc at gmail.com Tue May 18 13:30:50 2010 From: pacopyc at gmail.com (pacopyc) Date: Tue, 18 May 2010 13:30:50 +0200 Subject: [python-win32] set wait time max In-Reply-To: References: <4BF24051.2020308@gmail.com> Message-ID: <4BF27A6A.1070802@gmail.com> On 18/05/2010 13:10, Graeme Glass wrote: > On Tue, May 18, 2010 at 9:22 AM, pacopyc wrote: > >> Hi, I've a question for you. I'd like to call a function and waiting its >> return value for a time max (30 sec). >> The function could not respond and then I must avoid to wait for infinite >> time. >> Can you help me? >> >> Thanks >> > It depends on what method you are calling? From what module? > Some methods, take a timeout parameter (aka socket). > > You could call your method in a thread and a timeout on the thread. > http://docs.python.org/library/threading.html#module-threading > > This very much depends on what you trying to do, as to what is the > best way to go. > > Maybe you could give a little bit more information about what you are > trying to achieve and what modules/methods you trying to access. > Since you posted to win32 mailing list, I am assuming you are running > this windows. > > hth. > > Graeme > Ok, you're right. I'm developing a software to monitor my LAN (Windows clients). I'm using WMI and pywin32 (win32net.NetLocalGroupMembers, win32net.NetGroupEnum,Win32_NetworkAdapterConfiguration, .....). Maybe that a Windows client not respond (blocked, personal firewall, ...) and then my script wait for an infinite time. Of course this is no good. If function respond with an error my script catch it, but if function don't finish is a big problem. That is why I'd like finish the function and analyse next client. I think that I must set a max time. Thank you very much. From steve_geo at optusnet.com.au Tue May 18 14:26:02 2010 From: steve_geo at optusnet.com.au (Stephen George) Date: Tue, 18 May 2010 22:26:02 +1000 Subject: [python-win32] ide for python 3.x In-Reply-To: <4BF0EACB.8070701@gmail.com> References: <959241.98442.qm@web32007.mail.mud.yahoo.com> <4BF0EACB.8070701@gmail.com> Message-ID: <4BF2875A.2030609@optusnet.com.au> Hi, I have not used it, but I noticed 'Eric 5' http://eric-ide.python-projects.org/ is targeting python3.0 Also from the documentation: "Qt designer, the standard Qt tool for designing forms, is launched by eric" I think most people use a Editor/IDE for python they feel comfortable with. To design the GUI they tend to use separate stand alone GUI design application based on the GUI toolkit you wish to use. i.e. pyGTK - Glade ( http://glade.gnome.org/ ) pyQt - Qt designer ( http://qt.nokia.com/products ) wxPython - wxGlade ( http://wxglade.sourceforge.net/ ) Some python editors/ide's not already mentioned (in no particular order) http://pythonide.blogspot.com/ http://www.openkomodo.com/ http://drpython.sourceforge.net/ http://pydev.org// ( for eclipse ) http://code.google.com/p/pyscripter/ - Steve On 17/05/2010 5:05 PM, Michael Torrie wrote: > Vineet Deodhar wrote: > >> Does anybody know whether an IDE (open-source) is available which >> supports Python 3.x and GUI toolkit? >> > Depends on what GUI toolkit you want to use. If you want to use PyQt, > then Qt's own Designer (or upcoming Qt Creator) and then do python in > any IDE of your choice. There's very little need to integrate GUI > development with coding in my opinion given how well Qt Designer works > standalone. > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > > No virus found in this incoming message. > Checked by AVG -www.avg.com > Version: 9.0.819 / Virus Database: 271.1.1/2876 - Release Date: 05/16/10 04:26:00 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cappy2112 at gmail.com Tue May 18 15:55:39 2010 From: cappy2112 at gmail.com (Tony Cappellini) Date: Tue, 18 May 2010 06:55:39 -0700 Subject: [python-win32] Enable/disable Remote Desktop via Python Message-ID: Message: 4 Date: Tue, 18 May 2010 10:19:28 +1000 From: Mark Hammond Cc: Python-Win32 List Subject: Re: [python-win32] Enable/disable Remote Desktop via Python Message-ID: <4BF1DD10.2020502 at gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed >>Or even if you do manage to do this without stopping the service and >>immediately losing your connection, what happens when the network drops >>out etc and you lose your existing connection without the opportunity of >>re-enabling future remote connections? Then I'll walk over to the machine and re-enable it myself. I've been toggling the checkbox in Control Panel manually ever since I knew RD existed, and it has never terminated the connection I was using at the time.Perhaps certain configurations might cuase that, but I don't know what those would be. It's just not convenient to not be able to do this with a batchfile, or shortcut From inf200523 at ucf.edu.cu Wed May 19 15:36:15 2010 From: inf200523 at ucf.edu.cu (Boris Perez Canedo) Date: Wed, 19 May 2010 09:36:15 -0400 (EDT) Subject: [python-win32] Problem with service start type "auto" Message-ID: <1394.10.14.19.74.1274276175.squirrel@correo.ucf.edu.cu> Hi everybody. I'm new in the list?and I'm not an english speaking person.?If you?see a lot of mistakes?please excuse me I'm trying my best. I have a compiled python?service which I can install, remove, start?and stop without errors (manually). The problem ocurrs when I change the start type and set it to "auto". Then I restart my computer to see if the service starts correctly. I see two errors informed by the service control manager: 1)Timeout (30000 ms.)?for connection to?WBEM Inv service. And right after that. 2)The service did not responde to the start or control request in a timely fashion. If I go and perform an explicit start, keeping the start type in auto, the service starts and no errors are informed. I don't understand why the operating system can not start the service by itself. This is the output for "sc interrogate" on my service?in case it helps: SERVICE_NAME: WBEMInv ??????? TYPE?????????????? : 10? WIN32_OWN_PROCESS ??????? STATE????????????? : 4? RUNNING ??????????????????????????????? (STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN) ??????? WIN32_EXIT_CODE??? : 0? (0x0) ??????? SERVICE_EXIT_CODE? : 0? (0x0) ??????? CHECKPOINT???????? : 0x0 ??????? WAIT_HINT????????? : 0x0 My python code: import win32serviceutil import win32service import win32event import servicemanager import os def system(): ???? # my system implementation. class XmlRPCService(win32serviceutil.ServiceFramework): ??? _svc_name_ = 'WBEMInv' ??? _svc_display_name_ = "WBEM Inventory" ??? _svc_description_ = 'Servicio xml rpc para realizar inventario de ordenadores conectados a redes hibridas' ??? def __init__(self, args): ?????????key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"SOFTWARE\\UCf\\WBEMInv\\Settings") ?????????path = _winreg.EnumValue(key, 0)[1] ?????????os.chdir(path) # I dont want?the?working directory to be system32. ????????? _winreg.CloseKey(key) ???????? win32serviceutil.ServiceFramework.__init__(self, args) ??????? self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) ??? def SvcStop(self): ??????? self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) ??????? sys.stopservice = "true" ??????? win32event.SetEvent(self.hWaitStop) ??? def SvcDoRun(self): ??????? system() ??? if __name__=='__main__': ???? win32serviceutil.HandleCommandLine(XmlRPCService) Thank you very much. Boris. --- Convencion Internacional de Psicologia y Ciencias Sociales y Humanas Cienfuegos, Cuba, del 19 al 22 de abril del 2011 http://promociondeeventos.sld.cu/hominis2011 -------------- next part -------------- An HTML attachment was scrubbed... URL: From ddwiggins at advpubtech.com Wed May 19 23:46:31 2010 From: ddwiggins at advpubtech.com (Don Dwiggins) Date: Wed, 19 May 2010 14:46:31 -0700 Subject: [python-win32] Python service hangs in Dispatch when frozen with py2exe Message-ID: I'm developing a Python service under Win XP with Python 2.5 (the service is built on Twisted's XMLRPC server). For delivery to production, I "compile" it with py2exe. It's been running fine, but I've hit a snag. I've written new code to access a COM object (in a DLL); the code I've written does works successfully as long as I'm running the source under PythonService. The compiled version, however, hangs up in the call to Dispatch to get the COM object. I've put in debugging log entries all through the relevant section of code, and it's clear that it simply never returns from the Dispatch call. I've tried EnsureDispatch as well, and more recently the following code: > iab = IA.clsAuthorizeBatch() > auth = DispatchEx(iab.CLSID) ... where I've imported the gen_py module under the name IA (I've copied the module file to the same folder as the service, so there's no issue with py2exe or the executable not being able to find it). In this case, the hangup occurs in the first statement. I've tried running the code with and without wrapping it in CoInitialize/Couninitialize. I've run out of things I can think of to try, or even to get a hint of what might be getting hung up. One last bit of data: looking at the process in Process Explorer, I see that it's very busy for several seconds (about 50% CPU), then goes quiet. Any good words appreciated, -- Don Dwiggins Advanced Publishing Technology From skippy.hammond at gmail.com Thu May 20 00:28:35 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 20 May 2010 08:28:35 +1000 Subject: [python-win32] Problem with service start type "auto" In-Reply-To: <1394.10.14.19.74.1274276175.squirrel@correo.ucf.edu.cu> References: <1394.10.14.19.74.1274276175.squirrel@correo.ucf.edu.cu> Message-ID: <4BF46613.9010300@gmail.com> I'd suggest that remove almost all code from your __init__ function, and instead put it all in SvcDoRun - once SvcDoRun has been called we have already reported success to the service control manager and taking a little time to, eg, enumerate the registry will not cause problems. HTH, Mark On 19/05/2010 11:36 PM, Boris Perez Canedo wrote: > Hi everybody. > > I'm new in the list and I'm not an english speaking person. If you see a > lot of mistakes please excuse me I'm trying my best. > > I have a compiled python service which I can install, remove, start and > stop without errors (manually). The problem ocurrs when I change the > start type and set it to "auto". Then I restart my computer to see if > the service starts correctly. I see two errors informed by the service > control manager: > > 1)Timeout (30000 ms.) for connection to WBEM Inv service. > > And right after that. > > 2)The service did not responde to the start or control request in a > timely fashion. > > If I go and perform an explicit start, keeping the start type in auto, > the service starts and no errors are informed. > > I don't understand why the operating system can not start the service by > itself. > > This is the output for "sc interrogate" on my service in case it helps: > > SERVICE_NAME: WBEMInv > TYPE : 10 WIN32_OWN_PROCESS > STATE : 4 RUNNING > (STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN) > WIN32_EXIT_CODE : 0 (0x0) > SERVICE_EXIT_CODE : 0 (0x0) > CHECKPOINT : 0x0 > WAIT_HINT : 0x0 > > > My python code: > > import win32serviceutil > import win32service > import win32event > import servicemanager > import os > > def system(): > # my system implementation. > > class XmlRPCService(win32serviceutil.ServiceFramework): > _svc_name_ = 'WBEMInv' > _svc_display_name_ = "WBEM Inventory" > _svc_description_ = 'Servicio xml rpc para realizar inventario de > ordenadores conectados a redes hibridas' > def __init__(self, args): > key = > _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"SOFTWARE\\UCf\\WBEMInv\\Settings") > path = _winreg.EnumValue(key, 0)[1] > os.chdir(path) # I dont want the working directory to be system32. > _winreg.CloseKey(key) > win32serviceutil.ServiceFramework.__init__(self, args) > self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) > def SvcStop(self): > self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) > sys.stopservice = "true" > win32event.SetEvent(self.hWaitStop) > def SvcDoRun(self): > system() > > if __name__=='__main__': > win32serviceutil.HandleCommandLine(XmlRPCService) > > Thank you very much. > > Boris. > > ------------------------------------------------------------------------ > > Convencion Internacional de Psicologia y Ciencias Sociales y Humanas > > Cienfuegos, Cuba, del 19 al 22 de abril del 2011 > > http://promociondeeventos.sld.cu/hominis2011 > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From docdoster at gmail.com Thu May 20 23:46:05 2010 From: docdoster at gmail.com (George Doster) Date: Thu, 20 May 2010 16:46:05 -0500 Subject: [python-win32] Python, COM, VARIANT, VT_BYREF, Joy! Message-ID: Hello All, I'm trying to write a Python program that uses a provided ActiveX component. I have verified the component works ok with Visual Basic. I have used makepy to build the import module for my ActiveX component. I can successfully load the component via the ActiveXCtrl class found in wxPython. My issue is how to call one of the methods of the ActiveX component. The method requires a pointer to a variant. Excerpt from the makepy created module: def OpenUSB(self, lWarning=defaultNamedNotOptArg): return self._oleobj_.InvokeTypes(1, LCID, 1, (3, 0), ((16387, 0),),lWarning) As you can see, the first arg is a VT_BYREF | VT_I4. How do I call this from Python? How do I get a long int pointer to pass to this function? I've played around with comtypes and the VARIANT class, but I can't seem to find the right combo to get what I need. J -------------- next part -------------- An HTML attachment was scrubbed... URL: From docdoster at gmail.com Fri May 21 16:15:14 2010 From: docdoster at gmail.com (George Doster) Date: Fri, 21 May 2010 09:15:14 -0500 Subject: [python-win32] Python, COM, VARIANT, VT_BYREF, Joy! Message-ID: Hello All, I'm trying to write a Python program that uses a provided ActiveX component. I have verified the component works ok with Visual Basic. I have used makepy to build the import module for my ActiveX component. I can successfully load the component via the ActiveXCtrl class found in wxPython. My issue is how to call one of the methods of the ActiveX component. The method requires a pointer to a variant. Excerpt from the makepy created module: def OpenUSB(self, lWarning= defaultNamedNotOptArg): return self._oleobj_.InvokeTypes(1, LCID, 1, (3, 0), ((16387, 0),),lWarning) As you can see, the first arg is a VT_BYREF | VT_I4. How do I call this from Python? How do I get a long int pointer to pass to this function? I've played around with comtypes and the VARIANT class, but I can't seem to find the right combo to get what I need. J -------------- next part -------------- An HTML attachment was scrubbed... URL: From janssen at parc.com Fri May 21 23:03:27 2010 From: janssen at parc.com (Bill Janssen) Date: Fri, 21 May 2010 14:03:27 PDT Subject: [python-win32] does pipes.quote() work properly on Windows? In-Reply-To: References: Message-ID: <60485.1274475807@parc.com> Anyone know if the quote() function in the "pipes" module does the right thing for cmd.exe pipes? If not, what is the right thing? Bill From timr at probo.com Sat May 22 00:38:42 2010 From: timr at probo.com (Tim Roberts) Date: Fri, 21 May 2010 15:38:42 -0700 Subject: [python-win32] does pipes.quote() work properly on Windows? In-Reply-To: <60485.1274475807@parc.com> References: <60485.1274475807@parc.com> Message-ID: <4BF70B72.7090905@probo.com> Bill Janssen wrote: > Anyone know if the quote() function in the "pipes" module does the right > thing for cmd.exe pipes? > No, it doesn't. It uses sh rules, which aren't the same. > If not, what is the right thing? Unfortunately, command line parsing in Windows is not centralized in the shell. To satisfy cmd.exe, you can safely surround each file name in double quotes. Whether the application knows how to handle that or not is up to the application (although most do it correctly). Remember that this is only necessary when passing names to the command shell. The Windows APIs don't want the quotes. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From janssen at parc.com Sat May 22 03:28:26 2010 From: janssen at parc.com (Bill Janssen) Date: Fri, 21 May 2010 18:28:26 PDT Subject: [python-win32] does pipes.quote() work properly on Windows? In-Reply-To: <4BF70B72.7090905@probo.com> References: <60485.1274475807@parc.com> <4BF70B72.7090905@probo.com> Message-ID: <63832.1274491706@parc.com> Tim Roberts wrote: > Bill Janssen wrote: > > Anyone know if the quote() function in the "pipes" module does the right > > thing for cmd.exe pipes? > > > > No, it doesn't. It uses sh rules, which aren't the same. > > > If not, what is the right thing? > > Unfortunately, command line parsing in Windows is not centralized in the > shell. To satisfy cmd.exe, you can safely surround each file name in > double quotes. Whether the application knows how to handle that or not > is up to the application (although most do it correctly). Remember that > this is only necessary when passing names to the command shell. The > Windows APIs don't want the quotes. I'm actually not passing file names. I'm passing argument strings, which may contain spaces, quotes, and other things. For instance, myprogram --title="That's the game! says Mike "Hammer" Brotsky" --file=... "myprogram" is a Python program, and expects to get the whole "--title" argument as a single element of sys.argv. On Unix, I use arg = "--title=%s" % pipes.quote(title) to achieve that effect. What's the equivalent on Windows? Since cmd.exe also supports pipelines, I'd sort of expect it to do the right thing on Windows, too. Bill From andrea.gavana at gmail.com Sat May 22 15:10:35 2010 From: andrea.gavana at gmail.com (Andrea Gavana) Date: Sat, 22 May 2010 18:10:35 +0500 Subject: [python-win32] Makepy static and dynamic Dispatch COM headache Message-ID: Hi All, I have been spending the most part of the day to try to use makepy or Dispatch on a proprietary dll library (PISDK for those who know it). I did the following 2 things (not at the same time): 1) makepy.py -o PISDK.py C:/Program Files/PIPC/PISDK/pisdk.dll And I got a nice and big PISDK.py file on my computer, with all the methods/attributes I could ever need. However, when I try to use it, I get this: import PISDK servers = PISDK.Servers() D:\MyProjects\PI>PI.py Traceback (most recent call last): File "D:\MyProjects\PI\PI.py", line 9, in servers = PISDK.Servers() File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line 420, in __init__ oobj = pythoncom.new(self.CLSID) pywintypes.com_error: (-2147221164, 'Class not registered', None, None) Not good. 2) If I try to be smart and use Dispatch, I get the following: PISDK = Dispatch("PISDK.PISDK.1") server = PISDK.Servers.DefaultServer server.Open() point = server.PIPoints("KA:Well:WP9810_PI002.PV") data = point.Data.Snapshot print data.Value # => 106.406433105 print data.TimeStamp.LocalDate # => 05/22/10 18:05:04 start = "01/01/2010" end = "10/01/2010" # Here we crash print point.Data.InterpolatedValues2(start, end, 10) Traceback (most recent call last): File "D:\MyProjects\PI\PI.py", line 20, in point.Data.InterpolatedValues2(start, end, 10) File ">", line 4, in InterpolatedValues2 File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 272, in _ApplyTypes_ result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args) TypeError: The Python instance can not be converted to a COM object Not good. Could someone please offer some suggestions about these issues? I am really stuck, and no expert at all with COM... Thank you in advance. Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.alice.it/infinity77/ ==> Never *EVER* use RemovalGroup for your house removal. You'll regret it forever. http://thedoomedcity.blogspot.com/2010/03/removal-group-nightmare.html <== From greg.ewing at canterbury.ac.nz Sun May 23 03:00:18 2010 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Sun, 23 May 2010 13:00:18 +1200 Subject: [python-win32] does pipes.quote() work properly on Windows? In-Reply-To: <63832.1274491706@parc.com> References: <60485.1274475807@parc.com> <4BF70B72.7090905@probo.com> <63832.1274491706@parc.com> Message-ID: <4BF87E22.4080600@canterbury.ac.nz> Bill Janssen wrote: > myprogram --title="That's the game! says Mike "Hammer" Brotsky" --file=... > Since > cmd.exe also supports pipelines, I'd sort of expect it to do the right > thing on Windows, too. Don't know about later versions, but in Python 2.5 the pipes module is listed under "Unix specific services", so I guess it was never designed with Windows in mind. The reason it fails on Windows is that it assumes single quotes can be used to quote a string containing double quotes. But Windows usually requires double quotes around arguments, so you will have to escape the inner quotes: --title="That's the game! says Mike \"Hammer\" Brotsky" A quick test suggests that this will work, at least in the case where the program being passed the args is a Python program. -- Greg From waldemar.osuch at gmail.com Sun May 23 19:10:16 2010 From: waldemar.osuch at gmail.com (Waldemar Osuch) Date: Sun, 23 May 2010 11:10:16 -0600 Subject: [python-win32] does pipes.quote() work properly on Windows? In-Reply-To: <60485.1274475807@parc.com> References: <60485.1274475807@parc.com> Message-ID: On Fri, May 21, 2010 at 15:03, Bill Janssen wrote: > Anyone know if the quote() function in the "pipes" module does the right > thing for cmd.exe pipes? > > If not, what is the right thing? > twisted.python.win32 has a couple functions that try very hard to get the quoting right. http://twistedmatrix.com/documents/current/api/twisted.python.win32.html#quoteArguments From janssen at parc.com Mon May 24 00:40:27 2010 From: janssen at parc.com (Bill Janssen) Date: Sun, 23 May 2010 15:40:27 PDT Subject: [python-win32] does pipes.quote() work properly on Windows? In-Reply-To: References: <60485.1274475807@parc.com> Message-ID: <64415.1274654427@parc.com> Waldemar Osuch wrote: > On Fri, May 21, 2010 at 15:03, Bill Janssen wrote: > > Anyone know if the quote() function in the "pipes" module does the right > > thing for cmd.exe pipes? > > > > If not, what is the right thing? > > > twisted.python.win32 has a couple functions that try very hard to get > the quoting right. > http://twistedmatrix.com/documents/current/api/twisted.python.win32.html#quoteArguments There also seems to be an undocumented function (not a method, as the docs erroneously mention in passing) in the "subprocess" module, called "list2cmdline", which appropriately quotes things for win32's CreateProcess(). Interesting to see that both functions do the same thing: MARLOWE-VM:~ $ python -i Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import subprocess >>> subprocess.list2cmdline(["That's the game! says Mike \"Hammer\" Brotsky"]) '"That\'s the game! says Mike \\"Hammer\\" Brotsky"' >>> import pipes >>> pipes.quote("That's the game! says Mike \"Hammer\" Brotsky") '"That\'s the game! says Mike \\"Hammer\\" Brotsky"' >>> And the code in Twisted generates the same thing: >>> import win32 >>> win32.quoteArguments(["That's the game! says Mike \"Hammer\" Brotsky"]) '"That\'s the game! says Mike \\"Hammer\\" Brotsky"' >>> Bill From skippy.hammond at gmail.com Mon May 24 15:25:04 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Mon, 24 May 2010 23:25:04 +1000 Subject: [python-win32] Python, COM, VARIANT, VT_BYREF, Joy! In-Reply-To: References: Message-ID: <4BFA7E30.6000300@gmail.com> On 22/05/2010 12:15 AM, George Doster wrote: > Hello All, > > I'm trying to write a Python program that uses a provided ActiveX > component. I have verified the component works ok with Visual Basic. > > I have used makepy to build the import module for my ActiveX component. > > I can successfully load the component via the ActiveXCtrl class found in > wxPython. > > My issue is how to call one of the methods of the ActiveX component. The > method requires a pointer to a variant. > > Excerpt from the makepy created module: > > def OpenUSB(self, lWarning= > defaultNamedNotOptArg): > return self._oleobj_.InvokeTypes(1, LCID, 1, (3, 0), ((16387, > 0),),lWarning) > > As you can see, the first arg is a VT_BYREF | VT_I4. You should find that you don't need to supply the argument at all - win32com should initialize and provide the param for you and return the final result in the return value - assuming the param is an 'out' param. Cheers, Mark From timr at probo.com Mon May 24 19:04:33 2010 From: timr at probo.com (Tim Roberts) Date: Mon, 24 May 2010 10:04:33 -0700 Subject: [python-win32] does pipes.quote() work properly on Windows? In-Reply-To: <63832.1274491706@parc.com> References: <60485.1274475807@parc.com> <4BF70B72.7090905@probo.com> <63832.1274491706@parc.com> Message-ID: <4BFAB1A1.6090102@probo.com> Bill Janssen wrote: > I'm actually not passing file names. I'm passing argument strings, > which may contain spaces, quotes, and other things. For instance, > > myprogram --title="That's the game! says Mike "Hammer" Brotsky" --file=... > > "myprogram" is a Python program, and expects to get the whole "--title" > argument as a single element of sys.argv. > > On Unix, I use > > arg = "--title=%s" % pipes.quote(title) > > to achieve that effect. What's the equivalent on Windows? Since > cmd.exe also supports pipelines, I'd sort of expect it to do the right > thing on Windows, too. > Ah, foolish mortal. The problem with Windows is that, as I said, there is no central command-line parser, so there is no single set of rules. Cmd.exe does not parse the command line. Cmd.exe does not create argc/argv. Cmd.exe just passes the whole command line as a string. For C programs, the C run-time library will crack that string into argc/argv. Python on Windows has its own parser. If you are creating a list of arguments to pass AS A LIST, then no quoting is necessary. If you intend to mash them together into a single string, then I'm afraid you will need to experiment. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From vernondcole at gmail.com Mon May 24 19:33:50 2010 From: vernondcole at gmail.com (Vernon Cole) Date: Mon, 24 May 2010 11:33:50 -0600 Subject: [python-win32] Python, COM, VARIANT, VT_BYREF, Joy! In-Reply-To: <4BFA7E30.6000300@gmail.com> References: <4BFA7E30.6000300@gmail.com> Message-ID: If I Recall Correctly, the ActiveXCtrl class in wxPython does not use the pywin32 tools, but a different package. That, along with no plans to migrate to Python 3, is why my own work is migrating away from wxPython. Too bad, too. I rather liked wxPython. -- Vernon Cole On Mon, May 24, 2010 at 7:25 AM, Mark Hammond wrote: > On 22/05/2010 12:15 AM, George Doster wrote: > >> Hello All, >> >> I'm trying to write a Python program that uses a provided ActiveX >> component. I have verified the component works ok with Visual Basic. >> >> I have used makepy to build the import module for my ActiveX component. >> >> I can successfully load the component via the ActiveXCtrl class found in >> wxPython. >> >> My issue is how to call one of the methods of the ActiveX component. The >> method requires a pointer to a variant. >> >> Excerpt from the makepy created module: >> >> def OpenUSB(self, lWarning= >> defaultNamedNotOptArg): >> return self._oleobj_.InvokeTypes(1, LCID, 1, (3, 0), ((16387, >> 0),),lWarning) >> >> As you can see, the first arg is a VT_BYREF | VT_I4. >> > > You should find that you don't need to supply the argument at all - > win32com should initialize and provide the param for you and return the > final result in the return value - assuming the param is an 'out' param. > > Cheers, > > Mark > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From janssen at parc.com Mon May 24 20:19:28 2010 From: janssen at parc.com (Bill Janssen) Date: Mon, 24 May 2010 11:19:28 PDT Subject: [python-win32] does pipes.quote() work properly on Windows? In-Reply-To: <4BFAB1A1.6090102@probo.com> References: <60485.1274475807@parc.com> <4BF70B72.7090905@probo.com> <63832.1274491706@parc.com> <4BFAB1A1.6090102@probo.com> Message-ID: <81155.1274725168@parc.com> Tim Roberts wrote: > Bill Janssen wrote: > > I'm actually not passing file names. I'm passing argument strings, > > which may contain spaces, quotes, and other things. For instance, > > > > myprogram --title="That's the game! says Mike "Hammer" Brotsky" --file=... > > > > "myprogram" is a Python program, and expects to get the whole "--title" > > argument as a single element of sys.argv. > > > > On Unix, I use > > > > arg = "--title=%s" % pipes.quote(title) > > > > to achieve that effect. What's the equivalent on Windows? Since > > cmd.exe also supports pipelines, I'd sort of expect it to do the right > > thing on Windows, too. > > > > Ah, foolish mortal. Quixotic, perhaps, to attempt to achieve consistency on Windows... Actually, my last sentence there was more about, "Why doesn't the pipes module also work on Windows?", than it was about quoting. > The problem with Windows is that, as I said, there is no central > command-line parser, so there is no single set of rules. Cmd.exe does > not parse the command line. Cmd.exe does not create argc/argv. Cmd.exe > just passes the whole command line as a string. For C programs, the C > run-time library will crack that string into argc/argv. Python on > Windows has its own parser. The subprocess module has an idea of how it should work. Whether or not it's correct is a different matter. So, is the algorithm the same for the visual studio C runtime's parser, and Python's parser? I'd expect that, since CPython is a C program that uses VS C. If so, I'd be happy to settle for that "standard". The algorithm in the subprocess module is documented thusly: Translate a sequence of arguments into a command line string, using the same rules as the MS C runtime: 1) Arguments are delimited by white space, which is either a space or a tab. 2) A string surrounded by double quotation marks is interpreted as a single argument, regardless of white space or pipe characters contained within. A quoted string can be embedded in an argument. 3) A double quotation mark preceded by a backslash is interpreted as a literal double quotation mark. 4) Backslashes are interpreted literally, unless they immediately precede a double quotation mark. 5) If backslashes immediately precede a double quotation mark, every pair of backslashes is interpreted as a literal backslash. If the number of backslashes is odd, the last backslash escapes the next double quotation mark as described in rule 3. """ # See # http://msdn.microsoft.com/en-us/library/17w5ykft.aspx # or search http://msdn.microsoft.com for # "Parsing C++ Command-Line Arguments" Bill From ddwiggins at advpubtech.com Tue May 25 00:36:52 2010 From: ddwiggins at advpubtech.com (Don Dwiggins) Date: Mon, 24 May 2010 15:36:52 -0700 Subject: [python-win32] Python service hangs in Dispatch when frozen with py2exe In-Reply-To: References: Message-ID: OK, I have more information that may help. Looking into the code invoked by IA.clsAuthorizeBatch(), I've found that the hangup occurs in the call to pythoncom.new in CoClassBaseClass in win32com\client\__init__.py. Interestingly, if I run the code in the "main" Twisted thread, it executes without a problem (this is running the source, with py2exe out of the picture). If I run it in a subthread (using Twisted's DeferToThread) it hangs in the following call: > oo = pythoncom.new(IA.clsAuthorizeBatch.CLSID) .. where IA is the gen_py file, as before. The COM DLL is implemented in VB with a single threaded model (although I've tried making it apartment threaded as well). I can't go any deeper at the python level, since pythoncom is a DLL. As before, any advice appreciated ... I wrote previously: > I'm developing a Python service under Win XP with Python 2.5 (the > service is built on Twisted's XMLRPC server). For delivery to > production, I "compile" it with py2exe. It's been running fine, but > I've hit a snag. > > I've written new code to access a COM object (in a DLL); the code I've > written does works successfully as long as I'm running the source under > PythonService. > > The compiled version, however, hangs up in the call to Dispatch to get > the COM object. I've put in debugging log entries all through the > relevant section of code, and it's clear that it simply never returns > from the Dispatch call. I've tried EnsureDispatch as well, and more > recently the following code: > >> iab = IA.clsAuthorizeBatch() >> auth = DispatchEx(iab.CLSID) > > ... where I've imported the gen_py module under the name IA (I've copied > the module file to the same folder as the service, so there's no issue > with py2exe or the executable not being able to find it). In this case, > the hangup occurs in the first statement. I've tried running the code > with and without wrapping it in CoInitialize/Couninitialize. > > I've run out of things I can think of to try, or even to get a hint of > what might be getting hung up. One last bit of data: looking at the > process in Process Explorer, I see that it's very busy for several > seconds (about 50% CPU), then goes quiet. > > Any good words appreciated, From docdoster at gmail.com Tue May 25 00:43:27 2010 From: docdoster at gmail.com (George Doster) Date: Mon, 24 May 2010 17:43:27 -0500 Subject: [python-win32] Python, COM, VARIANT, VT_BYREF, Joy! In-Reply-To: <4BFA7E30.6000300@gmail.com> References: <4BFA7E30.6000300@gmail.com> Message-ID: On Mon, May 24, 2010 at 8:25 AM, Mark Hammond wrote: > On 22/05/2010 12:15 AM, George Doster wrote: > >> Hello All, >> >> I'm trying to write a Python program that uses a provided ActiveX >> component. I have verified the component works ok with Visual Basic. >> >> I have used makepy to build the import module for my ActiveX component. >> >> I can successfully load the component via the ActiveXCtrl class found in >> wxPython. >> >> My issue is how to call one of the methods of the ActiveX component. The >> method requires a pointer to a variant. >> >> Excerpt from the makepy created module: >> >> def OpenUSB(self, lWarning= >> defaultNamedNotOptArg): >> return self._oleobj_.InvokeTypes(1, LCID, 1, (3, 0), ((16387, >> 0),),lWarning) >> >> As you can see, the first arg is a VT_BYREF | VT_I4. >> > > You should find that you don't need to supply the argument at all - > win32com should initialize and provide the param for you and return the > final result in the return value - assuming the param is an 'out' param. > > Cheers, > > Mark > Hi Mark, On calling OpenUSB with no argument I get: Traceback (most recent call last): File "pyNovaII_new.py", line 22, in OnTest print app.OphirCtrl.ctrl.OpenUSB() File "C:\Python26\lib\site-packages\comtypes\__init__.py", line 517, in func return self.Invoke(obj, memid, _invkind=1, *args, **kw) # DISPATCH_METHOD File "C:\Python26\lib\site-packages\comtypes\automation.py", line 710, in Invoke byref(result), byref(excepinfo), byref(argerr)) _ctypes.COMError: (-2147352561, 'Parameter not optional.', (None, None, None, 0, None)) Parameter no optional.... :( J -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Tue May 25 02:03:06 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 25 May 2010 10:03:06 +1000 Subject: [python-win32] Python service hangs in Dispatch when frozen with py2exe In-Reply-To: References: Message-ID: <4BFB13BA.1030009@gmail.com> It might be worth making a call to pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED) in the thread which is doing this work. I *suspect* the problem will be related to when the import of pythoncom happens in the 2 environments - when it is first imported, it will call CoInitialize for you on that thread under the assumption it is the "main" thread. On a py2exe environment, it may be that for obscure reasons, that first import of pythoncom happens on a different thread. Googling for 'coinit_flags' should turn up more background about how CoInit is done and can be controlled in pythoncom. HTH, Mark On 25/05/2010 8:36 AM, Don Dwiggins wrote: > OK, I have more information that may help. Looking into the code > invoked by IA.clsAuthorizeBatch(), I've found that the hangup occurs in > the call to pythoncom.new in CoClassBaseClass in > win32com\client\__init__.py. > > Interestingly, if I run the code in the "main" Twisted thread, it > executes without a problem (this is running the source, with py2exe out > of the picture). If I run it in a subthread (using Twisted's > DeferToThread) it hangs in the following call: > >> oo = pythoncom.new(IA.clsAuthorizeBatch.CLSID) > > .. where IA is the gen_py file, as before. The COM DLL is implemented in > VB with a single threaded model (although I've tried making it apartment > threaded as well). > > I can't go any deeper at the python level, since pythoncom is a DLL. > > As before, any advice appreciated ... > > I wrote previously: >> I'm developing a Python service under Win XP with Python 2.5 (the >> service is built on Twisted's XMLRPC server). For delivery to >> production, I "compile" it with py2exe. It's been running fine, but >> I've hit a snag. >> >> I've written new code to access a COM object (in a DLL); the code I've >> written does works successfully as long as I'm running the source >> under PythonService. >> >> The compiled version, however, hangs up in the call to Dispatch to get >> the COM object. I've put in debugging log entries all through the >> relevant section of code, and it's clear that it simply never returns >> from the Dispatch call. I've tried EnsureDispatch as well, and more >> recently the following code: >> >>> iab = IA.clsAuthorizeBatch() >>> auth = DispatchEx(iab.CLSID) >> >> ... where I've imported the gen_py module under the name IA (I've >> copied the module file to the same folder as the service, so there's >> no issue with py2exe or the executable not being able to find it). In >> this case, the hangup occurs in the first statement. I've tried >> running the code with and without wrapping it in >> CoInitialize/Couninitialize. >> >> I've run out of things I can think of to try, or even to get a hint of >> what might be getting hung up. One last bit of data: looking at the >> process in Process Explorer, I see that it's very busy for several >> seconds (about 50% CPU), then goes quiet. >> >> Any good words appreciated, > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From ddwiggins at advpubtech.com Tue May 25 03:27:40 2010 From: ddwiggins at advpubtech.com (Don Dwiggins) Date: Mon, 24 May 2010 18:27:40 -0700 Subject: [python-win32] Python service hangs in Dispatch when frozen with py2exe In-Reply-To: <4BFB13BA.1030009@gmail.com> References: <4BFB13BA.1030009@gmail.com> Message-ID: <4BFB278C.3020300@advpubtech.com> Mark, Thanks for the feedback. > It might be worth making a call to > pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED) in the thread > which is doing this work. Yes, I've tried both apartment and multithreading models (building the DLL each way and using the corresponfing COINIT flag) -- no luck there. I've even built the project (VB6) as an EXE, and using the clsctx argument of Dispatch to call it as such -- same result. > I *suspect* the problem will be related to when the import of > pythoncom happens in the 2 environments - when it is first imported, > it will call CoInitialize for you on that thread under the assumption > it is the "main" thread. On a py2exe environment, it may be that for > obscure reasons, that first import of pythoncom happens on a different > thread. Googling for 'coinit_flags' should turn up more background > about how CoInit is done and can be controlled in pythoncom. There's a good hint there. I've got all my imports listed at the top of the file. I do know that, when using the source, the file is read twice -- once from the command line by the usual Python interpreter, and once by PythonService; it must be different, though, when the compiled .exe is run both to install and to start the service. I can't quite use the hint to figure out why it should fail when I do an explicit CoInitialize at the start of a thread. I am almost sure by now that threads are involved, somehow; unfortunately, I still can't tell what I need to change to make it work properly. To summarize what I've tried: 1. Running the service from the source: a. Calling Dispatch "in line" in the main thread: works. b. Putting the same sequence of code in a subthread: fails (no matter what permutation I use). 2. Freezing the 1.a code: fails. (I haven't tried freezing 1.b) I think (not sure) that the point where it hangs is always in pythoncom.new (for all permutations), where it's getting the OLE object to be wrapped. The question is, where in that function could it hang up waiting for something to happen? Again, thanks for your assistance, -- Don Dwiggins Advanced Publishing Technology > > On 25/05/2010 8:36 AM, Don Dwiggins wrote: >> OK, I have more information that may help. Looking into the code >> invoked by IA.clsAuthorizeBatch(), I've found that the hangup occurs in >> the call to pythoncom.new in CoClassBaseClass in >> win32com\client\__init__.py. >> >> Interestingly, if I run the code in the "main" Twisted thread, it >> executes without a problem (this is running the source, with py2exe out >> of the picture). If I run it in a subthread (using Twisted's >> DeferToThread) it hangs in the following call: >> >>> oo = pythoncom.new(IA.clsAuthorizeBatch.CLSID) >> >> .. where IA is the gen_py file, as before. The COM DLL is implemented in >> VB with a single threaded model (although I've tried making it apartment >> threaded as well). >> >> I can't go any deeper at the python level, since pythoncom is a DLL. >> >> As before, any advice appreciated ... >> >> I wrote previously: >>> I'm developing a Python service under Win XP with Python 2.5 (the >>> service is built on Twisted's XMLRPC server). For delivery to >>> production, I "compile" it with py2exe. It's been running fine, but >>> I've hit a snag. >>> >>> I've written new code to access a COM object (in a DLL); the code I've >>> written does works successfully as long as I'm running the source >>> under PythonService. >>> >>> The compiled version, however, hangs up in the call to Dispatch to get >>> the COM object. I've put in debugging log entries all through the >>> relevant section of code, and it's clear that it simply never returns >>> from the Dispatch call. I've tried EnsureDispatch as well, and more >>> recently the following code: >>> >>>> iab = IA.clsAuthorizeBatch() >>>> auth = DispatchEx(iab.CLSID) >>> >>> ... where I've imported the gen_py module under the name IA (I've >>> copied the module file to the same folder as the service, so there's >>> no issue with py2exe or the executable not being able to find it). In >>> this case, the hangup occurs in the first statement. I've tried >>> running the code with and without wrapping it in >>> CoInitialize/Couninitialize. >>> >>> I've run out of things I can think of to try, or even to get a hint of >>> what might be getting hung up. One last bit of data: looking at the >>> process in Process Explorer, I see that it's very busy for several >>> seconds (about 50% CPU), then goes quiet. >>> >>> Any good words appreciated, >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 > From inf200523 at ucf.edu.cu Tue May 25 15:38:56 2010 From: inf200523 at ucf.edu.cu (Boris Perez Canedo) Date: Tue, 25 May 2010 09:38:56 -0400 (EDT) Subject: [python-win32] problem with wmi within a service Message-ID: <1203.10.14.19.74.1274794736.squirrel@correo.ucf.edu.cu> Hi everybody, I'm having a problem when I try to query a remote (only a remote )computer using wmi. The python code has been compiled to become a windows service. I'm planning to query systems that implement the DMTF standard, WBEM, and for that I need a class that can handle cim-xml protocol and wmi connections. The functionalities are accessed through a XML-RPC server which is run in a separated thread inside the SvcDoRun method. This server has a procedure called Query that is used, obviously, to querie a remote systems or the local system. Inside this procedure I do the pythoncom.CoInitialize and pythoncom.CoUninitialize and in between I use the conection class mentioned above. The service work perfect when I query localhost but fails to query any remote machine. I have tried wmitester.exe a tool to test wmi and using the same user and password and remote? machine it works so It is not a permission problem. I also changed the name of the module wmi to my_wmi in case there could be a problem with wmi.dll but nothing changes.?The exception is here (__init__ at WBEMConn): ... self.conn = None ... try: ??? self.conn = wmi.WMI(computer = self.host, user = self.user, password = self.password) ??? self.system = "wmi" except wmi.x_access_denied: ????self.status = "access_denied" ??? return I have a module for the connection class (It has been tested outside the service and it works). import pywbem import wmi class WBEMConn: ??? def __init__(self, url, user, password) ????????? self.url = url ????????? self.user = user ????????? self.passwd = password ????????? self.conn = None ????????? #--------Here the is attempted a connection to a system which might be using cim-xml protocol ????????? #--------If fails try wmi. ??????????#--------if fails can not talk cim-xml or wmi ?????????? ?????????? ????def?ExecQuery(self,query): ???????? if self.conn is None: ??????????????? return?None ???????? if self.system == "cim-xml": ????????????? result = self.conn.ExecQuery("wql", query)#----for pywbem ?????????else: ?????????????? result ?= self.conn.query(query)????#---for wmi ??????????????? A module that defines a class for the xml-rpc server. class ThreadedXMLRPCServer_BasicAuth(ThreadingMixIn, SimpleXMLRPCServer) class ServerFunc: ????? def Query(self, url, user, password, query): ????????????? try: ????????????????? pythoncom.CoInitialize() ?????????????????????????conn = WBEMConn(url, user, password) ???????????????????????? result = conn.ExecQuery(query) ?????????????? finally: ??????????????????????? pythoncom.CoUninitialize() ???????????????return result?????????????????? The service's SvcDoRun method. def SvcDoRun(self): ????#-----import?all requiered modules ???? def StartServer(): ?????????? self.server.serve_forever() ???? self.server = ThreadedXMLRPCServer_BasicAuth(...) ???? func = ServerFunc() ???? self.server.register_instance(func) ???? StartServer() ???? while self.running: ??????????time.sleep(3) def SvcStop(self): ?? ...... ?? self.server.shutdown() ?? self.running = False ? ..... ???? Thanks a lot, Boris. --- Convencion Internacional de Psicologia y Ciencias Sociales y Humanas Cienfuegos, Cuba, del 19 al 22 de abril del 2011 http://promociondeeventos.sld.cu/hominis2011 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue May 25 16:18:37 2010 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 25 May 2010 15:18:37 +0100 Subject: [python-win32] problem with wmi within a service In-Reply-To: <1203.10.14.19.74.1274794736.squirrel@correo.ucf.edu.cu> References: <1203.10.14.19.74.1274794736.squirrel@correo.ucf.edu.cu> Message-ID: <4BFBDC3D.2010208@timgolden.me.uk> [... snip loads of WMI-related stuff ...] I'm happy to help you with this, but I'm afraid your formatting has defeated my email client. I've got a combination of non-standard space characters, odd line-wraps, and finally code which I don't entirely understand. Would it be possible for you to put something up on pastebin (or some equivalent service)? And, preferably, a self-contained failing example or else the full code? Significantly, I can't make out from your code snippets where the call to wmi.WMI () is happening in the context of the various threads. TJG From uszhaoxin at gmail.com Wed May 26 11:14:49 2010 From: uszhaoxin at gmail.com (Xin Zhao) Date: Wed, 26 May 2010 02:14:49 -0700 Subject: [python-win32] Help! How to get IHTMLDocument3 dispatch object? Message-ID: Hey, I am trying to get the Dispatch object of IHTMLDocument3, so I wrote the following code wo = pythoncom.New('InternetExplorer.Application') wo.QueryInterface('{3050F673-98B5-11CF-BB82-00AA00BDCE0B}') But got the following error: pywintypes.com_error: (-2147467262, 'No such interface supported', None, None) Any idea on how to address this problem? Thanks, xin -------------- next part -------------- An HTML attachment was scrubbed... URL: From uszhaoxin at gmail.com Wed May 26 11:18:59 2010 From: uszhaoxin at gmail.com (Xin Zhao) Date: Wed, 26 May 2010 02:18:59 -0700 Subject: [python-win32] Please help! How to get the event handler with IE Dom interfaces? Message-ID: Hey all, I am using pywin32 code get all event handlers defined in a HTML page in IE. I used pythoncom to start IE, then get document, and finally reached IHTMLElement object. If the html page defines "onclick=xxx", element.onclick returns the click handler. However, if an event handler is defined in javascript, element.onclick simply returns NULL. What's the right way to get the event handler then? Note: I don't have to know detail about the event handler. It's good enough to know that an event handler is associated with an element. Thanks, xin Below is an example that uses javascript to define event handler. jQuery -------------- next part -------------- An HTML attachment was scrubbed... URL: From john at saponara.net Thu May 27 17:56:03 2010 From: john at saponara.net (John) Date: Thu, 27 May 2010 11:56:03 -0400 Subject: [python-win32] unable to read mssql varchar(max) Message-ID: <4BFE9613.8080405@saponara.net> Hi, When a ms sql server database column was changed to varchar(max), my python code became unable to read that column. no matter the actual value, python sees it as '\x00'. I use sql server 2008, python 2.4, and pywin32-214. it had worked when the column was a fixed size varchar, eg varchar(1000). essentially my code is: connectionString=r"driver={SQL Server Native Client 10.0};server=...;uid=...;pwd=...;database=..." connection=odbc.odbc(connectionString) cursor=connection.cursor cursor.execute("select ...") cursor.fetchall() Could anyone suggest what the problem might be? Thanks, John From planders at gmail.com Thu May 27 18:18:22 2010 From: planders at gmail.com (Preston Landers) Date: Thu, 27 May 2010 11:18:22 -0500 Subject: [python-win32] unable to read mssql varchar(max) In-Reply-To: <4BFE9613.8080405@saponara.net> References: <4BFE9613.8080405@saponara.net> Message-ID: varchar(max) columns are like CLOBs, character large objects, and I'm not sure how well that odbc module handles them. I ended up switching to pyODBC which does handle them. Unfortunately it might not be just a drop-in replacement, and pyODBC does have its own issues. But so far it's working pretty well for us. http://code.google.com/p/pyodbc/ On Thu, May 27, 2010 at 10:56 AM, John wrote: > Hi, > > When a ms sql server database column was changed to varchar(max), my python > code became unable to read that column. no matter the actual value, python > sees it as '\x00'. I use sql server 2008, python 2.4, and pywin32-214. it > had worked when the column was a fixed size varchar, eg varchar(1000). > essentially my code is: > > connectionString=r"driver={SQL Server Native Client > 10.0};server=...;uid=...;pwd=...;database=..." > connection=odbc.odbc(connectionString) > cursor=connection.cursor > cursor.execute("select ...") > cursor.fetchall() > > Could anyone suggest what the problem might be? > > Thanks, > John > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu May 27 19:18:32 2010 From: timr at probo.com (Tim Roberts) Date: Thu, 27 May 2010 10:18:32 -0700 Subject: [python-win32] Please help! How to get the event handler with IE Dom interfaces? In-Reply-To: References: Message-ID: <4BFEA968.20707@probo.com> Xin Zhao wrote: > > I am using pywin32 code get all event handlers defined in a HTML page > in IE. I used pythoncom to start IE, then get document, and finally > reached IHTMLElement object. If the html page defines "onclick=xxx", > element.onclick returns the click handler. However, if an event > handler is defined in javascript, element.onclick simply returns NULL. > What's the right way to get the event handler then? > > Note: I don't have to know detail about the event handler. It's good > enough to know that an event handler is associated with an element. The code below adds the "click" event on the fly, in a callback event that happens after the page has loaded. It's quite possible that you are querying the document before the "ready" callback has completed. You might try delaying for a bit before you check for the handler. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From vernondcole at gmail.com Thu May 27 19:26:27 2010 From: vernondcole at gmail.com (Vernon Cole) Date: Thu, 27 May 2010 11:26:27 -0600 Subject: [python-win32] unable to read mssql varchar(max) In-Reply-To: References: <4BFE9613.8080405@saponara.net> Message-ID: I ran into the same problem using adodbapi. I tracked it down to the COM call which errored out, and decided that maybe it was a Microsoft problem and ignored it, just leaving the application broken on that feature. If pyODBC can do it, then the problem must be in the COM routines in pywin32. I can throw together a quick example of the failure if that will help with debugging. It involves a sample SQL data table that must be imported for the test and is not small (several recorded telephone calls as blobs)-- so I will only do it if needed. Does anyone (Mark?) need it? -- Vernon Cole On Thu, May 27, 2010 at 10:18 AM, Preston Landers wrote: > varchar(max) columns are like CLOBs, character large objects, and I'm not > sure how well that odbc module handles them. I ended up switching to > pyODBC which does handle them. Unfortunately it might not be just a drop-in > replacement, and pyODBC does have its own issues. But so far it's working > pretty well for us. > > http://code.google.com/p/pyodbc/ > > > > On Thu, May 27, 2010 at 10:56 AM, John wrote: > >> Hi, >> >> When a ms sql server database column was changed to varchar(max), my >> python code became unable to read that column. no matter the actual value, >> python sees it as '\x00'. I use sql server 2008, python 2.4, and >> pywin32-214. it had worked when the column was a fixed size varchar, eg >> varchar(1000). essentially my code is: >> >> connectionString=r"driver={SQL Server Native Client >> 10.0};server=...;uid=...;pwd=...;database=..." >> connection=odbc.odbc(connectionString) >> cursor=connection.cursor >> cursor.execute("select ...") >> cursor.fetchall() >> >> Could anyone suggest what the problem might be? >> >> Thanks, >> John >> >> >> > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu May 27 20:25:25 2010 From: timr at probo.com (Tim Roberts) Date: Thu, 27 May 2010 11:25:25 -0700 Subject: [python-win32] Help! How to get IHTMLDocument3 dispatch object? In-Reply-To: References: <4BFEA96A.6060802@probo.com> Message-ID: <4BFEB915.1010905@probo.com> Xin Zhao wrote: > Thanks for your kind reply. > > I tried the new iid, doesn't help. :( > > >>> import pythoncom > >>> wo=pythoncom.New('InternetExplorer.Application') > >>> wo.QueryInterface('{3050f485-98b5-11cf-bb82-00aa00bdce0b}') > Traceback (most recent call last): > File "", line 1, in ? > pywintypes.com_error: (-2147467262, 'No such interface supported', > None, None) > > Any further idea? Yes. The Internet Explorer application doesn't support that interface, because a single IE instance can have multiple documents. "wo" will be an instance of IWebBrowser2. You need to fetch a document from that interface, then fetch the IHTMLDocument3 interface from that. You want the Document property, which is either: doc = wo.Document or doc = wo.get_Document() That "doc" object should be an IHTMLDocument2. If you really need the "...3" version, that's where you do the QueryInterface. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu May 27 22:26:31 2010 From: timr at probo.com (Tim Roberts) Date: Thu, 27 May 2010 13:26:31 -0700 Subject: [python-win32] Help! How to get IHTMLDocument3 dispatch object? In-Reply-To: References: <4BFEA96A.6060802@probo.com> <4BFEB915.1010905@probo.com> Message-ID: <4BFED577.4090309@probo.com> Xin Zhao wrote: > I am not sure I follow you. > > What I did was: > > ----------------------------------------------------------------------------------------------------------------------- > >>> wo = pythoncom.New('InternetExplorer.Application') > >>> import win32com.client > >>> w = win32com.client.Dispatch(wo) > >>> w.Navigate('http://google.com') > >>> doc = w.Document That "doc" object is an IHTMLDocument3. No additional magic is required. > Am I missing something? Why does it simply complain that this > interface is not supported? It's indeed supported from MSDN document... You can't just ask any old object for any old interface. You have to ask an object that SUPPORTS that interface. The Internet Explorer application does not support IHTMLDocument3. Only the documents within IE do so. The MSDN articles talk about the Internet Explorer object model, which describes how to get from here to there. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From inf200523 at ucf.edu.cu Thu May 27 23:21:50 2010 From: inf200523 at ucf.edu.cu (Boris Perez Canedo) Date: Thu, 27 May 2010 17:21:50 -0400 (EDT) Subject: [python-win32] problem with wmi within a service In-Reply-To: <4BFBDC3D.2010208@timgolden.me.uk> References: <1203.10.14.19.74.1274794736.squirrel@correo.ucf.edu.cu> <4BFBDC3D.2010208@timgolden.me.uk> Message-ID: <2647.10.14.19.74.1274995310.squirrel@correo.ucf.edu.cu> > [... snip loads of WMI-related stuff ...] > > I'm happy to help you with this, but I'm afraid your formatting has > defeated my email client. I've got a combination of non-standard space > characters, odd line-wraps, and finally code which I don't entirely > understand. > > Would it be possible for you to put something up on pastebin (or some > equivalent service)? And, preferably, a self-contained failing example > or else the full code? Significantly, I can't make out from your code > snippets where the call to wmi.WMI () is happening in the context of > the various threads. > > TJG > _______________________________________________? I'm sorry for that. My email client is also gone mad. It was today when I had the opportunity to read your message. I thought there was a problem with the list. Thanks for your concern. I solved the problem, dont ask me how but it was solved. I rewrote the Query procedure and the connection class. Thanks a lot, Boris. --- Convencion Internacional de Psicologia y Ciencias Sociales y Humanas Cienfuegos, Cuba, del 19 al 22 de abril del 2011 http://promociondeeventos.sld.cu/hominis2011 -------------- next part -------------- An HTML attachment was scrubbed... URL: From uszhaoxin at gmail.com Thu May 27 22:06:09 2010 From: uszhaoxin at gmail.com (Xin Zhao) Date: Thu, 27 May 2010 13:06:09 -0700 Subject: [python-win32] Help! How to get IHTMLDocument3 dispatch object? In-Reply-To: <4BFEB915.1010905@probo.com> References: <4BFEA96A.6060802@probo.com> <4BFEB915.1010905@probo.com> Message-ID: I am not sure I follow you. What I did was: ----------------------------------------------------------------------------------------------------------------------- >>> wo = pythoncom.New('InternetExplorer.Application') >>> import win32com.client >>> w = win32com.client.Dispatch(wo) >>> w.Navigate('http://google.com') >>> doc = w.Document >>> wo.QueryInterface('{3050f485-98b5-11cf-bb82-00aa00bdce0b}') Traceback (most recent call last): File "", line 1, in ? pywintypes.com_error: (-2147467262, 'No such interface supported', None, None) >>> w.QueryInterface('{3050f485-98b5-11cf-bb82-00aa00bdce0b}') Traceback (most recent call last): File "", line 1, in ? File ">", line 2, in QueryInterface pywintypes.com_error: (-2147352573, 'Member not found.', None, None) ----------------------------------------------------------------------------------------------------------------------- Am I missing something? Why does it simply complain that this interface is not supported? It's indeed supported from MSDN document... Thanks, xin On Thu, May 27, 2010 at 11:25 AM, Tim Roberts wrote: > Xin Zhao wrote: > > Thanks for your kind reply. > > > > I tried the new iid, doesn't help. :( > > > > >>> import pythoncom > > >>> wo=pythoncom.New('InternetExplorer.Application') > > >>> wo.QueryInterface('{3050f485-98b5-11cf-bb82-00aa00bdce0b}') > > Traceback (most recent call last): > > File "", line 1, in ? > > pywintypes.com_error: (-2147467262, 'No such interface supported', > > None, None) > > > > Any further idea? > > Yes. The Internet Explorer application doesn't support that interface, > because a single IE instance can have multiple documents. "wo" will be > an instance of IWebBrowser2. You need to fetch a document from that > interface, then fetch the IHTMLDocument3 interface from that. You want > the Document property, which is either: > doc = wo.Document > or > doc = wo.get_Document() > > That "doc" object should be an IHTMLDocument2. If you really need the > "...3" version, that's where you do the QueryInterface. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Fri May 28 08:34:50 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 28 May 2010 16:34:50 +1000 Subject: [python-win32] Python service hangs in Dispatch when frozen with py2exe In-Reply-To: <4BFB278C.3020300@advpubtech.com> References: <4BFB13BA.1030009@gmail.com> <4BFB278C.3020300@advpubtech.com> Message-ID: <4BFF640A.2030509@gmail.com> On 25/05/2010 11:27 AM, Don Dwiggins wrote: > There's a good hint there. I've got all my imports listed at the top of > the file. I do know that, when using the source, the file is read twice > -- once from the command line by the usual Python interpreter, and once > by PythonService; it must be different, though, when the compiled .exe > is run both to install and to start the service. I can't quite use the > hint to figure out why it should fail when I do an explicit CoInitialize > at the start of a thread. By "fail" here you mean "hang" right? The object model semantics are tricky - if the object says it only supports single or apartment threading, COM is likely to marshal to the main thread regardless of how the thread initializes COM. What is your main thread doing? Can you make it run a message loop to test (ie, call pythoncom.PumpMessages() in that main thread?) > I think (not sure) that the point where it hangs is always in > pythoncom.new (for all permutations), where it's getting the OLE object > to be wrapped. The question is, where in that function could it hang up > waiting for something to happen? In the underlying call to COM's CoCreateInstance. I can't think of *why* that could happen though... HTH, Mark From skippy.hammond at gmail.com Fri May 28 08:36:58 2010 From: skippy.hammond at gmail.com (Mark Hammond) Date: Fri, 28 May 2010 16:36:58 +1000 Subject: [python-win32] unable to read mssql varchar(max) In-Reply-To: References: <4BFE9613.8080405@saponara.net> Message-ID: <4BFF648A.2040007@gmail.com> On 28/05/2010 3:26 AM, Vernon Cole wrote: > I can throw together a quick example of the failure if that will help > with debugging. It involves a sample SQL data table that must be > imported for the test and is not small (several recorded telephone calls > as blobs)-- so I will only do it if needed. Does anyone (Mark?) need it? Yeah, I could have a look at a sample which demonstrated the issue and try and track the root of it. I'm flat-out for about the next 4 weeks though... Mark From cburgmer at ira.uka.de Sat May 29 21:44:16 2010 From: cburgmer at ira.uka.de (Christoph Burgmer) Date: Sat, 29 May 2010 21:44:16 +0200 Subject: [python-win32] Python on Win32 and Unicode on the console Message-ID: <201005292144.18731.cburgmer@ira.uka.de> Hi list we want to read from stdin and write to stdout using Unicode (utf-8 is the way to go) in Python on Win32. This is what I normally do on Unix: >>> import locale >>> import sys >>> output_encoding = sys.stdout.encoding or locale.getpreferredencoding() or 'ascii' >>> print u"?".encode(output_encoding) It seems this does not work straight away on Windows, question marks instead. I can only test this in Wine emulation (so it's probably not much use), but there are at least two people on Windows with this issue. It seems to boil down to two things: - tell Windows to use utf-8 in the console ('cmd /u' and setting some code- page) - get Python to read and write utf-8 I tried using the Win specific 'mbcs' encoding, but that didn't help. Btw, a bug with a bit more text is filed here: http://code.google.com/p/cjklib/issues/detail?id=11 I believe there is a solution to that and hope you people can help out. -Christoph