From vladimir.sukhoy at gmail.com Thu Sep 1 07:24:38 2005 From: vladimir.sukhoy at gmail.com (Vladimir Sukhoy) Date: Thu, 1 Sep 2005 00:24:38 -0500 Subject: [python-win32] Python Asynchronous I/O library (pyasynchio) [currently win-only] Message-ID: <370966e205083122241b73fb91@mail.gmail.com> This Python library is created to support asynchronous I/O (Input/Output) operations. Unlike most platform-independent asynch I/O libraries, pyasynchio is simple. You do not have to know much about programming and anything about AIO in particular to use pyasynchio. Unlike, for example, famous asyncore library, pyasynchio does not require you to use some object-oriented approaches, implement certain interfaces or do anything similar. However you should understand what file or socket is, because currently pyasynchio provides I/O only for files and sockets. See http://pyasynchio.berlios.de/pyasynchio-about.htm for more details. -- Sincerely, Vladimir Sukhoy From Alex.Suzuki at ksta.ktzh.ch Thu Sep 1 10:50:03 2005 From: Alex.Suzuki at ksta.ktzh.ch (Suzuki Alex) Date: Thu, 1 Sep 2005 10:50:03 +0200 Subject: [python-win32] Creating an Exchange mailbox for an Active Directory user Message-ID: <1FD8792B19F9B546B649BAA8FD60791D907690@sksta66666.ksta.zh.ch> Hi all, I'm trying to create an Exchange mailbox for an existing user in the Active Directory. Apparently the CDOEXM.IMailBoxStore interface method CreateMailBox does this. My problem is I don't know how to get an object that supports this interface. Until now, I managed to do all Active Directory work with pure LDAP, avoiding COM,ADSI,CDO,CDOEXM and Windows things in general. :-) However, this seems to no longer be sufficient. I found this VB snippet on MSDN: -->-- Sub CreateMailboxCDOPerson(strFirstName As String, _ strLastName As String, _ strHomeMDBUrl As String) 'strHomeMDBUrl should look like this 'strHomeMDBUrl = "CN=Mailbox Store (MYSTORE),CN=First Storage Group, ' CN=InformationStore,CN=MYSTORE,CN=Servers, ' CN=First Administrative Group,CN=Administrative Groups, ' CN=IASI,CN=Microsoft Exchange,CN=Services,CN=Configuration, ' DC=mydomain,DC=fourthcoffee,DC=com" Dim oPerson As New CDO.Person Dim oMailbox As CDOEXM.IMailboxStore Dim strUserName As String Dim strURL As String Dim strContainerName As String strUserName = strFirstName & strLastName strContainerName = "Users" ' Create URL for the user CreateUserURL(strURL, strContainerName, False, strUserName) oPerson.FirstName = strFirstName oPerson.LastName = strLastName oPerson.DataSource.SaveTo strURL Set oPerson = New CDO.Person ' Bind oPerson.DataSource.Open strURL ' Create Mailbox Set oMailbox = oPerson oMailbox.CreateMailbox strHomeMDBUrl ' Save oPerson.DataSource.Save 'CleanUp Set oPerson = Nothing Set oMailbox = Nothing End Sub --<-- I don't know VB either (again, I'm not a Windows developer), but I guess the clue is the line "Set oMailbox = oPerson". How would I do this in Python? Any help is much appreciated. Regards, Alex From aregmi at gmail.com Thu Sep 1 15:54:35 2005 From: aregmi at gmail.com (Ananda Regmi) Date: Thu, 1 Sep 2005 07:54:35 -0600 Subject: [python-win32] Fwd: problem wih vi.run In-Reply-To: References: Message-ID: Hello Everybody, I am running into a strange problem while running a vi through python. Below is my sample code. lv = win32com.client.Dispatch("LabVIEW.Application.7.1") file_path = 'C:\\Documents and Settings\\administrator\\My Documents\\Python Files\\testvi.vi' vi=lv.GetVIReference(file_path) vi.Run # it stays in this line until the vi finishes running. When the execution reached the above line, it gets stuck there. It proceeds to the next line of code only after the vi finishes running. But, I need to change some control value in the Run-Time of the vi. I was wondering if there is any option to select before running the VI which can distinguish between completely running the vi and just starting the vi to run and going to the next line of script. I tried using vi.Run(1), vi.Run(), and vi.Run(0). In all of the above cases, python execution gets stuck at very same place, the VI gets executed, and when it finishes running, I get an error in Python IDLE saying "'NoneType' object is not callable labview" and does not go any further. I was also wondering, if vi.Run(1) is the right way to do it and if I need some extra code to avoid that error and run it the way I want to run it. I really appreciate your help. Thanks, Ananda -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050901/aebe644c/attachment.html From vladimir.sukhoy at gmail.com Thu Sep 1 18:41:59 2005 From: vladimir.sukhoy at gmail.com (Vladimir Sukhoy) Date: Thu, 1 Sep 2005 11:41:59 -0500 Subject: [python-win32] Python Asynchronous I/O library (pyasynchio) [currently win-only] In-Reply-To: References: <370966e205083122241b73fb91@mail.gmail.com> Message-ID: <370966e205090109412db264b8@mail.gmail.com> > (but I'm not sure writing large if-else trees and state machines is that > much easier than implementing hook methods, Yes, but the decision about how exactly to do that is up to library user. I tried to build library which can be easily plugged into existing code w/o need for serious reengineering or changing design. Maybe there is a reason to build OO framework similar to asyncore on top of apoll class, I will consider it. > whether you know much > about programming or not. have you considered the case where you > want your program to handle *different* protocols? how do you > associate state with sockets in your programming model?) If there is a need to associate state with socket itself, it can be done with simple global dictionary, or one can use "act" (Asynchronous Completion Token) parameter (which defaults to None and is passed in completion dict) which is present in each of the methods which start asynch operation, it can be used to pass state information along (it may be even more convenient). > > (and why return dictionaries? wouldn't an ordinary object be a better > choice in this case? evt['type'] isn't really that pythonic compared to > evt.type. an attribute-based approach also lets you delay construction > of Python objects until the client code actually attempts to use it). Yes, you are right, I considered attribute-based approach, it will be used together with dictionary-based in future versions. As for delayed construction I do not think that there is a big deal in using it in this particular library. > > (and given that the users will have to check the type and success fields > for every single event, wouldn't it be better to return those as separate > values: "for op, ok, event in apoll.poll(): if op == '...': ...") Thanks, great idea. -- Sincerely, Vladimir Sukhoy From rwupole at msn.com Thu Sep 1 19:36:39 2005 From: rwupole at msn.com (Roger Upole) Date: Thu, 1 Sep 2005 13:36:39 -0400 Subject: [python-win32] Re: win32com, pythoncom Message-ID: >From looking at the idl files in the sdk, all the interfaces are based on IDispatch, so this should be doable. To create a com server, you use a class that implements the methods of the interface and register it with your guid and the IID of the interface it represents. See the Quick start to server side COM in Pywin32.chm for details. hth Roger "Christophe Leske" wrote: > ok, > > so i wade through all the available documentation about this, but didn't > find anything. > > Does anyone know how one is supposed to implement an interface in > PythonCom, or how to acquire one which is NOT immediately available from > the control? > > What i am after is a sample on how an interface which will be passed to > another control is actually being implemented in Pythoncom. Since the > interface is passed on to the other application/control/whatever, we > need to pass something on - a pointer probably. How is this actually > done? What about "standard" interfaces, like IUnknown, IDispatch, and so > on, are these automatically provided by PythonCom? > > And how about the other way round? > > I got an activeX control here, which i can wrap using MakePy. I got a > wrapper class for it, but i cannot get to the Interfaces i am supposed > to acquire for the programming. I get to the Interfaces in order to > register my control with the application, but then i need to get to > OTHER interfaces in order to continue my work. Yet there is no such > wrapped method or way to get to them, i already wade through the > generated class. > > If anyone wants to check out what i am talking about, get yourself the > Google Desktop 2.0 SDK, and see the developer's forum on the site. > > > I can register my own, pythonmade control by the means of: > > reg = gds.GoogleDesktopRegistrar() > > compDesc = ["Title",TITLE, "Description",DESCRIPTION, "Icon",GDS_ICON] > registration = reg.StartComponentRegistration(MYGUID, compDesc) > > registrar_progid="GoogleDesktop.DisplayPluginRegistration" > registration=reg.GetRegistrationInterface(registrar_progid); > > registration.RegisterPlugin(MYGUID, 0) > reg.FinishComponentRegistration(); > > Works fine. > > But then what? Meaning, where is the flow of the application going? I > guess that it tries to acquire an interface from my control, so i need > to implement something for this - but what? A class? A method? How do i > pass the interface on? > > Thanks for any insights, > Christophe Leske From apocalypznow at gmail.com Thu Sep 1 18:51:20 2005 From: apocalypznow at gmail.com (apocalypznow) Date: Thu, 01 Sep 2005 09:51:20 -0700 Subject: [python-win32] Sample DDE server code Message-ID: Hi, I am looking for some sample DDE server code. I have been examining the one that came with win32all located in \python\Lib\site-packages\win32\Demos\dde but don't see anything in there that responds to a Poke from a client. I have a client application that sends pokes to a DDE server, and I am responsible for writing the DDE server to respond to it. Does anyone have any sample code or can explain how this would work? From aregmi at gmail.com Thu Sep 1 23:07:21 2005 From: aregmi at gmail.com (Ananda Regmi) Date: Thu, 1 Sep 2005 15:07:21 -0600 Subject: [python-win32] problem wih vi.run Message-ID: Hello Everybody, I am running into a strange problem while running a vi through python. Below is my sample code. lv = win32com.client.Dispatch("LabVIEW.Application.7.1") file_path = 'C:\\Documents and Settings\\administrator\\My Documents\\Python Files\\testvi.vi' vi=lv.GetVIReference(file_path) vi.Run # it stays in this line until the vi finishes running. When the execution reached the above line, it gets stuck there. It proceeds to the next line of code only after the vi finishes running. But, I need to change some control value in the Run-Time of the vi. I was wondering if there is any option to select before running the VI which can distinguish between completely running the vi and just starting the vi to run and going to the next line of script. I tried using vi.Run(1), vi.Run(), and vi.Run(0). In all of the above cases, python execution gets stuck at very same place, the VI gets executed, and when it finishes running, I get an error in Python IDLE saying "'NoneType' object is not callable labview" and does not go any further. I was also wondering, if vi.Run(1) is the right way to do it and if I need some extra code to avoid that error and run it the way I want to run it. I really appreciate your help. Thanks, Ananda -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050901/08156ed0/attachment.htm From rwupole at msn.com Fri Sep 2 11:37:12 2005 From: rwupole at msn.com (Roger Upole) Date: Fri, 2 Sep 2005 05:37:12 -0400 Subject: [python-win32] Re: win32com, pythoncom References: <431760EF.1030604@online.de> Message-ID: Here's a link to an indexing plugin implemented in python. http://www.orgmf.com.ar/condor/gdsPlugin.py Although it looks like the registration part needs to be updated for the newer Google sdk. Roger Christophe Leske wrote: > Roger Upole schrieb: > >>>From looking at the idl files in the sdk, all the interfaces are based >>on IDispatch, so this should be doable. >>To create a com server, you use a class that implements the >>methods of the interface and register it with your guid and >>the IID of the interface it represents. >>See the Quick start to server side COM in Pywin32.chm >>for details. >> >> > Hi Roger, > > i already saw that examples, yet i am not able to derive the way on how > to set things up. > Could you elaborate a bit, please? > > Any help is much appreciated, > Christophe Leske From Alex.Suzuki at ksta.ktzh.ch Fri Sep 2 11:43:54 2005 From: Alex.Suzuki at ksta.ktzh.ch (Suzuki Alex) Date: Fri, 2 Sep 2005 11:43:54 +0200 Subject: [python-win32] Creating an Exchange mailbox for an Active Dir ectory user Message-ID: <1FD8792B19F9B546B649BAA8FD60791D90769A@sksta66666.ksta.zh.ch> > I'm trying to create an Exchange mailbox for an existing user in the > Active Directory. Never mind, I figured it out. cheers, A. From rudy.schockaert at gmail.com Fri Sep 2 11:59:27 2005 From: rudy.schockaert at gmail.com (Rudy Schockaert) Date: Fri, 2 Sep 2005 11:59:27 +0200 Subject: [python-win32] Creating an Exchange mailbox for an Active Dir ectory user In-Reply-To: <1FD8792B19F9B546B649BAA8FD60791D90769A@sksta66666.ksta.zh.ch> References: <1FD8792B19F9B546B649BAA8FD60791D90769A@sksta66666.ksta.zh.ch> Message-ID: <60987dac05090202596f599dd0@mail.gmail.com> Alex, do you mind sharing your experience. I think others (including me) are interested in this. Ciao, Rudy On 9/2/05, Suzuki Alex wrote: > > > I'm trying to create an Exchange mailbox for an existing user in the > > Active Directory. > > Never mind, I figured it out. > > cheers, A. > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- "A little nonsense now and then, is cherished by the wisest men." -- Roald Dahl -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050902/6b102144/attachment.htm From Alex.Suzuki at ksta.ktzh.ch Fri Sep 2 13:15:35 2005 From: Alex.Suzuki at ksta.ktzh.ch (Suzuki Alex) Date: Fri, 2 Sep 2005 13:15:35 +0200 Subject: [python-win32] Creating an Exchange mailbox for an Active Dir ectory user Message-ID: <1FD8792B19F9B546B649BAA8FD60791D90769B@sksta66666.ksta.zh.ch> Hi Rudy. The code below creates a user in the active directory and then creates an Exchange mailbox. You need to install CDOEXM on your client machine. I didn't realize you could just call IMailBoxStore::CreateMailBox like that. I guess this has to do with some magic behind IDispatch. Again, I am totally new to COM, and actually hope to be done with it as soon as possible. The string you pass to CreateMailBox is a distinguished name that identifies the Information store in which you want to create the user's mailbox. Its format is (I think): cn=[StoreName],cn=[Storage group],cn=InformationStore,cn=[Server name],\ cn=Servers,cn=[Administrative group],cn=Exchange,cn=Microsoft Exchange,\ cn=Services,cn=Configuration,[Domain components] You can browse your active directory with adsiedit to find out the string for your installation. cheers, Alex -->-- import win32com, win32com.client, pythoncom path = "LDAP://hostname/cn=Users,dc=kt,dc=ktzh,dc=ch" auth = (binddn, bindpw) # Get ADSI Namespace object ns = win32com.client.Dispatch("ADsNameSpaces") # Get LDAP provider ldap = ns.GetObject("", "LDAP:") cont = ldap.OpenDSObject(path, auth[0], auth[1], 0) ou = cont.Create("organizationalUnit", "ou=Sandbox") ou.SetInfo() jolie = ou.Create("user", "cn=jolie") jolie.Put("sAMAccountName", "jolie") jolie.Put("userPrincipalName", "jolie at domain.com") jolie.Put("sn", "Jolie") jolie.Put("givenName", "Angelina") jolie.Put("description", "Sandbox user") jolie.Put("mail", "angelina.jolie at domain.com") jolie.SetInfo() jolie.AccountDisabled = 0 jolie.SetInfo() jolie.CreateMailBox("CN=Postfachspeicher (W2K03GE01),CN=Erste Speichergruppe,CN=InformationStore,CN=W2K03GE01,CN=Servers,CN=Erste administrative Gruppe,CN=Administrative Groups,CN=Exchange,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=kt,DC=ktzh,DC=ch") jolie.SetInfo() --<-- -----Original Message----- From: Rudy Schockaert [mailto:rudy.schockaert at gmail.com] Sent: Friday, September 02, 2005 11:59 AM To: Suzuki Alex Cc: python-win32 at python.org Subject: Re: [python-win32] Creating an Exchange mailbox for an Active Dir ectory user Alex, do you mind sharing your experience. I think others (including me) are interested in this. Ciao, Rudy On 9/2/05, Suzuki Alex < Alex.Suzuki at ksta.ktzh.ch> wrote: > I'm trying to create an Exchange mailbox for an existing user in the > Active Directory. Never mind, I figured it out. cheers, A. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -- "A little nonsense now and then, is cherished by the wisest men." -- Roald Dahl From darrenb at extendedsystems.com Fri Sep 2 01:35:46 2005 From: darrenb at extendedsystems.com (Darren Blaser) Date: Thu, 01 Sep 2005 17:35:46 -0600 Subject: [python-win32] py2dll - or an example of a dll writen in python? Message-ID: <43179052.7000807@extendedsystems.com> Hi, I have a dll that I'd like to write a simple replacement for in python. Is this possible? Is there an example somewhere of a dll written in python? The example could be for something as simple as a single dll export implementing the following GetApiVersion call... typedef enum _Status { STATUS_SUCCESS = 0x00000000, STATUS_FAILED = 0x00000001 }Status; typedef struct _ApiVersionInfo { DWORD dwMajor; DWORD dwMinor; DWORD dwDetailed }ApiVersionInfo; Status GetApiVersion(ApiVersionInfo *pstVersion); My googling turned up this old post from 5 years ago, but nothing more recent. http://mail.python.org/pipermail/python-list/2001-November/074600.html Thank you very much for any feedback. Best Regards, Darren From hpkotian at rbi.org.in Fri Sep 2 10:23:42 2005 From: hpkotian at rbi.org.in (Harish Kotian) Date: Fri, 2 Sep 2005 13:53:42 +0530 Subject: [python-win32] Help needed Message-ID: <000b01c5af97$a0c82180$3c0510ac@hydro.rbi.org.in> Hello Using python script I want to redirect the user to another page. I have pasted a sample script below. What is the equivalent to the response.redirect code? How should it read? Please help Harish. <%@ LANGUAGE = Python%> <% response.redirect("yahoo.com") %> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050902/e030db47/attachment.html From jhu at metrigenix.com Fri Sep 2 16:34:48 2005 From: jhu at metrigenix.com (James Hu) Date: Fri, 2 Sep 2005 10:34:48 -0400 Subject: [python-win32] wxImage can't read tif file? Message-ID: Hi, all gurus, I am working on a small project, which needs to display 16 bit tiff image on screen directly, I use wxStaticBitmap to do that, and I can show png and jpg file on the screen without any problem. (converting from tiff to png first is not option though). However, when I try to read tiff file, nothing there,(the program is running without error) of course, the tiff is OK, I can open it with IrFanView. where output.tif is about 640K, a little larger than output.png(450K), the document says wxImage can open tif! OR is there other way to show 16 bit tiff on windows with wxPython? Another thing: how can I call the static methods like wxImage::FindHandler, it always complains no matter what I use "image.FindHandler() or wxImage.FindHandler()" Any help will be apprecaited greatly!!! James the codes: #image=wx.Image('output.png',wxBITMAP_TYPE_PNG) #Can see, image=wx.Image('output.tif',wxBITMAP_TYPE_TIF) #can't see, still black as the empty bitmap bmp = image.ConvertToBitmap() bmp.SetHeight(self.bmpHeight) bmp.SetWidth(self.bmpWidth) self.staticBitmap1.SetBitmap(bmp) #staticBitmap1 already defined/created before From timr at probo.com Fri Sep 2 18:55:49 2005 From: timr at probo.com (Tim Roberts) Date: Fri, 02 Sep 2005 09:55:49 -0700 Subject: [python-win32] problem wih vi.run In-Reply-To: References: Message-ID: <43188415.50400@probo.com> On Thu, 1 Sep 2005 15:07:21 -0600, Ananda Regmi wrote: >Hello Everybody, > I am running into a strange problem while running a vi through python. >Below is my sample code. > >lv = win32com.client.Dispatch("LabVIEW.Application.7.1") >file_path = 'C:\\Documents and Settings\\administrator\\My Documents\\Python >Files\\testvi.vi' >vi=lv.GetVIReference(file_path) >vi.Run # it stays in this line until the vi finishes running. > >When the execution reached the above line, it gets stuck there. It proceeds >to the next line of code only after the vi finishes running. But, I need to >change some control value in the Run-Time of the vi. I was wondering if >there is any option to select before running the VI which can distinguish >between completely running the vi and just starting the vi to run and going >to the next line of script. > > This is strictly a LabVIEW problem. No one here will be able to answer this question. You need to check the LabVIEW documentation to see if their COM interface offers a way to run the script asynchronously. If they do not offer a way, you may be able to use multithreading to do this, by starting up a separate thread to do the Run, while maintaining your control in the main thread. You'll have to be careful to monitor the object lifetime, so you don't try to use the object after it completes. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From theller at python.net Fri Sep 2 20:41:35 2005 From: theller at python.net (Thomas Heller) Date: Fri, 02 Sep 2005 20:41:35 +0200 Subject: [python-win32] py2dll - or an example of a dll writen in python? References: <43179052.7000807@extendedsystems.com> Message-ID: Darren Blaser writes: > Hi, > > I have a dll that I'd like to write a simple replacement for in python. > Is this possible? Is there an example somewhere of a dll written in python? > > The example could be for something as simple as a single dll export > implementing the following GetApiVersion call... > > typedef enum _Status > { > STATUS_SUCCESS = 0x00000000, > STATUS_FAILED = 0x00000001 > }Status; > > typedef struct _ApiVersionInfo > { > DWORD dwMajor; > DWORD dwMinor; > DWORD dwDetailed > }ApiVersionInfo; > > Status GetApiVersion(ApiVersionInfo *pstVersion); > > My googling turned up this old post from 5 years ago, but nothing more > recent. > http://mail.python.org/pipermail/python-list/2001-November/074600.html > > Thank you very much for any feedback. In principle this is not complicated. Write the dll as usual, and call Python from the exported functions. Just make sure that you initialize Python somewhere, and be sure to handle the GIL correctly. It gets more complicated when the exe-process may also be using Python, or if other dlls used in the same process are also using Python (maybe because inproc COM objects are implemented in Python). Then you must be prepared to handle the case that Python already *is* initialized. The next step would be if you want to use py2exe or a similar tool to distribute your dll to machines that don't have Python installed (if you need that). But, of course there is prior art: pywin32, for example, has a ISAPI extension (which is a dll): http://cvs.sourceforge.net/viewcvs.py/pywin32/pywin32/isapi/src/pyISAPI.cpp?rev=1.2&view=auto And pywin32's pythoncom, which is the inproc COM server dll. Thomas From rwupole at msn.com Sat Sep 3 07:59:31 2005 From: rwupole at msn.com (Roger Upole) Date: Sat, 3 Sep 2005 01:59:31 -0400 Subject: [python-win32] Re: Help needed Message-ID: Python is case sensitive, so you'll need to use Response.Redirect hth Roger Harish Kotian wrote: > Hello > Using python script I want to redirect the user to another page. > I have pasted a sample script below. > What is the equivalent to the response.redirect code? > How should it read? > Please help > Harish. <%@ LANGUAGE = Python%> <% response.redirect("yahoo.com") %> From arun_tyagi at yahoo.com Mon Sep 5 18:21:46 2005 From: arun_tyagi at yahoo.com (Arun Tyagi) Date: Mon, 5 Sep 2005 09:21:46 -0700 (PDT) Subject: [python-win32] Python Problem Message-ID: <20050905162146.96827.qmail@web31001.mail.mud.yahoo.com> Hi, I want to know that can we execute MS Access Macro's using python. if anyone know's the answer then please send it. Its very urgent. Regards Arun __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From hpkotian at rbi.org.in Sat Sep 3 09:46:14 2005 From: hpkotian at rbi.org.in (Harish Kotian) Date: Sat, 3 Sep 2005 13:16:14 +0530 Subject: [python-win32] Looking for sample code Message-ID: <000801c5b05b$8fa8bd00$3c0510ac@hydro.rbi.org.in> Hi Friends I am looking for sample code using python script for: 1) reading / displaying contents from MS Access database, probably using ODBC drivers 2) Reading from a sessions object, Any pointers? Regards Harish. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050903/db3eea8d/attachment.htm From bgailer at alum.rpi.edu Tue Sep 6 19:40:05 2005 From: bgailer at alum.rpi.edu (bob) Date: Tue, 06 Sep 2005 10:40:05 -0700 Subject: [python-win32] Python Problem In-Reply-To: <20050905162146.96827.qmail@web31001.mail.mud.yahoo.com> References: <20050905162146.96827.qmail@web31001.mail.mud.yahoo.com> Message-ID: <6.1.2.0.0.20050906102948.032e94a0@mail.mric.net> At 09:21 AM 9/5/2005, Arun Tyagi wrote: >Hi, > >I want to know that can we execute MS Access Macro's using python. # requires Access to be installed import win32com.client # from https://sourceforge.net/projects/pywin32/ a = win32com.client.Dispatch('access.application.9') # 9 may be different depending on access version # check registry under HKEY_LOCAL_MACHINE\SOFTWARE\Classes\access.application for number # this starts access, as a process, so you don't see it; to see it (not required): a.visible = True a.OpenCurrentDatabase('c:/.../test.mdb') # provide path to your database returnValue = a.run("macroname", arg1, arg2, ...) # if macro is a function returnValue will be whatever function returns; if a sub returnValue = None From Jim.Vickroy at noaa.gov Tue Sep 6 21:45:09 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue, 06 Sep 2005 13:45:09 -0600 Subject: [python-win32] Looking for sample code In-Reply-To: <000801c5b05b$8fa8bd00$3c0510ac@hydro.rbi.org.in> References: <000801c5b05b$8fa8bd00$3c0510ac@hydro.rbi.org.in> Message-ID: <431DF1C5.7080405@noaa.gov> Harish Kotian wrote: > Hi Friends > > I am looking for sample code using python script for: > 1) reading / displaying contents from MS Access database, probably > using ODBC drivers > 2) Reading from a sessions object, > Any pointers? > Regards > Harish. > > >------------------------------------------------------------------------ > >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > I am not a MS Access user, but I have successfully used the information at http://www.connectionstrings.com/ to access the information in Excel files via ODBC. -- jv From laura.marco at alice.it Wed Sep 7 00:03:10 2005 From: laura.marco at alice.it (Marco & Laura) Date: Wed, 7 Sep 2005 00:03:10 +0200 Subject: [python-win32] Getting an Excel running instance Message-ID: <002c01c5b32e$d6e02b10$5a683052@DUDONE> Hi. I'm trying to implement an Excel add-in based on the demo I found in win32com/demos (excelAddin.py) The demo basically adds a CommandBar with a Button and register itself. What I'm trying to do is change the OnClick event to perform some operation in the ActiveSheet of the Excel instance in which the Button is clicked on. The relevant code snippet is then: def OnClick (self, button, cancel): xl = win32com.client.Dispatch('Excel.Application') It works fine if I have only one Excel instance running. If there are more instances, Dispatch invokes the first one, which is not necessarily the desired one. To work around, first I have tried to get a reference to the Application from the OnClick event, but I didn't be able to find any. After some googling, I've tried a less obvious way, querying the Running Object Table to get some reference about running instances. I manage to get the monikers of running objects, but I don't know how - and if possible - pass them to a function to get the object by reference. So, I wonder if there is a more newbie-ish method to reach my goal. Any help, hint or pointers would be greatly appreciated. Regards, Marco From gansevle at cs.utwente.nl Wed Sep 7 11:12:20 2005 From: gansevle at cs.utwente.nl (Fred Gansevles) Date: Wed, 07 Sep 2005 11:12:20 +0200 Subject: [python-win32] py2dll - or an example of a dll writen in python? In-Reply-To: Your message of Thu, 01 Sep 2005 17:35:46 MDT Message-ID: <20050907091221.30A7B508B8@mamba.cs.utwente.nl> > Hi, > > I have a dll that I'd like to write a simple replacement for in python. > Is this possible? Is there an example somewhere of a dll written in python? > > The example could be for something as simple as a single dll export > implementing the following GetApiVersion call... > > typedef enum _Status > { > STATUS_SUCCESS = 0x00000000, > STATUS_FAILED = 0x00000001 > }Status; > > typedef struct _ApiVersionInfo > { > DWORD dwMajor; > DWORD dwMinor; > DWORD dwDetailed > }ApiVersionInfo; > > Status GetApiVersion(ApiVersionInfo *pstVersion); > > My googling turned up this old post from 5 years ago, but nothing more > recent. > http://mail.python.org/pipermail/python-list/2001-November/074600.html > > Thank you very much for any feedback. Hi, I'v made a c-module to simplify embedding/extending Python without the need of a MS-C compiler (MingW is good enough) and without the hassle of packing/unpacking/ref-counting/thread-state when communicating with python. Using my c-module, your dll should look something like: ------------------------------------------------------- #include "PyLib.h" typedef enum _Status { STATUS_SUCCESS = 0x00000000, STATUS_FAILED = 0x00000001 }Status; typedef struct _ApiVersionInfo { DWORD dwMajor; DWORD dwMinor; DWORD dwDetailed }ApiVersionInfo; static initialized = 0; static Initialize() { if (!initialized) { PyLib_Initialize(NULL, 0, NULL); PyLib_Import("MyDll", r"C:\Dir\Containing\MyDll"); initialized = 1; } } Status GetApiVersion(ApiVersionInfo *pstVersion) { Initialize(); if (PyLib_Call("MyDll.GetApiVersion", "iii()", &(pstVersion->dwMajor), &(pstVersion->dwMinor), &(pstVersion->dwDetailed))) return STATUS_SUCCESS; else return STATUS_FAILED; } ------------------------------------------------------- and you must create a file "MyDll.py" with something like: ------------------------------------------------------- def GetApiVersion(): return 1, 1, 0 ------------------------------------------------------- Since the documentation is not ready I've not yet released this to the general python community. If you are interested I can send you the code. > > Best Regards, > > Darren > ____________________________________________________________________________ Fred Gansevles Phone: +31 53 489 4613 Org.: Twente University, Fac. of EWI, Box 217, 7500 AE Enschede, Netherlands "Linux is like a wigwam, No windows, no gates and an apache inside" From rwupole at msn.com Wed Sep 7 14:30:53 2005 From: rwupole at msn.com (Roger Upole) Date: Wed, 7 Sep 2005 08:30:53 -0400 Subject: [python-win32] Re: Getting an Excel running instance Message-ID: You should be able to reference it as self.Application. hth Roger "Marco & Laura" wrote: > Hi. > I'm trying to implement an Excel add-in based on the demo I found in > win32com/demos (excelAddin.py) > The demo basically adds a CommandBar with a Button and register itself. > What > I'm trying to do is change the OnClick event to perform some operation in > the ActiveSheet of the Excel instance in which the Button is clicked on. > The > relevant code snippet is then: > > def OnClick (self, button, cancel): > xl = win32com.client.Dispatch('Excel.Application') > > > It works fine if I have only one Excel instance running. If there are more > instances, Dispatch invokes the first one, which is not necessarily the > desired one. > > To work around, first I have tried to get a reference to the Application > from the OnClick event, but I didn't be able to find any. > > After some googling, I've tried a less obvious way, querying the Running > Object Table to get some reference about running instances. I manage to > get > the monikers of running objects, but I don't know how - and if possible - > pass them to a function to get the object by reference. So, I wonder if > there is a more newbie-ish method to reach my goal. > > Any help, hint or pointers would be greatly appreciated. > > Regards, > Marco From laura.marco at alice.it Wed Sep 7 14:57:29 2005 From: laura.marco at alice.it (Laura & Marco) Date: Wed, 7 Sep 2005 14:57:29 +0200 Subject: [python-win32] Re: Getting an Excel running instance References: Message-ID: <02b001c5b3ab$b4c62070$1200a8c0@zenit> *Roger Upole : > You should be able to reference it as self.Application. Thank you Roger. I resolved in a similar way after finding this archived message from Mark Hammond: http://mail.python.org/pipermail/python-win32/2004-October/002443.html Regards, Marco From rwupole at msn.com Wed Sep 7 14:58:06 2005 From: rwupole at msn.com (Roger Upole) Date: Wed, 7 Sep 2005 08:58:06 -0400 Subject: [python-win32] Re: More COM Problems Message-ID: If you know where the application's typelib (*.tlb) is, you can run makepy manually against it. You can also run makepy on an exe, dll, or ocx if it contains type information. Alternately, you might be able to register the typelib using pythoncom.RegisterTypeLib if the application doesn't do so itself. hth Roger pylist at gnulinux.net wrote: > > > > I still can't seem to get this to work correctly. Here is the code I am > testing with: > > --- > import win32com.client > from win32com.client import gencache, Dispatch > import os, sys > from win32com.shell import shell > import win32com.client.dynamic > > print "Creating late-bound Optix object" > xl = win32com.client.dynamic.Dispatch("Optix.Application") > print "The Optix object is", `xl` > > gencache.EnsureModule('{4BD66BC4-4AA0-11CF-A13A-00A024140CAD}', 0, 1, 2) > optix = Dispatch("Optix.Application") > print optix > sys.exit(0) > --- > > The output is: > Creating late-bound Optix object > The Optix object is > > > > The actual above gencache statement was not copied from the makepy utility > as it > could not find Optix.Application (or the classid) so I just ran it on > another > object and replaced it's classid with Optix's classid. > > I have noticed that Optix.Application is not in the TypeLib list inside of > makepy > utility though it does show up under all onjects in MS's OLE Browser. > > Another odd thing is that I can use Optix.Application in python (to some > degree) > but can't use it for what I need sense makepy/gencache doesn't seem to > make anything. > > Please Help! :-) > Steve Milner From timr at probo.com Wed Sep 7 19:02:37 2005 From: timr at probo.com (Tim Roberts) Date: Wed, 07 Sep 2005 10:02:37 -0700 Subject: [python-win32] Looking for sample code In-Reply-To: References: Message-ID: <431F1D2D.60406@probo.com> On Tue, 06 Sep 2005 13:45:09 -0600, Jim Vickroy wrote: > > >I am not a MS Access user, but I have successfully used the information at > >http://www.connectionstrings.com/ > >to access the information in Excel files via ODBC. > I'd like to comment just for completeness, in case someone reads these archives in the future. ODBC does allow you to gain acess to the INFORMATION in an Access database. It uses the Jet database engine to read the tables and queries. However, that's all it can get to. The macros, forms, reports, and VB code are NOT part of the database per se. They are strictly part of the Access application. In order to gain access to them, you have to use COM to fire up Access.Application, just as Bob suggested. By the way, Bob, it isn't necessary for you to fetch the Access application version number to do the dispatch. You can do this: a = win32com.client.Dispatch( "Access.Application" ) Through the magic of the registry, Access.Application is a "symbolic link" to Access.Application.10 (or whatever), which is itself a symbolic link to the UUID of the Access application. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From bgailer at alum.rpi.edu Wed Sep 7 20:38:41 2005 From: bgailer at alum.rpi.edu (bob) Date: Wed, 07 Sep 2005 11:38:41 -0700 Subject: [python-win32] Running Access Commands (was Python Problem) In-Reply-To: <20050907155803.30738.qmail@web31011.mail.mud.yahoo.com> References: <6.1.2.0.0.20050906102948.032e94a0@mail.mric.net> <20050907155803.30738.qmail@web31011.mail.mud.yahoo.com> Message-ID: <6.1.2.0.0.20050907111134.032ea8a8@mail.mric.net> At 08:58 AM 9/7/2005, Arun Tyagi wrote: >Hi Bob, > >last time i asked u how to run access macro through >python? and ur solution worked fine, so thanks a lot fot it. You are welcome. And please in the future give a meaningful subject on your questions. it helps us track the questions. Also please reply to the list as well as to me, since another might jump in with the next answer, and we all learn by following these threads. >Now i got another problem. Don't we all. >I want to know how can we export/import text file in Access using python? All Office applications use VBA as the core of their macro language, along with application-specific extensions to VBA. You may invoke any of these operations the same way you used RUN in my previous answer. There are several ways to discover the relevant commands. 1 - Open Access, then open the Visual Basic Editor under Tools->Macros..., press F2 to get the object browser, then Find to narrow the search to the operation you want. The syntax is displayed at the bottom of the browser. Press F1 to get the help details. 2 - Record a macro then do the Access thing to import a text file. Then Edit the macro. Then copy the relevant commands to your Python program, or run the macro itself from Python. 3 - Get a copy of Python Programming on Win32 (Hammond & Robinson) O'Reilly Press. Will explain a lot. Pay attention to makepy which can make like easier and things go faster. What you want in this situation is TransferText. This is an access action; to invoke it as a method requires DoCmd (as the help file will show you). Syntax: TransferText([TransferType As AcTextTransferType = acImportDelim], [SpecificationName], [TableName], [FileName], [HasFieldNames], [HTMLTableName], [CodePage]) You will have to lookup the TextTransferType to get the numeric value for this parameter, and of course there may be other things to establish (such as a specification) that is access specific and not a topic for Python. So the Python side begins to look like: a.DoCmd.TransferText(transfertype, specname or None, tablename, filename) I hope this steers you to your answer and helps you see how to find further answers on your own. We on this list like to help and helping you help yourself gives us more time for our own work. Of course some of us are also available to take on larger assignments as consultants. From bgailer at alum.rpi.edu Wed Sep 7 20:40:38 2005 From: bgailer at alum.rpi.edu (bob) Date: Wed, 07 Sep 2005 11:40:38 -0700 Subject: [python-win32] Looking for sample code In-Reply-To: <431F1D2D.60406@probo.com> References: <431F1D2D.60406@probo.com> Message-ID: <6.1.2.0.0.20050907114010.032eab38@mail.mric.net> At 10:02 AM 9/7/2005, Tim Roberts wrote: >On Tue, 06 Sep 2005 13:45:09 -0600, Jim Vickroy >wrote: > > > > > > >I am not a MS Access user, but I have successfully used the information at > > > >http://www.connectionstrings.com/ > > > >to access the information in Excel files via ODBC. > > > > >I'd like to comment just for completeness, in case someone reads these >archives in the future. > >ODBC does allow you to gain acess to the INFORMATION in an Access >database. It uses the Jet database engine to read the tables and queries. > >However, that's all it can get to. The macros, forms, reports, and VB >code are NOT part of the database per se. They are strictly part of the >Access application. In order to gain access to them, you have to use >COM to fire up Access.Application, just as Bob suggested. > >By the way, Bob, it isn't necessary for you to fetch the Access >application version number to do the dispatch. You can do this: > > a = win32com.client.Dispatch( "Access.Application" ) As if by magic that works today. Yesterday it did not work. >Through the magic of the registry, Access.Application is a "symbolic >link" to Access.Application.10 (or whatever), which is itself a symbolic >link to the UUID of the Access application. > >-- >Tim Roberts, timr at probo.com >Providenza & Boekelheide, Inc. > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 From le.dahut at laposte.net Thu Sep 8 16:42:59 2005 From: le.dahut at laposte.net (le dahut) Date: Thu, 08 Sep 2005 16:42:59 +0200 Subject: [python-win32] detecting windows type Message-ID: <1126190579.14380.48.camel@kls> Hello, How is it possible to detect which kind of windows a python script is running on ? (9x, Me, 2k, XP, 2k3) An other question: I've a script using win32com.client.Dispatch("WbemScripting.SWbemLocator") but it doesn't seem to function on win 9x. This script is intended to detect the computer's network configuration (gateway, dns, ip addr, subnet mask). Does someone know how to obtain those informations on a win 9x ? Thanks, K. From rschroev_nospam_ml at fastmail.fm Thu Sep 8 17:02:42 2005 From: rschroev_nospam_ml at fastmail.fm (Roel Schroeven) Date: Thu, 08 Sep 2005 17:02:42 +0200 Subject: [python-win32] detecting windows type In-Reply-To: <1126190579.14380.48.camel@kls> References: <1126190579.14380.48.camel@kls> Message-ID: le dahut wrote: > Hello, > > How is it possible to detect which kind of windows a python script is > running on ? (9x, Me, 2k, XP, 2k3) You can use sys.getwindowsversion() for that. Check MSDN documentation for the precise meaning of the result. > An other question: > I've a script using > win32com.client.Dispatch("WbemScripting.SWbemLocator") but it doesn't > seem to function on win 9x. This script is intended to detect the > computer's network configuration (gateway, dns, ip addr, subnet mask). > Does someone know how to obtain those informations on a win 9x ? Sorry, no idea. -- If I have been able to see further, it was only because I stood on the shoulders of giants. -- Isaac Newton Roel Schroeven From pjessop at gmail.com Thu Sep 8 17:24:05 2005 From: pjessop at gmail.com (Peter Jessop) Date: Thu, 8 Sep 2005 17:24:05 +0200 Subject: [python-win32] detecting windows type In-Reply-To: References: <1126190579.14380.48.camel@kls> Message-ID: On 9/8/05, le dahut wrote: Hello, How is it possible to detect which kind of windows a python script is running on ? (9x, Me, 2k, XP, 2k3) >>> from win32api import * >>> GetVersionEx() An other question: I've a script using win32com.client.Dispatch("WbemScripting.SWbemLocator") but it doesn't seem to function on win 9x. This script is intended to detect the computer's network configuration (gateway, dns, ip addr, subnet mask). Does someone know how to obtain those informations on a win 9x ? Windows 9x came without support for WMI. You can download WMI Core from http://www.microsoft.com/downloads/details.aspx?FamilyId=98A4C5BA-337B-4E92-8C18-A63847760EA5&displaylang=en although the implementation is quite limited Regards Peter Jessop -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050908/261c9b7a/attachment.html From sjmachin at lexicon.net Thu Sep 8 22:17:10 2005 From: sjmachin at lexicon.net (John Machin) Date: Fri, 09 Sep 2005 06:17:10 +1000 Subject: [python-win32] detecting windows type In-Reply-To: References: <1126190579.14380.48.camel@kls> Message-ID: <43209C46.6020101@lexicon.net> Roel Schroeven wrote: >le dahut wrote: > > >>Hello, >> >>How is it possible to detect which kind of windows a python script is >>running on ? (9x, Me, 2k, XP, 2k3) >> >> > >You can use sys.getwindowsversion() for that. Check MSDN documentation >for the precise meaning of the result. > > > > > Also check out the platform module: >>> import sys >>> sys.getwindowsversion() (5, 1, 2600, 2, 'Service Pack 2') >>> import platform as pl >>> pl.platform() 'Windows-XP-5.1.2600-SP2' >>> pl.system() 'Windows' >>> pl.release() 'XP' >>> pl.version() '5.1.2600' >>> From le.dahut at laposte.net Fri Sep 9 09:42:18 2005 From: le.dahut at laposte.net (le dahut) Date: Fri, 09 Sep 2005 09:42:18 +0200 Subject: [python-win32] detecting windows type In-Reply-To: References: <1126190579.14380.48.camel@kls> Message-ID: <1126251738.14380.58.camel@kls> Maybe I can parse the output of a 'ipfonfig' command, but commands.getoutput only work with unix, not with windows. Is there another way to get the output of a command line program under windows ? K. Le jeudi 08 septembre 2005 ? 17:24 +0200, Peter Jessop a ?crit : > > > On 9/8/05, le dahut wrote: > > Hello, > > How is it possible to detect which kind of windows a python script > is > running on ? (9x, Me, 2k, XP, 2k3) > > > >>> from win32api import * > >>> GetVersionEx() > > > > An other question: > I've a script using > win32com.client.Dispatch("WbemScripting.SWbemLocator") but it > doesn't > seem to function on win 9x. This script is intended to detect the > computer's network configuration (gateway, dns, ip addr, subnet > mask). > Does someone know how to obtain those informations on a win 9x ? > > > Windows 9x came without support for WMI. You can download WMI Core > from > http://www.microsoft.com/downloads/details.aspx?FamilyId=98A4C5BA-337B-4E92-8C18-A63847760EA5&displaylang=en > although the implementation is quite limited > > Regards > > Peter Jessop From bokverket at hotmail.com Fri Sep 9 11:28:06 2005 From: bokverket at hotmail.com (Bokverket) Date: Fri, 9 Sep 2005 11:28:06 +0200 Subject: [python-win32] Localization Message-ID: Hi, new to the list and to Python but enthusiastically on the move into both... I am from the world outside A-Za-z country. I wrote a simple text processing application in Python which I eventually would like to integrate with Microsoft Word. Right away, the following localization problems popped up: -- Sorting is done incorrectly for non-a-z letters. -- Using \W for whitespace in a regular expression makes it treat those non-a-z letters as whitespace, thus breaking words that should not be broken. -- Not yet sure if folding to lower-case is done correctly. How should I handle this in Python? I post on this list, since Windows by itself has good support for localization (altering the sorting sequence etc) as you know, though I am not familiar with the Windows calls for this. Best, From jason.mule at gmail.com Fri Sep 9 16:08:19 2005 From: jason.mule at gmail.com (Jason) Date: Fri, 9 Sep 2005 17:08:19 +0300 Subject: [python-win32] handling paths in windows services Message-ID: <138fdb2505090907081f0ac659@mail.gmail.com> I get the following error when trying to run a python script as a service The instance's SvcRun() method failed File "win32serviceutil.pyc", line 742, in SvcRun File "winService.pyc", line 134, in SvcDoRun File "winService.pyc", line 83, in RunMe File "config.pyc", line 28, in readConfig exceptions.IOError: (2, 'No such file or directory', 'svc.cfg') The 'svc.cfg' is on the the same directory that contains the python script, but its path is obviously not available to the windows service. Short of using absolute paths, what would be the correct way to handle this. Thank you From fchavez at intercorp.com.pe Fri Sep 9 16:26:28 2005 From: fchavez at intercorp.com.pe (Chavez Gutierrez, Freddy) Date: Fri, 9 Sep 2005 09:26:28 -0500 Subject: [python-win32] path to START MENU folder Message-ID: <707B1920B56175498274490E1DFF176305E73E48@ibmail3> Somewhere I found this code to get the path to the DESKTOP folder: from win32com.shell import shell df = shell.SHGetDesktopFolder() pidl = df.ParseDisplayName(0, None,"::{450d8fba-ad25-11d0-98a8-0800361b1103}")[1] mydocs = shell.SHGetPathFromIDList(pidl) print mydocs When I execute it, I get this: C:\Documents and Settings\freddy\My Documents. That's ok. Now, I want to get the START MENU folder for all users, which is something like: "C:\Documents and Settings\All Users\Start Menu". Thanks for your help. Regards, Freddy Chavez. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050909/b4a5ff47/attachment.html From rwupole at msn.com Fri Sep 9 16:50:10 2005 From: rwupole at msn.com (Roger Upole) Date: Fri, 9 Sep 2005 10:50:10 -0400 Subject: [python-win32] Re: path to START MENU folder Message-ID: shell.SHGetSpecialFolderPath(0,shellcon.CSIDL_COMMON_STARTMENU) should do the trick. Roger From pjessop at gmail.com Fri Sep 9 18:21:10 2005 From: pjessop at gmail.com (Peter Jessop) Date: Fri, 9 Sep 2005 18:21:10 +0200 Subject: [python-win32] path to START MENU folder In-Reply-To: <707B1920B56175498274490E1DFF176305E73E48@ibmail3> References: <707B1920B56175498274490E1DFF176305E73E48@ibmail3> Message-ID: Hola Freddy Another way of doing it would be to use the WScript.Shell object: import win32com.client objShell = win32com.client.Dispatch("WScript.Shell") allUserDocs = objShell.SpecialFolders("AllUsersDesktop") print allUserDocs similarly you can use the following to obtain access to other special folders: AllUsersDesktop,AllUsersStartMenu,AllUsersPrograms,AllUsersStartup Desktop,Favorites,Fonts,MyDocuments,NetHood,PrintHood,Recent,SendTo StartMenu,Startup & Templates Saludos Peter Jessop -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050909/11f64d70/attachment.html From timr at probo.com Fri Sep 9 19:44:43 2005 From: timr at probo.com (Tim Roberts) Date: Fri, 09 Sep 2005 10:44:43 -0700 Subject: [python-win32] detecting windows type In-Reply-To: References: Message-ID: <4321CA0B.2090706@probo.com> On Fri, 09 Sep 2005 09:42:18 +0200, le dahut wrote: >Maybe I can parse the output of a 'ipfonfig' command, > Nope, that won't work. Ipconfig is NT-only. 95 and 98 have winipcfg, but it is a GUI tool, not a command-line tool. >but commands.getoutput only work with unix, not with windows. Is there >another way to get the output of a command line program under windows ? > The usual way is to use os.popen, which works everywhere. However, as I said, that won't help you with this information. In fact, it is surprisingly difficult to get information about the network interfaces on a 95/98 machine. Have you tried the downloadable WMI support mentioned earlier? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gagenellina at softlab.com.ar Sat Sep 10 00:22:57 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Fri, 09 Sep 2005 19:22:57 -0300 Subject: [python-win32] handling paths in windows services In-Reply-To: <138fdb2505090907081f0ac659@mail.gmail.com> References: <138fdb2505090907081f0ac659@mail.gmail.com> Message-ID: <6.2.1.2.0.20050909192144.02eb69f0@192.168.0.115> At Friday 9/9/2005 11:08, you wrote: >The 'svc.cfg' is on the the same directory that contains the python >script, but its path is obviously not available to the windows >service. Short of using absolute paths, what would be the correct way >to handle this. Try this: import os,sys print os.path.join( os.path.dirname( os.path.abspath( sys.argv[0])), 'svc.cfg') Gabriel Genellina Softlab SRL From rays at blue-cove.com Sun Sep 11 06:22:22 2005 From: rays at blue-cove.com (RayS) Date: Sat, 10 Sep 2005 21:22:22 -0700 Subject: [python-win32] closing processes In-Reply-To: <42FCC255.4080406@noaa.gov> References: <20050812152009.91686.qmail@web52008.mail.yahoo.com> <42FCC255.4080406@noaa.gov> Message-ID: <6.2.3.4.2.20050910211648.0614fa70@blue-cove.com> I use pv command line version on 9x ME Windows, and call it with os.system etc. http://www.pcworld.com/downloads/file_description/0,fid,6102,00.asp also http://www.beyondlogic.org/solutions/processutil/processutil.htm For newer OSs, use WMI, as in http://mail.python.org/pipermail/python-win32/2003-October/001329.html Ray Schumacher At 08:37 AM 8/12/2005, Jim Vickroy wrote: >ryan pinto wrote: > >>hi - need some help, >> >>Looking for some way to close processes which are >>open. Is there any way that a process can be detected >>if its running and then closed. >> >>Ryan >> >>__________________________________________________ >>Do You Yahoo!? >>Tired of spam? Yahoo! Mail has the best spam protection around >>http://mail.yahoo.com >>_______________________________________________ >>Python-win32 mailing list >>Python-win32 at python.org >>http://mail.python.org/mailman/listinfo/python-win32 >> >> >Have you looked at section "6.1.5 Process Management" in the Python >Library Reference or, alternately, the win32process module? > >HTH -- jv >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 From bokverket at hotmail.com Mon Sep 12 18:43:34 2005 From: bokverket at hotmail.com (Bokverket) Date: Mon, 12 Sep 2005 18:43:34 +0200 Subject: [python-win32] Localization References: Message-ID: Hi, has anyone seen my msg on localization on September 9th? No answer yet, still hoping... Best, G?ran From rwupole at msn.com Mon Sep 12 20:30:52 2005 From: rwupole at msn.com (Roger Upole) Date: Mon, 12 Sep 2005 14:30:52 -0400 Subject: [python-win32] Localization Message-ID: Take a look at the locale module, in particular locale.setlocale. Roger "Bokverket" wrote: > Hi, new to the list and to Python but enthusiastically on the move into > both... > > I am from the world outside A-Za-z country. I wrote a simple text > processing application in Python which I eventually would like to > integrate with Microsoft Word. Right away, the following localization > problems popped up: > > -- Sorting is done incorrectly for non-a-z letters. > -- Using \W for whitespace in a regular expression makes it treat those > non-a-z letters as whitespace, thus breaking words that > should not be broken. > -- Not yet sure if folding to lower-case is done correctly. > > How should I handle this in Python? I post on this list, since Windows > by itself has good support for localization (altering the > sorting sequence etc) as you know, though I am not familiar with the > Windows calls for this. > Best, From bokverket at hotmail.com Tue Sep 13 13:24:51 2005 From: bokverket at hotmail.com (Bokverket) Date: Tue, 13 Sep 2005 13:24:51 +0200 Subject: [python-win32] Localization References: Message-ID: Thanks very much, did not know there was a non-Windows-specific module. It looks POSIXish in the documentation but will hopefully work. Best, G?ran From le.dahut at laposte.net Tue Sep 13 14:33:27 2005 From: le.dahut at laposte.net (le dahut) Date: Tue, 13 Sep 2005 14:33:27 +0200 Subject: [python-win32] detecting windows type In-Reply-To: <4321CA0B.2090706@probo.com> References: <4321CA0B.2090706@probo.com> Message-ID: <1126614808.14380.116.camel@kls> Thanks for your advice. A colleague told me how to get those informations. First install WMI on the 95/98 station, then write the program and compile it with py2exe, then it should work on every 95/98 station (also where WMI is NOT installed !). Note that 'ipconfig' is available on win98 so a os.popen('ipconfig /all') can be parsed to get infos. K. Le vendredi 09 septembre 2005 ? 10:44 -0700, Tim Roberts a ?crit : > On Fri, 09 Sep 2005 09:42:18 +0200, le dahut wrote: > > >Maybe I can parse the output of a 'ipfonfig' command, > > > > Nope, that won't work. Ipconfig is NT-only. 95 and 98 have winipcfg, > but it is a GUI tool, not a command-line tool. > > >but commands.getoutput only work with unix, not with windows. Is there > >another way to get the output of a command line program under windows ? > > > > The usual way is to use os.popen, which works everywhere. However, as I > said, that won't help you with this information. > > In fact, it is surprisingly difficult to get information about the > network interfaces on a 95/98 machine. Have you tried the downloadable > WMI support mentioned earlier? > From davidf at sjsoft.com Wed Sep 14 13:28:06 2005 From: davidf at sjsoft.com (David Fraser) Date: Wed, 14 Sep 2005 13:28:06 +0200 Subject: [python-win32] detecting windows type In-Reply-To: <1126614808.14380.116.camel@kls> References: <4321CA0B.2090706@probo.com> <1126614808.14380.116.camel@kls> Message-ID: <43280946.7010500@sjsoft.com> I wrote a module that has a variety of ways to get a MAC address on different platorms, it may be useful: import sys import os def rawtohex(raw): """converts a raw mac address to hex""" return ":".join(["%02X" % (ord(ch),) for ch in raw]) def getmacs_netbios(): """uses netbios to find mac addresses""" # code ported from "HOWTO: Get the MAC Address for an Ethernet Adapter" # MS KB ID: Q118623 import netbios ncb = netbios.NCB() ncb.Command = netbios.NCBENUM la_enum = netbios.LANA_ENUM() ncb.Buffer = la_enum rc = netbios.Netbios(ncb) if rc != 0: raise RuntimeError, "Unexpected result %d" % (rc,) for i in range(la_enum.length): ncb.Reset() ncb.Command = netbios.NCBRESET ncb.Lana_num = ord(la_enum.lana[i]) rc = netbios.Netbios(ncb) if rc != 0: raise RuntimeError, "Unexpected result %d" % (rc,) ncb.Reset() ncb.Command = netbios.NCBASTAT ncb.Lana_num = ord(la_enum.lana[i]) ncb.Callname = "* " adapter = netbios.ADAPTER_STATUS() ncb.Buffer = adapter netbios.Netbios(ncb) address = rawtohex(adapter.adapter_address) yield address def getmacs_wmi(): """uses wmi interface to find mac addresses""" # this uses wmi from http://tgolden.sc.sabren.com/python/wmi.html # its from the example at http://tgolden.sc.sabren.com/python/wmi_cookbook.html#ip_addresses import wmi c = wmi.WMI () for interface in c.Win32_NetworkAdapterConfiguration (IPEnabled=1): hasip = False for ipaddress in interface.IPAddress: if ipaddress: hasip = True if hasip: yield interface.MACAddress def getmacs_ifconfig(): """parses the output of unix ifconfig to find mac addresses""" lines = os.popen("ifconfig", "r").readlines() headerlines = [line for line in lines if line and not line[:1].isspace()] for line in headerlines: parts = line.split() ifname = parts[0] if 'HWaddr' in parts: hwpart = parts.index('HWaddr') if hwpart+1 < len(parts): mac = parts[hwpart+1] yield mac def getmacs_ipconfig(): """parses the output of windows ipconfig to find MAC addresses""" lines = os.popen("ipconfig /all", "r").readlines() for line in lines: if line and not line[:1].isspace(): header = line ipaddress, mac = None, None elif line.strip(): if line.strip().startswith("IP Address") and ":" in line: ipaddress = line.split(":", 1)[1].strip() if mac: yield mac ipaddress, mac = None, None if line.strip().startswith("Physical Address") and ":" in line: mac = line.split(":", 1)[1].strip() if ipaddress: yield mac ipaddress, mac = None, None def getmacs_winarp(): """parses the output of windows arp to find MAC addresses""" lines = os.popen("arp -a", "r").readlines() for line in lines: if line.startswith("Interface"): header = line ipaddress, mac = None, None elif line.strip().startswith("Internet Address"): pass elif line.strip(): ipaddress, mac = line.strip().split()[:2] yield mac def ipaddr2mac_winarp(ipaddr): """uses SendARP and ctypes to convert an IP Address to an ethernet address""" # see http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/347812 import ctypes try: SendARP = ctypes.windll.Iphlpapi.SendARP except: raise NotImplementedError('Usage only on Windows 2000 and above') import struct ip = ipaddr if isinstance(ip, (str, unicode)): ip = [int(i) for i in ip.split(".")] ip = struct.pack("BBBB", *ip) ip = struct.unpack("l", ip)[0] buffer = ctypes.c_buffer(6) addlen = ctypes.c_ulong(ctypes.sizeof(buffer)) if SendARP(ip, 0, ctypes.byref(buffer), ctypes.byref(addlen)) != 0: raise WindowsError('Retrieval of mac address(%s) - failed' % ipaddr) macaddr = rawtohex(struct.unpack('6s', buffer)[0]) return macaddr def getethdevs_ifconfig(): """parses the output of ifconfig to get a list of ethernet devices""" lines = os.popen("ifconfig", "r").readlines() headerlines = [line for line in lines if line and not line[:1].isspace()] for line in headerlines: parts = line.split() ifname = parts[0] yield ifname def getethdevs_proc(): """looks at /proc/net/dev to get a list of ethernet devices""" lines = open("/proc/net/dev").readlines() for line in lines: if ":" in line: ethdev = line.split(":", 1)[0].strip() yield ethdev getethdevs = getethdevs_proc def getmac_socket(ethdev): """returns the mac address by opening a socket on the given device. requires right permissions""" import socket s = socket.socket(socket.AF_PACKET,socket.SOCK_RAW) s.bind((ethdev,9999)) rawmac = s.getsockname()[-1] return rawtohex(rawmac) def getmacs_socket(): """returns the mac address by opening a socket on the devices found by getethdevs. requires right permissions""" for ethdev in getethdevs(): mac = getmac_socket(ethdev) if mac: yield mac def getmac_ioctl(ethdev): """returns the mac address by using ioctl calls on a socket""" # http://groups-beta.google.com/group/comp.lang.python/search?q=fcntl+socket+ifconfig # look at http://www.webservertalk.com/message891078.html for some C code import fcntl import struct import socket ifrn_name = ethdev ifru_addr_family = socket.AF_INET ifru_addr_data = "" ifr = struct.pack("16sH14s", ifrn_name, ifru_addr_family, "") SIOCGIFADDR = 0x8915 SIOCGIFHWADDR = 0x8927 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sfd = s.fileno() # get the IP address try: ifr_result = fcntl.ioctl(sfd, SIOCGIFADDR, ifr) ipaddr = struct.unpack("16sHH4B8s", ifr_result)[3:7] ipaddr = ".".join([str(d) for d in ipaddr]) except IOError: ipaddr = None # get the ethernet address try: ifr_result = fcntl.ioctl(sfd, SIOCGIFHWADDR, ifr) ethaddr = struct.unpack("16sH6s8s", ifr_result)[2] if sum([ord(c) for c in ethaddr]) == 0: return None ethaddr = rawtohex(ethaddr) except IOError: ethaddr = None return ethaddr def getmacs_ioctl(): """returns the mac address by opening a socket on the devices found by getethdevs. requires right permissions""" for ethdev in getethdevs(): mac = getmac_ioctl(ethdev) if mac: yield mac def getmacs(): if sys.platform == 'linux2': return getmacs_ioctl() elif sys.platform == 'win32': return getmacs_winarp() if __name__ == "__main__": for address in getmacs(): print address le dahut wrote: >Thanks for your advice. A colleague told me how to get those >informations. First install WMI on the 95/98 station, then write the >program and compile it with py2exe, then it should work on every 95/98 >station (also where WMI is NOT installed !). > >Note that 'ipconfig' is available on win98 so a >os.popen('ipconfig /all') can be parsed to get infos. > > >K. > >Le vendredi 09 septembre 2005 ? 10:44 -0700, Tim Roberts a ?crit : > > >>On Fri, 09 Sep 2005 09:42:18 +0200, le dahut wrote: >> >> >> >>>Maybe I can parse the output of a 'ipfonfig' command, >>> >>> >>> >>Nope, that won't work. Ipconfig is NT-only. 95 and 98 have winipcfg, >>but it is a GUI tool, not a command-line tool. >> >> >> >>>but commands.getoutput only work with unix, not with windows. Is there >>>another way to get the output of a command line program under windows ? >>> >>> >>> >>The usual way is to use os.popen, which works everywhere. However, as I >>said, that won't help you with this information. >> >>In fact, it is surprisingly difficult to get information about the >>network interfaces on a 95/98 machine. Have you tried the downloadable >>WMI support mentioned earlier? >> From tslui at yahoo.com Wed Sep 14 18:07:04 2005 From: tslui at yahoo.com (T. S. Lui) Date: Wed, 14 Sep 2005 09:07:04 -0700 (PDT) Subject: [python-win32] Window Media Player WMPlayer.OCX Message-ID: <20050914160704.21160.qmail@web40829.mail.yahoo.com> I got a strange problem that I can play media files (mp3 etc) through the Pythonwin.exe with the WMPlayer.OCX. However, it could not be done through the shell. When I checked the player.status, it shows "Opening media ...". Please help. Thanks, ts __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com From aregmi at gmail.com Wed Sep 14 18:10:54 2005 From: aregmi at gmail.com (Ananda Regmi) Date: Wed, 14 Sep 2005 10:10:54 -0600 Subject: [python-win32] Problem with reading array of clusters in LabView Message-ID: Hello, I am having trouble with reading array of clusters in LabVIew using python. I googled it and found some results some of which suggested that this topic might have been discussed earlier in python-win32 mail list. I was wondering if somebody can direct me to the right discussion or tell me how can a run a search through the archive of the mail list. Thanks in advance. Ananda -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050914/19e33d14/attachment.htm From lists at nabble.com Wed Sep 14 20:12:55 2005 From: lists at nabble.com (kooto (sent by Nabble.com)) Date: Wed, 14 Sep 2005 11:12:55 -0700 (PDT) Subject: [python-win32] Problem with reading array of clusters in LabView In-Reply-To: References: Message-ID: <862929.post@talk.nabble.com> Ananda Regmi wrote: > > I was wondering > if somebody can direct me to the right discussion or tell me how can a run a > search through the archive of the mail list. > Thanks in advance. > Ananda > Try browse and search all Python mailing lists on Nabble: http://www.nabble.com/Python-f2926.html - that may help you to find the group or individual to talk to. Gmane also have a list archive that has more historical data here: http://dir.gmane.org/gmane.comp.python.windows -- Sent from the Python - python-win32 forum at Nabble.com: http://www.nabble.com/Problem-with-reading-array-of-clusters-in-LabView-t308281.html#a862929 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050914/942dd0dc/attachment.html From rays at blue-cove.com Thu Sep 15 01:31:09 2005 From: rays at blue-cove.com (Ray Schumacher) Date: Wed, 14 Sep 2005 16:31:09 -0700 Subject: [python-win32] WindowsError: (0, 'The operation completed successfully') with compiled prog only Message-ID: <6.2.5.2.2.20050914162930.04b0a180@blue-cove.com> Hi all, anyone seen this? I'm writing a Win98 replacement shell; when I compile with console=[foo] I get no errors logged or in the console, but when compiled with windows=[foo] I get an error when I try to run subprocess: Traceback (most recent call last): File "Frame2.pyo", line 75, in OnProcessTimer File "Frame2.pyo", line 83, in getProcList File "Frame2.pyo", line 97, in launchWithoutConsole File "subprocess.pyo", line 549, in __init__ File "subprocess.pyo", line 626, in _get_handles WindowsError: (0, 'The operation completed successfully') (?) My code is: result = self.launchWithoutConsole('pv', ["-fq",]) def launchWithoutConsole(self, command, args): """Launches 'command' windowless and waits until finished""" startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW startupinfo.wShowWindow = win32con.SW_HIDE proc = subprocess.Popen([command] + args, startupinfo=startupinfo, shell=False, bufsize=1000, stdin=subprocess.PIPE, stdout=subprocess.PIPE ) return proc.stdout.readlines() I've tried many variations, but all (so far) leave a "LAUNCHER.EXE.log" with this error, even if command ="anything else".. If 'The operation completed successfully' and the error level is zero, why the logged error? Can it be suppressed? I also posted to py2exe-users... Ray Schumacher -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050914/5dfa90c6/attachment.htm From tslui at yahoo.com Wed Sep 14 17:50:03 2005 From: tslui at yahoo.com (T. S. Lui) Date: Wed, 14 Sep 2005 23:50:03 +0800 (CST) Subject: [python-win32] Window Media Player WMPlayer.OCX Message-ID: <20050914155003.22779.qmail@web40810.mail.yahoo.com> I got a strange problem that I can play media files (mp3 etc) through the Pythonwin.exe with the WMPlayer.OCX. However, it could not be done through the shell. When I checked the player.status, it shows "Opening media ...". Please help. Thanks, ts _______________________________________ ·Q§Y®É¦¬¨ì·s email ³qª¾¡H ¤U¸ü Yahoo! Messenger http://messenger.yahoo.com.hk From michael at zuerchertech.com Thu Sep 15 17:05:06 2005 From: michael at zuerchertech.com (Michael Zuercher) Date: Thu, 15 Sep 2005 10:05:06 -0500 Subject: [python-win32] win32com events using native interfaces Message-ID: <43298DA2.2080706@zuerchertech.com> I have a COM object that sends events. Rather that have the source interface be 'dispinterface' in the IDL, it is just 'interface'. Is there a way to catch events from this interface using win32com? The IDL for the coclass is below for reference. [ uuid(10020202-EB1C-11CF-AE6E-00AA004A34D5), version(2.0), helpstring("Data Transformation Services Package Object"), helpcontext(0x000002ee) ] coclass Package2 { interface _Package; [default] interface _Package2; [default, source] interface PackageEvents; }; Michael Zuercher Zuercher Technologies LLC From theller at python.net Thu Sep 15 21:04:00 2005 From: theller at python.net (Thomas Heller) Date: Thu, 15 Sep 2005 21:04:00 +0200 Subject: [python-win32] win32com events using native interfaces References: <43298DA2.2080706@zuerchertech.com> Message-ID: Michael Zuercher writes: > I have a COM object that sends events. Rather that have the source > interface be 'dispinterface' in the IDL, it is just 'interface'. Is > there a way to catch events from this interface using win32com? The IDL > for the coclass is below for reference. > > [ > uuid(10020202-EB1C-11CF-AE6E-00AA004A34D5), > version(2.0), > helpstring("Data Transformation Services Package Object"), > helpcontext(0x000002ee) > ] > coclass Package2 { > interface _Package; > [default] interface _Package2; > [default, source] interface PackageEvents; > }; Although it isn't in the recently released 0.1 version, comtypes supports this. Also you can receive events from a non-default source interface. Thomas From theller at python.net Thu Sep 15 21:05:31 2005 From: theller at python.net (Thomas Heller) Date: Thu, 15 Sep 2005 21:05:31 +0200 Subject: [python-win32] WindowsError: (0, 'The operation completed successfully') with compiled prog only References: <6.2.5.2.2.20050914162930.04b0a180@blue-cove.com> Message-ID: Ray Schumacher writes: > Hi all, anyone seen this? > > I'm writing a Win98 replacement shell; when I compile with console=[foo] I get no errors logged or in the console, but when compiled with windows=[foo] I get an error when I try to run subprocess: > > Traceback (most recent call last): > File "Frame2.pyo", line 75, in OnProcessTimer > File "Frame2.pyo", line 83, in getProcList > File "Frame2.pyo", line 97, in launchWithoutConsole > File "subprocess.pyo", line 549, in __init__ > File "subprocess.pyo", line 626, in _get_handles > WindowsError: (0, 'The operation completed successfully') > > (?) > > My code is: > > result = self.launchWithoutConsole('pv', ["-fq",]) > > def launchWithoutConsole(self, command, args): > """Launches 'command' windowless and waits until finished""" > startupinfo = subprocess.STARTUPINFO() > startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW > startupinfo.wShowWindow = win32con.SW_HIDE > proc = subprocess.Popen([command] + args, startupinfo=startupinfo, > shell=False, > bufsize=1000, > stdin=subprocess.PIPE, stdout=subprocess.PIPE > ) > > return proc.stdout.readlines() > > I've tried many variations, but all (so far) leave a "LAUNCHER.EXE.log" with this error, even if command ="anything else".. > > If 'The operation completed successfully' and the error level is zero, why the logged error? > Can it be suppressed? > > I also posted to py2exe-users... I answered this on the py2exe-users list. Thomas From mike.cavanagh at siemens.com Thu Sep 15 21:24:52 2005 From: mike.cavanagh at siemens.com (Cavanagh, Mike) Date: Thu, 15 Sep 2005 15:24:52 -0400 Subject: [python-win32] testMSOffice.py and Excel 2003 Message-ID: Hi! We have a couple of internal applications that are written in Python and have always worked with Excel 2000. We are 'upgrading' to Excel 2003 and in my pre-rollout testing, our applications are failing. Using the testMSOffice.py test case, I receive the following: >>> from win32com.test import testMSOffice >>> testMSOffice.TestAll() Starting Word 8 for dynamic test Starting Word 8 for non-lazy dynamic test Starting MSWord for generated test Starting Excel for Dynamic test... Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\test\testMSOffice.py", line 142, in TestAll TextExcel(xl) File "C:\Python24\Lib\site-packages\win32com\test\testMSOffice.py", line 96, i n TextExcel xl.Workbooks().Add() File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 165, in __call__ return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_. defaultDispatchName,None) com_error: (-2147352562, 'Invalid number of parameters.', None, None) I'm beginning to pull my hair out here, any help would be appreciated. Thanks, Mike From mhammond at skippinet.com.au Fri Sep 16 00:12:07 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 16 Sep 2005 08:12:07 +1000 Subject: [python-win32] win32com events using native interfaces In-Reply-To: <43298DA2.2080706@zuerchertech.com> Message-ID: This should be possible with pywin32 - arbitrary interfaces can be *implemented* by pywin32, just not called. You will need to setup the event mechanism just as if they were IDispatch based events. However, you will also need to setup the COM event class to reference the typelib and typelib interfaces like the win32com\test\pippo samples. It will probably be a little messing around as a direct sample of this may be hard to track down, but it can be made to work. hm - actually, on second thoughts, the demos\outlookAddin.py sample may be very close - it is capable of catching events from excel, where those events are in a typelib. Alternative, see the spambayes plugin implementation for a much larger example. Mark > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of Michael Zuercher > Sent: Friday, 16 September 2005 1:05 AM > To: python-win32 at python.org > Subject: [python-win32] win32com events using native interfaces > > > I have a COM object that sends events. Rather that have the source > interface be 'dispinterface' in the IDL, it is just 'interface'. Is > there a way to catch events from this interface using win32com? The IDL > for the coclass is below for reference. > > [ > uuid(10020202-EB1C-11CF-AE6E-00AA004A34D5), > version(2.0), > helpstring("Data Transformation Services Package Object"), > helpcontext(0x000002ee) > ] > coclass Package2 { > interface _Package; > [default] interface _Package2; > [default, source] interface PackageEvents; > }; > > > Michael Zuercher > Zuercher Technologies LLC > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Fri Sep 16 00:23:25 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 16 Sep 2005 08:23:25 +1000 Subject: [python-win32] Window Media Player WMPlayer.OCX In-Reply-To: <20050914155003.22779.qmail@web40810.mail.yahoo.com> Message-ID: > I got a strange problem that I can play media files > (mp3 etc) through the Pythonwin.exe with the > WMPlayer.OCX. However, it could not be done through > the shell. When I checked the player.status, it shows > "Opening media ...". Please help. As far as I know, the WMPlayer OCX will only work as a true "control" - not as a regular COM object. That means it must be hosted in a 'control container', and these are not trivial to implement. Pythonwin and wxWindows are the only 2 Python environments I am aware of capable of hosting such a control. Mark From timr at probo.com Fri Sep 16 21:17:25 2005 From: timr at probo.com (Tim Roberts) Date: Fri, 16 Sep 2005 12:17:25 -0700 Subject: [python-win32] testMSOffice.py and Excel 2003 In-Reply-To: References: Message-ID: <432B1A45.4090807@probo.com> On Thu, 15 Sep 2005 15:24:52 -0400, "Cavanagh, Mike" wrote: >We have a couple of internal applications that are written in Python and >have always worked with Excel 2000. > >We are 'upgrading' to Excel 2003 and in my pre-rollout testing, our >applications are failing. > >Using the testMSOffice.py test case, I receive the following: > > ... > File "C:\Python24\Lib\site-packages\win32com\test\testMSOffice.py", line >96, in TextExcel > xl.Workbooks().Add() > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 165, >in __call__ > return >self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_. >defaultDispatchName,None) >com_error: (-2147352562, 'Invalid number of parameters.', None, None) > >I'm beginning to pull my hair out here, any help would be appreciated. > Remove the inner set of parentheses: xl.Workbooks.Add() Workbooks is a collection object, not a method. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From python at kareta.de Fri Sep 16 23:45:34 2005 From: python at kareta.de (python@kareta.de) Date: Fri, 16 Sep 2005 23:45:34 +0200 Subject: [python-win32] win32gui.SetCapture Message-ID: <1126907134.432b3cfec804f@webmail.ldc.de> Hi, the following code pyhdl=win32gui.FindWindow(None,'PythonWin') win32gui.SetForegroundWindow(pyhdl) win32gui.SetCapture(pyhdl) results in: Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\test\screen\screen_capture.py", line 51, in ? win32gui.SetCapture(pyhdl) error: (0, 'SetCapture', 'No error message is available') Any hints ? regards, J?rgen ------------------------------------------------- Versandt durch den Webmaildienst der LDC GmbH Bonn From mhammond at skippinet.com.au Sat Sep 17 04:04:35 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 17 Sep 2005 12:04:35 +1000 Subject: [python-win32] win32gui.SetCapture In-Reply-To: <1126907134.432b3cfec804f@webmail.ldc.de> Message-ID: > the following code > > pyhdl=win32gui.FindWindow(None,'PythonWin') > win32gui.SetForegroundWindow(pyhdl) > win32gui.SetCapture(pyhdl) > > results in: > > Traceback (most recent call last): > File > "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", > line 310, in RunScript > exec codeObject in __main__.__dict__ > File "C:\test\screen\screen_capture.py", line 51, in ? > win32gui.SetCapture(pyhdl) > error: (0, 'SetCapture', 'No error message is available') > > Any hints ? The return value processing for SetCapture was in error (it was treated as a boolean function, so would always return None, or raise an error when there was no previous window that had captured the mouse). I have fixed that bug here. For now, you can simply catch that error and ignore it (the new version will simply return 0 in that case) Mark From davidnicolson1 at hotmail.com Mon Sep 19 07:53:32 2005 From: davidnicolson1 at hotmail.com (David Nicolson) Date: Mon, 19 Sep 2005 15:53:32 +1000 Subject: [python-win32] win32com.client.GetActiveObject() Message-ID: Hi, I have been successfully using iTunes' COM interface with Python using either of the following lines: iTunes = win32com.client.gencache.EnsureDispatch("iTunes.Application") iTunes = win32com.client.Dispatch("iTunes.Application") The only problem is that it will launch iTunes if it is not running when instantiating the object here. There are some reasons why I have not attempted to use more COM to check if iTunes is an active process. I tried either of the following lines to only form a connection if iTunes is running. iTunes = win32com.client.GetActiveObject("iTunes.Application") iTunes = win32com.client.GetObject(Class = "iTunes.Application") Both lines result in a pythoncom.com_error with 'Operation unavailable' in the second element of the tuple. Has anyone been able to successfully do this with iTunes' COM server? I have seen other 'Operation unavailable' messages in a few other mailing lists but was unable to find any solutions to this problem. Regards, David From python at kareta.de Mon Sep 19 12:49:37 2005 From: python at kareta.de (=?ISO-8859-1?Q?J=FCrgen_Kareta?=) Date: Mon, 19 Sep 2005 12:49:37 +0200 Subject: [python-win32] win32gui.SetCapture In-Reply-To: References: Message-ID: <432E97C1.3060300@kareta.de> Hi Mark, thanks a lot. J?rgen >>the following code >> >>pyhdl=win32gui.FindWindow(None,'PythonWin') >>win32gui.SetForegroundWindow(pyhdl) >>win32gui.SetCapture(pyhdl) >> >>results in: >> >>Traceback (most recent call last): >> File >>"C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", >>line 310, in RunScript >> exec codeObject in __main__.__dict__ >> File "C:\test\screen\screen_capture.py", line 51, in ? >> win32gui.SetCapture(pyhdl) >>error: (0, 'SetCapture', 'No error message is available') >> >>Any hints ? >> >> > >The return value processing for SetCapture was in error (it was treated as a >boolean function, so would always return None, or raise an error when there >was no previous window that had captured the mouse). I have fixed that bug >here. For now, you can simply catch that error and ignore it (the new >version will simply return 0 in that case) > >Mark > > > > > From mark.mclarnon at gmail.com Mon Sep 19 21:30:17 2005 From: mark.mclarnon at gmail.com (mark mclarnon) Date: Mon, 19 Sep 2005 15:30:17 -0400 Subject: [python-win32] Fwd: process listing without COM/WMI In-Reply-To: <25373858050826131328a0cc1c@mail.gmail.com> References: <25373858050826131328a0cc1c@mail.gmail.com> Message-ID: <25373858050919123013baaef7@mail.gmail.com> Trying to automate the clicking of a button from a ToolbarWindow32 object. Anyone have an example of doing so? I have already downloaded watsup - http://www.tizmoi.net/watsup/intro.html and there doesn't seem to be any examples. Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050919/eed2dcc3/attachment.html From tomas.necas at volny.cz Fri Sep 16 12:22:33 2005 From: tomas.necas at volny.cz (tomas.necas@volny.cz) Date: Fri, 16 Sep 2005 12:22:33 +0200 (CEST) Subject: [python-win32] swig Message-ID: <26194fb1b7ee76f292a02cc6f959c913@www1.mail.volny.cz> Cau please, I have done everything according to Swig Tutorial http://www.swig.org/tutorial.html and the third command ld -G -shared example.o example_wrap.o -o _example.so make me this trouble : ... example_wrap.o(.text+0x1d24):example_wrap.c: undefined reference to 'Perl_sv_setpv' ... I tried to something like that > ld -G -shared example.o example_wrap.o -o _example.so -lc -lpthread -L/lib/perl5/5.8/cygwin/CORE -lperl but the same result or it doesnt can some of this commands (like a -lc) Please whats wrong? win32, perl5.8, swig thanks tom From rshuttleworth at activplant.com Thu Sep 15 21:44:54 2005 From: rshuttleworth at activplant.com (Roger Shuttleworth) Date: Thu, 15 Sep 2005 15:44:54 -0400 Subject: [python-win32] Running a script Message-ID: Hello Windows XP SP2. I am a Python novice. I downloaded an application called rtf2xml that converts RTF files to XML. I have Python 2.4 installed, and updated my path to include c:\python24. The application has the following folder structure: rtf2xml-1.2 (contains setup.py, which I have installed using the python setup.py install command) rtf2xml (contains a bunch of .py files) scripts (contains rtf2xml.py and a test file called hello_world.rtf) The documentation says that I should be in the command prompt window and simply type: rtf2xml hello_world.rtf I've tried this but I get various errors, such as: rtf2xml is not recognized as an internal or external command... python: can't open file...[errno 13] permission denied Please can someone tell me (i) what directory I have to be in, and (ii) what the command line should be? I tried from various folders, with and without "python" in front, but nothing works. Thanks. roger Roger Shuttleworth Documentation Team Lead Activplant Corporation 140 Fullarton Street, 9th Floor London, ON N6A 5P2 Canada Tel. 519 668-7336 Fax. 519 668-3227 www.activplant.com ------------------------------------------------------- The information in this email is confidential and is intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Please contact privacy at activplant.com for cases where you have received this email and were not the intended recipient. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050915/7115a337/attachment.html From Jim.Vickroy at noaa.gov Tue Sep 20 00:40:17 2005 From: Jim.Vickroy at noaa.gov (Jim.Vickroy@noaa.gov) Date: Mon, 19 Sep 2005 16:40:17 -0600 Subject: [python-win32] Running a script Message-ID: <68e29f7d.9f7d68e2@noaa.gov> Hello Roger, Assuming your Python installation is viable (does typing "python" sans quotes at the command line launch the Python interpreter?), have you renamed the file from "rtf2xml" to "rtf2xml.py" as required to run under MS Windows? -- jv -------------- next part -------------- Hello Windows XP SP2. I am a Python novice. I downloaded an application called rtf2xml that converts RTF files to XML. I have Python 2.4 installed, and updated my path to include c:\python24. The application has the following folder structure: rtf2xml-1.2 (contains setup.py, which I have installed using the python setup.py install command) rtf2xml (contains a bunch of .py files) scripts (contains rtf2xml.py and a test file called hello_world.rtf) The documentation says that I should be in the command prompt window and simply type: rtf2xml hello_world.rtf I've tried this but I get various errors, such as: rtf2xml is not recognized as an internal or external command... python: can't open file...[errno 13] permission denied Please can someone tell me (i) what directory I have to be in, and (ii) what the command line should be? I tried from various folders, with and without "python" in front, but nothing works. Thanks. roger Roger Shuttleworth Documentation Team Lead Activplant Corporation 140 Fullarton Street, 9th Floor London, ON N6A 5P2 Canada Tel. 519 668-7336 Fax. 519 668-3227 www.activplant.com ------------------------------------------------------- The information in this email is confidential and is intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Please contact privacy at activplant.com for cases where you have received this email and were not the intended recipient. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050919/ccff7479/attachment.html -------------- next part -------------- _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From growlf at biocede.com Tue Sep 20 03:02:37 2005 From: growlf at biocede.com (Garth Johnson) Date: Mon, 19 Sep 2005 19:02:37 -0600 Subject: [python-win32] Client site not available Message-ID: <432F5FAD.3080300@biocede.com> Ok, I am still relatively new to python, but have chosen it as the language to write a project in. I have searched, googled and bought every O'Reilly book I can find.. and am still stumped. I turn to your venerable forum of knowledge for assistance. The project uses a piece of USB HID hardware that scans the swipe strip on credit cards and allows tracking, accounting etc for various purposes. The device I am using at the moment comes from MagTek and they supplied me with an OCX/ActiveX/COM control that their demo uses in a vbscript (IE only) web page. While this is just dandy, I need a more direct access method for a local instance in my project. I used the MakePy.py tool, and did the expected - added it to the Lib\site-packages\win32com\gen_py pile of supported COM components. Here is the result of me attempting to use it manually in PyWin... >>> import win32com.client >>> swipe = win32com.client.Dispatch("ctlUSBHID.USBHID") >>> swipe.PortOpen False >>> swipe.PortOpen = True Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 463, in __setattr__ self._oleobj_.Invoke(*(args + (value,) + defArgs)) com_error: (-2147352567, 'Exception occurred.', (0, 'ctlUSBHID', 'Client Site not available', None, 1000398, -2146827890), None) >>> The same process works fin in VBScript on the example page from MagTek.. The generated py code from MakePy.py has _prop_map_get_ = { "CardData": (1745027073, 2, (8, 0), (), "CardData", None), "CardEncodeType": (1745027082, 2, (8, 0), (), "CardEncodeType", None), "DeviceSerialNum": (1745027083, 2, (8, 0), (), "DeviceSerialNum", None), "MPrintData": (1745027086, 2, (12, 0), (), "MPrintData", None), "MPrintLen": (1745027087, 2, (3, 0), (), "MPrintLen", None), "MPrintStatus": (1745027084, 2, (3, 0), (), "MPrintStatus", None), "PortOpen": (1745027072, 2, (11, 0), (), "PortOpen", None), "SequenceNumber": (1745027085, 2, (3, 0), (), "SequenceNumber", None), } _prop_map_put_ = { "CardData": ((1745027073, LCID, 4, 0),()), "CardEncodeType": ((1745027082, LCID, 4, 0),()), "DeviceSerialNum": ((1745027083, LCID, 4, 0),()), "MPrintData": ((1745027086, LCID, 4, 0),()), "MPrintLen": ((1745027087, LCID, 4, 0),()), "MPrintStatus": ((1745027084, LCID, 4, 0),()), "PortOpen": ((1745027072, LCID, 4, 0),()), "SequenceNumber": ((1745027085, LCID, 4, 0),()), } What am I doing wrong.? ..or is it something wrong in the COM control itself? From upadhyay at gmail.com Tue Sep 20 08:41:55 2005 From: upadhyay at gmail.com (Amit Upadhyay) Date: Tue, 20 Sep 2005 12:11:55 +0530 Subject: [python-win32] Running a script In-Reply-To: <68e29f7d.9f7d68e2@noaa.gov> References: <68e29f7d.9f7d68e2@noaa.gov> Message-ID: <349edb38050919234162d10e93@mail.gmail.com> On 9/20/05, Jim.Vickroy at noaa.gov wrote: > > Assuming your Python installation is viable (does typing "python" sans > quotes at the command line launch the Python interpreter?), have you > renamed the file from "rtf2xml" to "rtf2xml.py" as required to run > under MS Windows? I fear that may not be enough, he will have to try "python rtf2xml.py". Also scripts are installed in C:\Python24\Scripts, so unless rtf2xml comes with a batch file, and Scripts folder is in the path, he will have to either go to scripts folder of give complete path to python "python c:\python24\scripts\rtf2xmp.py args". -- Amit Upadhyay Blog: http://www.rootshell.be/~upadhyay +91-9867-359-701 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050920/42ae53a0/attachment.htm From mhammond at skippinet.com.au Tue Sep 20 10:17:02 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 20 Sep 2005 18:17:02 +1000 Subject: [python-win32] Client site not available In-Reply-To: <432F5FAD.3080300@biocede.com> Message-ID: > The same process works fin in VBScript on the example page from > MagTek.. Does it work from VBScript executed via cscript/wscript? If it only works from VBScript inside a webpage hosting the control, the problem will be that you need an OCX "container" to host the control. Pythonwin is capable (see the pywin\demos\ocx dir), as is wxPython (but I've never use that). Otherwise, can you post the VBScript code which does work (just up to the successful PortOpen property set)? Cheers, Mark From steve at holdenweb.com Tue Sep 20 11:48:10 2005 From: steve at holdenweb.com (Steve Holden) Date: Tue, 20 Sep 2005 10:48:10 +0100 Subject: [python-win32] Running a script In-Reply-To: References: Message-ID: <432FDADA.1070705@holdenweb.com> Roger Shuttleworth wrote: > Hello > > Windows XP SP2. > > I am a Python novice. I downloaded an application called rtf2xml that > converts RTF files to XML. I have Python 2.4 installed, and updated my > path to include c:\python24. The application has the following folder > structure: > > rtf2xml-1.2 (contains setup.py, which I have installed using the python > setup.py install command) > rtf2xml (contains a bunch of .py files) > scripts (contains rtf2xml.py and a test file called hello_world.rtf) > > The documentation says that I should be in the command prompt window and > simply type: > rtf2xml hello_world.rtf > > I've tried this but I get various errors, such as: > rtf2xml is not recognized as an internal or external command... > python: can't open file...[errno 13] permission denied > > Please can someone tell me (i) what directory I have to be in, and (ii) > what the command line should be? I tried from various folders, with and > without "python" in front, but nothing works. > Some basic information that might help: http://www.python.org/doc/faq/windows.html It sounds as though your instructions might be a git Unix-xentric. In the Windows environment a program ordinarily has to be something.py or something.pyw to be recognised as a Python program, whereas in Unix/Linux the interpreter is often identified by the "shebang" line (#!/usr/bin/python, or whatever). Get back to the list if none of hte FAQ advice helps. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.pycon.org From growlf at biocede.com Tue Sep 20 17:28:34 2005 From: growlf at biocede.com (Garth Johnson) Date: Tue, 20 Sep 2005 09:28:34 -0600 Subject: [python-win32] Client site not available In-Reply-To: References: Message-ID: <43302AA2.4050108@biocede.com> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050920/2473c13d/attachment.html From theller at python.net Tue Sep 20 18:36:56 2005 From: theller at python.net (Thomas Heller) Date: Tue, 20 Sep 2005 18:36:56 +0200 Subject: [python-win32] Getting tired with py2exe Message-ID: I'm slowly getting tired maintaining py2exe. It is far from perfect, although it has interesting features (I would say). The problem, apart from the work, is that it is good enough for me - I can do everything that I need with it. But I assume I use far less libaries than other Python programmers, so a lot of bugs will never bite me. It is also interesting that the recently introduced bundle-files option, which allows to build single-file exes has gained a lot of interest - although the ONLY use case (so far) I have myself for it is to implement inproc COM servers which will compatible with Python clients (and other Python inproc COM servers) because of the total isolation of the Python VMs. Is anyone interested in taking over the maintainance, documentation, and further development? Should py2exe be integrated into another, larger, package? Pywin32 comes to mind, but also Philip Eby's setuptools (that's why I post to distutils-sig as well)... Thomas From steve at holdenweb.com Tue Sep 20 23:44:06 2005 From: steve at holdenweb.com (Steve Holden) Date: Tue, 20 Sep 2005 22:44:06 +0100 Subject: [python-win32] Getting tired with py2exe In-Reply-To: References: Message-ID: Thomas Heller wrote: > I'm slowly getting tired maintaining py2exe. It is far from perfect, > although it has interesting features (I would say). > > The problem, apart from the work, is that it is good enough for me - I > can do everything that I need with it. But I assume I use far less > libaries than other Python programmers, so a lot of bugs will never bite > me. > > It is also interesting that the recently introduced bundle-files option, > which allows to build single-file exes has gained a lot of interest - > although the ONLY use case (so far) I have myself for it is to implement > inproc COM servers which will compatible with Python clients (and other > Python inproc COM servers) because of the total isolation of the Python > VMs. > > Is anyone interested in taking over the maintainance, documentation, and > further development? > > Should py2exe be integrated into another, larger, package? Pywin32 > comes to mind, but also Philip Eby's setuptools (that's why I post to > distutils-sig as well)... > Ignoring all the philosophical questions I'd like to thank you for all your hard work on py2exe over the years, which has benefited the Windows Python community immeasurably. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.pycon.org From growlf at biocede.com Wed Sep 21 06:08:35 2005 From: growlf at biocede.com (Garth Johnson) Date: Tue, 20 Sep 2005 22:08:35 -0600 Subject: [python-win32] Getting tired with py2exe In-Reply-To: References: Message-ID: <4330DCC3.6090409@biocede.com> Steve Holden wrote: >Ignoring all the philosophical questions I'd like to thank you for all >your hard work on py2exe over the years, which has benefited the Windows >Python community immeasurably. > >regards > Steve > > here here! I have just begun my trek into Python and am already relying upon Py2Exe for my projects. Thank you for an effective, well designed tool that is easy to use. It was one of the final deciding factors in our company's choice of languages. (not the least of which was the ease of which our dev team took to Python after pretzling with perl). I do hope you change your mind. Garth From bob at redivi.com Wed Sep 21 01:12:49 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue, 20 Sep 2005 19:12:49 -0400 Subject: [python-win32] [Py2exe-users] Re: Getting tired with py2exe In-Reply-To: References: Message-ID: <999C4F9B-61DB-4229-8CD4-FC2B929CAC10@redivi.com> On Sep 20, 2005, at 5:44 PM, Steve Holden wrote: > Thomas Heller wrote: > >> I'm slowly getting tired maintaining py2exe. It is far from perfect, >> although it has interesting features (I would say). >> The problem, apart from the work, is that it is good enough for me >> - I >> can do everything that I need with it. But I assume I use far less >> libaries than other Python programmers, so a lot of bugs will >> never bite >> me. >> It is also interesting that the recently introduced bundle-files >> option, >> which allows to build single-file exes has gained a lot of interest - >> although the ONLY use case (so far) I have myself for it is to >> implement >> inproc COM servers which will compatible with Python clients (and >> other >> Python inproc COM servers) because of the total isolation of the >> Python >> VMs. >> Is anyone interested in taking over the maintainance, >> documentation, and >> further development? >> Should py2exe be integrated into another, larger, package? Pywin32 >> comes to mind, but also Philip Eby's setuptools (that's why I post to >> distutils-sig as well)... >> > Ignoring all the philosophical questions I'd like to thank you for > all your hard work on py2exe over the years, which has benefited > the Windows Python community immeasurably. I'd like to thank you as well. Although I'm primarily a Mac OS X (and various other *nix-ish things) user myself, I have used py2exe on several occasions to package a commercial product and to give various one-off applications to clients. py2exe was also a large inspiration for py2app (which I have been neglecting lately). py2exe (and py2app) currently do everything I need them do (albeit with a little prodding), so that's why I've done so little with it in the past few months. I hope that the packager-future will be largely setuptools based and that the various platform-specific packagers will share a lot more code in the future (setuptools, modulegraph, etc.), making maintenance easier and more fun for everyone. This was my primary use case when I was initially discussing the egg spec with PJE back around pycon-time (though I have been unfortunately useless implementing and evolving it). Right now, I think the packagers and the packages are at odds, because the packagers need metadata that the packages don't provide (in a pre-setuptools universe)... so right now users (or the packagers) need to know a lot of magic incantations to make the various complicated Python packages work, where with setuptools based packages the magic incantations are built-in :) -bob From tim.golden at viacom-outdoor.co.uk Wed Sep 21 16:55:34 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed, 21 Sep 2005 15:55:34 +0100 Subject: [python-win32] Retreive paper width from printer Message-ID: <9A28C052FF32734DACB0A288A3533991044D21FB@vogbs009.gb.vo.local> [Bill Burns] | Is it possible to retrieve the paper width from a printer? Unhelpfully (and I'd really like to be helpful), I'd point out that this is really a Win32 question. If you can find out from somewhere how you can do this at all in Windows, then I'm quite happy to help work out -- if you still need that help -- how that translates into Python. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From billburns at pennswoods.net Thu Sep 22 06:24:32 2005 From: billburns at pennswoods.net (Bill Burns) Date: Thu, 22 Sep 2005 00:24:32 -0400 Subject: [python-win32] Retreive paper width from printer In-Reply-To: <9A28C052FF32734DACB0A288A3533991044D21FB@vogbs009.gb.vo.local> References: <9A28C052FF32734DACB0A288A3533991044D21FB@vogbs009.gb.vo.local> Message-ID: <43323200.6070401@pennswoods.net> [Bill Burns] Is it possible to retrieve the paper width from a printer? [Tim Golden] Unhelpfully (and I'd really like to be helpful), I'd point out that this is really a Win32 question. If you can find out from somewhere how you can do this at all in Windows, then I'm quite happy to help work out -- if you still need that help -- how that translates into Python. Tim, Thank you for the reply and your excellent web site! After I had originally posted my question, I received a response from Roger Upole and he mentioned DEVMODE and win32print.GetPrinter using level 2. When I tried the code below >>at home<< against my little Deskjet 880, def printerProperties(self): #self.currentPrinter() is a method I had in my class to #retrieve the Printer name from a comboBox on the GUI. pHandle = win32print.OpenPrinter(self.currentPrinter()) properties = win32print.GetPrinter(pHandle, 2) pDevModeObj = properties["pDevMode"] print pDevModeObj.FormName print pDevModeObj.PaperSize print pDevModeObj.DefaultSource print pDevModeObj.PaperLength print pDevModeObj.PaperWidth win32print.ClosePrinter(pHandle) it seemed to work exactly as I wanted (PaperWidth> 2159, PaperLength> 2794). But when I tried it >>at work<< against the Savin 2400, it printed a PaperWidth of 2159 and a PaperLength of 2794, as well! At the time, the Savin had 24" & 30" wide paper in it (if I recall correctly), it can't even hold 8.5" x 11" paper. So I just figured I would look into it another day and that day hasn't come yet :-) I'd still like to make this work though (at some point in time). I did start to poke around on Savin's support web site.... I also had the idea of maybe trying to set the PaperWidth somehow and then catching any errors, i.e., try: set.PaperWidth = 36 except SomeError: # 36" paper is not in the printer set.PaperWidth = 30 except SomeError: # no 30" in the machine either! set.PaperWidth = 24 Who knows?? I'll definitely repost, if I find something. Again, thanks for the reply! Bill From ramirez08063 at itc.nl Thu Sep 22 15:40:47 2005 From: ramirez08063 at itc.nl (Jorge Ramirez) Date: Thu, 22 Sep 2005 15:40:47 +0200 Subject: [python-win32] Open PDF Message-ID: <36141C39871E4D4DAE92F79D1838543601B176C7@itcnt14.itc.nl> Hello, I would like to know how to open a PDF document from a python script, any suggestions are appreciated. Thanks, JR -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050922/52ee1d23/attachment.html From theller at python.net Thu Sep 22 15:55:56 2005 From: theller at python.net (Thomas Heller) Date: Thu, 22 Sep 2005 15:55:56 +0200 Subject: [python-win32] Open PDF References: <36141C39871E4D4DAE92F79D1838543601B176C7@itcnt14.itc.nl> Message-ID: "Jorge Ramirez" writes: > Hello, > > I would like to know how to open a PDF document from a python script, > any suggestions are appreciated. os.startfile("mydoc.pdf") Thomas From shendric at uga.edu Thu Sep 22 19:01:42 2005 From: shendric at uga.edu (Sean Q. Hendricks) Date: Thu, 22 Sep 2005 10:01:42 -0700 Subject: [python-win32] TerminateProcess issues Message-ID: <4332E376.6050706@uga.edu> Hi all, I've been working on a Python script that executes an external Windows program when the user presses a button, and I would like it to stop when they press another button. To that end, I created a class that represents the GUI, and there are two methods that are bound to button events. The following is the code for the two methods: def startEncode(self,event): self.newProc = subprocess.Popen(["C:\\Documents and Settings\Administrator\My Documents\Hendricks\Current Projects\ITAFeedback\Program\producer.exe"]) #The following line, when uncommented, allows the process to terminate with no problem #win32api.TerminateProcess(int(self.newProc._handle),-1) def stopEncode(self,event): if self.newProc: win32api.TerminateProcess(int(self.newProc._handle),-1) The problem is that I receive the following error when I run the program: pywintypes.error: (5, 'TerminateProcess', 'Access is denied.') Now, I'm running as an administrator, so I don't see that as an issue, and when I call TerminateProcess from within the same method wherein the process is created, there's no problem. I have seen some email in various places that mention that this can occur if a new handle is not created by a separate script, but I assume now that this means that even from a separate function in the same class, this is not possible. So, is there some way to communicate the process id correctly between two methods of a class? I'd really appreciate any help anyone can give me on this. I've tried many different ways of starting and stopping this process, and I have not found an adequate solution, as yet. I'm on Win2k, using Python 2.3 (having installed the subprocess module and the win32 extensions). Sean -- ***Please note new email address: shendric at uga.edu*** From ramirez08063 at itc.nl Thu Sep 22 16:48:07 2005 From: ramirez08063 at itc.nl (Jorge Ramirez) Date: Thu, 22 Sep 2005 16:48:07 +0200 Subject: [python-win32] Simultaneous Adobe Reader Message-ID: <36141C39871E4D4DAE92F79D1838543601B176C9@itcnt14.itc.nl> Hello, >From windows, using a python script how can I open Adobe Reader without displaying a PDF document? Furthermore, using a script is it possible to run two Adobe Reader sessions simulatneously. Thanks in advance. Kind Regards, JR -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050922/96094e02/attachment.html From Jim.Vickroy at noaa.gov Thu Sep 22 17:35:34 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu, 22 Sep 2005 09:35:34 -0600 Subject: [python-win32] Simultaneous Adobe Reader In-Reply-To: <36141C39871E4D4DAE92F79D1838543601B176C9@itcnt14.itc.nl> References: <36141C39871E4D4DAE92F79D1838543601B176C9@itcnt14.itc.nl> Message-ID: <4332CF46.1050902@noaa.gov> Jorge Ramirez wrote: > Hello, > > From windows, using a python script how can I open Adobe Reader > without displaying a PDF document? Furthermore, using a script is it > possible to run two Adobe Reader sessions simulatneously. Thanks in > advance. > > Kind Regards, > JR > >------------------------------------------------------------------------ > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > One way is to use the os.startfile(...) function, but that does not open multiple instances of v7.0 of the reader. -- jv From rwupole at msn.com Fri Sep 23 00:16:10 2005 From: rwupole at msn.com (Roger Upole) Date: Thu, 22 Sep 2005 18:16:10 -0400 Subject: [python-win32] Re: TerminateProcess issues Message-ID: Without knowing how the GUI executes the methods (eg in a different thread,etc) it's hard to tell what might be happening with the handle between the calls. You might be able to open another handle to the process and use that to kill it. h=win32api.OpenProcess(True, win32con.PROCESS_TERMINATE, self.newProc.pid) win32api.TerminateProcess(h,-1) hth Roger "Sean Q. Hendricks wrote: > Hi all, > > I've been working on a Python script that executes an external Windows > program when the user presses a button, and I would like it to stop when > they press another button. To that end, I created a class that > represents the GUI, and there are two methods that are bound to button > events. The following is the code for the two methods: > > def startEncode(self,event): > self.newProc = subprocess.Popen(["C:\\Documents and > Settings\Administrator\My Documents\Hendricks\Current > Projects\ITAFeedback\Program\producer.exe"]) > #The following line, when uncommented, allows the process to > terminate with no problem > #win32api.TerminateProcess(int(self.newProc._handle),-1) > > def stopEncode(self,event): > if self.newProc: > win32api.TerminateProcess(int(self.newProc._handle),-1) > > The problem is that I receive the following error when I run the program: > > pywintypes.error: (5, 'TerminateProcess', 'Access is denied.') > > Now, I'm running as an administrator, so I don't see that as an issue, > and when I call TerminateProcess from within the same method wherein the > process is created, there's no problem. I have seen some email in > various places that mention that this can occur if a new handle is not > created by a separate script, but I assume now that this means that even > from a separate function in the same class, this is not possible. So, > is there some way to communicate the process id correctly between two > methods of a class? I'd really appreciate any help anyone can give me > on this. I've tried many different ways of starting and stopping this > process, and I have not found an adequate solution, as yet. I'm on > Win2k, using Python 2.3 (having installed the subprocess module and the > win32 extensions). > > Sean From le.dahut at laposte.net Fri Sep 23 10:46:38 2005 From: le.dahut at laposte.net (le dahut) Date: Fri, 23 Sep 2005 10:46:38 +0200 Subject: [python-win32] hide subshell os.system Message-ID: <1127465198.14380.217.camel@kls> Hi everyone, How can the subshell be hidden when executing code such as : os.system('ping host') ? The program uses GTK and it's very annoying to see a black window when using a graphical program ... Thanks, K. From le.dahut at laposte.net Fri Sep 23 10:52:09 2005 From: le.dahut at laposte.net (le dahut) Date: Fri, 23 Sep 2005 10:52:09 +0200 Subject: [python-win32] wmi - 9x and py2exe Message-ID: <1127465529.14380.224.camel@kls> I've crawled google and its search results in broad, length and through but I didn't find a real explanation concerning the use of wmi with py2exe under win 9x/Me. My program works fine on the 98 machine where python pygtk gtk runtime and wmi are installed. I want to run it on fresh installed machines, where nothing but the base system is installed. Is it possible to "hard compile" WMi ? K. From theller at python.net Fri Sep 23 11:55:15 2005 From: theller at python.net (Thomas Heller) Date: Fri, 23 Sep 2005 11:55:15 +0200 Subject: [python-win32] hide subshell os.system References: <1127465198.14380.217.camel@kls> Message-ID: le dahut writes: > Hi everyone, > > How can the subshell be hidden when executing code such as : > > os.system('ping host') ? > > The program uses GTK and it's very annoying to see a black window when > using a graphical program ... You should use the subprocess module instead, it is more flexible and should allow this. Thomas From theller at python.net Fri Sep 23 11:56:13 2005 From: theller at python.net (Thomas Heller) Date: Fri, 23 Sep 2005 11:56:13 +0200 Subject: [python-win32] wmi - 9x and py2exe References: <1127465529.14380.224.camel@kls> Message-ID: le dahut writes: > I've crawled google and its search results in broad, length and through > but I didn't find a real explanation concerning the use of wmi with > py2exe under win 9x/Me. > > My program works fine on the 98 machine where python pygtk gtk runtime > and wmi are installed. I want to run it on fresh installed machines, > where nothing but the base system is installed. Is it possible to "hard > compile" WMi ? The windows WMI runtime must be installed in the win98 machine, otherwise it cannot work. Thomas From le.dahut at laposte.net Fri Sep 23 12:34:21 2005 From: le.dahut at laposte.net (le dahut) Date: Fri, 23 Sep 2005 12:34:21 +0200 Subject: [python-win32] hide subshell os.system In-Reply-To: References: <1127465198.14380.217.camel@kls> Message-ID: <1127471661.14380.230.camel@kls> Here, it's not really an answer but it may help many people. The ping module by Lars Strand : http://www.gnist.org/~lars/code/ping/ping.html Must be run as root on unix stations ... K. Le vendredi 23 septembre 2005 ? 11:55 +0200, Thomas Heller a ?crit : > le dahut writes: > > > Hi everyone, > > > > How can the subshell be hidden when executing code such as : > > > > os.system('ping host') ? > > > > The program uses GTK and it's very annoying to see a black window when > > using a graphical program ... > > You should use the subprocess module instead, it is more flexible and > should allow this. > > Thomas From shendric at uga.edu Fri Sep 23 18:16:14 2005 From: shendric at uga.edu (Sean Q. Hendricks) Date: Fri, 23 Sep 2005 09:16:14 -0700 Subject: [python-win32] TerminateProcess issues In-Reply-To: References: Message-ID: <43342A4E.7020208@uga.edu> Roger Upole wrote: >Without knowing how the GUI executes the methods (eg in a different >thread,etc) >it's hard to tell what might be happening with the handle between the calls. > > The GUI processes each method when a button event is caught. The methods startEncode() and stopEncode() are in the same class as the GUI. I don't know if that helps, but they are not opened in different threads, at least not intentionally. >You might be able to open another handle to the process and use that to kill >it. >h=win32api.OpenProcess(True, win32con.PROCESS_TERMINATE, self.newProc.pid) >win32api.TerminateProcess(h,-1) > > That seemed to do the trick. I guess I'm still not clear on how handles work in this instance. Apparently, after the startEncode() method begins and opens the process, the handle automatically closes. Then, when stopEncode is called, the handle is no longer available, although the pid is still available through the Popen instance. Perhaps when a Popen instance is created, there is some kind of temporary handle, since it apparently doesn't have one as a property? I'm not complaining, because it works, it would just be nice to understand exactly why. I'll probably just look through the subprocess module and try to figure it out. Thanks, that helps immensely. Sean > hth > Roger > > >"Sean Q. Hendricks wrote: > > >>Hi all, >> >>I've been working on a Python script that executes an external Windows >>program when the user presses a button, and I would like it to stop when >>they press another button. To that end, I created a class that >>represents the GUI, and there are two methods that are bound to button >>events. The following is the code for the two methods: >> >>def startEncode(self,event): >> self.newProc = subprocess.Popen(["C:\\Documents and >>Settings\Administrator\My Documents\Hendricks\Current >>Projects\ITAFeedback\Program\producer.exe"]) >> #The following line, when uncommented, allows the process to >>terminate with no problem >> #win32api.TerminateProcess(int(self.newProc._handle),-1) >> >>def stopEncode(self,event): >> if self.newProc: >> win32api.TerminateProcess(int(self.newProc._handle),-1) >> >>The problem is that I receive the following error when I run the program: >> >>pywintypes.error: (5, 'TerminateProcess', 'Access is denied.') >> >>Now, I'm running as an administrator, so I don't see that as an issue, >>and when I call TerminateProcess from within the same method wherein the >>process is created, there's no problem. I have seen some email in >>various places that mention that this can occur if a new handle is not >>created by a separate script, but I assume now that this means that even >>from a separate function in the same class, this is not possible. So, >>is there some way to communicate the process id correctly between two >>methods of a class? I'd really appreciate any help anyone can give me >>on this. I've tried many different ways of starting and stopping this >>process, and I have not found an adequate solution, as yet. I'm on >>Win2k, using Python 2.3 (having installed the subprocess module and the >>win32 extensions). >> >>Sean >> >> > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > > > -- ***Please note new email address: shendric at uga.edu*** From mike.cavanagh at siemens.com Fri Sep 23 15:23:18 2005 From: mike.cavanagh at siemens.com (Cavanagh, Mike) Date: Fri, 23 Sep 2005 09:23:18 -0400 Subject: [python-win32] testMSOffice.py and Excel 2003 Message-ID: Tim, Thanks for the reply, the test case now passes. However, our internal application is still failing. code snippet: import win32com import win32com.client.dynamic import pythoncom from pywintypes import Unicode from win32com.client import gencache xl = win32com.client.dynamic.Dispatch("Excel.Application") xl.Visible = 1 xlBook = xl.Workbooks.Open('C:\\test.xls') xlSheet = xlBook.Worksheets(1) print xlSheet.Name xlSheet.Cells(1,1).Value = "Hello World" print xlSheet.Cells(1,1).Value lastCol = 14 lastRow = xlSheet.Cells.Find('Hello World',xlSheet.Cells(1, 1), 1, 1).Row data = xlSheet.Range(xlSheet.Cells(1,1), xlSheet.Cells(lastRow,lastCol)).Value xl.Workbooks(1).Close(SaveChanges = 1) xl.Quit() /snippet When this is run, I receive the following error: Traceback (most recent call last): File "", line 1, in ? File "c:\python24\lib\site-packages\win32com\test\testExcel.py", line 16, in ? lastRow = xlSheet.Cells.Find('Hello World',xlSheet.Cells(1, 1), 1, 1).Row File "c:\python24\lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-00 0000000046x0x1x5\Range.py", line 197, in Find , MatchCase, MatchByte, SearchFormat) pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352565), None) I believe this error is coming from Excel, but I am not sure why. The offending line works with Excel 2000 but not 2003. Thanks, Mike -----Original Message----- From: Tim Roberts [mailto:timr at probo.com] Sent: Friday, September 16, 2005 3:17 PM To: python-win32 at python.org Subject: [python-win32] testMSOffice.py and Excel 2003 On Thu, 15 Sep 2005 15:24:52 -0400, "Cavanagh, Mike" wrote: >We have a couple of internal applications that are written in Python and >have always worked with Excel 2000. > >We are 'upgrading' to Excel 2003 and in my pre-rollout testing, our >applications are failing. > >Using the testMSOffice.py test case, I receive the following: > > ... > File "C:\Python24\Lib\site-packages\win32com\test\testMSOffice.py", line >96, in TextExcel > xl.Workbooks().Add() > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 165, >in __call__ > return >self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_. >defaultDispatchName,None) >com_error: (-2147352562, 'Invalid number of parameters.', None, None) > >I'm beginning to pull my hair out here, any help would be appreciated. > Remove the inner set of parentheses: xl.Workbooks.Add() Workbooks is a collection object, not a method. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From luc.saffre at gmx.net Fri Sep 23 16:27:49 2005 From: luc.saffre at gmx.net (Luc Saffre) Date: Fri, 23 Sep 2005 16:27:49 +0200 Subject: [python-win32] "Hebrew transformation" when printing with SetGraphicsMode(GM_ADVANCED) Message-ID: <433410E5.9030307@gmx.net> Hello, here is a script that prints a simple text to the Windows default printer. But on some printers, each letter is mirrored around its baseline (upside down, but left stays left). I call this effect "Hebrew transformation" because to me the result looked at first glance like hebrew text. The problem occurs for example on a Brother MFC-3520C (an ink jet printer). Funnily it never occurs on a Samsung ML-1200 (laser). It also never occurs if I use a redirected "Lexmark Optra PS" driver and watch the result using GhostView. It must have to do with advanced graphics mode because it also disappears on the Brother if I remove the line dc.SetGraphicsMode(win32con.GM_ADVANCED) (This script does not need GM_ADVANCED mode, but in other scripts I want to use SetWorldTransform() which requires GM_ADVANCED) Any hints or ideas? I'd also be glad to get some test reports on other printers. Luc Here is the code: ------- import win32ui import win32con dc = win32ui.CreateDC() dc.CreatePrinterDC() dc.StartDoc("test") dc.SetGraphicsMode(win32con.GM_ADVANCED) dc.SetMapMode(win32con.MM_TWIPS) dc.StartPage() font = win32ui.CreateFont({'name':"Courier New"}) dc.SelectObject(font) dc.TextOut(800,-800,"This is a test") dc.EndPage() ------- From timr at probo.com Fri Sep 23 18:15:54 2005 From: timr at probo.com (Tim Roberts) Date: Fri, 23 Sep 2005 09:15:54 -0700 Subject: [python-win32] hide subshell os.system In-Reply-To: References: Message-ID: <43342A3A.5040302@probo.com> On Fri, 23 Sep 2005 10:46:38 +0200, le dahut wrote: >Hi everyone, > >How can the subshell be hidden when executing code such as : > >os.system('ping host') ? > >The program uses GTK and it's very annoying to see a black window when >using a graphical program ... > ASPN includes a "ping" module for Python. No console window there! Google is your friend. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Sep 23 18:22:17 2005 From: timr at probo.com (Tim Roberts) Date: Fri, 23 Sep 2005 09:22:17 -0700 Subject: [python-win32] Simultaneous Adobe Reader In-Reply-To: References: Message-ID: <43342BB9.40401@probo.com> On Thu, 22 Sep 2005 16:48:07 +0200, "Jorge Ramirez" wrote: >From windows, using a python script how can I open Adobe Reader without >displaying a PDF document? > What would be the point? It's certainly possible to look up the location of the Acrobat Reader in the registry (by looking for the handler for .pdf files) and launch the program by name, but why would you want to? >Furthermore, using a script is it possible >to run two Adobe Reader sessions simulatneously. > > Yes and no. The Acrobat Reader is an MDI program. That means it handles multiple documents, but it does so by using a single Acrobat process, and a single "master" window. Now, you can certainly have multiple PDF documents open at once. By default, Acrobat runs with its client (document) windows maximized, so you can only see one at a time. If you un-maximize the client window, or if choose Window -> Cascade, you can see there are multiple documents inside. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Paul.Weimer at harlandfs.com Mon Sep 26 18:28:56 2005 From: Paul.Weimer at harlandfs.com (Paul Weimer) Date: Mon, 26 Sep 2005 09:28:56 -0700 Subject: [python-win32] Using SOAPpy Within a Windows NT service Message-ID: I have a web service written in SOAPpy that is working fine; it is currently run from a batch file as a scheduled task on a WIndows server. My support folks would like it to be run as an NT service. I have been able to write NT service in Python before but I'm not having much luck interupting the SOAP server when it's waiting for reaquests. Any ideas? Paul Weimer -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050926/60c98115/attachment.htm From mike.cavanagh at siemens.com Mon Sep 26 20:47:13 2005 From: mike.cavanagh at siemens.com (Cavanagh, Mike) Date: Mon, 26 Sep 2005 14:47:13 -0400 Subject: [python-win32] testMSOffice.py and Excel 2003 Message-ID: Here we go: Worked with Excel 2000, but not 2003: lastRow = xlSheet.Cells.Find('Hello World',xlSheet.Cells(1, 1), 1, 1).Row Works with Excel 2000 and 2003: lastRow = xlSheet.Cells.Find('Hello World',xlSheet.Cells(1, 1), -4163, 1).Row >From MSDN: expression.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte) Excel 2003 wanted the xlValues constant (-4163) for LookIn, 2000 was happy with 1. Not sure why... Cheers, Mike -----Original Message----- From: Cavanagh, Mike Sent: Friday, September 23, 2005 9:23 AM To: python-win32 at python.org Subject: Re: [python-win32] testMSOffice.py and Excel 2003 Tim, Thanks for the reply, the test case now passes. However, our internal application is still failing. code snippet: import win32com import win32com.client.dynamic import pythoncom from pywintypes import Unicode from win32com.client import gencache xl = win32com.client.dynamic.Dispatch("Excel.Application") xl.Visible = 1 xlBook = xl.Workbooks.Open('C:\\test.xls') xlSheet = xlBook.Worksheets(1) print xlSheet.Name xlSheet.Cells(1,1).Value = "Hello World" print xlSheet.Cells(1,1).Value lastCol = 14 lastRow = xlSheet.Cells.Find('Hello World',xlSheet.Cells(1, 1), 1, 1).Row data = xlSheet.Range(xlSheet.Cells(1,1), xlSheet.Cells(lastRow,lastCol)).Value xl.Workbooks(1).Close(SaveChanges = 1) xl.Quit() /snippet When this is run, I receive the following error: Traceback (most recent call last): File "", line 1, in ? File "c:\python24\lib\site-packages\win32com\test\testExcel.py", line 16, in ? lastRow = xlSheet.Cells.Find('Hello World',xlSheet.Cells(1, 1), 1, 1).Row File "c:\python24\lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-00 0000000046x0x1x5\Range.py", line 197, in Find , MatchCase, MatchByte, SearchFormat) pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352565), None) I believe this error is coming from Excel, but I am not sure why. The offending line works with Excel 2000 but not 2003. Thanks, Mike -----Original Message----- From: Tim Roberts [mailto:timr at probo.com] Sent: Friday, September 16, 2005 3:17 PM To: python-win32 at python.org Subject: [python-win32] testMSOffice.py and Excel 2003 On Thu, 15 Sep 2005 15:24:52 -0400, "Cavanagh, Mike" wrote: >We have a couple of internal applications that are written in Python and >have always worked with Excel 2000. > >We are 'upgrading' to Excel 2003 and in my pre-rollout testing, our >applications are failing. > >Using the testMSOffice.py test case, I receive the following: > > ... > File "C:\Python24\Lib\site-packages\win32com\test\testMSOffice.py", line >96, in TextExcel > xl.Workbooks().Add() > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 165, >in __call__ > return >self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_. >defaultDispatchName,None) >com_error: (-2147352562, 'Invalid number of parameters.', None, None) > >I'm beginning to pull my hair out here, any help would be appreciated. > Remove the inner set of parentheses: xl.Workbooks.Add() Workbooks is a collection object, not a method. -- 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 _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From cmtaylor at ti.com Mon Sep 26 20:52:14 2005 From: cmtaylor at ti.com (Taylor, Martin) Date: Mon, 26 Sep 2005 13:52:14 -0500 Subject: [python-win32] [Pywebsvcs-talk] Using SOAPpy Within a Windows NT service Message-ID: I have a SOAP server that I wrote in Python, using SOAPpy, and then I turned it into a Windows service using FireDaemon (http://www.firedaemon.com/). Its not Open Source but its very cheap and works well. My company has bought 15 licenses so far and plans to buy more as we set up more SOAP servers. Martin Taylor ________________________________ From: pywebsvcs-talk-admin at lists.sourceforge.net [mailto:pywebsvcs-talk-admin at lists.sourceforge.net] On Behalf Of Paul Weimer Sent: Monday, September 26, 2005 11:29 AM To: pywebsvcs-talk at lists.sourceforge.net; python-win32 at python.org Subject: [Pywebsvcs-talk] Using SOAPpy Within a Windows NT service I have a web service written in SOAPpy that is working fine; it is currently run from a batch file as a scheduled task on a WIndows server. My support folks would like it to be run as an NT service. I have been able to write NT service in Python before but I'm not having much luck interupting the SOAP server when it's waiting for reaquests. Any ideas? Paul Weimer -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050926/8e163eb2/attachment.html From mhammond at skippinet.com.au Tue Sep 27 00:35:02 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 27 Sep 2005 08:35:02 +1000 Subject: [python-win32] [Pywebsvcs-talk] Using SOAPpy Within a WindowsNT service In-Reply-To: Message-ID: As a matter of interest, is there a reason the pywin32 package wasn't able to host your service for free? It works quite well with a number of sophisticated systems (including Zope) and even is supported by py2exe (so you need not install Python itself) Mark. -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Taylor, Martin Sent: Tuesday, September 27, 2005 4:52 AM To: Paul Weimer Cc: pywebsvcs-talk at lists.sourceforge.net; python-win32 at python.org Subject: Re: [python-win32] [Pywebsvcs-talk] Using SOAPpy Within a WindowsNT service I have a SOAP server that I wrote in Python, using SOAPpy, and then I turned it into a Windows service using FireDaemon (http://www.firedaemon.com/). Its not Open Source but its very cheap and works well. My company has bought 15 licenses so far and plans to buy more as we set up more SOAP servers. Martin Taylor ---------------------------------------------------------------------------- -- From: pywebsvcs-talk-admin at lists.sourceforge.net [mailto:pywebsvcs-talk-admin at lists.sourceforge.net] On Behalf Of Paul Weimer Sent: Monday, September 26, 2005 11:29 AM To: pywebsvcs-talk at lists.sourceforge.net; python-win32 at python.org Subject: [Pywebsvcs-talk] Using SOAPpy Within a Windows NT service I have a web service written in SOAPpy that is working fine; it is currently run from a batch file as a scheduled task on a WIndows server. My support folks would like it to be run as an NT service. I have been able to write NT service in Python before but I'm not having much luck interupting the SOAP server when it's waiting for reaquests. Any ideas? Paul Weimer -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050927/8366c5e8/attachment.htm From mhammond at skippinet.com.au Tue Sep 27 00:45:12 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 27 Sep 2005 08:45:12 +1000 Subject: [python-win32] Using SOAPpy Within a Windows NT service In-Reply-To: Message-ID: oops - reading my mail in the reverse order :) Generally a program like this will spawn a new thread to run the "real" (ie, SOAP) server in. The services main thread then simply waits for a shutdown request from Windows, and asks the server to shut down. As it is in another thread, it can sleep for 5 seconds or so to give it the chance, then just finish anyway (effectively killing the thread). [Note that this also implies you can *skip* the 'attempt to shutdown soap' part, and just have the server be killed as the service goes down - it works, and I suspect is what other solutions would do] The trick then is to find how to shut down the server itself. As I don't know SOAPpy I can't offer specific advice. A common problem in this scenario is that the server will be blocked on a 'select' call - so even if a "stop" flag has been set, the server will not see it until select returns. A common way around this is for the service shutdown itself set the flag, then to make a local connection to the server - just enough to wake the select so the server can see it is being asked to shut down. Alternatively, that select() call may have a timeout associated with it - in that case, you could simply wait the timeout period (plus a bit) before killing the server. Mark -----Original Message----- From: python-win32-bounces+mhammond=keypoint.com.au at python.org [mailto:python-win32-bounces+mhammond=keypoint.com.au at python.org]On Behalf Of Paul Weimer Sent: Tuesday, September 27, 2005 2:29 AM To: pywebsvcs-talk at lists.sourceforge.net; python-win32 at python.org Subject: [python-win32] Using SOAPpy Within a Windows NT service I have a web service written in SOAPpy that is working fine; it is currently run from a batch file as a scheduled task on a WIndows server. My support folks would like it to be run as an NT service. I have been able to write NT service in Python before but I'm not having much luck interupting the SOAP server when it's waiting for reaquests. Any ideas? Paul Weimer From eunjoo1984 at gmail.com Tue Sep 27 01:50:31 2005 From: eunjoo1984 at gmail.com (eunjoo1984@gmail.com) Date: Tue, 27 Sep 2005 08:50:31 +0900 Subject: [python-win32] explorer clone Message-ID: <43388947.10207@gmail.com> Hi! I'm trying to make an explorer clone using python-win32.(not the tree. just the folderview on the right side.) I know that I have to use the IShellFolder&IShellView, but don't know how to. Could someone show me an example. or is there anyone that has already done it? Thank you for any kind of help. Billy. From mhammond at skippinet.com.au Tue Sep 27 03:57:00 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 27 Sep 2005 11:57:00 +1000 Subject: [python-win32] explorer clone In-Reply-To: <43388947.10207@gmail.com> Message-ID: > I'm trying to make an explorer clone using python-win32.(not the tree. > just the folderview on the right side.) > I know that I have to use the IShellFolder&IShellView, but don't know > how to. If you are writing a clone and are only interested in the file system, there would be no need to use the shell interfaces at all - you could similate most of it in pure-python. If you wanted to use the shell interfaces so that you see everything explorer does, you would only need to use IShellFolder. IShellView is only used if you want to provide your own view *inside* explorer. If you were hoping to reuse the Explorer IShellView implementations inside your own application, I think you would have a battle on your hands. Here is some code that vaguely demonstrates how to use IShellFolder (which I also just checked into the win32comext\shell\demos directory) # A little sample that walks from the desktop into child # items. from win32com.shell import shell, shellcon def walk(folder, depth=2, indent=""): try: pidls = folder.EnumObjects(0, shellcon.SHCONTF_FOLDERS) except shell.error: # no items return for pidl in pidls: dn = folder.GetDisplayNameOf(pidl, shellcon.SHGDN_NORMAL) print indent, dn if depth: try: child = folder.BindToObject(pidl, None, shell.IID_IShellFolder) except shell.error: pass else: walk(child, depth-1, indent+" ") walk(shell.SHGetDesktopFolder()) Mark From upadhyay at gmail.com Tue Sep 27 14:38:06 2005 From: upadhyay at gmail.com (Amit Upadhyay) Date: Tue, 27 Sep 2005 18:08:06 +0530 Subject: [python-win32] Using SOAPpy Within a Windows NT service In-Reply-To: References: Message-ID: <349edb3805092705382b08e91d@mail.gmail.com> On 9/26/05, Paul Weimer wrote: > > I have a web service written in SOAPpy that is working fine; it is > currently run from a batch file as a scheduled task on a WIndows server. My > support folks would like it to be run as an NT service. I have been able to > write NT service in Python before but I'm not having much luck interupting > the SOAP server when it's waiting for reaquests. Any ideas? > Are you using SOAPpy.Server.SOAPServer or SOAPpy.Server.ThreadingSOAPServer? If former, you can follow the recepie http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/425210 and subclass SOAPpy.Server.SOAPServer to give you a quit() method. You can also take some hints from http://nerdierthanthou.nfshost.com/soap.txt [some description here ], and bypass SOAPpy's servers and use it as a marshaller only, using StoppableHTTPServer from recipe. -- Amit Upadhyay Blog: http://www.rootshell.be/~upadhyay +91-9867-359-701 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050927/b37a6910/attachment.html From timr at probo.com Tue Sep 27 20:11:38 2005 From: timr at probo.com (Tim Roberts) Date: Tue, 27 Sep 2005 11:11:38 -0700 Subject: [python-win32] testMSOffice.py and Excel 2003 In-Reply-To: References: Message-ID: <43398B5A.9090907@probo.com> On Fri, 23 Sep 2005 09:23:18 -0400, "Cavanagh, Mike" wrote: >Thanks for the reply, the test case now passes. > >However, our internal application is still failing. > >code snippet: > >import win32com >import win32com.client.dynamic >import pythoncom >from pywintypes import Unicode >from win32com.client import gencache > >xl = win32com.client.dynamic.Dispatch("Excel.Application") >xl.Visible = 1 >xlBook = xl.Workbooks.Open('C:\\test.xls') >xlSheet = xlBook.Worksheets(1) >print xlSheet.Name >xlSheet.Cells(1,1).Value = "Hello World" >print xlSheet.Cells(1,1).Value > >lastCol = 14 >lastRow = xlSheet.Cells.Find('Hello World',xlSheet.Cells(1, 1), 1, 1).Row >data = xlSheet.Range(xlSheet.Cells(1,1), >xlSheet.Cells(lastRow,lastCol)).Value > >xl.Workbooks(1).Close(SaveChanges = 1) >xl.Quit() > >/snippet > >When this is run, I receive the following error: > >Traceback (most recent call last): > File "", line 1, in ? > File "c:\python24\lib\site-packages\win32com\test\testExcel.py", line 16, >in ? > > lastRow = xlSheet.Cells.Find('Hello World',xlSheet.Cells(1, 1), 1, >1).Row > File >"c:\python24\lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-00 >0000000046x0x1x5\Range.py", line 197, in Find > , MatchCase, MatchByte, SearchFormat) >pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, >None, > 0, -2147352565), None) > >I believe this error is coming from Excel, but I am not sure why. > > -2148352565 is 0x8002000B, which is DISP_E_BADINDEX. The problem is the third parameter in your call to Find. This is the "LookIn" parameter, which tells it whether to search formulas, values, or comments. 1 is not a legal value for this parameter. It needs to be either xlFormulas (-4123) or xlValues (-4163). You should probably use symbolic constants instead of integers. Instead of using dynamic.Dispatch, if you say this: from win32com.client import gencache, constants xl = gencache.EnsureDisplatch("Excel.Application") now you can say this: lastRow = xlSheet.Cells.Find('Hello World', xlSheet.Cells(1, 1), constants.xlFormulas, constants.xlWhole ).Row and your code runs. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From michael.drumheller at boeing.com Wed Sep 28 22:03:58 2005 From: michael.drumheller at boeing.com (Drumheller, Michael) Date: Wed, 28 Sep 2005 13:03:58 -0700 Subject: [python-win32] Typelib usage Message-ID: <716621DCB4468F46BBCC1BCFBED45C120129D6B0@XCH-NW-2V2.nw.nos.boeing.com> It seems that if you have a typelib for a pythoncom server, you do not need to list the exposed methods in _public_methods_. It is enough that they just appear in the typelib. True? From fred.dixon at gmail.com Fri Sep 30 05:37:20 2005 From: fred.dixon at gmail.com (fred dixon) Date: Fri, 30 Sep 2005 03:37:20 +0000 (UTC) Subject: [python-win32] Getting tired with py2exe References: <4330DCC3.6090409@biocede.com> Message-ID: Garth Johnson biocede.com> writes: > > Steve Holden wrote: > > >Ignoring all the philosophical questions I'd like to thank you for all > >your hard work on py2exe over the years, which has benefited the Windows > >Python community immeasurably. > > > >regards > > Steve > > > > > here here! I have just begun my trek into Python and am already relying > upon Py2Exe for my projects. Thank you for an effective, well designed > tool that is easy to use. It was one of the final deciding factors in > our company's choice of languages. (not the least of which was the ease > of which our dev team took to Python after pretzling with perl). I do > hope you change your mind. > > Garth > Garth pretty much summed up my feelings as well. I never would have started to learn python with out the option of py2exe, now i love it and would HATE to have to go back to some lesser language. IMHO. so thank you as well From steve at holdenweb.com Fri Sep 30 09:25:54 2005 From: steve at holdenweb.com (Steve Holden) Date: Fri, 30 Sep 2005 08:25:54 +0100 Subject: [python-win32] Getting tired with py2exe In-Reply-To: References: <4330DCC3.6090409@biocede.com> Message-ID: <433CE882.8000406@holdenweb.com> fred dixon wrote: > Garth Johnson biocede.com> writes: > > >>Steve Holden wrote: >> >> >>>Ignoring all the philosophical questions I'd like to thank you for all >>>your hard work on py2exe over the years, which has benefited the Windows >>>Python community immeasurably. >>> >>>regards >>> Steve >>> >>> >> >>here here! I have just begun my trek into Python and am already relying >>upon Py2Exe for my projects. Thank you for an effective, well designed >>tool that is easy to use. It was one of the final deciding factors in >>our company's choice of languages. (not the least of which was the ease >>of which our dev team took to Python after pretzling with perl). I do >>hope you change your mind. >> >>Garth >> > > > > Garth pretty much summed up my feelings as well. > I never would have started to learn python with out the option of py2exe, > now i love it and would HATE to have to go back to some lesser language. IMHO. > so thank you as well > Well, it's all very well singing Thomas' praises, but what's really needed here is someone who'll maintain the code base! I would urge the hordes of py2exe users to consider if they couldn't give up a little time to keep the software in shape now Thomas no longer has the time. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ From michael.drumheller at boeing.com Fri Sep 30 17:14:22 2005 From: michael.drumheller at boeing.com (Drumheller, Michael) Date: Fri, 30 Sep 2005 08:14:22 -0700 Subject: [python-win32] Getting tired with py2exe Message-ID: <716621DCB4468F46BBCC1BCFBED45C120129D6BC@XCH-NW-2V2.nw.nos.boeing.com> Speaking of "hordes": Are there any numbers available on the size of py2exe's user base? md -------------------------------- Well, it's all very well singing Thomas' praises, but what's really needed here is someone who'll maintain the code base! I would urge the hordes of py2exe users to consider if they couldn't give up a little time to keep the software in shape now Thomas no longer has the time. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From davidf at sjsoft.com Fri Sep 30 17:36:34 2005 From: davidf at sjsoft.com (David Fraser) Date: Fri, 30 Sep 2005 17:36:34 +0200 Subject: [python-win32] Getting tired with py2exe In-Reply-To: <433CE882.8000406@holdenweb.com> References: <4330DCC3.6090409@biocede.com> <433CE882.8000406@holdenweb.com> Message-ID: <433D5B82.9020000@sjsoft.com> Steve Holden wrote: >fred dixon wrote: > > >>Garth Johnson biocede.com> writes: >> >> >> >> >>>Steve Holden wrote: >>> >>> >>> >>> >>>>Ignoring all the philosophical questions I'd like to thank you for all >>>>your hard work on py2exe over the years, which has benefited the Windows >>>>Python community immeasurably. >>>> >>>>regards >>>>Steve >>>> >>>> >>>> >>>> >>>here here! I have just begun my trek into Python and am already relying >>>upon Py2Exe for my projects. Thank you for an effective, well designed >>>tool that is easy to use. It was one of the final deciding factors in >>>our company's choice of languages. (not the least of which was the ease >>>of which our dev team took to Python after pretzling with perl). I do >>>hope you change your mind. >>> >>>Garth >>> >>> >>> >> >>Garth pretty much summed up my feelings as well. >>I never would have started to learn python with out the option of py2exe, >> now i love it and would HATE to have to go back to some lesser language. IMHO. >>so thank you as well >> >> >> >Well, it's all very well singing Thomas' praises, but what's really >needed here is someone who'll maintain the code base! I would urge the >hordes of py2exe users to consider if they couldn't give up a little >time to keep the software in shape now Thomas no longer has the time. > >regards > Steve > > I've been watching similar things in other projects ... The nice thing about open source is that you don't have to have somebody taking over straight away ... I suspect that what will happen is somebody will want to do something new with the code some time, or fix a number of bugs, and at that point they will volunteer... David