From 3dbernard at gmail.com Sun Oct 2 21:01:59 2005 From: 3dbernard at gmail.com (Bernard Lebel) Date: Sun, 2 Oct 2005 15:01:59 -0400 Subject: [python-win32] pywin32 under Win64 Message-ID: <61d0e2b40510021201l2fe5fce6v316e6abfba6cc697@mail.gmail.com> Hello, I'm considering switching to Windows 64bit. However I was wondering if anyone on this list have been using the pywin32 extension (or any win32com-related package/distribution for that matter) on Win64. Possibly the pywin*32* thing is making me cautious, but that would not be nice if I find out I can't use the package after I have done all the OS installation :-) Thanks Bernard From jramirez08063 at yahoo.com Mon Oct 3 12:33:28 2005 From: jramirez08063 at yahoo.com (Pepe Pena) Date: Mon, 3 Oct 2005 03:33:28 -0700 (PDT) Subject: [python-win32] Load PDF Message-ID: <20051003103329.60831.qmail@web35001.mail.mud.yahoo.com> Hello, I am attempting to load a pdf file programatically within Adobe Reader using the Adobe Acrobat 7.0 Browser Control Type Library. If I run this code PythonWin terminates abruptly, can anyone suggest any changes I should make to the following lines of code, thanks. import win32com.client test = win32com.client.Dispatch("AcroPDF.PDF.1") test.LoadFile("D:\\sql.pdf") --------------------------------- Yahoo! for Good Click here to donate to the Hurricane Katrina relief effort. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051003/883f6c9b/attachment.htm From bgailer at alum.rpi.edu Mon Oct 3 18:43:14 2005 From: bgailer at alum.rpi.edu (bob) Date: Mon, 03 Oct 2005 09:43:14 -0700 Subject: [python-win32] [Tutor] Load PDF In-Reply-To: <20051003104130.61589.qmail@web35001.mail.mud.yahoo.com> References: <20051003104130.61589.qmail@web35001.mail.mud.yahoo.com> Message-ID: <6.1.2.0.0.20051003092001.03481750@mail.mric.net> I am moving this to the python-win32 list where we can better handle it. Please send further replies there. At 03:41 AM 10/3/2005, Pepe Pena wrote: >I am attempting to load a pdf file programatically within Adobe Reader >using the Adobe Acrobat 7.0 Browser Control Type Library. If I run this >code PythonWin terminates abruptly, can anyone suggest any changes I >should make to the following lines of code, thanks. > >import win32com.client >test = win32com.client.Dispatch("AcroPDF.PDF.1") >test.LoadFile("D:\\sql.pdf") I confirm the behavior. I have no explanation. From alan.patterson5 at gmail.com Mon Oct 3 19:04:29 2005 From: alan.patterson5 at gmail.com (Alan Patterson) Date: Mon, 3 Oct 2005 18:04:29 +0100 Subject: [python-win32] Hooks Message-ID: <36bab1c80510031004n351a3310n@mail.gmail.com> I am looking to use python with the Windows Hooks calls namely, e.g.: SetWindowsHookEx. It does not seem to be implemented in python-win32. Does anyone have a wrapper around these functions, or is there any problem with doing this? Thanks, Alan From mhammond at skippinet.com.au Mon Oct 3 23:19:04 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 4 Oct 2005 07:19:04 +1000 Subject: [python-win32] Load PDF In-Reply-To: <20051003103329.60831.qmail@web35001.mail.mud.yahoo.com> Message-ID: This crash happens deep inside Acrobat itself and seems like a bug in that software. Running the following VBScript code produces the exact same error for me: set test = CreateObject("AcroPDF.PDF.1") test.LoadFile("filename.pdf") Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Pepe Pena Sent: Monday, October 03, 2005 8:33 PM To: python-win32 at python.org Subject: [python-win32] Load PDF Hello, I am attempting to load a pdf file programatically within Adobe Reader using the Adobe Acrobat 7.0 Browser Control Type Library. If I run this code PythonWin terminates abruptly, can anyone suggest any changes I should make to the following lines of code, thanks. import win32com.client test = win32com.client.Dispatch("AcroPDF.PDF.1") test.LoadFile("D:\\sql.pdf") ---------------------------------------------------------------------------- -- Yahoo! for Good Click here to donate to the Hurricane Katrina relief effort. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051004/f2d39da8/attachment.htm From nghsiaohui at yahoo.com Tue Oct 4 10:33:07 2005 From: nghsiaohui at yahoo.com (ng hsiaohui) Date: Tue, 4 Oct 2005 01:33:07 -0700 (PDT) Subject: [python-win32] create word document? Message-ID: <20051004083308.19600.qmail@web54403.mail.yahoo.com> Hi, I am creating MS word document using python win32. import win32com.client w = win32com.client.Dispatch("word.application") doc = w.Documents.Add("c:/test.doc") After that where can I find the command use to write contents in to this word document and to change the margin and fonts? Thanks for help. Regards, Hsiao Hui __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From eric.powell at srs.gov Tue Oct 4 17:20:56 2005 From: eric.powell at srs.gov (eric.powell@srs.gov) Date: Tue, 04 Oct 2005 11:20:56 -0400 Subject: [python-win32] create word document? In-Reply-To: <20051004083308.19600.qmail@web54403.mail.yahoo.com> Message-ID: After this, you are using the methods and objects that are part of the MS Office COM object. One place to look is the object browser within the VBA environment in Word. Another would be any book on office automation. A final approach would be to record a macro of what you trying to do and then examine the code to find the appropriate objects, interfaces and methods. Eric Eric B. Powell Process & Geographic Software Engineering BSRI (803)952-7783 There is no genius without a mixture of madness. (Seneca, De Tranquillitate) ng hsiaohui Sent by: python-win32-bounces at python.org 10/04/2005 04:33 AM To python-win32 at python.org cc Subject [python-win32] create word document? Hi, I am creating MS word document using python win32. import win32com.client w = win32com.client.Dispatch("word.application") doc = w.Documents.Add("c:/test.doc") After that where can I find the command use to write contents in to this word document and to change the margin and fonts? Thanks for help. Regards, Hsiao Hui __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051004/2aff7f4e/attachment.htm From nicky.p.impert at boeing.com Wed Oct 5 20:12:42 2005 From: nicky.p.impert at boeing.com (Impert, Nicky P) Date: Wed, 5 Oct 2005 11:12:42 -0700 Subject: [python-win32] errors running C++ client against python COM server Message-ID: <34C0247D227E0F4CBE949B2AAE16B3B8107B02@XCH-NW-3V2.nw.nos.boeing.com> Greetings. I need a working example of implementing an event handler in a C++ client with a python server. I broke apart the python connect example into a client and server. (i.e. I split C:\Python24\Lib\site-packages\win32com\demos\connect.py into client.py and server.py in some other directory.) I then changed the guids of server.py. I added this directory to my PYTHONPATH environment variable. I then created an idl file to match the interface as best I could. I compiled the idl file with visual studio's midl tool to get a header and tlb file and I wrote a C++ client against the generated header and tlb file. When I register the python server and run the python client, everything works fine. Running the C++ client gave me errors, so I tried to add additional information from the idl file to the python server (the idl file requires 4 uuids, but initially server.py as copied from connect.py only had 2). The python client still works, the C++ client does not. What I would like to know is if I need to add or change anything else in the python server or the derived idl file, or should they work with a C++ client as written. The typelib guid is currently defined as a top-level _reg_clsid_ as opposed to _typelib_guid_ within the coclass because if I set this parameter in server.py, client.py fails. Below is a printout of the output of both clients as well as the source of server.py and the implied idl file MyEventServer.idl: Any help much appreciated, --Nicky Impert >python server.py Registered: Python.MyEventServer >python client.py I am being called Sent 'Hello', but got back u'Hello_suffix' Everything seemed to work! still works, but when I run by C++ client, I get: 'ConnectionClient.exe': Loaded 'C:\Python24\Lib\site-packages\win32\win32trace.pyd', No symbols loaded. pythoncom error: ERROR: server.policy could not create an instance. Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 144, in CreateInstance return retObj._CreateInstance_(clsid, reqIID) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 211, in _CreateInstance_ raise pythoncom.com_error, (hr, desc, exc, arg) pywintypes.com_error: (-2147467262, "The object '' was created, but does not support the interface 'IConnectableServer'({F51A6858-F43E-4CF9-B603-6D15D3E8DB71}): No such interface supported", None, None) pythoncom error: Unexpected gateway error Traceback (most recent call last): (. . . -- above traceback info repeats) pythoncom error: CPyFactory::CreateInstance failed to create instance. (80004005) ---- server.py ---- # Implements a connectable server. # # Initial server code extracted from # C:\Python24\Lib\site-packages\win32com\demos\connect.py # then embellished in an attempt to allow a C++ client to exercise it. import pythoncom import win32com.server.util import win32com.server.connect from win32com.server.exception import Exception # This is the IID of the Events interface both Client and Server support. IID__IConnectDemoEvents = pythoncom.MakeIID("{FCA56F6D-2291-4A32-9BDE-D577D24616F1}") IID_IConnectableServer = pythoncom.MakeIID("{F51A6858-F43E-4CF9-B603-6D15D3E8DB71}") # putting typelib guid up here as top-level reg_clsid because I have # seen it done this way before, and uncommenting _typelib_guid_ causes # the client to fail. _reg_clsid_ = "{3593F5DE-2F61-43E9-8788-68D2D4C943D8}" _reg_libname_ = "server Typelib" # The server which implements # Create a connectable class, that has a single public method # 'DoIt', which echos to a single sink 'DoneIt' class MyConnectableServer(win32com.server.connect.ConnectableServer): """Interface MyConnectableServer""" _public_methods_ = ["DoIt"] + win32com.server.connect.ConnectableServer._public_methods_ _reg_progid_ = "Python.MyEventServer" # _reg_verprogid_ = "Python.MyEventServer.1" _reg_clsid_ = "{FA5F6400-DD37-4E1D-9E2C-9BEC56C4F2AE}" _reg_desc_ = "Python Event Server (test server -- returns string)" _reg_class_spec_ = "server.MyConnectableServer" # _reg_policy_spec_ = "win32com.servers.EventServer.SingletonPolicy" # uncommenting these lines causes client.py to fail # _typelib_guid_ = "{3593F5DE-2F61-43E9-8788-68D2D4C943D8}" # _typelib_version_ = 0, 1 _connect_interfaces_ = [IID__IConnectDemoEvents] _com_interfaces_ = [IID_IConnectableServer] + win32com.server.connect.ConnectableServer._com_interfaces_ # The single public method that the client can call on us # (ie, as a normal COM server, this exposes just this single method). def DoIt(self,arg): # Simply broadcast a notification. print "I am being called" arg = arg + "_suffix" self._BroadcastNotify(self.NotifyDoneIt, (arg,)) def NotifyDoneIt(self, interface, arg): interface.Invoke(1000, 0, pythoncom.DISPATCH_METHOD, 1, arg) if __name__=='__main__': import win32com.server.register win32com.server.register.UseCommandLine(MyConnectableServer) ---- MyEventServer.idl ---- /////////////////////////////////////////////////////////////////// // This file (MyEventServer.idl) was written to match up with the // implied definition in server.py // // To produce a type library (.tlb) just run 'midl' on this file. // import "oaidl.idl"; import "ocidl.idl"; // Interface IConnectableServer: [ object, uuid(F51A6858-F43E-4CF9-B603-6D15D3E8DB71), dual, helpstring("IConnectableServer Interface"), pointer_default(unique) ] interface IConnectableServer : IDispatch { [id(1000), helpstring("method DoIt")] HRESULT DoIt([in] BSTR arg); }; /////////////////////////////////////////////// // Type Library: [ // Every class of the form "CFoo" must contain the class attribute // _typelib_guid_ = "{3593F5DE-2F61-43E9-8788-68D2D4C943D8}" uuid(3593F5DE-2F61-43E9-8788-68D2D4C943D8), // top level _reg_clsid_ version(0.1), helpstring("server 0.1 Type Library") ] library MyEventServerLib { importlib("stdole32.tlb"); importlib("stdole2.tlb"); // callback (event handler) OnDoneIt [ uuid(FCA56F6D-2291-4A32-9BDE-D577D24616F1), helpstring("_IConnectDemoEvents Interface") ] interface _IConnectDemoEvents : IUnknown { [id(1000), helpstring("method OnDoneIt")] HRESULT OnDoneIt(BSTR Result); } // Class MyConnectableServer: [ // The Python class MyConnectableServer must contain this class attribute: uuid(FA5F6400-DD37-4E1D-9E2C-9BEC56C4F2AE), // _reg_clsid_ helpstring("server MyConnectableServer Class") ] coclass MyConnectableServer // _reg_progid_ { [default] interface IConnectableServer; [default, source] interface _IConnectDemoEvents; }; }; From timr at probo.com Wed Oct 5 19:46:28 2005 From: timr at probo.com (Tim Roberts) Date: Wed, 05 Oct 2005 10:46:28 -0700 Subject: [python-win32] create word document? In-Reply-To: References: Message-ID: <43441174.7030604@probo.com> On Tue, 4 Oct 2005 01:33:07 -0700 (PDT), ng hsiaohui wrote: >I am creating MS word document using python win32. > >import win32com.client >w = win32com.client.Dispatch("word.application") >doc = w.Documents.Add("c:/test.doc") > >After that where can I find the command use to write >contents in to this word document and to change the >margin and fonts? > My approach to this is to Google for "microsoft word object model". Their documentation on their object model ebbs and flows, but you can usually find a reference somewhere. However, I consider this a fairly odd request. What are you actually trying to do? If you want to generate and print formatted documents, you would have finer control and a much more flexible solution by using ReportLab to create PDF files, or HTML and the wxHtmlPrinting class in wxPython. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From claudio.segurablanc at bancofrances.com.ar Wed Oct 5 19:59:27 2005 From: claudio.segurablanc at bancofrances.com.ar (Segura Blanc, Claudio E.) Date: Wed, 5 Oct 2005 14:59:27 -0300 Subject: [python-win32] win32pdhutil Processor Time always returns 99 Message-ID: <1128535167.21206.0.camel@localhost.localdomain> This is an aparent solution only sintaxis "Processor" By import win32pdh, time, win32pdhutil path = win32pdh.MakeCounterPath( (None,"Processor","_Total", None, -1, "% Processor Time") ) #Idle, _Total print path # open the query, and add the counter to the query #print win32pdhutil.GetPerformanceAttributes("Process(_Total)","% Processor Time") base = win32pdh.OpenQuery() print base counter = win32pdh.AddCounter(base, path) print counter # collect the data for the query object. We need to collect the query data # twice to be able to calculate the % Processor Time win32pdh.CollectQueryData(base) time.sleep(1) win32pdh.CollectQueryData(base) # Get the formatted value of the counter print "Uso de procesador al", (win32pdh.GetFormattedCounterValue(counter, win32pdh.PDH_FMT_LONG)[1]), "%" From gagenellina at softlab.com.ar Wed Oct 5 22:31:30 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Wed, 05 Oct 2005 17:31:30 -0300 Subject: [python-win32] create word document? In-Reply-To: References: <20051004083308.19600.qmail@web54403.mail.yahoo.com> Message-ID: <6.2.1.2.0.20051005172742.03720760@192.168.0.115> At Tuesday 4/10/2005 12:20, eric.powell at srs.gov wrote: >A final approach would be to record a macro of what you trying to do and >then examine the code to find the appropriate objects, interfaces and methods. I consider this the easiest way, specially when you don't know how the exposed objects work. Just record a macro doing whatever you want to do in Word and see the resulting code. Gabriel Genellina Softlab SRL From jeff at lfchosting.com Thu Oct 6 05:51:54 2005 From: jeff at lfchosting.com (Jeff Fisher TEST) Date: Wed, 5 Oct 2005 21:51:54 -0600 (CST) Subject: [python-win32] Weird ADSI hang. Message-ID: <35282.24.72.79.6.1128570714.squirrel@207.195.54.249> Hi all, I'm rather frustrated by an issue I'm having. This sample bit of code runs fine; however, at the end just hangs and the program never ends. I'm using Python 2.3.2 (from ActiveState - build 232) BEGIN CODE import win32com.client def recurse(objstr): for obj in win32com.client.GetObject(objstr): print "Digging into", obj.ADsPath, "class=" + obj.Class recurse(obj.ADsPath) print "At the start" print recurse("IIS://localhost/W3SVC") print "At the end" END CODE "At the end" does print and at that point it just hangs there. Any ideas? I will try upgrading to Python 2.3.5 (from ActiveState) tomorrow and see if that makes any difference. Thanks in advance, Jeff From mc at mclaveau.com Thu Oct 6 14:14:17 2005 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 6 Oct 2005 14:14:17 +0200 Subject: [python-win32] Load PDF References: <20051003103329.60831.qmail@web35001.mail.mud.yahoo.com> Message-ID: <001c01c5ca6f$7c7bb5b0$0701a8c0@PORTABLES> Hi ! Try, with the src property, like : import win32com.client test = win32com.client.Dispatch("AcroPDF.PDF.1") test.src="C:\\107.pdf" test.LoadFile("C:\\107.pdf") print test.GetVersions() etc. @-salutations Michel Claveau From jeff at lfchosting.com Thu Oct 6 16:52:31 2005 From: jeff at lfchosting.com (Jeff Fisher) Date: Thu, 06 Oct 2005 08:52:31 -0600 Subject: [python-win32] Weird ADSI hang. In-Reply-To: <35282.24.72.79.6.1128570714.squirrel@207.195.54.249> References: <35282.24.72.79.6.1128570714.squirrel@207.195.54.249> Message-ID: <43453A2F.9090703@lfchosting.com> > Any ideas? I will try upgrading to Python 2.3.5 (from ActiveState) > tomorrow and see if that makes any difference. Just did the upgrade and I'm seeing the same hang at the end of the program. Jeff -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: OpenPGP digital signature Url : http://mail.python.org/pipermail/python-win32/attachments/20051006/eff1ce41/signature.pgp From p.f.moore at gmail.com Thu Oct 6 17:20:01 2005 From: p.f.moore at gmail.com (Paul Moore) Date: Thu, 6 Oct 2005 16:20:01 +0100 Subject: [python-win32] Service problem - can't find stop method of object Message-ID: <79990c6b0510060820j5667b88cg3307472373f20019@mail.gmail.com> This is a very odd problem. I have a module that I want to package up as a service - it has a "Registry" class, with mainloop and stop methods (the former sits in an infinite loop, the latter signals the loop to terminate). I am trying to package this up as a simple service, as follows: import win32serviceutil, win32service import registry class RegistryQueryService(win32serviceutil.ServiceFramework): _svc_name_ = "RegistryQueryService" _svc_display_name_ = "Oracle Registry Query Service" def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) self.reg.stop() def SvcDoRun(self): self.reg = registry.Registry() self.reg.mainloop() if __name__=='__main__': win32serviceutil.HandleCommandLine(RegistryQueryService) However, when I install and debug the service, and hit Ctrl-C to stop it, I get the error "Registry instance has no attribute 'stop'"!!! Here's a dump of the command output: D:\Data\RegQueries >service.py install Installing service RegistryQueryService to Python class D:\Data\RegQueries\servi ce.RegistryQueryService Service installed D:\Data\RegQueries >service.py debug Debugging service RegistryQueryService - press Ctrl+C to stop. Stopping debug service. Stopping debug service. Error 0xC000000B - The Python service control handler failed. File "C:\Apps\Python24\lib\site-packages\win32\lib\win32serviceutil.py", line 701, in ServiceCtrlHandler self.SvcStop() File "D:\Data\RegQueries\service.py", line 14, in SvcStop exceptions.AttributeError: Registry instance has no attribute 'stop' I'm baffled. I've added debug prints displaying my registry object, its dir(), the stop method, and they all look fine. Why can't SvcStop() find the method??? Thanks for any help. Paul. From bgailer at alum.rpi.edu Thu Oct 6 19:36:29 2005 From: bgailer at alum.rpi.edu (bob) Date: Thu, 06 Oct 2005 10:36:29 -0700 Subject: [python-win32] Weird ADSI hang. In-Reply-To: <35282.24.72.79.6.1128570714.squirrel@207.195.54.249> References: <35282.24.72.79.6.1128570714.squirrel@207.195.54.249> Message-ID: <6.1.2.0.0.20051006103505.03428fb8@mail.mric.net> At 08:51 PM 10/5/2005, Jeff Fisher TEST wrote: >Hi all, > >I'm rather frustrated by an issue I'm having. > >This sample bit of code runs fine; however, at the end just hangs and the >program never ends. I'm using Python 2.3.2 (from ActiveState - build 232) > >BEGIN CODE > >import win32com.client > >def recurse(objstr): > for obj in win32com.client.GetObject(objstr): > print "Digging into", obj.ADsPath, "class=" + obj.Class > recurse(obj.ADsPath) > >print "At the start" >print recurse("IIS://localhost/W3SVC") >print "At the end" > >END CODE > >"At the end" does print and at that point it just hangs there. > >Any ideas? Well I ran it w/o problem. Under what are you running it? (IDLE, Python command prompt, ...??) What is the evidence that it hangs? From jeff at lfchosting.com Thu Oct 6 20:15:56 2005 From: jeff at lfchosting.com (Jeff Fisher) Date: Thu, 06 Oct 2005 12:15:56 -0600 Subject: [python-win32] Weird ADSI hang. In-Reply-To: <6.1.2.0.0.20051006103505.03428fb8@mail.mric.net> References: <35282.24.72.79.6.1128570714.squirrel@207.195.54.249> <6.1.2.0.0.20051006103505.03428fb8@mail.mric.net> Message-ID: <434569DC.2040005@lfchosting.com> > Well I ran it w/o problem. Under what are you running it? (IDLE, Python > command prompt, ...??) > What is the evidence that it hangs? I'm running it from a command prompt typing: python iisdigger.py Evidence it hangs? It starts, seems to run fully, and then python never ends. I let it sit for 30 minutes and it would never end. Suppose I could fire up a debugger and have a look. Jeff -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: OpenPGP digital signature Url : http://mail.python.org/pipermail/python-win32/attachments/20051006/7ee6ba6a/signature.pgp From bgailer at alum.rpi.edu Thu Oct 6 23:17:58 2005 From: bgailer at alum.rpi.edu (bob) Date: Thu, 06 Oct 2005 14:17:58 -0700 Subject: [python-win32] Weird ADSI hang. In-Reply-To: <434569DC.2040005@lfchosting.com> References: <35282.24.72.79.6.1128570714.squirrel@207.195.54.249> <6.1.2.0.0.20051006103505.03428fb8@mail.mric.net> <434569DC.2040005@lfchosting.com> Message-ID: <6.1.2.0.0.20051006141725.03420558@mail.mric.net> At 11:15 AM 10/6/2005, Jeff Fisher wrote: > > Well I ran it w/o problem. Under what are you running it? (IDLE, Python > > command prompt, ...??) > > What is the evidence that it hangs? > >I'm running it from a command prompt typing: python iisdigger.py > >Evidence it hangs? It starts, seems to run fully, and then python never >ends. I let it sit for 30 minutes and it would never end. Suppose I >could fire up a debugger and have a look. Sorry; can't reproduce the problem. Ends OK for me. From bgailer at alum.rpi.edu Thu Oct 6 23:29:51 2005 From: bgailer at alum.rpi.edu (bob) Date: Thu, 06 Oct 2005 14:29:51 -0700 Subject: [python-win32] Weird ADSI hang. In-Reply-To: <434569DC.2040005@lfchosting.com> References: <35282.24.72.79.6.1128570714.squirrel@207.195.54.249> <6.1.2.0.0.20051006103505.03428fb8@mail.mric.net> <434569DC.2040005@lfchosting.com> Message-ID: <6.1.2.0.0.20051006142909.0341c8d8@mail.mric.net> At 11:15 AM 10/6/2005, Jeff Fisher wrote: > > Well I ran it w/o problem. Under what are you running it? (IDLE, Python > > command prompt, ...??) > > What is the evidence that it hangs? > >I'm running it from a command prompt typing: python iisdigger.py > >Evidence it hangs? It starts, seems to run fully, and then python never >ends. I let it sit for 30 minutes and it would never end. Just for grins hit Enter at the end and see what happens. From gagenellina at softlab.com.ar Fri Oct 7 01:15:02 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Thu, 06 Oct 2005 20:15:02 -0300 Subject: [python-win32] Weird ADSI hang. In-Reply-To: <35282.24.72.79.6.1128570714.squirrel@207.195.54.249> References: <35282.24.72.79.6.1128570714.squirrel@207.195.54.249> Message-ID: <6.2.1.2.0.20051006200749.0342c570@192.168.0.115> At Thursday 6/10/2005 00:51, you wrote: >import win32com.client > >def recurse(objstr): > for obj in win32com.client.GetObject(objstr): > print "Digging into", obj.ADsPath, "class=" + obj.Class > recurse(obj.ADsPath) > >print "At the start" >print recurse("IIS://localhost/W3SVC") >print "At the end" > >END CODE > >"At the end" does print and at that point it just hangs there. Maybe it doesn't matter, but try removing the print statement on print recurse(...) since recurse() doesnt return anything print "At the start" recurse("IIS://localhost/W3SVC") print "At the end" Gabriel Genellina Softlab SRL From bgailer at alum.rpi.edu Fri Oct 7 02:10:52 2005 From: bgailer at alum.rpi.edu (bob) Date: Thu, 06 Oct 2005 17:10:52 -0700 Subject: [python-win32] Weird ADSI hang. In-Reply-To: <6.2.1.2.0.20051006200749.0342c570@192.168.0.115> References: <35282.24.72.79.6.1128570714.squirrel@207.195.54.249> <6.2.1.2.0.20051006200749.0342c570@192.168.0.115> Message-ID: <6.1.2.0.0.20051006170933.034217d0@mail.mric.net> At 04:15 PM 10/6/2005, Gabriel Genellina wrote: >At Thursday 6/10/2005 00:51, you wrote: > > >import win32com.client > > > >def recurse(objstr): > > for obj in win32com.client.GetObject(objstr): > > print "Digging into", obj.ADsPath, "class=" + obj.Class > > recurse(obj.ADsPath) > > > >print "At the start" > >print recurse("IIS://localhost/W3SVC") > >print "At the end" > > > >END CODE > > > >"At the end" does print and at that point it just hangs there. > >Maybe it doesn't matter, but try removing the print statement on print >recurse(...) since recurse() doesnt return anything Oh but it does. It returns None. And print None does nothing. >print "At the start" >recurse("IIS://localhost/W3SVC") >print "At the end" From timr at probo.com Fri Oct 7 19:10:00 2005 From: timr at probo.com (Tim Roberts) Date: Fri, 07 Oct 2005 10:10:00 -0700 Subject: [python-win32] Service problem - can't find stop method of object In-Reply-To: References: Message-ID: <4346ABE8.9040409@probo.com> On Thu, 6 Oct 2005 16:20:01 +0100, Paul Moore wrote >This is a very odd problem. I have a module that I want to package up >as a service - it has a "Registry" class, with mainloop and stop >methods (the former sits in an infinite loop, the latter signals the >loop to terminate). ... > >However, when I install and debug the service, and hit Ctrl-C to stop >it, I get the error "Registry instance has no attribute 'stop'"!!! >... > > >Debugging service RegistryQueryService - press Ctrl+C to stop. >Stopping debug service. >Stopping debug service. >Error 0xC000000B - The Python service control handler failed. > > File "C:\Apps\Python24\lib\site-packages\win32\lib\win32serviceutil.py", line >701, in ServiceCtrlHandler > self.SvcStop() > File "D:\Data\RegQueries\service.py", line 14, in SvcStop > >exceptions.AttributeError: Registry instance has no attribute 'stop' > >I'm baffled. I've added debug prints displaying my registry object, >its dir(), the stop method, and they all look fine. Why can't >SvcStop() find the method??? > > 0xC000000B is "invalid client ID". If I had to guess, I'd guess that it actually WAS executing self.reg.stop(), but is getting an error during some OS operation, and the interpreter is misdiagnosing the results. What does self.reg.stop() do? Is it possible you're doing some operation that tries to cross a user boundary? Services run as LOCAL_SYSTEM, and there are some things you can't do to service processes. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From p.f.moore at gmail.com Fri Oct 7 21:26:31 2005 From: p.f.moore at gmail.com (Paul Moore) Date: Fri, 7 Oct 2005 20:26:31 +0100 Subject: [python-win32] Service problem - can't find stop method of object In-Reply-To: <4346ABE8.9040409@probo.com> References: <4346ABE8.9040409@probo.com> Message-ID: <79990c6b0510071226q14c1701cp99e16f7897de1017@mail.gmail.com> On 10/7/05, Tim Roberts wrote: > On Thu, 6 Oct 2005 16:20:01 +0100, Paul Moore wrote > > >Debugging service RegistryQueryService - press Ctrl+C to stop. > >Stopping debug service. > >Stopping debug service. > >Error 0xC000000B - The Python service control handler failed. > > > > File "C:\Apps\Python24\lib\site-packages\win32\lib\win32serviceutil.py", line > >701, in ServiceCtrlHandler > > self.SvcStop() > > File "D:\Data\RegQueries\service.py", line 14, in SvcStop > > > >exceptions.AttributeError: Registry instance has no attribute 'stop' > > 0xC000000B is "invalid client ID". If I had to guess, I'd guess that it > actually WAS executing self.reg.stop(), but is getting an error during > some OS operation, and the interpreter is misdiagnosing the results. > > What does self.reg.stop() do? Is it possible you're doing some > operation that tries to cross a user boundary? Services run as > LOCAL_SYSTEM, and there are some things you can't do to service processes. Ah. I hadn't noticed the hex error number, and was completely sidetracked by the error saying that the stop attribute didn't exist :-( I don't know quite what was going on, but I rewrote the mainloop/stop interaction (for other reasons, mainly) and the problem went away. FWIW, the mainloop function was waiting on an Oracle pipe for requests, then spawning threads to handle the requests. The stop function was putting a "quit processing" request into the pipe. It should be OK, but Oracle isn't always very happy with being run in odd environments (and I think running a multithreaded Windows service in debug mode probably counts :-)) so I'm going to put it down to experience. The lesson for me is to be very careful to trap *all* possible errors from Oracle functions, and don't block forever in Oracle API calls - I suspect the significant change was moving from an infinite timeout on the wait, to waiting for 1 second and then going back round the Python main loop. Anyway, thanks for pointing me at the real explanation of the problem. Paul. From robin at reportlab.com Sat Oct 8 16:11:08 2005 From: robin at reportlab.com (Robin Becker) Date: Sat, 08 Oct 2005 14:11:08 +0000 Subject: [python-win32] Pythonwin problem Message-ID: <4347D37C.1030501@jessikat.fsnet.co.uk> After debugging a particular program I started getting funny messages about window handles being bad. Then I get this at startup in a dialog box from the runtime library Runbtime Error! Program c:\python\lib\site-packages\pythonwin\Pythonwin.exe R6025 - pure virtual function call these problems happen when I start with pythonwin rml2pdf.py when I start with pythonwin I see a fair delay before things start up (reminiscent of the old toolbar problem). I looked for the toolbar stuff in the registry The version stuff is XPSP2 PythonWin 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2004 Mark Hammond (mhammond at skippinet.com.au) - see 'Help/About PythonWin' for further copyright information. >>> -- Robin Becker From steve at holdenweb.com Mon Oct 10 08:33:39 2005 From: steve at holdenweb.com (Steve Holden) Date: Mon, 10 Oct 2005 07:33:39 +0100 Subject: [python-win32] non descriptive error In-Reply-To: <4349A37B.9060706@open-networks.net> References: <4346002C.3080504@open-networks.net> <4349A37B.9060706@open-networks.net> Message-ID: <434A0B43.8070004@holdenweb.com> Timothy Smith wrote: > Steve Holden wrote: > >> Timothy Smith wrote: >> >> >>> i try to run my app and i get this >>> >>> %python DutyShift.py >>> error >>> >>> >>> thats it. thats the error. mya pp was previously working, and i did >>> make some fairly large changes to it, but i'd expect a more >>> descriptive message then just "error". anyidea where i need to start >>> looking? >>> >> >> >> I would look inside *your* program! I don't ever remember Python >> producing any message so terse and unhelpful. >> >> A way to check this would be to run python interactively and enter the >> statement >> >> import DutyShift >> >> though this won't necessarily run all the logic that gets run by your >> command. >> >> regards >> Steve >> >> > FYI it was a wrongly indented block. which is strange because i have > seen python produce helpful messages on similar occasions. a bug in the > interperter maybe?? > This probably should be reported if you can reproduce it, though I honestly don't understand how the compiler could produce such a message. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ From python at kapitalisten.no Tue Oct 11 11:32:53 2005 From: python at kapitalisten.no (=?iso-8859-1?Q?=D8yvind?=) Date: Tue, 11 Oct 2005 11:32:53 +0200 (CEST) Subject: [python-win32] Translating MS-Word documents Message-ID: <29345.193.71.38.142.1129023173.squirrel@mail.sporck.net> Hello. I need to translate several Word-documents. I have a list with approximately 5000 words and its translation, and would like to read thru a Word-document, look for the words in the list and replace them. However, I need to keep the current formating of the Word-documents. (Using Word 2003 and XP). What is the best way of doing this as fast and efficient as possible? 1) Search and replace for each word directly in Word 2) Exctract the text, run it thru regex and thereafter do a search and replace in Word. 3) Some other way? (The only language I know is Python, so writing some C++ stuff that can do it a lot faster is not an option). Thanks in advance. -- This email has been scanned for viruses & spam by Decna as - www.decna.no Denne e-posten er sjekket for virus & spam av Decna as - www.decna.no From bgailer at alum.rpi.edu Tue Oct 11 14:50:08 2005 From: bgailer at alum.rpi.edu (bob) Date: Tue, 11 Oct 2005 05:50:08 -0700 Subject: [python-win32] Translating MS-Word documents In-Reply-To: <29345.193.71.38.142.1129023173.squirrel@mail.sporck.net> References: <29345.193.71.38.142.1129023173.squirrel@mail.sporck.net> Message-ID: <6.1.2.0.0.20051011054146.03465cd0@mail.mric.net> At 02:32 AM 10/11/2005, ?yvind wrote: >Hello. > >I need to translate several Word-documents. I have a list with >approximately 5000 words and its translation, and would like to read thru >a Word-document, look for the words in the list and replace them. However, >I need to keep the current formating of the Word-documents. (Using Word >2003 and XP). > >What is the best way of doing this as fast and efficient as possible? How big are the documents? How many documents? A) Ask Word to save document in rtf format, then read, translate, save the rtf file using Python, then ask Word to open the rtf document and save as a Word doc. The only caveat is ensuring that none of the words are also rtf keywords. B) Make Python dictionary with the words as keys and their translations as values. Step thru the document's words collection, look each up in the dictionary, replace if found. T >1) Search and replace for each word directly in Word > >2) Exctract the text, run it thru regex and thereafter do a search and >replace in Word. > >3) Some other way? > >(The only language I know is Python, so writing some C++ stuff that can do >it a lot faster is not an option). C++ IMHO would not make things a lot faster. From timr at probo.com Tue Oct 11 18:13:57 2005 From: timr at probo.com (Tim Roberts) Date: Tue, 11 Oct 2005 09:13:57 -0700 Subject: [python-win32] Translating MS-Word documents In-Reply-To: References: Message-ID: <434BE4C5.8000107@probo.com> On Tue, 11 Oct 2005 11:32:53 +0200 (CEST), ?yvind wrote: >I need to translate several Word-documents. I have a list with >approximately 5000 words and its translation, and would like to read thru >a Word-document, look for the words in the list and replace them. However, >I need to keep the current formating of the Word-documents. (Using Word >2003 and XP). > >What is the best way of doing this as fast and efficient as possible? > >1) Search and replace for each word directly in Word > >2) Exctract the text, run it thru regex and thereafter do a search and >replace in Word. > >3) Some other way? > >(The only language I know is Python, so writing some C++ stuff that can do >it a lot faster is not an option). > > This is a hard problem. If you can let this run for a number of hours, the simplest answer is to use the Word object model to open each file in turn and use the Document.Find method to search and replace. It'll take a while, but the computer won't complain. Here's an MSDN article that shows how to use Find and Replace within a selection; the same syntax should work with a Document: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrcore/html/wrtskhowtoreplacetext.asp However, in many cases, it is easier to use the Word macro recorder to record what you want to do ONCE, and then use the generated VBA to create your script. If your document formatting will survive a change to RTF and back, you could convert to RTF (which is easily machine readable) and do the replacements in plain text. However, few documents survive that change completely intact. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Richard.Kerry at bbc.co.uk Tue Oct 11 18:31:09 2005 From: Richard.Kerry at bbc.co.uk (Richard Kerry) Date: Tue, 11 Oct 2005 17:31:09 +0100 Subject: [python-win32] Translating MS-Word documents Message-ID: <6A2513361DC9DB4F8660B859A5DBE82D023EA58F@bbcxue214.national.core.bbc.co.uk> If I understand correctly, this process it to be used to translate languages. I trust that all concerned appreciate that the differences between languages' grammars mean that the results are very unlikely to be particularly legible. You're into Machine Translation issues really and probably need to pass whole sentences into a proper language translator that will also deal with the grammar. Even then the results are likely to be somewhat stilted. Linguistically, Richard. -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Roberts Sent: Tuesday, October 11, 2005 5:14 PM To: python-win32 at python.org Subject: Re: [python-win32] Translating MS-Word documents On Tue, 11 Oct 2005 11:32:53 +0200 (CEST), ?yvind wrote: >I need to translate several Word-documents. I have a list with >approximately 5000 words and its translation, and would like to read >thru a Word-document, look for the words in the list and replace them. >However, I need to keep the current formating of the Word-documents. >(Using Word >2003 and XP). > >What is the best way of doing this as fast and efficient as possible? > >1) Search and replace for each word directly in Word > >2) Exctract the text, run it thru regex and thereafter do a search and >replace in Word. > >3) Some other way? > >(The only language I know is Python, so writing some C++ stuff that can >do it a lot faster is not an option). > > This is a hard problem. If you can let this run for a number of hours, the simplest answer is to use the Word object model to open each file in turn and use the Document.Find method to search and replace. It'll take a while, but the computer won't complain. Here's an MSDN article that shows how to use Find and Replace within a selection; the same syntax should work with a Document: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrco re/html/wrtskhowtoreplacetext.asp However, in many cases, it is easier to use the Word macro recorder to record what you want to do ONCE, and then use the generated VBA to create your script. If your document formatting will survive a change to RTF and back, you could convert to RTF (which is easily machine readable) and do the replacements in plain text. However, few documents survive that change completely intact. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 http://www.bbc.co.uk/ This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated. If you have received it in error, please delete it from your system. Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately. Please note that the BBC monitors e-mails sent or received. Further communication will signify your consent to this. From Paul.Weimer at harlandfs.com Tue Oct 11 18:44:00 2005 From: Paul.Weimer at harlandfs.com (Paul Weimer) Date: Tue, 11 Oct 2005 09:44:00 -0700 Subject: [python-win32] Translating MS-Word documents Message-ID: Could always try the Google language tools... -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Richard Kerry Sent: Tuesday, October 11, 2005 9:31 AM To: Tim Roberts; python-win32 at python.org Subject: Re: [python-win32] Translating MS-Word documents If I understand correctly, this process it to be used to translate languages. I trust that all concerned appreciate that the differences between languages' grammars mean that the results are very unlikely to be particularly legible. You're into Machine Translation issues really and probably need to pass whole sentences into a proper language translator that will also deal with the grammar. Even then the results are likely to be somewhat stilted. Linguistically, Richard. -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Roberts Sent: Tuesday, October 11, 2005 5:14 PM To: python-win32 at python.org Subject: Re: [python-win32] Translating MS-Word documents On Tue, 11 Oct 2005 11:32:53 +0200 (CEST), ?yvind wrote: >I need to translate several Word-documents. I have a list with >approximately 5000 words and its translation, and would like to read >thru a Word-document, look for the words in the list and replace them. >However, I need to keep the current formating of the Word-documents. >(Using Word >2003 and XP). > >What is the best way of doing this as fast and efficient as possible? > >1) Search and replace for each word directly in Word > >2) Exctract the text, run it thru regex and thereafter do a search and >replace in Word. > >3) Some other way? > >(The only language I know is Python, so writing some C++ stuff that can >do it a lot faster is not an option). > > This is a hard problem. If you can let this run for a number of hours, the simplest answer is to use the Word object model to open each file in turn and use the Document.Find method to search and replace. It'll take a while, but the computer won't complain. Here's an MSDN article that shows how to use Find and Replace within a selection; the same syntax should work with a Document: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrco re/html/wrtskhowtoreplacetext.asp However, in many cases, it is easier to use the Word macro recorder to record what you want to do ONCE, and then use the generated VBA to create your script. If your document formatting will survive a change to RTF and back, you could convert to RTF (which is easily machine readable) and do the replacements in plain text. However, few documents survive that change completely intact. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 http://www.bbc.co.uk/ This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated. If you have received it in error, please delete it from your system. Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately. Please note that the BBC monitors e-mails sent or received. Further communication will signify your consent to this. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From timr at probo.com Tue Oct 11 18:52:06 2005 From: timr at probo.com (Tim Roberts) Date: Tue, 11 Oct 2005 09:52:06 -0700 Subject: [python-win32] Translating MS-Word documents In-Reply-To: <6A2513361DC9DB4F8660B859A5DBE82D023EA58F@bbcxue214.national.core.bbc.co.uk> References: <6A2513361DC9DB4F8660B859A5DBE82D023EA58F@bbcxue214.national.core.bbc.co.uk> Message-ID: <434BEDB6.4090805@probo.com> Richard Kerry wrote: >If I understand correctly, this process it to be used to translate >languages. >I trust that all concerned appreciate that the differences between >languages' grammars mean that the results are very unlikely to be >particularly legible. You're into Machine Translation issues really and >probably need to pass whole sentences into a proper language translator >that will also deal with the grammar. Even then the results are likely >to be somewhat stilted. > > This is an excellent point. I did not assume that the task was actually language translation, since the author did not mention it, although there are certainly few other applications for which a 5,000 word dictionary would be necessary. Yes, there are tools for this that are much better than rote word-for-word replacement. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From python at kapitalisten.no Wed Oct 12 13:28:19 2005 From: python at kapitalisten.no (=?iso-8859-1?Q?=D8yvind?=) Date: Wed, 12 Oct 2005 13:28:19 +0200 (CEST) Subject: [python-win32] Translating MS-Word documents Message-ID: <49284.193.71.38.142.1129116499.squirrel@mail.sporck.net> Hello, and thank you for the answers so far. The documents can be huge, as in 4-5000 pages, and there are upto 7*5000 words that needs to be replaced. (It is as you have pointed out a translation of languages, but for a very speicalised branch of patents. Therefore there are no translaters that know most of these words. They will be changed, and thereafter, someone might spend a few weeks/months getting it correct.) I don't really think changing it to rtf is a sollution. The formating is very important. The company do have Word Macros today that do the job. But, as you might imagine, it is very hard to maintain and got lots of 'issues'. It started out with a few words 6-7 years ago, and have grown. Will there be a increase in speed if I pull out all the text, run it thru regex and thereafter do a Word Search and Replace of those words that Regex finds, instead of doing a complete Search and Replace in Word? Thanks in advance. -- This email has been scanned for viruses & spam by Decna as - www.decna.no Denne e-posten er sjekket for virus & spam av Decna as - www.decna.no From alexj at businessabstraction.com Wed Oct 12 14:21:17 2005 From: alexj at businessabstraction.com (Alex Jouravlev) Date: Wed, 12 Oct 2005 22:21:17 +1000 Subject: [python-win32] Possible bug: what information to provide Message-ID: Hi, I have a potential bug report. PythonWin fails to invoke a COM Object's function. I am a bit puzzled what information should be provided. I am not a COM guru - I am using PythonWin to write some scripts to an off-the-shelf COM enabled system - the system is outside of my control, I cannot get into it with a debugger etc. - All examples are provided in VB, PythonWin is not officially supported as COM client Details: OS:WIN XP SP2 Python 2.4.2 Python 2.4 PythonWin extension build 204 Application: Sparx Enterprise Architect >>> r.ref >>> r.ref.Update() Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 489, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: EA.Repository.Update With all other objects of their interface, the following pattern appears: All attributes work as documented No method (from what I can see) works as documented. (documentation is in VB though) Any help would be appreciated. Regards, Alex From bgailer at alum.rpi.edu Wed Oct 12 17:05:22 2005 From: bgailer at alum.rpi.edu (bob) Date: Wed, 12 Oct 2005 08:05:22 -0700 Subject: [python-win32] Possible bug: what information to provide In-Reply-To: References: Message-ID: <6.1.2.0.0.20051012080421.0345db40@mail.mric.net> At 05:21 AM 10/12/2005, Alex Jouravlev wrote: >Hi, > >I have a potential bug report. PythonWin fails to invoke a COM Object's >function. I am a bit puzzled what information should be provided. I am not a >COM guru > > - I am using PythonWin to write some scripts to an off-the-shelf COM >enabled system > - the system is outside of my control, I cannot get into it with a debugger >etc. > - All examples are provided in VB, PythonWin is not officially supported as >COM client > >Details: > OS:WIN XP SP2 > Python 2.4.2 > Python 2.4 PythonWin extension build 204 > Application: Sparx Enterprise Architect > > >>> r.ref > > >>> r.ref.Update() >Traceback (most recent call last): > File "", line 1, in ? > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 489, >in __getattr__ > raise AttributeError, "%s.%s" % (self._username_, attr) >AttributeError: EA.Repository.Update Case sensitivity may be an issue. Try r.ref.update() >With all other objects of their interface, the following pattern appears: > > All attributes work as documented > No method (from what I can see) works as documented. > >(documentation is in VB though) > > > >Any help would be appreciated. > >Regards, > >Alex > > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 From bgailer at alum.rpi.edu Wed Oct 12 19:28:29 2005 From: bgailer at alum.rpi.edu (bob) Date: Wed, 12 Oct 2005 10:28:29 -0700 Subject: [python-win32] Translating MS-Word documents In-Reply-To: <49284.193.71.38.142.1129116499.squirrel@mail.sporck.net> References: <49284.193.71.38.142.1129116499.squirrel@mail.sporck.net> Message-ID: <6.1.2.0.0.20051012080555.0345d8b0@mail.mric.net> At 04:28 AM 10/12/2005, ?yvind wrote: >Hello, and thank you for the answers so far. > >The documents can be huge, as in 4-5000 pages, and there are upto 7*5000 >words that needs to be replaced. (It is as you have pointed out a >translation of languages, but for a very speicalised branch of patents. >Therefore there are no translaters that know most of these words. They >will be changed, and thereafter, someone might spend a few weeks/months >getting it correct.) > >I don't really think changing it to rtf is a sollution. The formating is >very important. You don't lose formatting with rtf. What did you not like about my proposal to run the words collections thru a dictionary. For what its worth I created a 405 word dictionary, and ran a document of 1000 words thru it. Every word in the document was in the dictionary. On my machine which is at least 3 years old (1 ghz cpu I think) it took 16 seconds. Heres the code if you want to experiment with it. I still think it is the fastest solution. But YMMV. import win32com.client import time from translations import t # I assume you have a dictionary of words & translations named t w=win32com.client.Dispatch('word.application') d=w.documents.Open('c:/foo.doc') def main(): s = time.clock() wds = d.words.count+1 for i in range(1,d.wds): word = d.words(i) try: word.text = t[word .text] except:pass print time.clock() - s main() The time is proportional to the # of words in the document. The size of the dictionary should not radically affect the time. The reason for the try is that some words in my sample document were in links, and reassigning the text failed. This also supports the cases where the word is not a dictionary key. Most of the time is spent looping and accessing the words. About 1% looking in the dictionary. The rest in reassigning the text. >The company do have Word Macros today that do the job. But, as you might >imagine, it is very hard to maintain and got lots of 'issues'. It started >out with a few words 6-7 years ago, and have grown. > >Will there be a increase in speed if I pull out all the text, run it thru >regex and thereafter do a Word Search and Replace of those words that >Regex finds, instead of doing a complete Search and Replace in Word? > >Thanks in advance. > > > >-- >This email has been scanned for viruses & spam by Decna as - www.decna.no >Denne e-posten er sjekket for virus & spam av Decna as - www.decna.no > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 From alexj at businessabstraction.com Wed Oct 12 22:25:24 2005 From: alexj at businessabstraction.com (Alex Jouravlev) Date: Thu, 13 Oct 2005 06:25:24 +1000 Subject: [python-win32] Possible bug: what information to provide In-Reply-To: <6.1.2.0.0.20051012080421.0345db40@mail.mric.net> Message-ID: Sorry, I initially provided wrong fragment More bug details: >>> r.ref >>> r.ref.GetLastError() Traceback (most recent call last): File "", line 1, in ? TypeError: 'unicode' object is not callable >>> r.ref.GetLastError u'' >>> However, GetLastError() is a function according to specs and Makepy.py One more strange thing: MakePy recognised the object as "IRepository" rather then "Repository" System details: OS:WIN XP SP2 Python 2.4.2 Python 2.4 PythonWin extension build 204 Application: Sparx Enterprise Architect Thanks, Alex From mhammond at skippinet.com.au Thu Oct 13 04:23:24 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 13 Oct 2005 12:23:24 +1000 Subject: [python-win32] Possible bug: what information to provide In-Reply-To: Message-ID: > >>> r.ref > > >>> r.ref.GetLastError() > Traceback (most recent call last): > File "", line 1, in ? > TypeError: 'unicode' object is not callable > >>> r.ref.GetLastError > u'' > >>> Can you provide a short example that also includes how the object is created? > However, GetLastError() is a function according to specs and Makepy.py The code above is not using makepy, even though it may have been run. You could try creating the object using win32com.client.gencache.EnsureDispatch instead of plain Dispatch, but you may still strike the same error. If you do, it generally means the object is not telling us what type it is, so we can't associate it with a makepy interface. We can work around this though. > One more strange thing: > MakePy recognised the object as "IRepository" rather then "Repository" I'm not sure what you mean here. Please post a complete code sample, including all output that confuses you or you believe to be wrong. Cheers, Mark From mhammond at skippinet.com.au Thu Oct 13 04:23:25 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 13 Oct 2005 12:23:25 +1000 Subject: [python-win32] Pythonwin problem In-Reply-To: <4347D37C.1030501@jessikat.fsnet.co.uk> Message-ID: > After debugging a particular program I started getting funny messages > about window handles being bad. Then I get this at startup in a dialog > box from the runtime library > > > Runbtime Error! > > Program c:\python\lib\site-packages\pythonwin\Pythonwin.exe > > R6025 > - pure virtual function call I've seem similar things happen in response to an access violation etc. > these problems happen when I start with > > pythonwin rml2pdf.py Can you reproduce it with a smaller example? Regards, Mark From mhammond at skippinet.com.au Thu Oct 13 04:33:34 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 13 Oct 2005 12:33:34 +1000 Subject: [python-win32] errors running C++ client against python COM server In-Reply-To: <34C0247D227E0F4CBE949B2AAE16B3B8107B02@XCH-NW-3V2.nw.nos.boeing.com> Message-ID: > '' was created, but > does not support the interface > 'IConnectableServer'({F51A6858-F43E-4CF9-B603-6D15D3E8DB71}): No such > interface supported", None, None) So the problem is our gateway doesn't think we support that interface. > # putting typelib guid up here as top-level reg_clsid because I have > # seen it done this way before, and uncommenting _typelib_guid_ causes > # the client to fail. That is how it will need to be done though. Can you be more specific about how it fails? The test\pippo* files all do what you need (ie, implement interfaces described in typelibs). Note that a *Python* client will not be able to QI for that interface, but other clients will. Mark. From alexj at businessabstraction.com Thu Oct 13 05:06:18 2005 From: alexj at businessabstraction.com (Alex Jouravlev) Date: Thu, 13 Oct 2005 13:06:18 +1000 Subject: [python-win32] Possible bug: what information to provide In-Reply-To: Message-ID: Thanks, Mark, > > One more strange thing: > > MakePy recognised the object as "IRepository" rather then "Repository" > > I'm not sure what you mean here. Please post a complete code sample, > including all output that confuses you or you believe to be wrong. > Makepy.py output (fragment, for information about the Object) ----------------------------------------------- class IRepository(DispatchBaseClass): CLSID = IID('{F2DC9B8B-3ACE-4AD1-A863-2321C60220AB}') coclass_clsid = None ............... def GetLastError(self): return self._ApplyTypes_(14, 1, (12, 0), (), 'GetLastError', None,) ....................... def OpenFile2(self, FileName=defaultNamedNotOptArg, Username=defaultNamedNotOptArg, Password=defaultNamedNotOptArg): return self._oleobj_.InvokeTypes(18, LCID, 1, (11, 0), ((12, 0), (12, 0), (12, 0)),FileName , Username, Password) -------------------------------------------------------------------- PythonWin Dialogue ------------------------------ >>> import win32com >>> rep = win32com.client.Dispatch('EA.Repository') >>> rep.OpenFile2("C:\Test.eap","","") True >>> rep.GetLastError() Traceback (most recent call last): File "", line 1, in ? TypeError: 'unicode' object is not callable >>> ----------------------------------------------------- > The code above is not using makepy, even though it may have been run. You > could try creating the object using > win32com.client.gencache.EnsureDispatch I tried, here is the result: ----------------------------------- >>> rep = win32com.client.gencache.EnsureDispatch('EA.Repository') Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line 543, in EnsureDispatch raise TypeError, "This COM object can not automate the makepy process - please run makepy manually for this object" TypeError: This COM object can not automate the makepy process - please run makepy manually for this object >>> --------------------------------------- Thanks again, Alex From mhammond at skippinet.com.au Thu Oct 13 06:00:38 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 13 Oct 2005 14:00:38 +1000 Subject: [python-win32] Possible bug: what information to provide In-Reply-To: Message-ID: > > > One more strange thing: > > > MakePy recognised the object as "IRepository" rather then "Repository" > > > > I'm not sure what you mean here. Please post a complete code sample, > > including all output that confuses you or you believe to be wrong. > > > Makepy.py output (fragment, for information about the Object) > ----------------------------------------------- > class IRepository(DispatchBaseClass): Right - that is normal. It is indeed the interface that has the method - the "coclass" described in the file probably has a reference to that interface - a coclass may implement many interfaces. > > The code above is not using makepy, even though it may have > > been run. You > > could try creating the object using > > win32com.client.gencache.EnsureDispatch > > I tried, here is the result: > ----------------------------------- > >>> rep = win32com.client.gencache.EnsureDispatch('EA.Repository') > Traceback (most recent call last): > File "", line 1, in ? > File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line > 543, in EnsureDispatch > raise TypeError, "This COM object can not automate the makepy > process - > please run makepy manually for this object" > TypeError: This COM object can not automate the makepy process - > please run > makepy manually for this object Sadly, this object is not providing its typeinfo at runtime. If you can get in touch with the developers, ask them to consider adding this IDispatch typeinfo support - they already have the typeinfo available from their typelib, so it should be quite easy to do. In the meantime, you need to explicitly "cast" your objects into these makepy objects. You should start by running "makepy.py -i" (from a command-prompt). Here is what I get when I pick some random lib: IAS Helper COM Component 1.0 Type Library {6BC096BB-0CE6-11D1-BAAE-00C04FC2E20D}, lcid=0, major=1, minor=0 >>> # Use these commands in Python code to auto generate .py support >>> from win32com.client import gencache >>> gencache.EnsureModule('{6BC096BB-0CE6-11D1-BAAE-00C04FC2E20D}', 0, 1, 0) You should add these lines to your code - but with one change: > from win32com.client import gencache > mod = gencache.EnsureModule('{6BC096BB-0CE6-11D1-BAAE-00C04FC2E20D}', 0, 1, 0) Note the last line - 'mod ='. This will be the makepy module, as imported from the gen_py directory. You can then write: rep = win32com.client.Dispatch('EA.Repository') # Now 'cast' it to an IRepository object. rep = mod.IRepository(rep) print repr(rep) # Should now print a repr that indicates it is a makepy object. You will need to this whenever you get a "new" object. Eg, let's say there was a "GetApplication()" method on a repository. app = rep.GetApplication() print repr(app) # will probably say "" - not what you want. app = mod.IApplication(app) # Cast to a mythical IApplication object. print repr(app) # should show the makepy object. Hope that makes sense, Mark From peter.mctaggart at boeing.com Thu Oct 13 07:16:00 2005 From: peter.mctaggart at boeing.com (I-McTaggart, Peter) Date: Thu, 13 Oct 2005 15:16:00 +1000 Subject: [python-win32] Using win32security from IIS/CGI script Message-ID: <373EC11E4993DF4F9DCBD2E630568CE37A2835@xch-au-20.au.nos.boeing.com> Hi, I'm trying to call the following win3security API as part of a CGI script being served up by IIS6 on W2k3. secDes = win32security.GetNamedSecurityInfo(filename, \ win32security.SE_FILE_OBJECT, \ win32security.DACL_SECURITY_INFORMATION \ | win32security.GROUP_SECURITY_INFORMATION \ | win32security.OWNER_SECURITY_INFORMATION) I have got the script running from a secure page (NT Auth) in the context of the user that is calling the script through IIS but I am getting an access denied error, as indicated below E:\Inetpub\tools\AccessList.py in getAceList(filename=r'\\server\somefile') secDes = win32security.GetNamedSecurityInfo(filename, \ win32security.SE_FILE_OBJECT, \ win32security.DACL_SECURITY_INFORMATION \ | win32security.GROUP_SECURITY_INFORMATION \ | win32security.OWNER_SECURITY_INFORMATION) global win32security = , win32security.DACL_SECURITY_INFORMATION = 4, win32security.GROUP_SECURITY_INFORMATION = 2, win32security.OWNER_SECURITY_INFORMATION = 1 error: (5, 'GetNamedSecurityInfo', 'Access is denied.') args = (5, 'GetNamedSecurityInfo', 'Access is denied.') I can confirm that it is running in the context of me as a user and This works ok if I run it interactively from PythonWin directly on the server under my account. Can anyone point me in the right direction? Thanks Peter From andrew.markebo at comhem.se Wed Oct 12 10:27:14 2005 From: andrew.markebo at comhem.se (Andrew Markebo) Date: Wed, 12 Oct 2005 10:27:14 +0200 Subject: [python-win32] Bug: Not letting through the readable error? Message-ID: Hi! I am trying to generate a DirectX API(?) by myself instead if using makepy.py. So I do: >>> import win32com.client.gencache >>> LVClass = win32com.client.gencache.EnsureDispatch("LabVIEW.Application") And I get: Traceback (most recent call last): File "", line 1, in ? File "C:\PROGRA~1\Python23\lib\site-packages\win32com\client\gencache.py", line 537, in EnsureDispatch GetModuleForCLSID(disp_clsid) File "C:\PROGRA~1\Python23\lib\site-packages\win32com\client\gencache.py", line 240, in GetModuleForCLSID makepy.GenerateChildFromTypeLibSpec(sub_mod, info) File "c:\Progra~1\Python23\lib\site-packages\win32com\client\makepy.py", line 318, in GenerateChildFromTypeLibSpec __import__("win32com.gen_py." + dir_name + "." + child) ImportError: No module named _IApplication When looking at the stack in pdb, there is a better message to show I think, not just walking through it: > c:\progra~1\python23\lib\site-packages\win32com\client\gencache.py(543)EnsureDispatch() -> raise TypeError, "This COM object can not automate the makepy process - please run makepy manually for this object" (This run is probably due to that there are 4 LabVIEW targets in the list of api's to create, two on LabVIEW 7.1, and two on LabVIEW 7.0) /Andy -- TANSTAAFI - There Are No Such Thing As A Free Internet Or? From shendric at uga.edu Thu Oct 13 22:33:27 2005 From: shendric at uga.edu (Sean Q. Hendricks) Date: Thu, 13 Oct 2005 13:33:27 -0700 Subject: [python-win32] Control-C Message-ID: <434EC497.9080107@uga.edu> Hi all, I've looked around, but I wasn't able to find anything about this issue. I am writing an application that calls a separate windows application as a process. That's not a problem, I can get it to run and do what it needs to do. However, the normal way to stop the separate windows application is to hit CTRL-C. That allows it to end and do finishing processes. Is there a way to send a CTRL-C signal to a process? I tried simply doing a TerminateProcess on the process, as suggested to me earlier, however, this doesn't allow the normal cleanup operations to do what they need to do. Any help you might have would be greatly appreciated. Sean -- ***Please note new email address: shendric at uga.edu*** From gagenellina at softlab.com.ar Thu Oct 13 22:12:09 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Thu, 13 Oct 2005 17:12:09 -0300 Subject: [python-win32] Control-C Message-ID: <6.2.1.2.0.20051013171203.0350f810@192.168.0.115> At Thursday 13/10/2005 17:33, you wrote: I've looked around, but I wasn't able to find anything about this >issue. I am writing an application that calls a separate windows >application as a process. That's not a problem, I can get it to run and >do what it needs to do. However, the normal way to stop the separate >windows application is to hit CTRL-C. That allows it to end and do >finishing processes. Is there a way to send a CTRL-C signal to a >process? I tried simply doing a TerminateProcess on the process, as >suggested to me earlier, however, this doesn't allow the normal cleanup >operations to do what they need to do. Any help you might have would be >greatly appreciated. win32api.GenerateConsoleCtrlEvent http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/generateconsolectrlevent.asp Gabriel Genellina Softlab SRL From mhammond at skippinet.com.au Fri Oct 14 00:22:18 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 14 Oct 2005 08:22:18 +1000 Subject: [python-win32] Control-C In-Reply-To: <434EC497.9080107@uga.edu> Message-ID: > I've looked around, but I wasn't able to find anything about this > issue. I am writing an application that calls a separate windows > application as a process. That's not a problem, I can get it to run and > do what it needs to do. However, the normal way to stop the separate > windows application is to hit CTRL-C. That allows it to end and do > finishing processes. Is there a way to send a CTRL-C signal to a > process? I tried simply doing a TerminateProcess on the process, as > suggested to me earlier, however, this doesn't allow the normal cleanup > operations to do what they need to do. Any help you might have would be > greatly appreciated. Sadly, I think GenerateConsoleCtrlEvent will not work for you. In short, it is nearly useless :) The description of the function says it "sends a specified signal to a console process group that shares the console associated with the calling process" and it means it literally. In your case, it sounds like you have a GUI program, so that will not have a console, so will never be able to be part of your process group. If the running program is not in the exact same console as your app, you are hosed. More info on this can be found at http://www.microsoft.com/msj/0698/win320698.aspx, where they describe a technique where they need to use another child process to make this work - but even then its not clear it would work if you app is a GUI one. hrm - re-reading your message above, it sounds like the child process *is* a console process. Either way, the above should get you in the right direction. Mark From shendric at uga.edu Fri Oct 14 17:30:43 2005 From: shendric at uga.edu (Sean Q. Hendricks) Date: Fri, 14 Oct 2005 08:30:43 -0700 Subject: [python-win32] Control-C In-Reply-To: References: Message-ID: <434FCF23.9040507@uga.edu> Mark Hammond wrote: >Sadly, I think GenerateConsoleCtrlEvent will not work for you. In short, it >is nearly useless :) The description of the function says it "sends a >specified signal to a console process group that shares the console >associated with the calling process" and it means it literally. In your >case, it sounds like you have a GUI program, so that will not have a >console, so will never be able to be part of your process group. If the >running program is not in the exact same console as your app, you are hosed. > >More info on this can be found at >http://www.microsoft.com/msj/0698/win320698.aspx, where they describe a >technique where they need to use another child process to make this work - >but even then its not clear it would work if you app is a GUI one. > > Thank you for the link. I'll check it out. I hadn't had the chance to try the GenerateConsoleCtrlEvent yet. >hrm - re-reading your message above, it sounds like the child process *is* a >console process. Either way, the above should get you in the right >direction. > > In this case, yes, the child process is a console process, since it's a commandline application. It turns out that the application comes with another program attached that may do what I need, but I'm going to look at the link you provided, just in case. Thanks a bunch. Sean From emlynj at gmail.com Fri Oct 14 16:08:27 2005 From: emlynj at gmail.com (Emlyn Jones) Date: Fri, 14 Oct 2005 15:08:27 +0100 Subject: [python-win32] Python ASP Install Message-ID: Hello, I've written a web application using the Win32 IIS stuff. It uses a few .py modules and a collection of ASP pages using Python. I was wondering if anybody had any experience in distributing and installing an application like this and could offer any useful tips/gotchas. At the moment the plan is to ask the user to install Python and PyWin32, run the Python/ASP registration script and then copy the files from a zip file onto the server. Is there a more straight forward way to do this? Are there any functions in pyWin32 for setting up IIS (making virtual folders and such like?) then I could just install the whole thing like any other python package (using bdist_winst) and then link a virtual folder to it from a post install script. Regards, Emlyn. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051014/39f1e945/attachment.htm From davidsch at verity.com Fri Oct 14 17:38:49 2005 From: davidsch at verity.com (David Schnepper) Date: Fri, 14 Oct 2005 08:38:49 -0700 Subject: [python-win32] Control-C Message-ID: Mark Hammond wrote: >Sadly, I think GenerateConsoleCtrlEvent will not work for you. In short, it >is nearly useless :) The description of the function says it "sends a >specified signal to a console process group that shares the console >associated with the calling process" and it means it literally. In your >case, it sounds like you have a GUI program, so that will not have a >console, so will never be able to be part of your process group. If the >running program is not in the exact same console as your app, you are hosed. > >More info on this can be found at >http://www.microsoft.com/msj/0698/win320698.aspx, where they describe a >technique where they need to use another child process to make this work - >but even then its not clear it would work if you app is a GUI one. > > Thank you for the link. I'll check it out. I hadn't had the chance to try the GenerateConsoleCtrlEvent yet. ---------------- The Windows notion of a "Console" is independent from a "visual window on the display". You can still have a Console without anything appearing on the screen. Generally, if you start a process from a cmd.exe window you inherit the cmd.exe window as your console, if your process is started from the Services Manager you have no console -- but can allocate one with AllocConsole(). A process can disassociate itself from a console with FreeConsole() - and a good way to find out if you have a console is call AllocConsole() and check for an error -- if you already had a console an error code is returned. A process can spawn a child detached from the console, or with a new console, with flags to CreateProcess() David Schnepper Ultraseek Software Craftsman david.schnepper at verity.com +1-408-542-2306 From wawork at hotmail.com Fri Oct 14 18:20:31 2005 From: wawork at hotmail.com (Randy in Wash st) Date: Fri, 14 Oct 2005 16:20:31 +0000 Subject: [python-win32] Comparing dbase date value with os.path.getmtime(filename) Message-ID: I have a python script that opens a dbase table and reading a lastmod date file. I would like to compare this value with the system datetime of a file on the network. The os.path.getmtime(filename) function returns the time in 9 digit sequence. The dbase date prints out as 09/13/2005 12:00:00 AM while the getmtime returns 1126729268. How can I convert the datetime coming from the dbase record with the modify datetime of a file so I can determine which date is older? Thanks, r wawork at hotmail.com From Jim.Vickroy at noaa.gov Fri Oct 14 18:46:22 2005 From: Jim.Vickroy at noaa.gov (Jim.Vickroy@noaa.gov) Date: Fri, 14 Oct 2005 10:46:22 -0600 Subject: [python-win32] Comparing dbase date value with os.path.getmtime(filename) Message-ID: <475c544a07.44a07475c5@noaa.gov> You may wish to take a look at the time module (specifically) time.gmtime(...) or time.localtime(...)) to work with the return value from getmtime(...). Can't really help much with the return value from the database since I don't know what type of object it is. If you are using Python 2.3 or later you may wish to look at the datetime module (specifically datetime.datetime). HTH, -- jv ----- Original Message ----- From: Randy in Wash st Date: Friday, October 14, 2005 10:20 am Subject: [python-win32] Comparing dbase date value with os.path.getmtime(filename) > I have a python script that opens a dbase table and reading a > lastmod date > file. I would like to compare this value with the system datetime > of a file > on the network. The os.path.getmtime(filename) function returns > the time in > 9 digit sequence. The dbase date prints out as 09/13/2005 > 12:00:00 AM while > the getmtime returns 1126729268. > > How can I convert the datetime coming from the dbase record with > the modify > datetime of a file so I can determine which date is older? > > Thanks, > r > wawork at hotmail.com > > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From rwupole at msn.com Fri Oct 14 18:47:29 2005 From: rwupole at msn.com (Roger Upole) Date: Fri, 14 Oct 2005 12:47:29 -0400 Subject: [python-win32] Re: Python ASP Install Message-ID: Emlyn Jones wrote: > Hello, > I've written a web application using the Win32 IIS stuff. It uses a few > .py > modules and a collection of ASP pages using Python. > I was wondering if anybody had any experience in distributing and > installing > an application like this and could offer any useful tips/gotchas. > At the moment the plan is to ask the user to install Python and PyWin32, > run > the Python/ASP registration script and then copy the files from a zip file > onto the server. Is there a more straight forward way to do this? > Are there any functions in pyWin32 for setting up IIS (making virtual > folders and such like?) then I could just install the whole thing like any > other python package (using bdist_winst) and then link a virtual folder to > it from a post install script. > Regards, > Emlyn. There are a whole set of COM objects for managing IIS. Here's some code that creates a virtual dir. import win32com.client iis=win32com.client.GetObject('IIS://localhost/w3svc/1/Root') vdir=iis.Create("IIsWebVirtualDir", "virtualdircreatebypython") vdir.Path='z:\\somedir\\' vdir.SetInfo() hth Roger From alexj at businessabstraction.com Sun Oct 16 14:50:59 2005 From: alexj at businessabstraction.com (Alex Jouravlev) Date: Sun, 16 Oct 2005 22:50:59 +1000 Subject: [python-win32] Possible bug: what information to provide In-Reply-To: Message-ID: Thank you for that, Mark. I am afraid it still doesn't work ------------------------------------------ >>> from win32com.client import gencache >>> ea=gencache.EnsureModule('{64FB2BF4-9EFA-11D2-8307-C45586000000}', 0, 2, 10) >>> import win32com.client >>> rep = win32com.client.Dispatch('EA.Repository') >>> rep = ea.IRepository(rep) >>> rep.OpenFile2("C:\Test.eap","","") Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\lib\site-packages\win32com\gen_py\64FB2BF4-9EFA-11D2-8307-C4558 6000000x0x2x10.py", line 4480, in OpenFile2 , Username, Password) com_error: (-2147352573, 'Member not found.', None, None) ------------------------------------------------ Alex > -----Original Message----- > From: Mark Hammond [mailto:mhammond at skippinet.com.au] > Sent: Thursday, October 13, 2005 2:01 PM > To: Alex Jouravlev; python-win32 at python.org > Subject: RE: [python-win32] Possible bug: what information to provide > > > > > > One more strange thing: > > > > MakePy recognised the object as "IRepository" rather then > "Repository" > > > > > > I'm not sure what you mean here. Please post a complete code sample, > > > including all output that confuses you or you believe to be wrong. > > > > > Makepy.py output (fragment, for information about the Object) > > ----------------------------------------------- > > class IRepository(DispatchBaseClass): > > Right - that is normal. It is indeed the interface that has the method - > the "coclass" described in the file probably has a reference to that > interface - a coclass may implement many interfaces. > > > > The code above is not using makepy, even though it may have > > > been run. You > > > could try creating the object using > > > win32com.client.gencache.EnsureDispatch > > > > I tried, here is the result: > > ----------------------------------- > > >>> rep = win32com.client.gencache.EnsureDispatch('EA.Repository') > > Traceback (most recent call last): > > File "", line 1, in ? > > File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line > > 543, in EnsureDispatch > > raise TypeError, "This COM object can not automate the makepy > > process - > > please run makepy manually for this object" > > TypeError: This COM object can not automate the makepy process - > > please run > > makepy manually for this object > > Sadly, this object is not providing its typeinfo at runtime. If > you can get > in touch with the developers, ask them to consider adding this IDispatch > typeinfo support - they already have the typeinfo available from their > typelib, so it should be quite easy to do. > > In the meantime, you need to explicitly "cast" your objects into these > makepy objects. You should start by running "makepy.py -i" (from a > command-prompt). Here is what I get when I pick some random lib: > > IAS Helper COM Component 1.0 Type Library > {6BC096BB-0CE6-11D1-BAAE-00C04FC2E20D}, lcid=0, major=1, minor=0 > >>> # Use these commands in Python code to auto generate .py support > >>> from win32com.client import gencache > >>> gencache.EnsureModule('{6BC096BB-0CE6-11D1-BAAE-00C04FC2E20D}', 0, 1, > 0) > > You should add these lines to your code - but with one change: > > > from win32com.client import gencache > > mod = gencache.EnsureModule('{6BC096BB-0CE6-11D1-BAAE-00C04FC2E20D}', 0, > 1, 0) > > Note the last line - 'mod ='. This will be the makepy module, as imported > from the gen_py directory. You can then write: > > rep = win32com.client.Dispatch('EA.Repository') > # Now 'cast' it to an IRepository object. > rep = mod.IRepository(rep) > > print repr(rep) # Should now print a repr that indicates it is a makepy > object. > > You will need to this whenever you get a "new" object. Eg, let's > say there > was a "GetApplication()" method on a repository. > > app = rep.GetApplication() > print repr(app) # will probably say "" - not what > you want. > app = mod.IApplication(app) # Cast to a mythical IApplication object. > print repr(app) # should show the makepy object. > > Hope that makes sense, > > Mark > > From rwupole at msn.com Sun Oct 16 16:51:54 2005 From: rwupole at msn.com (Roger Upole) Date: Sun, 16 Oct 2005 10:51:54 -0400 Subject: [python-win32] Re: Using win32security from IIS/CGI script Message-ID: > Hi, > > I'm trying to call the following win3security API as part of a CGI > script being served up by IIS6 on W2k3. > > secDes = win32security.GetNamedSecurityInfo(filename, \ > win32security.SE_FILE_OBJECT, \ > win32security.DACL_SECURITY_INFORMATION \ > win32security.GROUP_SECURITY_INFORMATION \ > win32security.OWNER_SECURITY_INFORMATION) > > I have got the script running from a secure page (NT Auth) in the > context of the user that is calling the script through IIS but I am > getting an access denied error, as indicated below > > E:\Inetpub\tools\AccessList.py in > getAceList(filename=r'\\server\somefile') > secDes = win32security.GetNamedSecurityInfo(filename, \ > win32security.SE_FILE_OBJECT, \ > win32security.DACL_SECURITY_INFORMATION \ > | win32security.GROUP_SECURITY_INFORMATION \ > | win32security.OWNER_SECURITY_INFORMATION) > > global win32security = Files\Python24\lib\site-packages\win32\win32security.pyd'>, > win32security.DACL_SECURITY_INFORMATION = 4, > win32security.GROUP_SECURITY_INFORMATION = 2, > win32security.OWNER_SECURITY_INFORMATION = 1 > > error: (5, 'GetNamedSecurityInfo', 'Access is denied.') > args = (5, 'GetNamedSecurityInfo', 'Access is denied.') > > I can confirm that it is running in the context of me as a user and > This works ok if I run it interactively from PythonWin directly on the > server under my account. > > Can anyone point me in the right direction? > > Thanks > Peter Can you do a normal open on the file, or is just the security functions that fail ? Also, how are you verifying that the script is running as you when run under CGI? Does win32api.GetUserName() return your user id ? Roger From timr at probo.com Mon Oct 17 18:48:31 2005 From: timr at probo.com (Tim Roberts) Date: Mon, 17 Oct 2005 09:48:31 -0700 Subject: [python-win32] Control-C In-Reply-To: References: Message-ID: <4353D5DF.6090000@probo.com> On Fri, 14 Oct 2005 08:38:49 -0700, "David Schnepper" wrote: >The Windows notion of a "Console" is independent from a "visual window >on the display". You can still have a Console without anything appearing >on the screen. Generally, if you start a process from a cmd.exe >window you inherit the cmd.exe window as your console, if your process >is started from the Services Manager you have no console -- but can >allocate one with AllocConsole(). > Unfortunately, this situation is changing in Windows Vista. Services will be absolutely prohibited from interacting with the user. They will have to start up a separate process in the user's session in order to communicate -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From nicky.p.impert at boeing.com Mon Oct 17 23:39:50 2005 From: nicky.p.impert at boeing.com (Impert, Nicky P) Date: Mon, 17 Oct 2005 14:39:50 -0700 Subject: [python-win32] errors running C++ client against python COM server Message-ID: <34C0247D227E0F4CBE949B2AAE16B3B8107B0E@XCH-NW-3V2.nw.nos.boeing.com> Mark, thanks for getting back to me. Note, I have since also tried getting a python COM server using package ctypes to connect to a C++ COM client using event handlers and found I could do it with a dispatch interface (dispinterface in idl), but not a custom interface (inherited from IUnknown). Can someone tell me if it is possible to call an event handler on a client from python using a custom interface (w/ or w/out ctypes)? If so, can someone show me an example? Here is the error log from the default python client (only try to connect from the C++ client if the python client is still happy): python client.py create instance of server pythoncom error: ERROR: server.policy could not create an instance. Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 144, in CreateInstance return retObj._CreateInstance_(clsid, reqIID) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 203, in _CreateInstance_ self._wrap_(myob) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 468, in _wrap_ tlb_major, tlb_minor, interfaces) File "C:\Python24\Lib\site-packages\win32com\universal.py", line 54, in RegisterInterfaces raise ValueError, "Interface '%s' does not exist in this cached typelib" % (name,) exceptions.ValueError: Interface '{F51A6858-F43E-4CF9-B603-6D15D3E8DB71}' does not exist in this cached typelib pythoncom error: Unexpected gateway error Traceback (most recent call last): File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 144, in CreateInstance return retObj._CreateInstance_(clsid, reqIID) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 203, in _CreateInstance_ self._wrap_(myob) File "C:\Python24\Lib\site-packages\win32com\server\policy.py", line 468, in _wrap_ tlb_major, tlb_minor, interfaces) File "C:\Python24\Lib\site-packages\win32com\universal.py", line 54, in RegisterInterfaces raise ValueError, "Interface '%s' does not exist in this cached typelib" % (name,) exceptions.ValueError: Interface '{F51A6858-F43E-4CF9-B603-6D15D3E8DB71}' does not exist in this cached typelib pythoncom error: CPyFactory::CreateInstance failed to create instance. (80004005) Traceback (most recent call last): File "client.py", line 72, in ? test(1) File "client.py", line 54, in test server = win32com.client.dynamic.Dispatch("Python.MyEventServer") File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 98, in Dispatch IDispatch, userName = _GetGoodDispatchAndUserName(IDispatch,userName,clsctx) File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 79, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147221231, 'ClassFactory cannot supply requested class', None, None) the python client code reads: # Implements a connectable client. # # Initial client code extracted from # C:\Python24\Lib\site-packages\win32com\demos\connect.py import pythoncom import win32com.server.util import win32com.server.connect from win32com.server.exception import Exception # This is the IID of the Events interface both Client and Server support. IID__IConnectDemoEvents = pythoncom.MakeIID("{FCA56F6D-2291-4A32-9BDE-D577D24616F1}") # Here is the client side of the connection world. # Define a COM object which implements the methods defined by the # IConnectDemoEvents interface. class ConnectableClient: # This is another cheat - I _know_ the server defines the "DoneIt" # event as DISPID==1000 - I also know from the implementation details # of COM that the first method in _public_methods_ gets 1000. # Normally some explicit DISPID->Method mapping is required. _public_methods_ = ["OnDoneIt"] def __init__(self): self.last_event_arg = None # A client must implement QI, and respond to a query for the Event # interface. In addition, it must provide a COM object. # This is provided by server.util.wrap(). def _query_interface_(self, iid): import win32com.server.util # Note that this seems like a necessary hack. # I am responding to IID__IConnectDemoEvents # but only creating an IDispatch gateway object. if iid==IID__IConnectDemoEvents: return win32com.server.util.wrap(self) # And here is our event method which gets called. def OnDoneIt(self, arg): self.last_event_arg = arg def CheckEvent(server, client, val, verbose): client.last_event_arg = None server.DoIt(val) if client.last_event_arg != val: print "Sent %r, but got back %r" % (val, client.last_event_arg) elif verbose: print "Sent and received %r" % val # A simple test script for all this. # In the real world, it is likely that the code controlling the server # will be in the same class as that getting the notifications. def test(verbose=0): import win32com.client.dynamic, win32com.client.connect import win32com.server.policy print "create instance of server" server = win32com.client.dynamic.Dispatch("Python.MyEventServer") print "create instance of client" client = ConnectableClient() print "connect client to server (1 of 2)" connection = win32com.client.connect.SimpleConnection() print "connect client to server (2 of 2)" connection.Connect(server, client, IID__IConnectDemoEvents) CheckEvent(server, client, "Hello", verbose) if verbose: print "Everything seemed to work!" # Aggressive memory leak checking (ie, do nothing!) # :-) All should cleanup OK??? if __name__=='__main__': test(1) From peter.mctaggart at boeing.com Wed Oct 19 07:01:58 2005 From: peter.mctaggart at boeing.com (I-McTaggart, Peter) Date: Wed, 19 Oct 2005 15:01:58 +1000 Subject: [python-win32] Using win32security from IIS/CGI script Message-ID: <373EC11E4993DF4F9DCBD2E630568CE37A2923@xch-au-20.au.nos.boeing.com> Hi Roger, I am printing GetUserName() and it is the correct user (ie my user id). I haven't tried to normally open the file - but will give it a go. I'm travelling now so it ay take a week or so before I get to it. Thanks Peter -----Original Message----- From: Roger Upole [mailto:rwupole at msn.com] Sent: Sunday, October 16, 2005 7:52 AM To: python-win32 at python.org Subject: [python-win32] Re: Using win32security from IIS/CGI script > Hi, > > I'm trying to call the following win3security API as part of a CGI > script being served up by IIS6 on W2k3. > > secDes = win32security.GetNamedSecurityInfo(filename, \ > win32security.SE_FILE_OBJECT, \ > win32security.DACL_SECURITY_INFORMATION \ > win32security.GROUP_SECURITY_INFORMATION \ > win32security.OWNER_SECURITY_INFORMATION) > > I have got the script running from a secure page (NT Auth) in the > context of the user that is calling the script through IIS but I am > getting an access denied error, as indicated below > > E:\Inetpub\tools\AccessList.py in > getAceList(filename=r'\\server\somefile') > secDes = win32security.GetNamedSecurityInfo(filename, \ > win32security.SE_FILE_OBJECT, \ > win32security.DACL_SECURITY_INFORMATION \ > | win32security.GROUP_SECURITY_INFORMATION \ > | win32security.OWNER_SECURITY_INFORMATION) > > global win32security = Files\Python24\lib\site-packages\win32\win32security.pyd'>, > win32security.DACL_SECURITY_INFORMATION = 4, > win32security.GROUP_SECURITY_INFORMATION = 2, > win32security.OWNER_SECURITY_INFORMATION = 1 > > error: (5, 'GetNamedSecurityInfo', 'Access is denied.') args = (5, > 'GetNamedSecurityInfo', 'Access is denied.') > > I can confirm that it is running in the context of me as a user and > This works ok if I run it interactively from PythonWin directly on the > server under my account. > > Can anyone point me in the right direction? > > Thanks > Peter Can you do a normal open on the file, or is just the security functions that fail ? Also, how are you verifying that the script is running as you when run under CGI? Does win32api.GetUserName() return your user id ? Roger _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From kingsleyturner at westpac.com.au Wed Oct 19 01:51:32 2005 From: kingsleyturner at westpac.com.au (Kinsley Turner) Date: Wed, 19 Oct 2005 09:51:32 +1000 Subject: [python-win32] String weirdness on python 2.4 / windows Message-ID: Hey-ho, I'm having a problem with some binary data read into a string. Basically I open an icon file "rb", read() it into a string, then spit it back down on a web request for /favicon.ico. It works fine under unix, but under Win32 Python 2.4.2 (#67, Sep 28 2005 ... It comes back corrupted. Similiarly I have a string with the IBM-extended-ASCII degrees symbol (ascii 0xb0) that is read in from a network-connected field device. Somehow this ends up with an extended 'A' (with a single dot over it.) prepended before it. Is there some sort of new 2.4 string encoding option I've missed ? Never seen anything like this before. I have the "# -*- coding: iso-8859-1 -*-" atop my files. -kt Please consider our environment before printing this email. WARNING - This email and any attachments may be confidential. If received in error, please delete and inform us by return email. Because emails and attachments may be interfered with, may contain computer viruses or other defects and may not be successfully replicated on other systems, you must be cautious. Westpac cannot guarantee that what you receive is what we sent. If you have any doubts about the authenticity of an email by Westpac, please contact us immediately. It is also important to check for viruses and defects before opening or using attachments. Westpac's liability is limited to resupplying any affected attachments. This email and its attachments are not intended to constitute any form of financial advice or recommendation of, or an offer to buy or offer to sell, any security or other financial product. We recommend that you seek your own independent legal or financial advice before proceeding with any investment decision. Westpac Institutional Bank is a division of Westpac Banking Corporation, a company registered in New South Wales in Australia under the Corporations Act 2001 (Cth). Westpac is authorised and regulated in the United Kingdom by the Financial Services Authority and is registered at Cardiff in the United Kingdom as Branch No. BR 106. Westpac operates in the United States of America as a federally chartered branch, regulated by the Office of the Comptroller of the Currency. Westpac Banking Corporation ABN 33 007 457 141. From shad.muegge at gmail.com Wed Oct 19 22:22:37 2005 From: shad.muegge at gmail.com (Shad Muegge) Date: Wed, 19 Oct 2005 13:22:37 -0700 Subject: [python-win32] win32com calling C++ COM interface Message-ID: Hi, I've just started looking at Python. I am trying to resolve an issue a user is having trying to access the COM interface in our application from Python. C++ code: STDMETHODIMP CMyClass::Read( const int x, VARIANT *indexlist, // IN: "safe" array of 4-byte integers VARIANT *results) Python code: def read(self, x, addr): try: addr = buffer(array.array('L', addr)) data = self.__Api.Read(x, addr) ... x.read(0, 0x12345678) The variant that shows up on the C++ code is a safearray of 1-byte integers with 4 elements: 12, 34, 56, 78. The API treats them each as individual "addresses"... Here's the COM definition from the .py file. def Read(self, x=defaultNamedNotOptArg, indexlist=defaultNamedNotOptArg, results=pythoncom.Missing): """method Read""" return self._ApplyTypes_(2, 1, (24, 0), ((3, 1), (16396, 1), (16396, 2)), 'Read', None,x , indexlist, results) Thanks, Shad -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051019/55404cc7/attachment.htm From bgailer at alum.rpi.edu Wed Oct 19 22:37:01 2005 From: bgailer at alum.rpi.edu (bob) Date: Wed, 19 Oct 2005 13:37:01 -0700 Subject: [python-win32] win32com calling C++ COM interface In-Reply-To: References: Message-ID: <6.1.2.0.0.20051019133500.0350bee8@mail.mric.net> At 01:22 PM 10/19/2005, Shad Muegge wrote: >Hi, > >I've just started looking at Python. I am trying to resolve an issue a >user is having trying to access the COM interface in our application from >Python. > >C++ code: > >STDMETHODIMP >CMyClass::Read( > const int x, > VARIANT *indexlist, // IN: "safe" array of 4-byte integers > VARIANT *results) > > >Python code: > > def read(self, x, addr): > try: > addr = buffer(array.array('L', addr)) > data = self.__Api.Read(x, addr) >... > >x.read(0, 0x12345678) > >The variant that shows up on the C++ code is a safearray of 1-byte >integers with 4 elements: 12, 34, 56, 78. > >The API treats them each as individual "addresses"... > >Here's the COM definition from the .py file. > > def Read(self, x=defaultNamedNotOptArg, indexlist=defaultNamedNotOptArg, > results=pythoncom.Missing): > """method Read""" > return self._ApplyTypes_(2, 1, (24, 0), ((3, 1), (16396, 1), (16396, > 2)), 'Read', None,x > , indexlist, results) > Since I don't know the C++ side of COM I probably can't help. And perhaps it is for that reason that I don't even know what the user's issue is. If it is obvious to the cognoscenti, fine. For my sake could you elaborate. What is the "issue"? From shad.muegge at gmail.com Wed Oct 19 22:42:57 2005 From: shad.muegge at gmail.com (Shad Muegge) Date: Wed, 19 Oct 2005 13:42:57 -0700 Subject: [python-win32] win32com calling C++ COM interface In-Reply-To: <6.1.2.0.0.20051019133500.0350bee8@mail.mric.net> References: <6.1.2.0.0.20051019133500.0350bee8@mail.mric.net> Message-ID: Sorry, the interface is expecting a safearray of 4-byte integers, instead it's getting a safearray of 1-byte integers. On 10/19/05, bob wrote: > > At 01:22 PM 10/19/2005, Shad Muegge wrote: > >Hi, > > > >I've just started looking at Python. I am trying to resolve an issue a > >user is having trying to access the COM interface in our application from > >Python. > > > >C++ code: > > > >STDMETHODIMP > >CMyClass::Read( > > const int x, > > VARIANT *indexlist, // IN: "safe" array of 4-byte integers > > VARIANT *results) > > > > > >Python code: > > > > def read(self, x, addr): > > try: > > addr = buffer(array.array('L', addr)) > > data = self.__Api.Read(x, addr) > >... > > > >x.read(0, 0x12345678) > > > >The variant that shows up on the C++ code is a safearray of 1-byte > >integers with 4 elements: 12, 34, 56, 78. > > > >The API treats them each as individual "addresses"... > > > >Here's the COM definition from the .py file. > > > > def Read(self, x=defaultNamedNotOptArg, indexlist=defaultNamedNotOptArg, > > results=pythoncom.Missing): > > """method Read""" > > return self._ApplyTypes_(2, 1, (24, 0), ((3, 1), (16396, 1), (16396, > > 2)), 'Read', None,x > > , indexlist, results) > > > Since I don't know the C++ side of COM I probably can't help. And perhaps > it is for that reason that I don't even know what the user's issue is. If > it is obvious to the cognoscenti, fine. For my sake could you elaborate. > What is the "issue"? > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051019/a1f8d3e9/attachment.html From mhammond at skippinet.com.au Wed Oct 19 23:57:16 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 20 Oct 2005 07:57:16 +1000 Subject: [python-win32] win32com calling C++ COM interface In-Reply-To: Message-ID: Your code is explicitly creating a buffer object, which the win32com framework translates as "array of bytes". Try just passing a list (or tuple) of integers instead of the buffer. Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Shad Muegge Sent: Thursday, 20 October 2005 6:23 AM To: python-win32 at python.org Subject: [python-win32] win32com calling C++ COM interface Hi, I've just started looking at Python. I am trying to resolve an issue a user is having trying to access the COM interface in our application from Python. C++ code: STDMETHODIMP CMyClass::Read( const int x, VARIANT *indexlist, // IN: "safe" array of 4-byte integers VARIANT *results) Python code: def read(self, x, addr): try: addr = buffer(array.array('L', addr)) data = self.__Api.Read(x, addr) ... x.read(0, 0x12345678) The variant that shows up on the C++ code is a safearray of 1-byte integers with 4 elements: 12, 34, 56, 78. The API treats them each as individual "addresses"... Here's the COM definition from the .py file. def Read(self, x=defaultNamedNotOptArg, indexlist=defaultNamedNotOptArg, results=pythoncom.Missing): """method Read""" return self._ApplyTypes_(2, 1, (24, 0), ((3, 1), (16396, 1), (16396, 2)), 'Read', None,x , indexlist, results) Thanks, Shad -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051020/7040a424/attachment.htm From kimwaic888-pythonwin32 at yahoo.com Thu Oct 20 01:20:25 2005 From: kimwaic888-pythonwin32 at yahoo.com (kimwaic888-pythonwin32@yahoo.com) Date: Wed, 19 Oct 2005 16:20:25 -0700 (PDT) Subject: [python-win32] msoScaleFromTopLeft Message-ID: <20051019232025.52308.qmail@web51409.mail.yahoo.com> Hi list, Could someone please tell me what I should do with values such as msoScaleFromTopLeft? I tried: constants.msoScaleFromTopLeft and that didn't work. Thanks, -- John From kingsleyturner at westpac.com.au Thu Oct 20 02:04:24 2005 From: kingsleyturner at westpac.com.au (Kinsley Turner) Date: Thu, 20 Oct 2005 10:04:24 +1000 Subject: [python-win32] String weirdness on python 2.4 / windows In-Reply-To: Message-ID: Emlyn Jones wrote on 20/10/2005 02:46:54 AM: > In what way is it corrupted? Are you 100% sure that no extra output > is being prepended/appended when you output the icon file data via > HTTP? Have a look at it in emacs/notepad just to check there are no > stray HTTP Headers or other output ending up in your file. I checked the icon, it seemed to be ok. I'm unfamiliar with win32 tools, but it seemed that the data being delivered from the socket rendered differently from a python print() compared to a terminal 'type icon.ico'. I cut the code out and tested it in isolation - this showed it to be flawless. Despite appearing correct in other software the binary identical icon appears broken in IE 6.. I think you might be correct with the headers suggestion, that was going to be my next point of investigation. I don't think the MIME type of image/bmp is acceptable to IE. thanks, -kt -- Please consider our environment before printing this email. WARNING - This email and any attachments may be confidential. If received in error, please delete and inform us by return email. Because emails and attachments may be interfered with, may contain computer viruses or other defects and may not be successfully replicated on other systems, you must be cautious. Westpac cannot guarantee that what you receive is what we sent. If you have any doubts about the authenticity of an email by Westpac, please contact us immediately. It is also important to check for viruses and defects before opening or using attachments. Westpac's liability is limited to resupplying any affected attachments. This email and its attachments are not intended to constitute any form of financial advice or recommendation of, or an offer to buy or offer to sell, any security or other financial product. We recommend that you seek your own independent legal or financial advice before proceeding with any investment decision. Westpac Institutional Bank is a division of Westpac Banking Corporation, a company registered in New South Wales in Australia under the Corporations Act 2001 (Cth). Westpac is authorised and regulated in the United Kingdom by the Financial Services Authority and is registered at Cardiff in the United Kingdom as Branch No. BR 106. Westpac operates in the United States of America as a federally chartered branch, regulated by the Office of the Comptroller of the Currency. Westpac Banking Corporation ABN 33 007 457 141. From kingsleyturner at westpac.com.au Thu Oct 20 03:16:03 2005 From: kingsleyturner at westpac.com.au (Kinsley Turner) Date: Thu, 20 Oct 2005 11:16:03 +1000 Subject: [python-win32] String weirdness on python 2.4 / windows In-Reply-To: <4356B6C4.9000103@lexicon.net> Message-ID: > >Similarly I have a string with the IBM-extended-ASCII degrees symbol > >(ascii 0xb0) > >that is read in from a network-connected field device. Somehow this ends > >up with > >an extended 'A' (with a single dot over it.) prepended before it. > This question is inappropriate for this mailing list, which is for the > pywin32 extensions, which you don't appear to be using. You should send > the question to python-list. Really? Ok. The list index (http://mail.python.org/mailman/listinfo) says this list is for "Python on win32". > What does "spit it back down on a web request for /favicon.ico" mean??? > What "it" comes back from "where" corrupted? When I say 'spit', you can read this as "transmits to the requesting web-browser using HTTP protocol over a BSD-style socket layering atop TCP/IP". > What does corrupted mean? No longer in it's original form. In this case it looks like bytes have been removed & changed. > It would help greatly if you showed the actual code that causes the > alleged problem. Even better would be to cut that out and make it > into a small standalone script that demonstrates the problem. Also > stating the expected or preferred result would be a good idea. Yes I agree, but not all problems can be rendered down into a simple example easily. You see in this case the string is rendered into an image and served back to a web browser. I had hoped for a simple answer like "Add encoding header XYZ to your script". Alas. > AFAIK ASCII describes only characters with ordinals in range(0x80). Yes that's true, original ASCII was only 7 bit. Obviously I was referring to ISO-8859-1, commonly referred to as 'Extended ASCII' and IIRC popularised by IBM in the 80's (70's?). It's been the dominant latin character set for 20 years or so. But you knew this already. > Perhaps you mean that you have a string which contains '\xb0'. No. The string is encoded as a single symbol within the python string, not a trigraph (quadgraph?). > "Somehow" -- unless you have pixies at the bottom of your garden, it > got mangled because *YOU* did something to it. If you can't tell us > what you did to it, we can't help you. The string in question is a test-string. Basically it contains a few words, then "1234567890 !C" where the '!' is the degrees-symbol as specified in Extended ASCII / ISO-8859-*. The text is then rendered into an image (using a supplied GNU TTF font) via the Python Imaging Library (PIL). Under UNIX this comes out as expected, with the degrees symbol rendered appropriately. When run as a Win32 service the rendering comes out with an accented 'A' in front of it. > "Extended A with a single dot over it"?? Are you sure that's a dot? I'd > like to know what language uses A with dot above *and* what the pixies > are using to render it on your screen. Could it possibly be a circumflex > accent? I thought it was a '?' (pasted in an 'A' with a dot above it, well, ok, maybe I should have said 'circle above it') Depending on your font & size sometimes the dot is connected to the top of the A, in other's it hovers. Try it: print u'\xc5'. This is from an ISO-8859-1 encoding, YMMV. Sorry, I don't know what language uses this character either. It's being rendered by the PIL. > Hint (1): u'\xb0'.encode('utf-8') produces '\xc2\xb0'. If that is > displayed by a gadget that's expecting iso-8859-1 (or cp1252) instead of > utf-8, '\xc2' will show as Latin capital A with circumflex. Hmmm, I wonder if PIL is doing some kind of modification to the string before rendering it. This question might better be posed to the PIL list. I can't really control what the device sends back, but I think this is not the only Extended ASCII / ISO-8859-* character it delivers. Ahhh... I think I've got it. > Hint (2): print repr(allegedly_mangled_string) This gives me '1234567890\xb0C' from a UNIX python (2.4.2 #1) Win32 (python 2.4.2 #64) gives the same. So it mustn't be something to do with the python / string representation. > "prepended before it" -- as opposed to "prepended after it"? That would be "'appended' after it", wouldn't it? (or are you just trying to pick a spoonerism) > Perhaps we should avoid Westpac ATMs until you sound the all-clear :-) Last time I looked these ran on OS/2[1], so I think you'll be safe. thanks for the hints, -kt [1] At least the old ones anyway. (unremovable disclaimer below) -- Please consider our environment before printing this email. WARNING - This email and any attachments may be confidential. If received in error, please delete and inform us by return email. Because emails and attachments may be interfered with, may contain computer viruses or other defects and may not be successfully replicated on other systems, you must be cautious. Westpac cannot guarantee that what you receive is what we sent. If you have any doubts about the authenticity of an email by Westpac, please contact us immediately. It is also important to check for viruses and defects before opening or using attachments. Westpac's liability is limited to resupplying any affected attachments. This email and its attachments are not intended to constitute any form of financial advice or recommendation of, or an offer to buy or offer to sell, any security or other financial product. We recommend that you seek your own independent legal or financial advice before proceeding with any investment decision. Westpac Institutional Bank is a division of Westpac Banking Corporation, a company registered in New South Wales in Australia under the Corporations Act 2001 (Cth). Westpac is authorised and regulated in the United Kingdom by the Financial Services Authority and is registered at Cardiff in the United Kingdom as Branch No. BR 106. Westpac operates in the United States of America as a federally chartered branch, regulated by the Office of the Comptroller of the Currency. Westpac Banking Corporation ABN 33 007 457 141. From justin.mailinglists at gmail.com Thu Oct 20 03:44:22 2005 From: justin.mailinglists at gmail.com (Justin Ezequiel) Date: Thu, 20 Oct 2005 09:44:22 +0800 Subject: [python-win32] String weirdness on python 2.4 / windows Message-ID: <3c6718980510191844w7faeadafjd628a0ed9822de0@mail.gmail.com> > Date: Thu, 20 Oct 2005 10:04:24 +1000 > From: Kinsley Turner > > I checked the icon, it seemed to be ok. I'm unfamiliar with win32 > tools, but it seemed that the data being delivered from the socket > rendered differently from a python print() compared to a terminal > 'type icon.ico'. I cut the code out and tested it in isolation - this > showed it to be flawless. Despite appearing correct in other software > the binary identical icon appears broken in IE 6.. for what its worth, had a similar problem serving up images from a Python CGI script running on Apache on WinXP. what worked for me was adding the "-u" switch to the shebang #!E:\Python23\python.exe -u -u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x) see man page for details on internal buffering relating to '-u' hope this helps From gagenellina at softlab.com.ar Thu Oct 20 05:19:07 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Thu, 20 Oct 2005 00:19:07 -0300 Subject: [python-win32] String weirdness on python 2.4 / windows In-Reply-To: References: Message-ID: <6.2.1.2.0.20051020000745.034982d0@192.168.0.115> At Wednesday 19/10/2005 21:04, you wrote: >I think you might be correct with the headers suggestion, that was >going to be my next point of investigation. I don't think the >MIME type of image/bmp is acceptable to IE. Should be image/vnd.microsoft.icon or image/x-icon, but NOT image/bmp (icon files having different format than bmp files) Gabriel Genellina Softlab SRL From steve at holdenweb.com Thu Oct 20 09:00:50 2005 From: steve at holdenweb.com (Steve Holden) Date: Thu, 20 Oct 2005 08:00:50 +0100 Subject: [python-win32] String weirdness on python 2.4 / windows In-Reply-To: References: Message-ID: <435740A2.1040001@holdenweb.com> Kinsley Turner wrote: > >>>Similarly I have a string with the IBM-extended-ASCII degrees symbol >>>(ascii 0xb0) >>>that is read in from a network-connected field device. Somehow this > > ends > >>>up with >>>an extended 'A' (with a single dot over it.) prepended before it. > > >>This question is inappropriate for this mailing list, which is for the >>pywin32 extensions, which you don't appear to be using. You should send >>the question to python-list. > > > Really? Ok. > The list index (http://mail.python.org/mailman/listinfo) says > this list is for "Python on win32". > Which understandably misled you, but this list is specifically for issues concerning the use of the win32all extension modules. General Python help is best obtained fro python-list at python.org, whether on Windows or any other platform. > >>What does "spit it back down on a web request for /favicon.ico" mean??? >>What "it" comes back from "where" corrupted? > > > When I say 'spit', you can read this as "transmits to the requesting > web-browser using HTTP protocol over a BSD-style socket layering > atop TCP/IP". > > >>What does corrupted mean? > > > No longer in it's original form. > In this case it looks like bytes have been removed & changed. > > >>It would help greatly if you showed the actual code that causes the >>alleged problem. Even better would be to cut that out and make it >>into a small standalone script that demonstrates the problem. Also >>stating the expected or preferred result would be a good idea. > > > Yes I agree, but not all problems can be rendered down into a simple > example easily. You see in this case the string is rendered into > an image and served back to a web browser. I had hoped for a simple > answer like "Add encoding header XYZ to your script". Alas. > > >>AFAIK ASCII describes only characters with ordinals in range(0x80). > > > Yes that's true, original ASCII was only 7 bit. > Obviously I was referring to ISO-8859-1, commonly referred to as > 'Extended ASCII' and IIRC popularised by IBM in the 80's (70's?). > It's been the dominant latin character set for 20 years or so. > But you knew this already. > > >>Perhaps you mean that you have a string which contains '\xb0'. > > > No. > The string is encoded as a single symbol within the python string, > not a trigraph (quadgraph?). > In Python, of course, '\xb0' is a single-byte string literal containing only the character whose integer value is hex B0. > >>"Somehow" -- unless you have pixies at the bottom of your garden, it >>got mangled because *YOU* did something to it. If you can't tell us >>what you did to it, we can't help you. > > > The string in question is a test-string. Basically it contains a > few words, then "1234567890 !C" where the '!' is the degrees-symbol > as specified in Extended ASCII / ISO-8859-*. The text is then rendered > into an image (using a supplied GNU TTF font) via the Python Imaging > Library > (PIL). Under UNIX this comes out as expected, with the degrees symbol > rendered appropriately. When run as a Win32 service the rendering > comes out with an accented 'A' in front of it. > > >>"Extended A with a single dot over it"?? Are you sure that's a dot? I'd >>like to know what language uses A with dot above *and* what the pixies >>are using to render it on your screen. Could it possibly be a circumflex > > >>accent? > > > I thought it was a '?' (pasted in an 'A' with a dot above it, > well, ok, maybe I should have said 'circle above it') Depending > on your font & size sometimes the dot is connected to the top of > the A, in other's it hovers. Try it: print u'\xc5'. This is from an > ISO-8859-1 encoding, YMMV. Sorry, I don't know what language > uses this character either. It's being rendered by the PIL. > > > >>Hint (1): u'\xb0'.encode('utf-8') produces '\xc2\xb0'. If that is >>displayed by a gadget that's expecting iso-8859-1 (or cp1252) instead of > > >>utf-8, '\xc2' will show as Latin capital A with circumflex. > > > Hmmm, I wonder if PIL is doing some kind of modification to the string > before rendering it. This question might better be posed to the PIL list. > I can't really control what the device sends back, but I think this > is not the only Extended ASCII / ISO-8859-* character it delivers. > > Ahhh... I think I've got it. > >>Hint (2): print repr(allegedly_mangled_string) > > > This gives me '1234567890\xb0C' from a UNIX python (2.4.2 #1) > Win32 (python 2.4.2 #64) gives the same. So it mustn't be something > to do with the python / string representation. > > >>"prepended before it" -- as opposed to "prepended after it"? > > > That would be "'appended' after it", wouldn't it? > (or are you just trying to pick a spoonerism) > > > >>Perhaps we should avoid Westpac ATMs until you sound the all-clear :-) > > > Last time I looked these ran on OS/2[1], so I think you'll be safe. > > > > thanks for the hints, > -kt > > > > [1] At least the old ones anyway. > > > Anyway, it looks like you are on the track of what appears to be a character set or encoding issue. Good luck. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ From le.dahut at laposte.net Thu Oct 20 16:24:02 2005 From: le.dahut at laposte.net (le dahut) Date: Thu, 20 Oct 2005 16:24:02 +0200 Subject: [python-win32] user currently connected Message-ID: <1129818242.9284.7.camel@kls> Hi, How can I get the name of a user currently connected on a windows workstation ? I mean a sort of "whoami". Thanks From tim.golden at viacom-outdoor.co.uk Thu Oct 20 16:35:54 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu, 20 Oct 2005 15:35:54 +0100 Subject: [python-win32] user currently connected Message-ID: <9A28C052FF32734DACB0A288A3533991044D226C@vogbs009.gb.vo.local> [le dahut] > How can I get the name of a user currently connected on a windows workstation ? I mean a sort of "whoami". import getpass getpass.getuser () Or import win32api win32api.GetUserName () Or import os os.environ['USERNAME'] TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From BRADLEY.S.GASPARD at saic.com Thu Oct 20 16:54:09 2005 From: BRADLEY.S.GASPARD at saic.com (Gaspard, Bradley S) Date: Thu, 20 Oct 2005 10:54:09 -0400 Subject: [python-win32] Access to the DHCP Client API Message-ID: <4797F6E414C24D4A96AAC14B320BCAD70FA531@0015-its-exmb02.us.saic.com> Is it possible to access Windows DHCP Client API using Python's win32 extensions? I couldn't find any information on the web. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051020/1e4eeed0/attachment.htm From Jim.Vickroy at noaa.gov Thu Oct 20 17:12:29 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu, 20 Oct 2005 09:12:29 -0600 Subject: [python-win32] detect file modification event In-Reply-To: References: <707B1920B56175498274490E1DFF176305E73E48@ibmail3> Message-ID: <4357B3DD.1070201@noaa.gov> Sorry if this has been previously answered, but my search failed to detect it. Could someone refer to information on how to detect file modification (e.g., update) events in MS Windows? Thanks, -- jv From tim.golden at viacom-outdoor.co.uk Thu Oct 20 17:29:26 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu, 20 Oct 2005 16:29:26 +0100 Subject: [python-win32] detect file modification event Message-ID: <9A28C052FF32734DACB0A288A3533991044D226D@vogbs009.gb.vo.local> [Jim Vickroy] > Sorry if this has been previously answered, but my search failed to detect it. > Could someone refer to information on how to detect file modification (e.g., update) events in MS Windows? Is this the sort of thing you were after? http://timgolden.me.uk/python/win32_how_do_i/watch_directory_for_changes .html TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From Jim.Vickroy at noaa.gov Thu Oct 20 17:42:15 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu, 20 Oct 2005 09:42:15 -0600 Subject: [python-win32] detect file modification event In-Reply-To: <9A28C052FF32734DACB0A288A3533991044D226D@vogbs009.gb.vo.local> References: <9A28C052FF32734DACB0A288A3533991044D226D@vogbs009.gb.vo.local> Message-ID: <4357BAD7.10203@noaa.gov> Fantastic! That's it exactly. I was hoping to avoid polling and this shows me how. Thanks much. -- jv Tim Golden wrote: >[Jim Vickroy] > > > >>Sorry if this has been previously answered, but my search failed to >> >> >detect it. > > >>Could someone refer to information on how to detect file modification >> >> >(e.g., update) events in MS Windows? > >Is this the sort of thing you were after? > >http://timgolden.me.uk/python/win32_how_do_i/watch_directory_for_changes >.html > >TJG > >________________________________________________________________________ >This e-mail has been scanned for all viruses by Star. The >service is powered by MessageLabs. For more information on a proactive >anti-virus service working around the clock, around the globe, visit: >http://www.star.net.uk >________________________________________________________________________ >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > From rwupole at msn.com Thu Oct 20 18:35:56 2005 From: rwupole at msn.com (Roger Upole) Date: Thu, 20 Oct 2005 12:35:56 -0400 Subject: [python-win32] Re: Access to the DHCP Client API Message-ID: "Gaspard, Bradley S" wrote: > Is it possible to access Windows DHCP Client API using Python's win32 > extensions? > I couldn't find any information on the web. None of the Dhcp functions are wrapped, but depending on what you're trying to accomplish, you might be able use use WMI. The Win32_NetworkAdapterConfiguration class has several methods and properties related to Dhcp. hth Roger From timr at probo.com Thu Oct 20 18:57:57 2005 From: timr at probo.com (Tim Roberts) Date: Thu, 20 Oct 2005 09:57:57 -0700 Subject: [python-win32] String weirdness on python 2.4 / windows In-Reply-To: References: Message-ID: <4357CC95.40009@probo.com> On Wed, 19 Oct 2005 09:51:32 +1000, Kinsley Turner wrote: >Hey-ho, > >I'm having a problem with some binary data read into a string. > >Basically I open an icon file "rb", read() it into a string, then >spit it back down on a web request for /favicon.ico. > >It works fine under unix, but under Win32 Python 2.4.2 (#67, Sep 28 2005 >... >It comes back corrupted. > >Similiarly I have a string with the IBM-extended-ASCII degrees symbol >(ascii 0xb0) >that is read in from a network-connected field device. Somehow this ends >up with >an extended 'A' (with a single dot over it.) prepended before it. > >Is there some sort of new 2.4 string encoding option I've missed ? >Never seen anything like this before. > >I have the "# -*- coding: iso-8859-1 -*-" atop my files. > Are you writing this as a CGI process in Apache/Win32? Have you redefined your stdout to be binary? By default, Python opens its stdout as binary, so when you write this out to the socket, the file system will "helpfully" translate 0A to 0D/0A. You need something like this: import msvcrt msvcrt.setmode( 0, os.O_BINARY ) msvcrt.setmode( 1, os.O_BINARY ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jim.mccoy at gmail.com Thu Oct 20 19:01:28 2005 From: jim.mccoy at gmail.com (Jim McCoy) Date: Thu, 20 Oct 2005 10:01:28 -0700 Subject: [python-win32] detect file modification event In-Reply-To: <4357BAD7.10203@noaa.gov> References: <9A28C052FF32734DACB0A288A3533991044D226D@vogbs009.gb.vo.local> <4357BAD7.10203@noaa.gov> Message-ID: The only warning I would add here is that you should be aware of the fact that your watcher thread will block waiting for a change to occur in the directory; you cannot cancel the blocked ReadDirectoryChangesW call using the standard pywin32 bindings. We have put together some patches for ReadDirectoryChangesW in pywin32-204 that enable you to do this check using an io completion event so that you do not end up blocking on the directory you are watching. I have been a lazy bum and left these things sitting in a directory waiting to send off to Mark... I guess I should pass them along. Jim From jhu at metrigenix.com Thu Oct 20 22:26:35 2005 From: jhu at metrigenix.com (James Hu) Date: Thu, 20 Oct 2005 16:26:35 -0400 Subject: [python-win32] create user message for wxPython Message-ID: <90DEA7ED93F71A4580CEDF76A02682EA03ACC4@torexch.metrigenix.com> Hi, There are 2 wxPython application, A and B and need to exchange msg. Sending WM_CLOSE, wxEVT_MOUSEWHEEL to B is OK, and sending user message like 1225 from A to B is also OK. But B didn't catch this message, note, B is running before A sends msg and can receive "WM_CLOSE". Do I have to make my own msg loop by using win32api, win32gui? I used win32gui to post Message to other windows. Using wx.Frame: wx.EVT_START_MSG= 1225 EVT_START_MSG_EVENT= wx.PyEventBinder(wx.EVT_START_MSG, 0) EVT_START_MSG_EVENT(self, self.OnStart) Or Self.Bind(EVT_START_MSG_EVENT,self.OnStart) def OnStart(self, event): print 'got start message' Thanks a lot in advance! James From tim.golden at viacom-outdoor.co.uk Fri Oct 21 09:48:36 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Fri, 21 Oct 2005 08:48:36 +0100 Subject: [python-win32] detect file modification event Message-ID: <9A28C052FF32734DACB0A288A3533991044D2270@vogbs009.gb.vo.local> [Jim McCoy] > The only warning I would add here is that you should be aware of the fact that your watcher > thread will block waiting for a change to occur in the directory; you cannot cancel the > blocked ReadDirectoryChangesW call using the standard pywin32 bindings. If it causes a problem it might be worth considering one of the other techniques, eg http://tgolden.sc.sabren.com/python/win32_how_do_i/watch_directory_for_c hanges.html#use_findfirstchange which uses the standard WaitForSingleObject approach which admits of a timeout. > We have put together some patches for ReadDirectoryChangesW in pywin32-204 > that enable you to do this check using an io completion event so that you do > not end up blocking on the directory you are watching. I have been a lazy > bum and left these things sitting in a directory waiting to send off to Mark... > I guess I should pass them along. Please do. I, at least, would love to grapple with it. Jim _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From le.dahut at laposte.net Fri Oct 21 15:28:27 2005 From: le.dahut at laposte.net (le dahut) Date: Fri, 21 Oct 2005 15:28:27 +0200 Subject: [python-win32] cwd of program Message-ID: <1129901308.4835.4.camel@kls> hi I try to get the program's directory, the one where the .exe (or .py) is. With os.getcwd() I get the directory from where the program is launched not his directory. The program has to copy some files and thus I get an error like "XXXXXX no such file or directory" (the DOS box closed to quickly to have the detailed error msg...) where XXXXXX is a sub-directory of the program's one. Does someone have the solution ? Thanks From tim.golden at viacom-outdoor.co.uk Fri Oct 21 15:42:40 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Fri, 21 Oct 2005 14:42:40 +0100 Subject: [python-win32] cwd of program Message-ID: <9A28C052FF32734DACB0A288A3533991044D227E@vogbs009.gb.vo.local> [le dahut] > I try to get the program's directory, the one where the .exe (or .py) is. From within Python, sys.argv[0] usually gives you the running program (not sure what it does with py2exe etc.). So something like (untested): import os, sys print os.path.dirname (sys.argv[0]) > With os.getcwd() I get the directory from where the program is launched > not his directory. The program has to copy some files and thus I get an > error like "XXXXXX no such file or directory". Umm. It's not clear why you get "no such file / directory". Surely os.getcwd returns *some* real directory. Or is it that you don't have permissions to the directory? > (the DOS box closed to quickly to have the detailed > error msg...) where XXXXXX is a sub-directory of > the program's one. I'm assuming you're double-clicking on a Python icon to run the program. You might try, instead, running it from the command line: Start > Run > cmd.exe (DOS box opens) python x:\path\to\my\program.py This should let you see what's going on. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From le.dahut at laposte.net Fri Oct 21 15:53:21 2005 From: le.dahut at laposte.net (le dahut) Date: Fri, 21 Oct 2005 15:53:21 +0200 Subject: [python-win32] cwd of program In-Reply-To: <9A28C052FF32734DACB0A288A3533991044D227E@vogbs009.gb.vo.local> References: <9A28C052FF32734DACB0A288A3533991044D227E@vogbs009.gb.vo.local> Message-ID: <1129902802.4835.8.camel@kls> In fact I build an SFX archive with winrar where I specify a program to launch once extraction has ended. The program is launched but don't find it's sub-directory. If I go to the extracted archive directory an dlbe-clic on "install.exe" all runs fine, but whit winrar's "Run after extraction" option it doesn't. Le vendredi 21 octobre 2005 ? 14:42 +0100, Tim Golden a ?crit : > [le dahut] > > > I try to get the program's directory, the one where the .exe (or .py) > is. > > >From within Python, sys.argv[0] usually gives you the running > program (not sure what it does with py2exe etc.). So something > like (untested): > > > import os, sys > > print os.path.dirname (sys.argv[0]) > > > > > With os.getcwd() I get the directory from where the program is > launched > > not his directory. The program has to copy some files and thus I get > an > > error like "XXXXXX no such file or directory". > > Umm. It's not clear why you get "no such file / directory". Surely > os.getcwd returns *some* real directory. Or is it that you don't > have permissions to the directory? > > > (the DOS box closed to quickly to have the detailed > > error msg...) where XXXXXX is a sub-directory of > > the program's one. > > I'm assuming you're double-clicking on a Python icon to > run the program. You might try, instead, running it from > the command line: > > Start > Run > cmd.exe > (DOS box opens) > python x:\path\to\my\program.py > > This should let you see what's going on. > > TJG > > > ________________________________________________________________________ > This e-mail has been scanned for all viruses by Star. The > service is powered by MessageLabs. For more information on a proactive > anti-virus service working around the clock, around the globe, visit: > http://www.star.net.uk > ________________________________________________________________________ > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From jhu at metrigenix.com Fri Oct 21 17:53:42 2005 From: jhu at metrigenix.com (James Hu) Date: Fri, 21 Oct 2005 11:53:42 -0400 Subject: [python-win32] findwindow by its class name Message-ID: <90DEA7ED93F71A4580CEDF76A02682EA03ACC6@torexch.metrigenix.com> Hi, For the simple code: from wxPython.wx import * class MyApp(wxApp): def OnInit(self): frame = wxFrame(NULL, -1, "Hello App") frame.Show(true) self.SetTopWindow(frame) return true app = MyApp(0) app.MainLoop() Is there any way to know this windows' class name? I need to find it by win32gui.FindWindow(classname,None) and send msg from another application, but not using its title "Hello App". MyApp is not the classname, for it couldn't be found by FindWindow("MyApp",None). Thanks a lot in advance! James From steve at holdenweb.com Fri Oct 21 18:29:18 2005 From: steve at holdenweb.com (Steve Holden) Date: Fri, 21 Oct 2005 17:29:18 +0100 Subject: [python-win32] findwindow by its class name In-Reply-To: <90DEA7ED93F71A4580CEDF76A02682EA03ACC6@torexch.metrigenix.com> References: <90DEA7ED93F71A4580CEDF76A02682EA03ACC6@torexch.metrigenix.com> Message-ID: James Hu wrote: > Hi, > > For the simple code: > > from wxPython.wx import * > > class MyApp(wxApp): > def OnInit(self): > frame = wxFrame(NULL, -1, "Hello App") > frame.Show(true) > self.SetTopWindow(frame) > return true > > app = MyApp(0) > app.MainLoop() > > Is there any way to know this windows' class name? I need to find it by > win32gui.FindWindow(classname,None) and send msg from another > application, but not using its title "Hello App". > MyApp is not the classname, for it couldn't be found by > FindWindow("MyApp",None). > > Thanks a lot in advance! > I'm not saying it can'ty be done (which is a pity for you, because that's usually a cue for someone to contradict me) but it's expecting quite a lot of win32gui. A wxPython application is not a windows handle, and I suspect you will find that the classname you seek isn't visible from inside (wx)Python. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ From timr at probo.com Fri Oct 21 18:56:34 2005 From: timr at probo.com (Tim Roberts) Date: Fri, 21 Oct 2005 09:56:34 -0700 Subject: [python-win32] create user message for wxPython In-Reply-To: References: Message-ID: <43591DC2.4070707@probo.com> On Thu, 20 Oct 2005 16:26:35 -0400, "James Hu" >There are 2 wxPython application, A and B and need to exchange msg. >Sending WM_CLOSE, wxEVT_MOUSEWHEEL to B is OK, and sending user message >like 1225 from A to B is also OK. > >But B didn't catch this message, note, B is running before A sends msg >and can receive "WM_CLOSE". > >Do I have to make my own msg loop by using win32api, win32gui? I used >win32gui to post Message to other windows. > >Using wx.Frame: > >wx.EVT_START_MSG= 1225 >EVT_START_MSG_EVENT= wx.PyEventBinder(wx.EVT_START_MSG, 0) > > >EVT_START_MSG_EVENT(self, self.OnStart) >Or >Self.Bind(EVT_START_MSG_EVENT,self.OnStart) > >def OnStart(self, event): > print 'got start message' > > Application B must have a message loop in order to receive messages. You said application B was also a wxPython application. Doesn't it already have a wxApp and a wxFrame main window? If you are running app.MainLoop(), that should be enough to catch messages. As long as that "OnStart" function is a member of the frame class, it should work. How are you sending the messages? How did you get the window handle of the second application? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jhu at metrigenix.com Fri Oct 21 19:58:27 2005 From: jhu at metrigenix.com (James Hu) Date: Fri, 21 Oct 2005 13:58:27 -0400 Subject: [python-win32] create user message for wxPython Message-ID: <90DEA7ED93F71A4580CEDF76A02682EA03ACC7@torexch.metrigenix.com> Hi, Tim, Your idea probably works as well, but I found another way to catch user defined message. Thanks a lot! For the handler of the second app, win32gui.FindWindow can do this job, then win32gui.PostMessage. But for FindWindow, I can only find the specific window by its title, not by its registered class, which I posted another message. Any idea? James -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Roberts Sent: Friday, October 21, 2005 12:57 PM To: python-win32 at python.org Subject: [python-win32] create user message for wxPython On Thu, 20 Oct 2005 16:26:35 -0400, "James Hu" >There are 2 wxPython application, A and B and need to exchange msg. >Sending WM_CLOSE, wxEVT_MOUSEWHEEL to B is OK, and sending user message >like 1225 from A to B is also OK. > >But B didn't catch this message, note, B is running before A sends msg >and can receive "WM_CLOSE". > >Do I have to make my own msg loop by using win32api, win32gui? I used >win32gui to post Message to other windows. > >Using wx.Frame: > >wx.EVT_START_MSG= 1225 >EVT_START_MSG_EVENT= wx.PyEventBinder(wx.EVT_START_MSG, 0) > > >EVT_START_MSG_EVENT(self, self.OnStart) >Or >Self.Bind(EVT_START_MSG_EVENT,self.OnStart) > >def OnStart(self, event): > print 'got start message' > > Application B must have a message loop in order to receive messages. You said application B was also a wxPython application. Doesn't it already have a wxApp and a wxFrame main window? If you are running app.MainLoop(), that should be enough to catch messages. As long as that "OnStart" function is a member of the frame class, it should work. How are you sending the messages? How did you get the window handle of the second application? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From p.f.moore at gmail.com Fri Oct 21 20:27:43 2005 From: p.f.moore at gmail.com (Paul Moore) Date: Fri, 21 Oct 2005 19:27:43 +0100 Subject: [python-win32] findwindow by its class name In-Reply-To: References: <90DEA7ED93F71A4580CEDF76A02682EA03ACC6@torexch.metrigenix.com> Message-ID: <79990c6b0510211127i690370f6kaa59220d806dea83@mail.gmail.com> On 10/21/05, Steve Holden wrote: > > Is there any way to know this windows' class name? I need to find it by [...] > I'm not saying it can'ty be done (which is a pity for you, because > that's usually a cue for someone to contradict me) but it's expecting > quite a lot of win32gui. A wxPython application is not a windows handle, > and I suspect you will find that the classname you seek isn't visible > from inside (wx)Python. You had to make me do it, didn't you? :-) wxPython windows expose their HWND via the GetHandle() method. So you can get the frame's class name as win32gui.GetClassName(frame.GetHandle()) FWIW, I get a constant value of "wxWindowClassNR". Hope this helps, Paul. From jhu at metrigenix.com Fri Oct 21 21:26:52 2005 From: jhu at metrigenix.com (James Hu) Date: Fri, 21 Oct 2005 15:26:52 -0400 Subject: [python-win32] findwindow by its class name Message-ID: <90DEA7ED93F71A4580CEDF76A02682EA03ACC8@torexch.metrigenix.com> Thanks a lot! Yes, GetHandle() can return 'wxWindowClassNR', which is nice, but all wxPython apps return wxWindowClassNR as well, so when I Post Message, it goes to itself. James -----Original Message----- From: python-win32-bounces+jhu=metrigenix.com at python.org [mailto:python-win32-bounces+jhu=metrigenix.com at python.org] On Behalf Of Paul Moore Sent: Friday, October 21, 2005 2:28 PM To: Steve Holden Cc: python-list at python.org; python-win32 at python.org Subject: Re: [python-win32] findwindow by its class name On 10/21/05, Steve Holden wrote: > > Is there any way to know this windows' class name? I need to find it by [...] > I'm not saying it can'ty be done (which is a pity for you, because > that's usually a cue for someone to contradict me) but it's expecting > quite a lot of win32gui. A wxPython application is not a windows handle, > and I suspect you will find that the classname you seek isn't visible > from inside (wx)Python. You had to make me do it, didn't you? :-) wxPython windows expose their HWND via the GetHandle() method. So you can get the frame's class name as win32gui.GetClassName(frame.GetHandle()) FWIW, I get a constant value of "wxWindowClassNR". Hope this helps, Paul. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From gagenellina at softlab.com.ar Sat Oct 22 02:18:43 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Fri, 21 Oct 2005 21:18:43 -0300 Subject: [python-win32] findwindow by its class name In-Reply-To: <90DEA7ED93F71A4580CEDF76A02682EA03ACC8@torexch.metrigenix. com> References: <90DEA7ED93F71A4580CEDF76A02682EA03ACC8@torexch.metrigenix.com> Message-ID: <6.2.1.2.0.20051021210639.0371eb00@192.168.0.115> At Friday 21/10/2005 16:26, you wrote: >Thanks a lot! Yes, GetHandle() can return 'wxWindowClassNR', which is >nice, >but all wxPython apps return wxWindowClassNR as well, so when I Post >Message, it goes to itself. Application A can broadcast a private known message (using RegisterWindowMessage) including its own HWND; Application B handles it and replies to A with its own HWND. After that, both apps know the other's HWND and can post messages. Gabriel Genellina Softlab SRL From andre.burgaud at gmail.com Sat Oct 22 02:38:32 2005 From: andre.burgaud at gmail.com (Andre Burgaud) Date: Fri, 21 Oct 2005 19:38:32 -0500 Subject: [python-win32] cwd of program In-Reply-To: <1129902802.4835.8.camel@kls> References: <9A28C052FF32734DACB0A288A3533991044D227E@vogbs009.gb.vo.local> <1129902802.4835.8.camel@kls> Message-ID: <158731350510211738i51853abbl26eb1317d7f7cd5e@mail.gmail.com> Hi Le Dahut, I use the following code for prgrams built with py2exe: import sys import os print os.path.dirname(sys.executable) This may work in your situation as well. Regards, Andre http://www.burgaud.com/ On 10/21/05, le dahut wrote: > > In fact I build an SFX archive with winrar where I specify a program to > launch once extraction has ended. The program is launched but don't find > it's sub-directory. > If I go to the extracted archive directory an dlbe-clic on "install.exe" > all runs fine, but whit winrar's "Run after extraction" option it > doesn't. > > > Le vendredi 21 octobre 2005 ? 14:42 +0100, Tim Golden a ?crit : > > [le dahut] > > > > > I try to get the program's directory, the one where the .exe (or .py) > > is. > > > > >From within Python, sys.argv[0] usually gives you the running > > program (not sure what it does with py2exe etc.). So something > > like (untested): > > > > > > import os, sys > > > > print os.path.dirname (sys.argv[0]) > > > > > > > > > With os.getcwd() I get the directory from where the program is > > launched > > > not his directory. The program has to copy some files and thus I get > > an > > > error like "XXXXXX no such file or directory". > > > > Umm. It's not clear why you get "no such file / directory". Surely > > os.getcwd returns *some* real directory. Or is it that you don't > > have permissions to the directory? > > > > > (the DOS box closed to quickly to have the detailed > > > error msg...) where XXXXXX is a sub-directory of > > > the program's one. > > > > I'm assuming you're double-clicking on a Python icon to > > run the program. You might try, instead, running it from > > the command line: > > > > Start > Run > cmd.exe > > (DOS box opens) > > python x:\path\to\my\program.py > > > > This should let you see what's going on. > > > > TJG > > > > > > ________________________________________________________________________ > > This e-mail has been scanned for all viruses by Star. The > > service is powered by MessageLabs. For more information on a proactive > > anti-virus service working around the clock, around the globe, visit: > > http://www.star.net.uk > > ________________________________________________________________________ > > _______________________________________________ > > Python-win32 mailing list > > Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051021/c540175a/attachment.html From jhu at metrigenix.com Sat Oct 22 05:58:57 2005 From: jhu at metrigenix.com (James Hu) Date: Fri, 21 Oct 2005 23:58:57 -0400 Subject: [python-win32] findwindow by its class name Message-ID: <90DEA7ED93F71A4580CEDF76A02682EA04C286@torexch.metrigenix.com> Thanks, Actually, app A is a commercial engine, which written by VC++, but we can't change it at all. app B is our application, which written by wxPython, If we can't find a way to get the classname of app B, it's no way for app A to send the message to app B , for app A uses classname to get the handler of app B, not it's windows caption. RegisterWindowMessage can't do this job either. Can we register/bind a specific classname for any wxPython application? James ________________________________ From: Gabriel Genellina [mailto:gagenellina at softlab.com.ar] Sent: Fri 10/21/2005 8:18 PM To: James Hu Cc: python-win32 at python.org Subject: Re: [python-win32] findwindow by its class name At Friday 21/10/2005 16:26, you wrote: >Thanks a lot! Yes, GetHandle() can return 'wxWindowClassNR', which is >nice, >but all wxPython apps return wxWindowClassNR as well, so when I Post >Message, it goes to itself. Application A can broadcast a private known message (using RegisterWindowMessage) including its own HWND; Application B handles it and replies to A with its own HWND. After that, both apps know the other's HWND and can post messages. Gabriel Genellina Softlab SRL -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051021/1daec8da/attachment.html From mhammond at skippinet.com.au Sat Oct 22 06:50:20 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 22 Oct 2005 14:50:20 +1000 Subject: [python-win32] findwindow by its class name In-Reply-To: <90DEA7ED93F71A4580CEDF76A02682EA04C286@torexch.metrigenix.com> Message-ID: Re: [python-win32] findwindow by its class nameIf all else fails, you could create a win32gui based hidden window with a classname of your choice. pywin32's win32gui_taskbar.py does exactly this. You would probably need to create this window in its own thread running a win32gui message pump, so you would need to arrange a way to communicate with your main wx thread - but it should be able to be made to work. As for changing the wx classname, you would be better off asking a wx list. Cheers, Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of James Hu Sent: Saturday, 22 October 2005 1:59 PM To: Gabriel Genellina Cc: python-win32 at python.org Subject: Re: [python-win32] findwindow by its class name Thanks, Actually, app A is a commercial engine, which written by VC++, but we can't change it at all. app B is our application, which written by wxPython, If we can't find a way to get the classname of app B, it's no way for app A to send the message to app B , for app A uses classname to get the handler of app B, not it's windows caption. RegisterWindowMessage can't do this job either. Can we register/bind a specific classname for any wxPython application? James ---------------------------------------------------------------------------- -- From: Gabriel Genellina [mailto:gagenellina at softlab.com.ar] Sent: Fri 10/21/2005 8:18 PM To: James Hu Cc: python-win32 at python.org Subject: Re: [python-win32] findwindow by its class name At Friday 21/10/2005 16:26, you wrote: >Thanks a lot! Yes, GetHandle() can return 'wxWindowClassNR', which is >nice, >but all wxPython apps return wxWindowClassNR as well, so when I Post >Message, it goes to itself. Application A can broadcast a private known message (using RegisterWindowMessage) including its own HWND; Application B handles it and replies to A with its own HWND. After that, both apps know the other's HWND and can post messages. Gabriel Genellina Softlab SRL -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051022/d613ead5/attachment.html From amonroe at columbus.rr.com Sat Oct 22 14:51:42 2005 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Sat, 22 Oct 2005 08:51:42 -0400 Subject: [python-win32] create user message for wxPython In-Reply-To: <90DEA7ED93F71A4580CEDF76A02682EA03ACC7@torexch.metrigenix.com> References: <90DEA7ED93F71A4580CEDF76A02682EA03ACC7@torexch.metrigenix.com> Message-ID: <178264152200.20051022085142@columbus.rr.com> > Hi, Tim, > Your idea probably works as well, but I found another way to catch user > defined message. Thanks a lot! > For the handler of the second app, win32gui.FindWindow can do this job, > then win32gui.PostMessage. But for FindWindow, I can only find the > specific window by its title, not by its registered class, which I > posted another message. > Any idea? Google for a utility called "SanxSpy". It lets you examine all window information for any window you drag the mouse across. Alan From jhu at metrigenix.com Sat Oct 22 17:25:53 2005 From: jhu at metrigenix.com (James Hu) Date: Sat, 22 Oct 2005 11:25:53 -0400 Subject: [python-win32] create user message for wxPython Message-ID: <90DEA7ED93F71A4580CEDF76A02682EA04C287@torexch.metrigenix.com> Thanks, VC++ tool Spy++ can do this as well. ________________________________ From: python-win32-bounces at python.org on behalf of R. Alan Monroe Sent: Sat 10/22/2005 8:51 AM To: python-win32 at python.org Subject: Re: [python-win32] create user message for wxPython > Hi, Tim, > Your idea probably works as well, but I found another way to catch user > defined message. Thanks a lot! > For the handler of the second app, win32gui.FindWindow can do this job, > then win32gui.PostMessage. But for FindWindow, I can only find the > specific window by its title, not by its registered class, which I > posted another message. > Any idea? Google for a utility called "SanxSpy". It lets you examine all window information for any window you drag the mouse across. Alan _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051022/8098e275/attachment.html From geon at post.cz Sun Oct 23 18:21:51 2005 From: geon at post.cz (geon) Date: Sun, 23 Oct 2005 18:21:51 +0200 Subject: [python-win32] wdFormatText Message-ID: <435BB89F.3040406@post.cz> I try to convert *.doc to *.txt and in saving part of my script I receive following error. Can anyone help - I have tried all I know without any success. I could swear it worked at win98. Now i do not have chnage to run it there - I have w2000, office2000, py2.4 ------------------------------------------------------------- processing i:\?kola\Archiv\Archiv 8zs\Fyzika\F8 0-A.doc --> Traceback (most recent call last): File "I:\Python\my_py\J5804173.py", line 58, in ? wordapp.ActiveDocument.SaveAs(docastxt, FileFormat=win32com.client.constants.wdFormatText) File "C:\prg\Python24\Lib\site-packages\win32com\client\__init__.py", line 168, in __getattr__ raise AttributeError, a AttributeError: wdFormatText -------------------------------------------------------- my script: -------------------------------------------------------------------------- import fnmatch, os, win32com.client, time inDir=ur'i:\?kola\Archiv\Archiv 8zs\Fyzika' outDir=u'i:\\text\\' wordapp = win32com.client.Dispatch("Word.Application") if not os.path.isdir(outDir): os.makedirs(outDir) for path, dirs, files in os.walk(inDir): docFiles= [os.path.abspath(os.path.join(path, filename)) for filename in files \ if (fnmatch.fnmatch(filename, '*.doc') and not fnmatch.fnmatch(filename,'~*.doc'))] for doc in docFiles: print "processing %s -->" % doc, wordapp.Documents.Open(doc) soubor=os.path.basename(doc.rstrip('.doc').rstrip('.DOC')) docastxt = outDir+soubor + u'.text' wordapp.ActiveDocument.SaveAs(docastxt, FileFormat=win32com.client.constants.wdFormatText) wordapp.ActiveDocument.Close() print docastxt ----------------------------------------------------------------------- When I create macro in Word, I can see there this "wdFormatText" and even in some tutorial I saw in used in this way... Thanks a lot -- geon From mc at mclaveau.com Sun Oct 23 19:28:14 2005 From: mc at mclaveau.com (Michel Claveau) Date: Sun, 23 Oct 2005 19:28:14 +0200 Subject: [python-win32] wdFormatText References: <435BB89F.3040406@post.cz> Message-ID: <001c01c5d7f7$28ffe4c0$0701a8c0@PORTABLES> Hi ! >>> ...macro in Word, I can see there this "wdFormatText" and even in some >>> tutorial I saw in used in this way... You can to watch the class I had create, for "to tele-command" word, here: http://mclaveau.com/ress/python/pxword.htm (and look the "saveas" method) @-salutations Michel Claveau From geon at post.cz Sun Oct 23 20:24:08 2005 From: geon at post.cz (geon) Date: Sun, 23 Oct 2005 20:24:08 +0200 Subject: [python-win32] wdFormatText In-Reply-To: <001c01c5d7f7$28ffe4c0$0701a8c0@PORTABLES> References: <435BB89F.3040406@post.cz> <001c01c5d7f7$28ffe4c0$0701a8c0@PORTABLES> Message-ID: <435BD548.4000408@post.cz> Michel Claveau napsal(a): >You can to watch the class I had create, for "to tele-command" word, here: > http://mclaveau.com/ress/python/pxword.htm >(and look the "saveas" method) > > so easy and so much spent my time on it. Thanks a lot. Anyway I wonder if this could be found in MSDN documentation or in word macro itself....just for the next time I am in the same situation... -- geon From sjmachin at lexicon.net Sun Oct 23 22:38:35 2005 From: sjmachin at lexicon.net (John Machin) Date: Mon, 24 Oct 2005 06:38:35 +1000 Subject: [python-win32] wdFormatText In-Reply-To: <435BD548.4000408@post.cz> References: <435BB89F.3040406@post.cz> <001c01c5d7f7$28ffe4c0$0701a8c0@PORTABLES> <435BD548.4000408@post.cz> Message-ID: <435BF4CB.7090003@lexicon.net> geon wrote: >Michel Claveau napsal(a): > > > >>You can to watch the class I had create, for "to tele-command" word, here: >> http://mclaveau.com/ress/python/pxword.htm >>(and look the "saveas" method) >> >> >> >> >so easy and so much spent my time on it. Thanks a lot. Anyway I wonder >if this could be found in MSDN documentation or in word macro >itself....just for the next time I am in the same situation... > > > You are meant to use the names, not magic numbers. Have you run makepy? Have you ever heard of Google? google("wdFormatText") -> first hit is a clue about makepy, second hit tells you that the magic number is 2 google("wdFormatText Python") -> 3rd hit points to an Activestate Python Cookbook recipe ... which looks as though your code was derived fom it :-) Later on there's this: http://herlock.com/ob/pythoncb/0596007973/chp-2-sect-27.html By the way, you have u'text' in your code -- are you sure that you don't mean u'txt'? Cheers, John From mc at mclaveau.com Sun Oct 23 23:11:32 2005 From: mc at mclaveau.com (Michel Claveau) Date: Sun, 23 Oct 2005 23:11:32 +0200 Subject: [python-win32] wdFormatText References: <435BB89F.3040406@post.cz> <001c01c5d7f7$28ffe4c0$0701a8c0@PORTABLES><435BD548.4000408@post.cz> <435BF4CB.7090003@lexicon.net> Message-ID: <001c01c5d816$59bff680$0701a8c0@PORTABLES> Hi_release_2 ! >>> Anyway I wonder if this could be found in MSDN documentation or in word >>> macro itself....just for the next time I am in the same situation... First, for to find, I have make a word's macro, with : reponse = MsgBox(wdFormatText, vbOKOnly, "wdFormatText") Then, I had make a macro, for to list all constants : Sub Macro6() Dim i&, X As Object, Y As Object, R As Object, mbr As Object Set X = CreateObject("TLI.TLIApplication") Set Y = X.TypeLibInfoFromFile("C:\Program Files\Microsoft Office\Office10\Msword.olb") For Each R In Y.Constants For Each mbr In R.Members i = i + 1 Selection.TypeText Text:=mbr.Name Selection.TypeText Text:="=" Selection.TypeText Text:=mbr.Value Selection.TypeParagraph Next mbr Selection.TypeParagraph Next R Set Y = Nothing Set X = Nothing Set R = Nothing Set mbr = Nothing End Sub Result : 63 pages, for to list the constants ! But ("TLI.TLIApplication") is installed only by Visual-Studio (I don't have...) Then... I had found the good file (tlbinf32.dll) ont a DK site (URL: http://lambdasoft.dk) And then, I remembered MakePy (in PinWin). MakePy gives all information. Thanks, M. Hammond. Good luck ! And sorry for my *bad english* @-salutations -- Michel Claveau m?l : http://cerbermail.com/?6J1TthIa8B sites : http://mclaveau.com http://bergoiata.org http://ponx.org newsgroups (utilisateur: "zoo" passe: "entrer") : news://news.zoo-logique.org/programmation.Paradox news://news.zoo-logique.org/ponx news://news.zoo-logique.org/???`????a&?|~??@.?#' From sjmachin at lexicon.net Sun Oct 23 23:35:48 2005 From: sjmachin at lexicon.net (John Machin) Date: Mon, 24 Oct 2005 07:35:48 +1000 Subject: [python-win32] wdFormatText In-Reply-To: <001c01c5d816$59bff680$0701a8c0@PORTABLES> References: <435BB89F.3040406@post.cz> <001c01c5d7f7$28ffe4c0$0701a8c0@PORTABLES><435BD548.4000408@post.cz> <435BF4CB.7090003@lexicon.net> <001c01c5d816$59bff680$0701a8c0@PORTABLES> Message-ID: <435C0234.5000705@lexicon.net> Michel Claveau wrote: > Hi_release_2 ! > >>>> Anyway I wonder if this could be found in MSDN documentation or in >>>> word >>>> macro itself....just for the next time I am in the same situation... >>> > I don't know why you are sending this to me -- the above quote is from "geon", and as for the story about your ramble through the woods instead of RTFM/Google: confession may be good for your soul, but I am not your priest :-) > First, for to find, I have make a word's macro, with : > reponse = MsgBox(wdFormatText, vbOKOnly, "wdFormatText") > > > Then, I had make a macro, for to list all constants : > > Sub Macro6() [snip] > End Sub > > Result : 63 pages, for to list the constants ! > > But ("TLI.TLIApplication") is installed only by Visual-Studio (I don't > have...) > Then... I had found the good file (tlbinf32.dll) ont a DK site (URL: > http://lambdasoft.dk) > > > And then, I remembered MakePy (in PinWin). MakePy gives all information. > Thanks, M. Hammond. From geon at post.cz Mon Oct 24 08:22:01 2005 From: geon at post.cz (geon) Date: Mon, 24 Oct 2005 08:22:01 +0200 Subject: [python-win32] wdFormatText In-Reply-To: <435BF4CB.7090003@lexicon.net> References: <435BB89F.3040406@post.cz> <001c01c5d7f7$28ffe4c0$0701a8c0@PORTABLES> <435BD548.4000408@post.cz> <435BF4CB.7090003@lexicon.net> Message-ID: <435C7D89.9050906@post.cz> John Machin napsal(a): >Have you run makepy? > > > No, I didnt know about that before >Have you ever heard of Google? >google("wdFormatText") -> first hit is a clue about makepy, second hit >tells you that the magic number is 2 > > you must have another google... ;-) I didnt get any relevant generaly mentioned article about these constants and the problem. Michel Claveau helped me. And now I already know why it work before on w98 - I must did have run makepy - then my script with wordapp.ActiveDocument.SaveAs(docastxt, FileFormat=win32com.client.constants.wdFormatText) works fine, cause these constant are created in folder gen_py under "magic" names of files. When I want to run this script on another machines I must use rather number 2. Regards -- geon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051024/85be06b4/attachment.html From hpkotian at rbi.org.in Mon Oct 24 10:46:13 2005 From: hpkotian at rbi.org.in (Harish Kotian) Date: Mon, 24 Oct 2005 14:16:13 +0530 Subject: [python-win32] Any volunteers Message-ID: <00e701c5d877$63c8a990$3c0510ac@hydro.rbi.org.in> Hello folks I am a blind programmer. The problem I am having with python is that it is indendation sensitive. Would someone volunteer to write a code which will do indentation probably using regular expression. I would use for example endif or endwhile in my code and this should trigger the indentation. Conversely, a source python code should be substituted with these keywords which will make the code more readable to me. As this is the inherent part of the language, I can't expect any changes to take for my sake, However, A filter like this could take care of the problem. Harish -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051024/2062c9bc/attachment.html From renata.marin at gmail.com Mon Oct 24 11:16:14 2005 From: renata.marin at gmail.com (Renata Marin) Date: Mon, 24 Oct 2005 10:16:14 +0100 Subject: [python-win32] thumbnails Message-ID: <68d369590510240216v3519f386u@mail.gmail.com> Hello, I want to find out if a MSOffice document has or not a thumbnail (preview save picture). If yes I would like to save this thumbnail in a .jpeg file, if no, i want to save a temporary preview picture of this document and obtain the thumbnail in a .jpeg file. Unfortunately this doesn't work. When I do: > def PrintStats(filename): > if not pythoncom.StgIsStorageFile(filename): > print "The file is not a storage file!" > return > # Open the file. > flags = storagecon.STGM_READ | storagecon.STGM_SHARE_EXCLUSIVE > stg = pythoncom.StgOpenStorage(filename, None, flags ) > > # Now see if the storage object supports Property Information. > try: > pss = stg.QueryInterface(pythoncom.IID_IPropertySetStorage) > except pythoncom.com_error: > print "No summary information is available" > return > # Open the user defined properties. > ps = pss.Open(FMTID_UserDefinedProperties) > props = PIDSI_TITLE, PIDSI_SUBJECT, PIDSI_AUTHOR, PIDSI_CREATE_DTM, > PIDSI_THUMBNAIL > data = ps.ReadMultiple( props ) > # Unpack the result into the items. > title, subject, author, created, thumbnail = data > print "Title:", title > print "Subject:", subject > print "Author:", author > print "Created:", created.Format() > print "Thumbnail:", thumbnail If the thumbnail doesn't exists, it returns None, if It exists, it returns me : data = ps.ReadMultiple( props ) > TypeError: Unsupported property type > Please, somebody can help me? thanks Rena -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051024/c872c0a2/attachment.html From niki at vintech.bg Mon Oct 24 13:34:44 2005 From: niki at vintech.bg (Niki Spahiev) Date: Mon, 24 Oct 2005 14:34:44 +0300 Subject: [python-win32] Any volunteers In-Reply-To: <00e701c5d877$63c8a990$3c0510ac@hydro.rbi.org.in> References: <00e701c5d877$63c8a990$3c0510ac@hydro.rbi.org.in> Message-ID: <435CC6D4.6020504@vintech.bg> Harish Kotian wrote: > > Hello folks > I am a blind programmer. The problem I am having with python is that it > is indendation sensitive. > Would someone volunteer to write a code which will do indentation > probably using regular expression. check Tools/scripts/pindent.py in your python installation. HTH Niki Spahiev From shad.muegge at gmail.com Mon Oct 24 22:40:05 2005 From: shad.muegge at gmail.com (Shad Muegge) Date: Mon, 24 Oct 2005 13:40:05 -0700 Subject: [python-win32] win32com calling C++ COM interface In-Reply-To: <6.1.2.0.0.20051019133500.0350bee8@mail.mric.net> References: <6.1.2.0.0.20051019133500.0350bee8@mail.mric.net> Message-ID: With a lot of help from Mark Hammond we discovered the problems 1) the parameter type in the COM definition .py file was incorrect 2) the code shouldn't have been converting the parameter to a buffer object The type of "indexlist" in the COM definition .py file. def Read(self, x=defaultNamedNotOptArg, indexlist=defaultNamedNotOptArg, results=pythoncom.Missing): """method Read""" return self._ApplyTypes_(2, 1, (24, 0), ((3, 1), (16396, 1), (16396, 2)),'Read', None,x, indexlist, results) 16396 - VT_VARIANT, VT_BYREF which matches exactly the type in the IDL file ...VARIANT* indexlist,... so makepy worked as expected. The problem is that the interface expected a single variant containing a safearray of integers, so a more proper IDL file might look like this ...SAFEARRAY(int) indexlist,... I update the .py file with the correct type. (0x2000 | 19) - VT_ARRAY, VT_IU4 Also, the python code was converting the parameter to a buffer object addr = buffer(array.array ('L', addr)) // bad which wasn't correct because this is a special case for the win32com code. All buffer objects are converted to safe arrays of bytes. I removed that line and code. After these two changes the code worked. On 10/19/05, bob wrote: > > At 01:22 PM 10/19/2005, Shad Muegge wrote: > >Hi, > > > >I've just started looking at Python. I am trying to resolve an issue a > >user is having trying to access the COM interface in our application from > > >Python. > > > >C++ code: > > > >STDMETHODIMP > >CMyClass::Read( > > const int x, > > VARIANT *indexlist, // IN: "safe" array of 4-byte integers > > VARIANT *results) > > > > > >Python code: > > > > def read(self, x, addr): > > try: > > addr = buffer(array.array ('L', addr)) > > data = self.__Api.Read(x, addr) > >... > > > >x.read(0, 0x12345678) > > > >The variant that shows up on the C++ code is a safearray of 1-byte > >integers with 4 elements: 12, 34, 56, 78. > > > >The API treats them each as individual "addresses"... > > > >Here's the COM definition from the .py file. > > > > def Read(self, x=defaultNamedNotOptArg, indexlist=defaultNamedNotOptArg, > > > results=pythoncom.Missing): > > """method Read""" > > return self._ApplyTypes_(2, 1, (24, 0), ((3, 1), (16396, 1), (16396, > > 2)), 'Read', None,x > > , indexlist, results) > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051024/e8886533/attachment.htm From mhammond at skippinet.com.au Tue Oct 25 03:18:43 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 25 Oct 2005 11:18:43 +1000 Subject: [python-win32] thumbnails In-Reply-To: <68d369590510240216v3519f386u@mail.gmail.com> Message-ID: There are a couple of types unsupported by the property storage code. I did try adding support, but the VT_CF structure is very poorly documented by MS. After following the best instructions I could find, I did appear to get data in CF_METAFILEPICT format, but I was unable to make SetClipboardData work with the data. I could send you the mods I made (let me know what Python version) to get this raw data, but you would need to understand the METAFILEPICT structure to make heads or tails of it. Let me know if this is something would like. Sadly these mods just missed build 205. Cheers, Mark. -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Renata Marin Sent: Monday, 24 October 2005 7:16 PM To: Python-win32 at python.org Subject: [python-win32] thumbnails Hello, I want to find out if a MSOffice document has or not a thumbnail (preview save picture). If yes I would like to save this thumbnail in a .jpeg file, if no, i want to save a temporary preview picture of this document and obtain the thumbnail in a .jpeg file. Unfortunately this doesn't work. When I do: def PrintStats(filename): if not pythoncom.StgIsStorageFile(filename): print "The file is not a storage file!" return # Open the file. flags = storagecon.STGM_READ | storagecon.STGM_SHARE_EXCLUSIVE stg = pythoncom.StgOpenStorage(filename, None, flags ) # Now see if the storage object supports Property Information. try: pss = stg.QueryInterface(pythoncom.IID_IPropertySetStorage) except pythoncom.com_error: print "No summary information is available" return # Open the user defined properties. ps = pss.Open(FMTID_UserDefinedProperties) props = PIDSI_TITLE, PIDSI_SUBJECT, PIDSI_AUTHOR, PIDSI_CREATE_DTM, PIDSI_THUMBNAIL data = ps.ReadMultiple( props ) # Unpack the result into the items. title, subject, author, created, thumbnail = data print "Title:", title print "Subject:", subject print "Author:", author print "Created:", created.Format () print "Thumbnail:", thumbnail If the thumbnail doesn't exists, it returns None, if It exists, it returns me : data = ps.ReadMultiple( props ) TypeError: Unsupported property type Please, somebody can help me? thanks Rena From mhammond at skippinet.com.au Tue Oct 25 03:20:38 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 25 Oct 2005 11:20:38 +1000 Subject: [python-win32] pywin32 build 205 just released. Message-ID: Hi all, I've just released build 205 of the pywin32 extensions - you can find it via: http://sourceforge.net/projects/pywin32 or directly via: http://sourceforge.net/project/showfiles.php?group_id=78018&package_id=79063 &release_id=365777 In summary, this release is mainly bug fixes, but a few new modules (win32crypt, win32console), support for the decimal module when using COM 'currency' variants and a few other ehancements exist. Please see the release notes for details. A few things have conspired towards making these releases slower than I like, but I hope to turn them around faster in the future. Cheers, Mark. From jhu at metrigenix.com Wed Oct 26 20:10:07 2005 From: jhu at metrigenix.com (James Hu) Date: Wed, 26 Oct 2005 14:10:07 -0400 Subject: [python-win32] simulate DoEvents by python/wxpython Message-ID: <90DEA7ED93F71A4580CEDF76A02682EA03ACD2@torexch.metrigenix.com> Hi, all gurus, I need to simulate DoEvents in VB by python/wxPython, My application needs to capture live image in a loop until one specific button pressed Multi-thread is also not very good solution, for there are big number of data to exchange between the two threads. Win32gui doesn't have PeekMessage. Or translate the folllowinf codes to python? DoEvents() { MSG msg; while ( ::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) { if ( !PumpMessage( ) ) { ::PostQuitMessage( 1 ); return FALSE; } } // let MFC do its idle processing LONG lIdle = 0; while ( OnIdle(lIdle++ ) ) ; return TRUE; } } Thanks in advance, James -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051026/9dd9483c/attachment.html From mhammond at skippinet.com.au Thu Oct 27 01:15:49 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 27 Oct 2005 09:15:49 +1000 Subject: [python-win32] simulate DoEvents by python/wxpython In-Reply-To: <90DEA7ED93F71A4580CEDF76A02682EA03ACD2@torexch.metrigenix.com> Message-ID: Build 205 of win32gui does have PeekMessage etc so you can now write the message loop in Python should the need arise - however, the various "PumpMessages" and "PumpWaitingMessages" functions do the same thing, but are implemented in C. There are versions of these functions in win32gui and win32ui. win32ui is the MFC wrapper, and its version does do it the "MFC way", as opposed to the vanilla Windows way that win32gui exposes. Your code below looks like it is MFC based, so the win32ui versions may work better for you (eg, work correctly with the MFC idle processing). If you do truly only need VB DoEvents style processing (which is not MFC aware), win32gui.Pump(Waiting)Messages should be fine though. Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of James Hu Sent: Thursday, 27 October 2005 4:10 AM To: Python-win32 at python.org; python-list at python.org Subject: [python-win32] simulate DoEvents by python/wxpython Hi, all gurus, I need to simulate DoEvents in VB by python/wxPython, My application needs to capture live image in a loop until one specific button pressed Multi-thread is also not very good solution, for there are big number of data to exchange between the two threads. Win32gui doesn't have PeekMessage. Or translate the folllowinf codes to python? DoEvents() { MSG msg; while ( ::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) { if ( !PumpMessage( ) ) { ::PostQuitMessage( 1 ); return FALSE; } } // let MFC do its idle processing LONG lIdle = 0; while ( OnIdle(lIdle++ ) ) ; return TRUE; } } Thanks in advance, James From mc at mclaveau.com Thu Oct 27 14:08:18 2005 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 27 Oct 2005 14:08:18 +0200 Subject: [python-win32] Installer Pywin dans open-Office 2.0 ? References: Message-ID: <000c01c5daef$226a7c10$4d01a8c0@PORTABLES> Hi! OpenOffice.org_2.0 is arrived (also in french). OO_2 has Python like macro's language. But OO_2 use his embbed Python (release 2.3.4). I had downloaded a release of PyWin for Python2.3. And... How install it ? I use Python 2.4.2, and the package for P_2.3 don't found Python 2.3... Thanks by advance Michel Claveau From alexj at businessabstraction.com Thu Oct 27 14:11:36 2005 From: alexj at businessabstraction.com (Alex Jouravlev) Date: Thu, 27 Oct 2005 22:11:36 +1000 Subject: [python-win32] Possible bug: what information to provide In-Reply-To: Message-ID: Hi Mark, Python interface only invokes method without attributes, when called without brackets: i.e: "ref.Update()" does not work, while "ref.Update" does invoke correct _method_ The code is not using Makepy, initial object reference gained via client.Dispatch('name') . I don't think that is win32py problem, and I don't have resources to zero on the bug, but possibly you know what can cause this behaviour ? Thank you, Alex > -----Original Message----- > From: Mark Hammond [mailto:mhammond at skippinet.com.au] > Sent: Thursday, October 13, 2005 2:01 PM > To: Alex Jouravlev; python-win32 at python.org > Subject: RE: [python-win32] Possible bug: what information to provide > > > > > > One more strange thing: > > > > MakePy recognised the object as "IRepository" rather then > "Repository" > > > > > > I'm not sure what you mean here. Please post a complete code sample, > > > including all output that confuses you or you believe to be wrong. > > > > > Makepy.py output (fragment, for information about the Object) > > ----------------------------------------------- > > class IRepository(DispatchBaseClass): > > Right - that is normal. It is indeed the interface that has the method - > the "coclass" described in the file probably has a reference to that > interface - a coclass may implement many interfaces. > > > > The code above is not using makepy, even though it may have > > > been run. You > > > could try creating the object using > > > win32com.client.gencache.EnsureDispatch > > > > I tried, here is the result: > > ----------------------------------- > > >>> rep = win32com.client.gencache.EnsureDispatch('EA.Repository') > > Traceback (most recent call last): > > File "", line 1, in ? > > File "C:\Python24\Lib\site-packages\win32com\client\gencache.py", line > > 543, in EnsureDispatch > > raise TypeError, "This COM object can not automate the makepy > > process - > > please run makepy manually for this object" > > TypeError: This COM object can not automate the makepy process - > > please run > > makepy manually for this object > > Sadly, this object is not providing its typeinfo at runtime. If > you can get > in touch with the developers, ask them to consider adding this IDispatch > typeinfo support - they already have the typeinfo available from their > typelib, so it should be quite easy to do. > > In the meantime, you need to explicitly "cast" your objects into these > makepy objects. You should start by running "makepy.py -i" (from a > command-prompt). Here is what I get when I pick some random lib: > > IAS Helper COM Component 1.0 Type Library > {6BC096BB-0CE6-11D1-BAAE-00C04FC2E20D}, lcid=0, major=1, minor=0 > >>> # Use these commands in Python code to auto generate .py support > >>> from win32com.client import gencache > >>> gencache.EnsureModule('{6BC096BB-0CE6-11D1-BAAE-00C04FC2E20D}', 0, 1, > 0) > > You should add these lines to your code - but with one change: > > > from win32com.client import gencache > > mod = gencache.EnsureModule('{6BC096BB-0CE6-11D1-BAAE-00C04FC2E20D}', 0, > 1, 0) > > Note the last line - 'mod ='. This will be the makepy module, as imported > from the gen_py directory. You can then write: > > rep = win32com.client.Dispatch('EA.Repository') > # Now 'cast' it to an IRepository object. > rep = mod.IRepository(rep) > > print repr(rep) # Should now print a repr that indicates it is a makepy > object. > > You will need to this whenever you get a "new" object. Eg, let's > say there > was a "GetApplication()" method on a repository. > > app = rep.GetApplication() > print repr(app) # will probably say "" - not what > you want. > app = mod.IApplication(app) # Cast to a mythical IApplication object. > print repr(app) # should show the makepy object. > > Hope that makes sense, > > Mark > > From mhammond at skippinet.com.au Thu Oct 27 14:30:21 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 27 Oct 2005 22:30:21 +1000 Subject: [python-win32] Possible bug: what information to provide In-Reply-To: Message-ID: > Python interface only invokes method without attributes, when > called without > brackets: > > i.e: "ref.Update()" does not work, while "ref.Update" does invoke correct > _method_ > > The code is not using Makepy, The problem is that the object is being asked to invoke a *property* named Foo, but is treating it as a method call. Python is more sensitive to this than VB. The solution is generally to use makepy, but using it via win32com.client.gencache.EnsureDispatch() is generally more convenient, in that it doesn't require any manual steps. Hope this helps, Mark. From jhu at metrigenix.com Thu Oct 27 15:32:34 2005 From: jhu at metrigenix.com (James Hu) Date: Thu, 27 Oct 2005 09:32:34 -0400 Subject: [python-win32] simulate DoEvents by python/wxpython Message-ID: <90DEA7ED93F71A4580CEDF76A02682EA03ACD5@torexch.metrigenix.com> Thanks a lot! -----Original Message----- From: Mark Hammond [mailto:mhammond at skippinet.com.au] Sent: Wednesday, October 26, 2005 7:16 PM To: James Hu; Python-win32 at python.org; python-list at python.org Subject: RE: [python-win32] simulate DoEvents by python/wxpython Build 205 of win32gui does have PeekMessage etc so you can now write the message loop in Python should the need arise - however, the various "PumpMessages" and "PumpWaitingMessages" functions do the same thing, but are implemented in C. There are versions of these functions in win32gui and win32ui. win32ui is the MFC wrapper, and its version does do it the "MFC way", as opposed to the vanilla Windows way that win32gui exposes. Your code below looks like it is MFC based, so the win32ui versions may work better for you (eg, work correctly with the MFC idle processing). If you do truly only need VB DoEvents style processing (which is not MFC aware), win32gui.Pump(Waiting)Messages should be fine though. Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of James Hu Sent: Thursday, 27 October 2005 4:10 AM To: Python-win32 at python.org; python-list at python.org Subject: [python-win32] simulate DoEvents by python/wxpython Hi, all gurus, I need to simulate DoEvents in VB by python/wxPython, My application needs to capture live image in a loop until one specific button pressed Multi-thread is also not very good solution, for there are big number of data to exchange between the two threads. Win32gui doesn't have PeekMessage. Or translate the folllowinf codes to python? DoEvents() { MSG msg; while ( ::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) { if ( !PumpMessage( ) ) { ::PostQuitMessage( 1 ); return FALSE; } } // let MFC do its idle processing LONG lIdle = 0; while ( OnIdle(lIdle++ ) ) ; return TRUE; } } Thanks in advance, James From christianjunker at gmail.com Thu Oct 27 18:58:10 2005 From: christianjunker at gmail.com (Christian Junker) Date: Thu, 27 Oct 2005 18:58:10 +0200 Subject: [python-win32] Spawning processes with os module Message-ID: <1953811f0510270958t132c3df0v@mail.gmail.com> Hi people, I am having difficulty spawning processes with the os.P_NOWAIT and the waitpid function in the os module. What I simply want to do is to launch another process along with immediately getting its exit status in a cross-platform supported way. However the exit status is actually shifted 8 bits left on Win32 and when manually shifting it back, I always get 1 as the exit status although the process has obviously been started successfully. As we do not wish to use extra packages and modules, we need to have some way to do this very common task *without* win32all package - which as I know would have functions for properly launching processes on Windows - and just with the Python Standard library. Anyone with experiences on this field? I can't believe that there is no cookbook code snippet for this very commonly found task and that Python seems to lack crossplatform-power at this point. -- Best Regards Christian Junker From timr at probo.com Thu Oct 27 19:48:47 2005 From: timr at probo.com (Tim Roberts) Date: Thu, 27 Oct 2005 10:48:47 -0700 Subject: [python-win32] simulate DoEvents by python/wxpython In-Reply-To: References: Message-ID: <436112FF.2060107@probo.com> On Wed, 26 Oct 2005 14:10:07 -0400, "James Hu" wrote: >I need to simulate DoEvents in VB by python/wxPython, > >My application needs to capture live image in a loop until one specific >button pressed > >Multi-thread is also not very good solution, for there are big number of >data to exchange between the two threads. > > Threads all share the same address space. There is no need to "exchange" data at all. A separate thread is almost certainly the right way to do what you ask. You can use Python Queues to send messages between the threads, to signal when an image is available, or to signal that a worker thread should exit. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From p.f.moore at gmail.com Thu Oct 27 20:33:37 2005 From: p.f.moore at gmail.com (Paul Moore) Date: Thu, 27 Oct 2005 19:33:37 +0100 Subject: [python-win32] Spawning processes with os module In-Reply-To: <1953811f0510270958t132c3df0v@mail.gmail.com> References: <1953811f0510270958t132c3df0v@mail.gmail.com> Message-ID: <79990c6b0510271133l4da1467dodc54d5ee56d41d42@mail.gmail.com> On 10/27/05, Christian Junker wrote: > I am having difficulty spawning processes with the os.P_NOWAIT and the > waitpid function in the os module. What I simply want to do is to > launch another process along with immediately getting its exit status > in a cross-platform supported way. However the exit status is actually > shifted 8 bits left on Win32 and when manually shifting it back, I > always get 1 as the exit status although the process has obviously > been started successfully. I'm a bit confused. You say you are using P_NOWAIT, and yet you want the exit status "immediately"? os.spawnXX with P_NOWAIT returns a process ID. This can be used in os.waitpid to get the exit status, shifted left 8 bits, once the process does exit. But if you're just doing pid = os.spawnXX(...P_NOWAIT) pid, status = os.waitpid(pid) status = status >> 8 you may as well have used P_WAIT in the first place... Maybe if you posted some example code showing what you are trying to do, it may make your problem clearer. Paul. From jhu at metrigenix.com Thu Oct 27 21:39:53 2005 From: jhu at metrigenix.com (James Hu) Date: Thu, 27 Oct 2005 15:39:53 -0400 Subject: [python-win32] simulate DoEvents by python/wxpython Message-ID: <90DEA7ED93F71A4580CEDF76A02682EA03ACD7@torexch.metrigenix.com> Thanks, say there are two threads, one is wxGUI, another is camera, which will send lots of data (1280X1280) to wxGUI, or notify wxGUI by event to retrieve it after a frame of image is ready. If synchronized well, this approach should work as well. James -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Roberts Sent: Thursday, October 27, 2005 1:49 PM To: python-win32 at python.org Subject: Re: [python-win32] simulate DoEvents by python/wxpython On Wed, 26 Oct 2005 14:10:07 -0400, "James Hu" wrote: >I need to simulate DoEvents in VB by python/wxPython, > >My application needs to capture live image in a loop until one specific >button pressed > >Multi-thread is also not very good solution, for there are big number of >data to exchange between the two threads. > > Threads all share the same address space. There is no need to "exchange" data at all. A separate thread is almost certainly the right way to do what you ask. You can use Python Queues to send messages between the threads, to signal when an image is available, or to signal that a worker thread should exit. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From justinjohnson at gmail.com Thu Oct 27 23:42:53 2005 From: justinjohnson at gmail.com (Justin Johnson) Date: Thu, 27 Oct 2005 16:42:53 -0500 Subject: [python-win32] Getting pywin32 build number Message-ID: <94a776e70510271442y60a05b5bt8778d33898282524@mail.gmail.com> Is the build number for pywin32 (win32all) available anywhere other than pywin32.version.txt sitting in site-packages? I want to raise an exception if the wrong version is installed. I can read this file if needed, but it seems like there should already be a variable or function for getting this. Thanks, Justin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051027/a48b28a7/attachment.htm From christianjunker at gmail.com Fri Oct 28 00:18:38 2005 From: christianjunker at gmail.com (Christian Junker) Date: Fri, 28 Oct 2005 00:18:38 +0200 Subject: [python-win32] Spawning processes with os module In-Reply-To: <43614A95.3040100@lexicon.net> References: <1953811f0510270958t132c3df0v@mail.gmail.com> <43614A95.3040100@lexicon.net> Message-ID: <1953811f0510271518k7fb4baceh@mail.gmail.com> Hi John, 2005/10/27, John Machin : > Would it be possible for us to behold the code that you are using? sure: p = os.spawnv(os.P_NOWAIT, sOffice, cmdArray) exit_status = os.waitpid(p, os.WNOHANG)[1] if exit_status != 0: raise BootstrapException("Could not start %s." % (sOffice,), None) That was the initial code, but as Win32 does not support os.WNOHANG this will not work out for the Microsoft platform. Furtheron it did not do the shifting, we have changed this to have some conditionals to test for windows and if that's the case, call os.waitpid(p, 0). On *ix, if the process does not terminate immediately after its start, we get 0 as the exit status, on Win32 with no flag at all, we get a number that resolves to 1 when shifted 8 bits to the right. I hope that my post gets clear now, we just want to check if the process still runs which we cannot really dertemine as it looks like on Win32. -- Best Regards Christian Junker From mhammond at skippinet.com.au Fri Oct 28 01:16:07 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 28 Oct 2005 09:16:07 +1000 Subject: [python-win32] Getting pywin32 build number In-Reply-To: <94a776e70510271442y60a05b5bt8778d33898282524@mail.gmail.com> Message-ID: Nope, that's it - or you could use win32apiGetFileVersionInfo to check a specific DLL/.pyd. Mark. -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Justin Johnson Sent: Friday, 28 October 2005 7:43 AM To: python-win32 at python.org Subject: [python-win32] Getting pywin32 build number Is the build number for pywin32 (win32all) available anywhere other than pywin32.version.txt sitting in site-packages? I want to raise an exception if the wrong version is installed. I can read this file if needed, but it seems like there should already be a variable or function for getting this. Thanks, Justin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051028/c87e7a16/attachment.htm From justinjohnson at gmail.com Fri Oct 28 17:29:21 2005 From: justinjohnson at gmail.com (Justin Johnson) Date: Fri, 28 Oct 2005 10:29:21 -0500 Subject: [python-win32] Getting pywin32 build number In-Reply-To: References: <94a776e70510271442y60a05b5bt8778d33898282524@mail.gmail.com> Message-ID: <94a776e70510280829q1c7550a3wf78cac4121fb04d8@mail.gmail.com> Would you be opposed to introducing a variable with the version number so it can be accessed more conveniently? On 10/27/05, Mark Hammond wrote: > > ? Nope, that's it - or you could use win32apiGetFileVersionInfo to check a > specific DLL/.pyd. > Mark. > > -----Original Message----- > *From:* python-win32-bounces at python.org [mailto: > python-win32-bounces at python.org]*On Behalf Of *Justin Johnson > *Sent:* Friday, 28 October 2005 7:43 AM > *To:* python-win32 at python.org > *Subject:* [python-win32] Getting pywin32 build number > > Is the build number for pywin32 (win32all) available anywhere other than > pywin32.version.txt sitting in site-packages? I want to raise an exception > if the wrong version is installed. I can read this file if needed, but it > seems like there should already be a variable or function for getting this. > Thanks, > Justin > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051028/8422a3aa/attachment.htm From jhu at metrigenix.com Fri Oct 28 22:05:11 2005 From: jhu at metrigenix.com (James Hu) Date: Fri, 28 Oct 2005 16:05:11 -0400 Subject: [python-win32] drag/move image from staticBitmap control? Message-ID: <90DEA7ED93F71A4580CEDF76A02682EA03ACDA@torexch.metrigenix.com> Hi, all gurus, I have an application to show bitmap image on one wx.staticBitmap control area, I can display part of the image, or the whole image(detail is unclear), But I would like to use mouse to drag/move the image inside thewx.staticBitmap control when only part image on the screen, just like maps.google does, is it possible to do that? Any sample code or any idea or suggestion are appreciated! Have a nice weekend! James -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20051028/eb340ed2/attachment.htm From gagenellina at softlab.com.ar Sat Oct 29 03:22:36 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Fri, 28 Oct 2005 22:22:36 -0300 Subject: [python-win32] drag/move image from staticBitmap control? In-Reply-To: <90DEA7ED93F71A4580CEDF76A02682EA03ACDA@torexch.metrigenix. com> References: <90DEA7ED93F71A4580CEDF76A02682EA03ACDA@torexch.metrigenix.com> Message-ID: <6.2.1.2.0.20051028222126.03a05010@192.168.0.115> At Friday 28/10/2005 17:05, James Hu wrote: >I have an application to show bitmap image on one wx.staticBitmap control >area, I can display part of the image, or the whole image(detail is unclear), >But I would like to use mouse to drag/move the image inside >thewx.staticBitmap control when only part image on the screen, just like >maps.google does, >is it possible to do that? A better place to ask would be the wxPython list Gabriel Genellina Softlab SRL