From tmay at infoinplace.net Tue Jul 1 22:23:02 2008 From: tmay at infoinplace.net (Tony May) Date: Tue, 1 Jul 2008 16:23:02 -0400 Subject: [python-win32] wrapping classes Message-ID: <418cd5740807011323s4a62bc4bo8c9dbeeb80898b23@mail.gmail.com> I get the following error message when trying to build a modified helloworld tutorial. I'm trying to import a class. code in hello.cpp includes -------------------------------------------------- class GreetBase { public: GreetBase(std::string txt) : txt(txt) {} std::string txt; virtual const char * greet() { return "hi"; } }; BOOST_PYTHON_MODULE(hello_ext) { using namespace boost::python; class_("GreetBase") .def("greet", &GreetBase::greet) ; } ----------------------------- running bjam results in: hello.cpp(46) : error C2976: 'boost::python::class_' : too few template argument s C:\Program Files\boost\boost_1_35_0\boost/python/def_visitor.hpp(14) : s ee declaration of 'boost::python::class_' hello.cpp(46) : error C2440: '' : cannot convert from 'cons t char [10]' to 'boost::python::class_' Source or target has incomplete type hello.cpp(46) : error C2228: left of '.def' must have class/struct/union -------------------- Another problem I have is that when I try to run from a python script the dll doesn't even load(the tests from the jamroot script pass though): C:\Program Files\boost\boost_1_35_0\libs\python\example\tutorial>python hello.p Traceback (most recent call last): File "hello.py", line 6, in import hello_ext ImportError: DLL load failed: This application has failed to start because the pplication configuration is incorrect. Reinstalling the application may fix thi problem. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jsacksteder at gmail.com Wed Jul 2 16:56:12 2008 From: jsacksteder at gmail.com (jeff sacksteder) Date: Wed, 2 Jul 2008 10:56:12 -0400 Subject: [python-win32] Implementing Collections / Shim-ing Word Message-ID: <51c8a7be0807020756y6e63a80bra6c7bd076a62c18c@mail.gmail.com> I have a legacy application that uses Word as printing engine for standardized forms via COM. I'm trying to develop a thin COM server shim that implements the minimum required to intercept those requests and routes them to another application(likely OOo). I had hoped that the free Word doc viewer implemented a COM server, but no luck. To do this I need to create a public 'Documents' collection, which I'm not able to do. The app produces an error saying: Error Code: Member not found Subsystem: OLE Automation Client Error Subcode: 1 Function: DOCUMENTS Description: Member not Found (I take that to actually mean a member, not a true function in the 4th line) The important part of the server is: class OOoShim: _public_methods_ = [] _public_attrs_ = ['Documents'] _reg_progid_ = 'Word.Application.8' _reg_clsid_ = '{E313D9AC-DE79-4587-971F-A054829819D6}' Documents = NewCollection([]) I've tried 'Documents' as an attribute and as a function returning a collection. This looks like a manageable problem, but I'm stuck on creating these Collections. From timr at probo.com Wed Jul 2 19:03:59 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 02 Jul 2008 10:03:59 -0700 Subject: [python-win32] Implementing Collections / Shim-ing Word In-Reply-To: <51c8a7be0807020756y6e63a80bra6c7bd076a62c18c@mail.gmail.com> References: <51c8a7be0807020756y6e63a80bra6c7bd076a62c18c@mail.gmail.com> Message-ID: <486BB4FF.3080406@probo.com> jeff sacksteder wrote: > I have a legacy application that uses Word as printing engine for > standardized forms via COM. I'm trying to develop a thin COM server > shim that implements the minimum required to intercept those requests > and routes them to another application(likely OOo). I had hoped that > the free Word doc viewer implemented a COM server, but no luck. > > To do this I need to create a public 'Documents' collection, which I'm > not able to do. The app produces an error saying: > > Error Code: Member not found > Subsystem: OLE Automation Client > Error Subcode: 1 > Function: DOCUMENTS > Description: Member not Found > > (I take that to actually mean a member, not a true function in the 4th line) > Well, COM objects don't have members (externally). Everything is a function. Did you try spelling your attribute like the error: DOCUMENTS? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Jul 2 23:31:39 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 02 Jul 2008 14:31:39 -0700 Subject: [python-win32] Implementing Collections / Shim-ing Word In-Reply-To: <51c8a7be0807021404k379ecb69tf7d942b7ee65ea04@mail.gmail.com> References: <51c8a7be0807020756y6e63a80bra6c7bd076a62c18c@mail.gmail.com> <486BB4FF.3080406@probo.com> <51c8a7be0807021404k379ecb69tf7d942b7ee65ea04@mail.gmail.com> Message-ID: <486BF3BB.4000505@probo.com> jeff sacksteder wrote: >> Well, COM objects don't have members (externally). Everything is a >> function. >> > > If everything is a function, what's _public_attrs_ for? > I suppose it's really a matter of semantics more than a useful distinction. _public_attrs_ creates what COM calls a "property", which are actually implemented as as two special functions called get_Xxx and put_Xxx (for a property called Xxx). Languages that have the notion of a property usually hide this from you, calling the functions behind your back. A COM interface is a pure virtual C++ class, which means it can consist of nothing but function pointers. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Thu Jul 3 01:21:47 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 3 Jul 2008 09:21:47 +1000 Subject: [python-win32] Implementing Collections / Shim-ing Word In-Reply-To: <51c8a7be0807020756y6e63a80bra6c7bd076a62c18c@mail.gmail.com> References: <51c8a7be0807020756y6e63a80bra6c7bd076a62c18c@mail.gmail.com> Message-ID: <027b01c8dc9a$698cd250$3ca676f0$@com.au> Attributes will need to be in an instance of the class, not the class itself (the instance's __dict__ is used). Also, yu probably want to read up on registering your classes with "--debugging" so you can see tracebacks and other details of the implementation. Cheers, Mark > -----Original Message----- > From: python-win32-bounces at python.org [mailto:python-win32- > bounces at python.org] On Behalf Of jeff sacksteder > Sent: Thursday, 3 July 2008 12:56 AM > To: python-win32 at python.org > Subject: [python-win32] Implementing Collections / Shim-ing Word > > I have a legacy application that uses Word as printing engine for > standardized forms via COM. I'm trying to develop a thin COM server > shim that implements the minimum required to intercept those requests > and routes them to another application(likely OOo). I had hoped that > the free Word doc viewer implemented a COM server, but no luck. > > To do this I need to create a public 'Documents' collection, which I'm > not able to do. The app produces an error saying: > > Error Code: Member not found > Subsystem: OLE Automation Client > Error Subcode: 1 > Function: DOCUMENTS > Description: Member not Found > > (I take that to actually mean a member, not a true function in the 4th > line) > > The important part of the server is: > > class OOoShim: > _public_methods_ = [] > _public_attrs_ = ['Documents'] > _reg_progid_ = 'Word.Application.8' > _reg_clsid_ = '{E313D9AC-DE79-4587-971F-A054829819D6}' > > Documents = NewCollection([]) > > I've tried 'Documents' as an attribute and as a function returning a > collection. This looks like a manageable problem, but I'm stuck on > creating these Collections. > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From le.dahut at laposte.net Wed Jul 2 16:50:05 2008 From: le.dahut at laposte.net (le dahut) Date: Wed, 02 Jul 2008 16:50:05 +0200 Subject: [python-win32] Netbios api Message-ID: <486B959D.7020601@laposte.net> Hello, I'm looking for APIs to do some stuff like 'nbtstat' does. Does have any starting point ? Actually it is to force the resolving of the PDC name via his IP address to avoid messages like : "Domain is unavailable" if user logs on to fast after computer boot. It seems that windows need some time to "find" the network which may explain it. For experts, it is a Samba 3.0 PDC with WINS Server activated and correctly configured on the client (wins server). Thanks, K. From mc at mclaveau.com Thu Jul 3 16:54:14 2008 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 3 Jul 2008 16:54:14 +0200 Subject: [python-win32] Netbios api In-Reply-To: <486B959D.7020601@laposte.net> References: <486B959D.7020601@laposte.net> Message-ID: Bonjour ! Lorsque Windows d?marre, les adaptateurs r?seau (cartes) (et aussi les composants logiciels) sont initialis?s parmi les derniers ?l?ments. Or, tant que cette initialisation n'est pas faite, impossible de se connecter ? un r?seau. Il faut donc, avant de lancer un script de connexion, attendre que tout soit initialis?. @-salutations -- Michel Claveau PS : ce n'est pas un probl?me Python. From siddhartha.veedaluru at gmail.com Fri Jul 4 07:01:29 2008 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Fri, 4 Jul 2008 10:31:29 +0530 Subject: [python-win32] Get Blank Lines in a text file Message-ID: <424b71ec0807032201o74f3d767meaf0509c358f03b5@mail.gmail.com> Hi, As part of a task i need to verify that last line of a text file is blank. When i read that file, its getting ignored and i couldn't able to check that. Here is the code snippet that i used: import os iniFileName = "Config.ini" iniFile = open(iniFileName, 'r') lines = iniFile.readlines() noOfLines = len(lines) if lines[noOfLines] == "": print "Last line is blank" else: print "Last line is not blank" regards, Siddhartha -------------- next part -------------- An HTML attachment was scrubbed... URL: From ferdinandsousa at gmail.com Fri Jul 4 12:35:45 2008 From: ferdinandsousa at gmail.com (Ferdinand Sousa) Date: Fri, 4 Jul 2008 16:05:45 +0530 Subject: [python-win32] Fwd: Running a python script in the system tray In-Reply-To: References: Message-ID: Hi I just wanted some pointers on how I can run a python script in the system tray. My configuration is: Win Xp Python 2.5.1 Python Imaging Library 1.1.6 pywin 2.1.1 I already have a screen captor (python script) that pastes images from the windows clipboard. Its disadvantage is that for every screenshot I take, I have to: 1) press Print Screen 2) run the script Also, is there a way I can capture keyboard events? What I want to achieve is: 1) run the script 2) select a shortcut key, say Ctrl+key/Alt+key/Shift+key/Function keys etc 3) minimise the script to the system tray 4) capture screenshots Apologies for asking so many questions, and thanks for taking the trouble to read! Ferdi From sjmachin at lexicon.net Fri Jul 4 12:59:18 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 04 Jul 2008 20:59:18 +1000 Subject: [python-win32] Get Blank Lines in a text file In-Reply-To: <424b71ec0807032201o74f3d767meaf0509c358f03b5@mail.gmail.com> References: <424b71ec0807032201o74f3d767meaf0509c358f03b5@mail.gmail.com> Message-ID: <486E0286.3020201@lexicon.net> siddhartha veedaluru wrote: > Hi, Your problem is nothing to do with Windows at all; a better target would have been the comp.lang.python newsgroup or the python-list at python.org mailing list [but NOT both; messages are gatewayed both ways]. > > As part of a task i need to verify that last line of a text file is blank. > When i read that file, its getting ignored and i couldn't able to check > that. > Here is the code snippet that i used: > > import os You don't use "os" ... > iniFileName = "Config.ini" > iniFile = open(iniFileName, 'r') > lines = iniFile.readlines() > noOfLines = len(lines) > if lines[noOfLines] == "": You say "its getting ignored"; I say it should raise an IndexError exception (see below). When asking about a problem, always show the exact code that you ran, and any output (including any traceback and error message). >>> lines = ['a\n', 'b\n', '\n'] >>> n = len(lines) >>> lines[n] Traceback (most recent call last): File "", line 1, in IndexError: list index out of range >>> n 3 >>> lines[2] '\n' >>> lines[-1] '\n' >>> You can access the last line as lines[-1] (see above). Now we need to think about what you mean by "blank". The last line in a file will usually end with '\n' but may not. That's problem 1. Problem 2 is that it may contain spaces, tabs, and/or (rarely) other forms of whitespace. So testing against only "" is not a good idea. You can cover all those bases by using the strip method. Oh and you'd better test that you do have a last line. Putting it all together: DEBUG = True if not lines: print "No lines" else: if DEBUG: # If you can't understand what's happening in your program, # do some debugging! print "Last line is", repr(lines[-1]) if lines[-1].strip(): print "Last line is NOT blank" # Note: I changed the order else: print "Last line is blank" Hope this helps, John From p.f.moore at gmail.com Fri Jul 4 12:59:36 2008 From: p.f.moore at gmail.com (Paul Moore) Date: Fri, 4 Jul 2008 11:59:36 +0100 Subject: [python-win32] Running Python + pywin32 portably Message-ID: <79990c6b0807040359p6f723cb9p2347146c5b04d4e8@mail.gmail.com> Is it possible to run Python and pywin32 portably (ie, in a configuration I can copy from one machine to another without rble with Pytstaller)? I know it's possible with Python - but does pywin32 "work" if the postinstall hasn't been run? Specifically, I don't care about embedding Python, or about creating COM servers or services, but I do want to be able to run "normal" Python scripts and COM clients. I could try it and see, but I don't currently have access to a machine which hasn't got Python+Pywin32 installed :-) Thanks, Paul. From fuzzyman at voidspace.org.uk Fri Jul 4 14:16:36 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 04 Jul 2008 13:16:36 +0100 Subject: [python-win32] Running Python + pywin32 portably In-Reply-To: <79990c6b0807040359p6f723cb9p2347146c5b04d4e8@mail.gmail.com> References: <79990c6b0807040359p6f723cb9p2347146c5b04d4e8@mail.gmail.com> Message-ID: <486E14A4.7040603@voidspace.org.uk> Paul Moore wrote: > Is it possible to run Python and pywin32 portably (ie, in a > configuration I can copy from one machine to another without rble with > Pytstaller)? > > I know it's possible with Python - but does pywin32 "work" if the > postinstall hasn't been run? Specifically, I don't care about > embedding Python, or about creating COM servers or services, but I do > want to be able to run "normal" Python scripts and COM clients. > > I could try it and see, but I don't currently have access to a machine > which hasn't got Python+Pywin32 installed :-) > Movable Python comes with the Pywin32 extensions. http://www.voidspace.org.uk/python/movpy/ Michael Foord > Thanks, > Paul. > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/ http://www.trypython.org/ http://www.ironpython.info/ http://www.resolverhacks.net/ http://www.theotherdelia.co.uk/ From p.f.moore at gmail.com Fri Jul 4 14:43:33 2008 From: p.f.moore at gmail.com (Paul Moore) Date: Fri, 4 Jul 2008 13:43:33 +0100 Subject: [python-win32] Running Python + pywin32 portably In-Reply-To: <486E14A4.7040603@voidspace.org.uk> References: <79990c6b0807040359p6f723cb9p2347146c5b04d4e8@mail.gmail.com> <486E14A4.7040603@voidspace.org.uk> Message-ID: <79990c6b0807040543g1bd12902oebdc6237728e09b1@mail.gmail.com> On 04/07/2008, Michael Foord wrote: > Movable Python comes with the Pywin32 extensions. > > http://www.voidspace.org.uk/python/movpy/ Thanks. Does that mean that out of the box pywin32 works portably, or were changes needed for Movable Python? (I don't want to use Movable Python itself, for reasons that aren't really relevant here). Paul. From fuzzyman at voidspace.org.uk Fri Jul 4 14:44:08 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 04 Jul 2008 13:44:08 +0100 Subject: [python-win32] Running Python + pywin32 portably In-Reply-To: <79990c6b0807040543g1bd12902oebdc6237728e09b1@mail.gmail.com> References: <79990c6b0807040359p6f723cb9p2347146c5b04d4e8@mail.gmail.com> <486E14A4.7040603@voidspace.org.uk> <79990c6b0807040543g1bd12902oebdc6237728e09b1@mail.gmail.com> Message-ID: <486E1B18.9070400@voidspace.org.uk> Paul Moore wrote: > On 04/07/2008, Michael Foord wrote: > >> Movable Python comes with the Pywin32 extensions. >> >> http://www.voidspace.org.uk/python/movpy/ >> > > Thanks. Does that mean that out of the box pywin32 works portably, or > were changes needed for Movable Python? (I don't want to use Movable > Python itself, for reasons that aren't really relevant here). > > Paul. > I can't remember the precise hacks I needed to make. I think that was more to do with getting it to work with py2exe rather than anything to do with being portable. It is certainly worth *trying* portably and seeing what problems you encounter - I *Suspect* they will be minimal. Michael Foord -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/ http://www.trypython.org/ http://www.ironpython.info/ http://www.resolverhacks.net/ http://www.theotherdelia.co.uk/ From p.f.moore at gmail.com Fri Jul 4 14:49:17 2008 From: p.f.moore at gmail.com (Paul Moore) Date: Fri, 4 Jul 2008 13:49:17 +0100 Subject: [python-win32] Running Python + pywin32 portably In-Reply-To: <486E1B18.9070400@voidspace.org.uk> References: <79990c6b0807040359p6f723cb9p2347146c5b04d4e8@mail.gmail.com> <486E14A4.7040603@voidspace.org.uk> <79990c6b0807040543g1bd12902oebdc6237728e09b1@mail.gmail.com> <486E1B18.9070400@voidspace.org.uk> Message-ID: <79990c6b0807040549i1f758631uc0175d0688667770@mail.gmail.com> On 04/07/2008, Michael Foord wrote: > It is certainly worth *trying* portably and seeing what problems you > encounter - I *Suspect* they will be minimal. That's a fair point. I'll see if I can set up a virtual machine with no Python installed, and give it a go. Paul. From malaclypse2 at gmail.com Fri Jul 4 23:09:41 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Fri, 4 Jul 2008 17:09:41 -0400 Subject: [python-win32] Fwd: Running a python script in the system tray In-Reply-To: References: Message-ID: <16651e80807041409q4ed3984o3cf6098fca006f63@mail.gmail.com> On Fri, Jul 4, 2008 at 6:35 AM, Ferdinand Sousa wrote: > Also, is there a way I can capture keyboard events? Tim Golden has an article showing how to register with windows to receive hotkey notifications: http://tgolden.sc.sabren.com/python/win32_how_do_i/catch_system_wide_hotkeys.html I'm not sure about minimizing to the system tray. I know you can do that with the various windowing toolkits, like wxpython, but I'm not sure how to do it without those. -- Jerry From mhammond at skippinet.com.au Sat Jul 5 02:00:14 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 5 Jul 2008 10:00:14 +1000 Subject: [python-win32] Running Python + pywin32 portably In-Reply-To: <79990c6b0807040359p6f723cb9p2347146c5b04d4e8@mail.gmail.com> References: <79990c6b0807040359p6f723cb9p2347146c5b04d4e8@mail.gmail.com> Message-ID: <045e01c8de32$1cdaede0$5690c9a0$@com.au> > I know it's possible with Python - but does pywin32 "work" if the > postinstall hasn't been run? Specifically, I don't care about > embedding Python, or about creating COM servers or services, but I do > want to be able to run "normal" Python scripts and COM clients. In the simple case, it works fine without the post_install script execute, and so long as no embedding is attempted. Cheers, Mark From mhammond at skippinet.com.au Sat Jul 5 02:00:14 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 5 Jul 2008 10:00:14 +1000 Subject: [python-win32] Fwd: Running a python script in the system tray In-Reply-To: References: Message-ID: <045f01c8de32$21a14f90$64e3eeb0$@com.au> > I just wanted some pointers on how I can run a python script in the > system tray. See win32\demos\win32gui_taskbar.py in the pythonwin distro. Cheers, Mark. From p.f.moore at gmail.com Sat Jul 5 13:13:13 2008 From: p.f.moore at gmail.com (Paul Moore) Date: Sat, 5 Jul 2008 12:13:13 +0100 Subject: [python-win32] Running Python + pywin32 portably In-Reply-To: <045e01c8de32$1cdaede0$5690c9a0$@com.au> References: <79990c6b0807040359p6f723cb9p2347146c5b04d4e8@mail.gmail.com> <045e01c8de32$1cdaede0$5690c9a0$@com.au> Message-ID: <79990c6b0807050413r278d1dc5t1b7405cc867fa4db@mail.gmail.com> 2008/7/5 Mark Hammond : >> I know it's possible with Python - but does pywin32 "work" if the >> postinstall hasn't been run? Specifically, I don't care about >> embedding Python, or about creating COM servers or services, but I do >> want to be able to run "normal" Python scripts and COM clients. > > In the simple case, it works fine without the post_install script execute, > and so long as no embedding is attempted. Excellent, thanks for the confirmation. (Oh, and the fact that I find it so hard to locate a machine *without* pywin32 installed is a testament to how useful it is, so thanks for all the work you put into developing it!!!) Paul. From teekaysoh at gmail.com Sun Jul 6 05:18:45 2008 From: teekaysoh at gmail.com (TK Soh) Date: Sun, 6 Jul 2008 03:18:45 +0000 Subject: [python-win32] killing overlay extensions Message-ID: <58b84f8e0807052018s16a5855fi67ce40f7cefee07b@mail.gmail.com> I'd like to know what's the 'proper' way to stop a pythonwin's overlay shell extension from kicking in. I've not been able find much documentation on this, particularly the return values of GetOverlayInfo() function. Based on sample that I've found, the GetOverlayInfo() function returns a tuple of (icon_path, 0, shellcon.ISIOI_ICONFILE), and it's not clear to me what the '0' is representing. So far my way to 'kill' the extension is either to raise an exception in, or return None from, GetOverlayInfo(). Though it seemed to work fine so far, I am not sure if this will create and ill effect down the road. I'd really appreciate if anyone can share some experience on this. Thanks. From timr at probo.com Sun Jul 6 08:00:38 2008 From: timr at probo.com (Tim Roberts) Date: Sat, 5 Jul 2008 23:00:38 -0700 Subject: [python-win32] killing overlay extensions Message-ID: <200807060600.m6660c227856@probo.probo.com> You wrote: > >... Based on sample that I've found, the >GetOverlayInfo() function returns a tuple of (icon_path, 0, >shellcon.ISIOI_ICONFILE), and it's not clear to me what the '0' is >representing. Icon files can contain multiple icons. The 0 is the ordinal of the icon that should be used -- the first one, in this case. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Mon Jul 7 09:14:08 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 7 Jul 2008 10:14:08 +0300 Subject: [python-win32] killing overlay extensions In-Reply-To: <58b84f8e0807052018s16a5855fi67ce40f7cefee07b@mail.gmail.com> References: <58b84f8e0807052018s16a5855fi67ce40f7cefee07b@mail.gmail.com> Message-ID: <000601c8e001$2482f350$6d88d9f0$@com.au> > I'd like to know what's the 'proper' way to stop a pythonwin's overlay > shell extension from kicking in. I've not been able find much > documentation on this, particularly the return values of > GetOverlayInfo() function. Based on sample that I've found, the > GetOverlayInfo() function returns a tuple of (icon_path, 0, > shellcon.ISIOI_ICONFILE), and it's not clear to me what the '0' is > representing. > > So far my way to 'kill' the extension is either to raise an exception > in, or return None from, GetOverlayInfo(). Though it seemed to work > fine so far, I am not sure if this will create and ill effect down the > road. I'd really appreciate if anyone can share some experience on > this. Thanks. Tim answered one of your questions, but I don't quite understand the other one. The correct way is simply to remove the shell extension and restart any programs which may have used it. COM doesn't define a way to "stop" an object or anything similar at all - what will work will depend on the implementation of the code using the object - in this example, of explorer.exe. If you want something specific to your app, then your shell extension code could check some kind of flag/event/whatever and then refuse to do anything - but that isn't "killing" it. BTW, have you been tracking the shell extension code for bzr? It shouldn't be that far from being VCS agnostic and a first cut has been released and pushed (I'm assuming you are still playing with shell extensions for mercurial :) Cheers, Mark From mail at timgolden.me.uk Mon Jul 7 13:03:29 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 07 Jul 2008 12:03:29 +0100 Subject: [python-win32] killing overlay extensions In-Reply-To: <58b84f8e0807052018s16a5855fi67ce40f7cefee07b@mail.gmail.com> References: <58b84f8e0807052018s16a5855fi67ce40f7cefee07b@mail.gmail.com> Message-ID: <4871F801.40203@timgolden.me.uk> TK Soh wrote: > I'd like to know what's the 'proper' way to stop a pythonwin's overlay > shell extension from kicking in. I've not been able find much > documentation on this, particularly the return values of > GetOverlayInfo() function. Based on sample that I've found, the > GetOverlayInfo() function returns a tuple of (icon_path, 0, > shellcon.ISIOI_ICONFILE), and it's not clear to me what the '0' is > representing. On the basis of the following assumptions: 1) You have a shell overlay extension which handles some icons. 2) You want to have it *not* handle certain icons. I think you want to look at the IsMemberOf function of the IShellOverlayInfo interface. If this returns S_FALSE or E_FAIL (the latter, I think) then the GetOverlayInfo shouldn't even be called. In essence, an overlay handler ought to return "No" from this function as fast as it can since it will get called by Windows for every single icon. TJG From tmay at infoinplace.net Mon Jul 7 17:10:33 2008 From: tmay at infoinplace.net (Tony May) Date: Mon, 7 Jul 2008 11:10:33 -0400 Subject: [python-win32] MSVC ++ and Boost libraries Message-ID: <418cd5740807070810x38c697c6lfa8f06440ac7f8dd@mail.gmail.com> Is it possible to use the pre-built binaries with MSVC++ 2005 express edition? I get the following error from bjam when attempting to build the pyd from the source file hello.cpp. ----------------------------------------------------- hello.cpp has the following code trying to wrap a class BOOST_PYTHON_MODULE(hello_ext) { class_("GreetBase") # line 50 .def("greet", &GreetBase::greet) ; } -------------------------------------------- hello.cpp(50) : error C2976: 'boost::python::class_' : too few template arguments C:\Program Files\boost\boost_1_35_0\boost/python/def_visitor.hpp(14) : see declaration of 'boost::python::class_' hello.cpp(50) : error C2440: '' : cannot convert from 'const char [10]' to 'boost::python::class_' Source or target has incomplete type hello.cpp(50) : error C2228: left of '.def' must have class/struct/union ------------------------------------------------ Do I need to rebuild the boost libraries? Would this be expected to fix the problem? -------------- next part -------------- An HTML attachment was scrubbed... URL: From kirk at pacificmindworks.com Mon Jul 7 17:38:22 2008 From: kirk at pacificmindworks.com (Kirk Fertitta) Date: Mon, 7 Jul 2008 08:38:22 -0700 Subject: [python-win32] Python and IUnknown-based COM objects Message-ID: <169D58390A1DD64C89617976E4ED70231F7A506869@EXVMBX003-2.exch003intermedia.net> I am trying to use a COM component that does not support the IDispatch interface. It has only early-bound IUnknown derived interfaces in it. The folks at ActiveState directed me to this list for some assistance. It seems from some of the documentation I've come across that Python can make early-bound function calls, but it seems that all of the creation mechanisms perform a QueryInterface for IDispatch (which, of course, will always fail for our COM components). Does anyone have any idea on if/how Python can be used with non-IDispatch COM components? Any advice is very much appreciated. Thanks in advance. -kirk Kirk Fertitta Chief Technical Officer Pacific MindWorks, Inc. www.pacificmindworks.com ph: 858-587-8876 x237 fax: 858-587-8907 -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Mon Jul 7 18:14:08 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 07 Jul 2008 17:14:08 +0100 Subject: [python-win32] Python and IUnknown-based COM objects In-Reply-To: <169D58390A1DD64C89617976E4ED70231F7A506869@EXVMBX003-2.exch003intermedia.net> References: <169D58390A1DD64C89617976E4ED70231F7A506869@EXVMBX003-2.exch003intermedia.net> Message-ID: <487240D0.9080106@timgolden.me.uk> Kirk Fertitta wrote: > I am trying to use a COM component that does not support the IDispatch > interface. It has only early-bound IUnknown derived interfaces in it. > The folks at ActiveState directed me to this list for some assistance. > It seems from some of the documentation I?ve come across that Python can > make early-bound function calls, but it seems that all of the creation > mechanisms perform a QueryInterface for IDispatch (which, of course, > will always fail for our COM components). Does anyone have any idea on > if/how Python can be used with non-IDispatch COM components? Any advice > is very much appreciated. The short answer is: you want comtypes. I recommend getting the svn trunk http://starship.python.net/crew/theller/comtypes/ The longer answer is that there *is* support for non-IDispatch interfaces in pywin32, but it's more-or-less the raison d'etre for comtypes (whose principal architect Thomas Heller is still away on holiday, I think), while it's one thing among many in pywin32 which is notoriously underdocumented and more complex in any case. TJG From kirk at pacificmindworks.com Mon Jul 7 18:19:04 2008 From: kirk at pacificmindworks.com (Kirk Fertitta) Date: Mon, 7 Jul 2008 09:19:04 -0700 Subject: [python-win32] Python and IUnknown-based COM objects In-Reply-To: <487240D0.9080106@timgolden.me.uk> References: <169D58390A1DD64C89617976E4ED70231F7A506869@EXVMBX003-2.exch003intermedia.net> <487240D0.9080106@timgolden.me.uk> Message-ID: <169D58390A1DD64C89617976E4ED70231F7A5068C8@EXVMBX003-2.exch003intermedia.net> Hi Tim, Thanks for your prompt and helpful reply. I'll have a look at comtypes and maybe wait for Thomas Heller to return if I struggle. Thanks again. -kirk Kirk Fertitta Chief Technical Officer Pacific MindWorks, Inc. www.pacificmindworks.com ph: 858-587-8876 x237 fax: 858-587-8907 -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Golden Sent: Monday, July 07, 2008 9:14 AM Cc: python-win32 at python.org Subject: Re: [python-win32] Python and IUnknown-based COM objects Kirk Fertitta wrote: > I am trying to use a COM component that does not support the IDispatch > interface. It has only early-bound IUnknown derived interfaces in it. > The folks at ActiveState directed me to this list for some assistance. > It seems from some of the documentation I've come across that Python can > make early-bound function calls, but it seems that all of the creation > mechanisms perform a QueryInterface for IDispatch (which, of course, > will always fail for our COM components). Does anyone have any idea on > if/how Python can be used with non-IDispatch COM components? Any advice > is very much appreciated. The short answer is: you want comtypes. I recommend getting the svn trunk http://starship.python.net/crew/theller/comtypes/ The longer answer is that there *is* support for non-IDispatch interfaces in pywin32, but it's more-or-less the raison d'etre for comtypes (whose principal architect Thomas Heller is still away on holiday, I think), while it's one thing among many in pywin32 which is notoriously underdocumented and more complex in any case. TJG _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From teekaysoh at gmail.com Tue Jul 8 01:15:27 2008 From: teekaysoh at gmail.com (TK Soh) Date: Mon, 7 Jul 2008 23:15:27 +0000 Subject: [python-win32] killing overlay extensions In-Reply-To: <000601c8e001$2482f350$6d88d9f0$@com.au> References: <58b84f8e0807052018s16a5855fi67ce40f7cefee07b@mail.gmail.com> <000601c8e001$2482f350$6d88d9f0$@com.au> Message-ID: <58b84f8e0807071615v6155bfacv8f2ac00d8f39ea7f@mail.gmail.com> On Mon, Jul 7, 2008 at 7:14 AM, Mark Hammond wrote: >> I'd like to know what's the 'proper' way to stop a pythonwin's overlay >> shell extension from kicking in. I've not been able find much >> documentation on this, particularly the return values of >> GetOverlayInfo() function. Based on sample that I've found, the >> GetOverlayInfo() function returns a tuple of (icon_path, 0, >> shellcon.ISIOI_ICONFILE), and it's not clear to me what the '0' is >> representing. >> >> So far my way to 'kill' the extension is either to raise an exception >> in, or return None from, GetOverlayInfo(). Though it seemed to work >> fine so far, I am not sure if this will create and ill effect down the >> road. I'd really appreciate if anyone can share some experience on >> this. Thanks. > > Tim answered one of your questions, but I don't quite understand the other > one. > > The correct way is simply to remove the shell extension and restart any > programs which may have used it. COM doesn't define a way to "stop" an > object or anything similar at all - what will work will depend on the > implementation of the code using the object - in this example, of > explorer.exe. I am trying to provide a way for user to [totally] disable the overlay extension, and enable them later if they want, without having to go through the pain to remove the shell extension from windows registry. > If you want something specific to your app, then your shell extension code > could check some kind of flag/event/whatever and then refuse to do anything > - but that isn't "killing" it. I am doing that already, but unfortunately that's still slow Explorer noticeably. > BTW, have you been tracking the shell extension code for bzr? It shouldn't > be that far from being VCS agnostic and a first cut has been released and > pushed (I'm assuming you are still playing with shell extensions for > mercurial :) I am afraid I haven't. When can I find the new shell extension code for bzr? BTW, is it written in VC? From teekaysoh at gmail.com Tue Jul 8 01:21:11 2008 From: teekaysoh at gmail.com (TK Soh) Date: Mon, 7 Jul 2008 23:21:11 +0000 Subject: [python-win32] killing overlay extensions In-Reply-To: <4871F801.40203@timgolden.me.uk> References: <58b84f8e0807052018s16a5855fi67ce40f7cefee07b@mail.gmail.com> <4871F801.40203@timgolden.me.uk> Message-ID: <58b84f8e0807071621m28bb764cla28323ecbdb2ebc2@mail.gmail.com> On Mon, Jul 7, 2008 at 11:03 AM, Tim Golden wrote: > TK Soh wrote: >> >> I'd like to know what's the 'proper' way to stop a pythonwin's overlay >> shell extension from kicking in. I've not been able find much >> documentation on this, particularly the return values of >> GetOverlayInfo() function. Based on sample that I've found, the >> GetOverlayInfo() function returns a tuple of (icon_path, 0, >> shellcon.ISIOI_ICONFILE), and it's not clear to me what the '0' is >> representing. > > On the basis of the following assumptions: > > 1) You have a shell overlay extension which handles some icons. > 2) You want to have it *not* handle certain icons. > > > I think you want to look at the IsMemberOf function of the > IShellOverlayInfo interface. If this returns S_FALSE or E_FAIL > (the latter, I think) then the GetOverlayInfo shouldn't even be > called. In essence, an overlay handler ought to return "No" > from this function as fast as it can since it will get called by > Windows for every single icon. The debugging trace suggests that IsMemberOf are called after GetOverlayInfo, which itself is called when Explorer starts up. In any case, as I said in my reply to Mark, Explorer slows down noticeably just by having the extensions turned on, i.e, calling the IsMemberOf function. Probably due to the overhead within pythonwin COM mechanism. From marcus at internetnowasp.net Tue Jul 8 05:53:04 2008 From: marcus at internetnowasp.net (Marcus Low) Date: Tue, 08 Jul 2008 11:53:04 +0800 Subject: [python-win32] strange crashed on calling loaded shared Library in windows Message-ID: <4872E4A0.2010109@internetnowasp.net> I have this shared library that is loaded via : vr = ctypes.CDLL("varcfunction.dll") When i ran it thru main : if __name__ == "__main__" : str = "aaaaa" LR = vr.DoIt(str) print "results %d" %(LR) It works perfectly fine and the return result was correct. I could loop it 1000 times without any problem However when the same code is placed into a thread : def _test_thread (count, *args) : str = "aaaaa" LR = vr.DoIt(str) print "results %d" %(LR) It bombs out on the first try with :- WindowsError: exception: access violation reading 0x00000064 Any ideas as to what might be wrong here? From marcus at internetnowasp.net Tue Jul 8 06:00:29 2008 From: marcus at internetnowasp.net (Marcus Low) Date: Tue, 08 Jul 2008 12:00:29 +0800 Subject: [python-win32] strange crashed on calling loaded shared Library in windows In-Reply-To: <4872E4A0.2010109@internetnowasp.net> References: <4872E4A0.2010109@internetnowasp.net> Message-ID: <4872E65D.60804@internetnowasp.net> One more thing, maybe that is the cause, the vr = ctypes.CDLL was called by a different thread then the one using it in the 2nd scenario. Hmm...could this be the problem. Marcus Low wrote: > I have this shared library that is loaded via : > > vr = ctypes.CDLL("varcfunction.dll") > > When i ran it thru main : > > if __name__ == "__main__" : > str = "aaaaa" > LR = vr.DoIt(str) > print "results %d" %(LR) > > It works perfectly fine and the return result was correct. I could > loop it 1000 times without any problem > However when the same code is placed into a thread : > > def _test_thread (count, *args) : str = "aaaaa" > LR = vr.DoIt(str) > print "results %d" %(LR) > > It bombs out on the first try with :- > WindowsError: exception: access violation reading 0x00000064 > > Any ideas as to what might be wrong here? > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From marcus at internetnowasp.net Tue Jul 8 06:58:08 2008 From: marcus at internetnowasp.net (Marcus Low) Date: Tue, 08 Jul 2008 12:58:08 +0800 Subject: [python-win32] ctypes question DLL Message-ID: <4872F3E0.9030709@internetnowasp.net> Hi, I have been reading the documentation on ctypes and the 2.5 python on ctypes when it comes to loading libraries. But surprisingly, or maybe i miss it somewhere, but How do you unload the loaded dll? For eg : dllfunc = ctypes.CDLL("mylib.dll") Later if i want to replace this dll without stopping the python program and reload the dll, how can this be done? From mhammond at skippinet.com.au Tue Jul 8 09:08:07 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 8 Jul 2008 10:08:07 +0300 Subject: [python-win32] killing overlay extensions In-Reply-To: <58b84f8e0807071615v6155bfacv8f2ac00d8f39ea7f@mail.gmail.com> References: <58b84f8e0807052018s16a5855fi67ce40f7cefee07b@mail.gmail.com> <000601c8e001$2482f350$6d88d9f0$@com.au> <58b84f8e0807071615v6155bfacv8f2ac00d8f39ea7f@mail.gmail.com> Message-ID: <00ba01c8e0c9$7022db40$506891c0$@com.au> > I am trying to provide a way for user to [totally] disable the overlay > extension, and enable them later if they want, without having to go > through the pain to remove the shell extension from windows registry. Why is removal from the registry a pain? > > If you want something specific to your app, then your shell extension > code > > could check some kind of flag/event/whatever and then refuse to do > anything > > - but that isn't "killing" it. > > I am doing that already, but unfortunately that's still slow Explorer > noticeably. That is strange - do you think that is simply the overhead of calling Python functions? [apols to the list for the following, which is really getting off topic for python-win32] > > > BTW, have you been tracking the shell extension code for bzr? It > shouldn't > > be that far from being VCS agnostic and a first cut has been released > and > > pushed (I'm assuming you are still playing with shell extensions for > > mercurial :) > > I am afraid I haven't. When can I find the new shell extension code > for bzr? It is a launchpad branch at https://code.launchpad.net/~tortoisebzr-developers/tortoisebzr/tbzr2-proto - note it is still very early though. > BTW, is it written in VC? Not yet, but all VCS work is done by the remote process. In other words, we are very close to being able to throw away the .py version of the shell itself and replace it with a dumb VC version. However, it is likely we will not attempt to do that until a little later - once we have more functionality in place - so that we have a complete picture of what the C++ code must do... Cheers, Mark From mhammond at skippinet.com.au Tue Jul 8 09:29:06 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 8 Jul 2008 10:29:06 +0300 Subject: [python-win32] killing overlay extensions In-Reply-To: <58b84f8e0807071621m28bb764cla28323ecbdb2ebc2@mail.gmail.com> References: <58b84f8e0807052018s16a5855fi67ce40f7cefee07b@mail.gmail.com> <4871F801.40203@timgolden.me.uk> <58b84f8e0807071621m28bb764cla28323ecbdb2ebc2@mail.gmail.com> Message-ID: <00c601c8e0cc$71f85730$55e90590$@com.au> > The debugging trace suggests that IsMemberOf are called after > GetOverlayInfo, which itself is called when Explorer starts up. That is correct - GetOverlayInfo is called just once per process IIUC. Having this function fail should prevent your IsMemberOf being called - but once it has been successfully called, you are in the same position you are now. > In any case, as I said in my reply to Mark, Explorer slows down > noticeably just by having the extensions turned on, i.e, calling the > IsMemberOf function. Probably due to the overhead within pythonwin COM > mechanism. That would surprise me, as the overhead should not be much at all - a lock acquisition, creation of a tuple for the args, getattr for the function and a few calls. No IDispatch is involved here, so there isn't much magic at all. For most folders, you can expect one call per file - which typically will only be in the dozens of files. So if the overhead of doing nothing is too great, I can't see how the extension could do much work at all. In other words, I'd be quite surprised if the overhead of a Python implementation that does nothing is more than the (say) C++ TSVN overhead when it is actually talking to subversion, stating files on disk, parsing the 'entries' file, etc. TSVN uses locks quite liberally too, etc.... Maybe we need to measure this overhead somehow? There are probably some optimizations we can make in some cases too - eg, caching the function objects rather than looking them up each call, etc, but as implied above, I'd be very surprised to see that make a measurable difference unless the number of calls is truly huge and the real work being done by the function is close to zero. Cheers, Mark From mail at timgolden.me.uk Tue Jul 8 10:24:04 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 08 Jul 2008 09:24:04 +0100 Subject: [python-win32] killing overlay extensions In-Reply-To: <00c601c8e0cc$71f85730$55e90590$@com.au> References: <58b84f8e0807052018s16a5855fi67ce40f7cefee07b@mail.gmail.com> <4871F801.40203@timgolden.me.uk> <58b84f8e0807071621m28bb764cla28323ecbdb2ebc2@mail.gmail.com> <00c601c8e0cc$71f85730$55e90590$@com.au> Message-ID: <48732424.2090202@timgolden.me.uk> Mark Hammond wrote: > >> The debugging trace suggests that IsMemberOf are called after >> GetOverlayInfo, which itself is called when Explorer starts up. > > That is correct - GetOverlayInfo is called just once per process IIUC. > Having this function fail should prevent your IsMemberOf being called - but > once it has been successfully called, you are in the same position you are > now. Sorry. Both of you are quite right, of course. I'd forgotten that each overlay handler only handles one icon overlay. I must say, the design of this particular extension from the Windows point of view makes for relatively inefficient handlers. Every overlay handler is called for every icon, and it's up to each handler to return "No" as fast as it can if it's not interested. Would be useful if you could establish a handler on a per-filetype basis (with the usual fallback of the * to handle all types). Although that obviously wouldn't help on things like svn/hg which have to stat around a bit and look at their context to establish applicability. Tk Soh - do you find, even if the IsMemberOf does nothing but return its "No" value, that Explorer still slows down? TJG From mail at timgolden.me.uk Tue Jul 8 11:41:17 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 08 Jul 2008 10:41:17 +0100 Subject: [python-win32] ctypes question DLL In-Reply-To: <4872F3E0.9030709@internetnowasp.net> References: <4872F3E0.9030709@internetnowasp.net> Message-ID: <4873363D.7080204@timgolden.me.uk> Marcus Low wrote: > Hi, > I have been reading the documentation on ctypes and the 2.5 python on > ctypes when it comes to loading libraries. > > But surprisingly, or maybe i miss it somewhere, but How do you unload > the loaded dll? > > For eg : dllfunc = ctypes.CDLL("mylib.dll") > > Later if i want to replace this dll without stopping the python program > and reload the dll, how can this be done? I imagine this isn't such a common requirement, because the FreeLibrary function is present in _ctypes but isn't exposed via ctypes. import ctypes import _ctypes dllfunc = ctypes.CDLL("mylib.dll") _ctypes.FreeLibrary (dllfunc._handle) TJG From colichia at gmail.com Tue Jul 8 19:31:00 2008 From: colichia at gmail.com (aaron) Date: Tue, 8 Jul 2008 12:31:00 -0500 Subject: [python-win32] IE & DocumentComplete Message-ID: <20080708123100.5a828879@ulx-0.m6300.net> Sorry if this is a repeat, but the information on the web regarding DocumentComplete and IE is not helping me find a solution. I read a 2000 thread that documentcomplete was 'broken'.. is this still the case? If not, does anyone mind sending me a snippet of some working code where it's used? I feel like I'm running in circles here. Using the Busy and readyState attributes are proving to be a waste of time without long pausing to make sure the content is actually loaded. Thanks, A From rwupole at msn.com Tue Jul 8 20:24:15 2008 From: rwupole at msn.com (Roger Upole) Date: Tue, 8 Jul 2008 14:24:15 -0400 Subject: [python-win32] re: IE & DocumentComplete Message-ID: aaron wrote: > Sorry if this is a repeat, but the information on the web regarding > DocumentComplete and IE is not helping me find a solution. > > I read a 2000 thread that documentcomplete was 'broken'.. is this still > the case? If not, does anyone mind sending me a snippet of some > working code where it's used? I feel like I'm running in circles here. > > Using the Busy and readyState attributes are proving to be a waste of > time without long pausing to make sure the content is actually > loaded. > > Thanks, > > A As far as I know, it works in any recent build. import pythoncom import win32com.client defaultNamedNotOptArg=pythoncom.Missing class ieevents: def OnNavigateComplete2(self, pDisp=defaultNamedNotOptArg, URL=defaultNamedNotOptArg): print 'OnNavigateComplete2', URL def OnDocumentComplete(self, pDisp=defaultNamedNotOptArg, URL=defaultNamedNotOptArg): print 'OnDocumentComplete', URL, pDisp==self._oleobj_ ie=win32com.client.DispatchWithEvents('internetexplorer.application', ieevents) ie.Visible=1 ie.Navigate('http://sourceforge.net/projects/pywin32/') Roger From teekaysoh at gmail.com Wed Jul 9 06:32:17 2008 From: teekaysoh at gmail.com (TK Soh) Date: Wed, 9 Jul 2008 04:32:17 +0000 Subject: [python-win32] killing overlay extensions In-Reply-To: <00ba01c8e0c9$7022db40$506891c0$@com.au> References: <58b84f8e0807052018s16a5855fi67ce40f7cefee07b@mail.gmail.com> <000601c8e001$2482f350$6d88d9f0$@com.au> <58b84f8e0807071615v6155bfacv8f2ac00d8f39ea7f@mail.gmail.com> <00ba01c8e0c9$7022db40$506891c0$@com.au> Message-ID: <58b84f8e0807082132g1a32859fkd8913b40530e8bd0@mail.gmail.com> On Tue, Jul 8, 2008 at 7:08 AM, Mark Hammond wrote: >> I am trying to provide a way for user to [totally] disable the overlay >> extension, and enable them later if they want, without having to go >> through the pain to remove the shell extension from windows registry. > > Why is removal from the registry a pain? Technically, probably not so much. But right now overlay extension read the config file to enable/disable the extension. It simplifies my work if I am allow to 'kill' the extension that way. >> > If you want something specific to your app, then your shell extension >> code >> > could check some kind of flag/event/whatever and then refuse to do >> anything >> > - but that isn't "killing" it. >> >> I am doing that already, but unfortunately that's still slow Explorer >> noticeably. > > That is strange - do you think that is simply the overhead of calling Python functions? > > [apols to the list for the following, which is really getting off topic for python-win32] I think this discuss might interest others on win32. >> >> > BTW, have you been tracking the shell extension code for bzr? It >> shouldn't >> > be that far from being VCS agnostic and a first cut has been released >> and >> > pushed (I'm assuming you are still playing with shell extensions for >> > mercurial :) >> >> I am afraid I haven't. When can I find the new shell extension code >> for bzr? > > It is a launchpad branch at https://code.launchpad.net/~tortoisebzr-developers/tortoisebzr/tbzr2-proto - note it is still very early though. I will try take a look if I can download it. BTW, can I browse this bzr repo with a web browser? >> BTW, is it written in VC? > > Not yet, but all VCS work is done by the remote process. In other words, we are very close to being able to throw away the .py version of the shell itself and replace it with a dumb VC version. However, it is likely we will not attempt to do that until a little later - once we have more functionality in place - so that we have a complete picture of what the C++ code must do... > FYI, I have actually completed the a simple prototype with overlay extension, written C++, that retrieve Mercurial file status from remote process through a named pipe. Is really a prove-of-concept trial based on your proposal earlier. From teekaysoh at gmail.com Wed Jul 9 06:47:07 2008 From: teekaysoh at gmail.com (TK Soh) Date: Wed, 9 Jul 2008 04:47:07 +0000 Subject: [python-win32] killing overlay extensions In-Reply-To: <48732424.2090202@timgolden.me.uk> References: <58b84f8e0807052018s16a5855fi67ce40f7cefee07b@mail.gmail.com> <4871F801.40203@timgolden.me.uk> <58b84f8e0807071621m28bb764cla28323ecbdb2ebc2@mail.gmail.com> <00c601c8e0cc$71f85730$55e90590$@com.au> <48732424.2090202@timgolden.me.uk> Message-ID: <58b84f8e0807082147s1faee8cbwa58c9a5a906b29a9@mail.gmail.com> On Tue, Jul 8, 2008 at 8:24 AM, Tim Golden wrote: > Mark Hammond wrote: >> >> >>> >>> The debugging trace suggests that IsMemberOf are called after >>> GetOverlayInfo, which itself is called when Explorer starts up. >> >> That is correct - GetOverlayInfo is called just once per process IIUC. >> Having this function fail should prevent your IsMemberOf being called - >> but >> once it has been successfully called, you are in the same position you are >> now. > > Sorry. Both of you are quite right, of course. I'd forgotten that each > overlay handler only handles one icon overlay. It's indeed quite confusing ;-) > I must say, the design of this particular extension from the Windows > point of view makes for relatively inefficient handlers. Every overlay > handler is called for every icon, and it's up to each handler to return "No" > as fast as it can if it's not interested. Would be useful if you could > establish a handler on a per-filetype basis (with the usual fallback of > the * to handle all types). Although that obviously wouldn't help on > things like svn/hg which have to stat around a bit and look at their context > to establish applicability. That's true. > Tk Soh - do you find, even if the IsMemberOf does nothing > but return its "No" value, that Explorer still slows down? Please see my reply to Mark on this. From teekaysoh at gmail.com Wed Jul 9 06:50:39 2008 From: teekaysoh at gmail.com (TK Soh) Date: Wed, 9 Jul 2008 04:50:39 +0000 Subject: [python-win32] killing overlay extensions In-Reply-To: <00c601c8e0cc$71f85730$55e90590$@com.au> References: <58b84f8e0807052018s16a5855fi67ce40f7cefee07b@mail.gmail.com> <4871F801.40203@timgolden.me.uk> <58b84f8e0807071621m28bb764cla28323ecbdb2ebc2@mail.gmail.com> <00c601c8e0cc$71f85730$55e90590$@com.au> Message-ID: <58b84f8e0807082150x690e6c18s6211d67d4759508b@mail.gmail.com> On Tue, Jul 8, 2008 at 7:29 AM, Mark Hammond wrote: > >> The debugging trace suggests that IsMemberOf are called after >> GetOverlayInfo, which itself is called when Explorer starts up. > > That is correct - GetOverlayInfo is called just once per process IIUC. > Having this function fail should prevent your IsMemberOf being called - but > once it has been successfully called, you are in the same position you are > now. > >> In any case, as I said in my reply to Mark, Explorer slows down >> noticeably just by having the extensions turned on, i.e, calling the >> IsMemberOf function. Probably due to the overhead within pythonwin COM >> mechanism. > > That would surprise me, as the overhead should not be much at all - a lock > acquisition, creation of a tuple for the args, getattr for the function and > a few calls. No IDispatch is involved here, so there isn't much magic at > all. For most folders, you can expect one call per file - which typically > will only be in the dozens of files. > > So if the overhead of doing nothing is too great, I can't see how the > extension could do much work at all. In other words, I'd be quite surprised > if the overhead of a Python implementation that does nothing is more than > the (say) C++ TSVN overhead when it is actually talking to subversion, > stating files on disk, parsing the 'entries' file, etc. TSVN uses locks > quite liberally too, etc.... > > Maybe we need to measure this overhead somehow? There are probably some > optimizations we can make in some cases too - eg, caching the function > objects rather than looking them up each call, etc, but as implied above, > I'd be very surprised to see that make a measurable difference unless the > number of calls is truly huge and the real work being done by the function > is close to zero. I think I should revise my claim. Following Tim's advice, I just tried it again, and somehow the slowdown seemed much less obvious now. I am quite certain this used to be a problem at some point of time in the past. However, one thing has changed in the last few days though, that I'm now using build 211 you just released. Though I am not sure if it would have any impact on the topic we are discussing. FYI, earlier I was using the build 210.5 you created specially, and build 210 before that. If necessary, I can try again with the older builds to confirm the slowdown, but I wonder if it's really worth the effort, especially given the much limited time I get to spend on this. I am guessing we'd be okay as long as I using the 211 or the newer builds. In any case, we are definitely going move towards shell extension in C++, as we need to do this to address other issues that are not immediately solvable with current python/pywin32 implementation. I will keep the list posted if anything comes up in the future. Thank you all for the comment and feedback. From tmay at infoinplace.net Wed Jul 9 20:12:48 2008 From: tmay at infoinplace.net (Tony May) Date: Wed, 9 Jul 2008 14:12:48 -0400 Subject: [python-win32] Problem with destructor being declared protected. Message-ID: <418cd5740807091112y210b32aawb9f25be8857ede20@mail.gmail.com> I am trying to build a helloworld program using bjam so that it can be imported into a python script. I get an error message that mentions a problem with the destructor being declared protected. Has anyone noticed this problem when building with Boost and Delta3D? C:\Program Files\boost\boost_1_35_0\boost/python/object/value_holder.hpp(67) : warning C4624: 'boost::python::objects::value_holder' : destructor could not be generated because a base class destructor is inaccessible I didn't get this error when building with the ide. -------------- next part -------------- An HTML attachment was scrubbed... URL: From singhai.nish at gmail.com Thu Jul 10 07:49:20 2008 From: singhai.nish at gmail.com (kNish) Date: Thu, 10 Jul 2008 11:19:20 +0530 Subject: [python-win32] error in list length Message-ID: <81bfef2e0807092249q429ac3denf86fea06c211631b@mail.gmail.com> Hi, The following lines of code gives an error starting with line where len() is used local_BkFiles = glob.glob(localDirectoryName+'\\*' + data + '*bk*') local_BkFiles.sort(key=str.upper) last_pv_File_Name = local_PvFiles[len(local_PvFiles)-1] split_last_pv_File_Name = re.search(data+"_bk[0-9]{2}_[a-z]{3}_pv[0-9]{2}",last_pv_File_Name ) lastPv_FileVersion = re.search('(?<=pv)\d+',split_last_pv_File_Name.group(0)) This code is being called in a procedure or function def. How may I solve this. BRgds, kNish -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Thu Jul 10 12:10:22 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 10 Jul 2008 11:10:22 +0100 Subject: [python-win32] error in list length In-Reply-To: <81bfef2e0807092249q429ac3denf86fea06c211631b@mail.gmail.com> References: <81bfef2e0807092249q429ac3denf86fea06c211631b@mail.gmail.com> Message-ID: <4875E00E.8030803@timgolden.me.uk> kNish wrote: > The following lines of code gives an error starting with > line where len() is used [... snip code for the moment ...] META-ADVICE: kNish, when you're posting a question, please, please, post post the traceback you got. Cut-and-paste it from the console window into the email. > > local_BkFiles = glob.glob(localDirectoryName+'\\*' + > data + '*bk*') > local_BkFiles.sort(key=str.upper) > last_pv_File_Name = local_PvFiles[len(local_PvFiles)-1] > split_last_pv_File_Name = > re.search(data+"_bk[0-9]{2}_[a-z]{3}_pv[0-9]{2}",last_pv_File_Name ) > lastPv_FileVersion = > re.search('(?<=pv)\d+',split_last_pv_File_Name.group(0)) I'm not going to try to decode the re, but I can point out a few things: + You might want to look into os.path.join for the glob line, altho' what you've got seems all right. + To get the last item in a list L (or the last nth item) you can use L[-1] (or L[-n]). What problem are you trying to solve here? TJG From larry.bates at websafe.com Thu Jul 10 18:13:02 2008 From: larry.bates at websafe.com (Larry Bates) Date: Thu, 10 Jul 2008 11:13:02 -0500 Subject: [python-win32] error in list length In-Reply-To: <81bfef2e0807092249q429ac3denf86fea06c211631b@mail.gmail.com> References: <81bfef2e0807092249q429ac3denf86fea06c211631b@mail.gmail.com> Message-ID: kNish wrote: > Hi, > > The following lines of code gives an error starting with > line where len() is used > > > local_BkFiles = glob.glob(localDirectoryName+'\\*' + > data + '*bk*') > local_BkFiles.sort(key=str.upper) > last_pv_File_Name = local_PvFiles[len(local_PvFiles)-1] > split_last_pv_File_Name = > re.search(data+"_bk[0-9]{2}_[a-z]{3}_pv[0-9]{2}",last_pv_File_Name ) > lastPv_FileVersion = > re.search('(?<=pv)\d+',split_last_pv_File_Name.group(0)) > > > This code is being called in a procedure or function def. How may I > solve this. > > > BRgds, > > > kNish > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 Since you didn't post your full traceback (you should always do that in the future), we are guessing: local_PvFiles isn't defined prior to trying to determine its length. The way to get the last element of a list is: local_PvFiles[-1] you don't need to do all the length gymnastics. I'm no regex expert, so I'll leave that part to someone else but if the filenames are a fixed format, you don't need regex at all to extract the version. If it is a completely variable format, then you would. -Larry From venturasalvatore at yahoo.it Fri Jul 11 03:42:03 2008 From: venturasalvatore at yahoo.it (salvatore ventura) Date: Fri, 11 Jul 2008 01:42:03 +0000 (GMT) Subject: [python-win32] How to get IWebBrowser2 from a HWND Message-ID: <721931.14511.qm@web25608.mail.ukl.yahoo.com> Hi, I am trying to get the IWebBrowser2 object from the HWND of an open IE window. I have seen this topic covered in many languages, and I am following the same steps, but in python, yet I am hitting a wall that I can't figure how to break... So, yes, I have been 'googling', browsing and testing many options, but without the desired result. So, here details about my python installation on WinXP: - python-2.5.2.msi - pywin32-210.win32-py2.5.exe - comtypes-0.4.2.win32.exe - ServProv.tlb --> used to generate the IServiceProvider wrappers Now, my scenario is IE7 already open on a webpage 'Page1', and a modal popup webpage 'Modal1', which is not a Messagebox/Alert. Once that is up, the following code is supposed to retrieve the IWebBrowser2 object of the 'Modal1' window. (assume all the imports are done correctly) # get the window, and then reach the 'Internet Explorer_Server' win1 = win32gui.FindWindow('Internet Explorer_TridentDlgFrame', 'Modal1') win1 = winGuiAuto.findControl(win1, None, 'Internet Explorer_Server', None) # get ready to get the IHTMLDocument2 from win1 # # oleacc = oledll.LoadLibrary ( 'oleacc.dll' ) WM_HTML_GETOBJECT = windll.user32.RegisterWindowMessageA ('WM_HTML_GETOBJECT' ) lResult = c_ulong ( ) pIHTMLDocument2 = POINTER ( IHTMLDocument2 ) ( ) ret = windll.user32.SendMessageTimeoutA ( c_int ( win1 ), c_int (WM_HTML_GETOBJECT),c_int ( 0 ), c_int ( 0 ), c_int ( SMTO_ABORTIFHUNG ), c_int ( 1000 ), byref (lResult ) ) oleacc.ObjectFromLresult ( lResult, byref ( IHTMLDocument2._iid_ ), 0,byref (pIHTMLDocument2 ) ) # at this point pIHTMLDocument2 is at the right window, as the 'title' property gives me what I expect # now followup to get the parent ... ihtmlwin = pIHTMLDocument2.parentWindow # ... the service provider ... pIServiceProvider = ihtmlwin.QueryInterface(IServiceProvider, IServiceProvider._iid_) # ... and the IWebBrowser2: ie = pIServiceProvider.QueryService(IWebBrowserApp._iid_, IWebBrowser2._iid_) # which - of course - fails. Error returned: Traceback (most recent call last): File "", line 1, in COMError: (-2147467262, 'No such interface supported', (None, None, None, 0, None)) which would imply that I am in the wrong 'place'. But I can't see how. I must be doing something wrong, but can't figure what. Any help very much appreciated, and sorry for the long post. regards, .salvo ps. this a link to one of the places that describe the procedure i have followed: http://www.forum.it-berater.org/index.php?topic=574.msg1060#msg1060 From mhammond at skippinet.com.au Fri Jul 11 08:53:04 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 11 Jul 2008 09:53:04 +0300 Subject: [python-win32] How to get IWebBrowser2 from a HWND In-Reply-To: <721931.14511.qm@web25608.mail.ukl.yahoo.com> References: <721931.14511.qm@web25608.mail.ukl.yahoo.com> Message-ID: <008901c8e322$cc63b9a0$652b2ce0$@com.au> > # ... and the IWebBrowser2: > ie = pIServiceProvider.QueryService(IWebBrowserApp._iid_, > IWebBrowser2._iid_) > > # which - of course - fails. > > > Error returned: > Traceback (most recent call last): > File "", line 1, in > COMError: (-2147467262, 'No such interface supported', (None, None, > None, 0, None)) Its possible that you could specify IDispatch as the second IID, then wrap the resulting object using win32com.client.Dispatch() (or the equivalent using ctypes). Cheers, Mark From mail at timgolden.me.uk Fri Jul 11 12:27:13 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 11 Jul 2008 11:27:13 +0100 Subject: [python-win32] How to get IWebBrowser2 from a HWND In-Reply-To: <721931.14511.qm@web25608.mail.ukl.yahoo.com> References: <721931.14511.qm@web25608.mail.ukl.yahoo.com> Message-ID: <48773581.5050007@timgolden.me.uk> salvatore ventura wrote: > Hi, > I am trying to get the IWebBrowser2 object from the HWND of an open IE window. [... snip complex code ...] At the risk of oversimplifying matters (and thanks to Roger Upole for providing this snippet which I think I've linked to three times this week!): import win32com.client HWND = 0x00bd031e ShellWindows_guid = '{9BA05972-F6A8-11CF-A442-00A0C90A8F39}' for shell_window in win32com.client.Dispatch (ShellWindows_guid): if hasattr (shell_window, "HWND") and shell_window.HWND == HWND: web_browser = shell_window break else: web_browser = None if web_browser: print "browser at", web_browser.LocationURL else: print "Couldn't find browser at hwnd", HWND TJG From rasjidw at gmail.com Fri Jul 11 14:20:37 2008 From: rasjidw at gmail.com (Rasjid Wilcox) Date: Fri, 11 Jul 2008 22:20:37 +1000 Subject: [python-win32] ActiveX dll error - Non-modal forms cannot be displayed in this host application Message-ID: Hi, I have an ActiveX dll that I am trying to use in a Python script. I can dispatch the control, but when I try to runs its 'open' command, I get the following error: "Non-modal forms cannot be displayed in this host application from an ActiveX DLL, ActiveX Control, or Property Page." My googling seems to indicate that it is either something to do with threading model differences, or something to do with MsoStdCompMgr. Does anyone have any suggestions on how to get around this problem?? Cheers, Rasjid. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Fri Jul 11 15:22:01 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 11 Jul 2008 16:22:01 +0300 Subject: [python-win32] ActiveX dll error - Non-modal forms cannot be displayed in this host application In-Reply-To: References: Message-ID: <006901c8e359$1e4211a0$5ac634e0$@com.au> ActiveX DLLs in a raw python.exe program are tricky. I'm guessing you need to use the DLL in a true ActiveX host app - pythonwin is one (see the pywin\demos\ocx directory) and wxPython can also do it (but I'm not sure about how it is done there) Cheers, Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Rasjid Wilcox Sent: Friday, 11 July 2008 3:21 PM To: python-win32 at python.org Subject: [python-win32] ActiveX dll error - Non-modal forms cannot be displayed in this host application Hi, I have an ActiveX dll that I am trying to use in a Python script. I can dispatch the control, but when I try to runs its 'open' command, I get the following error: "Non-modal forms cannot be displayed in this host application from an ActiveX DLL, ActiveX Control, or Property Page." My googling seems to indicate that it is either something to do with threading model differences, or something to do with MsoStdCompMgr. Does anyone have any suggestions on how to get around this problem?? Cheers, Rasjid. -------------- next part -------------- An HTML attachment was scrubbed... URL: From shahmed at sfwmd.gov Fri Jul 11 15:36:15 2008 From: shahmed at sfwmd.gov (Ahmed, Shakir) Date: Fri, 11 Jul 2008 09:36:15 -0400 Subject: [python-win32] parsing outlook email In-Reply-To: <008901c8e322$cc63b9a0$652b2ce0$@com.au> References: <721931.14511.qm@web25608.mail.ukl.yahoo.com> <008901c8e322$cc63b9a0$652b2ce0$@com.au> Message-ID: Hi, I am working on a project where I need to parse incoming emails (Microsoft outlook 2003) with a specific subject into an excel file or a Microsoft access table. Any help is highly appreciated. Thanks sa From mail at timgolden.me.uk Fri Jul 11 16:24:30 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 11 Jul 2008 15:24:30 +0100 Subject: [python-win32] parsing outlook email In-Reply-To: References: <721931.14511.qm@web25608.mail.ukl.yahoo.com> <008901c8e322$cc63b9a0$652b2ce0$@com.au> Message-ID: <48776D1E.2050101@timgolden.me.uk> Ahmed, Shakir wrote: > Hi, > I am working on a project where I need to parse incoming emails > (Microsoft outlook 2003) with a specific subject into an excel file or a > > Microsoft access table. > > Any help is highly appreciated. You could create an Outlook Add-in. Have a look at the Spambayes codebase for ideas. [1] Or you could try using the Outlook event model externally. But it kept crashing when I tried it (and I admit I didn't try too hard). Or you could just have a long-running process which monitors incoming emails and does things with them. Which is what I do. Depends on what exactly you're trying to achieve and how slick it has to be. TJG [1] http://spambayes.sourceforge.net/windows.html From chester_lab at fltg.net Sat Jul 12 02:36:09 2008 From: chester_lab at fltg.net (FT) Date: Fri, 11 Jul 2008 20:36:09 -0400 Subject: [python-win32] Com and Sapi 4 speech engine, tts commands Message-ID: <001601c8e3b7$4b80c630$0501a8c0@brucetower> Hi! Has anyone here done any programming on the sapi 4.0A speech engine? I have the sapi 5 and the pytts engines and would like to use the sapi 4 because it has more voices. But found it difficult to find the commands for the connection to the engine since microsoft has gone to 5.3 and beyond. It would be nice to have the connection to get it started and I do have a working model, but it seems to say about 2 words then shut up. The when saying something else you have to create another instance, then wait until the second creation of it. I do not know what is going on and using some of the NVDA project in trying to get the sapi 4 to work, but I can not get beyond the problem I am having. I suspect that there something needed to keep the engine on. Bruce From jsacksteder at gmail.com Sat Jul 12 05:00:30 2008 From: jsacksteder at gmail.com (jeff sacksteder) Date: Fri, 11 Jul 2008 23:00:30 -0400 Subject: [python-win32] Implementing Collections / Shim-ing Word In-Reply-To: <027b01c8dc9a$698cd250$3ca676f0$@com.au> References: <51c8a7be0807020756y6e63a80bra6c7bd076a62c18c@mail.gmail.com> <027b01c8dc9a$698cd250$3ca676f0$@com.au> Message-ID: <51c8a7be0807112000u7bd6420and5cba1d77ae3023e@mail.gmail.com> With both the actual(MS Word) and simulated(my COM server) configurations, I am returned a generic COM object when trying to use the 'Documents' object. >>> w = Dispatch("Word.Application.8") >>> d = w.Documents >>> d > I think this relates to being late-bound. Anyway, whereas Word's 'Documents' collection has an Add() that creates a new document in the collection, my server has magically grown an Add() that requires 2 params, including an instance. >From previous discussion, my com server is shown here. class OOoShim: _public_methods_ = [] _public_attrs_ = ['Documents'] _reg_progid_ = 'Word.Application.8' _reg_clsid_ = '{E313D9AC-DE79-4587-971F-A054829819D6}' def __init__(self): self.Documents = NewCollection([]) If I can get an understanding of how these collections work on the Python side vs the COM side, I'll be make some progress. On Wed, Jul 2, 2008 at 7:21 PM, Mark Hammond wrote: > Attributes will need to be in an instance of the class, not the class itself > (the instance's __dict__ is used). Also, yu probably want to read up on > registering your classes with "--debugging" so you can see tracebacks and > other details of the implementation. > > Cheers, > > Mark > > >> -----Original Message----- >> From: python-win32-bounces at python.org [mailto:python-win32- >> bounces at python.org] On Behalf Of jeff sacksteder >> Sent: Thursday, 3 July 2008 12:56 AM >> To: python-win32 at python.org >> Subject: [python-win32] Implementing Collections / Shim-ing Word >> >> I have a legacy application that uses Word as printing engine for >> standardized forms via COM. I'm trying to develop a thin COM server >> shim that implements the minimum required to intercept those requests >> and routes them to another application(likely OOo). I had hoped that >> the free Word doc viewer implemented a COM server, but no luck. >> >> To do this I need to create a public 'Documents' collection, which I'm >> not able to do. The app produces an error saying: >> >> Error Code: Member not found >> Subsystem: OLE Automation Client >> Error Subcode: 1 >> Function: DOCUMENTS >> Description: Member not Found >> >> (I take that to actually mean a member, not a true function in the 4th >> line) >> >> The important part of the server is: >> >> class OOoShim: >> _public_methods_ = [] >> _public_attrs_ = ['Documents'] >> _reg_progid_ = 'Word.Application.8' >> _reg_clsid_ = '{E313D9AC-DE79-4587-971F-A054829819D6}' >> >> Documents = NewCollection([]) >> >> I've tried 'Documents' as an attribute and as a function returning a >> collection. This looks like a manageable problem, but I'm stuck on >> creating these Collections. From mc at mclaveau.com Sat Jul 12 07:30:04 2008 From: mc at mclaveau.com (Michel Claveau) Date: Sat, 12 Jul 2008 07:30:04 +0200 Subject: [python-win32] Com and Sapi 4 speech engine, tts commands In-Reply-To: <001601c8e3b7$4b80c630$0501a8c0@brucetower> References: <001601c8e3b7$4b80c630$0501a8c0@brucetower> Message-ID: Hi! Perso, I use MS-agents, and I choice an "empty" character. MS-agents are well knowed et well documented. Empty agent is invisible, but its voice is audible. A problem: on Vista, with non-english (french) voice, only English voices are available with Vista"standard", and we can download only very few French voices. @-salutations Michel Claveau From mhammond at skippinet.com.au Sat Jul 12 09:03:16 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 12 Jul 2008 10:03:16 +0300 Subject: [python-win32] Implementing Collections / Shim-ing Word In-Reply-To: <51c8a7be0807112000u7bd6420and5cba1d77ae3023e@mail.gmail.com> References: <51c8a7be0807020756y6e63a80bra6c7bd076a62c18c@mail.gmail.com> <027b01c8dc9a$698cd250$3ca676f0$@com.au> <51c8a7be0807112000u7bd6420and5cba1d77ae3023e@mail.gmail.com> Message-ID: <000001c8e3ed$5e227550$1a675ff0$@com.au> > With both the actual(MS Word) and simulated(my COM server) > configurations, I am returned a generic COM object when trying to use > the 'Documents' object. > > >>> w = Dispatch("Word.Application.8") > >>> d = w.Documents > >>> d > > > > I think this relates to being late-bound. Anyway, whereas Word's > 'Documents' collection has an Add() that creates a new document in the > collection, my server has magically grown an Add() that requires 2 > params, including an instance. > > >From previous discussion, my com server is shown here. > > class OOoShim: > _public_methods_ = [] > _public_attrs_ = ['Documents'] > _reg_progid_ = 'Word.Application.8' > _reg_clsid_ = '{E313D9AC-DE79-4587-971F-A054829819D6}' > > def __init__(self): > self.Documents = NewCollection([]) > > If I can get an understanding of how these collections work on the > Python side vs the COM side, I'll be make some progress. So what is you question? If it is asking why your Add method doesn't work as you expect, I'm afraid I lack the telepathic powers to mind-read your code. Mark From chester_lab at fltg.net Sat Jul 12 12:39:53 2008 From: chester_lab at fltg.net (FT) Date: Sat, 12 Jul 2008 06:39:53 -0400 Subject: [python-win32] Com and Sapi 4 speech engine, tts commands Message-ID: <000e01c8e40b$a2c853f0$0501a8c0@brucetower> Hi Michel, I am not sure what you are talking about. I suspect your referring to the Microsoft Sapi 5 stuff, are you? I am looking into the sapi 4 only for the extra voices. I do have a working Sapi 5 model but have not done a dictionary list for it unless I use the existing ones. My Sapi 5 only has 3 voices, Mary, Mike, and Sam where Vista has changed Sam to Anna. On the old Sapi 4 I noticed 28 voices, but the first 7 do not seem to work, Grandpa to Shelly I think, but 8 through to 28 where it is Mike in space, it works, but only for a few seconds, or cuts off pre-maturely. They say it is a little harder to work with but have not found much on what is going on. I look a little into the NVDA project but did not see much there. I am doing this to learn and have the extra voices for XP machines. As you know and others have joked about Vista kind of destroys everything and others went back to XP... So, if anyone knows of a good way to do the talking to the Sapi 4 would be of great help. I am sure I will soon read the right docs on it, but that is 9/10 of the battle, finding good docs. Bruce Hi! Perso, I use MS-agents, and I choice an "empty" character. MS-agents are well knowed et well documented. Empty agent is invisible, but its voice is audible. A problem: on Vista, with non-english (french) voice, only English voices are available with Vista"standard", and we can download only very few French voices. @-salutations Michel Claveau From bgailer at gmail.com Sat Jul 12 13:32:32 2008 From: bgailer at gmail.com (bob gailer) Date: Sat, 12 Jul 2008 07:32:32 -0400 Subject: [python-win32] scripting pythonwin Message-ID: <48789650.1050004@gmail.com> How can I learn to "script" pythonwin? I'd like to start with a script that would open an existing .py file in an edit window, then do various things such as: set the window size and position scroll the text position the cursor size the "class" pane position the splitter Any pointers are welcome. -- Bob Gailer 919-636-4239 Chapel Hill, NC From mhammond at skippinet.com.au Sat Jul 12 15:05:11 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 12 Jul 2008 16:05:11 +0300 Subject: [python-win32] scripting pythonwin In-Reply-To: <48789650.1050004@gmail.com> References: <48789650.1050004@gmail.com> Message-ID: <003101c8e41f$eeb7ef50$cc27cdf0$@com.au> > How can I learn to "script" pythonwin? > > I'd like to start with a script that would open an existing .py file in > an edit window, then do various things such as: > set the window size and position > scroll the text > position the cursor > size the "class" pane > position the splitter > > Any pointers are welcome. I'm afraid you need to learn MFC. To get started, try something like: >>> import win32ui >>> app = win32ui.GetApp() >>> o=app.OpenDocumentFile("c:\\whatever\\filename") >>> o >>> o.GetEditorView().GetParent().GetParent().GetParent().MoveWindow((0,0,10,10) ) Obviously lots of GetParent() calls - in the real world you would loop until you hit a frame window. Hope this helps, Mark From stef.mientki at gmail.com Sat Jul 12 20:20:00 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Sat, 12 Jul 2008 20:20:00 +0200 Subject: [python-win32] scripting pythonwin In-Reply-To: <48789650.1050004@gmail.com> References: <48789650.1050004@gmail.com> Message-ID: <4878F5D0.9090007@gmail.com> bob gailer wrote: > How can I learn to "script" pythonwin? > > I'd like to start with a script that would open an existing .py file > in an edit window, then do various things such as: > set the window size and position > scroll the text > position the cursor > size the "class" pane > position the splitter > > Any pointers are welcome. > you might take a look at the exPython demo. cheers, Stef From jsacksteder at gmail.com Sat Jul 12 21:05:10 2008 From: jsacksteder at gmail.com (jeff sacksteder) Date: Sat, 12 Jul 2008 15:05:10 -0400 Subject: [python-win32] Implementing Collections / Shim-ing Word In-Reply-To: <000001c8e3ed$5e227550$1a675ff0$@com.au> References: <51c8a7be0807020756y6e63a80bra6c7bd076a62c18c@mail.gmail.com> <027b01c8dc9a$698cd250$3ca676f0$@com.au> <51c8a7be0807112000u7bd6420and5cba1d77ae3023e@mail.gmail.com> <000001c8e3ed$5e227550$1a675ff0$@com.au> Message-ID: <51c8a7be0807121205t2fe4c4b7y41d5490d3f6bac2@mail.gmail.com> >> If I can get an understanding of how these collections work on the >> Python side vs the COM side, I'll be make some progress. > > So what is you question? How do I create a COM server that emulates the COM interface of MS Word? Specifically, returning this 'Documents' collection in what ever is the proper form. Much as I would prefer to ask a well-formulated and direct question, I don't have the vocabulary to do so. I am primarily familiar with python with only a basic knowledge of COM. I have used it to script external applications in the past, but implementing servers is more involved. Most documentation that I have found presumes an existing knowledge of COM that makes it less useful to me. A working code snippet demonstrating the described feature would be helpful. So would information about what sort of COM features I should be learning about. If that sort of query is off-topic for this venue, then a suggestion regarding a good documentation resource, because I have just about exhausted my ability to bootstrap my skills to a useful level. From mhammond at skippinet.com.au Sat Jul 12 21:58:26 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 12 Jul 2008 22:58:26 +0300 Subject: [python-win32] Implementing Collections / Shim-ing Word In-Reply-To: <51c8a7be0807121205t2fe4c4b7y41d5490d3f6bac2@mail.gmail.com> References: <51c8a7be0807020756y6e63a80bra6c7bd076a62c18c@mail.gmail.com> <027b01c8dc9a$698cd250$3ca676f0$@com.au> <51c8a7be0807112000u7bd6420and5cba1d77ae3023e@mail.gmail.com> <000001c8e3ed$5e227550$1a675ff0$@com.au> <51c8a7be0807121205t2fe4c4b7y41d5490d3f6bac2@mail.gmail.com> Message-ID: <005201c8e459$ab5f4930$021ddb90$@com.au> > How do I create a COM server that emulates the COM interface of MS > Word? Specifically, returning this 'Documents' collection in what ever > is the proper form. That is a very tough question - I doubt many people are familiar enough with the implementation details of Word to know for sure. > Much as I would prefer to ask a well-formulated and direct question, I > don't have the vocabulary to do so. And sadly we are unlikely to have the technical knowledge about the impl of work to present a well formulated answer! If you can stick to specific questions about specific issues you are having, we can likely help - but the question as stated is too vague for me to know where to start... Cheers, Mark From venturasalvatore at yahoo.it Sun Jul 13 00:47:36 2008 From: venturasalvatore at yahoo.it (salvatore ventura) Date: Sat, 12 Jul 2008 22:47:36 +0000 (GMT) Subject: [python-win32] How to get IWebBrowser2 from a HWND In-Reply-To: <008901c8e322$cc63b9a0$652b2ce0$@com.au> Message-ID: <621939.28061.qm@web25606.mail.ukl.yahoo.com> Hi Mark, Tim, thanks for the prompt responses. Tim, the code you suggest does not help me in this context, as it is not able to 'see' the HWND of the modal popup as an IE (ShellWindow) one. In fact, that code is only able to get the main IE app window. Mark, I tried what you suggest, two ways (following my previous code): pIServiceProvider.QueryService(IWebBrowserApp._iid_, GUID(pythoncom.IID_IDispatch)) win32com.client.Dispatch(pIServiceProvider.QueryService(IWebBrowserApp._iid_, GUID(pythoncom.IID_IDispatch))) Still I get the 'No such interface supported'. Now, I start to think that somehow I am not (in the class structure) in the place I think I am, but I am not too sure of how to know that. Will the 'type' on an object be reliable in these cases? Or will it just reflect what the variable has been defined as (which would be my guess)? In other words, how will I be able to debug this? I am somehow new to both python and COM, so sorry if some questions will be silly... thanks a lot! .salvo --- Gio 10/7/08, Mark Hammond ha scritto: > Da: Mark Hammond > Oggetto: RE: [python-win32] How to get IWebBrowser2 from a HWND > A: "'salvatore ventura'" , python-win32 at python.org > Data: Gioved? 10 luglio 2008, 23:53 > > # ... and the IWebBrowser2: > > ie = > pIServiceProvider.QueryService(IWebBrowserApp._iid_, > > IWebBrowser2._iid_) > > > > # which - of course - fails. > > > > > > Error returned: > > Traceback (most recent call last): > > File "", line 1, > in > > COMError: (-2147467262, 'No such interface > supported', (None, None, > > None, 0, None)) > > Its possible that you could specify IDispatch as the second > IID, then wrap > the resulting object using win32com.client.Dispatch() (or > the equivalent > using ctypes). > > Cheers, > > Mark From bgailer at gmail.com Sun Jul 13 01:08:05 2008 From: bgailer at gmail.com (bob gailer) Date: Sat, 12 Jul 2008 19:08:05 -0400 Subject: [python-win32] scripting pythonwin In-Reply-To: <4878F5D0.9090007@gmail.com> References: <48789650.1050004@gmail.com> <4878F5D0.9090007@gmail.com> Message-ID: <48793955.1000303@gmail.com> Stef Mientki wrote: > bob gailer wrote: >> How can I learn to "script" pythonwin? >> >> I'd like to start with a script that would open an existing .py file >> in an edit window, then do various things such as: >> set the window size and position >> scroll the text >> position the cursor >> size the "class" pane >> position the splitter >> >> Any pointers are welcome. >> > you might take a look at the exPython demo. Did you mean wxPython? How does that relate to the edit windows in the PythonWin IDE? It is those windows that I want to manage. According to Mark H I must use MFC. -- Bob Gailer 919-636-4239 Chapel Hill, NC From venturasalvatore at yahoo.it Sun Jul 13 02:00:10 2008 From: venturasalvatore at yahoo.it (salvatore ventura) Date: Sun, 13 Jul 2008 00:00:10 +0000 (GMT) Subject: [python-win32] How to get IWebBrowser2 from a HWND Message-ID: <67251.41765.qm@web25607.mail.ukl.yahoo.com> Hi, to make things easier, I have attached two htm files that display my scenario: - main.htm has a link, that once clicked will open a modal popup dialog.htm) that has an input text box. What I would like to achieve is the IWebBrowser2 object of the dialog.htm page. I know I can access anything on the page itself via the IHTMLDocument2 (which I already have) but that's not my need. For testing, to make things easy, for now, I open the web page and click on the link from *outside* of the python script, then have the script go ahead and figure the windows names etc etc... In the real scenario, one python script will drive the dialog opening, but I will use a second thread to deal with the dialog. I am using PAMIE, and the thread idea is freely mutuated from the cModalPopUp class that comes with it (which only deals with alert boxes and similar though). I have also attached a zip file with the whole ball (python test script, htm files, the winAutoGui.py that you may know already, and the tlb file for the service provider, which I found on the web. Thanks again for the help, I will be experimenting other ways around this in the meanwhile. regards, .salvo --- Sab 12/7/08, salvatore ventura ha scritto: > Da: salvatore ventura > Oggetto: RE: [python-win32] How to get IWebBrowser2 from a HWND > A: python-win32 at python.org > Data: Sabato 12 luglio 2008, 15:47 > Hi Mark, Tim, > thanks for the prompt responses. > > Tim, > the code you suggest does not help me in this context, as > it is not able to 'see' the HWND of the modal popup > as an IE (ShellWindow) one. In fact, that code is only able > to get the main IE app window. > > Mark, > I tried what you suggest, two ways (following my previous > code): > > pIServiceProvider.QueryService(IWebBrowserApp._iid_, > GUID(pythoncom.IID_IDispatch)) > > win32com.client.Dispatch(pIServiceProvider.QueryService(IWebBrowserApp._iid_, > GUID(pythoncom.IID_IDispatch))) > > Still I get the 'No such interface supported'. > > Now, I start to think that somehow I am not (in the class > structure) in the place I think I am, but I am not too sure > of how to know that. Will the 'type' on an object be > reliable in these cases? Or will it just reflect what the > variable has been defined as (which would be my guess)? > > In other words, how will I be able to debug this? > > I am somehow new to both python and COM, so sorry if some > questions will be silly... > > > thanks a lot! > .salvo > > > > --- Gio 10/7/08, Mark Hammond > ha scritto: > > > Da: Mark Hammond > > Oggetto: RE: [python-win32] How to get IWebBrowser2 > from a HWND > > A: "'salvatore ventura'" > , python-win32 at python.org > > Data: Gioved? 10 luglio 2008, 23:53 > > > # ... and the IWebBrowser2: > > > ie = > > pIServiceProvider.QueryService(IWebBrowserApp._iid_, > > > IWebBrowser2._iid_) > > > > > > # which - of course - fails. > > > > > > > > > Error returned: > > > Traceback (most recent call last): > > > File "", > line 1, > > in > > > COMError: (-2147467262, 'No such interface > > supported', (None, None, > > > None, 0, None)) > > > > Its possible that you could specify IDispatch as the > second > > IID, then wrap > > the resulting object using win32com.client.Dispatch() > (or > > the equivalent > > using ctypes). > > > > Cheers, > > > > Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: IE_modals.zip Type: application/x-zip-compressed Size: 11161 bytes Desc: not available URL: From marcus at internetnowasp.net Sun Jul 13 04:20:06 2008 From: marcus at internetnowasp.net (Marcus Low) Date: Sun, 13 Jul 2008 10:20:06 +0800 Subject: [python-win32] scripting pythonwin In-Reply-To: <48793955.1000303@gmail.com> References: <48789650.1050004@gmail.com> <4878F5D0.9090007@gmail.com> <48793955.1000303@gmail.com> Message-ID: <48796656.6050904@internetnowasp.net> Bob, Do you mean u want to control pythonwin ide itself as somekind of automation? Else whether its MFC or wxPython, those are for you to develop windows native like apps where u get to do all those thing that u list. If you want to control pythonwin, then its another story. Marcus. bob gailer wrote: > Stef Mientki wrote: >> bob gailer wrote: >>> How can I learn to "script" pythonwin? >>> >>> I'd like to start with a script that would open an existing .py file >>> in an edit window, then do various things such as: >>> set the window size and position >>> scroll the text >>> position the cursor >>> size the "class" pane >>> position the splitter >>> >>> Any pointers are welcome. >>> >> you might take a look at the exPython demo. > > Did you mean wxPython? > > How does that relate to the edit windows in the PythonWin IDE? It is > those windows that I want to manage. According to Mark H I must use MFC. > > From bgailer at gmail.com Sun Jul 13 04:27:49 2008 From: bgailer at gmail.com (bob gailer) Date: Sat, 12 Jul 2008 22:27:49 -0400 Subject: [python-win32] scripting pythonwin In-Reply-To: <48796656.6050904@internetnowasp.net> References: <48789650.1050004@gmail.com> <4878F5D0.9090007@gmail.com> <48793955.1000303@gmail.com> <48796656.6050904@internetnowasp.net> Message-ID: <48796825.1010405@gmail.com> Marcus Low wrote: > Bob, > > Do you mean u want to control pythonwin ide itself as somekind of > automation? Yes. I already accomplished my first goal based on what Mark told me, a program to open, size & position 5 py file edit windows - something I was doing by hand each time I started the IDE. Next step is to save the configuration upon exiting so I can restore it at next startup. MFC documentation will take some time to comprehend, as it is written for C++ / NET rather than Python. > If you want to control pythonwin, then its another story. That is the story I am writing! -- Bob Gailer 919-636-4239 Chapel Hill, NC From bgailer at gmail.com Sun Jul 13 17:48:16 2008 From: bgailer at gmail.com (bob gailer) Date: Sun, 13 Jul 2008 11:48:16 -0400 Subject: [python-win32] scripting pythonwin In-Reply-To: <003101c8e41f$eeb7ef50$cc27cdf0$@com.au> References: <48789650.1050004@gmail.com> <003101c8e41f$eeb7ef50$cc27cdf0$@com.au> Message-ID: <487A23C0.4040900@gmail.com> Mark Hammond wrote: >>>> import win32ui >>>> app = win32ui.GetApp() >>>> o=app.OpenDocumentFile("c:\\whatever\\filename") >>>> o >>>> > 0x0129EFD0> > > o.GetEditorView().GetParent().GetParent().GetParent().MoveWindow((0,0,10,10) > ) > > Obviously lots of GetParent() calls - in the real world you would loop until > you hit a frame window. > > Hope this helps, > It is a great starter. I now have a program that opens 5 files with the windows where I want them. Questions follow - please answer only as much as you have time and energy for: I'd like to have this program run each time I start the IDE. How do I do that? I'd also like to save window settings when I close the IDE. How do I capture the quit event? How do I enumerate the open windows? I have started reading the MFC documentation. It is not easy reading! It is hard to tell which methods are actually available, and what the parameters mean. I assume if I had the appropriate header file I'd have access to the values of the named constants. How do I get that file? Is there a tutorial re MFC that might make it easier? Thanks for your help. -- Bob Gailer 919-636-4239 Chapel Hill, NC From mhammond at skippinet.com.au Sun Jul 13 18:53:48 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 13 Jul 2008 19:53:48 +0300 Subject: [python-win32] scripting pythonwin In-Reply-To: <487A23C0.4040900@gmail.com> References: <48789650.1050004@gmail.com> <003101c8e41f$eeb7ef50$cc27cdf0$@com.au> <487A23C0.4040900@gmail.com> Message-ID: <000a01c8e509$07042e40$150c8ac0$@com.au> > I'd like to have this program run each time I start the IDE. How do I > do that? Check out pywin.framework.intpyapp - you will find almost all the pythonwin "app" framework there, including sys.argv handing. Specifically, "/run" might be the option you want (and alternatively, patches that get a bit closer to what you need are obviously welcome) > I'd also like to save window settings when I close the IDE. How do I > capture the quit event? How do I enumerate the open windows? I'm not sure how simple that would be, but extra code in intpyapp's ExitInstance might make sense. > I have started reading the MFC documentation. It is not easy reading! > It > is hard to tell which methods are actually available, and what the > parameters mean. Yep - that hasn't changed in over 10 years ;) > I assume if I had the appropriate header file I'd have access to the > values of the named constants. How do I get that file? What file? Win32ui has most constants you should need. Otherwise, see h2py.py (somewhere in your Python's scripts/tools directory) > Is there a tutorial re MFC that might make it easier? Not that I'm aware of (but things may have changed in the 10 years since I last looked ;) Cheers, Mark From marcus at internetnowasp.net Mon Jul 14 04:54:32 2008 From: marcus at internetnowasp.net (Marcus.CM) Date: Mon, 14 Jul 2008 10:54:32 +0800 Subject: [python-win32] scripting pythonwin In-Reply-To: <48796825.1010405@gmail.com> References: <48789650.1050004@gmail.com> <4878F5D0.9090007@gmail.com> <48793955.1000303@gmail.com> <48796656.6050904@internetnowasp.net> <48796825.1010405@gmail.com> Message-ID: <487ABFE8.103@internetnowasp.net> Hi Bob, Coming from a VC++ to python was not that hard, but there are some mentality changes and "gotchas" when i took up python. In your case, if you want to learn MFC, well, actaully its going to a lot more "gotchas" and finer mentality changes. But i would recommend the following book if you are serious into learning MFC without getting confused by much of other C++ stuffs :- http://www.amazon.com/Microsoft-Mastering-Development-Using-Visual/dp/B00002S9IV/ref=sr_1_1?ie=UTF8&s=software&qid=1216004029&sr=8-1 -best Marcuys. bob gailer wrote: > Marcus Low wrote: >> Bob, >> >> Do you mean u want to control pythonwin ide itself as somekind of >> automation? > > Yes. I already accomplished my first goal based on what Mark told me, > a program to open, size & position 5 py file edit windows - something > I was doing by hand each time I started the IDE. > > Next step is to save the configuration upon exiting so I can restore > it at next startup. > > MFC documentation will take some time to comprehend, as it is written > for C++ / NET rather than Python. >> If you want to control pythonwin, then its another story. > > That is the story I am writing! > > From sunp1028 at gmail.com Mon Jul 14 09:17:49 2008 From: sunp1028 at gmail.com (Patrol Sun) Date: Mon, 14 Jul 2008 15:17:49 +0800 Subject: [python-win32] about wmi exception Message-ID: <27cbc0fa0807140017i37cffcf8wfe2a8b3c9703bfbe@mail.gmail.com> I want to prevent some process from running. The code is in the following. I encounter some unexpected troubles. Probelm1: This program cannot terminate "scrcons.exe" and "FNPLicensingService.exe",which are system processes. Problem2:After a while, this program will abort by error File "C:\Python25\lib\wmi.py", line 397, in __call__ handle_com_error (error_info) File "C:\Python25\lib\wmi.py", line 190, in handle_com_error raise x_wmi, "\n".join (exception_string) UnicodeDecodeError: 'ascii' codec can't decode byte 0xb7 in position 14: ordinal not in range(128) ---------------------------------------------------- code-----------------------------------------------------------------------?----------- # -*- coding:utf-8 -*- import pythoncom import wmi import threading import time from xml.dom.minidom import parse, parseString class Info (threading.Thread): def __init__ (self): threading.Thread.__init__ (self) def run (self): print 'In Another Thread...' pythoncom.CoInitialize () dom1 = parse('processTerminateList.xml') config_element = dom1.getElementsByTagName("processTerminateList") [0] servers = config_element.getElementsByTagName("processName") try: c = wmi.WMI () for process in c.Win32_Process (): for server in servers: if process.name == getText(server.childNodes): process.Terminate() print process.name process_watcher = c.Win32_Process.watch_for("creation") while True: new_process = process_watcher() name = new_process.Caption print name for server in servers: if name == getText(server.childNodes): new_process.Terminate() finally: pythoncom.CoUninitialize () def getText(nodelist): rc = "" for node in nodelist: if node.nodeType == node.TEXT_NODE: rc = rc + node.data return rc if __name__ == '__main__': Info().start() ------------------------------------------------------ processTerminateList.xml---------------------------------------------------?-------------------- scrcons.exe TXPlatform.exe mdm.exe FNPLicensingService.exe notepad.exe uedit32.exe -------------- next part -------------- An HTML attachment was scrubbed... URL: From thomas.lidebrandt at gmail.com Mon Jul 14 14:00:45 2008 From: thomas.lidebrandt at gmail.com (Thomas Lidebrandt) Date: Mon, 14 Jul 2008 14:00:45 +0200 Subject: [python-win32] Matlab COM object cause memory leak Message-ID: <7542c2e60807140500t50e32febw9229f587ddc27ea7@mail.gmail.com> Hello I have a Server application that uses Matlab, this works fine when I use the Execute method to evaluate and retrieve data. However, using the method GetFullMatrix in the method getvar seems to cause a memory leak. Anyone got any idea? I use the following code for the communication with Matlab import pythoncom, pywintypes from win32com.client import Dispatch class MatlabServer(): def __init__(self): pythoncom.CoInitialize() matlab_object = Dispatch('matlab.application.single') self.execute = getattr(matlab_object, 'Execute') self.putfullmatrix = getattr(matlab_object, 'PutFullMatrix') self.getfullmatrix = getattr(matlab_object, 'GetFullMatrix') self.getchararray = getattr(matlab_object, 'GetCharArray') def __del__(self): pythoncom.CoUninitialize() def setvar(self, xnam, x, workspace = "base"): if type(x) is not list: x = [ x ] self.putfullmatrix(xnam, workspace, x, None) def getvar(self, xnam, workspace = "base"): try: return self.getfullmatrix(xnam, workspace, None, None)[0] except pywintypes.com_error: return [] def getstring(self, xnam, workspace = "base"): try: return self.getchararray(xnam, workspace) except pywintypes.com_error: return '' /Thomas -------------- next part -------------- An HTML attachment was scrubbed... URL: From bourdon.jeremy at gmail.com Mon Jul 14 14:50:29 2008 From: bourdon.jeremy at gmail.com (BOURDON jeremy) Date: Mon, 14 Jul 2008 14:50:29 +0200 Subject: [python-win32] win32gui_menu doesn't work correctly Message-ID: <4101a8400807140550x4b2128bexcf681a0ce976ec24@mail.gmail.com> hi, When I run win32gui_menu.py, one bitmap in the menu is not drawing. The one that's not drawing is the ico convert to bitmap with the text "Menu with icon". I install the last build of pywin32 with python 2.5.1 and my OS is WindowsXP SP2. is there a problem with the example code or it's only with me that doesn't work ? thanks very much, Jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Mon Jul 14 19:27:54 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 14 Jul 2008 10:27:54 -0700 Subject: [python-win32] about wmi exception In-Reply-To: <27cbc0fa0807140017i37cffcf8wfe2a8b3c9703bfbe@mail.gmail.com> References: <27cbc0fa0807140017i37cffcf8wfe2a8b3c9703bfbe@mail.gmail.com> Message-ID: <487B8C9A.5050500@probo.com> Patrol Sun wrote: > I want to prevent some process from running. The code is in the > following. I encounter some unexpected troubles. > Probelm1: This program cannot terminate "scrcons.exe" and > "FNPLicensingService.exe",which are system processes. If you kill FNPLicensingService, you will not be able to use the Adobe Acrobat Reader. Adobe has made the incredibly stupid decision to have the Acrobat Reader "phone home" now and then using this service, and if it is not present, Acrobat simply refuses to run. Scrcons.exe is part of WMI. Why do you want to kill it? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From drorco at gmail.com Mon Jul 14 20:19:48 2008 From: drorco at gmail.com (Dror Cohen) Date: Mon, 14 Jul 2008 21:19:48 +0300 Subject: [python-win32] How to get the current active language in which I'm typing in windows. Message-ID: <884670ce0807141119v2ff6c0bfw24c14a34d289c807@mail.gmail.com> Hi :) I've been asking about this matter in the python tutor mailing list and I've been suggested to post my question here, as it was specific to win32api. I want to be able to know what is my currently active language, how can I do that? I've been searching around for functions and this is the only thing I found fitting - http://msdn.microsoft.com/en-us/library/ms628562(VS.85).aspx I've asked how to use it on the Tutor mailing list and this is the answer I got from a very nice fellow Maybe it could help you understand what I've got so far - " Dror Cohen wrote: > I'm trying to use the these functions which are in isnide of > ITfInputProcessorProfiles > http://msdn.microsoft.com/en-us/library/ms538984(VS.85).aspx > > I think that its registry key is {892F230F-FE00-4A41-A98E-FCD6DE0D35EF} > (though I don't know if I even need this) > > How can I use its function inside of python. > I tried using this by thinking it will get me somewhere (Got no idea if I > was even close) > > > point = None > Inputpp = pythoncom.MakeIID('{892F230F-FE00-4A41-A98E-FCD6DE0D35EF}') > pythoncom.CoCreateInstance(Inputpp, None, pythoncom.CLSCTX_INPROC_SERVER, > point) > > but then I got this error message > > Traceback (most recent call last): > File "", line 1, in > TypeError: Only strings and iids can be converted to a CLSID. > This question would probably be better posed to the python-win32 mailing list. People on the tutor list are always ready to be helpful, but this one's a bit specific. To answer your question as straightforwardly as possible: the pywin32 COM extensions can't handle arbitrary COM interfaces. For that you need to use comtypes [1] (or write your own extension). The code below works against the current comtypes svn HEAD. import ctypes from ctypes import wintypes import comtypes class ITfInputProcessorProfiles (comtypes.IUnknown): _iid_ = comtypes.GUID ("{1F02B6C5-7842-4EE6-8A0B-9A24183A95CA}") _idlflags_ = [] _case_insensitive_ = False _methods_ = [ comtypes.COMMETHOD ( [], comtypes.HRESULT, "GetCurrentLanguage", (["out"], ctypes.POINTER (wintypes.LANGID), "pLangId") ) ] ipp = comtypes.CoCreateInstance ( comtypes.IID ("{33C53A50-F456-4884-B049-85FD643ECFED}"), ITfInputProcessorProfiles ) langid = wintypes.LANGID (ipp.GetCurrentLanguage ()) print langid I get a value of 0, which seems to indicate a major and sub language of NEUTRAL. I don't really know how languages work on Windows, and there seem to be too many variants. As an alternative, you might want to look at the win32api module, which has functions like GetUserDefaultLangID and GetUserDefaultLCID. TJG " The problem with it is that it was always returning "c_ushort(0)" No matter what language I was set on typing in. Also, how can I write my own extensions? Will it be better for me in this case to write my own extension? I hope you guys will be able to help me :) Thanks a lot! -------------- next part -------------- An HTML attachment was scrubbed... URL: From rwupole at msn.com Tue Jul 15 04:00:10 2008 From: rwupole at msn.com (Roger Upole) Date: Mon, 14 Jul 2008 22:00:10 -0400 Subject: [python-win32] Re: How to get the current active language in which I'm Message-ID: Dror Cohen wrote: > Hi :) > > I've been asking about this matter in the python tutor mailing list and > I've > been suggested to post my question here, as it was specific to win32api. > I want to be able to know what is my currently active language, how can I > do > that? Try win32api.GetThreadLocale(). Roger From tibor.arpas at infinit.sk Tue Jul 15 16:20:17 2008 From: tibor.arpas at infinit.sk (Tibor Arpas) Date: Tue, 15 Jul 2008 16:20:17 +0200 Subject: [python-win32] COM Base Class and derived classes Message-ID: <19a7c8c20807150720t2ec11ef7m3691f6cc14d30d25@mail.gmail.com> Hi, I'm new to both python and COM. I try to use the win32com.client. Many things work like a charm, but I bumped into following problem. The COM server has following hierarchy of types: Component (Base class) -----Folder -----Drawing -----Image -----Form -----Script ----- ...... The components are stored in a collection. When I try to access specific component in my script I'm always getting the instance of "Component". >>> s.Document.ComponentSet['MyDrawing'] .... instance of Component ...... When I try the same thing in IronPython (the COM component has also .NET interface and I use the clr library from IronPython), I get the specific type. This confirms that at least some of my assumptions are right. >>>s.Document.ComponentSet["MyDrawing"] Can anybody give some pointers where to look and what to check? Regards, Tibor -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Jul 15 18:26:50 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 15 Jul 2008 17:26:50 +0100 Subject: [python-win32] about wmi exception In-Reply-To: <27cbc0fa0807140017i37cffcf8wfe2a8b3c9703bfbe@mail.gmail.com> References: <27cbc0fa0807140017i37cffcf8wfe2a8b3c9703bfbe@mail.gmail.com> Message-ID: <487CCFCA.8020306@timgolden.me.uk> Patrol Sun wrote: > I want to prevent some process from running. The code is in the > following. As an additional datum, the WMI event management code (at least for process creation) works by polling, not by receiving events from the underlying O/S. That means that it's possible to miss a creation event. If you want to be certain to close down certain processes, you'll need roll-your-own polling and look for the existence of a process, not its creation. TJG From matherbe at cisco.com Tue Jul 15 22:30:51 2008 From: matherbe at cisco.com (Matt Herbert (matherbe)) Date: Tue, 15 Jul 2008 16:30:51 -0400 Subject: [python-win32] CAPICOM on Vista 64 Message-ID: <249A89BAA060C94FA0B93EA6135CC93C05C8CF66@xmb-rtp-20b.amer.cisco.com> Hey all, I'm using python 2.6b1.amd64 and pywin32-211.win-amd64 on my 64 bit vista system. I am trying to access the CAPICOM COM library through win32com.client. However, every time I try to load it through the Dispatch method I get the following error: >>> win32com.client.Dispatch('CAPICOM.Store.2') Traceback (most recent call last): File "", line 1, in File "C:\Python26\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsct x) File "C:\Python26\Lib\site-packages\win32com\client\dynamic.py", line 98, in _ GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python26\Lib\site-packages\win32com\client\dynamic.py", line 78, in _ GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_ID ispatch) pywintypes.com_error: (-2147221164, 'Class not registered', None, None) >>> This same code and same CAPICOM library work just fine on a vista 32 system. If I run makepy, I can select the CAPICOM v2.1 Type Library(2.1) from the list, and it creates the python interface from the type library without any problems. Based on the many searches I've done on Google, it looks like CAPICOM v 2.1.0.2 (which is the version I'm using) is supported on Windows Vista. Only problem is I couldn't find anything about whether it supposed to work on Vista64 or not? Anybody got any clues what's going on here? Thanks -Matt From mhammond at skippinet.com.au Wed Jul 16 02:57:21 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 16 Jul 2008 10:57:21 +1000 Subject: [python-win32] CAPICOM on Vista 64 In-Reply-To: <249A89BAA060C94FA0B93EA6135CC93C05C8CF66@xmb-rtp-20b.amer.cisco.com> References: <249A89BAA060C94FA0B93EA6135CC93C05C8CF66@xmb-rtp-20b.amer.cisco.com> Message-ID: <01a701c8e6de$e959be00$bc0d3a00$@com.au> > I'm using python 2.6b1.amd64 and pywin32-211.win-amd64 on my 64 bit > vista system. I am trying to access the CAPICOM COM library through > win32com.client. However, every time I try to load it through the > Dispatch method I get the following error: It appears that a 64bit version of that COM object has not been installed. On my Vista64 box I see the following: 32bit version of Python: | pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, u'The Store object does not represent an opened certificate store.\r\n', None, 0, -2138570192), None) (ie, the object is installed - but for whatever reason it failed to be created) While the 64bit version of Python on the same box: | pywintypes.com_error: (-2147221164, 'Class not registered', None, None) (ie, object not registered) Sadly (but for good reason) COM doesn't provide interoperability between 64 and 32 bit versions of COM objects. Although it does allow both 32 and 64bit versions to be registered, this particular COM object doesn't take advantage of that. Also somewhat sadly, Python has explicitly made the decision to *not* allow both 32 and 64bit versions to be installed on the same machine (although that does work fine once you arrange for them to both be installed) Cheers, Mark From mhammond at skippinet.com.au Wed Jul 16 03:07:37 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 16 Jul 2008 11:07:37 +1000 Subject: [python-win32] win32gui_menu doesn't work correctly In-Reply-To: <4101a8400807140550x4b2128bexcf681a0ce976ec24@mail.gmail.com> References: <4101a8400807140550x4b2128bexcf681a0ce976ec24@mail.gmail.com> Message-ID: <01a801c8e6e0$58c2bfc0$0a483f40$@com.au> > When I run win32gui_menu.py, one bitmap in the menu is not drawing. The one > that's not drawing is the ico convert to bitmap with the text "Menu with icon". Bugger - that doesn't appear to be working for me either at the moment. I can't recall me knowing a reason for that but I don't have time at this instant to dig deeper. Cheers, Mark From mhammond at skippinet.com.au Wed Jul 16 03:07:37 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 16 Jul 2008 11:07:37 +1000 Subject: [python-win32] COM Base Class and derived classes In-Reply-To: <19a7c8c20807150720t2ec11ef7m3691f6cc14d30d25@mail.gmail.com> References: <19a7c8c20807150720t2ec11ef7m3691f6cc14d30d25@mail.gmail.com> Message-ID: <01a901c8e6e0$5f417fd0$1dc47f70$@com.au> You probably want to look at using makepy and see if the behaviour changes. Note too that the "name" displayed by win32com may not correspond to the type of the object at all, particularly when makepy isn't used or for whatever reason the object doesn't support type information. Are you actually seeing a problem caused by what you describe? If so, what? If the problem is that the methods etc from the sub-class aren't seen, then check out win32com.client.CastTo() Cheers, Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tibor Arpas Sent: Wednesday, 16 July 2008 12:20 AM To: python-win32 at python.org Subject: [python-win32] COM Base Class and derived classes Hi, I'm new to both python and COM. I try to use the win32com.client. Many things work like a charm, but I bumped into following problem. The COM server has following hierarchy of types: Component (Base class) -----Folder -----Drawing -----Image -----Form -----Script ----- ...... The components are stored in a collection. When I try to access specific component in my script I'm always getting the instance of "Component". >>> s.Document.ComponentSet['MyDrawing'] .... instance of Component ...... When I try the same thing in IronPython (the COM component has also .NET interface and I use the clr library from IronPython), I get the specific type. This confirms that at least some of my assumptions are right. >>>s.Document.ComponentSet["MyDrawing"] Can anybody give some pointers where to look and what to check? Regards, Tibor -------------- next part -------------- An HTML attachment was scrubbed... URL: From rwupole at msn.com Wed Jul 16 04:23:49 2008 From: rwupole at msn.com (Roger Upole) Date: Tue, 15 Jul 2008 22:23:49 -0400 Subject: [python-win32] Re: win32gui_menu doesn't work correctly Message-ID: > Bugger - that doesn't appear to be working for me either at the moment. I > can't recall me knowing a reason for that but I don't have time at this > instant to dig deeper. > > Cheers, > > Mark This one appears to be my fault. I changed bitmap handles to be self-closing like PyHANDLE's. (DeleteObject is called when the object's refcount goes to 0) Adding a .Detach at line 168 lets the icon show up again: item, extras = PackMENUITEMINFO(text="Menu with icon", hbmpItem=hbm.Detach(), wID=1011) Roger From rwupole at msn.com Wed Jul 16 04:43:18 2008 From: rwupole at msn.com (Roger Upole) Date: Tue, 15 Jul 2008 22:43:18 -0400 Subject: [python-win32] Re: CAPICOM on Vista 64 Message-ID: "Mark Hammond" wrote in message news:01a701c8e6de$e959be00$bc0d3a00$@com.au... >> I'm using python 2.6b1.amd64 and pywin32-211.win-amd64 on my 64 bit >> vista system. I am trying to access the CAPICOM COM library through >> win32com.client. However, every time I try to load it through the >> Dispatch method I get the following error: > > It appears that a 64bit version of that COM object has not been installed. > On my Vista64 box I see the following: > > 32bit version of Python: > > | pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, > u'The > Store object does not represent an opened certificate store.\r\n', None, > 0, > -2138570192), None) > > (ie, the object is installed - but for whatever reason it failed to be > created) > > While the 64bit version of Python on the same box: > > | pywintypes.com_error: (-2147221164, 'Class not registered', None, None) > > (ie, object not registered) > > Sadly (but for good reason) COM doesn't provide interoperability between > 64 > and 32 bit versions of COM objects. Although it does allow both 32 and > 64bit versions to be registered, this particular COM object doesn't take > advantage of that. Also somewhat sadly, Python has explicitly made the > decision to *not* allow both 32 and 64bit versions to be installed on the > same machine (although that does work fine once you arrange for them to > both > be installed) > As far as I can tell, they haven't released a 64-bit version of CAPICOM at all. What I've done is to create a COM+ application that runs in its own process and exports the interfaces provided by CAPICOM. This is fairly straightforward using the Component Services snapin for MMC. Roger From sunp1028 at gmail.com Wed Jul 16 14:46:17 2008 From: sunp1028 at gmail.com (Patrol Sun) Date: Wed, 16 Jul 2008 20:46:17 +0800 Subject: [python-win32] about wmi exception In-Reply-To: <487CCFCA.8020306@timgolden.me.uk> References: <27cbc0fa0807140017i37cffcf8wfe2a8b3c9703bfbe@mail.gmail.com> <487CCFCA.8020306@timgolden.me.uk> Message-ID: <27cbc0fa0807160546v417abe02gaf9e685e3486333d@mail.gmail.com> Thanks. Can you tell me how long the polling period of the process creation is? So I can use the sleep and poll instead of the process creation monitoring. 2008/7/16 Tim Golden : > Patrol Sun wrote: > >> I want to prevent some process from running. The code is in the >> following. >> > > As an additional datum, the WMI event management code > (at least for process creation) works by polling, not > by receiving events from the underlying O/S. That > means that it's possible to miss a creation event. > If you want to be certain to close down certain processes, > you'll need roll-your-own polling and look for the existence > of a process, not its creation. > > TJG > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Wed Jul 16 14:50:03 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 16 Jul 2008 13:50:03 +0100 Subject: [python-win32] about wmi exception In-Reply-To: <27cbc0fa0807160546v417abe02gaf9e685e3486333d@mail.gmail.com> References: <27cbc0fa0807140017i37cffcf8wfe2a8b3c9703bfbe@mail.gmail.com> <487CCFCA.8020306@timgolden.me.uk> <27cbc0fa0807160546v417abe02gaf9e685e3486333d@mail.gmail.com> Message-ID: <487DEE7B.8070604@timgolden.me.uk> Patrol Sun wrote: > Thanks. Can you tell me how long the polling period of the process > creation is? So I can use the sleep and poll instead of the process > creation monitoring. You can specify it, but I don't believe you can get anything finer than 1 second. But even if you're running the watcher in a separate thread, a second process could be created between the time you notice the first one and the time you start watching again. And WMI won't pick it up retroactively. Obviously, if you're rolling your own polling loop then you can decide how often you *need* to check for the existence of a process -- ie how often you expect it to be created and how fast you need to react when it is. TJG From tibor.arpas at infinit.sk Wed Jul 16 15:55:15 2008 From: tibor.arpas at infinit.sk (Tibor Arpas) Date: Wed, 16 Jul 2008 15:55:15 +0200 Subject: [python-win32] COM Base Class and derived classes In-Reply-To: <01a901c8e6e0$5f417fd0$1dc47f70$@com.au> References: <19a7c8c20807150720t2ec11ef7m3691f6cc14d30d25@mail.gmail.com> <01a901c8e6e0$5f417fd0$1dc47f70$@com.au> Message-ID: <19a7c8c20807160655t2fb660c2y4b4b96d05276ee02@mail.gmail.com> Hi, I did use the makepy utility through pythonwin GUI (although I'm not sure It had any effect) >>> cs = s.ms.Document.ComponentSet >>> cs[4].TypeName # attribute of type Component u'Folder' >>> cs[4].Children # attribute of type Folder Traceback (most recent call last): File "", line 1, in File "C:\ActivePython25\Lib\site-packages\win32com\client\__init__.py", line 496, in __getattr__ if d is not None: return getattr(d, attr) File "C:\ActivePython25\Lib\site-packages\win32com\client\__init__.py", line 454, in __getattr__ raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) AttributeError: '' object has no attribute 'Children' >>> NOW APPLAYING YOUR ADVICE >>> f = win32com.client.CastTo(cs[4],"IFolder") >>> f.Children So yes, I can go this way, although it's much less elegant, then automatic casting. Thanks a lot, Tibor On Wed, Jul 16, 2008 at 3:07 AM, Mark Hammond wrote: > You probably want to look at using makepy and see if the behaviour > changes. > > > > Note too that the "name" displayed by win32com may not correspond to the > type of the object at all, particularly when makepy isn't used or for > whatever reason the object doesn't support type information. Are you > actually seeing a problem caused by what you describe? If so, what? If the > problem is that the methods etc from the sub-class aren't seen, then check > out win32com.client.CastTo() > > > > Cheers, > > > > Mark > > > > *From:* python-win32-bounces at python.org [mailto: > python-win32-bounces at python.org] *On Behalf Of *Tibor Arpas > *Sent:* Wednesday, 16 July 2008 12:20 AM > *To:* python-win32 at python.org > *Subject:* [python-win32] COM Base Class and derived classes > > > > Hi, > I'm new to both python and COM. I try to use the win32com.client. Many > things work like a charm, but I bumped into following problem. The COM > server has following hierarchy of types: > > Component (Base class) > -----Folder > -----Drawing > -----Image > -----Form > -----Script > ----- ...... > > The components are stored in a collection. When I try to access specific > component in my script I'm always getting the instance of "Component". > > >>> s.Document.ComponentSet['MyDrawing'] > .... instance of Component ...... > > > When I try the same thing in IronPython (the COM component has also .NET > interface and I use the clr library from IronPython), I get the specific > type. This confirms that at least some of my assumptions are right. > >>>s.Document.ComponentSet["MyDrawing"] > > > Can anybody give some pointers where to look and what to check? > Regards, > Tibor > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rdm at rcblue.com Thu Jul 17 06:11:53 2008 From: rdm at rcblue.com (Dick Moores) Date: Wed, 16 Jul 2008 21:11:53 -0700 Subject: [python-win32] Setting background color in Pythonwin Message-ID: <20080717041845.6CEBD1E4003@bag.python.org> Please see the image, . That's where I am in attempting to set the colors. How do I change all that white to the light green I have elsewhere, #CEECE (206, 233, 206)? Thanks, Dick Moores From rwupole at msn.com Thu Jul 17 07:30:15 2008 From: rwupole at msn.com (Roger Upole) Date: Thu, 17 Jul 2008 01:30:15 -0400 Subject: [python-win32] Re: Setting background color in Pythonwin Message-ID: Dick Moores wrote: > Please see the image, > . That's > where I am in attempting to set the colors. How do I change all that > white to the light green I have elsewhere, #CEECE (206, 233, 206)? > > Thanks, > > Dick Moores You might need to change all the individual elements to use the default background. It looks as if you've defined a separate background for some categories. The overall background can be set by selecting a background for Whitespace. Roger From rdm at rcblue.com Thu Jul 17 08:15:04 2008 From: rdm at rcblue.com (Dick Moores) Date: Wed, 16 Jul 2008 23:15:04 -0700 Subject: [python-win32] [Possible SPAM] Re: Setting background color in Pythonwin In-Reply-To: References: Message-ID: <20080717061522.A663E1E4003@bag.python.org> At 10:30 PM 7/16/2008, Roger Upole wrote: >Dick Moores wrote: >>Please see the image, >>. That's >>where I am in attempting to set the colors. How do I change all >>that white to the light green I have elsewhere, #CEECE (206, 233, 206)? >>Thanks, >>Dick Moores > >You might need to change all the individual elements to use the default >background. Yes, that's what it seems is necessary. Thanks. Dick From mhammond at skippinet.com.au Sat Jul 19 08:36:00 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 19 Jul 2008 16:36:00 +1000 Subject: [python-win32] How to get IWebBrowser2 from a HWND In-Reply-To: <67251.41765.qm@web25607.mail.ukl.yahoo.com> References: <67251.41765.qm@web25607.mail.ukl.yahoo.com> Message-ID: <052101c8e969$b8444960$28ccdc20$@com.au> I dug into this a little more, but I'm afraid there isn't much good news to share :( > What I would like to achieve is the IWebBrowser2 object of the > dialog.htm page. I know I can access anything on the page itself via > the IHTMLDocument2 (which I already have) but that's not my need. I can reproduce this your problem. I also added ObjectFromLresult to pywin32 - so getting the doc object from a HWND will (in pywin32-212) be as easy as: # See KB Q249232 hwnd = win32gui.FindWindow('IEFrame', None) for child_class in ['TabWindowClass', 'Shell DocObject View', 'Internet Explorer_Server']: hwnd = win32gui.FindWindowEx(hwnd, 0, child_class, None) msg = win32gui.RegisterWindowMessage("WM_HTML_GETOBJECT") rc, result = win32gui.SendMessageTimeout(hwnd, msg, 0, 0, win32con.SMTO_ABORTIFHUNG, 1000) ob = pythoncom.ObjectFromLresult(result, pythoncom.IID_IDispatch, 0) doc = Dispatch(ob) doc.bgColor = "red" (The above is the simple case - I understand your example was more complex due to the modal dialog). But as you said, you are already at that point with ctypes, and we move into your problem. From the code above, pywin32 can take over - it already has native support for IServiceProvider - so, something like the following, from your failing sample. ihtmlwin = doc.parentWindow # ... the service provider ... pIServiceProvider = ihtmlwin._oleobj_.QueryInterface(pythoncom.IID_IServiceProvider) # ... and the IWebBrowser2: ie = pIServiceProvider.QueryService(IID_IWebBrowserApp, IID_IWebBrowserApp) And the problem I see is that QueryService *always* fail with E_NOINTERFACE, regardless of the interface requested as the second param. Even IUnknown fails, which doesn't make sense, so my conclusion is that the object is simply refusing to return that service (rather than failing to return the interface for the service). The docs imply IE should indeed work here, so I suspect the issue relates specifically to the modal window. I'm afraid I ran out of time on this issue to confirm the QueryService worked in the "normal" case - I just got far enough to ensure myself the problem wasn't related to Python ;) Hope your are progressing regardless ;) Cheers, Mark From galaviel at yahoo.com Sun Jul 20 14:21:40 2008 From: galaviel at yahoo.com (Gal Aviel) Date: Sun, 20 Jul 2008 12:21:40 +0000 (UTC) Subject: [python-win32] Registering 3rd party DLLs Message-ID: Hello All, I posted a related question in the py2exe mailing list, only to realize that the issue might be more related to this mailing list ... I'm distributing a python application as a self-contained executable using py2exe. My application relies on several 3rd party DLLs which I am trying to bundle w/ my app. Of the about 10 DLLs, one is a COM server that needs to be registered with windows (regsvr32 on the windows shell). I already know about win32com.server.register.UseCommandLine() however it accepts a python class; is there a corresponding method for registering real, Physical DLL file? I want to try to register the DLL pro programaticaly from my python code. Many thanks in advance :) Gal. From singhai.nish at gmail.com Mon Jul 21 07:24:41 2008 From: singhai.nish at gmail.com (kNish) Date: Mon, 21 Jul 2008 10:54:41 +0530 Subject: [python-win32] sort error Message-ID: <81bfef2e0807202224s2cbde606h2ffc721928504096@mail.gmail.com> Hi, I have had this issue for long now. Is it possible to have a work around for this. When these commands are run singly, they give a result. When run inside a script, the second line does not give a result. What is a possible work around for this. BkFiles.sort(key=str.upper) last_bk_File_Name = BkFiles[len(BkFiles)-1] BRgds, kNish -------------- next part -------------- An HTML attachment was scrubbed... URL: From singhai.nish at gmail.com Mon Jul 21 07:44:25 2008 From: singhai.nish at gmail.com (knish) Date: Sun, 20 Jul 2008 22:44:25 -0700 (PDT) Subject: [python-win32] error in list length In-Reply-To: References: <81bfef2e0807092249q429ac3denf86fea06c211631b@mail.gmail.com> Message-ID: <18562507.post@talk.nabble.com> Hi, Thank you for your reply. I will remember your point and send the code from the console. BRgds, kNish Larry Bates wrote: > > kNish wrote: >> Hi, >> >> The following lines of code gives an error starting with >> line where len() is used >> >> >> local_BkFiles = glob.glob(localDirectoryName+'\\*' + >> data + '*bk*') >> local_BkFiles.sort(key=str.upper) >> last_pv_File_Name = local_PvFiles[len(local_PvFiles)-1] >> split_last_pv_File_Name = >> re.search(data+"_bk[0-9]{2}_[a-z]{3}_pv[0-9]{2}",last_pv_File_Name ) >> lastPv_FileVersion = >> re.search('(?<=pv)\d+',split_last_pv_File_Name.group(0)) >> >> >> This code is being called in a procedure or function def. How may I >> solve this. >> >> >> BRgds, >> >> >> kNish >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 > > Since you didn't post your full traceback (you should always do that in > the > future), we are guessing: > > local_PvFiles isn't defined prior to trying to determine its length. > > The way to get the last element of a list is: > > local_PvFiles[-1] > > you don't need to do all the length gymnastics. > > I'm no regex expert, so I'll leave that part to someone else but if the > filenames are a fixed format, you don't need regex at all to extract the > version. If it is a completely variable format, then you would. > > -Larry > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- View this message in context: http://www.nabble.com/error-in-list-length-tp18376387p18562507.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From siddhartha.veedaluru at gmail.com Mon Jul 21 10:41:46 2008 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Mon, 21 Jul 2008 14:11:46 +0530 Subject: [python-win32] Cannot import "pyodbc" module Message-ID: <424b71ec0807210141oa2d1603ob53f715ac9564052@mail.gmail.com> Hi, Getting the following error while i install the pyodbc module and import it >>> import pyodbc Traceback (most recent call last): File "", line 1, in import pyodbc ImportError: DLL load failed with error code 193 i have installed win32it pyodbc module in a x64 Win 2003 os already having python in it. importing the pyodbc module gives the above error. i couldn't able to get x64 bit version of it. hence used 32bit one. Please help. Regards, siddhartha -------------- next part -------------- An HTML attachment was scrubbed... URL: From rwupole at msn.com Mon Jul 21 10:52:33 2008 From: rwupole at msn.com (Roger Upole) Date: Mon, 21 Jul 2008 04:52:33 -0400 Subject: [python-win32] Re: Cannot import "pyodbc" module Message-ID: "siddhartha veedaluru" wrote in message news:424b71ec0807210141oa2d1603ob53f715ac9564052 at mail.gmail.com... > Hi, > > Getting the following error while i install the pyodbc module and import > it > >>>> import pyodbc > Traceback (most recent call last): > File "", line 1, in > import pyodbc > ImportError: DLL load failed with error code 193 > > i have installed win32it pyodbc module in a x64 Win 2003 os already having > python in it. > importing the pyodbc module gives the above error. > > i couldn't able to get x64 bit version of it. > hence used 32bit one. > > Please help. > > Regards, > siddhartha > Modules compiled as 32-bit won't work with 64-bit python. If there isn't a 64-bit version of pyodbc, you'll need to stick with 32-bit python (which continues to run well on 64-bit systems). Roger From mail at timgolden.me.uk Mon Jul 21 11:02:49 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 21 Jul 2008 10:02:49 +0100 Subject: [python-win32] Cannot import "pyodbc" module In-Reply-To: References: Message-ID: <488450B9.7010405@timgolden.me.uk> Roger Upole wrote: > Modules compiled as 32-bit won't work with 64-bit python. > If there isn't a 64-bit version of pyodbc, you'll need to stick > with 32-bit python (which continues to run well on > 64-bit systems). I wonder whether (he says, talking to the air) it would be worth mentioning something brief to this effect on the main Python site. I'm just having to do with 64-bit now as our work servers go that way, and I can't say I'm really clued-up on these kind of issues. I can just imagine newcomers diving into the 64-bit .msi (because I've got a 64-bit server, so why not?) and then falling down this particular hole. TJG From larry.bates at websafe.com Mon Jul 21 20:02:53 2008 From: larry.bates at websafe.com (Larry Bates) Date: Mon, 21 Jul 2008 13:02:53 -0500 Subject: [python-win32] sort error In-Reply-To: <81bfef2e0807202224s2cbde606h2ffc721928504096@mail.gmail.com> References: <81bfef2e0807202224s2cbde606h2ffc721928504096@mail.gmail.com> Message-ID: kNish wrote: > Hi, I have had this issue for long now. Is it possible to have a work > around for this. When these commands are run singly, they give a result. > When run inside a script, the second line does not give a result. What > is a possible work around for this. BkFiles.sort(key=str.upper) > last_bk_File_Name = BkFiles[len(BkFiles)-1] BRgds, kNish > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 It is a little hard to read your code but I'll try: Your code: BkFiles.sort(key=str.upper) last_bk_File_Name = BkFiles[len(BkFiles)-1] # BRgds, kNish # # Not clear what this is supposed to do???? # This line should cause a syntax error. You can more easily write the second line as: last_bk_File_Name = BkFiles[-1] -Larry From larry.bates at websafe.com Mon Jul 21 20:04:38 2008 From: larry.bates at websafe.com (Larry Bates) Date: Mon, 21 Jul 2008 13:04:38 -0500 Subject: [python-win32] Registering 3rd party DLLs In-Reply-To: References: Message-ID: <4884CFB6.6010705@websafe.com> Gal Aviel wrote: > Hello All, > > I posted a related question in the py2exe mailing list, only to realize > that the issue might be more related to this mailing list ... > > I'm distributing a python application as a self-contained executable > using py2exe. > > My application relies on several 3rd party DLLs which I am trying > to bundle w/ my app. > > Of the about 10 DLLs, one is a COM server that needs to be > registered with windows (regsvr32 on the windows shell). > > I already know about win32com.server.register.UseCommandLine() however > it accepts a python class; is there a corresponding method for > registering real, Physical DLL file? I want to try to register > the DLL pro programaticaly from my python code. > > Many thanks in advance :) > > Gal. Your question has been answered on the other list, but here goes. Get a copy of Inno Setup and use it to create a Windows installer (e.g. setup.exe) file that packages everything up into a single distributable file. It can take care of registering the COM dlls during installation. -Larry From larry.bates at websafe.com Mon Jul 21 20:07:02 2008 From: larry.bates at websafe.com (Larry Bates) Date: Mon, 21 Jul 2008 13:07:02 -0500 Subject: [python-win32] Cannot import "pyodbc" module In-Reply-To: <488450B9.7010405@timgolden.me.uk> References: <488450B9.7010405@timgolden.me.uk> Message-ID: Tim Golden wrote: > Roger Upole wrote: >> Modules compiled as 32-bit won't work with 64-bit python. >> If there isn't a 64-bit version of pyodbc, you'll need to stick >> with 32-bit python (which continues to run well on >> 64-bit systems). > > > I wonder whether (he says, talking to the air) it would be worth > mentioning something brief to this effect on the main Python > site. I'm just having to do with 64-bit now as our work servers > go that way, and I can't say I'm really clued-up on these kind > of issues. I can just imagine newcomers diving into the 64-bit > .msi (because I've got a 64-bit server, so why not?) and then > falling down this particular hole. > > > TJG Tim, Mark Hammond made a post on py2exe asking for input about this 32/64 bit issue last week. I think it is going to become a bigger issue this year. FYI, Larry From venturasalvatore at yahoo.it Tue Jul 22 01:51:51 2008 From: venturasalvatore at yahoo.it (salvatore ventura) Date: Mon, 21 Jul 2008 23:51:51 +0000 (GMT) Subject: [python-win32] How to get IWebBrowser2 from a HWND In-Reply-To: <052101c8e969$b8444960$28ccdc20$@com.au> Message-ID: <456787.17415.qm@web25605.mail.ukl.yahoo.com> Hi Mark, thanks for helping out. I have tried the same QueryInterface but this time on the 'main' window (no popup open), this time looking for the 'IEFrame' class, and then following the same steps as in my popup example, but this time, the QueryInterface seems to happily return a 'number'. I couldn't figure out what that number is (handle? pointer? to what?). Here the code: win1 = win32gui.FindWindow('IEFrame', 'Test main page - Windows Internet Explorer') #IE window handle win1 = winGuiAuto.findControl(win1, None, 'Internet Explorer_Server', None) # get the 'Internet Explorer_Server # get the IHTMLDocument2 of the popup dialog oleacc = oledll.LoadLibrary ( 'oleacc.dll' ) WM_HTML_GETOBJECT = windll.user32.RegisterWindowMessageA ('WM_HTML_GETOBJECT' ) lResult = c_ulong ( ) ret = windll.user32.SendMessageTimeoutA ( c_int ( win1 ), c_int (WM_HTML_GETOBJECT),c_int ( 0 ), c_int ( 0 ), c_int ( SMTO_ABORTIFHUNG ), c_int ( 1000 ), byref (lResult ) ) pIHTMLDocument2 = POINTER ( IHTMLDocument2 ) ( ) oleacc.ObjectFromLresult ( lResult, byref ( IHTMLDocument2._iid_ ), 0,byref (pIHTMLDocument2 ) ) # title of the page verifies ihtmlwin = pIHTMLDocument2.parentWindow # and the IServiceProvider pIServiceProvider = POINTER ( IServiceProvider ) () pIServiceProvider = ihtmlwin.QueryInterface(IServiceProvider, IServiceProvider._iid_) ie = POINTER(IWebBrowser2) () ie = pIServiceProvider.QueryService(IWebBrowserApp._iid_, IWebBrowser2._iid_) # this one doesn't bump... I have found my way around my problem, although with a major change in my approach and class structures. One more question, that might have been already asked: the difference between pythoncom and ctypes. I think I am mixing them up in my code and concepts still... thanks again, .salvo --- Ven 18/7/08, Mark Hammond ha scritto: > Da: Mark Hammond > Oggetto: RE: [python-win32] How to get IWebBrowser2 from a HWND > A: "'salvatore ventura'" , python-win32 at python.org > Data: Venerd? 18 luglio 2008, 23:36 > I dug into this a little more, but I'm afraid there > isn't much good news to share :( > > > What I would like to achieve is the IWebBrowser2 > object of the > > dialog.htm page. I know I can access anything on the > page itself via > > the IHTMLDocument2 (which I already have) but > that's not my need. > > I can reproduce this your problem. I also added > ObjectFromLresult to pywin32 - so getting the doc object > from a HWND will (in pywin32-212) be as easy as: > > # See KB Q249232 > hwnd = win32gui.FindWindow('IEFrame', None) > for child_class in ['TabWindowClass', > 'Shell DocObject View', > 'Internet > Explorer_Server']: > hwnd = win32gui.FindWindowEx(hwnd, 0, child_class, > None) > msg = > win32gui.RegisterWindowMessage("WM_HTML_GETOBJECT") > rc, result = win32gui.SendMessageTimeout(hwnd, msg, 0, > 0, win32con.SMTO_ABORTIFHUNG, 1000) > ob = pythoncom.ObjectFromLresult(result, > pythoncom.IID_IDispatch, 0) > doc = Dispatch(ob) > doc.bgColor = "red" > > (The above is the simple case - I understand your example > was more complex due to the modal dialog). But as you > said, you are already at that point with ctypes, and we > move into your problem. From the code above, pywin32 can > take over - it already has native support for > IServiceProvider - so, something like the following, from > your failing sample. > > ihtmlwin = doc.parentWindow > # ... the service provider ... > pIServiceProvider = > ihtmlwin._oleobj_.QueryInterface(pythoncom.IID_IServiceProvider) > # ... and the IWebBrowser2: > ie = pIServiceProvider.QueryService(IID_IWebBrowserApp, > IID_IWebBrowserApp) > > And the problem I see is that QueryService *always* fail > with E_NOINTERFACE, regardless of the interface requested > as the second param. Even IUnknown fails, which > doesn't make sense, so my conclusion is that the object > is simply refusing to return that service (rather than > failing to return the interface for the service). The docs > imply IE should indeed work here, so I suspect the issue > relates specifically to the modal window. I'm afraid I > ran out of time on this issue to confirm the QueryService > worked in the "normal" case - I just got far > enough to ensure myself the problem wasn't related to > Python ;) > > Hope your are progressing regardless ;) > > Cheers, > > Mark From larry.bates at websafe.com Tue Jul 22 03:29:23 2008 From: larry.bates at websafe.com (Larry Bates) Date: Mon, 21 Jul 2008 20:29:23 -0500 Subject: [python-win32] error in list length In-Reply-To: <18562507.post@talk.nabble.com> References: <81bfef2e0807092249q429ac3denf86fea06c211631b@mail.gmail.com> <18562507.post@talk.nabble.com> Message-ID: knish wrote: > Hi, > > Thank you for your reply. I will remember your point and send the code > from the console. > > BRgds, > > kNish > > > Larry Bates wrote: >> kNish wrote: >>> Hi, >>> >>> The following lines of code gives an error starting with >>> line where len() is used >>> >>> >>> local_BkFiles = glob.glob(localDirectoryName+'\\*' + >>> data + '*bk*') >>> local_BkFiles.sort(key=str.upper) >>> last_pv_File_Name = local_PvFiles[len(local_PvFiles)-1] >>> split_last_pv_File_Name = >>> re.search(data+"_bk[0-9]{2}_[a-z]{3}_pv[0-9]{2}",last_pv_File_Name ) >>> lastPv_FileVersion = >>> re.search('(?<=pv)\d+',split_last_pv_File_Name.group(0)) >>> >>> >>> This code is being called in a procedure or function def. How may I >>> solve this. >>> >>> >>> BRgds, >>> >>> >>> kNish >>> >>> >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> python-win32 mailing list >>> python-win32 at python.org >>> http://mail.python.org/mailman/listinfo/python-win32 >> Since you didn't post your full traceback (you should always do that in >> the >> future), we are guessing: >> >> local_PvFiles isn't defined prior to trying to determine its length. >> >> The way to get the last element of a list is: >> >> local_PvFiles[-1] >> >> you don't need to do all the length gymnastics. >> >> I'm no regex expert, so I'll leave that part to someone else but if the >> filenames are a fixed format, you don't need regex at all to extract the >> version. If it is a completely variable format, then you would. >> >> -Larry >> >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> >> > What "this" to you want to solve? I see no traceback, no listing of files, no explanation of what you are trying to do. Help us try to help you. Taking a second look, You sort local_BkFiles: local_BkFiles.sort(key=str.upper) Then you access local_PvFiles: last_pv_File_Name = local_PvFiles[len(local_PvFiles)-1] did you mean local_BkFiles? (a full traceback would have pointed that out immediately) -Larry From wegraps at gmail.com Tue Jul 22 08:34:50 2008 From: wegraps at gmail.com (Graps Graps) Date: Tue, 22 Jul 2008 12:04:50 +0530 Subject: [python-win32] How to replace the values with keys ? Message-ID: <92df0f7c0807212334w5911c307l29db5d8855c8ad0@mail.gmail.com> Hi all, I am a newbie to python... I have two text files text1 and text2. Text1 is a tabbed separated file, say like a b a c a d a g b c b d b h c d c h... and so on.. Text2 is a python dictionary containing data as {0: 'a', 1: 'b', 2: 'c'...} now I want the data in text1 to be replaced with the keys, say like 0 1 0 2 0 3 0 6 1 2... so on.. Is there some way I could do it in python? Thanking in advance.., GraPs -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Jul 22 14:34:41 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 22 Jul 2008 13:34:41 +0100 Subject: [python-win32] com_error Unicode problems Message-ID: <4885D3E1.1080304@timgolden.me.uk> There's a thread over on c.l.py which concerns the error messages returned from the WMI module, which uses win32com.client and all its works and promises... http://mail.python.org/pipermail/python-list/2008-July/499172.html The OP is running on a Simple Chinese edition of Windows XP, and the error message, naturally, returns Simple Chinese characters. But... it's apparent that the com_error info structure returns not Unicode but byte stream. I *think* I can decode into Unicode by using the sys.stdout.encoding, but even if I'm right that's a fragile solution: running under the SciTE editor, eg, sys.stdout.encoding is None. So, a couple of questions: 1) Is there some API which will tell me: non-Unicode error messages can be converted to Unicode *thus*. I've looked around, but there's nothing too obvious. 2) How onerous would it be to change PyCom_BuildPyException to call FormatMessageW and to return true Unicode objects? Non-trivial, I imagine, since that function's called everywhere, but maybe now's the time...? [... three questions; nobody expects ...] 3) Is there something more obvious which I've missed? An alternative which occurs to me is to call FormatMessageW myself from my own code, given the hresult, but I'd rather that were a workaround rather than a solution. TJG From larry.bates at websafe.com Tue Jul 22 15:12:57 2008 From: larry.bates at websafe.com (Larry Bates) Date: Tue, 22 Jul 2008 08:12:57 -0500 Subject: [python-win32] How to replace the values with keys ? In-Reply-To: <92df0f7c0807212334w5911c307l29db5d8855c8ad0@mail.gmail.com> References: <92df0f7c0807212334w5911c307l29db5d8855c8ad0@mail.gmail.com> Message-ID: Graps Graps wrote: > Hi all, > > I am a newbie to python... I have two text files text1 and text2. Text1 > is a tabbed separated file, say like > > a b > a c > a d > a g > b c > b d > b h > c d > c h... and so on.. > > Text2 is a python dictionary containing data as > > {0: 'a', 1: 'b', 2: 'c'...} > > now I want the data in text1 to be replaced with the keys, say like > > 0 1 > 0 2 > 0 3 > 0 6 > 1 2... so on.. > Is there some way I could do it in python? > > Thanking in advance.., > GraPs > > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 This list is for questions about Python's Win32 extensions and Python's interfaces to Windows. I don't see anything in your post that relates to either of these issues. You should try comp.lang.python instead. The short answer to your question is "yes". But since you didn't show us that you have actually tried anything AND this looks a lot like a homework problem, I will leave you to actually post something that you have done before answering further. -Larry From lynton.grice at netweaverguru.com Tue Jul 22 16:25:23 2008 From: lynton.grice at netweaverguru.com (Lynton Grice) Date: Tue, 22 Jul 2008 16:25:23 +0200 Subject: [python-win32] MSMQ - cannot catch COM_ERROR with"pythoncom.com_error" Message-ID: <001701c8ec06$cab46cc0$8ee3ed9b@logos> Hi there, Please help me ;-) I know how to push / pop messages off of a MSMQ, also how to create a queue etc.....but my problem is I cannot seen to catch the "com_error" when I try create a MSMQ that already exists ;-( The basic code is as follows: import win32com.client import pythoncom import os try: queue_info = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") computer_name = os.getenv('COMPUTERNAME') format_name = "direct=os:" + computer_name + "\\private$\\test3" queue_info.FormatName=format_name queue=queue_info.Open(2,0) "Dies here obviously as queue does not exist except pythoncom.com_error: #Queue does not exist...create queue.... queue_info.PathName = ".\\private$\\test3" queue_info.Label = "New Queue" queue_info.Create() I get an Exception raised in WingIDE that says something like "com_error......the queue does not exist or you do not have sufficient permissions etc" - something like that..... This is the line in "IMSMQQueueInfo3.py" that it is dying on..... def Open(self, Access=defaultNamedNotOptArg, ShareMode=defaultNamedNotOptArg): """Method used to open a queue. The PathName property must be specified to open a queue. Parameters include Access (send, peek, or receive) and ShareMode (exclusive or all).""" ret = self._oleobj_.InvokeTypes(1610743835, LCID, 1, (9, 0), ((3, 1), (3, 1)),Access , ShareMode) Here is the wingide error.... http://www.nabble.com/file/p18586458/error.png File "D:\Documents and Settings\Lynton\Desktop\test_reg.py", line 10, in ? queue=queue_info.Open(2,0) File "D:\Python24\Lib\site-packages\win32com\gen_py\D7D6E071-DCCD-11D0-AA4B-00609 70DEBAEx0x3x0\IMSMQQueueInfo3.py", line 46, in Open , ShareMode) Any ideas on how I can catch ANY COM type error here? Why would it ignore the pythoncom.com_error??? Your help would be greatly appreciated ;-) Lynton -- View this message in context: http://www.nabble.com/MSMQ---cannot-catch-COM_ERROR-with-%22pythoncom.com_er ror%22-tp18586458p18586458.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From mail at timgolden.me.uk Tue Jul 22 17:20:32 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 22 Jul 2008 16:20:32 +0100 Subject: [python-win32] MSMQ - cannot catch COM_ERROR with"pythoncom.com_error" In-Reply-To: <001701c8ec06$cab46cc0$8ee3ed9b@logos> References: <001701c8ec06$cab46cc0$8ee3ed9b@logos> Message-ID: <4885FAC0.3000303@timgolden.me.uk> Lynton Grice wrote: > Please help me ;-) I know how to push / pop messages off of a MSMQ, also how > to create a queue etc.....but my problem is I cannot seen to catch the > "com_error" when I try create a MSMQ that already exists ;-( The basic code > is as follows: > > import win32com.client > import pythoncom > import os > > try: > queue_info = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") > computer_name = os.getenv('COMPUTERNAME') > format_name = "direct=os:" + computer_name + "\\private$\\test3" > > queue_info.FormatName=format_name > queue=queue_info.Open(2,0) "Dies here obviously as queue does not exist > except pythoncom.com_error: > #Queue does not exist...create queue.... > queue_info.PathName = ".\\private$\\test3" > queue_info.Label = "New Queue" > queue_info.Create() > > I get an Exception raised in WingIDE that says something like > "com_error......the queue does not exist or you do not have sufficient > permissions etc" - something like that..... I can't see anything obvious (aside from the possible dangers inherent in assuming that *any* com_error means the queue doesnt' exist). I assume that the -- "Dies here... -- isn't in the original code? Does the same thing happen if you run in the standard interpreter? (Don't know if WingIDE does anything fancy to intercept exceptions). If the same does happen in the interpreter, can you use the traceback module / sys.exc_info to determine exactly what exception is raised and how it relates to pythoncom.com_error? TJG From timr at probo.com Tue Jul 22 18:39:18 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 22 Jul 2008 09:39:18 -0700 Subject: [python-win32] How to replace the values with keys ? In-Reply-To: <92df0f7c0807212334w5911c307l29db5d8855c8ad0@mail.gmail.com> References: <92df0f7c0807212334w5911c307l29db5d8855c8ad0@mail.gmail.com> Message-ID: <48860D36.5050406@probo.com> Graps Graps wrote: > Hi all, > > I am a newbie to python... I have two text files text1 and text2. > Text1 is a tabbed separated file, say like > > a b > a c > a d > a g > b c > b d > b h > c d > c h... and so on.. > > Text2 is a python dictionary containing data as > > {0: 'a', 1: 'b', 2: 'c'...} > > now I want the data in text1 to be replaced with the keys, say like > > 0 1 > 0 2 > 0 3 > 0 6 > 1 2... so on.. > Is there some way I could do it in python? reverseText2 = dict( (b,a) for a,b in Text2.items() ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From wegraps at gmail.com Wed Jul 23 06:32:08 2008 From: wegraps at gmail.com (Graps Graps) Date: Wed, 23 Jul 2008 10:02:08 +0530 Subject: [python-win32] How to replace the values with keys ? In-Reply-To: References: <92df0f7c0807212334w5911c307l29db5d8855c8ad0@mail.gmail.com> Message-ID: <92df0f7c0807222132h2f5e21b0t491439749c327992@mail.gmail.com> Hi all, I tried import aDict import re infile = open('text1.txt','rw') outfile = open('text3.txt','w') def replace_words(infile, aDict): rc=re.compile('|'.join(map(re.escape, aDict))) def translate(match): return aDict[match.group(0)] return rc.sub(translate, infile) outfile = replace_words(infile,aDict) I am thrown with: Traceback (most recent call last): File "", line 1, in File "", line 2, in replace_words TypeError: argument 2 to map() must support iteration I imported text2.txt , containing python dictionary as aDict.py. I want the replaced values in a separate file text3.txt. Thanking in advance.., GraPs On Tue, Jul 22, 2008 at 6:42 PM, Larry Bates wrote: > Graps Graps wrote: > >> Hi all, >> >> I am a newbie to python... I have two text files text1 and text2. Text1 is >> a tabbed separated file, say like >> >> a b >> a c >> a d >> a g >> b c >> b d >> b h >> c d >> c h... and so on.. >> >> Text2 is a python dictionary containing data as >> >> {0: 'a', 1: 'b', 2: 'c'...} >> >> now I want the data in text1 to be replaced with the keys, say like >> >> 0 1 >> 0 2 >> 0 3 >> 0 6 >> 1 2... so on.. >> Is there some way I could do it in python? >> >> Thanking in advance.., >> GraPs >> >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> > > This list is for questions about Python's Win32 extensions and Python's > interfaces to Windows. I don't see anything in your post that relates to > either of these issues. You should try comp.lang.python instead. > > The short answer to your question is "yes". But since you didn't show us > that you have actually tried anything AND this looks a lot like a homework > problem, I will leave you to actually post something that you have done > before answering further. > > -Larry > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From siddhartha.veedaluru at gmail.com Wed Jul 23 07:52:18 2008 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Wed, 23 Jul 2008 11:22:18 +0530 Subject: [python-win32] 32bit python on x64 bit machine cannot access registry Message-ID: <424b71ec0807222252i24df9cebi26b27bbf7bf19e3e@mail.gmail.com> Hello i cannot access some of the values from registry using 32bit python on x64bit machine i need to install 32bit because i couldn't get x64bit pyodbc module. Can anyone know where can i get the x64 version pyodbc. or solution to the above problem. thanks Siddhartha -------------- next part -------------- An HTML attachment was scrubbed... URL: From rwupole at msn.com Wed Jul 23 09:18:53 2008 From: rwupole at msn.com (Roger Upole) Date: Wed, 23 Jul 2008 03:18:53 -0400 Subject: [python-win32] Re: 32bit python on x64 bit machine cannot access Message-ID: siddhartha veedaluru wrote: > Hello > > i cannot access some of the values from registry using > 32bit python on x64bit machine > > i need to install 32bit because i couldn't get x64bit pyodbc module. > Can anyone know where can i get the x64 version pyodbc. > > or solution to the above problem. > > thanks > Siddhartha You can pass KEY_WOW64_64KEY as part of the access mask when opening a key. Roger From niki at vintech.bg Wed Jul 23 09:32:52 2008 From: niki at vintech.bg (niki) Date: Wed, 23 Jul 2008 10:32:52 +0300 Subject: [python-win32] com_error Unicode problems In-Reply-To: <4885D3E1.1080304@timgolden.me.uk> References: <4885D3E1.1080304@timgolden.me.uk> Message-ID: <4886DEA4.7050607@vintech.bg> Tim Golden wrote: > There's a thread over on c.l.py which concerns the error messages > returned from the WMI module, which > uses win32com.client and all its works and promises... > > http://mail.python.org/pipermail/python-list/2008-July/499172.html > > The OP is running on a Simple Chinese edition of Windows XP, > and the error message, naturally, returns Simple Chinese > characters. But... it's apparent that the com_error info > structure returns not Unicode but byte stream. I *think* > I can decode into Unicode by using the sys.stdout.encoding, > but even if I'm right that's a fragile solution: running > under the SciTE editor, eg, sys.stdout.encoding is None. > > So, a couple of questions: > > 1) Is there some API which will tell me: non-Unicode error > messages can be converted to Unicode *thus*. I've looked > around, but there's nothing too obvious. > > 2) How onerous would it be to change PyCom_BuildPyException > to call FormatMessageW and to return true Unicode objects? > Non-trivial, I imagine, since that function's called everywhere, > but maybe now's the time...? > > [... three questions; nobody expects ...] > > 3) Is there something more obvious which I've missed? Yes use 'mbcs' codec :) HTH Niki Spahiev From mhammond at skippinet.com.au Wed Jul 23 09:40:28 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 23 Jul 2008 17:40:28 +1000 Subject: [python-win32] 32bit python on x64 bit machine cannot access registry In-Reply-To: <424b71ec0807222252i24df9cebi26b27bbf7bf19e3e@mail.gmail.com> References: <424b71ec0807222252i24df9cebi26b27bbf7bf19e3e@mail.gmail.com> Message-ID: <087801c8ec97$65ec7030$31c55090$@com.au> > i cannot access some of the values from registry using > 32bit python on x64bit machine See the article at http://blogs.msdn.com/junfeng/archive/2004/04/05/107433.aspx for an overview of how the registry works in such systems. The short story is that you can combine the value KEY_WOW64_64KEY (==256) with the 'samDesired' paramater to win32api.RegOpenKey/_winreg.OpenKey and the CreateKey versions. I've personally used: if win32process.IsWow64Process(win32process.GetCurrentProcess()): reg_flags |= KEY_WOW64_64KEY to achieve that (which requires pywin32-211) Hope that helps, Mark From mail at timgolden.me.uk Wed Jul 23 12:40:08 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 23 Jul 2008 11:40:08 +0100 Subject: [python-win32] com_error Unicode problems In-Reply-To: <4886DEA4.7050607@vintech.bg> References: <4885D3E1.1080304@timgolden.me.uk> <4886DEA4.7050607@vintech.bg> Message-ID: <48870A88.6020408@timgolden.me.uk> niki wrote: > Tim Golden wrote: >> The OP is running on a Simple Chinese edition of Windows XP, >> and the error message, naturally, returns Simple Chinese >> characters. But... it's apparent that the com_error info >> structure returns not Unicode but byte stream. I *think* >> I can decode into Unicode by using the sys.stdout.encoding, >> but even if I'm right that's a fragile solution: running >> under the SciTE editor, eg, sys.stdout.encoding is None. >> 3) Is there something more obvious which I've missed? > > Yes use 'mbcs' codec :) > > HTH > > Niki Spahiev Thank you so much. I knew there'd be something nice and obvious which I'd overlooked. TJG From siddhartha.veedaluru at gmail.com Wed Jul 23 12:57:19 2008 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Wed, 23 Jul 2008 16:27:19 +0530 Subject: [python-win32] python-win32 Digest, Vol 64, Issue 25 In-Reply-To: References: Message-ID: <424b71ec0807230357l1a3c7cadt9f3daeb5f0e05b11@mail.gmail.com> Hi, Tried the following snippet: import os, sys from _winreg import * KEY_WOW64_64KEY = 256 regHandle = OpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\Myapp\Base",0,KEY_WOW64_64KEY) val = QueryValue(regHandle,"nPLATTYPE") print val Got the following error Traceback (most recent call last): File "C:\Precert\test.py", line 4, in regHandle = OpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\MyApp\Base",0,KEY_WOW64_64KEY) WindowsError: [Error 5] Access is denied Please help,. regards Sid -------------- next part -------------- An HTML attachment was scrubbed... URL: From siddhartha.veedaluru at gmail.com Wed Jul 23 12:58:35 2008 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Wed, 23 Jul 2008 16:28:35 +0530 Subject: [python-win32] python-win32 Digest, Vol 64, Issue 25 In-Reply-To: <424b71ec0807230357l1a3c7cadt9f3daeb5f0e05b11@mail.gmail.com> References: <424b71ec0807230357l1a3c7cadt9f3daeb5f0e05b11@mail.gmail.com> Message-ID: <424b71ec0807230358u51594846i4e2389d55b516f06@mail.gmail.com> On Wed, Jul 23, 2008 at 4:27 PM, siddhartha veedaluru < siddhartha.veedaluru at gmail.com> wrote: > Hi, > > Tried the following snippet: > > import os, sys > from _winreg import * > KEY_WOW64_64KEY = 256 > regHandle = > OpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\Myapp\Base",0,KEY_WOW64_64KEY) > val = QueryValue(regHandle,"nPLATTYPE") > print val > Got the following error > > Traceback (most recent call last): > File "C:\Precert\test.py", line 4, in > regHandle = > OpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\MyApp\Base",0,KEY_WOW64_64KEY) > WindowsError: [Error 5] Access is denied > > Please help,. > > regards > Sid > -------------- next part -------------- An HTML attachment was scrubbed... URL: From njp at njp.us Wed Jul 23 15:30:59 2008 From: njp at njp.us (Norm Petterson) Date: Wed, 23 Jul 2008 09:30:59 -0400 Subject: [python-win32] python-win32 Digest, Vol 64, Issue 25 In-Reply-To: <424b71ec0807230357l1a3c7cadt9f3daeb5f0e05b11@mail.gmail.com> References: <424b71ec0807230357l1a3c7cadt9f3daeb5f0e05b11@mail.gmail.com> Message-ID: <9670a730807230630o3f3748f8o5ffcebd055458629@mail.gmail.com> Google is your friend. Of the many references, he first for "WindowsError: [Error 5] Access is denied" probably answers your question ;-)... On Wed, Jul 23, 2008 at 6:57 AM, siddhartha veedaluru < siddhartha.veedaluru at gmail.com> wrote: > Hi, > > Tried the following snippet: > > import os, sys > from _winreg import * > KEY_WOW64_64KEY = 256 > regHandle = > OpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\Myapp\Base",0,KEY_WOW64_64KEY) > val = QueryValue(regHandle,"nPLATTYPE") > print val > Got the following error > > Traceback (most recent call last): > File "C:\Precert\test.py", line 4, in > regHandle = > OpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\MyApp\Base",0,KEY_WOW64_64KEY) > WindowsError: [Error 5] Access is denied > > Please help,. > > regards > Sid > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jr9445 at ATT.COM Wed Jul 23 16:41:36 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Wed, 23 Jul 2008 09:41:36 -0500 Subject: [python-win32] Problem with TLB file and COM Message-ID: I'm having trouble with a COM object for which none of its methods are available at runtime. The COM class is defined in a tlb file. I used "makepy -i", added the gencache lines to the program, and can see the methods in the generated file. However, when I try to call any method, it blows up with a DISPATCH_METHOD flag error. The equivalent code works just fine in Perl. Anyone have any idea why a COM object defined in a tlb file would be so problematic in Python? === program === import win32com.client from win32com.client import gencache gencache.EnsureModule('{A5B37030-06D9-11D2-A58A-006097B17A75}', 0, 4, 0) gui = win32com.client.Dispatch("ReqPro40.GUIApp") print gui print print dir(gui) print print 'showword =', gui.ShowWord() == output == ['_ApplyTypes_', '_FlagAsMethod', '_LazyAddAttr_', '_NewEnum', '_Release_', '__AttrToID__', '__LazyMap__', '__call__', '__cmp__', '__doc__', '__getattr__', '__getitem__', '__init__', '__int__', '__len__', '__module__', '__nonzero__', '__repr__', '__setattr__', '__setitem__', '__str__', '_builtMethods_', '_enum_', '_find_dispatch_type_', '_get_good_object_', '_get_good_single_object_', '_lazydata_', '_make_method_', '_mapCachedItems_', '_oleobj_', '_olerepr_', '_print_details_', '_proc_', '_unicode_to_string_', '_username_', '_wrap_dispatch_'] showword = Traceback (most recent call last): File "D:\mydata\dev\reqpro\renumber\c.py", line 13, in print 'showword =', gui.ShowWord() File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 491, in __getattr__ raise pythoncom.com_error, details pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Smalltalk', 'Incorrect dispatch invocation flags: DISPATCH_METHOD flag not set for method ShowWord.', None, 0, 0), None) === snippets of gen file ==== CLSID = IID('{A5B37030-06D9-11D2-A58A-006097B17A75}') ... from win32com.client import DispatchBaseClass class IReqProGUIApp(DispatchBaseClass): """RequisitePro GUI Application Dispatch Interface""" CLSID = IID('{52795522-11D4-11D2-A59B-006097B17A75}') coclass_clsid = None ... def ShowWord(self): """Brint the Word Workplace to the front.""" return self._oleobj_.InvokeTypes(209, LCID, 1, (11, 0), (),) ***** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA621 From lynton.grice at netweaverguru.com Wed Jul 23 17:37:56 2008 From: lynton.grice at netweaverguru.com (Lynton Grice) Date: Wed, 23 Jul 2008 17:37:56 +0200 Subject: [python-win32] FW: MSMQ - cannot catchCOM_ERROR with"pythoncom.com_error" Message-ID: <001501c8ecda$18f4c820$8ee3ed9b@logos> Hey Tim, Wow, you are 100% correct....there was something in WingIDE that is not happy....strange.... I ran the same code in the standard interpreter and it caught the error perfectly.... BTW: What IDE's do you guys use for Python? Thanks a million, have a great day! Lynton -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Golden Sent: 22 July 2008 05:21 PM Cc: python-win32 at python.org Subject: Re: [python-win32] MSMQ - cannot catchCOM_ERROR with"pythoncom.com_error" Lynton Grice wrote: > Please help me ;-) I know how to push / pop messages off of a MSMQ, also how > to create a queue etc.....but my problem is I cannot seen to catch the > "com_error" when I try create a MSMQ that already exists ;-( The basic code > is as follows: > > import win32com.client > import pythoncom > import os > > try: > queue_info = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") > computer_name = os.getenv('COMPUTERNAME') > format_name = "direct=os:" + computer_name + "\\private$\\test3" > > queue_info.FormatName=format_name > queue=queue_info.Open(2,0) "Dies here obviously as queue does not exist > except pythoncom.com_error: > #Queue does not exist...create queue.... > queue_info.PathName = ".\\private$\\test3" > queue_info.Label = "New Queue" > queue_info.Create() > > I get an Exception raised in WingIDE that says something like > "com_error......the queue does not exist or you do not have sufficient > permissions etc" - something like that..... I can't see anything obvious (aside from the possible dangers inherent in assuming that *any* com_error means the queue doesnt' exist). I assume that the -- "Dies here... -- isn't in the original code? Does the same thing happen if you run in the standard interpreter? (Don't know if WingIDE does anything fancy to intercept exceptions). If the same does happen in the interpreter, can you use the traceback module / sys.exc_info to determine exactly what exception is raised and how it relates to pythoncom.com_error? TJG _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From rdahlstrom at directedge.com Wed Jul 23 17:45:24 2008 From: rdahlstrom at directedge.com (Dahlstrom, Roger) Date: Wed, 23 Jul 2008 11:45:24 -0400 Subject: [python-win32] FW: MSMQ - cannotcatchCOM_ERROR with"pythoncom.com_error" References: <001501c8ecda$18f4c820$8ee3ed9b@logos> Message-ID: Notepad++ -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Lynton Grice Sent: Wednesday, July 23, 2008 11:38 AM To: python-win32 at python.org Subject: [python-win32] FW: MSMQ - cannotcatchCOM_ERROR with"pythoncom.com_error" Hey Tim, Wow, you are 100% correct....there was something in WingIDE that is not happy....strange.... I ran the same code in the standard interpreter and it caught the error perfectly.... BTW: What IDE's do you guys use for Python? Thanks a million, have a great day! Lynton -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Golden Sent: 22 July 2008 05:21 PM Cc: python-win32 at python.org Subject: Re: [python-win32] MSMQ - cannot catchCOM_ERROR with"pythoncom.com_error" Lynton Grice wrote: > Please help me ;-) I know how to push / pop messages off of a MSMQ, also how > to create a queue etc.....but my problem is I cannot seen to catch the > "com_error" when I try create a MSMQ that already exists ;-( The basic code > is as follows: > > import win32com.client > import pythoncom > import os > > try: > queue_info = win32com.client.Dispatch("MSMQ.MSMQQueueInfo") > computer_name = os.getenv('COMPUTERNAME') > format_name = "direct=os:" + computer_name + "\\private$\\test3" > > queue_info.FormatName=format_name > queue=queue_info.Open(2,0) "Dies here obviously as queue does not exist > except pythoncom.com_error: > #Queue does not exist...create queue.... > queue_info.PathName = ".\\private$\\test3" > queue_info.Label = "New Queue" > queue_info.Create() > > I get an Exception raised in WingIDE that says something like > "com_error......the queue does not exist or you do not have sufficient > permissions etc" - something like that..... I can't see anything obvious (aside from the possible dangers inherent in assuming that *any* com_error means the queue doesnt' exist). I assume that the -- "Dies here... -- isn't in the original code? Does the same thing happen if you run in the standard interpreter? (Don't know if WingIDE does anything fancy to intercept exceptions). If the same does happen in the interpreter, can you use the traceback module / sys.exc_info to determine exactly what exception is raised and how it relates to pythoncom.com_error? TJG _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From mdriscoll at co.marshall.ia.us Wed Jul 23 18:11:51 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Wed, 23 Jul 2008 11:11:51 -0500 Subject: [python-win32] FW: MSMQ - cannot catchCOM_ERROR with"pythoncom.com_error" In-Reply-To: <001501c8ecda$18f4c820$8ee3ed9b@logos> References: <001501c8ecda$18f4c820$8ee3ed9b@logos> Message-ID: <48875847.20408@co.marshall.ia.us> Lynton Grice wrote: > Hey Tim, > > Wow, you are 100% correct....there was something in WingIDE that is not > happy....strange.... > > I ran the same code in the standard interpreter and it caught the error > perfectly.... > > BTW: What IDE's do you guys use for Python? > > Thanks a million, have a great day! > > Lynton > I usually just use IDLE for Python stuff. My boss recently bought Wing for me and it's code-completion is great, but it's definitely much more sensitive to errors and I haven't used it enough to figure out how to find the tracebacks. PythonWin is ok, and PyDev for Eclipse is cool, but kind of bloated. Mike From m_norley_public at yahoo.co.uk Wed Jul 23 19:15:31 2008 From: m_norley_public at yahoo.co.uk (Mark Norley) Date: Wed, 23 Jul 2008 19:15:31 +0200 Subject: [python-win32] Python and Visual Basic Integration Message-ID: <6ae25ad0807231015p3f3c5317ube1d230d4eb99d7d@mail.gmail.com> Hi I've got a Python script that outputs a large text file of data and I've recently made a simple GUI for it in Visual Basic (2008). While it's simple enough to launch the Python script and pass it command line parameters from VB using Shell(python etc), I'm wondering how to pass information back to VB from Python. For example, it would be nice to be able to let VB know that the Python script has finished (at the moment I am repeatedly checking for the existence of the aforementioned text file, and sleeping for a short while if it hasn't appeared, which is clumsy but works). Ideally, I would like to be able to pass parameters to Python functions from VB and return values back to VB, just using VB for the front end while Python does all the hard work. I know I could just use Tkinter but is this sort of integration between Python and VB possible? Mark Norley -------------- next part -------------- An HTML attachment was scrubbed... URL: From ing_emanuels at hotmail.com Wed Jul 23 19:16:25 2008 From: ing_emanuels at hotmail.com (Emanuel Sotelo) Date: Wed, 23 Jul 2008 12:16:25 -0500 Subject: [python-win32] how to automate VB fron python Message-ID: hi, i will like to now if it's posible to automate visual basic and do you do this, i have read that for word you just use Word.Application same case for excel, but i cant get to find how to run visual basic from python, or from a existing program of VB to use one of he class that i create _________________________________________________________________ Juega y gana, tenemos 3 Xbox a la semana. http://club.prodigymsn.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Jul 23 19:28:25 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 23 Jul 2008 10:28:25 -0700 Subject: [python-win32] Python and Visual Basic Integration In-Reply-To: <6ae25ad0807231015p3f3c5317ube1d230d4eb99d7d@mail.gmail.com> References: <6ae25ad0807231015p3f3c5317ube1d230d4eb99d7d@mail.gmail.com> Message-ID: <48876A39.2070002@probo.com> Mark Norley wrote: > > I've got a Python script that outputs a large text file of data and > I've recently made a simple GUI for it in Visual Basic (2008). While > it's simple enough to launch the Python script and pass it command > line parameters from VB using Shell(python etc), I'm wondering how to > pass information back to VB from Python. For example, it would be nice > to be able to let VB know that the Python script has finished (at the > moment I am repeatedly checking for the existence of the > aforementioned text file, and sleeping for a short while if it hasn't > appeared, which is clumsy but works). > > Ideally, I would like to be able to pass parameters to Python > functions from VB and return values back to VB, just using VB for the > front end while Python does all the hard work. I know I could just use > Tkinter but is this sort of integration between Python and VB possible? Yes, with some glue. You can turn your Python script into a COM server, and then use the .NET COM Interop to invoke it from your VB code. Is that more trouble than starting a process and monitoring its results? You'll have to judge that yourself... -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Jul 23 19:29:31 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 23 Jul 2008 10:29:31 -0700 Subject: [python-win32] FW: MSMQ - cannot catch COM_ERROR with "pythoncom.com_error" In-Reply-To: <001501c8ecda$18f4c820$8ee3ed9b@logos> References: <001501c8ecda$18f4c820$8ee3ed9b@logos> Message-ID: <48876A7B.6040908@probo.com> Lynton Grice wrote: > Wow, you are 100% correct....there was something in WingIDE that is not > happy....strange.... > > I ran the same code in the standard interpreter and it caught the error > perfectly.... > > BTW: What IDE's do you guys use for Python? > gvim, the World's Greatest Editor, by unanimous acclaim. Real men use command lines. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Jul 23 19:31:06 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 23 Jul 2008 10:31:06 -0700 Subject: [python-win32] how to automate VB fron python In-Reply-To: References: Message-ID: <48876ADA.1080105@probo.com> Emanuel Sotelo wrote: > hi, i will like to now if it's posible to automate visual basic and do > you do this, i have read that for word you just use Word.Application > same case for excel, but i cant get to find how to run visual basic > from python, or from a existing program of VB to use one of he class > that i create This is kind of the inverse of the last question! Partly, this depends on which version of VB you are using. Your VB program can become a COM server. Once you do that, your Python code can use it, just like Word.Application and Excel.Application. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Jul 23 19:33:49 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 23 Jul 2008 10:33:49 -0700 Subject: [python-win32] How to replace the values with keys ? In-Reply-To: <92df0f7c0807222132h2f5e21b0t491439749c327992@mail.gmail.com> References: <92df0f7c0807212334w5911c307l29db5d8855c8ad0@mail.gmail.com> <92df0f7c0807222132h2f5e21b0t491439749c327992@mail.gmail.com> Message-ID: <48876B7D.9020704@probo.com> Graps Graps wrote: > Hi all, > > I tried > > import aDict > import re > infile = open('text1.txt','rw') > outfile = open('text3.txt','w') > def replace_words(infile, aDict): > rc=re.compile('|'.join(map(re. > escape, aDict))) > def translate(match): > return aDict[match.group(0)] > return rc.sub(translate, infile) > outfile = replace_words(infile,aDict) > > I am thrown with: > > Traceback (most recent call last): > File "", line 1, in > File "", line 2, in replace_words > TypeError: argument 2 to map() must support iteration > > I imported text2.txt , containing python dictionary as aDict.py. I > want the replaced values in a separate file text3.txt. You need to show us exactly what aDict.py contains. If it looks like this: aDict = { 'a': '1', ... } then you should probably start your program with this: from aDict import aDict -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From m_norley_public at yahoo.co.uk Wed Jul 23 19:45:28 2008 From: m_norley_public at yahoo.co.uk (Mark Norley) Date: Wed, 23 Jul 2008 19:45:28 +0200 Subject: [python-win32] Python and Visual Basic Integration In-Reply-To: <48876A39.2070002@probo.com> References: <6ae25ad0807231015p3f3c5317ube1d230d4eb99d7d@mail.gmail.com> <48876A39.2070002@probo.com> Message-ID: <6ae25ad0807231045x4af466d0ueaf44b521f8cf526@mail.gmail.com> Thanks Tim. Where would I go to find out about setting up my Python script as a COM server? (A "for dummies" level of instruction is what I'd be looking for :-) On Wed, Jul 23, 2008 at 7:28 PM, Tim Roberts wrote: > Mark Norley wrote: > >> >> I've got a Python script that outputs a large text file of data and I've >> recently made a simple GUI for it in Visual Basic (2008). While it's simple >> enough to launch the Python script and pass it command line parameters from >> VB using Shell(python etc), I'm wondering how to pass information back to VB >> from Python. For example, it would be nice to be able to let VB know that >> the Python script has finished (at the moment I am repeatedly checking for >> the existence of the aforementioned text file, and sleeping for a short >> while if it hasn't appeared, which is clumsy but works). >> >> Ideally, I would like to be able to pass parameters to Python functions >> from VB and return values back to VB, just using VB for the front end while >> Python does all the hard work. I know I could just use Tkinter but is this >> sort of integration between Python and VB possible? >> > > Yes, with some glue. You can turn your Python script into a COM server, > and then use the .NET COM Interop to invoke it from your VB code. > > Is that more trouble than starting a process and monitoring its results? > You'll have to judge that yourself... > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ing_emanuels at hotmail.com Wed Jul 23 19:52:23 2008 From: ing_emanuels at hotmail.com (Emanuel Sotelo) Date: Wed, 23 Jul 2008 12:52:23 -0500 Subject: [python-win32] how to automate VB fron python Message-ID: hi Tim Roberts, well a have install visual basic 6.0 can you help me by telling me how to make mi VB programa into a COM Server or indicate some web pages that can help me out _________________________________________________________________ Los mejores conciertos en exclusiva por MSN in concert http://video.msn.com/?mkt=es-mx -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Jul 23 20:00:26 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 23 Jul 2008 11:00:26 -0700 Subject: [python-win32] Python and Visual Basic Integration In-Reply-To: <6ae25ad0807231045x4af466d0ueaf44b521f8cf526@mail.gmail.com> References: <6ae25ad0807231015p3f3c5317ube1d230d4eb99d7d@mail.gmail.com> <48876A39.2070002@probo.com> <6ae25ad0807231045x4af466d0ueaf44b521f8cf526@mail.gmail.com> Message-ID: <488771BA.8050900@probo.com> Mark Norley wrote: > Thanks Tim. Where would I go to find out about setting up my Python > script as a COM server? (A "for dummies" level of instruction is what > I'd be looking for :-) There have been a number of posts on this mailing list in the last couple of months on this topic. Plus, if you have pywin32 installed, there are samples in PythonXX\lib\site-packages\win32com\servers. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ing_emanuels at hotmail.com Wed Jul 23 21:38:14 2008 From: ing_emanuels at hotmail.com (Emanuel Sotelo) Date: Wed, 23 Jul 2008 14:38:14 -0500 Subject: [python-win32] how to automate VB fron python Message-ID: Tim Roberts wrote: >This is kind of the inverse of the last question! >Partly, this depends on which version of VB you are using. Your VB >program can become a COM server. Once you do that, your Python code can >use it, just like Word.Application and Excel.Application. hi Tim Roberts, well a have install visual basic 6.0 can you help me by telling me how to make mi VB programa into a COM Server or indicate some web pages that can help me out _________________________________________________________________ Tenemos lo que b?scas?JUEGOS. http://club.prodigymsn.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Jul 23 22:28:44 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 23 Jul 2008 13:28:44 -0700 Subject: [python-win32] how to automate VB fron python In-Reply-To: References: Message-ID: <4887947C.3010304@probo.com> Emanuel Sotelo wrote: > hi Tim Roberts, well a have install visual basic 6.0 Are you aware that Visual Basic 6.0 is now 10 years old? Software is not like wine and cheese. It does not get better with age. > can you help me by telling me how to make mi VB > programa into a COM Server or indicate some web pages that can help > me out There are many, many web pages that talk about this. Google for it. I can speak VB, but I am not a VB expert, and I'd venture that few on this mailing list are. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From vernondcole at gmail.com Thu Jul 24 03:06:09 2008 From: vernondcole at gmail.com (Vernon Cole) Date: Wed, 23 Jul 2008 19:06:09 -0600 Subject: [python-win32] Python and Visual Basic Integration In-Reply-To: <488771BA.8050900@probo.com> References: <6ae25ad0807231015p3f3c5317ube1d230d4eb99d7d@mail.gmail.com> <48876A39.2070002@probo.com> <6ae25ad0807231045x4af466d0ueaf44b521f8cf526@mail.gmail.com> <488771BA.8050900@probo.com> Message-ID: Errrr, ummm, (cough)... Wouldn't it be a lot easier to write the GUI in python (perhaps using wxpython?) and simply import and call the (other) python script? Writing text to a notebook page is quite trivial compared to interprocess communications. I can make a sample if you are interested. -- Vernon Cole On Wed, Jul 23, 2008 at 12:00 PM, Tim Roberts wrote: > Mark Norley wrote: > >> Thanks Tim. Where would I go to find out about setting up my Python script >> as a COM server? (A "for dummies" level of instruction is what I'd be >> looking for :-) >> > > There have been a number of posts on this mailing list in the last couple > of months on this topic. Plus, if you have pywin32 installed, there are > samples in PythonXX\lib\site-packages\win32com\servers. > > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Thu Jul 24 03:25:05 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 24 Jul 2008 11:25:05 +1000 Subject: [python-win32] Problem with TLB file and COM In-Reply-To: References: Message-ID: <093801c8ed2c$1cbecf30$563c6d90$@com.au> This will be due to the object throwing an incorrect error code when the flag for the method is incorrect, and win32com can't know what the correct flag is ahead of time for "dynamic" objects. Further, the object doesn't support type info from its typelib at runtime, so Python can't match up the makepy generated module with the object, which would also prevent this. It might be possible to work around that with something like: from win32com.client import gencache mod = gencache.EnsureModule('{A5B37030-06D9-11D2-A58A-006097B17A75}', 0, 4, 0) gui = win32com.client.Dispatch("ReqPro40.GUIApp") # according to your snippet, the generated file has a class # IReqProGUIApp - convert the "dynamic" object to one of them. gui = mod.IReqProGUIApp(gui) gui.ShowWord() # should work as it goes directly by the generated method. Sadly, it will be necessary to wrap *every* object - eg, imagine a method GetFoo() that returned an object, you would need: foo = gui.GetFoo() foo = mod.IReqWhateverFooIs(foo) # obviously can be written as 1 line ;) Hope this helps, Mark > -----Original Message----- > From: python-win32-bounces at python.org [mailto:python-win32- > bounces at python.org] On Behalf Of Reedick, Andrew > Sent: Thursday, 24 July 2008 12:42 AM > To: python-win32 at python.org > Subject: [python-win32] Problem with TLB file and COM > > I'm having trouble with a COM object for which none of its methods are > available at runtime. The COM class is defined in a tlb file. I used > "makepy -i", added the gencache lines to the program, and can see the > methods in the generated file. However, when I try to call any method, > it blows up with a DISPATCH_METHOD flag error. > > The equivalent code works just fine in Perl. > > Anyone have any idea why a COM object defined in a tlb file would be so > problematic in Python? > > > === program === > import win32com.client > > from win32com.client import gencache > gencache.EnsureModule('{A5B37030-06D9-11D2-A58A-006097B17A75}', 0, 4, > 0) > > gui = win32com.client.Dispatch("ReqPro40.GUIApp") > print gui > print > print dir(gui) > > print > print 'showword =', gui.ShowWord() > > > > == output == > > > ['_ApplyTypes_', '_FlagAsMethod', '_LazyAddAttr_', '_NewEnum', > '_Release_', '__AttrToID__', '__LazyMap__', '__call__', '__cmp__', > '__doc__', '__getattr__', '__getitem__', '__init__', '__int__', > '__len__', '__module__', '__nonzero__', '__repr__', '__setattr__', > '__setitem__', '__str__', '_builtMethods_', '_enum_', > '_find_dispatch_type_', '_get_good_object_', > '_get_good_single_object_', > '_lazydata_', '_make_method_', '_mapCachedItems_', '_oleobj_', > '_olerepr_', '_print_details_', '_proc_', '_unicode_to_string_', > '_username_', '_wrap_dispatch_'] > > showword = > Traceback (most recent call last): > File "D:\mydata\dev\reqpro\renumber\c.py", line 13, in > print 'showword =', gui.ShowWord() > File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line > 491, in __getattr__ > raise pythoncom.com_error, details > pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, > 'Smalltalk', 'Incorrect dispatch invocation flags: DISPATCH_METHOD flag > not set for method ShowWord.', None, 0, 0), None) > > > === snippets of gen file ==== > > CLSID = IID('{A5B37030-06D9-11D2-A58A-006097B17A75}') > ... > from win32com.client import DispatchBaseClass > class IReqProGUIApp(DispatchBaseClass): > """RequisitePro GUI Application Dispatch Interface""" > CLSID = IID('{52795522-11D4-11D2-A59B-006097B17A75}') > coclass_clsid = None > > ... > > def ShowWord(self): > """Brint the Word Workplace to the front.""" > return self._oleobj_.InvokeTypes(209, LCID, 1, (11, 0), > (),) From wegraps at gmail.com Thu Jul 24 04:02:58 2008 From: wegraps at gmail.com (Graps Graps) Date: Thu, 24 Jul 2008 07:32:58 +0530 Subject: [python-win32] How to replace the values with keys ? In-Reply-To: <48876B7D.9020704@probo.com> References: <92df0f7c0807212334w5911c307l29db5d8855c8ad0@mail.gmail.com> <92df0f7c0807222132h2f5e21b0t491439749c327992@mail.gmail.com> <48876B7D.9020704@probo.com> Message-ID: <92df0f7c0807231902t76519fe4pc8800d9dee4233ad@mail.gmail.com> Hi all, aDict is a dictionary, containing {0: 'str1\n', 1: 'str22\n', 2: 'str3\n', 3: 'str4\n', 4: 'str5\n', ..........., , 1308: 'str1309\n'}. I used: keys = m values = noDupes aDict = dict(zip(keys,values)) to get aDict, where m=range(1309) and noDupes was a list read from a text file. When I tried: from aDict import aDict I am thrown with: Traceback (most recent call last): File "", line 1, in ImportError: cannot import name aDict. Thanking You in advance. On Wed, Jul 23, 2008 at 11:03 PM, Tim Roberts wrote: > Graps Graps wrote: > >> Hi all, >> >> I tried >> >> from aDict import aDict >> import re >> infile = open('text1.txt','rw') >> outfile = open('text3.txt','w') >> def replace_words(infile, aDict): >> rc=re.compile('|'.join(map(re. >> escape, aDict))) >> def translate(match): >> return aDict[match.group(0)] >> return rc.sub(translate, infile) >> outfile = replace_words(infile,aDict) >> >> I am thrown with: >> >> Traceback (most recent call last): >> File "", line 1, in >> File "", line 2, in replace_words >> TypeError: argument 2 to map() must support iteration >> >> I imported text2.txt , containing python dictionary as aDict.py. I want >> the replaced values in a separate file text3.txt. >> > > You need to show us exactly what aDict.py contains. If it looks like this: > > aDict = { > 'a': '1', ... > } > > then you should probably start your program with this: > from aDict import aDict > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From marcus at internetnowasp.net Thu Jul 24 07:21:20 2008 From: marcus at internetnowasp.net (Marcus.CM) Date: Thu, 24 Jul 2008 13:21:20 +0800 Subject: [python-win32] ctypes and DLL Message-ID: <48881150.2090102@internetnowasp.net> Hi On Windows/Vista :- vr = ctypes.CDLL(str) When loading a DLL that is corrupted using cytpes, i get a bombed out box with "python.exe - bad image" as the message box title instead of handling it at my exception handler. How do i do this without the ugly messagebox from python ? Marcus.CM. From m_norley_public at yahoo.co.uk Thu Jul 24 08:47:11 2008 From: m_norley_public at yahoo.co.uk (Mark Norley) Date: Thu, 24 Jul 2008 08:47:11 +0200 Subject: [python-win32] Python and Visual Basic Integration In-Reply-To: References: <6ae25ad0807231015p3f3c5317ube1d230d4eb99d7d@mail.gmail.com> <48876A39.2070002@probo.com> <6ae25ad0807231045x4af466d0ueaf44b521f8cf526@mail.gmail.com> <488771BA.8050900@probo.com> Message-ID: <6ae25ad0807232347i692e41b9lc25717104c65f2a7@mail.gmail.com> Thanks for the advice everyone. I've managed to get my VB GUI talking to a simple "Hello World!" Python COM server (there was a quickstart help page in the pywin32 package that I hadn't spotted). On Thu, Jul 24, 2008 at 3:06 AM, Vernon Cole wrote: > Errrr, ummm, (cough)... > > Wouldn't it be a lot easier to write the GUI in python (perhaps using > wxpython?) and simply import and call the (other) python script? Writing > text to a notebook page is quite trivial compared to interprocess > communications. > > I can make a sample if you are interested. > -- > Vernon Cole > > > On Wed, Jul 23, 2008 at 12:00 PM, Tim Roberts wrote: > >> Mark Norley wrote: >> >>> Thanks Tim. Where would I go to find out about setting up my Python >>> script as a COM server? (A "for dummies" level of instruction is what I'd be >>> looking for :-) >>> >> >> There have been a number of posts on this mailing list in the last couple >> of months on this topic. Plus, if you have pywin32 installed, there are >> samples in PythonXX\lib\site-packages\win32com\servers. >> >> >> -- >> 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 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From egregio at gmail.com Thu Jul 24 09:57:48 2008 From: egregio at gmail.com (_ _) Date: Thu, 24 Jul 2008 09:57:48 +0200 Subject: [python-win32] win32security.LogonUser Message-ID: <1bdf59490807240057v160b023fm8e343d20c653a5f1@mail.gmail.com> Hi... How are you? I use win32extensions... I have a problem, can you help me please? import win32security domain = "myNetworkDomain" username = "testUser" password = "testUser" hUser = win32security.LogonUser (username, domain, password, win32security.LOGON32_LOGON_NETWORK,win32security.LOGON32_PROVIDER_DEFAULT) win32security.ImpersonateLoggedOnUser(hUser) f = file (r"D:\test\local\kkk.txt", "w") Traceback (most recent call last): File "", line 1, in IOError: [Errno 2] No such file or directory: 'D:\\test\\local\\kkk.txt' (D:\test\local exists!!) What is the problem?... Thanks a lot... E -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Thu Jul 24 10:17:07 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 24 Jul 2008 09:17:07 +0100 Subject: [python-win32] win32security.LogonUser In-Reply-To: <1bdf59490807240057v160b023fm8e343d20c653a5f1@mail.gmail.com> References: <1bdf59490807240057v160b023fm8e343d20c653a5f1@mail.gmail.com> Message-ID: <48883A83.7000106@timgolden.me.uk> _ _ wrote: > Hi... How are you? > > I use win32extensions... I > have a problem, can you help me please? > > > import win32security > domain = "myNetworkDomain" > username = "testUser" > password = "testUser" > > hUser = win32security.LogonUser (username, domain, password, > win32security.LOGON32_LOGON_ > NETWORK,win32security.LOGON32_PROVIDER_DEFAULT) > win32security.ImpersonateLoggedOnUser(hUser) > f = file (r"D:\test\local\kkk.txt", "w") > > Traceback (most recent call last): > File "", line 1, in > IOError: [Errno 2] No such file or directory: 'D:\\test\\local\\kkk.txt' > > (D:\test\local exists!!) What is the problem?... Well, let's take a few casts in the absence of more complete data: 1) Is "D:" a network drive which isn't mapped for the other user? 2) Does the "testUser" actually have security access to D:\\test\\local\\kkk.txt and at least traverse access to the intervening directories? I wouldn't actually expect this error if they didn't (rather, a permissions error, but who knows?) 3) (Since you've obviously had to munge the code a little for security) are you absolutely sure that the path you've specified *does* exist? TJG From egregio at gmail.com Thu Jul 24 10:36:56 2008 From: egregio at gmail.com (_ _) Date: Thu, 24 Jul 2008 10:36:56 +0200 Subject: [python-win32] win32security.LogonUser In-Reply-To: <48883A83.7000106@timgolden.me.uk> References: <1bdf59490807240057v160b023fm8e343d20c653a5f1@mail.gmail.com> <48883A83.7000106@timgolden.me.uk> Message-ID: <1bdf59490807240136l297f24a3g2dc895d966f6d265@mail.gmail.com> 1) D: is a local drive 2) "testUser" actually have security access. If I execute Notepad as "testUser", I can create this file in this folder. 3) I check that the folder exists. Thanks a lot 2008/7/24 Tim Golden : > _ _ wrote: > >> Hi... How are you? >> >> I use win32extensions... I >> have a problem, can you help me please? >> >> >> import win32security >> domain = "myNetworkDomain" >> username = "testUser" >> password = "testUser" >> >> hUser = win32security.LogonUser (username, domain, password, >> win32security.LOGON32_LOGON_ >> NETWORK,win32security.LOGON32_PROVIDER_DEFAULT) >> win32security.ImpersonateLoggedOnUser(hUser) >> f = file (r"D:\test\local\kkk.txt", "w") >> >> Traceback (most recent call last): >> File "", line 1, in >> IOError: [Errno 2] No such file or directory: 'D:\\test\\local\\kkk.txt' >> >> (D:\test\local exists!!) What is the problem?... >> > > Well, let's take a few casts in the absence of > more complete data: > > 1) Is "D:" a network drive which isn't mapped for the other user? > > 2) Does the "testUser" actually have security access > to D:\\test\\local\\kkk.txt and at least traverse access > to the intervening directories? I wouldn't actually > expect this error if they didn't (rather, a permissions > error, but who knows?) > > 3) (Since you've obviously had to munge the code a little > for security) are you absolutely sure that the path you've > specified *does* exist? > > TJG > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Thu Jul 24 11:50:13 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 24 Jul 2008 10:50:13 +0100 Subject: [python-win32] win32security.LogonUser In-Reply-To: <1bdf59490807240136l297f24a3g2dc895d966f6d265@mail.gmail.com> References: <1bdf59490807240057v160b023fm8e343d20c653a5f1@mail.gmail.com> <48883A83.7000106@timgolden.me.uk> <1bdf59490807240136l297f24a3g2dc895d966f6d265@mail.gmail.com> Message-ID: <48885055.8060702@timgolden.me.uk> _ _ wrote: > 1) D: is a local drive > 2) "testUser" actually have security access. If I execute Notepad as > "testUser", I can create this file in this folder. > 3) I check that the folder exists. Well, can you do some other tests such as: + Use os.access or os.exists to determine whether the new user can see *anything* on the D: drive + Can the new user "read" an existing file from that directory? + Can the new user write files in any *other* folder? + Can a *different* impersonated user create files? This isn't a general problem: I can impersonate another user and write a file to an arbitrary point on my filesystem. You're going to have to narrow it down to something which is particular about this case. TJG From theller at ctypes.org Thu Jul 24 12:12:43 2008 From: theller at ctypes.org (Thomas Heller) Date: Thu, 24 Jul 2008 12:12:43 +0200 Subject: [python-win32] ctypes and DLL In-Reply-To: <48881150.2090102@internetnowasp.net> References: <48881150.2090102@internetnowasp.net> Message-ID: Marcus.CM schrieb: > Hi > > On Windows/Vista :- > > vr = ctypes.CDLL(str) > > When loading a DLL that is corrupted using cytpes, i get a bombed out > box with "python.exe - bad image" as the message box title instead of > handling it at my exception handler. > How do i do this without the ugly messagebox from python ? > > Marcus.CM. You could try changing the process error-mode flags by calling the Windows SetErrorMode() function before loading the dll. Probably ctypes.windll.kernel32.SetErrorMode(0x8007) will help. See http://msdn.microsoft.com/en-us/library/ms680621(VS.85).aspx -- Thomas From egregio at gmail.com Thu Jul 24 12:34:46 2008 From: egregio at gmail.com (_ _) Date: Thu, 24 Jul 2008 12:34:46 +0200 Subject: [python-win32] win32security.LogonUser In-Reply-To: <48885055.8060702@timgolden.me.uk> References: <1bdf59490807240057v160b023fm8e343d20c653a5f1@mail.gmail.com> <48883A83.7000106@timgolden.me.uk> <1bdf59490807240136l297f24a3g2dc895d966f6d265@mail.gmail.com> <48885055.8060702@timgolden.me.uk> Message-ID: <1bdf59490807240334i50fc1104y5cf3a316b768e564@mail.gmail.com> + I use os.path.isfile ("D:/test/local/file.txt") and return False. And "D:/test/local/file.txt" exists! + If I try to read a file return a error... + The user can't read or write files when I impersonated. But if I login interactive, or execute as, with this user ("testUser") I can read and write files... + With other user don't work. But If impersonated user is equal "main user" this works... More things: After impersonated, If I execute win32api.GetUserName() returns "testUser" After impersonated, if I try execute os.system ("dir") returns -1 I can impersonate another user and write a file to an arbitrary point on my filesystem in other computer. This computer (where impersonated works) is out of windows domain. Thanks a lot again 2008/7/24 Tim Golden : > _ _ wrote: > >> 1) D: is a local drive >> 2) "testUser" actually have security access. If I execute Notepad as >> "testUser", I can create this file in this folder. >> 3) I check that the folder exists. >> > > Well, can you do some other tests such as: > > + Use os.access or os.exists to determine whether the > new user can see *anything* on the D: drive > > + Can the new user "read" an existing file from that > directory? > > + Can the new user write files in any *other* folder? > > + Can a *different* impersonated user create files? > > This isn't a general problem: I can impersonate another > user and write a file to an arbitrary point on my > filesystem. You're going to have to narrow it down > to something which is particular about this case. > > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Thu Jul 24 12:48:52 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 24 Jul 2008 11:48:52 +0100 Subject: [python-win32] win32security.LogonUser In-Reply-To: <1bdf59490807240334i50fc1104y5cf3a316b768e564@mail.gmail.com> References: <1bdf59490807240057v160b023fm8e343d20c653a5f1@mail.gmail.com> <48883A83.7000106@timgolden.me.uk> <1bdf59490807240136l297f24a3g2dc895d966f6d265@mail.gmail.com> <48885055.8060702@timgolden.me.uk> <1bdf59490807240334i50fc1104y5cf3a316b768e564@mail.gmail.com> Message-ID: <48885E14.8080208@timgolden.me.uk> _ _ wrote: > + I use os.path.isfile ("D:/test/local/file.txt") and return False. And > "D:/test/local/file.txt" exists! > + If I try to read a file return a error... > + The user can't read or write files when I impersonated. But if I login > interactive, or execute as, with this user ("testUser") I can read and > write files... > + With other user don't work. But If impersonated user is equal "main > user" this works... > > More things: > After impersonated, If I execute win32api.GetUserName() returns "testUser" > After impersonated, if I try execute os.system ("dir") returns -1 > I can impersonate another user and write a file to an arbitrary point on > my filesystem in other computer. This computer (where impersonated > works) is out of windows domain. Sorry, stupid of me: I didn't notice that you were specifying a LOGON_NETWORK in the call to LogonUser. Try using LOGON32_LOGON_INTERACTIVE instead. The NETWORK_LOGON flag works fine for checking credentials (altho' you're supposed to do that via SSPI these days) but doesn't give you enough of a token to get hold of local resources, I think. The fact that you can access remote resources might be because the remote non-domain machine allows guest access. TJG From josesimas at gmail.com Thu Jul 24 14:56:52 2008 From: josesimas at gmail.com (jose simas) Date: Thu, 24 Jul 2008 13:56:52 +0100 Subject: [python-win32] how to automate VB fron python In-Reply-To: <4887947C.3010304@probo.com> References: <4887947C.3010304@probo.com> Message-ID: Hi, Your best bet would be writing an Add-In for VB6's IDE. Check out: http://oreilly.com/catalog/devvbad/chapter/ch01.html For an intro to VB Add-ins and use SpamBayes as a model for your python code: http://spambayes.sourceforge.net/ Hope this helps Jose From mdriscoll at co.marshall.ia.us Thu Jul 24 15:30:42 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Thu, 24 Jul 2008 08:30:42 -0500 Subject: [python-win32] Python and Visual Basic Integration In-Reply-To: <6ae25ad0807232347i692e41b9lc25717104c65f2a7@mail.gmail.com> References: <6ae25ad0807231015p3f3c5317ube1d230d4eb99d7d@mail.gmail.com> <48876A39.2070002@probo.com> <6ae25ad0807231045x4af466d0ueaf44b521f8cf526@mail.gmail.com> <488771BA.8050900@probo.com> <6ae25ad0807232347i692e41b9lc25717104c65f2a7@mail.gmail.com> Message-ID: <48888402.1030107@co.marshall.ia.us> Mark Norley wrote: > Thanks for the advice everyone. I've managed to get my VB GUI talking > to a simple "Hello World!" Python COM server (there was a quickstart > help page in the pywin32 package that I hadn't spotted). > As I understand it, you can call VB stuff from within IronPython and vise-versa. However, that probably only applies to the .NET versions of VB. If you plan to upgrade to the .NET studios, than you should probably look at it...especially if you don't want to mess with wxPython or Tkinter. Mike From timr at probo.com Thu Jul 24 18:16:55 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 24 Jul 2008 09:16:55 -0700 Subject: [python-win32] How to replace the values with keys ? In-Reply-To: <92df0f7c0807231902t76519fe4pc8800d9dee4233ad@mail.gmail.com> References: <92df0f7c0807212334w5911c307l29db5d8855c8ad0@mail.gmail.com> <92df0f7c0807222132h2f5e21b0t491439749c327992@mail.gmail.com> <48876B7D.9020704@probo.com> <92df0f7c0807231902t76519fe4pc8800d9dee4233ad@mail.gmail.com> Message-ID: <4888AAF7.3020109@probo.com> Graps Graps wrote: > > aDict is a dictionary, containing > > {0: 'str1\n', 1: 'str22\n', 2: 'str3\n', 3: 'str4\n', 4: 'str5\n', > ..........., , 1308: 'str1309\n'}. Are you saying that string is exactly what is in the file "aDict.py"? In that case, you can't import it. The expression will be evaluated, and then discarded. You would have to read it as a string and use "eval": aDict = eval( open( 'aDict.py', 'r' ).read() ) However, because that's dangerous, I strongly recommend that you change aDict.py so that it reads: aDict = {0: 'str1\n', 1: 'str2\n', ... } That way, you COULD use from aDict import aDict > I used: > > keys = m > values = noDupes > aDict = dict(zip(keys,values)) > > to get aDict, where m=range(1309) and noDupes was a list read from a > text file. OK, then why use a dictionary at all? If the indices are just sequential numbers, why not just make it a list: aList = [ 'str1\n', 'str2\n', 'str3\n', 'str4\n' ... ] You would use it exactly the same way: from aDict import aList ... newValue = aList[ i ] -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From marcus at internetnowasp.net Thu Jul 24 19:43:27 2008 From: marcus at internetnowasp.net (Marcus.CM) Date: Fri, 25 Jul 2008 01:43:27 +0800 Subject: [python-win32] ctypes and DLL In-Reply-To: References: <48881150.2090102@internetnowasp.net> Message-ID: <4888BF3F.5080106@internetnowasp.net> Hi Thomas, Thanks, will give it a shot . My main concern is that i need to use the code in a service and have a display msgbox is not an ideal design. Marcus Thomas Heller wrote: > Marcus.CM schrieb: > >> Hi >> >> On Windows/Vista :- >> >> vr = ctypes.CDLL(str) >> >> When loading a DLL that is corrupted using cytpes, i get a bombed out >> box with "python.exe - bad image" as the message box title instead of >> handling it at my exception handler. >> How do i do this without the ugly messagebox from python ? >> >> Marcus.CM. >> > > You could try changing the process error-mode flags by calling the > Windows SetErrorMode() function before loading the dll. > > Probably ctypes.windll.kernel32.SetErrorMode(0x8007) will help. > See http://msdn.microsoft.com/en-us/library/ms680621(VS.85).aspx > From jr9445 at ATT.COM Thu Jul 24 22:56:29 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Thu, 24 Jul 2008 15:56:29 -0500 Subject: [python-win32] Problem with TLB file and COM In-Reply-To: <093801c8ed2c$1cbecf30$563c6d90$@com.au> References: <093801c8ed2c$1cbecf30$563c6d90$@com.au> Message-ID: > -----Original Message----- > From: Mark Hammond [mailto:mhammond at skippinet.com.au] > Sent: Wednesday, July 23, 2008 9:25 PM > To: Reedick, Andrew; python-win32 at python.org > Subject: RE: [python-win32] Problem with TLB file and COM > > > from win32com.client import gencache > mod = gencache.EnsureModule('{A5B37030-06D9-11D2-A58A-006097B17A75}', > 0, 4, > 0) > gui = win32com.client.Dispatch("ReqPro40.GUIApp") > > # according to your snippet, the generated file has a class > # IReqProGUIApp - convert the "dynamic" object to one of them. > gui = mod.IReqProGUIApp(gui) > > gui.ShowWord() # should work as it goes directly by the generated > method. > That works! The gui object's various methods are now accessible. Many thanks for the help. =) ***** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA623 From sina.sa at gmail.com Fri Jul 25 00:07:14 2008 From: sina.sa at gmail.com (Sina S) Date: Fri, 25 Jul 2008 08:07:14 +1000 Subject: [python-win32] Excel Document Message-ID: <66aaa6040807241507r5fddf31dje963fa0bf69a782f@mail.gmail.com> Hi guys, I have been using this module http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440661 To read the contents of an excel spreadsheet. In one case I am trying to read the value of the cell rather than its contents. i.e. if I have a hyperlink called "Document" or "Procedure" which is a hyperlink to http://intranet/foo.pdf then this script will return "Document" or "Link" as a unicode string rather than the URL that I require. I would also like to be able to read other cell attributes such as colour, if possible, but this is not essential. Obviously the script I linked to cannot do what I require, but I do not know how to extend it, being a bit of python noob. I asked in #python on freenode and while they could not help, suggested I contact this list for assistance. Thanks! ~Sina -------------- next part -------------- An HTML attachment was scrubbed... URL: From motoom at xs4all.nl Fri Jul 25 12:52:04 2008 From: motoom at xs4all.nl (Michiel Overtoom) Date: Fri, 25 Jul 2008 12:52:04 +0200 Subject: [python-win32] Excel Document Message-ID: <2.2.32.20080725105204.0160c9ec@pop.xs4all.nl> Sina wrote... >To read the contents of an excel spreadsheet. In one case I am trying to >read the value of the cell rather than its contents. i.e. if I have a >hyperlink called "Document" or "Procedure" which is a hyperlink to >http://intranet/foo.pdf then this script will return "Document" or "Link" as >a unicode string rather than the URL that I require. Could you post an example of such a worksheet somewhere? >I would also like to be able to read other cell attributes such as colour, >if possible, but this is not essential. This works for me. It uses an example sheet, which should be in the same directory as from you run the script from, you can get at ftp://ftp.motoom.net/files/excel.xls # excel.py: import win32com.client import os xlsname=os.path.join(os.getcwd(),"excel.xls") excel=win32com.client.DispatchEx("Excel.Application") book=excel.Workbooks.Open(xlsname) sheet=book.Sheets(1) rowcount=sheet.UsedRange.Rows.Count colcount=sheet.UsedRange.Columns.Count for row in range(1,rowcount+1): for col in range(1,colcount+1): cell=sheet.Cells(row,col) if not cell.Value: continue # skip empty cells print "\nRow",row,"Col",col if cell.Value: print "\tValue:",cell.Value if cell.HasFormula: print "\tFormula:",cell.Formula if cell.Font.ColorIndex>0: print "\tColor:",cell.Font.ColorIndex if cell.Font.FontStyle!="Regular": print "\tStyle:",cell.Font.FontStyle excel=None -- "The ability of the OSS process to collect and harness the collective IQ of thousands of individuals across the Internet is simply amazing." - Vinod Vallopillil http://www.catb.org/~esr/halloween/halloween4.html From ing_emanuels at hotmail.com Fri Jul 25 17:07:11 2008 From: ing_emanuels at hotmail.com (Emanuel Sotelo) Date: Fri, 25 Jul 2008 10:07:11 -0500 Subject: [python-win32] from excel to word Message-ID: hello, well this time i have to do someting more easier from python i create a excel document were a wrote a message, a number, and a have this number multiply by another with a formula. the a save de excel document. next in the same programa a create a word doucument were a also wrote a message, and what i want to do is that a pass the result of this formula to the word document, put in the midle of the document with a bigger font. and last have the word document sent to a printe. now a have started the code by mi self: from win32com.client import Dispatch import win32ui #excel part MYDIR='C:\\Documents and Settings\\Administrador\\My documents' xl= Dispatch("Excel.Application") xl.Visible=1 xl.Workbooks.Add() xl.Cells(1,2).Value=" excel data sent to a word document" xl.Cells(2,4).Value=3 xl.Cells(3,6).Formula='=D2*10' xl.Save(MYDIR+'\\excelword.doc') #word part wordapp = Dispatch("Word.Application") wordapp.Visible = 1 worddoc = wordapp.Documents.Add() rango = worddoc.Range(0,0) rango.InsertBefore('hi we are goin to bring the data from excel and have it print in word') worddoc.SaveAs(MYDIR+ '\\wordexcel.doc') rango.InsertAfter(xl.Cells(3,6)) #print part dc= win32ui.CreateDC() dc.CreatePrinterDC() # i dont now what else is supposed to go in this part to send it to print but i now is fiil with a lote of flaws, if somebody cant help me by give some suggestions or how to improve the program i will open to your comments _________________________________________________________________ Los mejores conciertos en exclusiva por MSN in concert http://video.msn.com/?mkt=es-mx -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Fri Jul 25 17:26:54 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 25 Jul 2008 16:26:54 +0100 Subject: [python-win32] from excel to word In-Reply-To: References: Message-ID: <4889F0BE.6010601@timgolden.me.uk> Emanuel Sotelo wrote: > #word part > wordapp = Dispatch("Word.Application") > wordapp.Visible = 1 > worddoc = wordapp.Documents.Add() > rango = worddoc.Range(0,0) > rango.InsertBefore('hi we are goin to bring the data from excel and have > it print in word') > worddoc.SaveAs(MYDIR+ '\\wordexcel.doc') > rango.InsertAfter(xl.Cells(3,6)) > > #print part > dc= win32ui.CreateDC() > dc.CreatePrinterDC() > # i dont now what else is supposed to go in this part to send it to print Well, you don't need to mess with Device Contexts in order to print from Word. As with most "How do I do this in MS Office?" questions, the answer is: record a macro which does what you want, and then look at the resulting VBA code and reproduce it in Python -- which is usually trivial. TJG From ing_emanuels at hotmail.com Fri Jul 25 19:34:37 2008 From: ing_emanuels at hotmail.com (Emanuel Sotelo) Date: Fri, 25 Jul 2008 12:34:37 -0500 Subject: [python-win32] i have this code, how do i passed to word Message-ID: hello again well this time a grab this code from a web page, the result is printed in the Interactive Window, now i will appreciated if some can help me pass this result to microsoft word This example shows you the available ProgIDs of the Windows applications which are installed and ahould be usable with win32com i will leave the code here: import win32com.client from win32com.client import Dispatch strComputer = "." objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator") objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2") colItems = objSWbemServices.ExecQuery("Select * from Win32_ProgIDSpecification") for objItem in colItems: print "Caption: ", objItem.Caption print "Check ID: ", objItem.CheckID print "Check Mode: ", objItem.CheckMode print "Description: ", objItem.Description print "Name: ", objItem.Name print "Parent: ", objItem.Parent print "ProgID: ", objItem.ProgID print "Software Element ID: ", objItem.SoftwareElementID print "Software Element State: ", objItem.SoftwareElementState print "Target Operating System: ", objItem.TargetOperatingSystem print "Version: ", objItem.Version print "-------------------------------------------------------------------" _________________________________________________________________ Juega y gana, tenemos 3 Xbox a la semana. http://club.prodigymsn.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From ing_emanuels at hotmail.com Fri Jul 25 19:36:18 2008 From: ing_emanuels at hotmail.com (Emanuel Sotelo) Date: Fri, 25 Jul 2008 12:36:18 -0500 Subject: [python-win32] i have this code, how do i passed to word Message-ID: hello again well this time a grab this code from a web page, the result is printed in the Interactive Window, now i will appreciated if some can help me pass this result to microsoft word This example shows you the available ProgIDs of the Windows applications which are installed and ahould be usable with win32com i will leave the code here: import win32com.client from win32com.client import Dispatch strComputer = "." objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator") objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2") colItems = objSWbemServices.ExecQuery("Select * from Win32_ProgIDSpecification") for objItem in colItems: print "Caption: ", objItem.Caption print "Check ID: ", objItem.CheckID print "Check Mode: ", objItem.CheckMode print "Description: ", objItem.Description print "Name: ", objItem.Name print "Parent: ", objItem.Parent print "ProgID: ", objItem.ProgID print "Software Element ID: ", objItem.SoftwareElementID print "Software Element State: ", objItem.SoftwareElementState print "Target Operating System: ", objItem.TargetOperatingSystem print "Version: ", objItem.Version print "-------------------------------------------------------------------" _________________________________________________________________ Tenemos lo que b?scas?JUEGOS. http://club.prodigymsn.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From ing_emanuels at hotmail.com Fri Jul 25 19:36:18 2008 From: ing_emanuels at hotmail.com (Emanuel Sotelo) Date: Fri, 25 Jul 2008 12:36:18 -0500 Subject: [python-win32] i have this code, how do i passed to word Message-ID: hello again well this time a grab this code from a web page, the result is printed in the Interactive Window, now i will appreciated if some can help me pass this result to microsoft word This example shows you the available ProgIDs of the Windows applications which are installed and ahould be usable with win32com i will leave the code here: import win32com.client from win32com.client import Dispatch strComputer = "." objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator") objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2") colItems = objSWbemServices.ExecQuery("Select * from Win32_ProgIDSpecification") for objItem in colItems: print "Caption: ", objItem.Caption print "Check ID: ", objItem.CheckID print "Check Mode: ", objItem.CheckMode print "Description: ", objItem.Description print "Name: ", objItem.Name print "Parent: ", objItem.Parent print "ProgID: ", objItem.ProgID print "Software Element ID: ", objItem.SoftwareElementID print "Software Element State: ", objItem.SoftwareElementState print "Target Operating System: ", objItem.TargetOperatingSystem print "Version: ", objItem.Version print "-------------------------------------------------------------------" _________________________________________________________________ Tenemos lo que b?scas?JUEGOS. http://club.prodigymsn.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Jul 25 20:21:59 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 25 Jul 2008 11:21:59 -0700 Subject: [python-win32] i have this code, how do i passed to word In-Reply-To: References: Message-ID: <488A19C7.8010404@probo.com> Emanuel Sotelo wrote: > hello again well this time a grab this code from a web page, the > result is printed in the Interactive > Window, now i will appreciated if some can help me pass this result > to microsoft word > This example shows you the available ProgIDs of the Windows > applications which are installed and > ahould be usable with win32com What do you mean by "pass this result to Microsoft Word"? If you're running this in idle, you can cut-and-paste the results into Word. If you're running from a command line, you can redirect the results to a file and open that file in Word. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ing_emanuels at hotmail.com Fri Jul 25 20:33:33 2008 From: ing_emanuels at hotmail.com (Emanuel Sotelo) Date: Fri, 25 Jul 2008 13:33:33 -0500 Subject: [python-win32] i have this code, how do i passed to word Message-ID: hello Tim yes that is something that i did, it was printed in the idle and a cut-and-paste to word. what i was wondering if it is posible to print the result in word instead of idle? what line codes do i need to make this hapend? _________________________________________________________________ P.D. Checa las nuevas fotos de mi Space http://home.services.spaces.live.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Jul 25 20:49:38 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 25 Jul 2008 11:49:38 -0700 Subject: [python-win32] i have this code, how do i passed to word In-Reply-To: References: Message-ID: <488A2042.9000600@probo.com> Emanuel Sotelo wrote: > hello Tim > yes that is something that i did, it was printed in the idle and a > cut-and-paste to word. > what i was wondering if it is posible to print the result in word > instead of idle? > what line codes do i need to make this hapend? I hope you do not think I am being stubborn, but the right answer depends on what your REAL task is. It IS possible to automate Word, but it is rather tedious, and in many cases there are better ways to accomplish your task. If this is for a one-time thing, where you just need to print the list, then what you did is exactly the right way. It isn't necessary (or beneficial) to automate everything. If this is something you need to do once in a while, then have the script write the information to a .txt file, then open the .txt file in Word to do your formatting. If you need to make a regular report out of this, then there are better ways than Word. One excellent way to do this is to write your text as an HTML page, with appropriate tags to lay it out exactly as you want, then launch the HTML page and let IE or Firefox do the formatting. wxPython even includes a module called HtmlEasyPrinting to help with this. If you really need to insert this text into an existing Word document, then you need to open the Word COM object and use the Word object model. See here for hints: http://www.faqts.com/knowledge_base/view.phtml/aid/37034/fid/244 word = win32com.client.EnsureDispatch( "Word.Application" ) word.Visible = 1 # if you want to watch the process doc = app.Documents.Add() doc.Content.Text = "This is the string to add to the document." doc.Content.MoveEnd() doc.Close() word.Quit() -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From cappy2112 at gmail.com Fri Jul 25 21:21:59 2008 From: cappy2112 at gmail.com (Tony Cappellini) Date: Fri, 25 Jul 2008 12:21:59 -0700 Subject: [python-win32] Excel Document Message-ID: <8249c4ac0807251221r4f6e7ffek3d6c6bdd1944fac@mail.gmail.com> Message: 1 Date: Fri, 25 Jul 2008 12:52:04 +0200 From: Michiel Overtoom Subject: Re: [python-win32] Excel Document To: python-win32 at python.org Message-ID: <2.2.32.20080725105204.0160c9ec at pop.xs4all.nl> Content-Type: text/plain; charset="us-ascii" Sina wrote... >To read the contents of an excel spreadsheet. In one case I am trying to >read the value of the cell rather than its contents. i.e. if I have a >hyperlink called "Document" or "Procedure" which is a hyperlink to >http://intranet/foo.pdf then this script will return "Document" or "Link" as >a unicode string rather than the URL that I require. If you want to read/write a spreadsheet you can also do this on a system that does not have Excel installed, and does not need a COM interface. However, there are some limitations with this library, but for reading numbers and text, it has been working well for me. http://sourceforge.net/projects/pyexcelerator http://www.lexicon.net/sjmachin/xlrd.htm From ing_emanuels at hotmail.com Fri Jul 25 21:22:03 2008 From: ing_emanuels at hotmail.com (Emanuel Sotelo) Date: Fri, 25 Jul 2008 14:22:03 -0500 Subject: [python-win32] i have this code, how do i passed to word Message-ID: thanks Tim i will look into all the opcions that you give me, but more specific in the one were a printed in a txt file. well you see a im beginning to lear python a used to only program in VB, so maybe that is the reason that i wan to automate everything. _________________________________________________________________ Los mejores conciertos en exclusiva por MSN in concert http://video.msn.com/?mkt=es-mx -------------- next part -------------- An HTML attachment was scrubbed... URL: From execrable at gmail.com Sat Jul 26 00:57:02 2008 From: execrable at gmail.com (Brian Parma) Date: Fri, 25 Jul 2008 15:57:02 -0700 Subject: [python-win32] SetCursor Message-ID: Is this function working? When I try it using a default cursor (IDC_WAIT), the cursor changes only if the mouse is over the window, and even then if I move the mouse at all it reverts back immediately. I googled this problem a bit and only found one mailing list post on this problem, but there was no solution posted, is this a bug? -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sat Jul 26 01:13:47 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 25 Jul 2008 16:13:47 -0700 Subject: [python-win32] SetCursor In-Reply-To: References: Message-ID: <488A5E2B.7020502@probo.com> Brian Parma wrote: > Is this function working? When I try it using a default cursor > (IDC_WAIT), the cursor changes only if the mouse is over the window, > and even then if I move the mouse at all it reverts back immediately. > > I googled this problem a bit and only found one mailing list post on > this problem, but there was no solution posted, is this a bug? The first part of your question is just the way Windows is designed. YOUR application is busy, but other applications are just fine. Why should your cursor choice be foisted upon other applications? As to the "reverts back immediately", do you have a runnable sample that shows this? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From execrable at gmail.com Sat Jul 26 02:50:16 2008 From: execrable at gmail.com (Brian Parma) Date: Fri, 25 Jul 2008 17:50:16 -0700 Subject: [python-win32] SetCursor In-Reply-To: <488A5E2B.7020502@probo.com> References: <488A5E2B.7020502@probo.com> Message-ID: On Fri, Jul 25, 2008 at 4:13 PM, Tim Roberts wrote: > Brian Parma wrote: > >> Is this function working? When I try it using a default cursor >> (IDC_WAIT), the cursor changes only if the mouse is over the window, and >> even then if I move the mouse at all it reverts back immediately. >> I googled this problem a bit and only found one mailing list post on this >> problem, but there was no solution posted, is this a bug? >> > > The first part of your question is just the way Windows is designed. YOUR > application is busy, but other applications are just fine. Why should your > cursor choice be foisted upon other applications? > > As to the "reverts back immediately", do you have a runnable sample that > shows this? > > -- > 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 > I was under the impression that SetCursor sets the mouse cursor 'system-wide', not just for your window. At least that's how it seems to work in this C++ example: For the second part, this example produces it. It uses PyQt4, could that be causing the problem? It changes the Icon on any key press when the window has focus. import win32con as w32c import win32gui as w32g from PyQt4 import QtGui, QtCore import pyHook, sys class WindowFinder(QtGui.QWidget): def __init__(self, parent=None, icon=None): QtGui.QWidget.__init__(self, parent) self.resize(200,200) def keyPressEvent(self, event): print 'set' hC = w32g.LoadCursor(0,w32c.IDC_WAIT) print w32g.SetCursor(hC) if __name__ == '__main__': app = QtGui.QApplication(sys.argv) wf = WindowFinder() wf.show() app.exec_() -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Sat Jul 26 03:13:48 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 25 Jul 2008 18:13:48 -0700 Subject: [python-win32] SetCursor In-Reply-To: References: <488A5E2B.7020502@probo.com> Message-ID: <488A7A4C.7030503@probo.com> Brian Parma wrote: > > > I was under the impression that SetCursor sets the mouse cursor > 'system-wide', not just for your window. At least that's how it seems > to work in this C++ example: No. It did in Win16, but not in the Win32 systems. > For the second part, this example produces it. It uses PyQt4, could > that be causing the problem? It changes the Icon on any key press > when the window has focus. Hmmm, I don't know enough about Qt to answer that. It's quite possible that Qt is doing its own cursor management, and is not expecting you to call the API behind its back. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From execrable at gmail.com Sat Jul 26 03:24:39 2008 From: execrable at gmail.com (Brian Parma) Date: Fri, 25 Jul 2008 18:24:39 -0700 Subject: [python-win32] SetCursor In-Reply-To: <488A7A4C.7030503@probo.com> References: <488A5E2B.7020502@probo.com> <488A7A4C.7030503@probo.com> Message-ID: On Fri, Jul 25, 2008 at 6:13 PM, Tim Roberts wrote: > Brian Parma wrote: > >> >> >> I was under the impression that SetCursor sets the mouse cursor >> 'system-wide', not just for your window. At least that's how it seems to >> work in this C++ example: >> > > No. It did in Win16, but not in the Win32 systems. > > > For the second part, this example produces it. It uses PyQt4, could that >> be causing the problem? It changes the Icon on any key press when the >> window has focus. >> > > Hmmm, I don't know enough about Qt to answer that. It's quite possible > that Qt is doing its own cursor management, and is not expecting you to call > the API behind its back. > > > -- > 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 > Oops, forgot to post the link for the C++ example: http://www.codeproject.com/KB/dialog/windowfinder.aspx The way it works is, when you click on the 'target' the mouse cursor changes, and it is kept that way as long as you keep the mouse button down, even when you drag the mouse out of the window (that's the point of the application). -------------- next part -------------- An HTML attachment was scrubbed... URL: From singhai.nish at gmail.com Sat Jul 26 20:29:41 2008 From: singhai.nish at gmail.com (kNish) Date: Sat, 26 Jul 2008 23:59:41 +0530 Subject: [python-win32] class and modules Message-ID: <81bfef2e0807261129s11f48277i5de8cce6a6b61ee2@mail.gmail.com> Hi, I went thru the notes. I said i will understand when the group explains this to me. How much difference does it make to call a module as it and call it as being part of a class. Say Class a: def b: def b: def c: def c: Do I need to know more before asking this question. Fill in the blanks. Brgds, kNish -------------- next part -------------- An HTML attachment was scrubbed... URL: From gerdusvanzyl at gmail.com Sat Jul 26 21:49:07 2008 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Sat, 26 Jul 2008 21:49:07 +0200 Subject: [python-win32] class and modules In-Reply-To: <81bfef2e0807261129s11f48277i5de8cce6a6b61ee2@mail.gmail.com> References: <81bfef2e0807261129s11f48277i5de8cce6a6b61ee2@mail.gmail.com> Message-ID: <91882ea90807261249y36048c97q874a7a904cabc984@mail.gmail.com> Wel firstly it won't work, the class should be: class a(object): def b(self): print "b" def c(self): print "c" so to call b you first need instance of object: myA = a() myA.b() I am not really understanding what you wish to achieve. Also you say "I went thru the notes.", what notes? Are you trying to learn python in general or do you wish to do something specific? ~Gerdus On Sat, Jul 26, 2008 at 8:29 PM, kNish wrote: > Hi, > > I went thru the notes. I said i will understand when the group > explains this to me. How much difference does it make to call a module as it > and call it as being part of a class. Say > > Class a: > def b: def b: > > > def c: def c: > > Do I need to know more before asking this question. Fill in the blanks. > > > Brgds, > > > kNish > > > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From motoom at xs4all.nl Sun Jul 27 03:19:09 2008 From: motoom at xs4all.nl (Michiel Overtoom) Date: Sun, 27 Jul 2008 03:19:09 +0200 Subject: [python-win32] SetCursor Message-ID: <2.2.32.20080727011909.01231df8@pop.xs4all.nl> Brian wrote... >The way it works is, when you click on the 'target' the mouse cursor >changes, and it is kept that way as long as you keep the mouse button down, >even when you drag the mouse out of the window (that's the point of the >application). Have you tried to 'capture' the mouse with SetCapture(windowhandle) ? Greetings, -- "The ability of the OSS process to collect and harness the collective IQ of thousands of individuals across the Internet is simply amazing." - Vinod Vallopillil http://www.catb.org/~esr/halloween/halloween4.html From execrable at gmail.com Sun Jul 27 03:42:03 2008 From: execrable at gmail.com (Brian Parma) Date: Sat, 26 Jul 2008 18:42:03 -0700 Subject: [python-win32] SetCursor In-Reply-To: <2.2.32.20080727011909.01231df8@pop.xs4all.nl> References: <2.2.32.20080727011909.01231df8@pop.xs4all.nl> Message-ID: On Sat, Jul 26, 2008 at 6:19 PM, Michiel Overtoom wrote: > Brian wrote... > > >The way it works is, when you click on the 'target' the mouse cursor > >changes, and it is kept that way as long as you keep the mouse button > down, > >even when you drag the mouse out of the window (that's the point of the > >application). > > Have you tried to 'capture' the mouse with SetCapture(windowhandle) ? > > Greetings, > > > -- > "The ability of the OSS process to collect and harness > the collective IQ of thousands of individuals across > the Internet is simply amazing." - Vinod Vallopillil > http://www.catb.org/~esr/halloween/halloween4.html > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > Ok that's another thing I was wondering about but didn't want to ask a ton of stuff in one post. The C++ uses SetCapture, so I was wondering if that is why it was able to control the cursor outside it's own window. I also tried this in my python example, but it seemed to have no effect on the results at all. -------------- next part -------------- An HTML attachment was scrubbed... URL: From larry.bates at websafe.com Sun Jul 27 04:08:47 2008 From: larry.bates at websafe.com (Larry Bates) Date: Sat, 26 Jul 2008 21:08:47 -0500 Subject: [python-win32] class and modules In-Reply-To: <81bfef2e0807261129s11f48277i5de8cce6a6b61ee2@mail.gmail.com> References: <81bfef2e0807261129s11f48277i5de8cce6a6b61ee2@mail.gmail.com> Message-ID: kNish wrote: > Hi, > > I went thru the notes. I said i will understand when the > group explains this to me. How much difference does it make to call a > module as it and call it as being part of a class. Say > > Class a: > def b: def b: > > > def c: &nbs p; def c: > > Do I need to know more before asking this question. Fill in the blanks. > > > Brgds, > > > kNish > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 There is not difference in how you "call" them. They are both functions that take arguments and can optionally return values. The difference is that in the class you can more easily maintain other information (like state) that can be used to effect the calls. -Larry From egregio at gmail.com Mon Jul 28 15:14:17 2008 From: egregio at gmail.com (_ _) Date: Mon, 28 Jul 2008 15:14:17 +0200 Subject: [python-win32] win32security.LogonUser In-Reply-To: <48885E14.8080208@timgolden.me.uk> References: <1bdf59490807240057v160b023fm8e343d20c653a5f1@mail.gmail.com> <48883A83.7000106@timgolden.me.uk> <1bdf59490807240136l297f24a3g2dc895d966f6d265@mail.gmail.com> <48885055.8060702@timgolden.me.uk> <1bdf59490807240334i50fc1104y5cf3a316b768e564@mail.gmail.com> <48885E14.8080208@timgolden.me.uk> Message-ID: <1bdf59490807280614w4c1637d4gda86439050c1dad4@mail.gmail.com> Woks!!!... Thanks a lot!! 2008/7/24 Tim Golden > _ _ wrote: > >> + I use os.path.isfile ("D:/test/local/file.txt") and return False. And >> "D:/test/local/file.txt" exists! >> + If I try to read a file return a error... >> + The user can't read or write files when I impersonated. But if I login >> interactive, or execute as, with this user ("testUser") I can read and write >> files... >> + With other user don't work. But If impersonated user is equal "main >> user" this works... >> >> More things: >> After impersonated, If I execute win32api.GetUserName() returns "testUser" >> After impersonated, if I try execute os.system ("dir") returns -1 >> I can impersonate another user and write a file to an arbitrary point on >> my filesystem in other computer. This computer (where impersonated works) is >> out of windows domain. >> > > > Sorry, stupid of me: I didn't notice that you were > specifying a LOGON_NETWORK in the call to LogonUser. > Try using LOGON32_LOGON_INTERACTIVE instead. The > NETWORK_LOGON flag works fine for checking credentials > (altho' you're supposed to do that via SSPI these days) > but doesn't give you enough of a token to get hold of > local resources, I think. > > The fact that you can access remote resources might be > because the remote non-domain machine allows guest > access. > > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From egregio at gmail.com Mon Jul 28 15:24:41 2008 From: egregio at gmail.com (_ _) Date: Mon, 28 Jul 2008 15:24:41 +0200 Subject: [python-win32] How can I modify owner file in windows?? Message-ID: <1bdf59490807280624k34061b46jf40d05ddd61e940@mail.gmail.com> How can I modify owner file in windows??. I try with: win32security.SetFileSecurity (FILENAME, win32security.OWNER_SECURITY_INFORMATION, sd) Thanks a lot... -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Mon Jul 28 16:17:07 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 28 Jul 2008 15:17:07 +0100 Subject: [python-win32] How can I modify owner file in windows?? In-Reply-To: <1bdf59490807280624k34061b46jf40d05ddd61e940@mail.gmail.com> References: <1bdf59490807280624k34061b46jf40d05ddd61e940@mail.gmail.com> Message-ID: <488DD4E3.1080209@timgolden.me.uk> _ _ wrote: > How can I modify owner file in windows??. > > I try with: > > win32security.SetFileSecurity (FILENAME, win32security.OWNER_SECURITY_INFORMATION, sd) To paraphrase someone or another "I didn't have time to write a short answer so I wrote a long one": http://timgolden.me.uk/python-on-windows/programming-areas/security/ownership.html TJG From egregio at gmail.com Tue Jul 29 11:59:53 2008 From: egregio at gmail.com (_ _) Date: Tue, 29 Jul 2008 11:59:53 +0200 Subject: [python-win32] How can I modify owner file in windows?? In-Reply-To: <488DD4E3.1080209@timgolden.me.uk> References: <1bdf59490807280624k34061b46jf40d05ddd61e940@mail.gmail.com> <488DD4E3.1080209@timgolden.me.uk> Message-ID: <1bdf59490807290259t6938fdc9va2bbed439b8fe77e@mail.gmail.com> Hi... Thanks... I try this but I have errors: pywintypes.error: (1307, or pywintypes.error: (5, I create "file1.txt" with user "user1" and I try change owner to "user2" but don't work. "user1" and "user2" are users in domain "domain1"... Can you help me please?? 2008/7/28 Tim Golden > _ _ wrote: > >> How can I modify owner file in windows??. >> >> I try with: >> >> win32security.SetFileSecurity (FILENAME, >> win32security.OWNER_SECURITY_INFORMATION, sd) >> > > To paraphrase someone or another "I didn't have time to > write a short answer so I wrote a long one": > > > http://timgolden.me.uk/python-on-windows/programming-areas/security/ownership.html > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Jul 29 12:09:23 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 29 Jul 2008 11:09:23 +0100 Subject: [python-win32] How can I modify owner file in windows?? In-Reply-To: <1bdf59490807290259t6938fdc9va2bbed439b8fe77e@mail.gmail.com> References: <1bdf59490807280624k34061b46jf40d05ddd61e940@mail.gmail.com> <488DD4E3.1080209@timgolden.me.uk> <1bdf59490807290259t6938fdc9va2bbed439b8fe77e@mail.gmail.com> Message-ID: <488EEC53.2080404@timgolden.me.uk> _ _ wrote: > Hi... Thanks... > > I try this but I have errors: > > pywintypes.error: (1307, > or > pywintypes.error: (5, > > I create "file1.txt" with user "user1" and I try change owner to "user2" > but don't work. > "user1" and "user2" are users in domain "domain1"... > > Can you help me please?? Sorry; I need to test that page some more. Use the WMI solution; it's much easier: import wmi FILENAME = "c:/temp/temp.txt" c = wmi.WMI () for file in c.CIM_DataFile (Name=FILENAME): file.TakeOwnerShip () TJG From mail at timgolden.me.uk Tue Jul 29 12:10:13 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 29 Jul 2008 11:10:13 +0100 Subject: [python-win32] How can I modify owner file in windows?? In-Reply-To: <1bdf59490807290259t6938fdc9va2bbed439b8fe77e@mail.gmail.com> References: <1bdf59490807280624k34061b46jf40d05ddd61e940@mail.gmail.com> <488DD4E3.1080209@timgolden.me.uk> <1bdf59490807290259t6938fdc9va2bbed439b8fe77e@mail.gmail.com> Message-ID: <488EEC85.80707@timgolden.me.uk> _ _ wrote: > Hi... Thanks... > > I try this but I have errors: > > pywintypes.error: (1307, > or > pywintypes.error: (5, > > I create "file1.txt" with user "user1" and I try change owner to "user2" > but don't work. > "user1" and "user2" are users in domain "domain1"... > > Can you help me please?? Also, please note that you can't *assign* ownership; you can only *take* ownership. You have to *be* user2 to change the owner to user2. TJG From siddhartha.veedaluru at gmail.com Tue Jul 29 13:27:17 2008 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Tue, 29 Jul 2008 16:57:17 +0530 Subject: [python-win32] Access is denied while retriving 64 bit registry from 32bit python script Message-ID: <424b71ec0807290427k380b8ccfgdddcdfcd48dc6131@mail.gmail.com> Hi, Hello, I have installed 32bit python on x64 bit machine. I also installed pywin32-211.win32-py2.5.exe As part of a script i required to access the registry and i used the following code snippet. import os, sys from _winreg import * KEY_WOW64_64KEY = 256 regHandle = OpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\Valule Systems\ValApp\Instance001",0,KEY_WOW64_64KEY or KEY_READ or KEY_WRITE) print regHandle val = QueryValue(regHandle,"sPhysicalNodeName") print val gives C:\Precert>test.py Traceback (most recent call last): File "C:\Precert\test.py", line 4, in regHandle = OpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\Value Systems\ValApp\In stance001",0,KEY_WOW64_64KEY or KEY_READ or KEY_WRITE) WindowsError: [Error 5] Access is denied Please help regards Siddhartha -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Jul 29 14:18:38 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 29 Jul 2008 13:18:38 +0100 Subject: [python-win32] Access is denied while retriving 64 bit registry from 32bit python script In-Reply-To: <424b71ec0807290427k380b8ccfgdddcdfcd48dc6131@mail.gmail.com> References: <424b71ec0807290427k380b8ccfgdddcdfcd48dc6131@mail.gmail.com> Message-ID: <488F0A9E.2000303@timgolden.me.uk> siddhartha veedaluru wrote: > Hi, > Hello, > > I have installed 32bit python on x64 bit machine. > I also installed pywin32-211.win32-py2.5.exe > > As part of a script i required to access the registry and i used the > following code snippet. > > import os, sys > from _winreg import * > KEY_WOW64_64KEY = 256 > regHandle = OpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\Valule > Systems\ValApp\Instance001",0,KEY_WOW64_64KEY or KEY_READ or KEY_WRITE) > print regHandle > val = QueryValue(regHandle,"sPhysicalNodeName") > print val Ignoring for the moment the problem at hand... ...why do you think that KEY_WOW64_64KEY or KEY_READ or KEY_WRITE will give you a bitwise or? Try this in the interpreter: A, B, C = 1, 2, 4 print A or B or C You probably want A | B | C TJG From newmurr at gmail.com Tue Jul 29 15:34:54 2008 From: newmurr at gmail.com (Murr Von Kater) Date: Tue, 29 Jul 2008 16:34:54 +0300 Subject: [python-win32] Problem with simple example Message-ID: Hi all! I'm beginer in python-win32 and i try a simple example which is described in "Python for Win32 Extensions Help": import win32com.client o = win32com.client.Dispatch("Excel.Application") o.Visible = 1 o.Workbooks.Add() # for office 97 ? 95 a bit different! o.Cells(1,1).Value = "Hello" But this example falls with traceback: File "D:\Python25\pyprojects\pyexample\pyexample.py", line 6, in o.Workbooks.Add() # for office 97 ? 95 a bit different! File "D:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 467, in __getattr__ if self._olerepr_.mapFuncs.has_key(attr): return self._make_method_(attr) File "D:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 295, in _make_method_ methodCodeList = self._olerepr_.MakeFuncMethod(self._olerepr_.mapFuncs[name], methodName,0) File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 297, in MakeFuncMethod return self.MakeDispatchFuncMethod(entry, name, bMakeClass) File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 318, in MakeDispatchFuncMethod s = linePrefix + 'def ' + name + '(self' + BuildCallList(fdesc, names, defNamedOptArg, defNamedNotOptArg, defUnnamedArg, defOutArg) + '):' File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 604, in BuildCallList argName = MakePublicAttributeName(argName) File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 542, in MakePublicAttributeName return filter( lambda char: char in valid_identifier_chars, className) File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 542, in return filter( lambda char: char in valid_identifier_chars, className) UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 52: ordinal not in range(128) Is it bug or may be i should set some settings to make it works? I use WinXP and MS Office 2003. Python-win32 has been intalled on my PC with pywin32-211.win32-py2.5.exe installer. -------------- next part -------------- An HTML attachment was scrubbed... URL: From pochon.jeremie at gmail.com Tue Jul 29 15:43:38 2008 From: pochon.jeremie at gmail.com (=?ISO-8859-1?Q?Pochon_J=E9r=E9mie?=) Date: Tue, 29 Jul 2008 15:43:38 +0200 Subject: [python-win32] Problem with simple example In-Reply-To: References: Message-ID: <62d391610807290643u75b5f119jf4ff3460bd29d606@mail.gmail.com> https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1998611&group_id=78018 2008/7/29 Murr Von Kater > Hi all! > > I'm beginer in python-win32 and i try a simple example which is described > in "Python for Win32 Extensions Help": > > import win32com.client > o = win32com.client.Dispatch(" Excel.Application") > o.Visible = 1 > o.Workbooks.Add() # for office 97 ? 95 a bit different! > o.Cells(1,1).Value = "Hello" > > But this example falls with traceback: > > File "D:\Python25\pyprojects\pyexample\pyexample.py", line 6, in > o.Workbooks.Add() # for office 97 ? 95 a bit different! > File "D:\Python25\Lib\site-packages\win32com\client\dynamic.py", line > 467, in __getattr__ > if self._olerepr_.mapFuncs.has_key(attr): return > self._make_method_(attr) > File "D:\Python25\Lib\site-packages\win32com\client\dynamic.py", line > 295, in _make_method_ > methodCodeList = > self._olerepr_.MakeFuncMethod(self._olerepr_.mapFuncs[name], methodName,0) > File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 297, > in MakeFuncMethod > return self.MakeDispatchFuncMethod(entry, name, bMakeClass) > File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 318, > in MakeDispatchFuncMethod > s = linePrefix + 'def ' + name + '(self' + BuildCallList(fdesc, names, > defNamedOptArg, defNamedNotOptArg, defUnnamedArg, defOutArg) + '):' > File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 604, > in BuildCallList > argName = MakePublicAttributeName(argName) > File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 542, > in MakePublicAttributeName > return filter( lambda char: char in valid_identifier_chars, className) > File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 542, > in > return filter( lambda char: char in valid_identifier_chars, className) > UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 52: > ordinal not in range(128) > > Is it bug or may be i should set some settings to make it works? I use > WinXP and MS Office 2003. Python-win32 has been intalled on my PC with > pywin32-211.win32-py2.5.exe installer. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- J?r?mie POCHON Portable : 06 19 50 00 48 mail : jeremie.pochon at supaero.fr -------------- next part -------------- An HTML attachment was scrubbed... URL: From rdahlstrom at directedge.com Tue Jul 29 15:47:00 2008 From: rdahlstrom at directedge.com (Dahlstrom, Roger) Date: Tue, 29 Jul 2008 09:47:00 -0400 Subject: [python-win32] Problem with simple example References: Message-ID: I copied and pasted your code (except for removing the line break in your line 2) and it worked fine for me. import win32com.client o = win32com.client.Dispatch("Excel.Application") o.Visible = 1 o.Workbooks.Add() o.Cells(1,1).Value = "Hello" This produced a visible Excel window, with Book1 visible and active, with the word "Hello" in row 1 column A. ________________________________ From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Murr Von Kater Sent: Tuesday, July 29, 2008 9:35 AM To: python-win32 at python.org Subject: [python-win32] Problem with simple example Hi all! I'm beginer in python-win32 and i try a simple example which is described in "Python for Win32 Extensions Help": import win32com.client o = win32com.client.Dispatch(" Excel.Application") o.Visible = 1 o.Workbooks.Add() # for office 97 - 95 a bit different! o.Cells(1,1).Value = "Hello" But this example falls with traceback: File "D:\Python25\pyprojects\pyexample\pyexample.py", line 6, in o.Workbooks.Add() # for office 97 - 95 a bit different! File "D:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 467, in __getattr__ if self._olerepr_.mapFuncs.has_key(attr): return self._make_method_(attr) File "D:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 295, in _make_method_ methodCodeList = self._olerepr_.MakeFuncMethod(self._olerepr_.mapFuncs[name], methodName,0) File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 297, in MakeFuncMethod return self.MakeDispatchFuncMethod(entry, name, bMakeClass) File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 318, in MakeDispatchFuncMethod s = linePrefix + 'def ' + name + '(self' + BuildCallList(fdesc, names, defNamedOptArg, defNamedNotOptArg, defUnnamedArg, defOutArg) + '):' File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 604, in BuildCallList argName = MakePublicAttributeName(argName) File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 542, in MakePublicAttributeName return filter( lambda char: char in valid_identifier_chars, className) File "D:\Python25\Lib\site-packages\win32com\client\build.py", line 542, in return filter( lambda char: char in valid_identifier_chars, className) UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 52: ordinal not in range(128) Is it bug or may be i should set some settings to make it works? I use WinXP and MS Office 2003. Python-win32 has been intalled on my PC with pywin32-211.win32-py2.5.exe installer. -------------- next part -------------- An HTML attachment was scrubbed... URL: From siddhartha.veedaluru at gmail.com Tue Jul 29 16:23:40 2008 From: siddhartha.veedaluru at gmail.com (siddhartha veedaluru) Date: Tue, 29 Jul 2008 19:53:40 +0530 Subject: [python-win32] Access is denied while retriving 64 bit registry from 32bit Message-ID: <424b71ec0807290723j5dedad2eic550c70c6c8e398@mail.gmail.com> Thanks Tim. Sorry,i was wrong in using the operators i modified the script and once again i ran it import os, sys from _winreg import * KEY_WOW64_64KEY = 256 regHandle = OpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\Value Systems\ValApp\Instance001",0,KEY_WOW64_64KEY|KEY_READ|KEY_WRITE) print regHandle val = QueryValue(regHandle,"sPhysicalNodeName") print val it gave the following window error.but the registry value is present. Traceback (most recent call last): File "C:\Precert\test.py", line 6, in val = QueryValue(regHandle,"sPhysicalNodeName") WindowsError: [Error 2] The system cannot find the file specified -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Jul 29 19:33:01 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 29 Jul 2008 10:33:01 -0700 Subject: [python-win32] Access is denied while retriving 64 bit registry from 32bit In-Reply-To: <424b71ec0807290723j5dedad2eic550c70c6c8e398@mail.gmail.com> References: <424b71ec0807290723j5dedad2eic550c70c6c8e398@mail.gmail.com> Message-ID: <488F544D.2080309@probo.com> siddhartha veedaluru wrote: > > i modified the script and once again i ran it > import os, sys > from _winreg import * > KEY_WOW64_64KEY = 256 > regHandle = OpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\Value > Systems\ValApp\Instance001",0,KEY_WOW64_64KEY|KEY_READ|KEY_WRITE) > print regHandle > val = QueryValue(regHandle,"sPhysicalNodeName") > print val > > it gave the following window error.but the registry value is present. > > > Traceback (most recent call last): > File "C:\Precert\test.py", line 6, in > val = QueryValue(regHandle,"sPhysicalNodeName") > WindowsError: [Error 2] The system cannot find the file specified Well, this makes the pretty strong argument that the "Value Systems\ValApp\Instance001" key in your 64-bit HKLM hive does not contain a value called "sPhysicalNodeName". -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Tue Jul 29 19:33:22 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 29 Jul 2008 10:33:22 -0700 Subject: [python-win32] How can I modify owner file in windows?? In-Reply-To: <1bdf59490807290259t6938fdc9va2bbed439b8fe77e@mail.gmail.com> References: <1bdf59490807280624k34061b46jf40d05ddd61e940@mail.gmail.com> <488DD4E3.1080209@timgolden.me.uk> <1bdf59490807290259t6938fdc9va2bbed439b8fe77e@mail.gmail.com> Message-ID: <488F5462.8020208@probo.com> _ _ wrote: > Hi... Thanks... > > I try this but I have errors: > > pywintypes.error: (1307, FYI, this is ERROR_INVALID_OWNER. > or > pywintypes.error: (5, This is ERROR_ACCESS_DENIED. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From fuzzyman at voidspace.org.uk Tue Jul 29 20:05:25 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 29 Jul 2008 19:05:25 +0100 Subject: [python-win32] IronPython Tutorial at PyCon UK Message-ID: <6f4025010807291105u362008ddg7270582597dd0418@mail.gmail.com> Hello all, September 12-14th at the Birmingham Conservatoire is the 2nd UK Python Conference, organised by the UK Python community. This year the conference starts with a tutorial day, and Christian Muirhead [#]_, Menno Smits and I will be running a half day IronPython tutorial. The tutorial day is only ?30, so if you're interested in learning about IronPython it is an ideal opportunity. Tutorials: http://www.pyconuk.org/timetable.html Currently accepted talks: http://www.pyconuk.org/talk_abstracts.html Booking: http://www.pyconuk.org/booking.html Details on a summary of the accepted talks and tutorials on my blog. http://www.voidspace.org.uk/python/weblog/arch_d7_2008_07_26.shtml#e996 Thanks Michael Foord .. [#] Christian and I are the authors of the nearly published IronPython in Action with Manning Publications. -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/ http://www.trypython.org/ http://www.ironpython.info/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From egregio at gmail.com Tue Jul 29 20:05:57 2008 From: egregio at gmail.com (_ _) Date: Tue, 29 Jul 2008 20:05:57 +0200 Subject: [python-win32] How can I modify owner file in windows?? In-Reply-To: <488F5462.8020208@probo.com> References: <1bdf59490807280624k34061b46jf40d05ddd61e940@mail.gmail.com> <488DD4E3.1080209@timgolden.me.uk> <1bdf59490807290259t6938fdc9va2bbed439b8fe77e@mail.gmail.com> <488F5462.8020208@probo.com> Message-ID: <1bdf59490807291105i5958faf4x6dae5eb7db136483@mail.gmail.com> can't *assign* ownership?? really? Thanks... 2008/7/29 Tim Roberts > _ _ wrote: > >> Hi... Thanks... >> >> I try this but I have errors: >> >> pywintypes.error: (1307, >> > > FYI, this is ERROR_INVALID_OWNER. > > or >> pywintypes.error: (5, >> > > This is ERROR_ACCESS_DENIED. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rwupole at msn.com Tue Jul 29 23:23:08 2008 From: rwupole at msn.com (Roger Upole) Date: Tue, 29 Jul 2008 17:23:08 -0400 Subject: [python-win32] Re: How can I modify owner file in windows?? Message-ID: You need to enable SE_RESTORE_NAME privilege to set the owner to an account other than your own. Roger From mail at timgolden.me.uk Wed Jul 30 10:08:36 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 30 Jul 2008 09:08:36 +0100 Subject: [python-win32] How can I modify owner file in windows?? In-Reply-To: References: Message-ID: <48902184.5090407@timgolden.me.uk> Roger Upole wrote: > You need to enable SE_RESTORE_NAME privilege to set > the owner to an account other than your own. Wow. It's amazing what you can bypass when you need to: presumably that's for use by backup/restore mechanisms which need to recreate the original security settings? Thanks as ever for the info, Roger. TJG From singhai.nish at gmail.com Wed Jul 30 13:28:37 2008 From: singhai.nish at gmail.com (kNish) Date: Wed, 30 Jul 2008 16:58:37 +0530 Subject: [python-win32] name not defined Message-ID: <81bfef2e0807300428m3148035ek7af7e7c1474b46dd@mail.gmail.com> Hi, I am using the following code to send mail from a open window in maya application. This gives me following error. I think it says that A2 is not created. What is a possible way to have this code send a mail. BRgds, kNish # Error: name 'A2' is not defined # Traceback (most recent call last): # File "", line 1, in # NameError: name 'A2' is not defined # import maya.cmds as cmds import smtplib import os class pMailmsg: "send message modules" def __init__(self): self.fUser = os.getenv("USERNAME") self.tUser = "ppro at eyeqube.com" self.conts = "" def pSendmsg(self,fromUser,toUser,contents): fU = cmds.textField(fromUser, query = True, text = True) tU = cmds.textField(toUser, query = True, text = True) co = cmds.textField(contents, query = True, text = True) cServer = smtplib.SMTP("xxx.xxx.x.x:xx") cServer.sendmail = (fU, tU, co) cServer.quit() def pShowWindow(self): fromWho = self.fUser toWhom = self.tUser window = cmds.window(width=150, height = 150) form = cmds.formLayout(numberOfDivisions = 200) fromText = cmds.text(label='From : ') fromUser = cmds.textField(width = 250) toText = cmds.text(label = 'To : ') toUser = cmds.textField(width = 250) subjectText = cmds.text(label = 'Subject : ') subject = cmds.textField(width = 250) contentsText = cmds.text(label = 'Contents : ') contents = cmds.scrollField(editable = True, wordWrap = True, width = 250, height = 100) submit = cmds.button(label = 'Send Mail', command = ('pSendmsg()')) cmds.textField(fromUser, edit = True, text = (fromWho + '@ eyeqube.com'), enable = False) cmds.textField(toUser, edit = True, text = toWhom, enable = False) cmds.textField(subject, edit = True,enable = False) cmds.formLayout( form, edit=True, attachForm=[(fromText, 'left', 5), (fromText, 'top', 5), (toText, 'left', 15), (fromUser, 'top', 5), (contents, 'left', 5), (submit, 'left', 165) ], attachControl=[(toText, 'top', 15, fromText), (subjectText, 'top', 25, toText), (contentsText, 'top',25,subjectText), (fromUser, 'left', 15, fromText), (toUser, 'top', 15, fromUser), (toUser, 'left', 15, toText), (subject, 'top', 15, toUser), (subject, 'left', 10, subjectText), (contents, 'top', 15, subject), (contents, 'left', 5, contentsText), (submit, 'top', 15, contents)]) cmds.showWindow( window ) c = pMailmsg() c.pShowWindow() -------------- next part -------------- An HTML attachment was scrubbed... URL: From rdahlstrom at directedge.com Wed Jul 30 13:36:21 2008 From: rdahlstrom at directedge.com (Dahlstrom, Roger) Date: Wed, 30 Jul 2008 07:36:21 -0400 Subject: [python-win32] name not defined References: <81bfef2e0807300428m3148035ek7af7e7c1474b46dd@mail.gmail.com> Message-ID: That seems like a roundabout way to send an email. def sendEmail(toe, frome, subject, body): import smtplib headers = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (frome, toe, subject) message = headers + body mailsvr = "MyMailServer" mailServer = smtplib.SMTP(mailsvr) mailServer.sendmail(frome, toe, message) mailServer.quit() sendEmail(me at somewhere.com , you at somewhere.com , "test subject", "Body") ________________________________ From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of kNish Sent: Wednesday, July 30, 2008 7:29 AM To: python-win32 at python.org Subject: [python-win32] name not defined Hi, I am using the following code to send mail from a open window in maya application. This gives me following error. I think it says that A2 is not created. What is a possible way to have this code send a mail. BRgds, kNish # Error: name 'A2' is not defined # Traceback (most recent call last): # File "", line 1, in # NameError: name 'A2' is not defined # import maya.cmds as cmds import smtplib import os class pMailmsg: "send message modules" def __init__(self): self.fUser = os.getenv("USERNAME") self.tUser = "ppro at eyeqube.com" self.conts = "" def pSendmsg(self,fromUser,toUser,contents): fU = cmds.textField(fromUser, query = True, text = True) tU = cmds.textField(toUser, query = True, text = True) co = cmds.textField(contents, query = True, text = True) cServer = smtplib.SMTP("xxx.xxx.x.x:xx") cServer.sendmail = (fU, tU, co) cServer.quit() def pShowWindow(self): fromWho = self.fUser toWhom = self.tUser window = cmds.window(width=150, height = 150) form = cmds.formLayout(numberOfDivisions = 200) fromText = cmds.text(label='From : ') fromUser = cmds.textField(width = 250) toText = cmds.text(label = 'To : ') toUser = cmds.textField(width = 250) subjectText = cmds.text(label = 'Subject : ') subject = cmds.textField(width = 250) contentsText = cmds.text(label = 'Contents : ') contents = cmds.scrollField(editable = True, wordWrap = True, width = 250, height = 100) submit = cmds.button(label = 'Send Mail', command = ('pSendmsg()')) cmds.textField(fromUser, edit = True, text = (fromWho + '@eyeqube.com'), enable = False) cmds.textField(toUser, edit = True, text = toWhom, enable = False) cmds.textField(subject, edit = True,enable = False) cmds.formLayout( form, edit=True, attachForm=[(fromText, 'left', 5), (fromText, 'top', 5), (toText, 'left', 15), (fromUser, 'top', 5), (contents, 'left', 5), (submit, 'left', 165) ], attachControl=[(toText, 'top', 15, fromText), (subjectText, 'top', 25, toText), (contentsText, 'top',25,subjectText), (fromUser, 'left', 15, fromText), (toUser, 'top', 15, fromUser), (toUser, 'left', 15, toText), (subject, 'top', 15, toUser), (subject, 'left', 10, subjectText), (contents, 'top', 15, subject), (contents, 'left', 5, contentsText), (submit, 'top', 15, contents)]) cmds.showWindow( window ) c = pMailmsg() c.pShowWindow() DISCLAIMER: This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE REGARDING PRIVACY AND CONFIDENTIALITY Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications. www.directedge.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From egregio at gmail.com Wed Jul 30 16:11:45 2008 From: egregio at gmail.com (_ _) Date: Wed, 30 Jul 2008 16:11:45 +0200 Subject: [python-win32] How can I modify owner file in windows?? In-Reply-To: <48902184.5090407@timgolden.me.uk> References: <48902184.5090407@timgolden.me.uk> Message-ID: <1bdf59490807300711j1924b2c4o41d42ce230dd8716@mail.gmail.com> Sorry... but..., how can I enable SE_RESTORE_NAME privilege?... Is a user property? Thanks again. 2008/7/30 Tim Golden > Roger Upole wrote: > >> You need to enable SE_RESTORE_NAME privilege to set >> the owner to an account other than your own. >> > > Wow. It's amazing what you can bypass when > you need to: presumably that's for use by > backup/restore mechanisms which need to recreate > the original security settings? > > Thanks as ever for the info, Roger. > > TJG > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Wed Jul 30 16:39:30 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 30 Jul 2008 15:39:30 +0100 Subject: [python-win32] How can I modify owner file in windows?? In-Reply-To: <1bdf59490807300711j1924b2c4o41d42ce230dd8716@mail.gmail.com> References: <48902184.5090407@timgolden.me.uk> <1bdf59490807300711j1924b2c4o41d42ce230dd8716@mail.gmail.com> Message-ID: <48907D22.4070302@timgolden.me.uk> _ _ wrote: > Sorry... but..., how can I enable SE_RESTORE_NAME privilege?... Is a > user property? It's a privilege. Have a look here: http://timgolden.me.uk/python-on-windows/programming-areas/security/privileges.html#id3 TJG From timr at probo.com Wed Jul 30 20:03:02 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 30 Jul 2008 11:03:02 -0700 Subject: [python-win32] name not defined In-Reply-To: <81bfef2e0807300428m3148035ek7af7e7c1474b46dd@mail.gmail.com> References: <81bfef2e0807300428m3148035ek7af7e7c1474b46dd@mail.gmail.com> Message-ID: <4890ACD6.8050308@probo.com> kNish wrote: > > I am using the following code to send mail from a open window > in maya application. This gives me following error. I think it says > that A2 is not created. What is a possible way to have this code send > a mail. > ... > # Error: name 'A2' is not defined > # Traceback (most recent call last): > # File "", line 1, in > # NameError: name 'A2' is not defined # There is nothing in your code that refers to a name 'A2', so this must be something maya-specific. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From birdprince at gmail.com Wed Jul 30 10:32:19 2008 From: birdprince at gmail.com (birdprince) Date: Wed, 30 Jul 2008 08:32:19 +0000 (UTC) Subject: [python-win32] Python COM Message-ID: I have implemented a COM in C++,buy i don't know how to use this COM in python. For example: the COM's ProgID is "MyCOM1.AdvMethod".this COM have two interfaces,the default interface's name is IAdvMethod,the second interface's name is IBasicMethod. I use this method to call the IAdvMethod's method,because IAdvMethod is the default interface code example: import win32com.client moncom = win32com.client.Dispatch('MyCOM1.AdvMethod') moncom.IAdvMethod(... who can tell me how to call the IBasicMethod's method?Thank you very much! From birdprince at gmail.com Thu Jul 31 03:26:13 2008 From: birdprince at gmail.com (birdprince) Date: Thu, 31 Jul 2008 01:26:13 +0000 (UTC) Subject: [python-win32] Python and COM Message-ID: I have implemented a COM in C++,buy i don't know how to use this COM in python. For example: the COM's ProgID is "MyCOM1.AdvMethod".this COM have two interfaces,the default interface's name is IAdvMethod,IAdvMethod have a method which name is Add,the second interface's name is IBasicMethod. IBasicMethod have a method which name is Sub.All the interface are based on IDispatch. who can tell me how to call the Add and Sub successful.Thank you very much,please answer my question in code. From birdprince at gmail.com Thu Jul 31 05:27:16 2008 From: birdprince at gmail.com (birdprince) Date: Thu, 31 Jul 2008 03:27:16 +0000 (UTC) Subject: [python-win32] IronPython COM Message-ID: I have implemented a COM in C++,buy i don't know how to use this COM in IronPython. For example: the COM's ProgID is "MyCOM1.AdvMethod".this COM have two interfaces,the default interface's name is IAdvMethod,IAdvMethod have a method which name is Add,the second interface's name is IBasicMethod. IBasicMethod have a method which name is Sub.All the interface are based on IDispatch. who can tell me how to call the Add and Sub successful.Thank you very much,please answer my question in code. From mail at timgolden.me.uk Thu Jul 31 10:30:00 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 31 Jul 2008 09:30:00 +0100 Subject: [python-win32] Python COM In-Reply-To: References: Message-ID: <48917808.9090004@timgolden.me.uk> birdprince wrote: > I have implemented a COM in C++,buy i don't know how to use this COM > in python. > For example: the COM's ProgID is "MyCOM1.AdvMethod".this COM have two > interfaces,the default interface's name is IAdvMethod,the second > interface's name is IBasicMethod. > I use this method to call the IAdvMethod's method,because IAdvMethod is the > default interface > code example: > import win32com.client > moncom = win32com.client.Dispatch('MyCOM1.AdvMethod') > moncom.IAdvMethod(... > > who can tell me how to call the IBasicMethod's method?Thank you very much! Well that looks like 3 emails in a few hours. And to the same list. Remarkable. In general, the win32com from pywin32 can't handle arbitrary non-Dispatch interfaces. Try comtypes: http://sourceforge.net/projects/comtypes TJG From timr at probo.com Thu Jul 31 20:04:46 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 31 Jul 2008 11:04:46 -0700 Subject: [python-win32] IronPython COM In-Reply-To: References: Message-ID: <4891FEBE.3020502@probo.com> birdprince wrote: > I have implemented a COM in C++,buy i don't know how to use this COM > in IronPython. > The technical details of IronPython are quite different from CPython. To talk COM, you have to use a magic subsystem called "Interop" that the people on this list will probably not know. I suggest you sign up for the IronPython mailing list here: http://lists.ironpython.com/listinfo.cgi/users-ironpython.com It only gets a few messages a day. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Jul 31 20:07:04 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 31 Jul 2008 11:07:04 -0700 Subject: [python-win32] Python and COM In-Reply-To: References: Message-ID: <4891FF48.8000504@probo.com> birdprince wrote: > I have implemented a COM in C++,buy i don't know how to use this COM > in python. > For example: the COM's ProgID is "MyCOM1.AdvMethod".this COM have two > interfaces,the default interface's name is IAdvMethod,IAdvMethod have a method > which name is Add,the second interface's name is IBasicMethod. IBasicMethod > have a method which name is Sub.All the interface are based on IDispatch. > > who can tell me how to call the Add and Sub successful. Have you read any of the documentation or any of the samples on using COM from Python? My guess is no. If you have, why don't you post what you tried and tell us what happened when you tried it? > Thank you very much,please answer my question in code. > Morse code? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From vernondcole at gmail.com Thu Jul 31 20:22:38 2008 From: vernondcole at gmail.com (Vernon Cole) Date: Thu, 31 Jul 2008 12:22:38 -0600 Subject: [python-win32] Is this user a member of a given Active Directory group? Message-ID: Dear group: My company makes use of Active Directory to determine what rights a given user has in an application system. If the user is a member of a certain group, then (s)he has the right to perform some set of functions. For example, if VCOLE is a member of WCPO-CREATE then I can create new purchase orders. The method I am using to determine a user's group membership consists of looking at all the members of each target group, and finding whether my user is on that list. Something like the following code snippet: v v v v v v glist = ['A','List',"of","possible",'group','names'] _username = win32api.GetUserName().upper() _LoginServer = win32net.NetGetAnyDCName() if True: # begin snippet groups = set() for g in glist: resume = 0 while True: try: entries, total, resume = \ win32net.NetGroupGetUsers( _LoginServer,g, 0, resume) except KeyboardInterrupt: raise except: print 'Group Name "%s" could not be found' % g break for de in entries: name = de['name'].upper() if name == _username: groups.add(g) if resume == 0: break # end snippet if 'possible' in groups: print 'You can do it.' ^ ^ ^ ^ ^ My question is this: There MUST be some better way. Is there no system call for "Is user U a member of group G"? -- Vernon Cole -------------- next part -------------- An HTML attachment was scrubbed... URL: From ing_emanuels at hotmail.com Thu Jul 31 23:39:41 2008 From: ing_emanuels at hotmail.com (Emanuel Sotelo) Date: Thu, 31 Jul 2008 16:39:41 -0500 Subject: [python-win32] when was pythonwin develop? Message-ID: hello, everybody perhaps somebody already ask this question but a i dont now the answer at what year was pythonwin develop, or at what year was his first release? is Mark Hammond the creator of pythonwin or was someone else? who help at the develoment of pythonwin? i hope some can help me aswer this questions. _________________________________________________________________ Los mejores conciertos en exclusiva por MSN in concert http://video.msn.com/?mkt=es-mx -------------- next part -------------- An HTML attachment was scrubbed... URL: