From tony at tcapp.com Mon Jan 3 23:47:11 2005 From: tony at tcapp.com (Tony Cappellini) Date: Mon Jan 3 23:29:42 2005 Subject: [python-win32] Executing a program on a remote machine Message-ID: <20050103143545.K8165@yamato.yamato.com> I've got three systems, each of which has a GPIB interface card inside. The GPIB connectors on the 3 cards are all daisy chained together, and connected to some test equipment. These 3 computers will be referred to as system 1,2, or 3. The problem with GPIB is only one of these cards can be the "system controller" at any one time, therefore two of the machines need to have that system controller bit turned off. I've written a Python app which will do that. However, I have to use a KVM swithc to get to each machine to turn that bit on or off. Too much work, when Python can do it for me. What I would like to do is use WMI or some other means to execute a program from one system (ie system #1) which will remotely execute the same program on the other two systems (2 and 3), through an ethernet connection. To clarify, each system will physically contain it's own copy of the program to be executed. These 3 systmes are My are alredy logged in, so authentication is NOT an issue. Each system has a unique name, so whenever the program is launched on the remote systems, it will know which system it is running on, and enable or disable the other systems approppriately. I just need to know how to exeucte a python app on the other two systems, via a remote connection. One system is running W98, one is running Win 2000, the other is running XP, SP1. If the remote stuff doesn't work on W98, that's ok, I can use this mechanism on Win2k and Xp. thanks From mhammond at skippinet.com.au Tue Jan 4 02:18:02 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Jan 4 02:18:22 2005 Subject: [python-win32] Executing a program on a remote machine In-Reply-To: <20050103143545.K8165@yamato.yamato.com> Message-ID: <5a3101c4f1fb$3e3a7400$0300a8c0@enfoldsystems.local> > What I would like to do is use WMI or some other means to execute a > program from one system (ie system #1) which will remotely execute the > same program on the other two systems (2 and 3), through an ethernet > connection. To clarify, each system will physically contain > it's own copy > of the program to be executed. One technique would be to use DCOM. You would register a Python COM object on each machine, then you could use win32com.client.DispatchEx() to invoke and call it. IIRC, the objects being registered will require a custom clsctx which includes pythoncom.CLSCTX_REMOTE_SERVER. "Python Programming on Win32" demonstrates how to do all this. Another fairly reliable technique would be to install a service on each machine, and use XMLRPC or some such to communicate. This service could then spawn child processes as each request came in, and would not rely on having a user logged in. Python provides most of the building blocks you need if you are happy to roll your own. Mark From Richard.Martin at thomson.net Tue Jan 4 02:23:56 2005 From: Richard.Martin at thomson.net (Martin Richard) Date: Tue Jan 4 02:24:03 2005 Subject: [python-win32] Executing a program on a remote machine Message-ID: <3531F1FE12C5B4489D2014F59B46691301D34E91@bvtnsmail01.am.thmulti.com> It seems just using 'rsh' should work. Rick -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org] On Behalf Of Mark Hammond Sent: Monday, January 03, 2005 5:18 PM To: 'Tony Cappellini'; python-win32@python.org Subject: RE: [python-win32] Executing a program on a remote machine > What I would like to do is use WMI or some other means to execute a > program from one system (ie system #1) which will remotely execute the > same program on the other two systems (2 and 3), through an ethernet > connection. To clarify, each system will physically contain it's own > copy of the program to be executed. One technique would be to use DCOM. You would register a Python COM object on each machine, then you could use win32com.client.DispatchEx() to invoke and call it. IIRC, the objects being registered will require a custom clsctx which includes pythoncom.CLSCTX_REMOTE_SERVER. "Python Programming on Win32" demonstrates how to do all this. Another fairly reliable technique would be to install a service on each machine, and use XMLRPC or some such to communicate. This service could then spawn child processes as each request came in, and would not rely on having a user logged in. Python provides most of the building blocks you need if you are happy to roll your own. Mark _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From lcatalin at siadv.com Wed Jan 5 10:28:22 2005 From: lcatalin at siadv.com (Catalin Lungu) Date: Wed Jan 5 10:28:29 2005 Subject: [python-win32] Image capture Message-ID: <001301c4f308$e71f4290$d900a8c0@catalin> Hi, Can anybody help me to implement the following VB code in Python. Thanks in advance. Private Declare Function SendMessage Lib "user32.dll" Alias _ "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, ByVal lParam As Long) As Long Private Const WM_PAINT = &HF Private Const WM_PRINT = &H317 Private Const PRF_CLIENT = &H4& Private Const PRF_CHILDREN = &H10& Private Const PRF_OWNED = &H20& Private Sub Command1_Click() SendMessage grid.hwnd, WM_PAINT, picture.hDC, 0 SendMessage grid.hwnd, WM_PRINT, picture.hDC, PRF_CHILDREN Or PRF_CLIENT Or PRF_OWNED picture.Picture = picture.Image picture.Refresh End Sub Catalin lcatalin@siadv.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050105/0ee1a2b5/attachment.htm From jens.jorgensen at tallan.com Wed Jan 5 16:36:05 2005 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Wed Jan 5 16:36:14 2005 Subject: [python-win32] Image capture In-Reply-To: <001301c4f308$e71f4290$d900a8c0@catalin> References: <001301c4f308$e71f4290$d900a8c0@catalin> Message-ID: <41DC0965.4000007@tallan.com> A little RTFM would go a long way here. The win32 extensions tend to translate the win32 api fairly directly into python. The SendMessage function can be found in the win32api module. Most constants are found in the win32con module. So, your python code should look something like: import win32api, win32con # assign grid_hwnd and picture_hdc somehow win32api.SendMessage(grid_hwnd, win32con.WM_PAINT, picture_hdc, 0) win32api.SendMessage(grid_hwnd, win32con.WM_PRINT, picture_hdc, win32con.PRF_CHILDREN | win32con.PRF_CLIENT | win32con.PRF_OWNED) That takes care of the SendMessage bits. However, your picture is clearly some kind of object (and not one I can seem to find from a casual perusal of the msdn) so I can't account for that in Python. Catalin Lungu wrote: > Hi, > > Can anybody help me to implement the following VB code in Python. > Thanks in advance. > > Private Declare Function SendMessage Lib "user32.dll" Alias _ > "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _ > ByVal wParam As Long, ByVal lParam As Long) As Long > > Private Const WM_PAINT = &HF > Private Const WM_PRINT = &H317 > Private Const PRF_CLIENT = &H4& > Private Const PRF_CHILDREN = &H10& > Private Const PRF_OWNED = &H20& > > Private Sub Command1_Click() > SendMessage grid.hwnd, WM_PAINT, picture.hDC, 0 > SendMessage grid.hwnd, WM_PRINT, picture.hDC, PRF_CHILDREN Or > PRF_CLIENT > Or PRF_OWNED > picture.Picture = picture.Image > picture.Refresh > End Sub > > Catalin > lcatalin@siadv.com > >------------------------------------------------------------------------ > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From timr at probo.com Wed Jan 5 18:36:04 2005 From: timr at probo.com (Tim Roberts) Date: Wed Jan 5 18:36:04 2005 Subject: [python-win32] Image capture In-Reply-To: <20050105110045.C41181E4009@bag.python.org> References: <20050105110045.C41181E4009@bag.python.org> Message-ID: <41DC2584.8030308@probo.com> On Wed, 5 Jan 2005 10:28:22 +0100, "Catalin Lungu" wrote: >Can anybody help me to implement the following VB code in Python. Thanks in advance. > > Do you have the rest of the application converted? This is just one small part of a GUI-based application. This one subroutine is responding to a button press, and in response is asking a grid control to refresh itself, and then print itself. If you already have an app with a grid control and some kind of image control, then you need to tell us what you used for that (wxPython? tkinter? Qt?) before we can advise you on this routine. >Private Declare Function SendMessage Lib "user32.dll" Alias _ > "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _ > ByVal wParam As Long, ByVal lParam As Long) As Long > >Private Const WM_PAINT = &HF >Private Const WM_PRINT = &H317 >Private Const PRF_CLIENT = &H4& >Private Const PRF_CHILDREN = &H10& >Private Const PRF_OWNED = &H20& > >Private Sub Command1_Click() > SendMessage grid.hwnd, WM_PAINT, picture.hDC, 0 > SendMessage grid.hwnd, WM_PRINT, picture.hDC, PRF_CHILDREN Or PRF_CLIENT >Or PRF_OWNED > picture.Picture = picture.Image > picture.Refresh >End Sub > -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From alex at moreati.org.uk Sat Jan 8 02:11:13 2005 From: alex at moreati.org.uk (Alex Willmer) Date: Sat Jan 8 02:11:16 2005 Subject: [python-win32] NetScheduleJob API in python? Message-ID: <41DF3331.3000507@moreati.org.uk> Whilst scripting an audit of service/scheduled jobs logins in our mixed NT/2000 domain I've found pywin32 does not expose the NetScheduleJob* functions. Does anyone know of library that exposes these? The API relates mostly to NT 4.0, in 2000 the task scheduler was upgraded and exposed through a COM interface (which is included). Documentation for the old API is here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/netmgmt/network_management_functions.asp If no pythonifyed interface exists how feasible would it be to call these functions directly through ctypes or windll? With thanks Alex From rwupole at msn.com Sat Jan 8 07:09:02 2005 From: rwupole at msn.com (Roger Upole) Date: Sat Jan 8 07:09:10 2005 Subject: [python-win32] Re: NetScheduleJob API in python? Message-ID: The Task Scheduler COM interfaces exist on NT also. They came as part of one of the IE installs (IE5 I think), so chances are you already have them on your NT machines. Roger -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050108/9d816c44/attachment.htm From ionel.mc at gmail.com Sat Jan 8 12:28:47 2005 From: ionel.mc at gmail.com (ionel) Date: Sat Jan 8 12:28:48 2005 Subject: [python-win32] Raw sockets on win32 ? Message-ID: i need some help on this .... raw sockets don't work on win32 ?!? i saw on some mailing list some guy wo recompiled the socket library ... any pointers? (i'm a newbie:P ) -- ionel. From alex at moreati.org.uk Sat Jan 8 14:01:16 2005 From: alex at moreati.org.uk (Alex Willmer) Date: Sat Jan 8 14:01:19 2005 Subject: [python-win32] Re: NetScheduleJob API in python? In-Reply-To: References: Message-ID: <41DFD99C.6030302@moreati.org.uk> Roger Upole wrote: > The Task Scheduler COM interfaces exist on NT also. They came as part of > one of the IE installs (IE5 I think), so chances are you already have them > on your NT machines. > Roger, Firstly thankyou for your work in pywin32 on that COM interface, I wouldn't have got this far without it. However some NT hosts are returning a COM error (which dumbly I don't have the details of now),when I try to call GetTargetComputer. It appears the Task Scheduler component isn't installed on these servers, no Scheduled Tasks special folder appears in Explorer under WINNT. According to MSDN the IE 4 redistributable is required, IE 5.x is installed, I can only assume the scheduler option was deselected. Alex From wap at openlink.com.br Sat Jan 8 08:13:57 2005 From: wap at openlink.com.br (Washington Coutinho Corra Jr) Date: Sat Jan 8 18:59:52 2005 Subject: [python-win32] Re: Calling Python functions from Excel References: <75ABDD2D2D569A439D18FFB90DC1494501D1344B@USEVS1.aigfpc.com> Message-ID: I think you just need to create a COM server with the Python function, then create a wrapper function (with VBA) in a module (within the spreadsheet). Isn't? Hugs, Junior (http://www.gs.kitbr.com/) "Quem controla o passado, controla o futuro; quem controla o presente controla o passado." (1984, George Orwell) From rwupole at msn.com Mon Jan 10 06:18:19 2005 From: rwupole at msn.com (Roger Upole) Date: Mon Jan 10 06:18:25 2005 Subject: [python-win32] Re: NetScheduleJob API in python? References: <41DFD99C.6030302@moreati.org.uk> Message-ID: ----- Original Message ----- From: "Alex Willmer" To: Sent: Saturday, January 08, 2005 8:01 AM Subject: Re: [python-win32] Re: NetScheduleJob API in python? > Roger Upole wrote: > >> The Task Scheduler COM interfaces exist on NT also. They came as part of >> one of the IE installs (IE5 I think), so chances are you already have >> them >> on your NT machines. >> > > Roger, > > Firstly thankyou for your work in pywin32 on that COM interface, I > wouldn't have got this far without it. You're very welcome ! > > However some NT hosts are returning a COM error (which dumbly I don't have > the details of now),when I try to call GetTargetComputer. It appears the > Task Scheduler component isn't installed on these servers, no Scheduled > Tasks special folder appears in Explorer under WINNT. > > According to MSDN the IE 4 redistributable is required, IE 5.x is > installed, I can only assume the scheduler option was deselected. > > Alex > > So you have a mix of some machines that have been upgraded and some that haven't ? Sounds pretty ugly. If installing the task scheduler on the rest of them isn't an option, you might be able to parse the results of AT \\servername . Alternately, I think the At service kept its entries in the registry somewhere. Can't remember exactly where though, and I think the keys had specific permissions set on them. Roger From python at kareta.de Mon Jan 10 19:41:55 2005 From: python at kareta.de (python@kareta.de) Date: Mon Jan 10 19:59:36 2005 Subject: [python-win32] Geting values from a thread Message-ID: <1105382515.41e2cc73f2a90@webmail.ldc.de> Hi all, I am wondering about the following situation: I defined a class and inside this class I start a new thread with thread.start_new_thread. When I set some attributes of that class inside the thread_function, the attributes are not changed. class test: def __init__(self): self.param='' thread.start_new_thread(self.run_thread,()) def run_thread(self): self.param='hello' return t=test() print t.param #result is an empty string The run_thread function operates on the same object but all changes are lost when the thread returns. How can I pass values from the thread function to the main thread ? regards, J?rgen ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/ From fumanchu at amor.org Mon Jan 10 20:06:18 2005 From: fumanchu at amor.org (Robert Brewer) Date: Mon Jan 10 20:09:10 2005 Subject: [python-win32] Dr. Watson woes with ADO, mysql Message-ID: <3A81C87DC164034AA4E2DDFE11D258E3398150@exchange.hqamor.amorhq.net> Hello all, I've spent the last year writing an ORM in Python which I'm reasonably pleased with. But I have a recent problem: I can't seem to migrate tables from Microsoft Access (using ADO) to MySQL (using MySQLdb) without a crash. But, don't let the context fool you: when it crashes, I don't think I'm doing *anything* with the ADO connection, and I actually get the same crash when using Postgres instead of MySQL. I'm not a Windows guru by any means, but I have noticed a pattern: throughout my (many, naive) code changes to try to avoid the crash, the same functions keep popping up in drwtsn32.log: function: PyComplex_AsCComplex function: NtWaitForSingleObject (multiple times) function: NtWaitForMultipleObjects function: ZwReplyWaitReceivePortEx function: NtDelayExecution function: ScrollDC ...where PyComplex_AsCComplex is the first one listed, and (if I'm reading MSDN correctly) is therefore the function "where the fault occurred". So the question is, what's the next step in tracking down the bug? PyComplex_AsCComplex is a pretty simple function. Or am I way off-base and should be looking elsewhere? Robert Brewer MIS Amor Ministries fumanchu@amor.org Application exception occurred: App: (pid=1436) When: 1/10/2005 @ 10:31:47.869 Exception number: c0000005 (access violation) *----> System Information <----* Computer Name: REDROVER User Name: rbre Number of Processors: 1 Processor Type: x86 Family 15 Model 2 Stepping 7 Windows 2000 Version: 5.0 Current Build: 2195 Service Pack: 4 Current Type: Uniprocessor Free Registered Organization: Registered Owner: Valued Sony Customer *----> Task List <----* 0 Idle.exe 8 System.exe 156 SMSS.exe 180 CSRSS.exe 176 WINLOGON.exe 228 SERVICES.exe 240 LSASS.exe 420 svchost.exe 448 spoolsv.exe 524 svchost.exe 544 sqlservr.exe 620 sqlservr.exe 636 mysqld-nt.exe 672 pg_ctl.exe 792 postmaster.exe 800 WinMgmt.exe 808 inetinfo.exe 908 postgres.exe 924 postgres.exe 944 postgres.exe 964 postgres.exe 1264 explorer.exe 1324 PcfMgr.exe 1168 Apoint.exe 1144 prpcui.exe 1132 WlanUtil.exe 1120 atiptaxx.exe 1112 qttask.exe 604 PhoneManager.ex.exe 1444 ApntEx.exe 1452 sqlmangr.exe 548 CMD.exe 1340 mysql.exe 1488 openvpnserv.exe 492 openvpn.exe 600 Pythonwin.exe 784 CMD.exe 1332 CMD.exe 1436 python.exe 1500 DRWTSN32.exe 0 _Total.exe (1D000000 - 1D005000) (77F80000 - 77FFD000) (1E000000 - 1E0F0000) (7C570000 - 7C623000) (77E10000 - 77E75000) (77F40000 - 77F7B000) (7C2D0000 - 7C332000) (77D30000 - 77DA1000) (782F0000 - 78535000) (63180000 - 631E9000) (78000000 - 78045000) (71710000 - 71794000) (75E60000 - 75E7A000) (1E1E0000 - 1E1EE000) (1D180000 - 1D18B000) (1E1D0000 - 1E1DC000) (75050000 - 75058000) (75030000 - 75044000) (75020000 - 75028000) (10000000 - 1007C000) (1D110000 - 1D115000) (00E60000 - 00E73000) (77A50000 - 77B3F000) (779B0000 - 77A4B000) (01290000 - 012DE000) (012E0000 - 012F0000) (77820000 - 77827000) (759B0000 - 759B6000) (7C340000 - 7C34F000) (013F0000 - 01426000) (782C0000 - 782CC000) (77980000 - 779A4000) (77340000 - 77353000) (77520000 - 77525000) (77320000 - 77337000) (75150000 - 7515F000) (75170000 - 751BF000) (77BF0000 - 77C01000) (77950000 - 7797A000) (751C0000 - 751C6000) (773B0000 - 773DF000) (77380000 - 773A3000) (77830000 - 7783E000) (77880000 - 7790E000) (7C0F0000 - 7C151000) (774E0000 - 77513000) (774C0000 - 774D1000) (77530000 - 77552000) (77360000 - 77379000) (777E0000 - 777E8000) (777F0000 - 777F5000) (74FD0000 - 74FEE000) (75010000 - 75017000) (775A0000 - 77630000) (1F440000 - 1F4BD000) (1F670000 - 1F693000) (76B30000 - 76B6E000) (1F890000 - 1F8FC000) (1F900000 - 1F911000) (1B570000 - 1B5C5000) (1B000000 - 1B170000) (1B5D0000 - 1B665000) (1B2C0000 - 1B2CD000) (1B2D0000 - 1B2F6000) (78740000 - 788AF000) (6DE80000 - 6DEE4000) (6DF80000 - 6E037000) (6A7A0000 - 6A7B0000) (73930000 - 73940000) (689D0000 - 689DD000) (1B810000 - 1B84A000) (0F9A0000 - 0F9AB000) (0F9C0000 - 0FA22000) (1F530000 - 1F53D000) State Dump for Thread Id 0x5cc eax=00000001 ebx=00cee0a0 ecx=00000001 edx=1e0b4480 esi=1e0b2317 edi=00000005 eip=1e0328ee esp=0012e910 ebp=00000001 iopl=0 nv up ei pl nz na pe nc cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000202 function: PyComplex_AsCComplex *----> Stack Back Trace <----* FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name 00000001 00000000 00000000 00000000 00000000 00000000 !PyComplex_AsCComplex *----> Raw Stack Dump <----* 0012e910 a0 e0 ce 00 01 00 00 00 - a0 34 7f 00 06 00 00 00 .........4...... 0012e920 e2 cf 02 1e a0 e0 ce 00 - 17 23 0b 1e 01 00 00 00 .........#...... 0012e930 f0 96 b3 00 46 ae 02 1e - f0 96 b3 00 17 23 0b 1e ....F........#.. 0012e940 01 00 00 00 a0 34 7f 00 - f0 96 b3 00 ff ff ff ff .....4.......... 0012e950 c8 f9 0c 1e a0 34 7f 00 - a0 34 7f 00 5b a2 02 1e .....4...4..[... 0012e960 f0 96 b3 00 a0 34 7f 00 - 01 00 00 00 70 3d cd 00 .....4......p=.. 0012e970 00 43 c6 00 f0 96 b3 00 - 70 3d cd 00 00 00 00 00 .C......p=...... 0012e980 00 00 00 00 bc 38 cb 00 - e0 bb 02 1e f0 96 b3 00 .....8.......... 0012e990 a0 34 7f 00 00 00 00 00 - 70 3d cd 00 f0 96 b3 00 .4......p=...... 0012e9a0 ff ff ff ff 90 93 cf 00 - 00 00 00 00 04 3a 01 1b .............:.. 0012e9b0 ff ff ff ff 00 19 f3 01 - 00 00 00 00 00 00 00 00 ................ 0012e9c0 00 00 00 00 d0 e9 12 00 - 00 00 00 00 40 00 00 00 ............@... 0012e9d0 00 35 04 1b 90 0e f3 01 - 00 00 00 00 00 00 00 00 .5.............. 0012e9e0 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 0012e9f0 d8 e8 58 7c ff ff ff ff - 44 ea 12 00 00 00 87 01 ..X|....D....... 0012ea00 00 00 00 00 e8 ea 12 00 - 00 00 00 00 03 c6 fc 77 ...............w 0012ea10 00 00 87 01 e0 c4 fc 77 - 50 06 87 01 60 06 87 01 .......wP...`... 0012ea20 00 00 00 00 30 02 94 02 - 30 02 94 02 f0 12 f3 01 ....0...0....... 0012ea30 b8 eb 12 00 3c 81 00 1b - 44 e6 f3 01 f0 12 f3 01 ....<...D....... 0012ea40 00 00 00 00 b8 eb 12 00 - 00 00 00 00 30 02 94 02 ............0... State Dump for Thread Id 0x5f8 eax=41e2ca13 ebx=00000000 ecx=0000026b edx=00000000 esi=77f82865 edi=00000364 eip=77f82870 esp=013ef878 ebp=013ef89c iopl=0 nv up ei pl zr na po nc cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000246 function: NtWaitForSingleObject 77f82865 b8ea000000 mov eax,0xea 77f8286a 8d542404 lea edx,[esp+0x4] ss:01ee975f=???????? 77f8286e cd2e int 2e 77f82870 c20c00 ret 0xc *----> Stack Back Trace <----* FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name 013EF89C 7C57B3DB 00000364 FFFFFFFF 00000000 1E080331 ntdll!NtWaitForSingleObject 013EF96C 00000001 00000000 00000000 0085EC38 00785B58 kernel32!WaitForSingleObject *----> Raw Stack Dump <----* 013ef878 e4 9f 59 7c 64 03 00 00 - 00 00 00 00 00 00 00 00 ..Y|d........... 013ef888 68 d5 a2 00 b6 91 00 78 - 78 4b b8 00 68 d5 a2 00 h......xxK..h... 013ef898 68 d5 a2 00 6c f9 3e 01 - db b3 57 7c 64 03 00 00 h...l.>...W|d... 013ef8a8 ff ff ff ff 00 00 00 00 - 31 03 08 1e 64 03 00 00 ........1...d... 013ef8b8 ff ff ff ff 00 00 00 00 - b6 91 00 78 8b 05 08 1e ...........x.... 013ef8c8 68 d5 a2 00 ff ff ff ff - d8 2a 01 1e 68 d5 a2 00 h........*..h... 013ef8d8 01 00 00 00 78 4b b8 00 - 32 00 00 00 00 00 00 00 ....xK..2....... 013ef8e8 43 17 08 1e 78 4b b8 00 - 40 0e 08 1e c8 bd 86 00 C...xK..@....... 013ef8f8 71 0e 08 1e 00 00 00 00 - 00 00 49 40 9a 99 99 99 q.........I@.... 013ef908 99 99 a9 3f 96 91 05 1e - 00 00 00 00 b0 0b 7f 00 ...?............ 013ef918 01 00 00 00 c8 bd 86 00 - 2c b9 9d 00 fb 69 01 1e ........,....i.. 013ef928 c8 bd 86 00 b0 0b 7f 00 - 00 00 00 00 6c f9 3e 01 ............l.>. 013ef938 01 00 00 00 e0 20 82 00 - e0 18 86 00 82 00 00 00 ..... .......... 013ef948 38 ec 85 00 00 00 00 00 - 85 4b 01 1e 6c f9 3e 01 8........K..l.>. 013ef958 b0 0b 7f 00 00 00 00 00 - 20 40 86 00 14 b9 9d 00 ........ @...... 013ef968 c0 b7 9d 00 30 b9 9d 00 - 01 00 00 00 00 00 00 00 ....0........... 013ef978 00 00 00 00 38 ec 85 00 - 58 5b 78 00 3c eb 85 00 ....8...X[x.<... 013ef988 00 00 00 00 00 00 00 00 - 00 00 00 00 78 4b b8 00 ............xK.. 013ef998 20 40 86 00 20 40 86 00 - 2c b9 9d 00 01 00 00 00 @.. @..,....... 013ef9a8 94 1c 83 00 ff ff ff ff - 00 00 00 00 b0 7f 81 00 ................ State Dump for Thread Id 0x438 eax=778321fe ebx=00000004 ecx=0012e7fc edx=00000000 esi=77f82873 edi=00000004 eip=77f8287e esp=0153fd24 ebp=0153fd70 iopl=0 nv up ei pl zr na po nc cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000246 function: NtWaitForMultipleObjects 77f82873 b8e9000000 mov eax,0xe9 77f82878 8d542404 lea edx,[esp+0x4] ss:02039c0b=???????? 77f8287c cd2e int 2e 77f8287e c21400 ret 0x14 *----> Stack Back Trace <----* FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name 0153FD70 7C59A0C2 0153FD48 00000001 00000000 00000000 ntdll!NtWaitForMultipleObjects 0153FFB4 7C57B388 00000005 000B000A 7C325107 00157838 kernel32!WaitForMultipleObjects 0153FFEC 00000000 778321FE 00157838 00000000 000000C8 kernel32!lstrcmpiW *----> Raw Stack Dump <----* 0153fd24 af a1 59 7c 04 00 00 00 - 48 fd 53 01 01 00 00 00 ..Y|....H.S..... 0153fd34 00 00 00 00 00 00 00 00 - 01 00 00 00 38 78 15 00 ............8x.. 0153fd44 01 00 00 00 00 03 00 00 - fc 02 00 00 ec 02 00 00 ................ 0153fd54 84 02 00 00 d0 bc 04 82 - 00 00 00 00 80 14 48 80 ..............H. 0153fd64 a8 b2 0a 82 c4 7b 12 ba - b8 bc 04 82 b4 ff 53 01 .....{........S. 0153fd74 c2 a0 59 7c 48 fd 53 01 - 01 00 00 00 00 00 00 00 ..Y|H.S......... 0153fd84 00 00 00 00 00 00 00 00 - b2 22 83 77 04 00 00 00 .........".w.... 0153fd94 b0 fe 53 01 00 00 00 00 - ff ff ff ff 38 78 15 00 ..S.........8x.. 0153fda4 07 51 32 7c 0a 00 0b 00 - 00 00 00 00 00 00 00 00 .Q2|............ 0153fdb4 00 00 00 00 00 00 00 00 - 01 00 00 00 38 00 00 00 ............8... 0153fdc4 23 00 00 00 23 00 00 00 - 0a 00 0b 00 07 51 32 7c #...#........Q2| 0153fdd4 38 78 15 00 ff ff ff ff - fc e7 12 00 fe 21 83 77 8x...........!.w 0153fde4 f8 eb fd 7f 00 b7 57 7c - 1b 00 00 00 00 02 00 00 ......W|........ 0153fdf4 fc ff 53 01 23 00 00 00 - 24 00 01 e1 98 00 00 00 ..S.#...$....... 0153fe04 43 ef 01 00 48 ce 3b 82 - 00 07 00 00 1e b4 44 80 C...H.;.......D. 0153fe14 43 ef 01 00 48 ce 3b 82 - 43 ef 01 00 48 ce 3b 82 C...H.;.C...H.;. 0153fe24 01 d2 fd 7f ae 06 00 00 - 4b bd 44 80 ae 06 00 00 ........K.D..... 0153fe34 30 e2 55 81 00 d0 fd 7f - fc 07 30 c0 00 00 00 00 0.U.......0..... 0153fe44 34 00 00 c0 ae 06 00 00 - 80 14 48 80 00 00 00 00 4.........H..... 0153fe54 01 00 00 00 00 00 00 00 - 00 e0 fd 7f fc 07 30 c0 ..............0. State Dump for Thread Id 0x548 eax=77d358be ebx=001452d0 ecx=0012e6c8 edx=00000000 esi=001592b8 edi=00000100 eip=77f83310 esp=0166fe28 ebp=0166ff74 iopl=0 nv up ei pl nz na pe nc cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000202 function: ZwReplyWaitReceivePortEx 77f83305 b8ac000000 mov eax,0xac 77f8330a 8d542404 lea edx,[esp+0x4] ss:02169d0f=???????? 77f8330e cd2e int 2e 77f83310 c21400 ret 0x14 *----> Stack Back Trace <----* FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name 0166FF74 77D37B4C 77D35924 001592B8 77D33E01 00130000 ntdll!ZwReplyWaitReceivePortEx 0166FFA8 77D358D6 00145160 0166FFEC 7C57B388 001452D0 rpcrt4!NdrCorrelationInitialize 0166FFB4 7C57B388 001452D0 77D33E01 00130000 001452D0 rpcrt4!RpcBindingFree 0166FFEC 00000000 00000000 00000000 00000000 00000000 kernel32!lstrcmpiW State Dump for Thread Id 0x620 eax=77ab502c ebx=00000102 ecx=01dc01da edx=00000000 esi=77f82826 edi=0176ff74 eip=77f82831 esp=0176ff60 ebp=0176ff7c iopl=0 nv up ei pl nz na po nc cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000206 function: NtDelayExecution 77f82826 b832000000 mov eax,0x32 77f8282b 8d542404 lea edx,[esp+0x4] ss:02269e47=???????? 77f8282f cd2e int 2e 77f82831 c20800 ret 0x8 77f82834 53 push ebx 77f82835 51 push ecx 77f82836 6a00 push 0x0 77f82838 c70701000000 mov dword ptr [edi],0x1 ds:0176ff74=dc3cba00 77f8283e ff750c push dword ptr [ebp+0xc] ss:02269e62=???????? 77f82841 50 push eax 77f82842 e879fdffff call RtlMultiByteToUnicodeN (77f825c0) 77f82847 e928fcffff jmp RtlConsoleMultiByteToUnicodeN+0x333 (77f82474) *----> Stack Back Trace <----* FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name 0176FF7C 7C59A20E 0000EA60 00000000 77AB8FFB 0000EA60 ntdll!NtDelayExecution 00007530 00000000 00000000 00000000 00000000 00000000 kernel32!Sleep State Dump for Thread Id 0x3ec eax=1f444878 ebx=001703ce ecx=01870fb4 edx=00000000 esi=0186ff54 edi=00000000 eip=77e11555 esp=0186ff18 ebp=0186ff30 iopl=0 nv up ei pl zr na po nc cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000246 function: ScrollDC 77e11533 8d542404 lea edx,[esp+0x4] ss:02369dff=???????? 77e11537 cd2e int 2e 77e11539 c21c00 ret 0x1c 77e1153c b838110000 mov eax,0x1138 77e11541 8d542404 lea edx,[esp+0x4] ss:02369dff=???????? 77e11545 cd2e int 2e 77e11547 c20400 ret 0x4 77e1154a b89a110000 mov eax,0x119a 77e1154f 8d542404 lea edx,[esp+0x4] ss:02369dff=???????? 77e11553 cd2e int 2e 77e11555 c21000 ret 0x10 77e11558 6a01 push 0x1 77e1155a 58 pop eax 77e1155b c20800 ret 0x8 77e1155e b839110000 mov eax,0x1139 77e11563 8d542404 lea edx,[esp+0x4] ss:02369dff=???????? 77e11567 cd2e int 2e 77e11569 c20800 ret 0x8 *----> Stack Back Trace <----* FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name 0186FF30 77ABBAD5 0186FF54 00000000 00000000 00000000 user32!ScrollDC 0186FF70 77ABBA23 7C599F73 00147910 00000102 000001CC ole32!CoInstall 0186FF8C 77ABB95E 77AB50EE 77B2E278 77A50000 00147910 ole32!CoInstall 00007530 00000000 00000000 00000000 00000000 00000000 ole32!CoInstall *----> Raw Stack Dump <----* 0186ff18 d7 15 e1 77 54 ff 86 01 - 00 00 00 00 00 00 00 00 ...wT........... 0186ff28 00 00 00 00 b0 15 e1 77 - 70 ff 86 01 d5 ba ab 77 .......wp......w 0186ff38 54 ff 86 01 00 00 00 00 - 00 00 00 00 00 00 00 00 T............... 0186ff48 00 00 00 00 78 e2 b2 77 - 00 00 00 00 ce 03 17 00 ....x..w........ 0186ff58 00 04 00 00 be ba 00 00 - 34 ac 14 00 5d 33 b9 02 ........4...]3.. 0186ff68 3f 03 00 00 dc 00 00 00 - 8c ff 86 01 23 ba ab 77 ?...........#..w 0186ff78 73 9f 59 7c 10 79 14 00 - 02 01 00 00 cc 01 00 00 s.Y|.y.......... 0186ff88 40 7a 14 00 30 75 00 00 - 5e b9 ab 77 ee 50 ab 77 @z..0u..^..w.P.w 0186ff98 78 e2 b2 77 00 00 a5 77 - 10 79 14 00 ec ff 86 01 x..w...w.y...... 0186ffa8 10 79 14 00 46 50 ab 77 - 30 02 00 00 00 00 00 00 .y..FP.w0....... 0186ffb8 88 b3 57 7c 10 79 14 00 - 30 02 00 00 00 00 00 00 ..W|.y..0....... 0186ffc8 10 79 14 00 00 90 fd 7f - 74 e3 12 00 c0 ff 86 01 .y......t....... 0186ffd8 74 e3 12 00 ff ff ff ff - 44 1f 5c 7c 08 2b 57 7c t.......D.\|.+W| 0186ffe8 00 00 00 00 00 00 00 00 - 00 00 00 00 2c 50 ab 77 ............,P.w 0186fff8 10 79 14 00 00 00 00 00 - c1 00 00 00 00 01 00 00 .y.............. 01870008 ff ee ff ee 03 10 00 00 - 01 00 00 00 00 fe 00 00 ................ 01870018 00 00 10 00 00 20 00 00 - 00 02 00 00 00 20 00 00 ..... ....... .. 01870028 a8 01 00 00 ff ef fd 7f - 07 00 08 06 00 00 00 00 ................ 01870038 00 00 00 00 00 00 00 00 - 00 00 00 00 98 05 87 01 ................ 01870048 0f 00 00 00 f8 ff ff ff - 50 00 87 01 50 00 87 01 ........P...P... State Dump for Thread Id 0x4ac eax=00000001 ebx=0283fd74 ecx=77b2d090 edx=00000000 esi=77f82865 edi=00000184 eip=77f82870 esp=0283fd58 ebp=0283fd7c iopl=0 nv up ei ng nz ac po cy cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000297 function: NtWaitForSingleObject 77f82865 b8ea000000 mov eax,0xea 77f8286a 8d542404 lea edx,[esp+0x4] ss:03339c3f=???????? 77f8286e cd2e int 2e 77f82870 c20c00 ret 0xc *----> Stack Back Trace <----* FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name 0283FD7C 7C57B3DB 00000184 00002710 00000000 7878DB85 ntdll!NtWaitForSingleObject 00000000 00000000 00000000 00000000 00000000 00000000 kernel32!WaitForSingleObject *----> Raw Stack Dump <----* 0283fd58 e4 9f 59 7c 84 01 00 00 - 00 00 00 00 74 fd 83 02 ..Y|........t... 0283fd68 f4 c5 13 00 00 00 00 00 - 0c c6 13 00 00 1f 0a fa ................ 0283fd78 ff ff ff ff 00 00 00 00 - db b3 57 7c 84 01 00 00 ..........W|.... 0283fd88 10 27 00 00 00 00 00 00 - 85 db 78 78 84 01 00 00 .'........xx.... 0283fd98 10 27 00 00 00 00 00 00 - 24 ec 12 00 ec ff 83 02 .'......$....... 0283fda8 f4 c5 13 00 00 00 74 78 - 43 00 3a 00 5c 00 57 00 ......txC.:.\.W. 0283fdb8 49 00 4e 00 4e 00 54 00 - 5c 00 53 00 79 00 73 00 I.N.N.T.\.S.y.s. 0283fdc8 74 00 65 00 6d 00 33 00 - 32 00 5c 00 63 00 6f 00 t.e.m.3.2.\.c.o. 0283fdd8 6d 00 73 00 76 00 63 00 - 73 00 2e 00 64 00 6c 00 m.s.v.c.s...d.l. 0283fde8 6c 00 00 00 1b 00 00 00 - 00 02 00 00 fc ff 83 02 l............... 0283fdf8 23 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 #............... 0283fe08 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 0283fe18 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 0283fe28 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 0283fe38 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 0283fe48 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 0283fe58 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 0283fe68 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 0283fe78 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 0283fe88 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ State Dump for Thread Id 0x420 eax=00000000 ebx=06a3ff0c ecx=00000400 edx=00000000 esi=77f82865 edi=0000019c eip=77f82870 esp=06a3fef0 ebp=06a3ff14 iopl=0 nv up ei ng nz ac po cy cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000297 function: NtWaitForSingleObject 77f82865 b8ea000000 mov eax,0xea 77f8286a 8d542404 lea edx,[esp+0x4] ss:07539dd7=???????? 77f8286e cd2e int 2e 77f82870 c20c00 ret 0xc *----> Stack Back Trace <----* FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name 06A3FF14 7C57B3DB 0000019C 00001388 00000000 1B009B78 ntdll!NtWaitForSingleObject 00000000 00000000 00000000 00000000 00000000 00000000 kernel32!WaitForSingleObject State Dump for Thread Id 0x598 eax=00000000 ebx=00000000 ecx=00000400 edx=00000000 esi=77f82865 edi=0000019c eip=77f82870 esp=06b3fef0 ebp=06b3ff14 iopl=0 nv up ei pl zr na po nc cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000246 function: NtWaitForSingleObject 77f82865 b8ea000000 mov eax,0xea 77f8286a 8d542404 lea edx,[esp+0x4] ss:07639dd7=???????? 77f8286e cd2e int 2e 77f82870 c20c00 ret 0xc *----> Stack Back Trace <----* FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name 06B3FF14 7C57B3DB 0000019C FFFFFFFF 00000000 1B009B78 ntdll!NtWaitForSingleObject 00000000 00000000 00000000 00000000 00000000 00000000 kernel32!WaitForSingleObject State Dump for Thread Id 0x294 eax=00000000 ebx=00000000 ecx=00000400 edx=00000000 esi=77f82865 edi=0000019c eip=77f82870 esp=06c3fef0 ebp=06c3ff14 iopl=0 nv up ei pl zr na po nc cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000246 function: NtWaitForSingleObject 77f82865 b8ea000000 mov eax,0xea 77f8286a 8d542404 lea edx,[esp+0x4] ss:07739dd7=???????? 77f8286e cd2e int 2e 77f82870 c20c00 ret 0xc *----> Stack Back Trace <----* FramePtr ReturnAd Param#1 Param#2 Param#3 Param#4 Function Name 06C3FF14 7C57B3DB 0000019C FFFFFFFF 00000000 1B009B78 ntdll!NtWaitForSingleObject 00000000 00000000 00000000 00000000 00000000 00000000 kernel32!WaitForSingleObject *----> Raw Stack Dump <----* 06c3fef0 e4 9f 59 7c 9c 01 00 00 - 00 00 00 00 00 00 00 00 ..Y|............ 06c3ff00 7c ff c3 06 a0 08 f3 01 - 01 00 00 00 9c 01 00 00 |............... 06c3ff10 9c 01 00 00 00 00 00 00 - db b3 57 7c 9c 01 00 00 ..........W|.... 06c3ff20 ff ff ff ff 00 00 00 00 - 78 9b 00 1b 9c 01 00 00 ........x....... 06c3ff30 ff ff ff ff c7 9a 00 1b - ff ff ff ff 7c ff c3 06 ............|... 06c3ff40 20 c5 58 7c 10 e8 f3 01 - 00 00 00 00 d0 0d 12 1b .X|............ 06c3ff50 00 00 00 00 ff ff ff ff - 94 02 00 00 8c 35 00 1b .............5.. 06c3ff60 7c ff c3 06 20 c5 58 7c - 24 e9 12 00 ec ff c3 06 |... .X|$....... 06c3ff70 d0 0d 12 1b 10 e8 f3 01 - 5c 01 00 00 01 00 00 00 ........\....... 06c3ff80 00 00 00 00 13 e7 42 80 - 00 00 00 00 97 02 00 00 ......B......... 06c3ff90 be e7 42 80 60 bd 52 81 - 40 db 4b 81 ff ff ff ff ..B.`.R.@.K..... 06c3ffa0 00 00 00 00 01 00 00 00 - 00 00 00 00 00 00 00 00 ................ 06c3ffb0 00 00 00 00 bf 80 f8 77 - 88 b3 57 7c d0 0d 12 1b .......w..W|.... 06c3ffc0 20 c5 58 7c 24 e9 12 00 - d0 0d 12 1b 00 50 fd 7f .X|$........P.. 06c3ffd0 55 1f f8 77 c0 ff c3 06 - 55 1f f8 77 ff ff ff ff U..w....U..w.... 06c3ffe0 44 1f 5c 7c 08 2b 57 7c - 00 00 00 00 00 00 00 00 D.\|.+W|........ 06c3fff0 00 00 00 00 9b 34 00 1b - d0 0d 12 1b 00 00 00 00 .....4.......... 06c40000 01 00 00 00 00 40 00 00 - 00 c0 17 00 37 01 c4 06 .....@......7... 06c40010 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00 ................ 06c40020 00 00 00 00 08 20 87 02 - 90 0e f3 01 3f 00 00 00 ..... ......?... From mhammond at skippinet.com.au Mon Jan 10 23:33:30 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon Jan 10 23:33:35 2005 Subject: [python-win32] Dr. Watson woes with ADO, mysql In-Reply-To: <3A81C87DC164034AA4E2DDFE11D258E3398150@exchange.hqamor.amorhq.net> Message-ID: <01d501c4f764$69fec0f0$0200a8c0@enfoldsystems.local> > I've spent the last year writing an ORM in Python which I'm reasonably > pleased with. But I have a recent problem: I can't seem to migrate > tables from Microsoft Access (using ADO) to MySQL (using MySQLdb) > without a crash. But, don't let the context fool you: when it > crashes, I > don't think I'm doing *anything* with the ADO connection, and > I actually > get the same crash when using Postgres instead of MySQL. > > I'm not a Windows guru by any means, but I have noticed a pattern: > throughout my (many, naive) code changes to try to avoid the > crash, the > same functions keep popping up in drwtsn32.log: > > function: PyComplex_AsCComplex > function: NtWaitForSingleObject (multiple times) > function: NtWaitForMultipleObjects > function: ZwReplyWaitReceivePortEx > function: NtDelayExecution > function: ScrollDC All except the first and last are quite usual. I'm not sure where ScrollDC has come from - are you using this from a GUI? > > ...where PyComplex_AsCComplex is the first one listed, and (if I'm > reading MSDN correctly) is therefore the function "where the fault > occurred". > > So the question is, what's the next step in tracking down the bug? > PyComplex_AsCComplex is a pretty simple function. Or am I way off-base > and should be looking elsewhere? If a GUI is involved, you should try and make sure you are living within its thread constraints. Its possible to cause a crash by mixing threading up in a GUI. PyComplex_AsCComplex does indeed look simple, but my guess is that given the trouble you are having reproducing, there is a subtle reference-count bug somewhere, and quite possibly relating to complex numbers. Given the nature of such bugs, the place where the crash occurs is generally *not* the place with the bug. Unfortunately, we are piling speculation on speculation. Personally I would get a debug build running, so a decent stack-trace is available, but I understand that may not be an option. Good luck, Mark. -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 2744 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050111/44cb347d/winmail-0001.bin From fumanchu at amor.org Mon Jan 10 23:55:45 2005 From: fumanchu at amor.org (Robert Brewer) Date: Mon Jan 10 23:58:36 2005 Subject: [python-win32] Dr. Watson woes with ADO, mysql Message-ID: <3A81C87DC164034AA4E2DDFE11D258E3398161@exchange.hqamor.amorhq.net> I wrote: > > I've spent the last year writing an ORM in Python which I'm > reasonably > > pleased with. But I have a recent problem: I can't seem to migrate > > tables from Microsoft Access (using ADO) to MySQL (using MySQLdb) > > without a crash. But, don't let the context fool you: when it > > crashes, I > > don't think I'm doing *anything* with the ADO connection, and > > I actually > > get the same crash when using Postgres instead of MySQL. > > > > I'm not a Windows guru by any means, but I have noticed a pattern: > > throughout my (many, naive) code changes to try to avoid the > > crash, the > > same functions keep popping up in drwtsn32.log: > > > > function: PyComplex_AsCComplex > > function: NtWaitForSingleObject (multiple times) > > function: NtWaitForMultipleObjects > > function: ZwReplyWaitReceivePortEx > > function: NtDelayExecution > > function: ScrollDC and Mark Hammond replied: > All except the first and last are quite usual. I'm not sure > where ScrollDC has come from - are you using this from a GUI? No, from a DOS prompt (cmd.exe). However, I get similar problems launching from Pythonwin interactively. > > ...where PyComplex_AsCComplex is the first one listed, and (if I'm > > reading MSDN correctly) is therefore the function "where the fault > > occurred". > > > > So the question is, what's the next step in tracking down the bug? > > PyComplex_AsCComplex is a pretty simple function. Or am I > way off-base > > and should be looking elsewhere? > > If a GUI is involved, you should try and make sure you are > living within its thread constraints. Its possible to cause > a crash by mixing threading up in a GUI. > > PyComplex_AsCComplex does indeed look simple, but my guess is > that given the trouble you are having reproducing, there is a > subtle reference-count bug somewhere, and quite possibly > relating to complex numbers. Given the nature of such bugs, > the place where the crash occurs is generally *not* the place > with the bug. Okay. This is probably especially true since my app doesn't handle any complex numbers (at least not in my code). I also can't find complex mentioned anywhere in the ADO COM lib (in gen_py) or in the _mysql.pyd C code (which I call directly instead of using the DBAPI wrapper). http://cvs.sourceforge.net/viewcvs.py/mysql-python/mysql/_mysqlmodule.c? rev=1.42&view=auto > Unfortunately, we are piling speculation on speculation. > Personally I would get a debug build running, so a decent > stack-trace is available, but I understand that may not be an option. ...for which I'd need vc++, right? IIRC, I'd need at least version 7? Would "Visual Studio .NET Professional Edition 2003" be okay? I can get that cheap from TechSoup. ;) I'm willing to do the research if I can just get pointed in the right direction. Thanks for the help so far! Robert Brewer MIS Amor Ministries fumanchu@amor.org From timr at probo.com Tue Jan 11 01:06:33 2005 From: timr at probo.com (Tim Roberts) Date: Tue Jan 11 01:06:41 2005 Subject: [python-win32] Geting values from a thread In-Reply-To: <20050110223336.A2EB31E4012@bag.python.org> References: <20050110223336.A2EB31E4012@bag.python.org> Message-ID: <41E31889.7060203@probo.com> On Mon, 10 Jan 2005 19:41:55 +0100, python@kareta.de wrote: >Hi all, > >I am wondering about the following situation: > >I defined a class and inside this class I start a new thread with >thread.start_new_thread. When I set some attributes of that class inside >the thread_function, the attributes are not changed. > > >class test: > def __init__(self): > self.param='' > thread.start_new_thread(self.run_thread,()) > def run_thread(self): > self.param='hello' > return > >t=test() >print t.param #result is an empty string > >The run_thread function operates on the same object but all changes are lost >when the thread returns. How can I pass values from the thread function to the >main thread ? > > You are misdiagnosing the problem. The problem is that the __init__ function returns and your print statement executes before the run_thread function has had a chance to run. Your main thread then exits, self.param gets set, and the second thread exits. That's the whole advantage of threads: they run independently. If you really need to communicate like this, you'll need to use a Queue or some other kind of interlock. However, if you DO find yourself waiting like this very often, then it is quite likely that threads are not the right answer for your problem. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From python at kareta.de Tue Jan 11 11:09:05 2005 From: python at kareta.de (python@kareta.de) Date: Tue Jan 11 11:26:24 2005 Subject: AW: [python-win32] Geting values from a thread Message-ID: <1105438145.41e3a5c1dc3ed@webmail.ldc.de> Hi, > That's the whole advantage of threads: they run independently. Yes, of course thats the reason. But I struggled into that problem, when I tried to send LogInfoMsg to the eventlog. (W2K,p2.3.3.pywin202) def SvcDoRun(self): import servicemanager servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, '')) while True: retval=win32event.WaitForMultipleObjects (self.close_evt,self.accept_evt),False,win32event.INFINITE) if retval == win32event.WAIT_OBJECT_0: win32file.CloseHandle(self.accept_evt) self.socket.close() servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STOPPED, (self._svc_name_, '')) return elif retval == win32event.WAIT_OBJECT_0 + 1: thread.start_new_thread(self.FetchData,(self.socket,)) def FetchData(self,socket): ##code import servicemanager message= 'Processed %d bytes for client connection and printed out on port %s' % (value1,value2) ##value 1,2 set inside the FetchData code servicemanager.LogInfoMsg(message) If the service runs in debug mode, the message is written to the console. If the service runs normal (with 'start' parameter) no message send to the eventlog (no error message, no exit code, nothing happens). If I put the message line and the LogInfoMsg line under thread.start_new_thread the message is send to the eventlog, but I cannot pass the two values of the FetchData function. That's the whole problem. Don't know how to solve :-( regards, J?rgen ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/ From python at kareta.de Tue Jan 11 14:59:04 2005 From: python at kareta.de (python@kareta.de) Date: Tue Jan 11 15:16:17 2005 Subject: [python-win32] (no subject) Message-ID: <1105451944.41e3dba8ac150@webmail.ldc.de> Hello, after more than a day I found a solution by myself :-)) The Solution: In the old code the LogInfoMsg is the last statement before the return statement (in the FetchData function). If I put an other statement between LogInfoMsg and return statement it works in debug and in start modus - don't know if this only appears on my machines ?(tested with w2k pywin202/nt04 sp6 pywin203, both p2.3.3). Is that a feature or a bug? regards, J?rgen >> That's the whole advantage of threads: they run independently. >Yes, of course thats the reason. But I struggled into that problem, when I >tried to send LogInfoMsg to the eventlog. > >def SvcDoRun(self): > > import servicemanager > servicemanager.LogMsg( > servicemanager.EVENTLOG_INFORMATION_TYPE, > servicemanager.PYS_SERVICE_STARTED, > (self._svc_name_, '')) > > while True: > retval=win32event.WaitForMultipleObjects((self.close_evt,self.accept_evt), False,win32event.INFINITE) > if retval == win32event.WAIT_OBJECT_0: > win32file.CloseHandle(self.accept_evt) > self.socket.close() > servicemanager.LogMsg( > servicemanager.EVENTLOG_INFORMATION_TYPE, > servicemanager.PYS_SERVICE_STOPPED, > (self._svc_name_, '')) > return > > elif retval == win32event.WAIT_OBJECT_0 + 1: > > thread.start_new_thread(self.FetchData,(self.socket,)) > > >def FetchData(self,socket): > ##code > import servicemanager > message= 'Processed %d bytes for client connection and printed out on >port %s' \ > % (value1,value2) ##set inside the FetchData code > servicemanager.LogInfoMsg(message) > > >If the service runs in debug mode, the message is written to the console. If >the service runs normal (with 'start' parameter) no message send to the >eventlog (no error message, no exit code, nothing happens). If I put the >message line and the LogInfoMsg line under thread.start_new_thread the message >is send to the eventlog, but I cannot pass the two values of the FetchData >function. >That's the whole problem. Don't know how to solve :-( >regards, >J?rgen ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/ From charlie at ezweave.com Mon Jan 10 04:25:41 2005 From: charlie at ezweave.com (Charlie Taylor) Date: Tue Jan 11 17:06:17 2005 Subject: [python-win32] ERROR installing pywin32 for python 2.2 Message-ID: <20050110032330.167611E400A@bag.python.org> I am getting an error from the install of... pywin32-203.win32-py2.2.exe on an NT 4.0 system. It looks like the "import win32trace" statement is the point of failure and gives the error message... error: (3, 'CreateMutex', 'The system cannot find the path specified.') Does anyone recognize this error? (Note that the python22 directory is on the F: drive) ------------ FULL ERROR MESSAGE FOLLOWS ---------------------- Copied pythoncom22.dll to C:\WINNT\System32\pythoncom22.dll Copied pywintypes22.dll to C:\WINNT\System32\pywintypes22.dll Registered: Python.Interpreter FAILED to register the Python COM objects -> Software\Python\PythonCore\2.2\Help[None]=None -> Software\Python\PythonCore\2.2\Help\Pythonwin Reference[None]='F:\\Python22\\Lib\\site-packages\\PyWin32.chm' function not available The pywin32 extensions were successfully installed. Traceback (most recent call last): File "F:\Python22\Scripts\pywin32_postinstall.py", line 213, in install RegisterCOMObjects() File "F:\Python22\Scripts\pywin32_postinstall.py", line 121, in RegisterCOMObjects __import__(module) File "F:\Python22\Lib\site-packages\win32com\servers\dictionary.py", line 36, in ? from win32com.server import util, policy File "F:\Python22\Lib\site-packages\win32com\server\util.py", line 4, in ? import policy File "F:\Python22\Lib\site-packages\win32com\server\policy.py", line 747, in ? from dispatcher import DispatcherTrace, DispatcherWin32trace File "F:\Python22\Lib\site-packages\win32com\server\dispatcher.py", line 277, in ? import win32trace error: (3, 'CreateMutex', 'The system cannot find the path specified.') From mhammond at skippinet.com.au Tue Jan 11 22:57:19 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Jan 11 22:57:30 2005 Subject: [python-win32] ERROR installing pywin32 for python 2.2 In-Reply-To: <20050110032330.167611E400A@bag.python.org> Message-ID: <03f801c4f828$860129e0$0200a8c0@enfoldsystems.local> This is a known problem in build 203 with Windows NT. I believe 202 did not have that problem (but did have some others instead!) http://sourceforge.net/tracker/index.php?func=detail&aid=1067148&group_id=78 018&atid=551954 It should be fixed in the next build. Regards, Mark > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of Charlie Taylor > Sent: Monday, 10 January 2005 2:26 PM > To: python-win32@python.org > Subject: [python-win32] ERROR installing pywin32 for python 2.2 > > > I am getting an error from the install of... > > pywin32-203.win32-py2.2.exe on an NT 4.0 system. > > It looks like the "import win32trace" statement is the point > of failure and > gives the error message... > error: (3, 'CreateMutex', 'The system cannot find the path > specified.') > > Does anyone recognize this error? > > (Note that the python22 directory is on the F: drive) > > ------------ FULL ERROR MESSAGE FOLLOWS ---------------------- > Copied pythoncom22.dll to C:\WINNT\System32\pythoncom22.dll > Copied pywintypes22.dll to C:\WINNT\System32\pywintypes22.dll > Registered: Python.Interpreter > FAILED to register the Python COM objects > -> Software\Python\PythonCore\2.2\Help[None]=None > -> Software\Python\PythonCore\2.2\Help\Pythonwin > Reference[None]='F:\\Python22\\Lib\\site-packages\\PyWin32.chm' > function not available > The pywin32 extensions were successfully installed. > Traceback (most recent call last): > File "F:\Python22\Scripts\pywin32_postinstall.py", line > 213, in install > RegisterCOMObjects() > File "F:\Python22\Scripts\pywin32_postinstall.py", line 121, in > RegisterCOMObjects > __import__(module) > File > "F:\Python22\Lib\site-packages\win32com\servers\dictionary.py", line > 36, in ? > from win32com.server import util, policy > File > "F:\Python22\Lib\site-packages\win32com\server\util.py", line 4, in ? > import policy > File > "F:\Python22\Lib\site-packages\win32com\server\policy.py", line 747, > in ? > from dispatcher import DispatcherTrace, DispatcherWin32trace > File > "F:\Python22\Lib\site-packages\win32com\server\dispatcher.py", line > 277, in ? > import win32trace > error: (3, 'CreateMutex', 'The system cannot find the path > specified.') > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From gagenellina at softlab.com.ar Tue Jan 11 23:53:20 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Wed Jan 12 00:03:52 2005 Subject: Subject: AW: [python-win32] Geting values from a thread In-Reply-To: <20050111110107.811351E4011@bag.python.org> References: <20050111110107.811351E4011@bag.python.org> Message-ID: <6.2.0.14.0.20050111194457.032f50b0@192.168.0.115> At 11/1/2005 08:01, you wrote: > while True: > retval=win32event.WaitForMultipleObjects >(self.close_evt,self.accept_evt),False,win32event.INFINITE) > if retval == win32event.WAIT_OBJECT_0: > win32file.CloseHandle(self.accept_evt) > self.socket.close() > servicemanager.LogMsg( > servicemanager.EVENTLOG_INFORMATION_TYPE, > servicemanager.PYS_SERVICE_STOPPED, > (self._svc_name_, '')) > return > > elif retval == win32event.WAIT_OBJECT_0 + 1: > > thread.start_new_thread(self.FetchData,(self.socket,)) > > >def FetchData(self,socket): > ##code > import servicemanager > message= 'Processed %d bytes for client connection and printed out > on port >%s' % (value1,value2) ##value 1,2 set inside the FetchData code > servicemanager.LogInfoMsg(message) > > >If the service runs in debug mode, the message is written to the console. >If the >service runs normal (with 'start' parameter) no message send to the >eventlog (no >error message, no exit code, nothing happens). If I put the message line >and the >LogInfoMsg line under thread.start_new_thread the message is send to the >eventlog, but I cannot pass the two values of the FetchData function. >That's the whole problem. Don't know how to solve :-( If you really need another thread to process FetchData, you could use a Queue to pass data between threads. But, for a server accepting multiple simultaneous connections the asyncore module may be a better solution than multiple threads. From AddisonN at iti-ab.com Wed Jan 12 14:43:35 2005 From: AddisonN at iti-ab.com (AddisonN@iti-ab.com) Date: Wed Jan 12 14:46:14 2005 Subject: [python-win32] File I/O problem Message-ID: <9355218C54DDFF4CA43FC31AEB6FB0EC433B92@iti00-exc01.iti.arabbank.plc> I trying to process a file that was originally created on an AS/400 as a spooled report. The file has been converted to ASCII before sending to me by e-mail. The original report is in Arabic script and so any Arabic script has been mapped to I can't read the whole file in unless I chop out all the (formerly) Arabic characters as read(), readline() or readlines() seems to think its done too early. The problem appears to be that the conversion has produced a byte with hex value 1a and Python is treating this as an end-of-file marker. This I've worked this out by using a Hex Editor and looking at the character after where the read operation stops. The offending character the square (unprintable) character in the file snippet below. Start file snippet >> MK 2005/01/10 ????? ??????(? .?.?) ????????? ??????? - ?????? ????????? ????????? ??? ?? ?? 01 : ???? ???? ?????? ========================================= ??????? << End file snippet Is there a way I can pre-process this file with Python and chop out the characters ( the 1a) I don't want? If I do this: import string report = open('d:\\Software\\PythonScripts\\ear11050110.txt').readlines() report is: >>> report ['MK 2005/01/10 \xc7\xe1\xc8\xe4\xdf \xc7\xe1\xda\xd1\xc8\xed(\xd4 .\xe3.\xda) \xc7\xe1\xe3\xed\xd2\xc7\xe4\xed\xc9 \xc7\xe1\xe3\xe6\xcd\xcf\xc9 - \xca\xde\xd1\xed\xdc\xd1 \xc7\xe1\xe3\xed\xd2\xc7\xe4\xed\xc9 \xc7\xe1\xd4\xe5\xdc\xdc\xd1\xed\xc9 \xdf\xe3\xc7 \xe5\xed \xdd\xed\n', ' 01 : \xdd\xd1\xe6\xda \xcf\xe6\xe1\xc9 \xc7'] Which is everything up to the hex 1a. Thanks for any prompting whatsoever. Nick. ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. Information Technology International (ITI) +44 (0)20 7315 8500 ********************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050112/bec6a77b/attachment.htm From Benjamin.Schollnick at xerox.com Wed Jan 12 16:56:23 2005 From: Benjamin.Schollnick at xerox.com (Schollnick, Benjamin) Date: Wed Jan 12 16:56:30 2005 Subject: [python-win32] File I/O problem Message-ID: <266589E1B9392B4C9195CC25A07C73B9124BA8@usa0300ms04.na.xerox.net> When in doubt, turn the problem around 90 degrees. file( filename[, mode[, bufsize]]) Return a new file object (described in section 2.3.8 , ``File Objects ''). The first two arguments are the same as for stdio's fopen(): filename is the file name to be opened, mode indicates how the file is to be opened: 'r' for reading, 'w' for writing (truncating an existing file), and 'a' opens it for appending (which on some Unix systems means that all writes append to the end of the file, regardless of the current seek position). The problem is that your file contains BINARY data.... So, let's remove the binary data: import sys import string def strip_binary ( filename, newname ): test = open ( filename, 'rb') stripped = open (newname, 'wb') data = None while data <> "": data = test.read (1) if data <> "": if data in string.printable: stripped.write (data) stripped.close () test.close () strip_binary ( sys.argv[1], sys.argv[2]) This will remove all characters that are not contained in the string modules PRINTABLE variable. Then you should be able to open the NEW file as a ASCII file, without any issues. You could instead of creating a temporary file, write the data to a list, and then use a SPLIT("\n") on the temporary list, and process that. That would be the rough equivalent of READLINES.... - Ben -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org] On Behalf Of AddisonN@iti-ab.com Sent: Wednesday, January 12, 2005 8:44 AM To: python-win32@python.org Subject: [python-win32] File I/O problem I trying to process a file that was originally created on an AS/400 as a spooled report. The file has been converted to ASCII before sending to me by e-mail. The original report is in Arabic script and so any Arabic script has been mapped to I can't read the whole file in unless I chop out all the (formerly) Arabic characters as read(), readline() or readlines() seems to think its done too early. The problem appears to be that the conversion has produced a byte with hex value 1a and Python is treating this as an end-of-file marker. This I've worked this out by using a Hex Editor and looking at the character after where the read operation stops. The offending character the square (unprintable) character in the file snippet below. Start file snippet >> MK 2005/01/10 ????? ??????(? .?.?) ????????? ??????? - ?????? ????????? ????????? ??? ?? ?? 01 : ???? ???? ?????? ========================================= ??????? << End file snippet Is there a way I can pre-process this file with Python and chop out the characters ( the 1a) I don't want? If I do this: import string report = open('d:\\Software\\PythonScripts\\ear11050110.txt').readlines() report is: >>> report ['MK 2005/01/10 \xc7\xe1\xc8\xe4\xdf \xc7\xe1\xda\xd1\xc8\xed(\xd4 .\xe3.\xda) \xc7\xe1\xe3\xed\xd2\xc7\xe4\xed\xc9 \xc7\xe1\xe3\xe6\xcd\xcf\xc9 - \xca\xde\xd1\xed\xdc\xd1 \xc7\xe1\xe3\xed\xd2\xc7\xe4\xed\xc9 \xc7\xe1\xd4\xe5\xdc\xdc\xd1\xed\xc9 \xdf\xe3\xc7 \xe5\xed \xdd\xed\n', ' 01 : \xdd\xd1\xe6\xda \xcf\xe6\xe1\xc9 \xc7'] Which is everything up to the hex 1a. Thanks for any prompting whatsoever. Nick. ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. Information Technology International (ITI) +44 (0)20 7315 8500 ********************************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050112/0050b170/attachment.htm From zapaya at tom.com Sun Jan 16 14:59:33 2005 From: zapaya at tom.com (=?gb2312?B?1tzGvdH0?=) Date: Sun Jan 16 19:42:24 2005 Subject: [python-win32] Missing python23.dll, trying again Message-ID: <000601c4fbd3$9fff81d0$0501a8c0@babybear> pyghon23.dll -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050116/e2ba7ef9/attachment.htm From Simon.Whitaker at shell.com Mon Jan 17 06:14:51 2005 From: Simon.Whitaker at shell.com (Whitaker, Simon SITI-SITI) Date: Mon Jan 17 06:15:00 2005 Subject: [python-win32] Extended MAPI : ConfigureMsgService Problem Message-ID: <780B7166263B764E850C1F846AC2C887024FA97A@mlb-s-027.asia-pac.shell.com> Hi all, This is a pseudo follow-up post to a previous question regarding creating and configuring MAPI profiles dynamically with Python. There was no posted solution to the question (as far as I can see) so I thought I'd opst again to see if anyone had any new ideas. The code is pretty clearly defined in C on MSDN, but when translated to Python, it fails when configuring services within the created profile. Included below is the code snippet --- from win32com.mapi import mapi, mapiutil, mapitags profileName = "Test" # Initialise mapi.MAPIInitialize(None) profileAdmin = mapi.MAPIAdminProfiles(0) # Get the current profiles profileTable = profileAdmin.GetProfileTable(0) profileRows = mapi.HrQueryAllRows(profileTable, [mapitags.PR_DISPLAY_NAME_A], None, None, 0) # Delete the profile if it already exists for profile in profileRows: if profile[0][1] == profileName: profileAdmin.DeleteProfile(profileName, 0) break # Create the profile profileAdmin.CreateProfile(profileName, None, 0, 0) # Administer the profile services serviceAdmin = profileAdmin.AdminServices(profileName, None, 0, 0) serviceAdmin.CreateMsgService('MSEMS', None, 0, 0) serviceAdmin.CreateMsgService('MSPST MS', None, 0, 0) # Get the service table - looking for service IDs msgServiceTable = serviceAdmin.GetMsgServiceTable(0) msgServiceRows = mapi.HrQueryAllRows(msgServiceTable, None, None, None, 0) # Get the service ID of the first service serviceUID = msgServiceRows[1][0][1] # Configure the MSEMS propsTuple = ((mapitags.PR_PROFILE_UNRESOLVED_NAME, "NAME"),(mapitags.PR_PROFILE_UNRESOLVED_SERVER, "SERVER")) serviceAdmin.ConfigureMsgService(serviceUID, 0, 0, propsTuple) <- !!! FAILS HERE !!! # Uninitialise mapi.MAPIUninitialize() --- The error returned when debugging in PythonWin IDE is --- Traceback (most recent call last): File "createprofile.py", line 41, in ? serviceAdmin.ConfigureMsgService(serviceUID, 0, 0, propsTuple) com_error: (-2147221005, 'Invalid class string', None, None) --- One possible issue is with the serviceUID, which when viewed in the IDE is [}Y?8P?E??-4?fY] which looks pretty interesting. Unfortunately, I have no way of telling if this is the problem, or if there is another issue. All assistance/ideas greatly appreciated. Cheers, Simon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050117/f740daca/attachment.htm From administrator at simonwhitaker.net Sun Jan 16 20:28:25 2005 From: administrator at simonwhitaker.net (administrator@simonwhitaker.net) Date: Mon Jan 17 17:16:47 2005 Subject: [python-win32] Extended MAPI : ConfigureMsgService Problem Message-ID: <20050117042743.681D11E4002@bag.python.org> Hi all, This is a pseudo follow-up post to a previous question regarding creating and configuring MAPI profiles dynamically with Python. There was no posted solution to the question (as far as I can see) so I thought I'd opst again to see if anyone had any new ideas. The code is pretty clearly defined in C on MSDN, but when translated to Python, it fails when configuring services within the created profile. Included below is the code snippet --- from win32com.mapi import mapi, mapiutil, mapitags profileName = "Test" # Initialise mapi.MAPIInitialize(None) profileAdmin = mapi.MAPIAdminProfiles(0) # Get the current profiles profileTable = profileAdmin.GetProfileTable(0) profileRows = mapi.HrQueryAllRows(profileTable, [mapitags.PR_DISPLAY_NAME_A], None, None, 0) # Delete the profile if it already exists for profile in profileRows: if profile[0][1] == profileName: profileAdmin.DeleteProfile(profileName, 0) break # Create the profile profileAdmin.CreateProfile(profileName, None, 0, 0) # Administer the profile services serviceAdmin = profileAdmin.AdminServices(profileName, None, 0, 0) serviceAdmin.CreateMsgService('MSEMS', None, 0, 0) serviceAdmin.CreateMsgService('MSPST MS', None, 0, 0) # Get the service table - looking for service IDs msgServiceTable = serviceAdmin.GetMsgServiceTable(0) msgServiceRows = mapi.HrQueryAllRows(msgServiceTable, None, None, None, 0) # Get the service ID of the first service serviceUID = msgServiceRows[1][0][1] # Configure the MSEMS propsTuple = ((mapitags.PR_PROFILE_UNRESOLVED_NAME, "NAME"),(mapitags.PR_PROFILE_UNRESOLVED_SERVER, "SERVER")) serviceAdmin.ConfigureMsgService(serviceUID, 0, 0, propsTuple) <- !!! FAILS HERE !!! # Uninitialise mapi.MAPIUninitialize() --- The error returned when debugging in PythonWin IDE is --- Traceback (most recent call last): File "createprofile.py", line 41, in ? serviceAdmin.ConfigureMsgService(serviceUID, 0, 0, propsTuple) com_error: (-2147221005, 'Invalid class string', None, None) --- One possible issue is with the serviceUID, which when viewed in the IDE is [}Y8PEŖ4ƒY] which looks pretty interesting. Unfortunately, I have no way of telling if this is the problem, or if there is another issue. All assistance/ideas greatly appreciated. Cheers, Simon From mhammond at skippinet.com.au Mon Jan 17 22:03:11 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon Jan 17 22:03:18 2005 Subject: [python-win32] Extended MAPI : ConfigureMsgService Problem In-Reply-To: <780B7166263B764E850C1F846AC2C887024FA97A@mlb-s-027.asia-pac.shell.com> Message-ID: <092701c4fcd7$f5163ce0$150a0a0a@enfoldsystems.local> > The code is pretty clearly defined in C on MSDN, but when translated to Python, > it fails when configuring services within the created profile. I have got past your immediate stumbling-block, just to hit another. > One possible issue is with the serviceUID, which when viewed in the IDE is > [}Y?8P?E??-4?fY] which looks pretty interesting. It seems very likely that this is a GUID encoded as a binary buffer (being 16 bytes (128 bits) long): Adding: serviceUID = pythoncom.MakeIID(serviceUID, 1) print "now is", serviceUID Results in: now is {607D544A-A7BF-412D-8EC7-E376FF96572C} Traceback (most recent call last): File "\temp\make_profile.py", line 41, in ? serviceAdmin.ConfigureMsgService(serviceUID, 0, 0, propsTuple) # <- !!! FAILS HERE !!! pywintypes.com_error: (-2147221233, 'OLE error 0x8004010f', None, None) 0x8004010f is MAPI_E_NOT_FOUND. This is as far as I got. Mark. -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 2252 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050118/9f4de962/winmail.bin From Simon.Whitaker at shell.com Mon Jan 17 22:52:50 2005 From: Simon.Whitaker at shell.com (Whitaker, Simon SITI-SITI) Date: Mon Jan 17 22:52:57 2005 Subject: [python-win32] Extended MAPI : ConfigureMsgService Problem Message-ID: <780B7166263B764E850C1F846AC2C887024FA981@mlb-s-027.asia-pac.shell.com> Cheers Mark, now we are cooking with Gas! The "MakeIID" works a treat, and the reason why the code then failed immediately after is due to a silly error on my part. From the original post... --- # Administer the profile services serviceAdmin = profileAdmin.AdminServices(profileName, None, 0, 0) serviceAdmin.CreateMsgService('MSEMS', None, 0, 0) serviceAdmin.CreateMsgService('MSPST MS', None, 0, 0) # Get the service table - looking for service IDs msgServiceTable = serviceAdmin.GetMsgServiceTable(0) msgServiceRows = mapi.HrQueryAllRows(msgServiceTable, None, None, None, 0) # Get the service ID of the first service serviceUID = msgServiceRows[1][0][1] --- The last line actually gets the UID of the second service, ie: the MS PST which is why it couldn't be configured as an MSEMS service. Ooops. Changed the last line to "serviceUID = msgServiceRows[0][0][1]" and it works fine. Thanks again - saves me getting VisC installed and trying to write it ;) Simon -----Original Message----- From: Mark Hammond [mailto:mhammond@skippinet.com.au] Sent: Tuesday, 18 January 2005 8:03 AM To: Whitaker, Simon SITI-SITI; python-win32@python.org Subject: RE: [python-win32] Extended MAPI : ConfigureMsgService Problem > The code is pretty clearly defined in C on MSDN, but when translated to Python, > it fails when configuring services within the created profile. I have got past your immediate stumbling-block, just to hit another. > One possible issue is with the serviceUID, which when viewed in the IDE is > [}Y?8P?E??-4?fY] which looks pretty interesting. It seems very likely that this is a GUID encoded as a binary buffer (being 16 bytes (128 bits) long): Adding: serviceUID = pythoncom.MakeIID(serviceUID, 1) print "now is", serviceUID Results in: now is {607D544A-A7BF-412D-8EC7-E376FF96572C} Traceback (most recent call last): File "\temp\make_profile.py", line 41, in ? serviceAdmin.ConfigureMsgService(serviceUID, 0, 0, propsTuple) # <- !!! FAILS HERE !!! pywintypes.com_error: (-2147221233, 'OLE error 0x8004010f', None, None) 0x8004010f is MAPI_E_NOT_FOUND. This is as far as I got. Mark. From gianluca at letreporte.it Tue Jan 18 16:24:02 2005 From: gianluca at letreporte.it (Gianluca Di Carlo) Date: Tue Jan 18 16:22:45 2005 Subject: [python-win32] Strange error Message-ID: <41ED2A12.3040203@letreporte.it> Hi, i'm a new in this list. I'm a strnage problem with a wxpython application when i build a exe file with py2exe. I use a xmlrpc to execute a call to a function in a zope server. Thi function is protect with username and password. So I use the module BasicAuthTransport to authenticate agaist zope server. If I lanch the application from console with python it's all right. If I use py2exe e lanche the executable file I obtain this error: Traceback (most recent call last): File "Main.pyc", line 268, in OnServerConnettiMenu File "xmlrpclib.pyc", line 1029, in __call__ File "xmlrpclib.pyc", line 1316, in __request File "BasicAuthTransport.pyc", line 24, in request File "httplib.pyc", line 712, in endheaders File "httplib.pyc", line 597, in _send_output File "httplib.pyc", line 564, in send File "httplib.pyc", line 532, in connect LookupError: unknown encoding: idna Here the output of py2exe: running py2exe *** searching for required modules *** *** parsing results *** creating python loader for extension 'wx._misc_' creating python loader for extension 'datetime' creating python loader for extension 'zlib' creating python loader for extension '_winreg' creating python loader for extension 'wx._html' creating python loader for extension 'wx._gizmos' creating python loader for extension '_sre' creating python loader for extension '_socket' creating python loader for extension 'wx._windows_' creating python loader for extension 'wx._gdi_' creating python loader for extension 'pyexpat' creating python loader for extension 'wx._controls_' creating python loader for extension '_ssl' creating python loader for extension 'wx._core_' *** finding dlls needed *** *** create binaries *** *** byte compile python files *** skipping byte-compilation of C:\IntranetMessenger\BasicAuthTransport.py to BasicAuthTransport.pyc byte-compiling C:\IntranetMessenger\Main.py to Main.pyc skipping byte-compilation of C:\IntranetMessenger\NewMessage.py to NewMessage.pyc byte-compiling C:\IntranetMessenger\autentificazione.py to autentificazione.pyc byte-compiling C:\IntranetMessenger\build\bdist.win32\winexe\temp\_socket.py to _socket.pyc byte-compiling C:\IntranetMessenger\build\bdist.win32\winexe\temp\_sre.py to _sre.pyc byte-compiling C:\IntranetMessenger\build\bdist.win32\winexe\temp\_ssl.py to _ssl.pyc byte-compiling C:\IntranetMessenger\build\bdist.win32\winexe\temp\_winreg.py to _winreg.pyc byte-compiling C:\IntranetMessenger\build\bdist.win32\winexe\temp\datetime.py to datetime.pyc byte-compiling C:\IntranetMessenger\build\bdist.win32\winexe\temp\pyexpat.py to pyexpat.pyc byte-compiling C:\IntranetMessenger\build\bdist.win32\winexe\temp\wx._controls_.py to wx\_controls_.pyc byte-compiling C:\IntranetMessenger\build\bdist.win32\winexe\temp\wx._core_.py to wx\_core_.pyc byte-compiling C:\IntranetMessenger\build\bdist.win32\winexe\temp\wx._gdi_.py to wx\_gdi_.pyc byte-compiling C:\IntranetMessenger\build\bdist.win32\winexe\temp\wx._gizmos.py to wx\_gizmos.pyc byte-compiling C:\IntranetMessenger\build\bdist.win32\winexe\temp\wx._html.py to wx\_html.pyc byte-compiling C:\IntranetMessenger\build\bdist.win32\winexe\temp\wx._misc_.py to wx\_misc_.pyc byte-compiling C:\IntranetMessenger\build\bdist.win32\winexe\temp\wx._windows_.py to wx\_windows_.pyc byte-compiling C:\IntranetMessenger\build\bdist.win32\winexe\temp\zlib.py to zlib.pyc skipping byte-compilation of C:\IntranetMessenger\cPAMIE.py to cPAMIE.pyc skipping byte-compilation of C:\IntranetMessenger\configurazione.py to configurazione.pyc skipping byte-compilation of C:\IntranetMessenger\feedparser.py to feedparser.pyc skipping byte-compilation of C:\IntranetMessenger\lastcontents.py to lastcontents.pyc skipping byte-compilation of C:\IntranetMessenger\messengerThread.py to messengerThread.pyc skipping byte-compilation of C:\IntranetMessenger\utils.py to utils.pyc skipping byte-compilation of C:\IntranetMessenger\ztaskbar.py to ztaskbar.pyc skipping byte-compilation of D:\Python23\lib\StringIO.py to StringIO.pyc skipping byte-compilation of D:\Python23\lib\UserDict.py to UserDict.pyc skipping byte-compilation of D:\Python23\lib\__future__.py to __future__.pyc skipping byte-compilation of D:\Python23\lib\_strptime.py to _strptime.pyc skipping byte-compilation of D:\Python23\lib\atexit.py to atexit.pyc skipping byte-compilation of D:\Python23\lib\base64.py to base64.pyc skipping byte-compilation of D:\Python23\lib\bisect.py to bisect.pyc skipping byte-compilation of D:\Python23\lib\calendar.py to calendar.pyc skipping byte-compilation of D:\Python23\lib\cgi.py to cgi.pyc skipping byte-compilation of D:\Python23\lib\codecs.py to codecs.pyc skipping byte-compilation of D:\Python23\lib\copy.py to copy.pyc skipping byte-compilation of D:\Python23\lib\copy_reg.py to copy_reg.pyc skipping byte-compilation of D:\Python23\lib\dis.py to dis.pyc skipping byte-compilation of D:\Python23\lib\dummy_thread.py to dummy_thread.pyc skipping byte-compilation of D:\Python23\lib\encodings\__init__.py to encodings\__init__.pyc skipping byte-compilation of D:\Python23\lib\encodings\aliases.py to encodings\aliases.pyc skipping byte-compilation of D:\Python23\lib\fnmatch.py to fnmatch.pyc skipping byte-compilation of D:\Python23\lib\ftplib.py to ftplib.pyc skipping byte-compilation of D:\Python23\lib\getopt.py to getopt.pyc skipping byte-compilation of D:\Python23\lib\getpass.py to getpass.pyc skipping byte-compilation of D:\Python23\lib\glob.py to glob.pyc skipping byte-compilation of D:\Python23\lib\gopherlib.py to gopherlib.pyc skipping byte-compilation of D:\Python23\lib\gzip.py to gzip.pyc skipping byte-compilation of D:\Python23\lib\htmlentitydefs.py to htmlentitydefs.pyc skipping byte-compilation of D:\Python23\lib\httplib.py to httplib.pyc skipping byte-compilation of D:\Python23\lib\inspect.py to inspect.pyc skipping byte-compilation of D:\Python23\lib\linecache.py to linecache.pyc skipping byte-compilation of D:\Python23\lib\locale.py to locale.pyc skipping byte-compilation of D:\Python23\lib\macpath.py to macpath.pyc skipping byte-compilation of D:\Python23\lib\macurl2path.py to macurl2path.pyc skipping byte-compilation of D:\Python23\lib\markupbase.py to markupbase.pyc skipping byte-compilation of D:\Python23\lib\mimetools.py to mimetools.pyc skipping byte-compilation of D:\Python23\lib\mimetypes.py to mimetypes.pyc skipping byte-compilation of D:\Python23\lib\ntpath.py to ntpath.pyc skipping byte-compilation of D:\Python23\lib\nturl2path.py to nturl2path.pyc skipping byte-compilation of D:\Python23\lib\opcode.py to opcode.pyc skipping byte-compilation of D:\Python23\lib\os.py to os.pyc skipping byte-compilation of D:\Python23\lib\os2emxpath.py to os2emxpath.pyc skipping byte-compilation of D:\Python23\lib\popen2.py to popen2.pyc skipping byte-compilation of D:\Python23\lib\posixpath.py to posixpath.pyc skipping byte-compilation of D:\Python23\lib\pprint.py to pprint.pyc skipping byte-compilation of D:\Python23\lib\quopri.py to quopri.pyc skipping byte-compilation of D:\Python23\lib\random.py to random.pyc skipping byte-compilation of D:\Python23\lib\re.py to re.pyc skipping byte-compilation of D:\Python23\lib\repr.py to repr.pyc skipping byte-compilation of D:\Python23\lib\rfc822.py to rfc822.pyc skipping byte-compilation of D:\Python23\lib\sgmllib.py to sgmllib.pyc skipping byte-compilation of D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\__init__.py to wx\__init__.pyc skipping byte-compilation of D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\__version__.py to wx\__version__.pyc skipping byte-compilation of D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\_controls.py to wx\_controls.pyc skipping byte-compilation of D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\_core.py to wx\_core.pyc skipping byte-compilation of D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\_gdi.py to wx\_gdi.pyc skipping byte-compilation of D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\_misc.py to wx\_misc.pyc skipping byte-compilation of D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\_windows.py to wx\_windows.pyc skipping byte-compilation of D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\gizmos.py to wx\gizmos.pyc skipping byte-compilation of D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\html.py to wx\html.pyc skipping byte-compilation of D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\lib\__init__.py to wx\lib\__init__.pyc skipping byte-compilation of D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\lib\buttons.py to wx\lib\buttons.pyc skipping byte-compilation of D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\lib\imageutils.py to wx\lib\imageutils.pyc skipping byte-compilation of D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\lib\mixins\__init__.py to wx\lib\mixins\__init__.pyc skipping byte-compilation of D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\lib\mixins\listctrl.py to wx\lib\mixins\listctrl.pyc skipping byte-compilation of D:\Python23\lib\socket.py to socket.pyc skipping byte-compilation of D:\Python23\lib\sre.py to sre.pyc skipping byte-compilation of D:\Python23\lib\sre_compile.py to sre_compile.pyc skipping byte-compilation of D:\Python23\lib\sre_constants.py to sre_constants.pyc skipping byte-compilation of D:\Python23\lib\sre_parse.py to sre_parse.pyc skipping byte-compilation of D:\Python23\lib\stat.py to stat.pyc skipping byte-compilation of D:\Python23\lib\string.py to string.pyc skipping byte-compilation of D:\Python23\lib\tempfile.py to tempfile.pyc skipping byte-compilation of D:\Python23\lib\threading.py to threading.pyc skipping byte-compilation of D:\Python23\lib\token.py to token.pyc skipping byte-compilation of D:\Python23\lib\tokenize.py to tokenize.pyc skipping byte-compilation of D:\Python23\lib\traceback.py to traceback.pyc skipping byte-compilation of D:\Python23\lib\types.py to types.pyc skipping byte-compilation of D:\Python23\lib\urllib.py to urllib.pyc skipping byte-compilation of D:\Python23\lib\urllib2.py to urllib2.pyc skipping byte-compilation of D:\Python23\lib\urlparse.py to urlparse.pyc skipping byte-compilation of D:\Python23\lib\uu.py to uu.pyc skipping byte-compilation of D:\Python23\lib\warnings.py to warnings.pyc skipping byte-compilation of D:\Python23\lib\weakref.py to weakref.pyc skipping byte-compilation of D:\Python23\lib\webbrowser.py to webbrowser.pyc skipping byte-compilation of D:\Python23\lib\xml\__init__.py to xml\__init__.pyc skipping byte-compilation of D:\Python23\lib\xml\parsers\__init__.py to xml\parsers\__init__.pyc skipping byte-compilation of D:\Python23\lib\xml\parsers\expat.py to xml\parsers\expat.pyc skipping byte-compilation of D:\Python23\lib\xml\sax\__init__.py to xml\sax\__init__.pyc skipping byte-compilation of D:\Python23\lib\xml\sax\_exceptions.py to xml\sax\_exceptions.pyc skipping byte-compilation of D:\Python23\lib\xml\sax\expatreader.py to xml\sax\expatreader.pyc skipping byte-compilation of D:\Python23\lib\xml\sax\handler.py to xml\sax\handler.pyc skipping byte-compilation of D:\Python23\lib\xml\sax\saxutils.py to xml\sax\saxutils.pyc skipping byte-compilation of D:\Python23\lib\xml\sax\xmlreader.py to xml\sax\xmlreader.pyc skipping byte-compilation of D:\Python23\lib\xmllib.py to xmllib.pyc skipping byte-compilation of D:\Python23\lib\xmlrpclib.py to xmlrpclib.pyc *** copy extensions *** *** copy dlls *** setting sys.winver for 'C:\IntranetMessenger\dist\python23.dll' to 'Z Intranet Messenger' copying D:\Python23\lib\site-packages\py2exe\run_w.exe -> C:\IntranetMessenger\dist\IntranetMessenger.exe The following modules appear to be missing ['cjkcodecs.aliases', 'iconv_codec', 'mx.Tidy', 'pywintypes', 'timeoutsocket', 'win32com.client', 'win32con', 'win32gui', 'wx.BitmapFromImage', 'wx.EmptyIcon', 'wx.NewId'] Can anyone help me? Best regards Gianluca Di Carlo From dsvmag at baboutini.net Tue Jan 18 21:43:03 2005 From: dsvmag at baboutini.net (Cathie & Arnaud) Date: Tue Jan 18 21:52:58 2005 Subject: [python-win32] Window capture using WM_PRINT and Python Message-ID: <41ED74D7.2080001@baboutini.net> Hi ! I'm a Java developper and I wish to make a capture of an offscreen window (on WinXP). It's not possible in Java, so I use a python script and WM_PRINT, but it doesn't seem to work. Could someone have a look at my script and give me any advise ? (That's my first script in python, be kind !) TIA -- Arnaud my python script : python snap.py GraphicalContext_handle image_handle -------------------------------------------------------------------------------------------------- snap.py : " import win32api, win32con, sys win32api.SendMessage(sys.argv[2], win32con.WM_PAINT, sys.argv[3], 0) win32api.SendMessage(sys.argv[2], win32con.WM_PRINT, sys.argv[3], win32con.PRF_CHILDREN | win32con.PRF_CLIENT | win32con.PRF_OWNED) " ------------------------------------------------------------------------------------------------ snippet from Snapshot.java : " public static Image snapshot(Composite bean) { GC gc = new GC(bean); final Image image = new Image (null, bean.getBounds().width, bean.getBounds().height); String commmand = "python snap.py " + gc.handle + " " + image.handle; Runtime rt = Runtime.getRuntime(); try { Process p = rt.exec(command); } catch (.....) gc.dispose(); return image; } " From mhammond at skippinet.com.au Wed Jan 19 00:08:27 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed Jan 19 00:08:36 2005 Subject: [python-win32] Strange error In-Reply-To: <41ED2A12.3040203@letreporte.it> Message-ID: <0aa401c4fdb2$9f0c3580$150a0a0a@enfoldsystems.local> It is likely that py2exe is not pulling in the "encodings" package. I generally get around this by adding: packages="encodings" To the py2exe options. Something like: py2exe_options = {"packages": "encodings,somethingelse"} setup(windows=["foo.py"], options = {"py2exe" : py2exe_options}) Mark. > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of Gianluca Di Carlo > Sent: Wednesday, 19 January 2005 2:24 AM > To: python-win32@python.org > Subject: [python-win32] Strange error > > > Hi, i'm a new in this list. > I'm a strnage problem with a wxpython application when i build a exe > file with py2exe. > I use a xmlrpc to execute a call to a function in a zope server. Thi > function is protect with username and password. So I use the module > BasicAuthTransport to authenticate agaist zope server. If I lanch the > application from console with python it's all right. > If I use py2exe e lanche the executable file I obtain this error: > > Traceback (most recent call last): > File "Main.pyc", line 268, in OnServerConnettiMenu > File "xmlrpclib.pyc", line 1029, in __call__ > File "xmlrpclib.pyc", line 1316, in __request > File "BasicAuthTransport.pyc", line 24, in request > File "httplib.pyc", line 712, in endheaders > File "httplib.pyc", line 597, in _send_output > File "httplib.pyc", line 564, in send > File "httplib.pyc", line 532, in connect > LookupError: unknown encoding: idna > > Here the output of py2exe: > > running py2exe > *** searching for required modules *** > *** parsing results *** > creating python loader for extension 'wx._misc_' > creating python loader for extension 'datetime' > creating python loader for extension 'zlib' > creating python loader for extension '_winreg' > creating python loader for extension 'wx._html' > creating python loader for extension 'wx._gizmos' > creating python loader for extension '_sre' > creating python loader for extension '_socket' > creating python loader for extension 'wx._windows_' > creating python loader for extension 'wx._gdi_' > creating python loader for extension 'pyexpat' > creating python loader for extension 'wx._controls_' > creating python loader for extension '_ssl' > creating python loader for extension 'wx._core_' > *** finding dlls needed *** > *** create binaries *** > *** byte compile python files *** > skipping byte-compilation of > C:\IntranetMessenger\BasicAuthTransport.py > to BasicAuthTransport.pyc > byte-compiling C:\IntranetMessenger\Main.py to Main.pyc > skipping byte-compilation of C:\IntranetMessenger\NewMessage.py to > NewMessage.pyc > byte-compiling C:\IntranetMessenger\autentificazione.py to > autentificazione.pyc > byte-compiling > C:\IntranetMessenger\build\bdist.win32\winexe\temp\_socket.py > to _socket.pyc > byte-compiling > C:\IntranetMessenger\build\bdist.win32\winexe\temp\_sre.py to _sre.pyc > byte-compiling > C:\IntranetMessenger\build\bdist.win32\winexe\temp\_ssl.py to _ssl.pyc > byte-compiling > C:\IntranetMessenger\build\bdist.win32\winexe\temp\_winreg.py > to _winreg.pyc > byte-compiling > C:\IntranetMessenger\build\bdist.win32\winexe\temp\datetime.py to > datetime.pyc > byte-compiling > C:\IntranetMessenger\build\bdist.win32\winexe\temp\pyexpat.py > to pyexpat.pyc > byte-compiling > C:\IntranetMessenger\build\bdist.win32\winexe\temp\wx._control > s_.py to > wx\_controls_.pyc > byte-compiling > C:\IntranetMessenger\build\bdist.win32\winexe\temp\wx._core_.py to > wx\_core_.pyc > byte-compiling > C:\IntranetMessenger\build\bdist.win32\winexe\temp\wx._gdi_.py to > wx\_gdi_.pyc > byte-compiling > C:\IntranetMessenger\build\bdist.win32\winexe\temp\wx._gizmos.py to > wx\_gizmos.pyc > byte-compiling > C:\IntranetMessenger\build\bdist.win32\winexe\temp\wx._html.py to > wx\_html.pyc > byte-compiling > C:\IntranetMessenger\build\bdist.win32\winexe\temp\wx._misc_.py to > wx\_misc_.pyc > byte-compiling > C:\IntranetMessenger\build\bdist.win32\winexe\temp\wx._windows_.py to > wx\_windows_.pyc > byte-compiling > C:\IntranetMessenger\build\bdist.win32\winexe\temp\zlib.py to zlib.pyc > skipping byte-compilation of C:\IntranetMessenger\cPAMIE.py > to cPAMIE.pyc > skipping byte-compilation of > C:\IntranetMessenger\configurazione.py to > configurazione.pyc > skipping byte-compilation of C:\IntranetMessenger\feedparser.py to > feedparser.pyc > skipping byte-compilation of C:\IntranetMessenger\lastcontents.py to > lastcontents.pyc > skipping byte-compilation of > C:\IntranetMessenger\messengerThread.py to > messengerThread.pyc > skipping byte-compilation of C:\IntranetMessenger\utils.py to > utils.pyc > skipping byte-compilation of C:\IntranetMessenger\ztaskbar.py to > ztaskbar.pyc > skipping byte-compilation of D:\Python23\lib\StringIO.py to > StringIO.pyc > skipping byte-compilation of D:\Python23\lib\UserDict.py to > UserDict.pyc > skipping byte-compilation of D:\Python23\lib\__future__.py to > __future__.pyc > skipping byte-compilation of D:\Python23\lib\_strptime.py to > _strptime.pyc > skipping byte-compilation of D:\Python23\lib\atexit.py to atexit.pyc > skipping byte-compilation of D:\Python23\lib\base64.py to base64.pyc > skipping byte-compilation of D:\Python23\lib\bisect.py to bisect.pyc > skipping byte-compilation of D:\Python23\lib\calendar.py to > calendar.pyc > skipping byte-compilation of D:\Python23\lib\cgi.py to cgi.pyc > skipping byte-compilation of D:\Python23\lib\codecs.py to codecs.pyc > skipping byte-compilation of D:\Python23\lib\copy.py to copy.pyc > skipping byte-compilation of D:\Python23\lib\copy_reg.py to > copy_reg.pyc > skipping byte-compilation of D:\Python23\lib\dis.py to dis.pyc > skipping byte-compilation of D:\Python23\lib\dummy_thread.py to > dummy_thread.pyc > skipping byte-compilation of D:\Python23\lib\encodings\__init__.py to > encodings\__init__.pyc > skipping byte-compilation of D:\Python23\lib\encodings\aliases.py to > encodings\aliases.pyc > skipping byte-compilation of D:\Python23\lib\fnmatch.py to fnmatch.pyc > skipping byte-compilation of D:\Python23\lib\ftplib.py to ftplib.pyc > skipping byte-compilation of D:\Python23\lib\getopt.py to getopt.pyc > skipping byte-compilation of D:\Python23\lib\getpass.py to getpass.pyc > skipping byte-compilation of D:\Python23\lib\glob.py to glob.pyc > skipping byte-compilation of D:\Python23\lib\gopherlib.py to > gopherlib.pyc > skipping byte-compilation of D:\Python23\lib\gzip.py to gzip.pyc > skipping byte-compilation of D:\Python23\lib\htmlentitydefs.py to > htmlentitydefs.pyc > skipping byte-compilation of D:\Python23\lib\httplib.py to httplib.pyc > skipping byte-compilation of D:\Python23\lib\inspect.py to inspect.pyc > skipping byte-compilation of D:\Python23\lib\linecache.py to > linecache.pyc > skipping byte-compilation of D:\Python23\lib\locale.py to locale.pyc > skipping byte-compilation of D:\Python23\lib\macpath.py to macpath.pyc > skipping byte-compilation of D:\Python23\lib\macurl2path.py to > macurl2path.pyc > skipping byte-compilation of D:\Python23\lib\markupbase.py to > markupbase.pyc > skipping byte-compilation of D:\Python23\lib\mimetools.py to > mimetools.pyc > skipping byte-compilation of D:\Python23\lib\mimetypes.py to > mimetypes.pyc > skipping byte-compilation of D:\Python23\lib\ntpath.py to ntpath.pyc > skipping byte-compilation of D:\Python23\lib\nturl2path.py to > nturl2path.pyc > skipping byte-compilation of D:\Python23\lib\opcode.py to opcode.pyc > skipping byte-compilation of D:\Python23\lib\os.py to os.pyc > skipping byte-compilation of D:\Python23\lib\os2emxpath.py to > os2emxpath.pyc > skipping byte-compilation of D:\Python23\lib\popen2.py to popen2.pyc > skipping byte-compilation of D:\Python23\lib\posixpath.py to > posixpath.pyc > skipping byte-compilation of D:\Python23\lib\pprint.py to pprint.pyc > skipping byte-compilation of D:\Python23\lib\quopri.py to quopri.pyc > skipping byte-compilation of D:\Python23\lib\random.py to random.pyc > skipping byte-compilation of D:\Python23\lib\re.py to re.pyc > skipping byte-compilation of D:\Python23\lib\repr.py to repr.pyc > skipping byte-compilation of D:\Python23\lib\rfc822.py to rfc822.pyc > skipping byte-compilation of D:\Python23\lib\sgmllib.py to sgmllib.pyc > skipping byte-compilation of > D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\__init__.py to > wx\__init__.pyc > skipping byte-compilation of > D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\__versio > n__.py to > wx\__version__.pyc > skipping byte-compilation of > D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\_controls.py to > wx\_controls.pyc > skipping byte-compilation of > D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\_core.py to > wx\_core.pyc > skipping byte-compilation of > D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\_gdi.py > to wx\_gdi.pyc > skipping byte-compilation of > D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\_misc.py to > wx\_misc.pyc > skipping byte-compilation of > D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\_windows.py to > wx\_windows.pyc > skipping byte-compilation of > D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\gizmos.py to > wx\gizmos.pyc > skipping byte-compilation of > D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\html.py > to wx\html.pyc > skipping byte-compilation of > D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\lib\__in > it__.py to > wx\lib\__init__.pyc > skipping byte-compilation of > D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\lib\butt > ons.py to > wx\lib\buttons.pyc > skipping byte-compilation of > D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\lib\imag > eutils.py > to wx\lib\imageutils.pyc > skipping byte-compilation of > D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\lib\mixi > ns\__init__.py > to wx\lib\mixins\__init__.pyc > skipping byte-compilation of > D:\Python23\lib\site-packages\wx-2.5.3-msw-unicode\wx\lib\mixi > ns\listctrl.py > to wx\lib\mixins\listctrl.pyc > skipping byte-compilation of D:\Python23\lib\socket.py to socket.pyc > skipping byte-compilation of D:\Python23\lib\sre.py to sre.pyc > skipping byte-compilation of D:\Python23\lib\sre_compile.py to > sre_compile.pyc > skipping byte-compilation of D:\Python23\lib\sre_constants.py to > sre_constants.pyc > skipping byte-compilation of D:\Python23\lib\sre_parse.py to > sre_parse.pyc > skipping byte-compilation of D:\Python23\lib\stat.py to stat.pyc > skipping byte-compilation of D:\Python23\lib\string.py to string.pyc > skipping byte-compilation of D:\Python23\lib\tempfile.py to > tempfile.pyc > skipping byte-compilation of D:\Python23\lib\threading.py to > threading.pyc > skipping byte-compilation of D:\Python23\lib\token.py to token.pyc > skipping byte-compilation of D:\Python23\lib\tokenize.py to > tokenize.pyc > skipping byte-compilation of D:\Python23\lib\traceback.py to > traceback.pyc > skipping byte-compilation of D:\Python23\lib\types.py to types.pyc > skipping byte-compilation of D:\Python23\lib\urllib.py to urllib.pyc > skipping byte-compilation of D:\Python23\lib\urllib2.py to urllib2.pyc > skipping byte-compilation of D:\Python23\lib\urlparse.py to > urlparse.pyc > skipping byte-compilation of D:\Python23\lib\uu.py to uu.pyc > skipping byte-compilation of D:\Python23\lib\warnings.py to > warnings.pyc > skipping byte-compilation of D:\Python23\lib\weakref.py to weakref.pyc > skipping byte-compilation of D:\Python23\lib\webbrowser.py to > webbrowser.pyc > skipping byte-compilation of D:\Python23\lib\xml\__init__.py to > xml\__init__.pyc > skipping byte-compilation of > D:\Python23\lib\xml\parsers\__init__.py to > xml\parsers\__init__.pyc > skipping byte-compilation of D:\Python23\lib\xml\parsers\expat.py to > xml\parsers\expat.pyc > skipping byte-compilation of D:\Python23\lib\xml\sax\__init__.py to > xml\sax\__init__.pyc > skipping byte-compilation of > D:\Python23\lib\xml\sax\_exceptions.py to > xml\sax\_exceptions.pyc > skipping byte-compilation of > D:\Python23\lib\xml\sax\expatreader.py to > xml\sax\expatreader.pyc > skipping byte-compilation of D:\Python23\lib\xml\sax\handler.py to > xml\sax\handler.pyc > skipping byte-compilation of D:\Python23\lib\xml\sax\saxutils.py to > xml\sax\saxutils.pyc > skipping byte-compilation of D:\Python23\lib\xml\sax\xmlreader.py to > xml\sax\xmlreader.pyc > skipping byte-compilation of D:\Python23\lib\xmllib.py to xmllib.pyc > skipping byte-compilation of D:\Python23\lib\xmlrpclib.py to > xmlrpclib.pyc > *** copy extensions *** > *** copy dlls *** > setting sys.winver for 'C:\IntranetMessenger\dist\python23.dll' to 'Z > Intranet Messenger' > copying D:\Python23\lib\site-packages\py2exe\run_w.exe -> > C:\IntranetMessenger\dist\IntranetMessenger.exe > The following modules appear to be missing > ['cjkcodecs.aliases', 'iconv_codec', 'mx.Tidy', 'pywintypes', > 'timeoutsocket', 'win32com.client', 'win32con', 'win32gui', > 'wx.BitmapFromImage', 'wx.EmptyIcon', 'wx.NewId'] > > Can anyone help me? > > Best regards > > Gianluca Di Carlo > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From gagenellina at softlab.com.ar Wed Jan 19 01:02:06 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Wed Jan 19 01:08:54 2005 Subject: [python-win32] Re: Window capture using WM_PRINT and Python In-Reply-To: <20050118230836.DB1B21E4018@bag.python.org> References: <20050118230836.DB1B21E4018@bag.python.org> Message-ID: <6.2.0.14.0.20050118203141.03308d60@192.168.0.115> At 18/1/2005 20:08, you wrote: >I'm a Java developper and I wish to make a capture of an offscreen window >(on WinXP). It's not possible in Java, so I use a python script and >WM_PRINT, but it doesn't seem to work. I think device contexts are not shareable between processes, so you can't pass a DC handle. Anyway, try to stay in Java - running a Python script to send some windows messages looks crazy to me! You're using SWT, dont you? I'm almost sure it *is* possible to capture the image, but ask in a Java or Eclipse list for help. From bluedust at swbell.net Wed Jan 19 02:19:23 2005 From: bluedust at swbell.net (Chris R. Martin) Date: Wed Jan 19 02:17:23 2005 Subject: [python-win32] python win32 demos question Message-ID: <41EDB59B.30409@swbell.net> In the win32\demos directory, there is a script called win32gui_dialog.py. Near the end of this script, there are the following lines: def DemoModal(): w=DemoWindow() w.DoModal() ## w.CreateWindow() ## win32gui.PumpMessages() ## # Not sure how to kill this loop. I realize that CreateWindow() and PumpMessages() is not needed by a dialog since dialogs have a "built-in" window procedure. However, the comment does seem to be correct - using a PumpMessages() loop does NOT end the python process when this function supposedly exits. In fact, it seems like this function never returns, even when the main window is closed. Shouldn't it? http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/win32gui_.28more.29__PumpMessages_meth.html How does one write a windows procedure and properly handle messages in a loop using win32 python? Do I need to manually do this? Maybe create a new thread for the rest of the program and sit and spin for messages in the main thread? Or maybe vice versa? Any examples of Python using a GUI/main loop? Thanks, Chris -- Guybrush: How can you see without eyeballs? Murray: How can you walk around without a brain? Some things no one can answer. From mhammond at skippinet.com.au Wed Jan 19 03:45:47 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed Jan 19 03:45:55 2005 Subject: [python-win32] python win32 demos question In-Reply-To: <41EDB59B.30409@swbell.net> Message-ID: <0acf01c4fdd0$fc03d130$150a0a0a@enfoldsystems.local> > In the win32\demos directory, there is a script called > win32gui_dialog.py. Near the end of this script, there are > the following > lines: That script obviously had a quick bash at it and it failed :) I have fixed the demo and will attach it in private mail. The upshot is: win32gui.PumpMessages() will run until the thread gets a WM_QUIT message, via someone calling PostQuitMessage(). The demo had this in the WM_DESTROY handler for the dialog itself which was wrong for 2 reasons: * This is not needed when the dialog is a "normal" dialog. * When used as a Window, WM_DESTROY is not automatically sent - someone needs to call DestroyWindow (rather than the EndDialog needed for the "normal" dialog). The fix for this is to have WM_CLOSE call DestroyWindow(), which then triggers the WM_DESTROY, which then calls PostQuitMessage (whew). Mark From Simon.Whitaker at shell.com Wed Jan 19 05:49:13 2005 From: Simon.Whitaker at shell.com (Whitaker, Simon SITI-SITI) Date: Wed Jan 19 05:49:23 2005 Subject: [python-win32] Extended MAPI : ConfigureMsgService Problem Message-ID: <780B7166263B764E850C1F846AC2C887024FA999@mlb-s-027.asia-pac.shell.com> Here you go - a more complete version. Script creates a new profile, adds and configures a personal and private store and then lists all of the top level folders. Comments welcome, but be gentle with me - I'm still learning! --- from win32com.mapi import mapi, mapiutil, mapitags import pythoncom import re profileName = "Test" # Initialise mapi.MAPIInitialize(None) #mapi.MAPIInitialize((mapi.MAPI_INIT_VERSION, mapi.MAPI_NT_SERVICE)) # Get the handle to administer the profiles profileAdmin = mapi.MAPIAdminProfiles(0) # Get the current profiles profileTable=profileAdmin.GetProfileTable(0) profileRows = mapi.HrQueryAllRows(profileTable, [mapitags.PR_DISPLAY_NAME_A], None, None, 0) # Delete the profile if it already exists for profile in profileRows: if profile[0][1] == profileName: profileAdmin.DeleteProfile(profileName, 0) break # Create the profile profileAdmin.CreateProfile(profileName, None, 0, 0) # Administer the profile services serviceAdmin = profileAdmin.AdminServices(profileName, None, 0, 0) serviceAdmin.CreateMsgService('MSEMS', None, 0, 0) # Add an Exchange service serviceAdmin.CreateMsgService('MSPST MS', None, 0, 0) # Add a .pst file # Get the service table - looking for service IDs msgServiceTable = serviceAdmin.GetMsgServiceTable(0) msgServiceRows = mapi.HrQueryAllRows(msgServiceTable, [mapitags.PR_SERVICE_UID], None, None, 0) # Get the service ID of the MSEMS service (first) serviceUID = msgServiceRows[0][0][1] serviceUID = pythoncom.MakeIID(serviceUID, 1) # Configure the Exchange Service propsTuple = ((mapitags.PR_PROFILE_UNRESOLVED_NAME, "USER"),(mapitags.PR_PROFILE_UNRESOLVED_SERVER, "SERVER")) serviceAdmin.ConfigureMsgService(serviceUID, 0, 0, propsTuple) # Get the service ID of the MS PST service (last) serviceUID = msgServiceRows[-1][0][1] serviceUID = pythoncom.MakeIID(serviceUID, 1) # Configure the .pst file PR_PST_PATH = int(0x6700001E) # This tag is not defined in mapitags? propsTuple = ((mapitags.PR_DISPLAY_NAME_A, "Temp"), (PR_PST_PATH, r"c:\temp.pst")) serviceAdmin.ConfigureMsgService(serviceUID, 0, 0, propsTuple) # Now logon to the profile session = mapi.MAPILogonEx(0, profileName, None, mapi.MAPI_EXTENDED | mapi.MAPI_NEW_SESSION | mapi.MAPI_NO_MAIL) #session = mapi.MAPILogonEx(0, profileName, None, mapi.MAPI_EXTENDED | mapi.MAPI_NEW_SESSION | mapi.MAPI_NO_MAIL | mapi.MAPI_NT_SERVICE) # Get the EMS, PF and PST store IDs msgStoresTable = session.GetMsgStoresTable(0) propTags = [mapitags.PR_PROVIDER_DISPLAY_A, mapitags.PR_DISPLAY_NAME_A, mapitags.PR_ENTRYID] msgStoresRows = mapi.HrQueryAllRows(msgStoresTable, propTags, None, None, 0) # Now iterate through each store and print out the top level folder names for msgStore in msgStoresRows: msgStoreID = msgStore[2][1] msgStoreName = msgStore[1][1] if (msgStore[0][1] == "Microsoft Exchange Server" or "Microsoft Exchange Message Store") and re.search("^Mailbox", msgStore[1][1]): msgStoreType = "private" subtreeEIDTag = mapitags.PR_IPM_SUBTREE_ENTRYID elif (msgStore[0][1] == "Microsoft Exchange Server" or "Microsoft Exchange Message Store") and msgStore[1][1] == "Public Folders": msgStoreType = "public" subtreeEIDTag = mapitags.PR_IPM_PUBLIC_FOLDERS_ENTRYID elif msgStore[0][1] == "Personal Folders" and re.search("^Temp", msgStore[1][1]): msgStoreType = "personal" subtreeEIDTag = mapitags.PR_IPM_SUBTREE_ENTRYID #Use your MAPI session to call the IMAPISession::OpenMsgStore method. msgStore = session.OpenMsgStore(0, msgStoreID, None, mapi.MDB_NO_DIALOG | mapi.MAPI_BEST_ACCESS) #Use the resulting message database pointer to call the IMAPIProp::GetProps method for the PR_IPM_SUBTREE_ENTRYID property. hr, props = msgStore.GetProps((subtreeEIDTag,), 0) subtreeEID = props[0][1] #Call the IMsgStore::OpenEntry method with the entry identifier to get an IMAPIFolder pointer. subtreeFolder = msgStore.OpenEntry(subtreeEID, None, 0) #Call the IMAPIContainer::GetHierarchyTable method to get a table of the contents of the folder. subtreeFolderHierarchy = subtreeFolder.GetHierarchyTable(0) #Call the IMAPITable::QueryRows method to list the folders in the top-level folder. subtreeFolderHierarchyRows = mapi.HrQueryAllRows(subtreeFolderHierarchy, [mapitags.PR_DISPLAY_NAME_A], None, None, 0) # Print store name print "\n" + msgStoreName + "\n" # Print out the folder name for row in subtreeFolderHierarchyRows: foldername = "\t" + row[0][1] print foldername #servicemanager.LogInfoMsg(foldername) # Uninitialise mapi.MAPIUninitialize() --- From niki at vintech.bg Wed Jan 19 09:36:13 2005 From: niki at vintech.bg (Niki Spahiev) Date: Wed Jan 19 09:36:18 2005 Subject: [python-win32] Window capture using WM_PRINT and Python In-Reply-To: <41ED74D7.2080001@baboutini.net> References: <41ED74D7.2080001@baboutini.net> Message-ID: <41EE1BFD.7050705@vintech.bg> Cathie & Arnaud wrote: > Hi ! > > I'm a Java developper and I wish to make a capture of an offscreen > window (on WinXP). It's not possible in Java, so I use a python script > and WM_PRINT, but it doesn't seem to work. > > Could someone have a look at my script and give me any advise ? (That's > my first script in python, be kind !) > > TIA > import win32api, win32con, sys # sys.argv[0] is script name hwnd = int(sys.argv[1]) hdc = int(sys.argv[2]) win32api.SendMessage(hwnd, win32con.WM_PAINT, hdc, 0) win32api.SendMessage(hwnd, win32con.WM_PRINT, hdc, win32con.PRF_CHILDREN | win32con.PRF_CLIENT | win32con.PRF_OWNED) check that hdc is valid DC handle. HTH Niki Spahiev From python at kareta.de Wed Jan 19 12:50:31 2005 From: python at kareta.de (python@kareta.de) Date: Wed Jan 19 13:05:51 2005 Subject: [python-win32] Re: remote copy wiht compress/decompress Message-ID: <1106135431.41ee49874a21b@webmail.ldc.de> Hi, thank you all for your hints and helps. I have now a working solution. But there is still a little problem and as I investigate in services and threads I like to see it running. If the socket-connection operates in the local network everything works fine. But if it operates over a VPN-connetion it post the following error message: size = q.recv(HDR_SZ) socket.error: (10035, 'The socket operation could not complete without blocking' If I use the first version of the programm without running as service it works over VPN too. So it seems to be a time problem. The socket doc declares that sockets start with 'blocking' as the default mode. I tried to use setblocking and settimeout in various ways but that doesn't change anything. What can I do examine the problem further ? regards, J?rgen ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/ From arlo at arlim.org Wed Jan 19 02:59:43 2005 From: arlo at arlim.org (Arlo) Date: Wed Jan 19 17:10:01 2005 Subject: [python-win32] Feature request for Python's msi Message-ID: <20050119015433.2935B2451F@smeagol.dreamhost.com> I couldn't really tell which list to post this to. This looked closest. Let me know if it should go elsewhere. I'd like a feature to be added to Python's windows installer. I want it to set up two environment variables for me. It should: 1. Append %PythonInstallDir%\Scripts to the system PATH. 2. Append .PY to the system PATHEXT. That way, if I install some tool that happens to have been written in python, I can use it on the command line as C:\somewhere\> foo arg arg , rather than as: C:\somewhere\> C:\Python24\Scripts\foo.py arg arg The installer already sets up the .py extension; just please add this to the search path. As is, I have to do this to every machine in the office. Thanks. Arlo From amonroe at columbus.rr.com Wed Jan 19 23:55:45 2005 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Wed Jan 19 23:56:18 2005 Subject: [python-win32] Feature request for Python's msi In-Reply-To: <20050119015433.2935B2451F@smeagol.dreamhost.com> References: <20050119015433.2935B2451F@smeagol.dreamhost.com> Message-ID: <125510154743.20050119175545@columbus.rr.com> > I'd like a feature to be added to Python's windows installer. I want it to > set up two environment variables for me. It should: > 1. Append %PythonInstallDir%\Scripts to the system PATH. > 2. Append .PY to the system PATHEXT. As an interim solution, have you looked at Innosetup? Alan From mhammond at skippinet.com.au Thu Jan 20 00:16:52 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Jan 20 00:16:57 2005 Subject: [python-win32] Feature request for Python's msi In-Reply-To: <20050119015433.2935B2451F@smeagol.dreamhost.com> Message-ID: <0bfc01c4fe7c$f64dcc30$150a0a0a@enfoldsystems.local> > I couldn't really tell which list to post this to. This > looked closest. Let > me know if it should go elsewhere. It should be added as a feature request in the main Python bug collector (ie, at sourceforge). There would be far far more chance of it getting done if you also provide a patch to the MSI generation process - most people involved in this are very short of time, and are likely to consider this non critical. > I'd like a feature to be added to Python's windows installer. > I want it to > set up two environment variables for me. It should: > > 1. Append %PythonInstallDir%\Scripts to the system PATH. I guess this could make sense if the main Python directory is put into sys.path. Having multiple Python versions installed could make this confusing > 2. Append .PY to the system PATHEXT. This makes sense, but also may be confusing with multiple versions. I guess the correct thing to do would be to ask the user if they do actually want these things to happen - most users would be happy to have them continue to not happen, judging from the small number of feature requests. > That way, if I install some tool that happens to have been written in > python, I can use it on the command line as > > C:\somewhere\> foo arg arg > > , rather than as: > > C:\somewhere\> C:\Python24\Scripts\foo.py arg arg In your real cases, who provided "foo.py"? If it was not installed with Python itself (ie, is a script you provided), then it may be better to add these scripts to a completely different directory, and ensure that directory is on your PATH. I can't think of any Python supplied scripts which are so useful they should be on the PATH, so I suspect you would have an uphill battle getting that one accepted. Mark From theller at python.net Thu Jan 20 08:59:45 2005 From: theller at python.net (Thomas Heller) Date: Thu Jan 20 08:58:30 2005 Subject: [python-win32] Re: Feature request for Python's msi References: <20050119015433.2935B2451F@smeagol.dreamhost.com> <0bfc01c4fe7c$f64dcc30$150a0a0a@enfoldsystems.local> Message-ID: >> 2. Append .PY to the system PATHEXT. > > This makes sense, but also may be confusing with multiple versions. I don't see a problem with multiple versions, the 'default' version is used when you type 'path\to\script'. And you can use batch files to select a specific Python version. But I also don't see a problem changing the env var yourself: it has only be done once. >> That way, if I install some tool that happens to have been written in >> python, I can use it on the command line as >> >> C:\somewhere\> foo arg arg >> >> , rather than as: >> >> C:\somewhere\> C:\Python24\Scripts\foo.py arg arg > > In your real cases, who provided "foo.py"? If it was not installed with > Python itself (ie, is a script you provided), then it may be better to add > these scripts to a completely different directory, and ensure that directory > is on your PATH. I can't think of any Python supplied scripts which are so > useful they should be on the PATH, so I suspect you would have an uphill > battle getting that one accepted. c:\PythonXY\Scripts is the default directory for scripts installed via distutils. If the ..\Scripts directory would be changed into a package, and the '-m' Python command line switch would be implemented fully (there's a PEP for it now), you could run the script in this way, with the batch files helpers (py23.bat, py24.bat) I mentioned before: py23 -m Scripts.foo arg arg Thomas From frcgis at earthlink.net Thu Jan 20 04:03:31 2005 From: frcgis at earthlink.net (David Kelly) Date: Thu Jan 20 17:48:26 2005 Subject: [python-win32] Error message? Message-ID: <200501200259.j0K2xajo000739@et-mco-3.site.stayonline.net> I got the following error message in stepping through a Python 2.2 script. Can anyone shed some light for me on what it means? I am new to Python. PythonWin 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (mhammond@skippinet.com.au) - see 'Help/About PythonWin' for further copyright information. [Dbg]>>> Traceback (most recent call last): File "C:\Python22\lib\site-packages\Pythonwin\pywin\framework\dbgcommands.py", line 73, in OnGo self._DoOrStart("do_set_continue", scriptutils.RS_DEBUGGER_GO) File "C:\Python22\lib\site-packages\Pythonwin\pywin\framework\dbgcommands.py", line 57, in _DoOrStart method() File "C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\debugger.py", line 637, in do_set_continue if self.GUIAboutToRun(): File "C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\debugger.py", line 788, in GUIAboutToRun if not self.StopDebuggerPump(): File "C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\debugger.py", line 486, in StopDebuggerPump if self.GUIAboutToFinishInteract(): File "C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\debugger.py", line 837, in GUIAboutToFinishInteract self.oldForeground.EnableWindow(1) win32ui: The window handle does not specify a valid window win32ui: Error in Command Message handler for command ID 15022, Code 0 Thanks, David N. Kelly From mhammond at skippinet.com.au Fri Jan 21 04:47:03 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri Jan 21 04:47:10 2005 Subject: [python-win32] Error message? In-Reply-To: <200501200259.j0K2xajo000739@et-mco-3.site.stayonline.net> Message-ID: <0e3601c4ff6b$df8e3940$150a0a0a@enfoldsystems.local> > I got the following error message in stepping through a > Python 2.2 script. > Can anyone shed some light for me on what it means? I am new > to Python. This is an old bug in Pythonwin. Upgrade to build 203 from sourceforge.net/projects/pywin32, and that particular error should go away. Mark From wade at leftwich.us Sat Jan 22 21:39:55 2005 From: wade at leftwich.us (Wade Leftwich) Date: Sat Jan 22 21:41:25 2005 Subject: [python-win32] Internet Explorer COM issues with XP SP2? In-Reply-To: <41F2B8E8.4000604@leftwich.us> References: <41F2B8E8.4000604@leftwich.us> Message-ID: <41F2BA1B.5010402@leftwich.us> On Dec 7, Steve McDonald wrote: > Replying to message from Bryan Kamrath from back in October: > > > I am using the PAMIE > > (http://pamie.sourceforge.net) module for doing some > > automated web testing. This module works with the > > Internet Explorer COM object to drive Internet > > Explorer by automating navigates, button clicks, the > > filling out of forms, etc. However, since I upgraded > > to XP SP2 I have not gotten this module to work very > > well. It seems that every time I try and fire an > > event fown to the COM object (like an "onchange") > > event I get the 'Access Denied' COM error. > > I'm having the same problem, and I haven't been able to find an answer > either. The following code demonstrates the problem without using PAMIE: > > from win32com.client import DispatchEx > import time > > ie = DispatchEx("InternetExplorer.Application") > ie.Visible = 1 > ie.Navigate("http://google.com") > # wait for page to finish loading > while ie.Busy: > time.sleep(0.1) > while ie.Document.ReadyState != 'complete': > time.sleep(0.1) > ie.Document.forms['f'].elements.all['q'].value = "win32all" > # the following line throws an exception on XP SP2: > ie.Document.forms['f'].elements.all['q'].fireEvent('onchange') > ie.Quit() > > The full error produced is: > > Traceback (most recent call last): > File > "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py" > , line 310, in RunScript > exec codeObject in __main__.__dict__ > File "C:\Documents and Settings\smcdonald\Desktop\xpsp2test.py", line > 14, in ? > ie.Document.forms['f'].elements.all['q'].fireEvent('onchange') > File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line > 165, in __call__ > return > self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.def > aultDispatchName,None) > com_error: (-2147024891, 'Access is denied.', None, None) > > If anyone has any solutions or suggestions, I'd love to hear them. > > -Steve > > I just ran into the exact same roadblock. I don't have a solution, but I did get to test the same program on XP and 2000, and it produced the same error with both OS's. Both boxes are running the latest update of IE6, so maybe it's an IE security thing we're getting snagged on. I too would *really* appreciate a solution or even a hint. -- Wade Leftwich Ithaca, NY From alipolatel at yahoo.com Sun Jan 23 19:28:47 2005 From: alipolatel at yahoo.com (Ali Polatel) Date: Sun Jan 23 19:29:02 2005 Subject: [python-win32] on the way to find pi! Message-ID: <20050123182847.74790.qmail@web61009.mail.yahoo.com> dear friends , I found a code which calculates pi with an interesting algorithm the programme code is below: from sys import stdout def f((q,r,t,k)): n = (3*q+r) / t if (4*q+r) / t == n: return (10*q,10*(r-n*t),t,k,n) else: return (q*k, q*(4*k+2)+r*(2*k+1),t*(2*k+1),k+1) # Call pi(20) for first 20 digits, or pi() for all digits def pi(n=-1): printed_decimal = False r = f((1,0,1,1)) while n != 0: if len(r) == 5: stdout.write(str(r[4])) if not printed_decimal: stdout.write('.') printed_decimal = True n -= 1 r = f(r[:4]) #stdout.write('\n') if __name__ == '__main__': from sys import argv try: digit_count = long(argv[1]) except: digit_count=int(raw_input('How many digits? :')) pi(digit_count) This code gives the number in an unusual format like "3.1415'None'" it has a number part and a string part . I want to seperate these from easc other but I couldn't manage. I mean when I try to turn it into string format then try to use things like [:4] or like that they don't work.Any idea how to seperate this 'None' from the number and make it a real normal number on which I can do operations like +1 -1 or like that :) Regards __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050123/16c7ff9e/attachment.htm From mc at mclaveau.com Sun Jan 23 20:45:05 2005 From: mc at mclaveau.com (Michel Claveau) Date: Sun Jan 23 20:57:38 2005 Subject: [python-win32] on the way to find pi! References: <20050123182847.74790.qmail@web61009.mail.yahoo.com> Message-ID: <029001c50184$0cd23220$0701a8c0@PORTABLES> Hi ! Very more simplistic, but easy for to code : def pi(nb): cpi=0 for i in xrange(1,nb,4): cpi=cpi+4./i-4./(i+2.) return(cpi) print pi(999999) @-salutations -- Michel Claveau From atul.kamat at rediffmail.com Mon Jan 24 12:48:22 2005 From: atul.kamat at rediffmail.com (Atul Kamat) Date: Mon Jan 24 16:44:06 2005 Subject: [python-win32] NT filepermissions Message-ID: <20050124114822.14792.qmail@webmail29.rediffmail.com> Hi All, This is a query about the NT file/Directory Permissions.In Windows NT,if we set the permissions for a file,it tends to ignore them and inherits the parent directory`s permissions.Is there a way by which i can make the file permissions work irrespective of what the parent directory`s permissions have been set.I`ve written a permissions handler module for unix based operating systems using chmod(),chown() and stat() .I`m using win32file() win32security() and ntsecuritycon() for the permissions handler on windows. Thanks and Regards Atul Kamat Network Security Developer Visionael Protector Labs Bangalore -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050124/88f99120/attachment.htm From FBatista at uniFON.com.ar Mon Jan 24 14:16:20 2005 From: FBatista at uniFON.com.ar (Batista, Facundo) Date: Mon Jan 24 16:44:58 2005 Subject: [python-win32] RE: on the way to find pi! Message-ID: [Fredrik Lundh] #- what's the point of that? the math module already contains #- pi with as many #- decimals as you can put in a Python float: #- #- $ python #- >>> pi = 3.1415926535897932384 #- >>> pi #- 3.1415926535897931 #- >>> import math #- >>> math.pi #- 3.1415926535897931 #- >>> pi = math.pi #- True And if you want to go beyond that, check http://www.python.org/dev/doc/devel/lib/decimal-recipes.html >>> from decimal import * >>> getcontext().prec = 60 >>> pi() Decimal("3.14159265358979323846264338327950288419716939937510582097494") >>> . Facundo Bit?cora De Vuelo: http://www.taniquetil.com.ar/plog PyAr - Python Argentina: http://pyar.decode.com.ar/ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ADVERTENCIA. La informaci?n contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener informaci?n confidencial o propietaria, cuya divulgaci?n es sancionada por la ley. Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no est? autorizado a divulgar, copiar, distribuir o retener informaci?n (o parte de ella) contenida en este mensaje. Por favor notif?quenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magn?tico) que pueda haber realizado del mismo. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telef?nica Comunicaciones Personales S.A. o alguna empresa asociada. Los mensajes electr?nicos pueden ser alterados, motivo por el cual Telef?nica Comunicaciones Personales S.A. no aceptar? ninguna obligaci?n cualquiera sea el resultante de este mensaje. Muchas Gracias. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050124/1d9d88d0/attachment.html From timr at probo.com Mon Jan 24 22:51:16 2005 From: timr at probo.com (Tim Roberts) Date: Mon Jan 24 22:51:21 2005 Subject: [python-win32] on the way to find pi! In-Reply-To: <20050124110029.90C721E400B@bag.python.org> References: <20050124110029.90C721E400B@bag.python.org> Message-ID: <41F56DD4.2010809@probo.com> On Sun, 23 Jan 2005 10:28:47 -0800 (PST), Ali Polatel wrote: >I found a code which calculates pi with an interesting algorithm the programme code is below: >from sys import stdout >def f((q,r,t,k)): > n = (3*q+r) / t > if (4*q+r) / t == n: > return (10*q,10*(r-n*t),t,k,n) > else: > return (q*k, q*(4*k+2)+r*(2*k+1),t*(2*k+1),k+1) ># Call pi(20) for first 20 digits, or pi() for all digits >def pi(n=-1): > printed_decimal = False > r = f((1,0,1,1)) > while n != 0: > if len(r) == 5: > stdout.write(str(r[4])) > if not printed_decimal: > stdout.write('.') > printed_decimal = True > n -= 1 > r = f(r[:4]) > #stdout.write('\n') >if __name__ == '__main__': > from sys import argv > try: > digit_count = long(argv[1]) > except: > digit_count=int(raw_input('How many digits? :')) > pi(digit_count) > >This code gives the number in an unusual format like "3.1415'None'" it has a number part and a string part . > Your problem is that the function "pi" doesn't actually return anything. If you do this, for example: print pi(5) you will see 3.1415None. The first 5 digits of pi come from the sys.stdout.write calls in the function, and the "None" comes from the print statement when it tries to display the result of the function. I can certainly tell you how to change this code so that it returns a value instead of always printing to stdout, but first let me ask what you plan to do with it. You said: >Any idea how to seperate this 'None' from the number and make it a real normal number on which I can do operations like +1 -1 or like that > This algorithm is useless as a way to generate a "real normal number", because there are no "real normal numbers" that keep an infinite number of floating point digits. This function is fun for generating 120 decimal digits for amusement purposes, but it has no practical value. If all you want is a "pi" that you can use in computation, you cannot do better than this: from math import pi Double-precision floating point arithmetic on x86 machines has about 15 digits of precision. Even if you generate pi(80) using your function, as soon as you convert it to a float to use it in a function, it will lose all but the first 15 digits. Here is your code, changed so that pi() returns a string value: import sys def f((q,r,t,k)): n = (3*q+r) / t if (4*q+r) / t == n: return (10*q,10*(r-n*t),t,k,n) else: return (q*k, q*(4*k+2)+r*(2*k+1),t*(2*k+1),k+1) # Call pi(20) for first 20 digits, or pi() for all digits def pi(n=-1): s = [] r = f((1,0,1,1)) while n != 0: if len(r) == 5: s.append( str(r[4]) ) n -= 1 r = f(r[:4]) s.insert( 1, '.' ) return ''.join( s ) if __name__ == '__main__': try: digit_count = long(sys.argv[1]) except: digit_count = int(raw_input('How many digits? :')) print pi(digit_count) print repr(float(pi(digit_count))) and here is what happens when you try to use it in arithmetic: C:\Tmp>x.py 5 3.1415 3.1415000000000002 C:\Tmp>x.py 10 3.141592653 3.141592653 C:\Tmp>x.py 15 3.14159265358979 3.14159265358979 C:\Tmp>x.py 20 3.1415926535897932384 3.1415926535897931 C:\Tmp> -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From steve at holdenweb.com Tue Jan 25 00:44:01 2005 From: steve at holdenweb.com (Steve Holden) Date: Tue Jan 25 00:49:11 2005 Subject: [python-win32] on the way to find pi! In-Reply-To: <41F56DD4.2010809@probo.com> References: <20050124110029.90C721E400B@bag.python.org> <41F56DD4.2010809@probo.com> Message-ID: <41F58841.7090506@holdenweb.com> Tim Roberts wrote: > On Sun, 23 Jan 2005 10:28:47 -0800 (PST), Ali Polatel > wrote: > >> I found a code which calculates pi with an interesting algorithm the >> programme code is below: >> from sys import stdout >> def f((q,r,t,k)): >> n = (3*q+r) / t >> if (4*q+r) / t == n: >> return (10*q,10*(r-n*t),t,k,n) >> else: >> return (q*k, q*(4*k+2)+r*(2*k+1),t*(2*k+1),k+1) >> # Call pi(20) for first 20 digits, or pi() for all digits >> def pi(n=-1): >> printed_decimal = False >> r = f((1,0,1,1)) >> while n != 0: >> if len(r) == 5: >> stdout.write(str(r[4])) >> if not printed_decimal: >> stdout.write('.') >> printed_decimal = True >> n -= 1 >> r = f(r[:4]) >> #stdout.write('\n') >> if __name__ == '__main__': >> from sys import argv >> try: >> digit_count = long(argv[1]) >> except: >> digit_count=int(raw_input('How many digits? :')) >> pi(digit_count) >> This code gives the number in an unusual format like >> "3.1415'None'" it has a number part and a string part . >> > > Your problem is that the function "pi" doesn't actually return > anything. If you do this, for example: > print pi(5) > you will see 3.1415None. The first 5 digits of pi come from the > sys.stdout.write calls in the function, and the "None" comes from the > print statement when it tries to display the result of the function. > > I can certainly tell you how to change this code so that it returns a > value instead of always printing to stdout, but first let me ask what > you plan to do with it. You said: > >> Any idea how to seperate this 'None' from the number and make it a >> real normal number on which I can do operations like +1 -1 or like that > > > This algorithm is useless as a way to generate a "real normal number", > because there are no "real normal numbers" that keep an infinite number > of floating point digits. This function is fun for generating 120 > decimal digits for amusement purposes, but it has no practical value. > If all you want is a "pi" that you can use in computation, you cannot do > better than this: > > from math import pi > one word: decimal > Double-precision floating point arithmetic on x86 machines has about 15 > digits of precision. Even if you generate pi(80) using your function, > as soon as you convert it to a float to use it in a function, it will > lose all but the first 15 digits. > > Here is your code, changed so that pi() returns a string value: > > import sys > > def f((q,r,t,k)): > n = (3*q+r) / t > if (4*q+r) / t == n: > return (10*q,10*(r-n*t),t,k,n) > else: > return (q*k, q*(4*k+2)+r*(2*k+1),t*(2*k+1),k+1) > > # Call pi(20) for first 20 digits, or pi() for all digits > def pi(n=-1): > s = [] > r = f((1,0,1,1)) > while n != 0: > if len(r) == 5: > s.append( str(r[4]) ) > n -= 1 > r = f(r[:4]) > s.insert( 1, '.' ) > return ''.join( s ) > > if __name__ == '__main__': > try: > digit_count = long(sys.argv[1]) > except: > digit_count = int(raw_input('How many digits? :')) > print pi(digit_count) > print repr(float(pi(digit_count))) > > and here is what happens when you try to use it in arithmetic: > > C:\Tmp>x.py 5 > 3.1415 > 3.1415000000000002 > > C:\Tmp>x.py 10 > 3.141592653 > 3.141592653 > > C:\Tmp>x.py 15 > 3.14159265358979 > 3.14159265358979 > > C:\Tmp>x.py 20 > 3.1415926535897932384 > 3.1415926535897931 > > C:\Tmp> > :-) regards-ly y'rs -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 From rays at blue-cove.com Tue Jan 25 01:32:35 2005 From: rays at blue-cove.com (Ray S) Date: Tue Jan 25 01:24:00 2005 Subject: [python-win32] sleep() fine-control in Python - RDTSC, select() etc. Message-ID: <5.2.0.4.2.20050124151315.1058def0@blue-cove.com> Skipped content of type multipart/alternative-------------- next part -------------- import time mytime = time.time ## optimization sleep = time.sleep clock = time.clock def mydelay(delay): global logical_time physical_time = mytime() try: logical_time = logical_time + delay except NameError: logical_time = physical_time + delay if logical_time > physical_time: sleep(logical_time - physical_time) #sleep(.0001) ## same as sleep(0)! #sleep(.001) p = 0. d1 = 0. d2 = 0. looped = 0. howMany = 100 for i in range(20): ## timer for pass in a for loop t1 = clock() for j in range(howMany): pass p += (clock()-t1) t1 = clock() for j in range(howMany): mydelay(.0000001) ## ~minumum useable d1 += (clock()-t1) t1 = clock() for j in range(howMany): mydelay(.00016) ## one turbine degree d2 += (clock()-t1) looped+= howMany print 'micro sec: %.1f %.1f %.1f' % (1000000*p/looped, 1000000*d1/looped, 1000000*(d2)/looped) -------------- next part -------------- import time import select import socket HOST = '' # Symbolic name meaning the local host PORT = 50007 # Arbitrary non-privileged port s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) mytime = time.time ## optimization sleep = time.sleep clock = time.clock p = 0. d1 = 0. d2 = 0. looped = 0. howMany = 100 for i in range(20): ## timer for pass in a for loop t1 = clock() for j in range(howMany): pass p += (clock()-t1) t1 = clock() for j in range(howMany): select.select([s], [], [], .0000009) #select.select([s], [], [], .000001) ## causes a timing jump! d1 += (clock()-t1) t1 = clock() for j in range(howMany): select.select([s], [], [], .0004) d2 += (clock()-t1) looped+= howMany print 'micro sec: %.1f %.1f %.1f' % (1000000*p/looped, 1000000*d1/looped, 1000000*(d2)/looped) -------------- next part -------------- // dosDelay.cpp : Defines the entry point for the console application. struct sysclock_t { int LL, LH, HL, HH; }; struct tv time; time.tv_sec = num_seconds_to_sleep; time.tv_usec = num_microseconds_to_sleep; select(NULL,NULL,NULL,& time); void main() { int ns= 1000000; // make the sleep in 100th nanoseconds. ns = (ns + 99)/100; //ns -= FACTOR; __asm { rdtsc // clock in EDX:EAX // we ignore EDX since we asume ns is // of shorter duration than that. add eax,dword ptr ns mov ebx,eax // save eax into ebx. jnc loop2 // new time is after wrapping around loop1: rdtsc // again we ignore EDX // wait for time to wrap around. cmp eax,ebx jae loop1 // Time has wrapped around and present time < wait time. loop2: rdtsc // again we ignore EDX cmp eax,ebx jb loop2 } } From gagenellina at softlab.com.ar Tue Jan 25 03:18:12 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Tue Jan 25 03:28:32 2005 Subject: [python-win32] Re: on the way to find pi! In-Reply-To: <20050124110029.649A41E4014@bag.python.org> References: <20050124110029.649A41E4014@bag.python.org> Message-ID: <6.2.0.14.0.20050124230128.02da0900@192.168.0.115> At 24/1/2005 08:00, you wrote: ># Call pi(20) for first 20 digits, or pi() for all digits >def pi(n=-1): > printed_decimal = False > r = f((1,0,1,1)) > while n != 0: > if len(r) == 5: > stdout.write(str(r[4])) >This code gives the number in an unusual format like "3.1415'None'" it has >a number part and a string part . I want to seperate these from easc other >but I couldn't manage. I mean when I try to turn it into string format >then try to use things like [:4] or like that they don't work.Any idea how >to seperate this 'None' from the number and make it a real normal number >on which I can do operations like +1 -1 or like that :) I bet: you call the function using: print pi(20) instead of just: pi(20) That function already prints the output, one digit at a time. You could accumulate the answer into a list, or perhaps into a string, and get thousands of digits; but it doesnt make sense to store the answer in a "real normal number" because you are limited by the underlying floating point precision to a few decimals. To get pi as a real number, just say: from math import pi From gagenellina at softlab.com.ar Tue Jan 25 03:48:11 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Tue Jan 25 03:58:28 2005 Subject: [python-win32] Re: sleep() fine-control in Python - RDTSC, select() etc. In-Reply-To: <20050125002400.5FBCE1E4009@bag.python.org> References: <20050125002400.5FBCE1E4009@bag.python.org> Message-ID: <6.2.0.14.0.20050124233304.02eaa720@192.168.0.115> At 24/1/2005 21:24, you wrote: >I have a need for a time.clock() with >0.000016 second (16us) accuracy. >The sleep() (on Python 2.3, Win32, at least) has a .001s limit. Is it >lower/better on other's platforms? Try a waitable timer SetWaitableTimer specifies the interval with 100ns granularity, but maybe the actual timer precision depends on hardware or OS version or ... From rays at blue-cove.com Tue Jan 25 06:23:30 2005 From: rays at blue-cove.com (RayS) Date: Tue Jan 25 06:24:28 2005 Subject: [python-win32] Re: sleep() fine-control in Python - RDTSC, select() etc. In-Reply-To: <6.2.0.14.0.20050124233304.02eaa720@192.168.0.115> References: <20050125002400.5FBCE1E4009@bag.python.org> <20050125002400.5FBCE1E4009@bag.python.org> Message-ID: <5.2.1.1.2.20050124211047.04cb0300@blue-cove.com> At 11:48 PM 1/24/2005 -0300, Gabriel Genellina wrote: >At 24/1/2005 21:24, you wrote: > >>I have a need for a time.clock() with >0.000016 second (16us) accuracy. >>The sleep() (on Python 2.3, Win32, at least) has a .001s limit. Is it lower/better on other's platforms? > >Try a waitable timer >SetWaitableTimer specifies the interval with 100ns granularity, but maybe the actual timer precision depends on hardware or OS version or ... Thanks! Upon searching I found: http://mail.python.org/pipermail/python-win32/2003-July/001166.html from ctypes import * import win32event, win32api h = windll.kernel32.CreateWaitableTimerA(None, 0, None) #dt = c_longlong(-60L * 10L**(9-2)) ## 60s * 1/(100nanoseconds) dt = c_longlong(-160L) ## 16microseconds dt_p = pointer(dt) ## uses 100ns increments windll.kernel32.SetWaitableTimer(h, dt_p, 0, None, None, 0) win32event.WaitForSingleObject(h, win32event.INFINITE) win32api.CloseHandle(h) I expect the actual timing to be off, but I'll be switching methods and/or hardware after this first demo app to a real-time OS or an A/D with counters. I'll post benched code tomorrow. Ray From michael.morgan2 at baesystems.com Tue Jan 25 08:25:52 2005 From: michael.morgan2 at baesystems.com (Morgan, Michael L (US SSA) GXP) Date: Tue Jan 25 08:25:31 2005 Subject: [python-win32] Connect to Excel via COM leaves process hanging Message-ID: Howdy, With the following snippet of code. from win32com.client import Dispatch xl_app= Dispatch("Excel.Application") xl_app.Quit() del xl_app This leaves 'Excel' in the process list. How can I get rid of it? Thanks for your time, Mike From timr at probo.com Tue Jan 25 19:37:13 2005 From: timr at probo.com (Tim Roberts) Date: Tue Jan 25 19:37:32 2005 Subject: [python-win32] sleep() fine-control in Python - RDTSC, select() etc. In-Reply-To: <20050125002400.91AE21E400C@bag.python.org> References: <20050125002400.91AE21E400C@bag.python.org> Message-ID: <41F691D9.5040602@probo.com> On Mon, 24 Jan 2005 16:32:35 -0800, Ray S wrote: >void main() >{ > int ns= 1000000; > // make the sleep in 100th nanoseconds. > ns = (ns + 99)/100; > //ns -= FACTOR; > > __asm { > rdtsc > // clock in EDX:EAX > // we ignore EDX since we asume ns is > // of shorter duration than that. > > This assumption is dangerous. On a 4 GHz processor, the low-order 32 bits of rdtsc wraps every second. 64-bit arithmetic is easy in x86 assembly. You should get in the habit of using it with rdtsc. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From michael.morgan2 at baesystems.com Tue Jan 25 21:37:58 2005 From: michael.morgan2 at baesystems.com (Morgan, Michael L (US SSA) GXP) Date: Tue Jan 25 21:37:37 2005 Subject: [python-win32] Connect to Excel via COM leaves process hanging Message-ID: Howdy, Yesterday, I sent out a message, but forgot a couple of key lines. Sorry for the oversite. from win32com.client import Dispatch #Open the sheet. xl_app= Dispatch("Excel.Application") xl_book= xl_app.Workbooks.Open() #Close the sheet and exit the app. xl_book.Close() xl_app.Quit() del xl_app This leaves 'Excel' in the process list. How can I get rid of it? Thanks for your time, Mike -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050125/6cc8368a/attachment.htm From tony at tcapp.com Tue Jan 25 21:55:16 2005 From: tony at tcapp.com (Tony Cappellini) Date: Tue Jan 25 21:55:31 2005 Subject: [python-win32] How to access Visual Basic's "Application" object, in Python In-Reply-To: <20041116144807.P73878@yamato.yamato.com> References: <20041116110104.C15A91E4015@bag.python.org> <20041116144807.P73878@yamato.yamato.com> Message-ID: <20050125124624.U35170@yamato.yamato.com> I am trying to mimic a short VB program in Python, which iterates over an Outlook 2002 global address list. The program runs in VB, so it is working. Unfortunately, I have to have outlook running for it to work. I was hoping it could be done without having to launch Outlook. This is only a minor issue though. However, I don't know what to use in Python, for VB's Application object, which is like a pointer to the entire process that is running the application. From Application, I can access the name of the executable, the version number, tha path, and some other attibutes. This is the vb program. Dim objOL As Outlook.Application Dim objNS, objAL, objAE, objMember On Error Resume Next Set objOL = GetObject(, "Outlook.Application") If objOL Is Nothing Then Set objOL = CreateObject("Outlook.Application") objOL.Session.Logon "my profile", , False, True End If Set objNS = Application.GetNamespace("MAPI") Set objAL = objNS.AddressLists("Global Address List") Set objAE = objAL.AddressEntries("python users") Debug.Print objAL.AddressEntries.Count Debug.Print objAE.Members.Count For Each objMember In objAE.Members Debug.Print objMember.Name, objMember.Address Next Does nayone have a suggestion? From rays at blue-cove.com Tue Jan 25 23:28:24 2005 From: rays at blue-cove.com (Ray S) Date: Tue Jan 25 23:19:44 2005 Subject: [python-win32] time. delay oddities Message-ID: <5.2.0.4.2.20050125132633.10976cc0@blue-cove.com> With the pure Python code below, I get results like: micro sec: 1.0 12.2 154.8 micro sec: 0.9 11.3 156.0 when requesting 0, 10 and 160 us, which seems reasonable - PII600 Win2K Py2.2. On Linux with a 2GHz Py2.3 it seems to always return 0.0 Additionally, I don't see why mydelay works as it does; I have tried other methods today, including an rdtsc DLL, and all other methodologies tried are limited by overhead of the call to ctypes (for rdstc or waitabletimer) or ~200ms clock granularity (averages, ignoring the randomness of MS timing). Can someone explain it? Does it work the same on other machines? Code snipped from: http://edily.progiciels-bpi.ca/showfile.html?name=courriel/c%C3%A9duleur&index=1 CODE: mytime = time.clock#time ## optimization sleep = time.sleep clock = time.clock def mydelay(delay): global logical_time physical_time = mytime() try: logical_time = logical_time + delay except NameError: logical_time = physical_time + delay if logical_time > physical_time: ## apparently only done when delays are > ~.001s sleep(logical_time - physical_time) #sleep(.001) ## same as above for small delays #print (logical_time - physical_time) *1000. ## print ms #sleep(.0001) ## same as sleep(0)! p = 0. d1 = 0. d2 = 0. looped = 0. howMany = 100 for i in range(20): ## timer for pass in a for loop t1 = clock() for j in range(howMany): pass p += (clock()-t1) t1 = clock() mydelay(.000001) for j in range(howMany): mydelay(.00001) ## ~minumum useable ~10us d1 += (clock()-t1) t1 = clock() for j in range(howMany): mydelay(.00016) d2 += (clock()-t1) looped+= howMany print 'micro sec: %.1f %.1f %.1f' % (1000000*p/looped, 1000000*d1/looped, 1000000*(d2)/looped) From rwupole at msn.com Wed Jan 26 01:48:30 2005 From: rwupole at msn.com (Roger Upole) Date: Wed Jan 26 01:48:37 2005 Subject: [python-win32] Re: NT filepermissions References: <20050124114822.14792.qmail@webmail29.rediffmail.com> Message-ID: NT doesn't do dynamic inheritance. On Windows 2000 and up, you can set SE_DACL_PROTECTED to prevent inheritance, but not on NT. Roger ----- Original Message ----- From: "Atul Kamat" To: Sent: Monday, January 24, 2005 6:48 AM Subject: [python-win32] NT filepermissions Hi All, This is a query about the NT file/Directory Permissions.In Windows NT,if we set the permissions for a file,it tends to ignore them and inherits the parent directory`s permissions.Is there a way by which i can make the file permissions work irrespective of what the parent directory`s permissions have been set.I`ve written a permissions handler module for unix based operating systems using chmod(),chown() and stat() .I`m using win32file() win32security() and ntsecuritycon() for the permissions handler on windows. Thanks and Regards Atul Kamat Network Security Developer Visionael Protector Labs Bangalore From karl.fast at pobox.com Wed Jan 26 04:40:23 2005 From: karl.fast at pobox.com (Karl Fast) Date: Wed Jan 26 04:40:37 2005 Subject: [python-win32] Connect to Excel via COM leaves process hanging In-Reply-To: ; from michael.morgan2@baesystems.com on Tue, Jan 25, 2005 at 12:37:58PM -0800 References: Message-ID: <20050125214023.C2828@signal.lights.com> I don't know why your code doesn't work. But I know that this does (here I am generating a new workbook, not opening an old one). excel = Dispatch('Excel.Application') excel.Visible = 0 excel.Workbooks.Add() excel.Worksheets(1).Activate() excel.ActiveWorkbook.SaveAs(file) ...do a bunch of stuff excel.ActiveWorkbook.Save() excel.Quit() del(excel) > from win32com.client import Dispatch > > #Open the sheet. > xl_app= Dispatch("Excel.Application") > xl_book= xl_app.Workbooks.Open() > > #Close the sheet and exit the app. > xl_book.Close() > xl_app.Quit() > del xl_app > > This leaves 'Excel' in the process list. How can I get rid of it? --karl http://www.livingskies.com/ From jeffpeery at seametrics.com Wed Jan 26 17:30:40 2005 From: jeffpeery at seametrics.com (Jeff Peery) Date: Wed Jan 26 17:30:44 2005 Subject: [python-win32] (no subject) Message-ID: <000001c503c4$60d0b0d0$7600000a@seametrics.local> Hello, I am using wxpython and I am having trouble passing variables from one frame to another. If I have a parent frame - frame1 - and I call a dialog using the following text: dlg = wxDialog2.wxDialog2(self) try: dlg.ShowModal() finally: dlg.Destroy() where in this bit of code would I pass a variable to the new dialog? I tried several things but I can't seem to get it to work. Thanks! Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050126/3d95370b/attachment.htm From belovedbob at greennet.net Wed Jan 26 17:42:59 2005 From: belovedbob at greennet.net (Robert Kaplan) Date: Wed Jan 26 17:42:06 2005 Subject: [python-win32] Greetings and win32 com events question Message-ID: <41F7C893.8090000@greennet.net> Hi, I'm new to the mailing, so greetings all! I'm working on an application try to respond to events in Microsoft Access using Python and win32com. However, I'm having trouble in setting up the event handlers. I can think of 2 approaches both of which yield win32com errors. First is the approach used the MSOfficeEvents.py test program. The problem is that the events to be picked up are not on the Application object but on a Form object created from it. class AccessEvents def OnActivate(self): print "Hello from Access" return 1 self. ac = Dispatch ("Access.Application") self. db = self. ac. NewCurrentDatabase ("d:\\pyhack\\foo") self. fm = self. ac. CreateForm () self. ac. Visible = true self. fm = DispatchWithEvents (self. fm, AcEvents) blows out with self. fm = DispatchWithEvents (self. fm, AcEvents) File "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line 258, in DispatchWithEvents clsid = disp_class.CLSID AttributeError: 'NoneType' object has no attribute 'CLSID'. I also tried a variety of string arguments, but all of those also yielded an invalid class id error. The other approach is more Visual Basic like: self. ac = Dispatch ("Access.Application") self. db = self. ac. NewCurrentDatabase ("d:\\pyhack\\foo") self. fm = self. ac. CreateForm () self. ac. Visible = true self. ev = AcEvents () self. fm. OnActivate = self. ev. OnActivate this couldn't set the OnActivate attribute with the following error. File "D:\pyhack\1\Bob.py", line 132, in DoAccess self. fm. OnActivate = self. ev. OnActivate File "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line 503, in __setattr__ d.__setattr__(attr, value) File "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line 463, in __setattr__ self._oleobj_.Invoke(*(args + (value,) + defArgs)) TypeError: Objects of type 'instance method' can not be converted to a COM VARIA NT Anyone know how to do this, either strategy is fine. Thanks Robert Kaplan From steve at holdenweb.com Wed Jan 26 18:17:44 2005 From: steve at holdenweb.com (Steve Holden) Date: Wed Jan 26 18:23:00 2005 Subject: [python-win32] (no subject) In-Reply-To: <000001c503c4$60d0b0d0$7600000a@seametrics.local> References: <000001c503c4$60d0b0d0$7600000a@seametrics.local> Message-ID: <41F7D0B8.2080703@holdenweb.com> Jeff Peery wrote: > Hello, I am using wxpython and I am having trouble passing variables > from one frame to another. If I have a parent frame ? frame1 ? and I > call a dialog using the following text: > > > > dlg = wxDialog2.wxDialog2(self) > > try: > > dlg.ShowModal() > > finally: > > dlg.Destroy() > > > > where in this bit of code would I pass a variable to the new dialog? I > tried several things but I can?t seem to get it to work. Thanks! > > If wxDialog2 is a subclass of wxDialog then it can have __init__() arguments that don't get passed to wxDialog's __init__() call, but are instead used (and possibly stored) by the instance's extension of __init__(). Does this answer your question? regards Steve -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 From timr at probo.com Wed Jan 26 18:31:38 2005 From: timr at probo.com (Tim Roberts) Date: Wed Jan 26 18:31:42 2005 Subject: [python-win32] time. delay oddities In-Reply-To: <20050126110040.96C031E400C@bag.python.org> References: <20050126110040.96C031E400C@bag.python.org> Message-ID: <41F7D3FA.6070502@probo.com> On Tue, 25 Jan 2005 14:28:24 -080, Ray S wrote: >With the pure Python code below, I get results like: >micro sec: 1.0 12.2 154.8 >micro sec: 0.9 11.3 156.0 >when requesting 0, 10 and 160 us, which seems reasonable - PII600 Win2K Py2.2. > >On Linux with a 2GHz Py2.3 it seems to always return 0.0 > > Right. On Linux, time.clock() has a precision of 10 ms. None of your calls take more than 10 ms, so the difference is always 0. I can't tell what you're trying to achieve with this code. time.clock() returns very different things on Windows and Linux. On Windows, it returns (roughly) real time since the beginning of the process. On Linux, it returns CPU time used since the beginning of the process. Since sleep() does not use CPU time, clock() stops while you sleep. What are you trying to achieve? Python is almost certainly the wrong approach for a real-time process. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From jeffpeery at seametrics.com Wed Jan 26 21:13:27 2005 From: jeffpeery at seametrics.com (Jeff Peery) Date: Wed Jan 26 21:13:34 2005 Subject: [python-win32] (no subject) In-Reply-To: <41F7DAB8.9030600@holdenweb.com> Message-ID: <000801c503e3$80613180$7600000a@seametrics.local> Ok, here it is. Thanks for the help really appreciate it. To pass information from one frame to the next (i.e., from wxFrame1 to wxDialog1) I use global variables from wxFrame1. So for example if I want to use a wxFrame1 variable myVar in wxDialog1 then I use wxFrame1.myVar in wxDialog1. I think this is bad form, I would rather pass the variables to the wxDialog1. thanks. Jeff -----Original Message----- From: Steve Holden [mailto:steve@holdenweb.com] Sent: Wednesday, January 26, 2005 10:00 AM To: Jeff Peery Subject: Re: [python-win32] (no subject) Perhaps you could post the code of your dialog? I presume a) It's in a module called wxDialog2, and b) It starts with class wxDialog2(wxDialog): regards Steve Jeff Peery wrote: > Hi thanks Steve, I am a bit new to this python stuff, could you explain > your response a bit more? I'm not sure what a subclass is, and the > _init_() function as I am aware of is simply the function that executes > when the dialog is opened... correct? My dialog2 is a dialog that I call > from a parent frame called wxFrame1. Thanks. > > -----Original Message----- > From: Steve Holden [mailto:steve@holdenweb.com] > Sent: Wednesday, January 26, 2005 9:18 AM > To: Jeff Peery > Cc: python-win32@python.org > Subject: Re: [python-win32] (no subject) > > Jeff Peery wrote: > > >>Hello, I am using wxpython and I am having trouble passing variables >>from one frame to another. If I have a parent frame - frame1 - and I >>call a dialog using the following text: >> >> >> >> dlg = wxDialog2.wxDialog2(self) >> >> try: >> >> dlg.ShowModal() >> >> finally: >> >> dlg.Destroy() >> >> >> >>where in this bit of code would I pass a variable to the new dialog? I > > >>tried several things but I can't seem to get it to work. Thanks! >> >> > > > If wxDialog2 is a subclass of wxDialog then it can have __init__() > arguments that don't get passed to wxDialog's __init__() call, but are > instead used (and possibly stored) by the instance's extension of > __init__(). > > Does this answer your question? > > regards > Steve -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 -------------- next part -------------- #Boa:Dialog:wxDialog2 from wxPython.wx import * from os import * from Numeric import * from cStringIO import * from string import * from fileinput import * from re import * import wxFrame1 def create(parent): return wxDialog2(parent) [wxID_WXDIALOG2, wxID_WXDIALOG2CANCEL, wxID_WXDIALOG2FINDK, wxID_WXDIALOG2STATICBOX1, wxID_WXDIALOG2STATICTEXT1, wxID_WXDIALOG2STATICTEXT10, wxID_WXDIALOG2STATICTEXT2, wxID_WXDIALOG2STATICTEXT3, wxID_WXDIALOG2STATICTEXT4, wxID_WXDIALOG2STATICTEXT5, wxID_WXDIALOG2STATICTEXT6, wxID_WXDIALOG2STATICTEXT7, wxID_WXDIALOG2STATICTEXT8, wxID_WXDIALOG2STATICTEXT9, wxID_WXDIALOG2TEXTCTRL3, wxID_WXDIALOG2TEXTCTRL5, wxID_WXDIALOG2WINDOW1, ] = map(lambda _init_ctrls: wxNewId(), range(17)) class wxDialog2(wxDialog): #Variables parent = wxDialog #holds the parent frame pointer interDiam = 0 #holds the internal diameter extDiam = 0 #holds the external diameter wallThickness = 0 #holds the wall thickness haveInterDiam = wxFrame1.FALSE #gets True if the user inputs a acceptable number or two other values are known haveWallThickness = wxFrame1.FALSE #gets True if the user inputs a acceptable number or two other values are known haveExtDiam = wxFrame1.FALSE #gets True if the user inputs a acceptable number or two other values are known def _init_utils(self): # generated method, don't edit pass def _init_ctrls(self, prnt): # generated method, don't edit wxDialog.__init__(self, id=wxID_WXDIALOG2, name='wxDialog2', parent=prnt, pos=wxPoint(367, 276), size=wxSize(271, 259), style=wxDEFAULT_DIALOG_STYLE, title='Approximate Dimensions') self._init_utils() self.SetClientSize(wxSize(263, 232)) self.window1 = wxWindow(id=wxID_WXDIALOG2WINDOW1, name='window1', parent=self, pos=wxPoint(0, 0), size=wxSize(263, 232), style=0) self.staticBox1 = wxStaticBox(id=wxID_WXDIALOG2STATICBOX1, label='Pipe Dimensions', name='staticBox1', parent=self.window1, pos=wxPoint(8, 8), size=wxSize(248, 104), style=0) self.FindK = wxButton(id=wxID_WXDIALOG2FINDK, label='Execute', name='FindK', parent=self.window1, pos=wxPoint(8, 192), size=wxSize(128, 32), style=0) self.FindK.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxNORMAL, False, 'MS Shell Dlg')) self.FindK.SetForegroundColour(wxColour(200, 0, 0)) EVT_BUTTON(self.FindK, wxID_WXDIALOG2FINDK, self.OnFindkButton) self.Cancel = wxButton(id=wxID_WXDIALOG2CANCEL, label='Cancel', name='Cancel', parent=self.window1, pos=wxPoint(144, 192), size=wxSize(112, 32), style=0) EVT_BUTTON(self.Cancel, wxID_WXDIALOG2CANCEL, self.OnCancelButton) self.staticText1 = wxStaticText(id=wxID_WXDIALOG2STATICTEXT1, label='K-factor:', name='staticText1', parent=self.window1, pos=wxPoint(24, 160), size=wxSize(48, 16), style=wxALIGN_RIGHT) self.staticText1.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxNORMAL, False, 'MS Shell Dlg')) self.staticText3 = wxStaticText(id=wxID_WXDIALOG2STATICTEXT3, label='Dimension D:', name='staticText3', parent=self.window1, pos=wxPoint(24, 128), size=wxSize(92, 16), style=wxALIGN_RIGHT) self.staticText3.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxNORMAL, False, 'MS Shell Dlg')) self.staticText4 = wxStaticText(id=wxID_WXDIALOG2STATICTEXT4, label='Wall Thickness:', name='staticText4', parent=self.window1, pos=wxPoint(24, 80), size=wxSize(95, 16), style=wxALIGN_RIGHT) self.staticText4.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxNORMAL, False, 'MS Shell Dlg')) self.textCtrl3 = wxTextCtrl(id=wxID_WXDIALOG2TEXTCTRL3, name='textCtrl3', parent=self.window1, pos=wxPoint(128, 32), size=wxSize(64, 24), style=0, value='') self.textCtrl3.SetToolTipString('') EVT_TEXT(self.textCtrl3, wxID_WXDIALOG2TEXTCTRL3, self.OnTextctrl3Text) self.textCtrl5 = wxTextCtrl(id=wxID_WXDIALOG2TEXTCTRL5, name='textCtrl5', parent=self.window1, pos=wxPoint(128, 72), size=wxSize(64, 24), style=0, value='') EVT_TEXT(self.textCtrl5, wxID_WXDIALOG2TEXTCTRL5, self.OnTextctrl5Text) self.staticText5 = wxStaticText(id=wxID_WXDIALOG2STATICTEXT5, label='Ext. Diameter:', name='staticText5', parent=self.window1, pos=wxPoint(24, 40), size=wxSize(82, 16), style=wxALIGN_RIGHT) self.staticText5.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxNORMAL, False, 'MS Shell Dlg')) self.staticText9 = wxStaticText(id=wxID_WXDIALOG2STATICTEXT9, label='(NA)', name='staticText9', parent=self.window1, pos=wxPoint(200, 128), size=wxSize(21, 13), style=0) self.staticText9.SetFont(wxFont(8, wxSWISS, wxNORMAL, wxNORMAL, False, 'MS Shell Dlg')) self.staticText6 = wxStaticText(id=wxID_WXDIALOG2STATICTEXT6, label='(NA)', name='staticText6', parent=self.window1, pos=wxPoint(200, 160), size=wxSize(21, 13), style=0) self.staticText6.SetFont(wxFont(8, wxSWISS, wxNORMAL, wxNORMAL, False, 'MS Shell Dlg')) self.staticText8 = wxStaticText(id=wxID_WXDIALOG2STATICTEXT8, label='(NA)', name='staticText8', parent=self.window1, pos=wxPoint(200, 40), size=wxSize(21, 13), style=0) self.staticText10 = wxStaticText(id=wxID_WXDIALOG2STATICTEXT10, label='(NA)', name='staticText10', parent=self.window1, pos=wxPoint(200, 80), size=wxSize(21, 13), style=0) self.staticText2 = wxStaticText(id=wxID_WXDIALOG2STATICTEXT2, label='', name='staticText2', parent=self.window1, pos=wxPoint(128, 128), size=wxSize(0, 13), style=0) self.staticText7 = wxStaticText(id=wxID_WXDIALOG2STATICTEXT7, label='', name='staticText7', parent=self.window1, pos=wxPoint(128, 160), size=wxSize(0, 13), style=0) def __init__(self, parent): self._init_ctrls(parent) #assign the pointer to frame1 to the global variable 'parent' wxDialog2.parent = parent #set the unit labels on 'K' and 'insertion depth' to the appropriate dimensions if parent.unitType == 'BRITISH': self.staticText6.SetLabel('(pulses/gal)') self.staticText9.SetLabel('(in)') self.staticText8.SetLabel('(in)') self.staticText10.SetLabel('(in)') if parent.unitType == 'SI': self.staticText6.SetLabel('(pulses/m^3)') self.staticText9.SetLabel('(m)') self.staticText8.SetLabel('(m)') self.staticText10.SetLabel('(m)') def OnCancelButton(self, event): #Reset variables wxDialog2.haveInterDiam = wxFrame1.FALSE #gets True if the user inputs a acceptable number or two other values are known wxDialog2.haveWallThickness = wxFrame1.FALSE #gets True if the user inputs a acceptable number or two other values are known wxDialog2.haveExtDiam = wxFrame1.FALSE #gets True if the user inputs a acceptable number or two other values are known self.Close() def OnFindkButton(self, event): #--------------------------------------------------------- #Get dimentions #Internal Diameter #wxDialog2.interDiam = self.textCtrl2.GetValue() #Wall thickness wxDialog2.wallThickness = self.textCtrl5.GetValue() #Get the external diameter wxDialog2.extDiam = self.textCtrl3.GetValue() #--------------------------------------------------------- #Determine what two dimensions are given and calculate the third ## try: ## isGoodNum = float(wxDialog2.interDiam)/2 ## wxDialog2.haveInterDiam = wxFrame1.TRUE ## wxDialog2.interDiam = float(wxDialog2.interDiam) ## except: wxDialog2.haveInterDiam = wxFrame1.FALSE try: isGoodNum = float(wxDialog2.wallThickness)/2 wxDialog2.wallThickness = float(wxDialog2.wallThickness) wxDialog2.haveWallThickness = wxFrame1.TRUE except: wxDialog2.haveWallThickness = wxFrame1.FALSE try: isGoodNum = float(wxDialog2.extDiam)/2 wxDialog2.extDiam = float(wxDialog2.extDiam) wxDialog2.haveExtDiam = wxFrame1.TRUE except: wxDialog2.haveExtDiam = wxFrame1.FALSE #Get and fill in the third dimension if any two of the three #dimensions are specified if wxDialog2.haveInterDiam and wxDialog2.haveExtDiam: wxDialog2.wallThickness = (wxDialog2.extDiam - wxDialog2.interDiam)/2 #self.textCtrl5.SetValue(('%5.4f' % wxDialog2.wallThickness)) elif wxDialog2.haveInterDiam and wxDialog2.haveWallThickness: wxDialog2.extDiam = wxDialog2.interDiam + 2*wxDialog2.wallThickness #self.textCtrl3.SetValue(('%5.4f' % wxDialog2.extDiam)) #fill in the external diam or internal diameter if the appropriate #text fields are filled in elif wxDialog2.haveWallThickness and wxDialog2.haveExtDiam: wxDialog2.interDiam = wxDialog2.extDiam - 2*wxDialog2.wallThickness #self.textCtrl2.SetValue(('%5.4f' % wxDialog2.interDiam)) elif wxDialog2.haveInterDiam and wxDialog2.haveWallThickness: wxDialog2.extDiam = wxDialog2.interDiam + 2*wxDialog2.wallThickness #self.textCtrl3.SetValue(('%5.4f' % wxDialog2.extDiam)) #fill in the wall thickness or internal diameter if the appropriate #text fields are filled in elif wxDialog2.haveInterDiam and wxDialog2.haveExtDiam: wxDialog2.wallThickness = (wxDialog2.extDiam - wxDialog2.interDiam)/2 #self.textCtrl5.SetValue(('%5.4f' % wxDialog2.wallThickness)) elif wxDialog2.haveExtDiam and wxDialog2.haveWallThickness: wxDialog2.interDiam = wxDialog2.extDiam - 2*wxDialog2.wallThickness #self.textCtrl2.SetValue(('%5.4f' % wxDialog2.interDiam)) else: dlg = wxMessageDialog(self, 'Internal Error', 'Caption', wxOK | wxICON_INFORMATION) try: dlg.ShowModal() finally: dlg.Destroy() #--------------------------------------------------------- #Determine if conversion of meter height is needed if wxDialog2.parent.unitType == 'BRITISH': conversion = 1.0 elif wxDialog2.parent.unitType == 'SI': conversion = wxFrame1.IN_TO_M #--------------------------------------------------------- #Determine insertion depth; using 12% internal diameter try: if wxDialog2.parent.meterType == wxFrame1.TYPE_EX81: insertionDepth = FALSE elif wxDialog2.parent.meterType == wxFrame1.TYPE_EX82: insertionDepth = FALSE elif wxDialog2.parent.meterType == wxFrame1.TYPE_EX101: insertionDepth = wxFrame1.HEIGHT_EX101*conversion - wxDialog2.wallThickness - (wxFrame1.PERC_INS_DEPTH/100.0)*wxDialog2.interDiam elif wxDialog2.parent.meterType == wxFrame1.TYPE_EX115: insertionDepth = wxFrame1.HEIGHT_EX115*conversion - wxDialog2.wallThickness - (wxFrame1.PERC_INS_DEPTH/100.0)*wxDialog2.interDiam elif wxDialog2.parent.meterType == wxFrame1.TYPE_EX201: insertionDepth = wxFrame1.HEIGHT_EX201*conversion - wxDialog2.wallThickness - (wxFrame1.PERC_INS_DEPTH/100.0)*wxDialog2.interDiam elif wxDialog2.parent.meterType == wxFrame1.TYPE_EX215: insertionDepth = wxFrame1.HEIGHT_EX215*conversion - wxDialog2.wallThickness - (wxFrame1.PERC_INS_DEPTH/100.0)*wxDialog2.interDiam except: dlg = wxMessageDialog(self, 'One or more dimensions are not valid numbers', 'Caption', wxOK | wxICON_INFORMATION) try: dlg.ShowModal() finally: dlg.Destroy() #--------------------------------------------------------- #Determine if conversion of volume is needed if wxDialog2.parent.unitType == 'BRITISH': conversion2 = 1.0 conversion1 = 1.0 elif wxDialog2.parent.unitType == 'SI': conversion2 = wxFrame1.G_TO_M_CUBED conversion1 = wxFrame1.IN_TO_M #--------------------------------------------------------- #POWER FIT try: k = exp(wxFrame1.A2 * log(wxDialog2.interDiam/conversion1) + wxFrame1.B2)*conversion2 #k2 is used for interpolating outside the bounds of empicial data k2 = (conversion2*(wxFrame1.A + wxFrame1.B*(wxDialog2.interDiam/conversion1) + wxFrame1.C*(wxDialog2.interDiam/conversion1)**2 + wxFrame1.D*(wxDialog2.interDiam/conversion1)**3 + wxFrame1.E*(wxDialog2.interDiam/conversion1)**4)) #Set the insertion depth in the appropriate text field self.staticText2.SetLabel(('%5.2f' % insertionDepth)) #check that the input diameter is within the operating range if wxDialog2.interDiam > (2.7*conversion1) and wxDialog2.interDiam < (70*conversion1): #Set the k value in the appropriate text field if wxDialog2.interDiam <= 8.065*conversion1: self.staticText7.SetLabel(('%5.2f' % k2)) elif wxDialog2.interDiam < 70*conversion1: self.staticText7.SetLabel(('%5.2f' % k)) else: dlg = wxMessageDialog(self, 'Internal diameter must be less than 50(in) or 1270(mm) \nand greater than 2.7(in) or 68.5(mm)', 'Caption', wxOK | wxICON_INFORMATION) try: dlg.ShowModal() finally: dlg.Destroy() except: dlg = wxMessageDialog(self, 'One or more dimensions are not valid numbers', 'Caption', wxOK | wxICON_INFORMATION) try: dlg.ShowModal() finally: dlg.Destroy() def OnTextctrl3Text(self, event): pass def OnTextctrl5Text(self, event): pass def OnTextctrl2Text(self, event): pass -------------- next part -------------- #Boa:Frame:wxFrame1 from wxPython.wx import * from wxPython.lib.anchors import LayoutAnchors from wxPython.lib.buttons import * import wxDialog2 from os import * from Numeric import * from cStringIO import * from string import * from fileinput import * from re import * #Globals #for regions inside the bounds of empirical data A = 3.641277972845E+002 B = -1.591675040373E+002 C = 2.581145417181E+001 D = -1.711266756664E+000 E = 3.532598870248E-002 # for regions out of bounds of empirical data this fit is used for interpolating A2 = -2.000000003185E+000 B2 = 6.580587941746E+000 #BOOLEAN FALSE FALSE = 0 #BOOLEAN TRUE TRUE = 1 #THIS NUMBER STORES THE TYPE OF INSERTION METER SPECIFIED BY THE USER #UNDER THE "METER IDENTIFICATION" SECTION OF THE PARENT DIALOG. THIS #IDENTIFICATION IS USED TO IDENTIFY THE "INSERTION DEPTH" OF THE PARTICULAR #METER. INSERTION DEPTH IS DEFINED AS THE DEPTH FROM THE TOP OF THE LOWER #HOUSING FLANGE TO THE FIRST STEP OF THE ELECTRODE CAP. THE FIRST STEP IS THE #LEVEL BELOW THE TIP (SECOND STEP), THE TIP HAS ONE ELECTRODE THE FIRST STEP #HAS TWO. # #MODEL TYPE EX81 TYPE_EX81 = 'TYPE_EX81' #MODEL TYPE EX81 TYPE_EX82 = 'TYPE_EX82' #MODEL TYPE EX101 TYPE_EX101 = 'TYPE_EX101' #MODEL TYPE EX101 TYPE_EX115 = 'TYPE_EX115' #MODEL TYPE EX101 TYPE_EX201 = 'TYPE_EX201' #MODEL TYPE EX101 TYPE_EX215 = 'TYPE_EX215' #CONVERSION UNITS (METERS PER IN); 0.0254 meters per in; reference www.onlineconversion.com IN_TO_M = 0.0254 #CONVERSION UNITS (METERS PER IN); 0.0254 meters per in; reference www.onlineconversion.com #IN_TO_MM = 0.0254*1000.0 #CONVERSION UNITS (METER CUBED PER GALLON; 1 cubic meter = 264.1720512 gallon [US, liquid]; ref www.onlineconversion.com G_TO_M_CUBED = 264.1720512 #CONVERSION UNITS (METER CUBED PER GALLON; 1 gallon [US, liquid] = 3,785,411.8 cubic millimeter; ref www.onlineconversion.com #G_TO_MM_CUBED = 1.0/3785411.8 #MODEL HEIGHT (in); there is not a good reference for these values HEIGHT_EX101 = 10.396 HEIGHT_EX201 = 15.396 HEIGHT_EX115 = 17.396 HEIGHT_EX215 = 21.396 #Insertion Depth, currently using 12% #this was determined from "Flow Measurement," Spitzer #plotting eq. 22-2 PERC_INS_DEPTH = 11.75 def create(parent): return wxFrame1(parent) [wxID_WXFRAME1, wxID_WXFRAME1BUTTON2, wxID_WXFRAME1CANCEL, wxID_WXFRAME1RADIOBOX1, wxID_WXFRAME1RADIOBOX2, wxID_WXFRAME1WINDOW1, ] = map(lambda _init_ctrls: wxNewId(), range(6)) class wxFrame1(wxFrame): #Variables meterType = TYPE_EX101 #Holds the Meter Type selected, default to ex101 unitType = 'BRITISH' #Holds 'BRITISH' or 'SI' unit type selected; default to british units def _init_utils(self): # generated method, don't edit self.icon = wxIcon('horse.ico', wxBITMAP_TYPE_ICO) self.SetIcon(self.icon) pass def _init_ctrls(self, prnt): # generated method, don't edit wxFrame.__init__(self, id=wxID_WXFRAME1, name='', parent=prnt, pos=wxPoint(338, 303), size=wxSize(240, 220), style=wxDEFAULT_FRAME_STYLE | wxCAPTION, title='EX SeaKalc') self._init_utils() self.SetClientSize(wxSize(240, 220)) self.SetFont(wxFont(10, wxSWISS, wxNORMAL, wxNORMAL, False, '@Arial Unicode MS')) self.Enable(True) self.SetAutoLayout(True) self.Show(True) self.window1 = wxWindow(id=wxID_WXFRAME1WINDOW1, name='window1', parent=self, pos=wxPoint(0, 0), size=wxSize(240, 220), style=0) self.button2 = wxButton(id=wxID_WXFRAME1BUTTON2, label='Calculate K and Insertion Depth', name='button2', parent=self.window1, pos=wxPoint(8, 152), size=wxSize(225, 28), style=0) self.button2.SetFont(wxFont(8, wxSWISS, wxNORMAL, wxNORMAL, False, 'MS Shell Dlg')) self.button2.SetForegroundColour(wxColour(250, 0, 0)) EVT_BUTTON(self.button2, wxID_WXFRAME1BUTTON2, self.OnButton2Button) self.Cancel = wxButton(id=wxID_WXFRAME1CANCEL, label='Cancel', name='Cancel', parent=self.window1, pos=wxPoint(8, 184), size=wxSize(225, 28), style=0) EVT_BUTTON(self.Cancel, wxID_WXFRAME1CANCEL, self.OnCancelButton) self.radioBox1 = wxRadioBox(choices=['EX81 ', 'EX82 ', 'EX101 ', 'EX115 ', 'EX201 ', 'EX215 '], id=wxID_WXFRAME1RADIOBOX1, label='Meter Type', majorDimension=3, name='radioBox1', parent=self.window1, point=wxPoint(8, 8), size=wxSize(225, 64), style=0, validator=wxDefaultValidator) self.radioBox1.SetFont(wxFont(8, wxSWISS, wxNORMAL, wxNORMAL, False, 'MS Shell Dlg')) self.radioBox1.Enable(True) self.radioBox1.Show(True) self.radioBox1.SetSelection(2) EVT_RADIOBOX(self.radioBox1, wxID_WXFRAME1RADIOBOX1, self.OnRadiobox1Radiobox) self.radioBox2 = wxRadioBox(choices=['meter/cubic meter', 'inches/gallon'], id=wxID_WXFRAME1RADIOBOX2, label='Unit Type', majorDimension=2, name='radioBox2', parent=self.window1, point=wxPoint(8, 80), size=wxSize(225, 64), style=wxRA_SPECIFY_COLS, validator=wxDefaultValidator) self.radioBox2.Show(True) self.radioBox2.SetSelection(1) EVT_RADIOBOX(self.radioBox2, wxID_WXFRAME1RADIOBOX2, self.OnRadiobox2Radiobox) def __init__(self, parent): self._init_ctrls(parent) def OnButton2Button(self, event): dlg = wxDialog2.wxDialog2(self) try: dlg.ShowModal() finally: dlg.Destroy() def OnCancelButton(self, event): self.Close() def OnRadiobox1Radiobox(self, event): #get the selected meter dummy = self.radioBox1.GetSelection() if dummy == 0: wxFrame1.meterType = TYPE_EX81 if dummy == 1: wxFrame1.meterType = TYPE_EX82 if dummy == 2: wxFrame1.meterType = TYPE_EX101 if dummy == 3: wxFrame1.meterType = TYPE_EX115 if dummy == 4: wxFrame1.meterType = TYPE_EX201 if dummy == 5: wxFrame1.meterType = TYPE_EX215 def OnRadiobox2Radiobox(self, event): #get the selected unit dummy = self.radioBox2.GetSelection() if dummy == 1: wxFrame1.unitType = 'BRITISH' elif dummy == 0: wxFrame1.unitType = 'SI' -------------- next part -------------- #!/usr/bin/env python #Boa:App:BoaApp #------------------------------------------------------- # Version 1.0.0 # by Jeff Peery July 15, 2004 #------------------------------------------------------- # # Add revisions here (number, description, date, initials #________________________ # # 1) initial release, 07/15/2004, JTP # from wxPython.wx import * import wxFrame1 from os import * from Numeric import * from cStringIO import * from string import * from fileinput import * from re import * modules ={'wxDialog1': [0, '', 'wxDialog1.py'], 'wxFrame1': [1, 'Main frame of Application', 'wxFrame1.py']} class BoaApp(wxApp): def OnInit(self): wxInitAllImageHandlers() self.main = wxFrame1.create(None) # needed when running from Boa under Windows 9X self.SetTopWindow(self.main) self.main.Show();self.main.Hide();self.main.Show() return True def main(): application = BoaApp(0) application.MainLoop() if __name__ == '__main__': main() From chris.stromberger at gmail.com Thu Jan 27 00:33:40 2005 From: chris.stromberger at gmail.com (Chris Stromberger) Date: Thu Jan 27 00:34:50 2005 Subject: [python-win32] PIL issue with desktop wallpaper changing Message-ID: I have a script to change the desktop wallpaper. If it encounters a corrupt jpg, it seems to get off track and not recover. Here's the code snippet. This is called in a loop with several jpg images in a directory to switch the wallpaper. im = Image.open(filename) [call im.resize() here if necessary to reduce/enlarge image size to fill screen] im.save('wallpaper.bmp') cs = ctypes.c_buffer('wallpaper.bmp') ok = ctypes.windll.user32.SystemParametersInfoA(win32con.SPI_SETDESKWALLPAPER, 0, cs, 0) The above fails in the im.save call when passed a corrupt jpg--an exception is raised in im.save. I catch it and loop to the next image. The next time this block is called, and for every call thereafter, the SystemParametersInfoA call fails (returns 0), and if I call GetLastError() after that, it shows error 32, which is a file sharing violation. I added an os.unlink('wallpaper.bmp') to the start of this block and it works until the corrupt jpg is processed. Thereafter, the file cannot be deleted ([Errno 13] Permission denied). So it seems like something is grabbing onto the file, but I have no idea how to release that handle or what it is. One further clue: if I raise an exception (anything) after detecting that ok is 0, then the next image I try to load will work. The exception raising clears everything out. So here are the two scenarios: 0. call with normal image(s)--works, wallpaper is changed each time 1. call with corrupt jpg--exception. 2. then call with normal images--SystemParametersInfoA returns 0 every time, wallpaper not changed again. if I add... 3. raise exception if SystemParametersInfoA returns 0--the next and subsequent images work. Until we loop around to the corrupt jpg again. Any ideas what's going on? Thanks, Chris http://www.fetidcascade.com/ From chris.stromberger at gmail.com Thu Jan 27 00:41:10 2005 From: chris.stromberger at gmail.com (Chris Stromberger) Date: Thu Jan 27 00:41:15 2005 Subject: [python-win32] Re: PIL issue with desktop wallpaper changing In-Reply-To: References: Message-ID: One more clue. If I change the code to resize always, then the corrupt jpg fails in the call to im.resize (before it attempts to call im.save), and thereafter there are no problems--the subsequent normal jpgs all work fine. So it appears that by failing in im.save, the 'windows.bmp' file is left with an open handle or somesuch to it somehow, in PIL, somewhere... On Wed, 26 Jan 2005 17:33:40 -0600, Chris Stromberger wrote: > I have a script to change the desktop wallpaper. If it encounters a > corrupt jpg, it seems to get off track and not recover. Here's the > code snippet. This is called in a loop with several jpg images in a > directory to switch the wallpaper. > > im = Image.open(filename) > [call im.resize() here if necessary to reduce/enlarge image size to fill screen] > im.save('wallpaper.bmp') > cs = ctypes.c_buffer('wallpaper.bmp') > ok = ctypes.windll.user32.SystemParametersInfoA(win32con.SPI_SETDESKWALLPAPER, > 0, cs, 0) > > The above fails in the im.save call when passed a corrupt jpg--an > exception is raised in im.save. I catch it and loop to the next > image. The next time this block is called, and for every call > thereafter, the SystemParametersInfoA call fails (returns 0), and if I > call GetLastError() after that, it shows error 32, which is a file > sharing violation. I added an os.unlink('wallpaper.bmp') to the start > of this block and it works until the corrupt jpg is processed. > Thereafter, the file cannot be deleted ([Errno 13] Permission denied). > So it seems like something is grabbing onto the file, but I have no > idea how to release that handle or what it is. > > One further clue: if I raise an exception (anything) after detecting > that ok is 0, then the next image I try to load will work. The > exception raising clears everything out. > > So here are the two scenarios: > > 0. call with normal image(s)--works, wallpaper is changed each time > 1. call with corrupt jpg--exception. > 2. then call with normal images--SystemParametersInfoA returns 0 every > time, wallpaper not changed again. > > if I add... > 3. raise exception if SystemParametersInfoA returns 0--the next and > subsequent images work. Until we loop around to the corrupt jpg > again. > > Any ideas what's going on? > > Thanks, > Chris > > http://www.fetidcascade.com/ > From tim.golden at viacom-outdoor.co.uk Thu Jan 27 09:40:33 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu Jan 27 09:38:50 2005 Subject: [python-win32] Greetings and win32 com events question Message-ID: <9A28C052FF32734DACB0A288A35339910359FF@vogbs009.gb.vo.local> [Robert Kaplan] | I'm new to the mailing, so greetings all! Welcome. As a word of warning, this is a relatively low-activity list and I don't know what the overlap is between this and the main python list. If you get no response (or no solution) here, you might want to try the Python list. | I'm working on an application try to respond to events in Microsoft | Access using Python and win32com. | class AccessEvents | def OnActivate(self): | print "Hello from Access" | return 1 | | | self. ac = Dispatch ("Access.Application") | self. db = self. ac. NewCurrentDatabase ("d:\\pyhack\\foo") | self. fm = self. ac. CreateForm () | self. ac. Visible = true | self. fm = DispatchWithEvents (self. fm, AcEvents) | | blows out with | | self. fm = DispatchWithEvents (self. fm, AcEvents) | File | "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line | 258, in | DispatchWithEvents | clsid = disp_class.CLSID | AttributeError: 'NoneType' object has no attribute 'CLSID'. Well, it's not clear from your code, but the third parameter to DispatchWithEvents should be a *class* and not an *instance*. Since AcEvents isn't defined anywhere within your code snippet, it's hard to see which it is, but just in case... That said, I can't for the life of me see why that would raise the error you're showing, but first things first. 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 tim.golden at viacom-outdoor.co.uk Thu Jan 27 09:53:19 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu Jan 27 09:51:41 2005 Subject: [python-win32] How to access Visual Basic's "Application" obj ect, in Python Message-ID: <9A28C052FF32734DACB0A288A3533991035A00@vogbs009.gb.vo.local> [Tony Cappellini] | | I am trying to mimic a short VB program in Python, which | iterates over an | Outlook 2002 global address list. | | However, I don't know what to use in Python, for VB's | Application object, which is like a pointer to the entire | process that is running the application. From Application, | I can access the name of the executable, | the version number, tha path, and some other attibutes. I admit I hadn't heard of the Application object as something outside Outlook. Care to give an example of these extra attributes. At the risk of stating the obvious, the code below seems to reproduce what your own code is doing. (But maybe you knew that). import win32com.client outlook = win32com.client.gencache.EnsureDispatch ("Outlook.Application") # # Assume you've got an Outlook session running, # so don't bother specifying a profile. # outlook.Session.Logon () namespace = outlook.GetNamespace ("MAPI") global_address_list = namespace.AddressLists["Global Address List"] address_entries = global_address_list.AddressEntries["!IT Development"] print address_entries.Members.Count for i in range (address_entries.Members.Count): member = address_entries.Members[i + 1] print member.Name, member.Address 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 p.f.moore at gmail.com Thu Jan 27 10:20:24 2005 From: p.f.moore at gmail.com (Paul Moore) Date: Thu Jan 27 10:20:27 2005 Subject: [python-win32] Re: PIL issue with desktop wallpaper changing In-Reply-To: References: Message-ID: <79990c6b050127012065449909@mail.gmail.com> On Wed, 26 Jan 2005 17:41:10 -0600, Chris Stromberger wrote: > One more clue. If I change the code to resize always, then the > corrupt jpg fails in the call to im.resize (before it attempts to call > im.save), and thereafter there are no problems--the subsequent normal > jpgs all work fine. So it appears that by failing in im.save, the > 'windows.bmp' file is left with an open handle or somesuch to it > somehow, in PIL, somewhere... This sounds more like a PIL bug, which I'd report on the image-sig mailing list. I know Fredrik hangs out there, so he may be able to help. You should probably quote the version of PIL you are using, as well. Paul From belovedbob at greennet.net Thu Jan 27 16:37:43 2005 From: belovedbob at greennet.net (Robert Kaplan) Date: Thu Jan 27 16:36:53 2005 Subject: [python-win32] Re: Greetings and win32 com events question (Typo corrected) Message-ID: <41F90AC7.4060208@greennet.net> Hi, Apologies, I screwed up with a typo. AcEvents was another class identical to AccessEvents. The problem is the same. class AcEvents def OnActivate(self): print "Hello from Access" return 1 self. ac = Dispatch ("Access.Application") self. db = self. ac. NewCurrentDatabase ("d:\\pyhack\\foo") self. fm = self. ac. CreateForm () self. ac. Visible = true self. fm = DispatchWithEvents (self. fm, AcEvents) blows out with self. fm = DispatchWithEvents (self. fm, AcEvents) File "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line 258, in DispatchWithEvents clsid = disp_class.CLSID AttributeError: 'NoneType' object has no attribute 'CLSID'. Second code snippet has the same screwup: self. ac = Dispatch ("Access.Application") self. db = self. ac. NewCurrentDatabase ("d:\\pyhack\\foo") self. fm = self. ac. CreateForm () self. ac. Visible = true self. ev = AcEvents () self. fm. OnActivate = self. ev. OnActivate this couldn't set the OnActivate attribute with the following error. File "D:\pyhack\1\Bob.py", line 132, in DoAccess self. fm. OnActivate = self. ev. OnActivate File "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line 503, in __setattr__ d.__setattr__(attr, value) File "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line 463, in __setattr__ self._oleobj_.Invoke(*(args + (value,) + defArgs)) TypeError: Objects of type 'instance method' can not be converted to a COM VARIANT Tim Golden wrote: > [Robert Kaplan] > > | I'm new to the mailing, so greetings all! > > Welcome. As a word of warning, this is a relatively > low-activity list and I don't know what the overlap > is between this and the main python list. If you get > no response (or no solution) here, you might want > to try the Python list. > > | I'm working on an application try to respond to events in Microsoft > | Access using Python and win32com. > > | class AccessEvents > | def OnActivate(self): > | print "Hello from Access" > | return 1 > | | > | self. ac = Dispatch ("Access.Application") > | self. db = self. ac. NewCurrentDatabase ("d:\\pyhack\\foo") > | self. fm = self. ac. CreateForm () > | self. ac. Visible = true > | self. fm = DispatchWithEvents (self. fm, AcEvents) > | | blows out with > | | self. fm = DispatchWithEvents (self. fm, AcEvents) > | File | > "D:\PYTHON22\Lib\site-packages\win32com\client\__init__.py", line | > 258, in > | DispatchWithEvents > | clsid = disp_class.CLSID > | AttributeError: 'NoneType' object has no attribute 'CLSID'. > > Well, it's not clear from your code, but the third > parameter to DispatchWithEvents should be a *class* > and not an *instance*. Since AcEvents isn't defined > anywhere within your code snippet, it's hard to > see which it is, but just in case... > > That said, I can't for the life of me see why that > would raise the error you're showing, but first > things first. > > TJG > > _______________________________________________________________________ > > From benn at cenix-bioscience.com Fri Jan 28 11:49:09 2005 From: benn at cenix-bioscience.com (Neil Benn) Date: Fri Jan 28 11:48:12 2005 Subject: [python-win32] Determine file being accessed Message-ID: <41FA18A5.7070607@cenix-bioscience.com> Hello, I have a job where I need to move a file on a trigger from another program, however this program may or may not have finished writing to the file when I need to move it (I have no way of changing this behavior). Therefore I need to determine if a file is still being written to, this is on a windows XP box. Does anyone know of a way to determine this using python (I'd prefer to use python as my company is a python shop and using anything else will create support issues)? Thanks, in advance for your help. Cheers, Neil -- Neil Benn Senior Automation Engineer Cenix BioScience BioInnovations Zentrum Tatzberg 46 D-01307 Dresden Germany Tel : +49 (0)351 4173 154 e-mail : benn@cenix-bioscience.com Cenix Website : http://www.cenix-bioscience.com From Richard.Kerry at bbc.co.uk Fri Jan 28 13:18:45 2005 From: Richard.Kerry at bbc.co.uk (Richard Kerry) Date: Fri Jan 28 13:18:47 2005 Subject: [python-win32] Embedding and Extending Python within one C++ dll, on Windows. Message-ID: <6A2513361DC9DB4F8660B859A5DBE82D7C8064@bbcxue214.national.core.bbc.co.uk> I wonder if someone can provide me with some advice, or guide me to resources where I can find this information. I am trying to embed Python in a C++ class, and also extend it with code in that class, or more accurately with code in a base class of that class. This is in Windows, so it's all in one DLL. My class represents the actions for a graphical control panel. This we refer to as the Script file and it has previously been written in C++. The class has a base class which contains some useful member functions for the Script to call to carry out its actions. As I've said, this is currently in C++. The class is created, and its constructor creates the graphical part of the control panel. When the user pushes buttons on the graphical panel, calls are generated to a ButtonPush handler in the C++ class. This is written using simple C++ and calls functions in its own base class to perform actions. What I want to do is to be able to implement the ButtonPush handler in Python. I've embedded a Python interpreter in the class, and I can get it to import another dll. But I already have the functions I want in this class, in this dll. Ie I want it to call straight back into this class (ie this dll), not load another. It seems I might be wanting to perform the actions of an import, but on the contents of my class (or my base class), rather than a newly read dll. Can I do this ? Is there any extra documentation I might have missed ? (Python ext.pdf goes into writing the Extensions in a dll and importing it, which I don't think is what I want). Uncertainly, Richard. Richard Kerry Colledia Control Engineer Siemens Business Services Media (formerly BBC Technology) Room 457 Design Building, Television Centre Tel: +44 (0)20 8225 9063 Fax: +44 (0)208 576 8182 Mobile: +44 (0)7973 817745 Email: richard.kerry@bbc.co.uk This e-mail (and any attachments) contains confidential information and is for the exclusive use of the addressee/s. Any views contained in this e-mail are not the views of Siemens Business Services Ltd unless specifically stated. If you are not the addressee, then any distribution, copying or use of this e-mail is prohibited. If received in error, please advise the sender and delete/destroy it immediately. We accept no liability for any loss or damage suffered by any person arising from use of this e-mail/fax. Please note that Siemens Business Services Ltd monitors e-mails sent or received. Further communication will signify your consent to this. Siemens Business Services Ltd Registered No: 04128934 England Registered Office: Siemens House, Oldbury, Bracknell, Berkshire, RG12 8FZ 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 tim.golden at viacom-outdoor.co.uk Fri Jan 28 15:18:24 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Fri Jan 28 15:16:32 2005 Subject: [python-win32] Determine file being accessed Message-ID: <9A28C052FF32734DACB0A288A3533991035A07@vogbs009.gb.vo.local> [Neil Benn] | I have a job where I need to move a file on a trigger from | another program, however this program may or may not have finished | writing to the file when I need to move it (I have no way of changing | this behavior). Therefore I need to determine if a file is | still being written to, this is on a windows XP box. [Hand-waving answer, faute de mieux] I believe you could do this by combining win32file.CreateFile and win32file.LockFile from pywin32. Looks that way to me, anyhow. But I haven't tried it (and don't have time to experiment at the mo). 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 quadric at primenet.com Fri Jan 28 22:50:33 2005 From: quadric at primenet.com (quadric@primenet.com) Date: Fri Jan 28 22:43:10 2005 Subject: [python-win32] 'import win32com' fails from within an embedded interpreter Message-ID: <5.1.1.6.2.20050128144156.02f39128@pop3.globalcrossing.net> I'm hoping someone can give me some advice, or point me in a helpful direction. I've embedded python 2.4 within an application that needs to connect with MS Excel. I've written the python code to communicate with Excel and tested it from the python command line interpreter. It works great! However, when I attempt to import win32com from within the embedded interpreter I get the following: "Fatal Python error: Can not setup interpreter state, as current state is invalid" The python startup file that executes the 'import win32com' code is successfully executing lots of other code including imports of other site-packages. Can anyone give me an idea as to what I might do to solve this dilemma ? Thanks for your help. From mhammond at skippinet.com.au Fri Jan 28 23:43:36 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri Jan 28 23:43:41 2005 Subject: [python-win32] 'import win32com' fails from within an embeddedinterpreter In-Reply-To: <5.1.1.6.2.20050128144156.02f39128@pop3.globalcrossing.net> Message-ID: <0a9e01c5058a$ce2e3e50$f502a8c0@enfoldsystems.local> > I'm hoping someone can give me some advice, or point me in a > helpful direction. > > I've embedded python 2.4 within an application that needs to > connect with > MS Excel. > I've written the python code to communicate with Excel and > tested it from > the python > command line interpreter. It works great! However, when I > attempt to > import win32com > from within the embedded interpreter I get the following: > > "Fatal Python error: Can not setup interpreter state, as > current state is > invalid" You need to look into the PyGILState_* functions. These functions allow you to acquire the thread-lock before calling into Python. Your code will look something like: PyGILState_STATE old_state = PyGILState_Ensure() // you can now safely call Python functions from this thread. // When all your Python work is complete... PyGILState_Release() // The lock for this thread has now been released. This thread can // no longer safely call Python functions until the lock is re-acquired. Mark From RyanP at foxracing.com Fri Jan 28 23:57:51 2005 From: RyanP at foxracing.com (Ryan Parrish) Date: Fri Jan 28 23:57:54 2005 Subject: [python-win32] Folder permissions Message-ID: Hi, this is my first jump into the win32 world of python so please excuse me and carry on your normal life's if what I'm saying makes no sense at all :-) I am trying to write a script that will walk all my directories and get the users/groups and there respective permissions that are assigned to the folder, but I cant seem to find a suitable part to start. I found the demo script called FileSecurityTest.py that seemed like what I was looking for, but the functions it uses win32security.GetFileSecurity() don't seem to return all permissions, all it really returns is the owner, and the data it gives for groups is incorrect. So I started looking in the docs and found what to me looked like EXACTLY what I was trying to do... http://aspn.activestate.com/ASPN/docs/ActivePython/2.2/PyWin32/html/win32/help/security_directories.html But it only gives the C code for this fileperm module?!? I cant file fileperm any ware on my system or in a fresh download from the site :-/ I don't have visual studio to compile this so I can begin using it, has anyone compiled it and could perhaps send me a copy? _-`-_-`-_-`-_-`-_-`-_-`-_-`-_-`-_-`-_ Ryan Parrish ryanp@foxracing.com IT Dept. 408-776-8633 extension 1229 Please direct all support questions to - (?`?.??.-> itsupport@foxracing.com _-`-_-`-_-`-_-`-_-`-_-`-_-`-_-`-_-`-_ From rwupole at msn.com Sat Jan 29 01:13:27 2005 From: rwupole at msn.com (Roger Upole) Date: Sat Jan 29 01:13:33 2005 Subject: [python-win32] Re: Determine file being accessed Message-ID: You get permission denied if you try to move a file while it's being written to, so you could just keep on trying to move it until you succeed. I actually had to do this once, and it worked very reliably. Roger "Neil Benn" wrote: > Hello, > > I have a job where I need to move a file on a trigger from > another program, however this program may or may not have finished > writing to the file when I need to move it (I have no way of changing > this behavior). Therefore I need to determine if a file is still being > written to, this is on a windows XP box. > > Does anyone know of a way to determine this using python (I'd prefer > to use python as my company is a python shop and using anything else > will create support issues)? > > Thanks, in advance for your help. > > Cheers, > > Neil From rwupole at msn.com Sat Jan 29 01:44:41 2005 From: rwupole at msn.com (Roger Upole) Date: Sat Jan 29 01:44:46 2005 Subject: [python-win32] Re: Folder permissions Message-ID: GetFileSecurity should be able to pick up the correct info, assuming you have sufficient permission to read the security descriptor. Does it pick up any permissions at all ? GetNamedSecurityInfo which the fileperm c code uses is also in the win32security module. What leads you to conclude that the group info is wrong ? Roger From RyanP at foxracing.com Sat Jan 29 02:02:37 2005 From: RyanP at foxracing.com (Ryan Parrish) Date: Sat Jan 29 02:02:41 2005 Subject: [python-win32] Re: Folder permissions Message-ID: Here is what I have as a little test... import os, win32security, ntsecuritycon for root, dirs, files in os.walk("c:\\"): sd= win32security.GetFileSecurity(root, win32security.GROUP_SECURITY_INFORMATION) sid= sd.GetSecurityDescriptorGroup() print root," ", win32security.LookupAccountSid(None, sid) I do have the necessary permission as I am a local admin on my box. Using OWNER_SECURITY_INFORMATION correctly returns owner of the file/directory, but with GROUP_SECURITY_INFORMATION it returns seemingly random groups from my domain that I absolutely know are not assigned on my box (yes I checked also), besides it only seems to return one group - I'm looking for all the groups that have access to the folder. Ah, now I see that win32security.GetNamedSecurityInfo, that's what they are talking about with the example, I totally didn't get that doh! Let me see if I can figure out win32security.GetNamedSecurityInfo. -Ryan Parrish -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org] On Behalf Of Roger Upole Sent: Friday, January 28, 2005 4:45 PM To: python-win32@python.org Subject: [python-win32] Re: Folder permissions GetFileSecurity should be able to pick up the correct info, assuming you have sufficient permission to read the security descriptor. Does it pick up any permissions at all ? GetNamedSecurityInfo which the fileperm c code uses is also in the win32security module. What leads you to conclude that the group info is wrong ? Roger _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From alex at moreati.org.uk Sat Jan 29 02:52:42 2005 From: alex at moreati.org.uk (Alex Willmer) Date: Sat Jan 29 02:52:39 2005 Subject: [python-win32] Folder permissions In-Reply-To: References: Message-ID: <41FAEC6A.9020601@moreati.org.uk> Ryan Parrish wrote: >Hi, this is my first jump into the win32 world of python so please excuse me and carry on your normal life's if what I'm saying makes no sense at all :-) > >I am trying to write a script that will walk all my directories and get the users/groups and there respective permissions that are assigned to the folder, but I cant seem to find a suitable part to start. > I was fighting this.. verbose API a while back. A few messages from the list archive might be of interest to you: http://mail.python.org/pipermail/python-win32/2003-June/001104.html http://mail.python.org/pipermail/python-win32/2003-June/001102.html I'm sorry to say I never got to the bottom of it. There are examples of the file security api in Mak Hammond's book, I dont have it right now so I'm afraid I can't say exactly what they cover. As an alternative you might try running cacls.exe or xcacls.exe and capturing the ouput. From rwupole at msn.com Sat Jan 29 04:42:03 2005 From: rwupole at msn.com (Roger Upole) Date: Sat Jan 29 04:42:10 2005 Subject: [python-win32] Re: Folder permissions Message-ID: There will only be a single group on the security descriptor itself. Depending on who created the files and how they were created, it wouldn't be unusual to have a variety of groups present on different files. To get a list of everyone who has access, you need to look at the DACL. It includes groups as well as users that have permissions. (or have been denied access) Roger From rwupole at msn.com Sat Jan 29 05:01:45 2005 From: rwupole at msn.com (Roger Upole) Date: Sat Jan 29 05:01:51 2005 Subject: [python-win32] Re: Using win32file.CreateDirectory including setting Message-ID: Note the flags in the ACE when you set the permissions manually. The difference is not in the access mask, but in the flags. AddAccessAllowedAce doesn't provide for inheritance flags. You need to use AddAccessAllowedAceEx in order to be able to duplicate these permissions exactly. acl2.AddAccessAllowedAceEx(win32security.ACL_REVISION_DS, win32security.OBJECT_INHERIT_ACE|win32security.CONTAINER_INHERIT_ACE, win32file.FILE_ALL_ACCESS, sid) Better late than never ;) Roger Alex Willmer wrote: > > win32file.CreateDirectory(r'c:\test42',sa) > > My problem is that I need users to have 'Full Control' of the directory, > as reported by the properties dialog of the directory. The > win32file.FILE_ALL_ACCESS doesn't achieve this, it reports the directory > as having 'Special Access', with none of the checkboxes in the advanced > page ticked. > > What is the correct constant to pass to acl.AddAccessAllowedAce? > OK, a little more playing reveals the following. C:\test43 was created manually and my account given full permission >>> import win32file, win32security, ntsecuritycon >>> sd = win32security.GetFileSecurity(r'c:\test42',win32security.DACL_SECURITY_INFORMATION) >>> acl = sd.GetSecurityDescriptorDacl() >>> acl.GetAceCount() 1 >>> acl.GetAce(0) ((0, 3), 2032127, ) >>> def bin(x): return ''.join([('0','1')[(x >> i) & 0x01] for i in range(31,-1,-1)]) ... >>> bin(acl.GetAce(0)[1]) '00000000000111110000000111111111' >>> This all seems good so far, however: >>> sid = win32security.LookupAccountName('','alex')[0] >>> sa = win32security.SECURITY_ATTRIBUTES() >>> acl2 = win32security.ACL(128) >>> acl2.AddAccessAllowedAce(x, sid) >>> sa.SetSecurityDescriptorDacl(1,acl2,0) >>> win32file.CreateDirectory(r'c:\test44',sa) >>> win32file.FILE_ALL_ACCESS 2032127 >>> win32file.FILE_ALL_ACCESS==x 1 From Simon.Whitaker at shell.com Sun Jan 30 22:50:38 2005 From: Simon.Whitaker at shell.com (Whitaker, Simon SITI-SITI) Date: Sun Jan 30 22:50:45 2005 Subject: [python-win32] Re: Folder permissions Message-ID: <780B7166263B764E850C1F846AC2C887024FA9F8@mlb-s-027.asia-pac.shell.com> Isn't a sharing caring community great? It just so happens that this is the first problem i chose to tackle as i am learning Python as well. Below is the code you require (i think) with the C translated to Python. Cheers, Simon --- import os, sys, time, win32net, getopt, win32security, string All_perms={ 1:"ACCESS_READ", #0x00000001 2:"ACCESS_WRITE", #0x00000002 4:"ACCESS_CREATE", #0x00000004 8:"ACCESS_EXEC", #0x00000008 16:"ACCESS_DELETE", #0x00000010 32:"ACCESS_ATRIB [sic]", #0x00000020 64:"ACCESS_PERM", #0x00000040 32768:"ACCESS_GROUP", #0x00008000 65536:"DELETE", #0x00010000 131072:"READ_CONTROL", #0x00020000 262144:"WRITE_DAC", #0x00040000 524288:"WRITE_OWNER", #0x00080000 1048576:"SYNCHRONIZE", #0x00100000 16777216:"ACCESS_SYSTEM_SECURITY",#0x01000000 33554432:"MAXIMUM_ALLOWED", #0x02000000 268435456:"GENERIC_ALL", #0x10000000 536870912:"GENERIC_EXECUTE",#0x20000000 1073741824:"GENERIC_WRITE", #0x40000000 65535:"SPECIFIC_RIGHTS_ALL",#0x0000ffff 983040:"STANDARD_RIGHTS_REQUIRED",#0x000f0000 2031616:"STANDARD_RIGHTS_ALL",#0x001f0000 } Typical_perms={ 2032127L:"Full Control(All)", 1179817L:"Read(RX)", 1180086L:"Add", 1180095L:"Add&Read", 1245631L:"Change" } def fileperm_get_perms(file): all_perms = {} mask = win32security.OWNER_SECURITY_INFORMATION | win32security.GROUP_SECURITY_INFORMATION | win32security.DACL_SECURITY_INFORMATION sd=win32security.GetFileSecurity(file, mask) ownersid=sd.GetSecurityDescriptorOwner() dacl=sd.GetSecurityDescriptorDacl() count = dacl.GetAceCount() for i in range(count): ace = dacl.GetAce(i) user, domain, int = win32security.LookupAccountSid(None, ace[2]) all_perms[domain+"\\"+user] = ace[1] return all_perms def get_mask(mask): a=2147483648L if Typical_perms.has_key(mask): return Typical_perms[mask] else: result='' while a>>1: a=a>>1 masked=mask&a if masked: if All_perms.has_key(masked): result=All_perms[masked]+':'+result return result def is_group(sys_id): #get the server for the domain -- it has to be a primary dc group=0 resume=0 sys_id=string.strip(sys_id) if D_group.has_key(sys_id): group=1 elif D_except.has_key(sys_id): group=0 else: try: #info returns a dictionary of information info = win32net.NetGroupGetInfo(Server, sys_id, 0) group=1 except: try: win32net.NetLocalGroupGetMembers(Server, sys_id, 0,resume,4096) group=1 except: pass return group def get_perm_base(file): all_perms=fileperm_get_perms(file) for (domain_id,mask) in all_perms.items(): (domain,sys_id)=string.split(domain_id,'\\',1) mask_name=get_mask(mask) Results.append(file+','+sys_id+','+mask_name) def get_perm(file): perm_list=[] perm_list.append(file) all_perms=fileperm_get_perms(file) for (domain_id,mask) in all_perms.items(): (domain,sys_id)=string.split(domain_id,'\\',1) print domain,sys_id sys_id=str(sys_id) mask_name=get_mask(mask) if len(sys_id)<7: perm_list.append(sys_id+'\t\t\t'+mask_name) elif len(sys_id)>14: perm_list.append(sys_id+'\t'+mask_name) else: perm_list.append(sys_id+'\t\t'+mask_name) return perm_list def get_perms(arg, d, files): a=2147483648L #1L<<31L print 'Now at ',d for i in files: file=d+'\\'+i if opts['-d']: if not os.path.isdir(file): # skip non-directories continue all_perms=fileperm_get_perms(file) for (domain_id,mask) in all_perms.items(): if string.find(domain_id,'\\')!=-1: (domain,sys_id)=string.split(domain_id,'\\',1) else: sys_id=domain_id mask_name=get_mask(mask) Results.append(file+','+sys_id+','+mask_name) Results.sort() return Results ###################################################################################################### #h - help #r - recursive #o - output file #d - directories only domain='domain' Server=str(win32net.NetGetDCName("",domain)) print '************************ Using domain ',domain only_dir=0 D_group={} D_except={} if len(sys.argv)==1: print sys.argv[0]," file or directory" print "-r for recursive mode \n-o for output file (default screen) \n-d for directories only" print 'Example:',sys.argv[0],'-o a.txt -r c:\\junk \n ----goes down dir tree in c:\\junk and saves in a.txt' sys.exit(0) else: try: optlist, args = getopt.getopt(sys.argv[1:], 'dho:r') except getopt.error: print "invalid option. available options are: -d -h -r -o " print "-r for recursive mode \n-o for output file (default screen) \n-d for directories only" sys.exit(0) opts = {'-d':0,'-h':0,'-o':0,'-r':0} for key, value in optlist: opts[key]=1 if key == '-o': opts[key]=value init=time.clock() Results=[] if opts['-r']: if os.path.isdir(args[0]): print 'walking thru',args[0] get_perm_base(args[0]) os.path.walk(args[0],get_perms,opts['-d']) else: print 'Directory',args[0],'does not exist' sys.exit(0) else: if os.path.exists(args[0]): Results=get_perm(args[0]) else: print 'Directory or file',args[0],'does not exist' sys.exit(0) #now print out the results if opts['-o']: #send to a file print 'Storing results in',opts['-o'] f=open(opts['-o'],'w') for i in Results: f.write(i) f.write('\n') else: for i in Results: print i end = time.clock()-init --- From davesum99 at yahoo.com Sun Jan 30 21:41:31 2005 From: davesum99 at yahoo.com (david sumner) Date: Mon Jan 31 19:27:27 2005 Subject: [python-win32] using MCI and related interfaces with pywin32 Message-ID: <20050130204131.73719.qmail@web31006.mail.mud.yahoo.com> hi -- Using pywin32, I'm trying to invoke multimedia devices with the MCI (Media Control Interface) API's. These commands do stuff like play video files. The strange thing is, all the relevant commands are defined in mmsystem.py, but the critical core functions used to send commands, such as mciSendString(), do not appear to be defined anywhere. Help? __________________________________ Do you Yahoo!? Yahoo! Mail - Easier than ever with enhanced search. Learn more. http://info.mail.yahoo.com/mail_250 From pythonmailing at web.de Mon Jan 31 20:40:22 2005 From: pythonmailing at web.de (Marek Kubica) Date: Mon Jan 31 20:39:16 2005 Subject: [python-win32] using MCI and related interfaces with pywin32 In-Reply-To: <20050130204131.73719.qmail@web31006.mail.mud.yahoo.com> References: <20050130204131.73719.qmail@web31006.mail.mud.yahoo.com> Message-ID: <20050131204022.00000824@galileo> On Sun, 30 Jan 2005 12:41:31 -0800 (PST) david sumner wrote: > Using pywin32, I'm trying to invoke multimedia devices > with the MCI (Media Control Interface) API's. These > commands do stuff like play video files. > > The strange thing is, all the relevant commands are > defined in mmsystem.py, but the critical core > functions used to send commands, such as > mciSendString(), do not appear to be defined anywhere. > > Help? def mci(): import ctypes wm = ctypes.windll.WINMM wm.mciSendStringA("Set CDAudio Door Open wait", 0, 0, 0) wm.mciSendStringA("Set CDAudio Door Closed wait", 0, 0, 0) I used this to open my cdrom tray. It uses whe winmm.dll and ctypes (which is always a nice thing to have) greets, Marek