From mhammond at skippinet.com.au Wed Dec 1 04:25:51 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed Dec 1 04:25:37 2004 Subject: [python-win32] How to use Common Controls In-Reply-To: <20041130192509.26686.qmail@web51306.mail.yahoo.com> Message-ID: <09d201c4d755$7632cfd0$0300a8c0@enfoldsystems.local> MONTHCAL_CLASS is a #define. CommCtrl.h has: #define MONTHCAL_CLASSW L"SysMonthCal32" #define MONTHCAL_CLASSA "SysMonthCal32" So you probably want "SysMonthCal32" rather than MONTHCAL_CLASS Mark -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org]On Behalf Of Wara Songkran Sent: Wednesday, 1 December 2004 6:25 AM To: python-win32@python.org Subject: [python-win32] How to use Common Controls Hi I've try to use Common Controls like Date and Time Picker I Initializes specific common controls with win32gui.InitCommonControlsEx(flag) the parameter ICC_ constants is 256 which is ICC_DATE_CLASSES I found defined in COMMCTRL.h so I've call ICC_DATE_CLASSES = 0x00000100 win32gui.InitCommonControlsEx(ICC_DATE_CLASSES) but when I try to create Date and Time Picker Control with dateHwnd = CreateWindow("MONTHCAL_CLASS", None, WS_CHILD | WS_VISIBLE, 300, 300, 50, 50, self.hwnd, 0, GetWindowLong(self.hwnd, GWL_HINSTANCE), None) python report error: (1407, 'CreateWindow', 'Cannot find window class.') please help. Regard Wara Songkran ---------------------------------------------------------------------------- -- Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041201/8590ad58/attachment.htm From rdm at rcblue.com Wed Dec 1 07:03:18 2004 From: rdm at rcblue.com (Dick Moores) Date: Wed Dec 1 07:03:23 2004 Subject: [python-win32] Problem with 2.4's IDLE Message-ID: <6.1.2.0.2.20041130220236.04610620@rcblue.com> I installed 2.4 today and find that when using its IDLE, File|Open opens to \Documents and Settings\Dick, a long ways from \Python24. Actually, I'd prefer \Python24\MyScripts. Same for File|Save. Is there a way to control this behavior? WinXP Thanks, Dick Moores rdm@rcblue.com From paandev at yahoo.com Wed Dec 1 08:33:26 2004 From: paandev at yahoo.com (Wara Songkran) Date: Wed Dec 1 08:33:28 2004 Subject: [python-win32] How to use Common Controls In-Reply-To: <09d201c4d755$7632cfd0$0300a8c0@enfoldsystems.local> Message-ID: <20041201073326.42299.qmail@web51306.mail.yahoo.com> It's work! thanks. Mark Hammond wrote: MONTHCAL_CLASS is a #define. CommCtrl.h has: #define MONTHCAL_CLASSW L"SysMonthCal32" #define MONTHCAL_CLASSA "SysMonthCal32" So you probably want "SysMonthCal32" rather than MONTHCAL_CLASS Mark -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org]On Behalf Of Wara Songkran Sent: Wednesday, 1 December 2004 6:25 AM To: python-win32@python.org Subject: [python-win32] How to use Common Controls Hi I've try to use Common Controls like Date and Time Picker I Initializes specific common controls with win32gui.InitCommonControlsEx(flag) the parameter ICC_ constants is 256 which is ICC_DATE_CLASSES I found defined in COMMCTRL.h so I've call ICC_DATE_CLASSES = 0x00000100 win32gui.InitCommonControlsEx(ICC_DATE_CLASSES) but when I try to create Date and Time Picker Control with dateHwnd = CreateWindow("MONTHCAL_CLASS", None, WS_CHILD | WS_VISIBLE, 300, 300, 50, 50, self.hwnd, 0, GetWindowLong(self.hwnd, GWL_HINSTANCE), None) python report error: (1407, 'CreateWindow', 'Cannot find window class.') please help. Regard Wara Songkran --------------------------------- Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. --------------------------------- Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041130/dbf1e006/attachment.html From lbates at syscononline.com Wed Dec 1 15:15:17 2004 From: lbates at syscononline.com (Larry Bates) Date: Wed Dec 1 15:15:23 2004 Subject: [python-win32] Service not seen in Services list on XP? In-Reply-To: <20041201110016.12D5A1E4009@bag.python.org> Message-ID: <004901c4d7b0$2fd87f70$5d00a8c0@LABWXP> To get my services to show up I do following: python servicescript.py install After that I can start by: python servicescript.py start or by using Windows servicemanager. I've done several services and they have all worked properly when installed/run using this method. I have also used py2exe to create .exe for services but the method for installing, starting/stopping is a little different for them and the eventlog handling is a little "tricky". Larry Bates ---------------------------------------------------------------------- Message: 1 Date: Tue, 30 Nov 2004 08:52:33 -0700 From: "Craig H. Anderson" Subject: [python-win32] Service not seen in Services list on XP? To: python-win32@python.org Message-ID: Content-Type: text/plain; format=flowed; charset="iso-8859-1" I am working on a windows service with info from Chapter 18 of Mark Hammond's book, Python Programming on Win32. The OS is Windows XP Pro. I can register and start the service by running the script with command line arguments install and start respectively. The event viewer shows the logs properly. I do not see PythonService or my service in the Services panel. I want the service to be auto started and start/stop available from the services panel. What is going on? From craig at coot.net Wed Dec 1 00:43:20 2004 From: craig at coot.net (Craig H. Anderson) Date: Wed Dec 1 17:24:34 2004 Subject: [python-win32] Re: Service not seen in Services list on XP? Message-ID: On closer inspection the service is in the Services list. The service name is the value of _svc_display_name_ From Richard at artsalliancemedia.com Wed Dec 1 15:06:01 2004 From: Richard at artsalliancemedia.com (Richard Cooper) Date: Wed Dec 1 17:24:39 2004 Subject: [python-win32] servicemanager.pyd still in use after service termination Message-ID: I have a xml-rpc server written in python which I: - Run as a service with win32serviceutil.ServiceFramework - Turn into an exe with py2exe - Install with inno setup I noticed that every so often running the installer over an existing installation would complain about servicemanager.pyd being still in use. This is despite the installer running 'net stop MyService' and 'MyService.exe -remove' before copying files. Digging a little deeper with Process Explorer I found that while MyService was running servicemanager.pyd was in use by MyService.exe and after calling 'net stop MyService' is was in use by nothing. This is as I expected. The problem is that my service reads a config file on start up and might raise an exception in SvcDoRun. (Causing the service to stop and the exception to be written to the system event log.) When the service terminates in this way servicemanager.pyd is not released properly. Instead it stops being used by MyService.exe and starts being used by Wmiprvse.exe! As a hacky workaround I wrapped my whole SvcDoRun in try: # my non service related code except: pass This 'fixed' the problem. Now the exe exits cleanly in both circumstances but I don't get the useful 'exception written to event log' behaviour. So, having described my situation I guess my questions are: 1) Any idea why this is happening? Is this a bug or user error? Should I be doing something else in SvcDoRun (or SvcRun)? 2) I couldn't find where exceptions from SvcDoRun are handled. Is what it's doing any different from: try: #SvnRun except: # write to event log # exit If not then why is Wmiprvse.exe grabbing servicemanager.pyd 3) If there is nothing I can do to fix the problem properly then can someone point me at documentation for writing the exception to the event log myself. Thanks in advance, Richard From jeffpeery at seametrics.com Wed Dec 1 18:48:19 2004 From: jeffpeery at seametrics.com (Jeff Peery) Date: Wed Dec 1 18:48:23 2004 Subject: [python-win32] debugger not working? Message-ID: <000101c4d7cd$f25f35d0$7600000a@seametrics.local> Hello, I am using the Boa Constructor to build wxpython applications. I am having difficulty debugging because the debugger does not line up with the code when I step through my application. I think it has to do with the end of a line character. maybe. Anyone have any ideas and might know how to fix this problem? Thanks, jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041201/6de8dac0/attachment.htm From jeffpeery at seametrics.com Wed Dec 1 20:10:45 2004 From: jeffpeery at seametrics.com (Jeff Peery) Date: Wed Dec 1 20:10:50 2004 Subject: [python-win32] timers? Message-ID: <000001c4d7d9$76b5fd90$7600000a@seametrics.local> Hello, I am using a timer for a windows application. I don't understand the functioning of the timer. For the button below when I press it I expect the first two messages to appear in the text field, then wait 3 seconds, then another message appears. However when I push the button there is the three second delay first, and then all three messages appear. Any ideas? Thanks Jeff def OnButton(self, event): self.go = TRUE #message 1 self.TextField.SetValue("Monitor Initiated\n%s" %self.TextField.GetValue()) #get the size of the file self.fileSize = int(stat(self.textCtrl1.GetValue())[6]) #while self.go: #message 2 self.TextField.SetValue("Monitor Sleeping\n%s" %self.TextField.GetValue()) #start the timer sleep(const_checkTime) #message 3 self.TextField.SetValue("Checking File Size\n%s" %self.TextField.GetValue()) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041201/24315241/attachment.htm From steve at holdenweb.com Wed Dec 1 21:32:37 2004 From: steve at holdenweb.com (Steve Holden) Date: Wed Dec 1 21:34:52 2004 Subject: [python-win32] timers? In-Reply-To: <000001c4d7d9$76b5fd90$7600000a@seametrics.local> References: <000001c4d7d9$76b5fd90$7600000a@seametrics.local> Message-ID: <41AE2A65.3070307@holdenweb.com> Jeff Peery wrote: > Hello, I am using a timer for a windows application. I don?t > understand the functioning of the timer. For the button below when I > press it I expect the first two messages to appear in the text field, > then wait 3 seconds, then another message appears. However when I push > the button there is the three second delay first, and then all three > messages appear. Any ideas? > > > > Thanks > > > > Jeff > > > > def OnButton(self, event): > > self.go = TRUE > > #message 1 > > self.TextField.SetValue("Monitor Initiated\n%s" > %self.TextField.GetValue()) > > #get the size of the file > > self.fileSize = int(stat(self.textCtrl1.GetValue())[6]) > > #while self.go: > > #message 2 > > self.TextField.SetValue("Monitor Sleeping\n%s" > %self.TextField.GetValue()) > > #start the timer > > sleep(const_checkTime) > > #message 3 > > self.TextField.SetValue("Checking File Size\n%s" > %self.TextField.GetValue()) > Yes. This is happening because you are sleeping inside the event handler, and so the window manager isn't getting control back to repaint the screen. I suspect, but cannot guarantee, that a PumpWaitingMessage() call before the sleep might bring your display up to date. regards Steve -- http://www.holdenweb.com http://pydish.holdenweb.com Holden Web LLC +1 800 494 3119 From jeffpeery at seametrics.com Wed Dec 1 22:12:21 2004 From: jeffpeery at seametrics.com (Jeff Peery) Date: Wed Dec 1 22:12:25 2004 Subject: [python-win32] timers? In-Reply-To: <41AE2A65.3070307@holdenweb.com> Message-ID: <000001c4d7ea$73b2e700$7600000a@seametrics.local> Thanks, Steve, although I did a quick google with not much luck, what is PumpWaitingMessage()... all I know is that it has something to do with Com... is this a python module? Thanks. -----Original Message----- From: Steve Holden [mailto:steve@holdenweb.com] Sent: Wednesday, December 01, 2004 12:33 PM To: Jeff Peery Cc: python-win32@python.org Subject: Re: [python-win32] timers? Jeff Peery wrote: > Hello, I am using a timer for a windows application. I don't > understand the functioning of the timer. For the button below when I > press it I expect the first two messages to appear in the text field, > then wait 3 seconds, then another message appears. However when I push > the button there is the three second delay first, and then all three > messages appear. Any ideas? > > > > Thanks > > > > Jeff > > > > def OnButton(self, event): > > self.go = TRUE > > #message 1 > > self.TextField.SetValue("Monitor Initiated\n%s" > %self.TextField.GetValue()) > > #get the size of the file > > self.fileSize = int(stat(self.textCtrl1.GetValue())[6]) > > #while self.go: > > #message 2 > > self.TextField.SetValue("Monitor Sleeping\n%s" > %self.TextField.GetValue()) > > #start the timer > > sleep(const_checkTime) > > #message 3 > > self.TextField.SetValue("Checking File Size\n%s" > %self.TextField.GetValue()) > Yes. This is happening because you are sleeping inside the event handler, and so the window manager isn't getting control back to repaint the screen. I suspect, but cannot guarantee, that a PumpWaitingMessage() call before the sleep might bring your display up to date. regards Steve -- http://www.holdenweb.com http://pydish.holdenweb.com Holden Web LLC +1 800 494 3119 From steve at holdenweb.com Wed Dec 1 22:31:08 2004 From: steve at holdenweb.com (Steve Holden) Date: Wed Dec 1 22:33:29 2004 Subject: [python-win32] timers? In-Reply-To: <000001c4d7ea$73b2e700$7600000a@seametrics.local> References: <000001c4d7ea$73b2e700$7600000a@seametrics.local> Message-ID: <41AE381C.8090606@holdenweb.com> Jeff Peery wrote: > Thanks, Steve, although I did a quick google with not much luck, what is > PumpWaitingMessage()... all I know is that it has something to do with > Com... is this a python module? > Erm, actually it was a typo foir PumpWaitingMessages(), but second thoughts are proverbially the best, and I now believe that what you actually want is a PumpMessages() call. This is a Windows API call. The documentation says "This allows an application which is performing a long operation to dispatch paint messages during the operation", which appears to cover your case pretty exactly. You can find it in the pythoncom module (so you should be able to say something like from pythoncom import PumpMessages to enable you to call it. Please remember, though, I'm kind of stabbing about here. Much of PythonWin assumes you know the API, and I don't :-) regards Steve -- http://www.holdenweb.com http://pydish.holdenweb.com Holden Web LLC +1 800 494 3119 From mhammond at skippinet.com.au Wed Dec 1 22:42:10 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed Dec 1 22:41:54 2004 Subject: [python-win32] servicemanager.pyd still in use after servicetermination In-Reply-To: Message-ID: <0a1601c4d7ee$9d670820$0300a8c0@enfoldsystems.local> > I noticed that every so often running the installer over an existing > installation would complain about servicemanager.pyd being > still in use. > This is despite the installer running 'net stop MyService' and > 'MyService.exe -remove' before copying files. Note that you will see this behaviour if the event-viewer application is open. This is because that application loads the DLLs to extract the messages. I've never seen this happen in any situation other than this. Mark -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 1780 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20041202/4c6fd703/winmail.bin From jeffpeery at seametrics.com Wed Dec 1 23:02:32 2004 From: jeffpeery at seametrics.com (Jeff Peery) Date: Wed Dec 1 23:02:37 2004 Subject: [python-win32] timers? In-Reply-To: <41AE381C.8090606@holdenweb.com> Message-ID: <000001c4d7f1$76485ac0$7600000a@seametrics.local> Thanks for the help Steve, the thing what works the best is win32gui.PumpWaitingMessages() I used the module win32gui because I saw that someone else used it with Pumpwaitingmessages(). It doesn't seem to work with pythoncom. So I instead imported the win32gui module. I have no idea what I am doing but based on trial and error it seems to be working ok. Pumpmessages didn't seem to work either. Thanks again for your help, please offer any thoughts. Jeff -----Original Message----- From: Steve Holden [mailto:steve@holdenweb.com] Sent: Wednesday, December 01, 2004 1:31 PM To: Jeff Peery Cc: python-win32@python.org Subject: Re: [python-win32] timers? Jeff Peery wrote: > Thanks, Steve, although I did a quick google with not much luck, what is > PumpWaitingMessage()... all I know is that it has something to do with > Com... is this a python module? > Erm, actually it was a typo foir PumpWaitingMessages(), but second thoughts are proverbially the best, and I now believe that what you actually want is a PumpMessages() call. This is a Windows API call. The documentation says "This allows an application which is performing a long operation to dispatch paint messages during the operation", which appears to cover your case pretty exactly. You can find it in the pythoncom module (so you should be able to say something like from pythoncom import PumpMessages to enable you to call it. Please remember, though, I'm kind of stabbing about here. Much of PythonWin assumes you know the API, and I don't :-) regards Steve -- http://www.holdenweb.com http://pydish.holdenweb.com Holden Web LLC +1 800 494 3119 From Richard at artsalliancemedia.com Thu Dec 2 10:53:05 2004 From: Richard at artsalliancemedia.com (Richard Cooper) Date: Thu Dec 2 10:52:54 2004 Subject: [python-win32] servicemanager.pyd still in use after servicetermination Message-ID: > > I noticed that every so often running the installer over an > existing > > installation would complain about servicemanager.pyd being still in > > use. > > This is despite the installer running 'net stop MyService' and > > 'MyService.exe -remove' before copying files. > > Note that you will see this behaviour if the event-viewer > application is open. This is because that application loads > the DLLs to extract the messages. I've never seen this > happen in any situation other than this. Yes, I've noticed this too. In this situation servicemanager.pyd is held by mmc.exe. However, I can reproduce the behaviour I described even after a reboot and without launching the event viewer. If my service raises an exception in SvcDoRun then servicemanager.pyd ends up being held by a process called Wmiprvse.exe If no one else is seeing this behaviour then I guess I will have to try to distil a minimal test case out of my code. BTW in case it matters I'm using python 2.3.4, pywin32 build 203 and py2exe 0.5.4. From mhammond at skippinet.com.au Thu Dec 2 13:43:28 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Dec 2 13:43:06 2004 Subject: [python-win32] servicemanager.pyd still in use afterservicetermination In-Reply-To: Message-ID: <02a001c4d86c$86a822d0$0300a8c0@enfoldsystems.local> > Yes, I've noticed this too. In this situation > servicemanager.pyd is held > by mmc.exe. However, I can reproduce the behaviour I described even > after a reboot and without launching the event viewer. If my service > raises an exception in SvcDoRun then servicemanager.pyd ends up being > held by a process called Wmiprvse.exe My guess us that this process has the DLL open for the exact same reason - ie, any process using the eventlog APIs could well cause this, and WMI certainly has that capability. I suspect that any DLLs referenced by the event-log will also be in use, so the problem may not be Python specific at all. The question you may need to answer is simply why this process has the event-log open on your box. Mark -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 1980 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20041202/acba9a37/winmail.bin From jeffpeery at seametrics.com Thu Dec 2 21:11:34 2004 From: jeffpeery at seametrics.com (Jeff Peery) Date: Thu Dec 2 21:11:40 2004 Subject: [python-win32] thread? Message-ID: <000001c4d8ab$1fe82010$7600000a@seametrics.local> Hello, I am trying to get a thread and timer to work, this is my first venture with these things. I attached my code below. Basically my problem is with the line: Timer(2, wxPostEvent(window, ResultEvent("Sleep"))).start() I want the timer to send the event result "sleep" after two seconds. Although I get an error message that this is the argument is a "none type". I tried pulling ResultEvent("Sleep") from the Timer function and placing it in its own function and then calling that function but I get into trouble with "window." I looked up definitions for wxPostEvent because I am not sure what the arguments are exactly. Any ideas, I'm a bit lost. Thanks. Jeff # Thread class that executes processing class WorkerThread(Thread): def __init__(self, notify_window): Thread.__init__(self) self._notify_window = notify_window self._want_abort = 0 # This starts the thread running on creation, but you could # also make the GUI thread responsible for calling this self.start() def run(self): # This is the code executing in the new thread. Simulation of # a long process (well, 10s here) as a simple loop - you will # need to structure your processing so that you periodically # peek at the abort variable if self._want_abort != 1: #indicate monitor is not sleeping wxPostEvent(self._notify_window,ResultEvent("NoSleep")) #define and start a timer object Timer(2, wxPostEvent(window, ResultEvent("Sleep"))).start() else: # Use a result of None to acknowledge the abort wxPostEvent(self._notify_window,ResultEvent(None)) return def abort(self): # Method for use by main thread to signal an abort self._want_abort = 1 self.worker = None -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041202/75b9bf28/attachment.html From yh.rhiu at gmail.com Mon Dec 6 13:52:45 2004 From: yh.rhiu at gmail.com (Young-Hoon Rhiu) Date: Mon Dec 6 13:52:48 2004 Subject: [python-win32] WMI scripting makepy error with ActivePython 2.4.0 Message-ID: <5090ca12041206045278f77e39@mail.gmail.com> When I do makepy 'Microsoft WMI Scripting V1.1 Library" on ActivePython 2.4.0, my PythonWin exits abnormally. But makepy testing on ActivePython 2.4 was O.K. Any ideas? __ Y.H. Rhiu From yh.rhiu at gmail.com Mon Dec 6 14:54:12 2004 From: yh.rhiu at gmail.com (Young-Hoon Rhiu) Date: Mon Dec 6 14:54:15 2004 Subject: [python-win32] WMI scripting makepy error with ActivePython 2.4.0 (re-post) Message-ID: <5090ca12041206055470c1f97@mail.gmail.com> Sorry, I repost my aticle because of erratum. ---------------------------------------------------------------------------------------- When I do makepy "Microsoft WMI Scripting V1.1 Library" on ActivePython 2.4.0, my PythonWin is terminated abnormally. But makepy test on ActivePython 2.3.4 was O.K. (I tested it on Win2000 and WinXP.) Any ideas? __ Y.H. Rhiu From mhammond at skippinet.com.au Mon Dec 6 23:02:06 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon Dec 6 23:01:20 2004 Subject: [python-win32] WMI scripting makepy error with ActivePython 2.4.0 In-Reply-To: <5090ca12041206045278f77e39@mail.gmail.com> Message-ID: <11ef01c4dbdf$3a45cf20$0300a8c0@enfoldsystems.local> Python 2.4 seems to have bloated the bytecode, and some typelibs are causing Python to generate too many byte-codes and crash. Excel has the same problem. The solution seems to be to use "for demand" makepy - ie, run "makepy -d ...". This will create a directory with a file per interface, rather than lumping them into one large .py file. The gencache functions have a bForDemand param which does the same thing. I think I will need to flick the switch and make it the default for Python 2.4 Mark. > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of Young-Hoon Rhiu > Sent: Monday, 6 December 2004 11:53 PM > To: python-win32@python.org > Subject: [python-win32] WMI scripting makepy error with ActivePython > 2.4.0 > > > When I do makepy 'Microsoft WMI Scripting V1.1 Library" on > ActivePython 2.4.0, my PythonWin exits abnormally. > > But makepy testing on ActivePython 2.4 was O.K. > > Any ideas? > > __ > Y.H. Rhiu > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From djones at innovativerobotics.com Mon Dec 6 23:20:18 2004 From: djones at innovativerobotics.com (Dave Jones) Date: Mon Dec 6 23:15:36 2004 Subject: [python-win32] Pythonwin is broke Message-ID: <3X3JGVQEC95A5JIB87WUP3VECVUX.41b4db22@bobo> Please help. This is driving me batty. I think someone who is familiar with the Pythonwin source code can probably figure this out. Pythonwin has quit working properly on my office computer, and I am at a loss as to how to fix it. I am using Python23 on MS Windows 2000 Pro. Prior to re-installing Pythonwin, I have uninstalled Pythonwin and Python, removed everything left over in the registry, and removed the Python23 dircectory. I even re-ran MS service pack 4. Pythonwin became broke at about the same time that I installed and then uninstalled Python 2.4. That could be a coincidence, or it could be significant; I don't know. Here are the symptoms: I open Pythonwin either through the menu shortcut or by clicking on the .exe directly. I have tried starting it in every conceivable directory. In any case, if I immediately use the X box to close Pythonwin, it closes properly. All the menus items on the main frame appear to be functional. But if I first open a .py file using the menu File/Open... then everything is frozen that's associated with the main window frame or the new file window's frame. I cannot close the new window or the main frame using an X box. Neither can I minimize either window, nor use any of the menu items on the main frame. I cannot re-size either window. Operations on the file itself, like right-click/ select-all seem to work okay. I can minimize or close Pythonwin from the MS Windows task bar. The interactive window seems to bahave properly in every respect. Please help. I really would like to be able to use Pythonwin again. Thanks, Dave From simon.brunning at gmail.com Tue Dec 7 16:33:24 2004 From: simon.brunning at gmail.com (Simon Brunning) Date: Tue Dec 7 16:33:59 2004 Subject: [python-win32] Application Error driving iTunes with COM Message-ID: <8c7f10c604120707331134824f@mail.gmail.com> I'm getting an odd error while playing with iTunes. Here's a simplified version of the code: -- import win32com.client def main(): for track_index, track in tracks(): print track_index, repr(track.Artist), repr(track.Album), repr(track.Name), track.PlayedCount, print track.PlayedDate def tracks(playlist=None): iTunes = win32com.client.gencache.EnsureDispatch("iTunes.Application") if playlist: library = iTunes.LibrarySource.Playlists.ItemByName(playlist) else: library = iTunes.LibraryPlaylist track_collection = library.Tracks track_count = track_collection.Count for track_index in range(1, track_count+1): yield track_index, track_collection.Item(track_index) if __name__ == '__main__': main() -- This fails when printing the 'PlayedDate' of a track that has never been played. Which is fair enough. up to a point, but I don't get an exception as I'd expect. (Well, *half* expect - a None would ne nice!) Instead, it just falls over with the following dialog: --------------------------- python.exe - Application Error --------------------------- The instruction at "0x1e606cf2" referenced memory at "0x00000000". The memory could not be "read". Click on OK to terminate the program Click on CANCEL to debug the program --------------------------- OK Cancel --------------------------- Debugging tells me: --------------------------- Microsoft Visual C++ --------------------------- Unhandled exception in python.exe (PYWINTYPES23.DLL): 0xC0000005: Access Violation. --------------------------- OK --------------------------- Any ideas? -- Cheers, Simon B, simon@brunningonline.net, http://www.brunningonline.net/simon/blog/ From simon.brunning at gmail.com Tue Dec 7 16:33:24 2004 From: simon.brunning at gmail.com (Simon Brunning) Date: Tue Dec 7 16:34:05 2004 Subject: [python-win32] Application Error driving iTunes with COM Message-ID: <8c7f10c604120707331134824f@mail.gmail.com> I'm getting an odd error while playing with iTunes. Here's a simplified version of the code: -- import win32com.client def main(): for track_index, track in tracks(): print track_index, repr(track.Artist), repr(track.Album), repr(track.Name), track.PlayedCount, print track.PlayedDate def tracks(playlist=None): iTunes = win32com.client.gencache.EnsureDispatch("iTunes.Application") if playlist: library = iTunes.LibrarySource.Playlists.ItemByName(playlist) else: library = iTunes.LibraryPlaylist track_collection = library.Tracks track_count = track_collection.Count for track_index in range(1, track_count+1): yield track_index, track_collection.Item(track_index) if __name__ == '__main__': main() -- This fails when printing the 'PlayedDate' of a track that has never been played. Which is fair enough. up to a point, but I don't get an exception as I'd expect. (Well, *half* expect - a None would ne nice!) Instead, it just falls over with the following dialog: --------------------------- python.exe - Application Error --------------------------- The instruction at "0x1e606cf2" referenced memory at "0x00000000". The memory could not be "read". Click on OK to terminate the program Click on CANCEL to debug the program --------------------------- OK Cancel --------------------------- Debugging tells me: --------------------------- Microsoft Visual C++ --------------------------- Unhandled exception in python.exe (PYWINTYPES23.DLL): 0xC0000005: Access Violation. --------------------------- OK --------------------------- Any ideas? -- Cheers, Simon B, simon@brunningonline.net, http://www.brunningonline.net/simon/blog/ From simon.brunning at gmail.com Tue Dec 7 16:44:12 2004 From: simon.brunning at gmail.com (Simon Brunning) Date: Tue Dec 7 16:44:16 2004 Subject: [python-win32] Re: Application Error driving iTunes with COM In-Reply-To: <8c7f10c604120707331134824f@mail.gmail.com> References: <8c7f10c604120707331134824f@mail.gmail.com> Message-ID: <8c7f10c604120707443b3371c@mail.gmail.com> On Tue, 7 Dec 2004 15:33:24 +0000, Simon Brunning wrote: > I'm getting an odd error while playing with iTunes. Here's a > simplified version of the code: Oops, I forgot. I'm using Python 2.3.4 and buil 163 of win32all. I'm driving iTunes version 4.7 on Windows 2000 workstation. -- Cheers, Simon B, simon@brunningonline.net, http://www.brunningonline.net/simon/blog/ From steve.mcdonald at ninaza.com Tue Dec 7 23:12:26 2004 From: steve.mcdonald at ninaza.com (Steve Mcdonald) Date: Tue Dec 7 23:14:55 2004 Subject: [python-win32] Internet Explorer COM issues with XP SP2? Message-ID: 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 From niki at vintech.bg Wed Dec 8 10:30:37 2004 From: niki at vintech.bg (Niki Spahiev) Date: Wed Dec 8 10:30:52 2004 Subject: [python-win32] Re: Application Error driving iTunes with COM In-Reply-To: <8c7f10c604120707443b3371c@mail.gmail.com> References: <8c7f10c604120707331134824f@mail.gmail.com> <8c7f10c604120707443b3371c@mail.gmail.com> Message-ID: <41B6C9BD.7020705@vintech.bg> Simon Brunning wrote: > Oops, I forgot. I'm using Python 2.3.4 and buil 163 of win32all. I'm > driving iTunes version 4.7 on Windows 2000 workstation. And tying build 202 gives? Niki Spahiev From simon.brunning at gmail.com Wed Dec 8 12:35:05 2004 From: simon.brunning at gmail.com (Simon Brunning) Date: Wed Dec 8 12:35:07 2004 Subject: [python-win32] Re: Application Error driving iTunes with COM In-Reply-To: <41B6C9BD.7020705@vintech.bg> References: <8c7f10c604120707331134824f@mail.gmail.com> <8c7f10c604120707443b3371c@mail.gmail.com> <41B6C9BD.7020705@vintech.bg> Message-ID: <8c7f10c604120803353d7b3e24@mail.gmail.com> On Wed, 08 Dec 2004 11:30:37 +0200, Niki Spahiev wrote: > And tying build 202 gives? > > Niki Spahiev Mark's been borrowing Guido's time machine again - whatever it was that wasn't working before does work in 203. -- Cheers, Simon B, simon@brunningonline.net, http://www.brunningonline.net/simon/blog/ From hongqn at gmail.com Wed Dec 8 15:56:43 2004 From: hongqn at gmail.com (Qiangning Hong) Date: Wed Dec 8 16:11:37 2004 Subject: [python-win32] How to determine CD-ROM or CD-R? Message-ID: How can my program find out the type of disc in my CD-RW drive? I want my program behaves differently depend on the type: if it is a normal CD-ROM, read data from it; if a recordable CD, burn data onto it. From tim.golden at viacom-outdoor.co.uk Wed Dec 8 16:27:08 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed Dec 8 16:26:53 2004 Subject: [python-win32] How to determine CD-ROM or CD-R? Message-ID: <9A28C052FF32734DACB0A288A353399103591D@vogbs009.gb.vo.local> [Qiangning Hong] | How can my program find out the type of disc in my CD-RW | drive? I want | my program behaves differently depend on the type: if it is a normal | CD-ROM, read data from it; if a recordable CD, burn data onto it. If you're on Windows, I think WMI can do it. Check out the Win32_CDROMDrive class and its Capabilities attribute. 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 charlie at ezweave.com Wed Dec 8 00:33:34 2004 From: charlie at ezweave.com (Charlie Taylor) Date: Wed Dec 8 17:12:01 2004 Subject: [python-win32] upgrading to python 2.4 Message-ID: <20041207233143.3538A1E4008@bag.python.org> Is there a good reference to the steps that should be taken to upgrade a Windows machine to the next version of python? My journey from 2.2 to 2.3 was very knicker-twisting. I'm hoping for more of a controlled landing on 2.4. From rogelio.flores at gmail.com Wed Dec 8 17:46:52 2004 From: rogelio.flores at gmail.com (Rogelio Flores) Date: Wed Dec 8 17:46:54 2004 Subject: [python-win32] Allowing service to interact with desktop Message-ID: Is there a way to set my python windows service to run witht the option "Allowing service to interact with desktop" turned on at installation time? I know how to enable it from the windows Services UI, but I'm hoping there is an option similar to "--startup auto" (to set the service to start automatically when the machine starts) so that I can do it from the command-line. Thanks, -- RF From jlowery at m2is.com Wed Dec 8 20:00:09 2004 From: jlowery at m2is.com (Jeff Lowery) Date: Wed Dec 8 20:11:52 2004 Subject: [python-win32] Problem running python cgi script Message-ID: <001a01c4dd58$286ba3e0$2600a8c0@Folderal> I'm trying to get MoinMoin Wiki server installed on IIS 6.0, but am hung up on getting the moin.cgi script to execute. Yes, I have read and followed the directions in the INSTALL.html document, including: 1) appended the site-packages directory to sys.path 2) added virtual directory 'wiki', pointing to htdocs directory 3) added virtual directory 'mywiki', pointing to wiki instance directory 4) configured the virtual directory in IIS above to run "c:\python23\python.exe" -u %s %s on .cgi extensions 5) set Web Service Extensions to allow unknown cgi extensions Added some logging statements to a log file at the top of moin.cgi, just to see if it was executing at all (runs fine from the command line, btw). Apparently not: getting a "CGI Error: The specified CGI application misbehaved by not returning a complete set of HTTP headers", and no log is generated. Funny thing is that if I remove the "-u %s %s" from the cgi extension setup (4), I get a timeout error instead. Looks like IIS knows about the CGI mapping, but is not running the python interpreter. Any ideas? From mhammond at skippinet.com.au Thu Dec 9 01:45:54 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Dec 9 01:46:04 2004 Subject: [python-win32] Problem running python cgi script In-Reply-To: <001a01c4dd58$286ba3e0$2600a8c0@Folderal> Message-ID: <012301c4dd88$71244670$0f0a0a0a@enfoldsystems.local> > 4) configured the virtual directory in IIS above to run > "c:\python23\python.exe" -u %s %s on .cgi extensions If the path has a space in it, try adding quotes around the "%s". If the virtual directory is on a network share, move it to a local dir. > Added some logging statements to a log file at the top of > moin.cgi, just to > see if it was executing at all (runs fine from the command > line, btw). > Apparently not: getting a "CGI Error: The specified CGI application > misbehaved by not returning a complete set of HTTP headers", That sounds to me like Python is being executed, but throwing some kind of exception. It may be a very early error, such as the named script file not being found (hence my suggestions above), or it could be a very early exception in the script. > and no log is > generated. Funny thing is that if I remove the "-u %s %s" > from the cgi > extension setup (4), I get a timeout error instead. That sounds like Python is correctly being executed and sitting at an interactive prompt. It never terminates, so IIS times it out. > Looks > like IIS knows > about the CGI mapping, but is not running the python interpreter. Sounds to me more like Python *is* being executed, but failing. Mark From mhammond at skippinet.com.au Thu Dec 9 01:49:05 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Dec 9 01:49:16 2004 Subject: [python-win32] Allowing service to interact with desktop In-Reply-To: Message-ID: <012401c4dd88$e2ff00f0$0f0a0a0a@enfoldsystems.local> > Is there a way to set my python windows service to run witht the > option "Allowing service to interact with desktop" turned on at > installation time? I know how to enable it from the windows Services > UI, but I'm hoping there is an option similar to "--startup auto" (to > set the service to start automatically when the machine starts) so > that I can do it from the command-line. How did you find out about "--startup"? Running "your_service.py" with no args prints: Options for 'install' and 'update' commands only: --username domain\username : The Username the service is to run under --password password : The password for the username --startup [manual|auto|disabled] : How the service starts, default = manual --interactive : Allow the service to interact with the desktop. ... I think the last one shown is what you are after. Be sure to look for the MSDN documentation on this flag - it may not do exactly what you want ("interact with the desktop" is slightly misleading...) Mark. From bluedust at swbell.net Thu Dec 9 01:55:56 2004 From: bluedust at swbell.net (Chris R. Martin) Date: Thu Dec 9 01:54:49 2004 Subject: [python-win32] "native" password dialog? Message-ID: <41B7A29C.4040305@swbell.net> I use a program called OmniPass, which is a password "vault" program that works in conjunction with a USB fingerprint device. The software works by "remembering" passwords typed into dialog boxes. When presented with the dialog box on subsequent occasions, it intercepts the dialog and displays its own "fingerprint enabled" dialog box. However, I've been unable to get the program to work with Python/Tk. It just doesn't "recognize" any of my dialog boxes as password dialogs. So, I guess my question has two parts: 1) Does win32 have a "native" type of password dialog? Any guesses on how OmniPass recognizes a dialog as a "password dialog"? 2) What is the best way to generate native dialogs with Python? Will they work in conjunction with Tk? Thanks for any information you can provide! -- 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 Thu Dec 9 02:22:33 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Dec 9 02:22:38 2004 Subject: [python-win32] "native" password dialog? In-Reply-To: <41B7A29C.4040305@swbell.net> Message-ID: <013701c4dd8d$8ffdd200$0f0a0a0a@enfoldsystems.local> > 1) Does win32 have a "native" type of password dialog? Any guesses on > how OmniPass recognizes a dialog as a "password dialog"? As far as I am aware, there is no standard "password" dialog - however, windows edit controls can have the ES_PASSWORD style. My guess is that Tk implements its own password control, but OmniPass is looking for this style on a control in the dialog to recognize the dialog as a "password dialog" Mark From bluedust at swbell.net Thu Dec 9 03:01:13 2004 From: bluedust at swbell.net (Chris R. Martin) Date: Thu Dec 9 03:00:12 2004 Subject: [python-win32] "native" password dialog? In-Reply-To: <013701c4dd8d$8ffdd200$0f0a0a0a@enfoldsystems.local> References: <013701c4dd8d$8ffdd200$0f0a0a0a@enfoldsystems.local> Message-ID: <41B7B1E9.4000507@swbell.net> How can I implement this Python, and will it work within a Tkinter app? Thanks, Chris Mark Hammond wrote: >>1) Does win32 have a "native" type of password dialog? Any guesses on >>how OmniPass recognizes a dialog as a "password dialog"? >> >> > >As far as I am aware, there is no standard "password" dialog - however, >windows edit controls can have the ES_PASSWORD style. > >My guess is that Tk implements its own password control, but OmniPass is >looking for this style on a control in the dialog to recognize the dialog as >a "password dialog" > >Mark > > > > -- Guybrush: How can you see without eyeballs? Murray: How can you walk around without a brain? Some things no one can answer. From hongqn at gmail.com Thu Dec 9 08:40:30 2004 From: hongqn at gmail.com (Qiangning Hong) Date: Thu Dec 9 08:44:06 2004 Subject: [python-win32] Re: How to determine CD-ROM or CD-R? In-Reply-To: <9A28C052FF32734DACB0A288A353399103591D@vogbs009.gb.vo.local> References: <9A28C052FF32734DACB0A288A353399103591D@vogbs009.gb.vo.local> Message-ID: Tim Golden wrote: > [Qiangning Hong] > | How can my program find out the type of disc in my CD-RW > | drive? I want > | my program behaves differently depend on the type: if it is a normal > | CD-ROM, read data from it; if a recordable CD, burn data onto it. > > If you're on Windows, I think WMI can do it. Check out the > Win32_CDROMDrive class and its Capabilities attribute. > Thanks for your answer. I installed the wmi module and use the following code to generate Win32_CDROMDrive's Capabilities: >>> import wmi >>> c = wmi.WMI() >>> cds = c.CDROMDrive() >>> cds [] >>> cds[0].Capabilities (3, 7) I have only one CD-RW drive with an empty CD-R disc inserted. It is expected that the capability "4" (write access) should be in cds[0].Capabilities. However it isn't there. From tim.golden at viacom-outdoor.co.uk Thu Dec 9 09:39:00 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu Dec 9 09:38:46 2004 Subject: [python-win32] Re: How to determine CD-ROM or CD-R? Message-ID: <9A28C052FF32734DACB0A288A3533991035922@vogbs009.gb.vo.local> | Tim Golden wrote: | > [Qiangning Hong] | > | How can my program find out the type of disc in my CD-RW | > | drive? I want | > | my program behaves differently depend on the type: if it | is a normal | > | CD-ROM, read data from it; if a recordable CD, burn data onto it. | > | > If you're on Windows, I think WMI can do it. Check out the | > Win32_CDROMDrive class and its Capabilities attribute. | > | | Thanks for your answer. | | I installed the wmi module and use the following code to generate | Win32_CDROMDrive's Capabilities: | | >>> import wmi | >>> c = wmi.WMI() | >>> cds = c.CDROMDrive() | >>> cds | [] | >>> cds[0].Capabilities | (3, 7) | | I have only one CD-RW drive with an empty CD-R disc inserted. It is | expected that the capability "4" (write access) should be in | cds[0].Capabilities. However it isn't there. Looks like I'm wrong then. I only have a CDROM (ie read, not write) and I also saw (3, 7). When I checked the docs I assumed that a CDRW would give you the 4. Might still be worth Googling a bit for WMI CDRW or something to see if there is some other solution within WMI. Maybe the more general purpose Win32_LogicalDisk or some other class will have the information. I don't know for sure, but I'd be surprised if it wasn't somewhere in WMI. 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 Dec 9 11:53:42 2004 From: p.f.moore at gmail.com (Paul Moore) Date: Thu Dec 9 11:54:07 2004 Subject: [python-win32] upgrading to python 2.4 In-Reply-To: <20041207233143.3538A1E4008@bag.python.org> References: <20041207233143.3538A1E4008@bag.python.org> Message-ID: <79990c6b041209025317a1111d@mail.gmail.com> On Tue, 7 Dec 2004 15:33:34 -0800, Charlie Taylor wrote: > Is there a good reference to the steps that should be taken to upgrade a > Windows machine to the next version of python? > > My journey from 2.2 to 2.3 was very knicker-twisting. I'm hoping for more > of a controlled landing on 2.4. I just did this, and my approach was: 1. Go into Add/Remove Programs, and list all the Python extensions I have installed. 2. Get 2.4 binaries for any that use C extensions 3. Remove all of the 2.3 stuff, and Python 2.3 itself. 4. Install 2.4, and the extensions I use. That's it. Worked OK for me. Some points, though: 1. I install *everything* via bdist_wininst installers. If one isn't provided, I build one myself. 2. If I have services using Python, I have to be a bit more careful. Uninstall the service before removing 2.3, then reinstall after. 3. I'm assuming that all of the scripts and applications I have will work. Testing thye upgrade is a separate issue. You can install 2.3 and 2.4 side by side if this helps with your testing... Also, I have a fairly high tolerance for breakage, or issues. Most of what I use Python for is timesaving utilities, added-value applications, and other nce-to-have stuff. If your business will fail should a Python application stop working, take a bit more care than I do!! But overall, the transition hasn't been too painful. Paul. From jlowery at m2is.com Thu Dec 9 02:27:47 2004 From: jlowery at m2is.com (Jeff Lowery) Date: Thu Dec 9 17:28:31 2004 Subject: [python-win32] Problem running python cgi script References: <012301c4dd88$71244670$0f0a0a0a@enfoldsystems.local> Message-ID: <002901c4dd8e$4aa09930$2600a8c0@Folderal> Turned out to the file system's "Sharing and Security" settings. Bumped up permissions a couple of notches on the wiki directory and it worked. I'll have to experiment with knocking them back down a bit for better security. The MoinMoin install instructions need some tweaking, perhaps. ----- Original Message ----- From: "Mark Hammond" To: "'Jeff Lowery'" ; Sent: Wednesday, December 08, 2004 4:45 PM Subject: RE: [python-win32] Problem running python cgi script >> 4) configured the virtual directory in IIS above to run >> "c:\python23\python.exe" -u %s %s on .cgi extensions > > If the path has a space in it, try adding quotes around the "%s". If the > virtual directory is on a network share, move it to a local dir. > >> Added some logging statements to a log file at the top of >> moin.cgi, just to >> see if it was executing at all (runs fine from the command >> line, btw). >> Apparently not: getting a "CGI Error: The specified CGI application >> misbehaved by not returning a complete set of HTTP headers", > > That sounds to me like Python is being executed, but throwing some kind of > exception. It may be a very early error, such as the named script file > not > being found (hence my suggestions above), or it could be a very early > exception in the script. > >> and no log is >> generated. Funny thing is that if I remove the "-u %s %s" >> from the cgi >> extension setup (4), I get a timeout error instead. > > That sounds like Python is correctly being executed and sitting at an > interactive prompt. It never terminates, so IIS times it out. > >> Looks >> like IIS knows >> about the CGI mapping, but is not running the python interpreter. > > Sounds to me more like Python *is* being executed, but failing. > > Mark > > From tim.leeuwvander at nl.unisys.com Thu Dec 9 11:39:01 2004 From: tim.leeuwvander at nl.unisys.com (Leeuw van der, Tim) Date: Thu Dec 9 17:28:32 2004 Subject: [python-win32] mfc71.dll missing and not found on website? Message-ID: Hi, I installed build 203 of the win32 extensions for Python (python 2.4) and the installer complains about missing mfc71.dll (don't remember the exact filename). The installer refers to the website, saying it can be downloaded from there, however I don't find it and I don't find it on the SF.net download pages either! I've looked into the FAQ and Installation Problems Guide, but didn't find references to this DLL there. I tried searching the python-win32 mailing list archives, but didn't see references there either that could help me. Can anyone perhaps help me to find that DLL? thanks in advance, --Tim van der Leeuw (PS: I'm not subscribed to the list, so please include me in replies!) From darkwing at proaxis.com Thu Dec 9 16:02:45 2004 From: darkwing at proaxis.com (Chad and Anita Stryker) Date: Thu Dec 9 17:28:32 2004 Subject: [python-win32] How to send mail via Extended MAPI Message-ID: <20041209150245.6492881EE0@smtp2.pacifier.net> David, Thank you for figuring this extended MAPI interface all out. I discovered a couple of problems with the code (on my system at least). First, the message in my outbox was marked as read. Second, the message would remain in the outbox after it was sent. After several hours of work, I added three lines to the function that mark the message as unread and cause the message to be deleted from the outbox after it is sent. First, I added a constant that I found in the MAPI header file MAPIDefS.h. CLEAR_READ_FLAG = 4 Next I added two lines just before "outboxfolder.SaveChanges(0)". message.SetReadFlag(CLEAR_READ_FLAG) message.SetProps([(mapitags.PR_DELETE_AFTER_SUBMIT,1)]) With these changes, the behavior in the outbox is consistent with sending messages directly from Outlook. Chad -------------- next part -------------- #!/usr/bin/env python """module to send mail with Extended MAPI using the pywin32 mapi wrappers...""" # this was based on Jason Hattingh's C++ code at http://www.codeproject.com/internet/mapadmin.asp # written by David Fraser > and Stephen Emslie > # you can test this by changing the variables at the bottom and running from the command line from win32com.mapi import mapi from win32com.mapi import mapitags # constant from MAPIDefS.h, added by Chad Stryker CLEAR_READ_FLAG = 4 # Pre 2.2.1 compat. try: True, False except NameError: True = 1==1; False = 1==0 def SendEMAPIMail(Subject="", Message="", SendTo=None, SendCC=None, SendBCC=None, MAPIProfile=None): """Sends an email to the recipient using the extended MAPI interface Subject and Message are strings Send{To,CC,BCC} are comma-separated address lists MAPIProfile is the name of the MAPI profile""" # initialize and log on mapi.MAPIInitialize(None) session = mapi.MAPILogonEx(0, MAPIProfile, None, mapi.MAPI_EXTENDED | mapi.MAPI_USE_DEFAULT) messagestorestable = session.GetMsgStoresTable(0) messagestorestable.SetColumns((mapitags.PR_ENTRYID, mapitags.PR_DISPLAY_NAME_A, mapitags.PR_DEFAULT_STORE),0) while (True): rows = messagestorestable.QueryRows(1, 0) if len(rows) != 1: break row = rows[0] propertyid, propertyvalue = row[0] if (propertyid == mapitags.PR_DEFAULT_STORE and propertyvalue == True): break # unpack the row and open the message store (eid_tag, eid), (name_tag, name), (def_store_tag, def_store) = row msgstore = session.OpenMsgStore(0,eid,None,mapi.MDB_NO_DIALOG | mapi.MAPI_BEST_ACCESS) # get the outbox hr, props = msgstore.GetProps((mapitags.PR_IPM_OUTBOX_ENTRYID), 0) (tag, eid) = props[0] outboxfolder = msgstore.OpenEntry(eid,None,mapi.MAPI_BEST_ACCESS) # create the message and the addrlist message = outboxfolder.CreateMessage(None,0) # note: you can use the resolveaddress functions for this. but you may get headaches pal = [] def makeentry(recipient, recipienttype): return ((mapitags.PR_RECIPIENT_TYPE, recipienttype), (mapitags.PR_SEND_RICH_INFO, False), (mapitags.PR_DISPLAY_TYPE, 0), (mapitags.PR_OBJECT_TYPE, 6), (mapitags.PR_EMAIL_ADDRESS_A, recipient), (mapitags.PR_ADDRTYPE_A, 'SMTP'), (mapitags.PR_DISPLAY_NAME_A, recipient)) if SendTo: pal.extend([makeentry(recipient, mapi.MAPI_TO) for recipient in SendTo.split(",")]) if SendCC: pal.extend([makeentry(recipient, mapi.MAPI_CC) for recipient in SendCC.split(",")]) if SendBCC: pal.extend([makeentry(recipient, mapi.MAPI_BCC) for recipient in SendBCC.split(",")]) # add the resolved recipients to the message message.ModifyRecipients(mapi.MODRECIP_ADD,pal) message.SetProps([(mapitags.PR_BODY_A,Message), (mapitags.PR_SUBJECT_A,Subject)]) # Chad Stryker's modifications... message.SetReadFlag(CLEAR_READ_FLAG) message.SetProps([(mapitags.PR_DELETE_AFTER_SUBMIT,1)]) # save changes and submit outboxfolder.SaveChanges(0) message.SubmitMessage(0) if __name__ == '__main__': MAPIProfile = "" # Change this to a valid email address to test SendTo = "an.invalid at address " SendMessage = "testing one two three" SendSubject = "Testing Extended MAPI!!" SendEMAPIMail(SendSubject, SendMessage, SendTo, MAPIProfile=MAPIProfile) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041209/36fa15e6/attachment.html From timr at probo.com Thu Dec 9 18:05:45 2004 From: timr at probo.com (Tim Roberts) Date: Thu Dec 9 18:05:52 2004 Subject: [python-win32] upgrading to python 2.4 In-Reply-To: <20041209020104.B23141E4017@bag.python.org> References: <20041209020104.B23141E4017@bag.python.org> Message-ID: <41B885E9.5000905@probo.com> On Tue, 7 Dec 2004 15:33:34 -0800, "Charlie Taylor" wrote: >Is there a good reference to the steps that should be taken to upgrade a >Windows machine to the next version of python? > >My journey from 2.2 to 2.3 was very knicker-twisting. I'm hoping for more >of a controlled landing on 2.4. > You can't upgrade. You have to throw out the old and start over. That's true any time the second digit changes. I got tired of this problem, so I have started keeping a batch file that tells me exactly what has to be done. I keep all of the additional packages in the same directory as the batch file. Any time I want to, I can delete the whole Python directory and run this script to start over. It made the 2.2-to-2.3 transition much easier. Plus, if I need to set up a new machine, I can copy that one directory over, and have my whole Python environment alive and well. For some packages, this just means running a .exe or a .msi. For some packages, it means unzipping and running "python setup.py install". For some packages, it means doing an nmake. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From simon.brunning at gmail.com Thu Dec 9 18:31:12 2004 From: simon.brunning at gmail.com (Simon Brunning) Date: Thu Dec 9 18:31:16 2004 Subject: [python-win32] mfc71.dll missing and not found on website? In-Reply-To: References: Message-ID: <8c7f10c60412090931107f9bda@mail.gmail.com> On Thu, 9 Dec 2004 11:39:01 +0100, Leeuw van der, Tim > Can anyone perhaps help me to find that DLL? First hit worked for me... -- Cheers, Simon B, simon@brunningonline.net, http://www.brunningonline.net/simon/blog/ From theller at python.net Thu Dec 9 19:00:59 2004 From: theller at python.net (Thomas Heller) Date: Thu Dec 9 19:00:15 2004 Subject: [python-win32] Re: upgrading to python 2.4 References: <20041209020104.B23141E4017@bag.python.org> <41B885E9.5000905@probo.com> Message-ID: Tim Roberts writes: > On Tue, 7 Dec 2004 15:33:34 -0800, "Charlie Taylor" > wrote: > >>Is there a good reference to the steps that should be taken to upgrade a >>Windows machine to the next version of python? >> >>My journey from 2.2 to 2.3 was very knicker-twisting. I'm hoping for more >>of a controlled landing on 2.4. >> > > You can't upgrade. You have to throw out the old and start over. > That's true any time the second digit changes. I cannot understand why virtually everyone insists to remove 2.3 before installing 2.4. I have even more Python versions (on Windows) installed at the same time, and I use batch scripts named py23.bat, py24.bat, and to on to select the one to run my scripts. This way I can develop with 2.4 (or even CVS), and deploy using 2.3. Thomas From tim.leeuwvander at nl.unisys.com Thu Dec 9 23:11:28 2004 From: tim.leeuwvander at nl.unisys.com (Leeuw van der, Tim) Date: Thu Dec 9 23:20:31 2004 Subject: [python-win32] mfc71.dll missing and not found on website? Message-ID: thanks! (should have thought of that myself...) -----Original Message----- From: Simon Brunning [mailto:simon.brunning@gmail.com] Sent: Thursday, December 09, 2004 6:31 PM To: Leeuw van der, Tim Cc: python-win32@python.org Subject: Re: [python-win32] mfc71.dll missing and not found on website? On Thu, 9 Dec 2004 11:39:01 +0100, Leeuw van der, Tim > Can anyone perhaps help me to find that DLL? First hit worked for me... -- Cheers, Simon B, simon@brunningonline.net, http://www.brunningonline.net/simon/blog/ From bluedust at swbell.net Fri Dec 10 02:14:38 2004 From: bluedust at swbell.net (Chris R. Martin) Date: Fri Dec 10 02:13:27 2004 Subject: [python-win32] win32 gui app example Message-ID: <41B8F87E.7030800@swbell.net> I looked all over the 'net today and could not find any examples of how to build a Python application using the win32gui module. There are some examples in the distribution but they really cover how to write a application as a top-level window. Using that code and some examples from win32 programming sites, I hacked together some code that almost works. The only problem that I have with it is that the program does not end after closing the main window. I am calling PostQuitMessage when the WM_DESTROY message is received, but this doesn't seem to work. I am assuming there is something wrong with my main loop. Can anyone help? Thanks, Chris Code below ---------- #example1.py import struct import win32api import win32con import win32gui class MainWindow: def __init__(self): win32gui.InitCommonControls() self.hinst = win32api.GetModuleHandle(None) def CreateWindow(self): className = self.RegisterClass() self.BuildWindow(className) def RegisterClass(self): className = "TeSt" message_map = { win32con.WM_DESTROY: self.OnDestroy, } wc = win32gui.WNDCLASS() wc.style = win32con.CS_HREDRAW | win32con.CS_VREDRAW wc.lpfnWndProc = message_map wc.cbWndExtra = 0 wc.hCursor = win32gui.LoadCursor( 0, win32con.IDC_ARROW ) wc.hbrBackground = win32con.COLOR_WINDOW + 1 wc.hIcon = win32gui.LoadIcon(0, win32con.IDI_APPLICATION) wc.lpszClassName = className # C code: wc.cbWndExtra = DLGWINDOWEXTRA + sizeof(HBRUSH) + (sizeof(COLORREF)); wc.cbWndExtra = win32con.DLGWINDOWEXTRA + struct.calcsize("Pi") #wc.hIconSm = 0 classAtom = win32gui.RegisterClass(wc) return className def BuildWindow(self, className): style = win32con.WS_OVERLAPPEDWINDOW xstyle = win32con.WS_EX_LEFT self.hwnd = win32gui.CreateWindow(className, "ThisIsJustATest", style, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, 500, 400, 0, 0, self.hinst, None) win32gui.ShowWindow(self.hwnd, win32con.SW_SHOW) def OnDestroy(self, hwnd, message, wparam, lparam): win32gui.PostQuitMessage(0) return True w = MainWindow() w.CreateWindow() win32gui.PumpMessages() ------- End code -- Guybrush: How can you see without eyeballs? Murray: How can you walk around without a brain? Some things no one can answer. From bluedust at swbell.net Fri Dec 10 02:30:48 2004 From: bluedust at swbell.net (Chris R. Martin) Date: Fri Dec 10 02:29:37 2004 Subject: [python-win32] win32 gui app example In-Reply-To: <41B8F87E.7030800@swbell.net> References: <41B8F87E.7030800@swbell.net> Message-ID: <41B8FC48.3000302@swbell.net> What I meant to say: > I looked all over the 'net today and could not find any examples of > how to build a Python application using the win32gui module. There are > some examples in the distribution but they really don't cover how to > write a application as a top-level window. That "don't" is important, otherwise I really look like an idiot. :) chris -- Guybrush: How can you see without eyeballs? Murray: How can you walk around without a brain? Some things no one can answer. From stephenemslie at gmail.com Fri Dec 10 12:26:42 2004 From: stephenemslie at gmail.com (stephen emslie) Date: Fri Dec 10 12:26:45 2004 Subject: [python-win32] How to send mail via Extended MAPI In-Reply-To: <20041209150245.6492881EE0@smtp2.pacifier.net> References: <20041209150245.6492881EE0@smtp2.pacifier.net> Message-ID: <51f97e530412100326539e70ff@mail.gmail.com> Thanks very much for this! On Thu, 9 Dec 2004 07:02:45 -0800, Chad and Anita Stryker wrote: > > > > David, > > > > Thank you for figuring this extended MAPI interface all out. I discovered a > couple of problems with the code (on my system at least). First, the > message in my outbox was marked as read. Second, the message would remain > in the outbox after it was sent. After several hours of work, I added three > lines to the function that mark the message as unread and cause the message > to be deleted from the outbox after it is sent. > > ... From timr at probo.com Fri Dec 10 18:42:08 2004 From: timr at probo.com (Tim Roberts) Date: Fri Dec 10 18:42:15 2004 Subject: [python-win32] Re: upgrading to python 2.4 In-Reply-To: <20041210110049.EF9D21E401B@bag.python.org> References: <20041210110049.EF9D21E401B@bag.python.org> Message-ID: <41B9DFF0.6020209@probo.com> On Thu, 09 Dec 2004 19:00:59 +0100, Thomas Heller wrote: > >I cannot understand why virtually everyone insists to remove 2.3 before >installing 2.4. I have even more Python versions (on Windows) installed >at the same time, and I use batch scripts named py23.bat, py24.bat, and >to on to select the one to run my scripts. > >This way I can develop with 2.4 (or even CVS), and deploy using 2.3. > > It's true, that works. But what is the point of developing on 2.4 if you have to deploy on 2.3? If you aren't going to be able to use any of 2.4's fancy new features when you deploy, why wouldn't you do your development under 2.3? -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From sdati at hotmail.com Fri Dec 10 21:30:05 2004 From: sdati at hotmail.com (Steve Davis) Date: Fri Dec 10 21:31:04 2004 Subject: [python-win32] Re: Internet Explorer COM issues with XP SP2? Message-ID: >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: ... I've spent the past couple days working on this problem independently - I discovered it just a few days ago when I returned to some scripts I had written to do website testing. I hadn't used them for a couple months. The problem seems to be more general than just using fireEvent - document.createEventObject() fails with the same error. I am running Win2k, and I see the same problem. Being a curious guy, I backed out a few patches to IE, and find that after I uninstall windows hotfix 889293 and 834707, I can fireEvent() and createEventObject() without any problem. But it's not a very good idea to be running without these security updates. So it seems to me that Microsoft managed to break automation of IE in a pretty bad way. The only documented change I can see that might have caused this is http://support.microsoft.com/kb/887741 I have no idea how to get this fixed - it appears to be either a bug introduced by Microsoft, or a design change. It does make automated web site testing pretty much impossible, unfortunately! Steve Davis From news at northportal.net Sun Dec 12 00:28:29 2004 From: news at northportal.net (VanL) Date: Sun Dec 12 00:41:23 2004 Subject: [python-win32] A Python Service that monitors the clipboard? Message-ID: I have tried several times after puzzling about the code in "Python Programming on Win32," but I have not been able to figure out a simple python service that monitors the clipboard. (My ultimate goal is to have a service that is something like ArsClip. I am trying to do this to learn more about Win32). Anyone have any ideas? Thanks, VanL From bgailer at alum.rpi.edu Sun Dec 12 03:16:47 2004 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Sun Dec 12 03:15:34 2004 Subject: [python-win32] A Python Service that monitors the clipboard? In-Reply-To: References: Message-ID: <6.2.0.14.0.20041211191445.066860c8@mail.mric.net> At 04:28 PM 12/11/2004, VanL wrote: >I have tried several times after puzzling about the code in "Python >Programming on Win32," but I have not been able to figure out a simple >python service that monitors the clipboard. (My ultimate goal is to have >a service that is something like ArsClip. I am trying to do this to learn >more about Win32). My guess is that each process has its own clipboard. So the service would see a different clipboard than an interactive session (unless you are logged on the console and the service interacts with the cosole). Python Programming on Win32 discusses clipboard management. Bob Gailer bgailer@alum.rpi.edu 303 442 2625 home 720 938 2625 cell From andre1 at yandex.ru Sun Dec 12 21:30:49 2004 From: andre1 at yandex.ru (Andrey Ivanov) Date: Sun Dec 12 21:25:12 2004 Subject: [python-win32] Re: A Python Service that monitors the clipboard? Message-ID: <106672902.20041212233049@yandex.ru> > I have tried several times after puzzling about the code in "Python > Programming on Win32," but I have not been able to figure out a simple > python service that monitors the clipboard. (My ultimate goal is to > have a service that is something like ArsClip. I am trying to do this > to learn more about Win32). > > Anyone have any ideas? > > Thanks, > > VanL A clipboard is shared among process assigned to the same WindowStation. By default all services run in another WindowStation with it's own clipboard. Your service will be assigned to the same WindowStation as interactive processes (usually WinSta0) *only* if you explicitly state that it is interactive when creating it. You can find all the details you need, either in MSDN or in excellent book series "Inside Microsoft Windows" by D. Solomon and M. Russinovich. Or I can try to make an example of Python service, accessing/monitoring cliboard, if you need it. :) From hgrund at gmx.de Sun Dec 12 23:31:19 2004 From: hgrund at gmx.de (Hannes Grund) Date: Sun Dec 12 23:31:21 2004 Subject: [python-win32] A Python Service that monitors the clipboard? References: Message-ID: <22905.1102890679@www1.gmx.net> Among the recent contributions to ActiveState's python-cookbook is a small application, that adds a window the clipboard viewer chain. Try the URL http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/355593 regards, Hannes Grund > I have tried several times after puzzling about the code in "Python > Programming on Win32," but I have not been able to figure out a simple > python service that monitors the clipboard. (My ultimate goal is to > have a service that is something like ArsClip. I am trying to do this > to learn more about Win32). > > Anyone have any ideas? > > Thanks, > > VanL > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- NEU +++ DSL Komplett von GMX +++ http://www.gmx.net/de/go/dsl GMX DSL-Netzanschluss + Tarif zum supergünstigen Komplett-Preis! From t-meyer at ihug.co.nz Mon Dec 13 00:49:49 2004 From: t-meyer at ihug.co.nz (Tony Meyer) Date: Mon Dec 13 00:50:31 2004 Subject: [python-win32] Re: upgrading to python 2.4 In-Reply-To: Message-ID: > It's true, that works. But what is the point of developing on 2.4 if > you have to deploy on 2.3? If you aren't going to be able to > use any of 2.4's fancy new features when you deploy, why wouldn't you > do your development under 2.3? Thinking more long-term, perhaps? Some 2.4's features can be used with 2.3 with appropriate compat modules and so on. I suspect that one of the main reasons that people have multiple versions installed for development, though, is to ensure that the code works across versions, because it's not known what version it will be deployed with. That's certainly what I do. =Tony.Meyer From hfuecks at gmail.com Mon Dec 13 10:03:42 2004 From: hfuecks at gmail.com (Harry Fuecks) Date: Mon Dec 13 10:03:44 2004 Subject: [python-win32] COM and Threaded XML-RPC server Message-ID: Hi, Wondering if someone can give me any pointers with a problem. Trying to call COM objects from inside an XML-RPC server which is using Python's threading (via SocketServer.ThreadingMixIn in the standard library). Gettings errors like; pywintypes.com_error:(-2147221020, 'Invalid syntax', None, None) If I use a single threaded server, no problem. Only getting this problem in combination with SocketServer.ThreadingMixIn. Example of the server looks like; #---------------------------------------------------- import SimpleXMLRPCServer, SocketServer import win32com.client class ThreadedXmlRpcServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer.SimpleXMLRPCServer): pass def listProcesses(): cses = win32com.client.GetObject("WinMgMts:").InstancesOf("Win32_Process") vals = [] for cs in cses: val = cs.Properties_("Caption").Value vals.append(val) return vals if __name__ == "__main__": print listProcesses() # This works... # This also works, if used - no threads... # server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8001)) # This doesnt... server = ThreadedXmlRpcServer(("localhost", 8001)) server.register_function(listProcesses) server.serve_forever() #---------------------------------------------------- And a client if anyone want's to try; #---------------------------------------------------- import xmlrpclib server = xmlrpclib.Server('http://localhost:8001') print server.listProcesses() #---------------------------------------------------- Apologies in advance if there's something obvious I've missed (like COM + threading is only possible via the win32api methods) - it's more than possible I'm guilty of clueless newbieness. Many thanks From python at kareta.de Mon Dec 13 15:52:57 2004 From: python at kareta.de (python@kareta.de) Date: Mon Dec 13 16:05:39 2004 Subject: [python-win32] remote copy with compress/decompress Message-ID: <1102949577.41bdacc939edd@webmail.ldc.de> Hello, I'm wondering if i try a good solution for the following problem: We have an old DOS Application running on a W2K-Server which uses normal DOS-print and a workstation(w2k) in an outlet connected to the server via VPN. The workstation uses remote desktop to run the software and prints to LPT 1,2,3 on the server. If I redirect the servers LPT's to a lokal printer of the workstation, printing is to slow. So I need a solution for this. My solution is as follow: 1: capture DOS-print to file =>solved 2: compress printfile => solved 3: open a socket, transfer file to desktop 4: decompress file step 3 and 4 is to develop a socket with python 5: print it on lokal printer => solved What do you think about it. I think of sockets because step 4 should be done automatically when the file arrives at the workstation. Otherwise I have to check a directory on the workstation for incomming files every 20 seconds. Sorry, for asking a question that is not pure python. But I'm still learning and to know that python is not good for that, helps me also out :-) regards, J?rgen ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/ From tim.golden at viacom-outdoor.co.uk Mon Dec 13 16:16:15 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon Dec 13 16:15:49 2004 Subject: [python-win32] COM and Threaded XML-RPC server Message-ID: <9A28C052FF32734DACB0A288A3533991035933@vogbs009.gb.vo.local> [Harry Fuecks] Well just a quick response to start with. I can't tell for sure, but most probs with multithreaded apps and COM derive from not initializing the COM threading model. Have a look at this post: http://aspn.activestate.com/ASPN/Mail/Message/Python-win32/2168314 for a discussion of a similar theme. It's using the WMI module rather than the "raw" pywin32 COM code, but it comes to the same thing. (The module issues the calls for you under the covers). If that doesn't help -- and it might not -- feel free to post again to ask for more help. 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 hfuecks at gmail.com Mon Dec 13 16:30:34 2004 From: hfuecks at gmail.com (Harry Fuecks) Date: Mon Dec 13 16:30:37 2004 Subject: [python-win32] COM and Threaded XML-RPC server In-Reply-To: <9A28C052FF32734DACB0A288A3533991035933@vogbs009.gb.vo.local> References: <9A28C052FF32734DACB0A288A3533991035933@vogbs009.gb.vo.local> Message-ID: Hi Tim, Works perfectly - many thanks (the Python Win32 book is due Christmas so hopefully will know things like that in future). Also using the WMI module btw (example stripped down to show the point) - many thanks for writing it - saves alot of effort. Regards, Harry On Mon, 13 Dec 2004 15:16:15 -0000, Tim Golden wrote: > [Harry Fuecks] > > Well just a quick response to start with. I can't tell > for sure, but most probs with multithreaded apps and > COM derive from not initializing the COM threading > model. Have a look at this post: > > http://aspn.activestate.com/ASPN/Mail/Message/Python-win32/2168314 > > for a discussion of a similar theme. It's using the WMI > module rather than the "raw" pywin32 COM code, but it > comes to the same thing. (The module issues the calls > for you under the covers). > > If that doesn't help -- and it might not -- feel free to post > again to ask for more help. > > 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 Mark.English at liffe.com Mon Dec 13 17:52:16 2004 From: Mark.English at liffe.com (Mark English) Date: Mon Dec 13 17:52:21 2004 Subject: [python-win32] Problem building pywin32 Message-ID: <40E605146701DE428FAF21286A97D3091744F3@wphexa02.corp.lh.int> I'm trying to build pywin32, and would like to know how to specify an override for the include directories. It's finding "shlobj.h" here: "C:\Program Files\Microsoft SDK\include\shlobj.h" But I want it to use the one here: "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ShlObj.h" Is there a way to pass this as a command line argument to setup.py ? Thanks, MarkE P.S. For what it's worth I modified msi.py to build a debug or release version of the core. There's one or two hard coded paths which could be easily amended. If anyone's interested I'd be happy to email it or post it somewhere. ----------------------------------------------------------------------- The information contained in this e-mail is confidential and solely for the intended addressee(s). Unauthorised reproduction, disclosure, modification, and/or distribution of this email may be unlawful. If you have received this email in error, please notify the sender immediately and delete it from your system. The views expressed in this message do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary companies. ----------------------------------------------------------------------- From news at northportal.net Mon Dec 13 18:32:45 2004 From: news at northportal.net (VanL) Date: Mon Dec 13 18:32:54 2004 Subject: [python-win32] Re: A Python Service that monitors the clipboard? In-Reply-To: References: Message-ID: Thanks for the replies so far. I have played a little bit with the clipboard code, and I found the ctypes code snippet reproduced this message. I have tweaked this a little bit and was going to use this to set the clipboard text across processes. The thing that I can't figure out is how to have a service that waits on the clipboard - i.e., has a function that is called when the clipboard changes. I was then going to look at the text on the clipboard to dtermine whether I should replace any of it. VanL ------------------------------------ from: I was going to use this to set the clipboard text across processes from ctypes import * from win32con import CF_TEXT, GHND OpenClipboard = windll.user32.OpenClipboard EmptyClipboard = windll.user32.EmptyClipboard GetClipboardData = windll.user32.GetClipboardData SetClipboardData = windll.user32.SetClipboardData CloseClipboard = windll.user32.CloseClipboard GlobalLock = windll.kernel32.GlobalLock GlobalAlloc = windll.kernel32.GlobalAlloc GlobalUnlock = windll.kernel32.GlobalUnlock memcpy = cdll.msvcrt.memcpy def GetClipboardText(): text = "" if OpenClipboard(c_int(0)): hClipMem = GetClipboardData(c_int(CF_TEXT)) GlobalLock.restype = c_char_p text = GlobalLock(c_int(hClipMem)) GlobalUnlock(c_int(hClipMem)) CloseClipboard() return text def SetClipboardText(text): buffer = c_buffer(text) bufferSize = sizeof(buffer) hGlobalMem = GlobalAlloc(c_int(GHND), c_int(bufferSize)) GlobalLock.restype = c_void_p lpGlobalMem = GlobalLock(c_int(hGlobalMem)) memcpy(lpGlobalMem, addressof(buffer), c_int(bufferSize)) GlobalUnlock(c_int(hGlobalMem)) if OpenClipboard(0): EmptyClipboard() SetClipboardData(c_int(CF_TEXT), c_int(hGlobalMem)) CloseClipboard() From djones at innovativerobotics.com Mon Dec 13 22:08:46 2004 From: djones at innovativerobotics.com (Dave Jones) Date: Mon Dec 13 22:03:44 2004 Subject: [python-win32] Re: Python-win32 Digest, Vol 21, Issue 13 In-Reply-To: <20041213110042.64E0A1E4015@bag.python.org> Message-ID: I posted this once before and got no responses. One more try and I guess I'll have to give up. I really hate to though... Pythonwin has quit working properly on my office computer, and I am at a loss as to how to fix it. I am using Python23 on MS Windows 2000 Pro. Prior to re-installing Pythonwin, I have uninstalled Pythonwin and Python, removed everything left over in the registry, and removed the Python23 dircectory. I even re-ran MS service pack 4. Pythonwin became broke at about the same time that I installed and then uninstalled Python 2.4. That could be a coincidence, or it could be significant; I don't know. Here are the symptoms: I open Pythonwin either through the menu shortcut or by clicking on the .exe directly. I have tried starting it in every conceivable directory. In any case, if I immediately use the X box to close Pythonwin, it closes properly. All the menus items on the main frame appear to be functional. But if I first open a .py file using the menu File/Open... then everything is frozen that's associated with the main window frame or the new file window's frame. I cannot close the new window or the main frame using an X box. Neither can I minimize either window, nor use any of the menu items on the main frame. I cannot re-size either window. Operations on the file itself, like right-click/ select-all seem to work okay. I can minimize or close Pythonwin from the MS Windows task bar. The interactive window seems to bahave properly in every respect. Please help. I really would like to be able to use Pythonwin again. Thanks, Dave From jens.jorgensen at tallan.com Tue Dec 14 00:22:36 2004 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Tue Dec 14 00:22:44 2004 Subject: [python-win32] remote copy with compress/decompress In-Reply-To: <1102949577.41bdacc939edd@webmail.ldc.de> References: <1102949577.41bdacc939edd@webmail.ldc.de> Message-ID: <41BE243C.40804@tallan.com> Well, this is pretty easy to do. The server side would look like this import socket, sys, pickle s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', 7777)) s.listen(5) while True : clientsock, clientaddr = s.accept() # read size of file file_size = pickle.load(clientsock.makefile('r')) # now we read through the file and write it out f = file('outputfile', 'w') i = 0 while i < file_size : buf = clientsock.recv(1024) if not buf : print 'error: client closed socket prematurely' sys.exit(-1) f.write(buf) i += len(buf) clientsock.close() f.close() # now do whatever else with your file and the client code analogously looks like this: import socket, pickle, os fname = 'filetosend' st = os.stat(fname) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('localhost', 7777)) sw = s.makefile('w') pickle.dump(st.st_size, sw) f = file(fname, 'rb') i = 0 while i < st.st_size : buf = f.read(1024) sw.write(buf) i += len(buf) sw.close() s.close() f.close() The above is simply the socket code to handle this file transfer. The server listens on port 7777, a number I just arbitrarily chose. The server listens for connections in a loop. When it receives a connection is first reads the size of the file (encoded in pickle format) and then opens up 'outputfile' to write the contents into. The just closes file and socket when done. The client does its end of this, connecting to port 7777 on localhost (in this case since I was doing this on my own machine), opening the file to be sent, sending the file's size and then the contents of the file. Easy! python@kareta.de wrote: >Hello, > >I'm wondering if i try a good solution for the following problem: > >We have an old DOS Application running on a W2K-Server which uses normal >DOS-print and a workstation(w2k) in an outlet connected to the server via VPN. >The workstation uses remote desktop to run the software and prints to LPT 1,2,3 >on the server. If I redirect the servers LPT's to a lokal printer of the >workstation, printing is to slow. So I need a solution for this. > >My solution is as follow: >1: capture DOS-print to file =>solved >2: compress printfile => solved > >3: open a socket, transfer file to desktop >4: decompress file >step 3 and 4 is to develop a socket with python > >5: print it on lokal printer => solved > >What do you think about it. I think of sockets because step 4 should be done >automatically when the file arrives at the workstation. Otherwise I have to >check a directory on the workstation for incomming files every 20 seconds. > >Sorry, for asking a question that is not pure python. But I'm still learning >and to know that python is not good for that, helps me also out :-) > >regards, >J?rgen > > > > >------------------------------------------------- >This mail sent through IMP: http://horde.org/imp/ >_______________________________________________ >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 djones at innovativerobotics.com Tue Dec 14 05:38:28 2004 From: djones at innovativerobotics.com (Dave Jones) Date: Tue Dec 14 05:33:24 2004 Subject: [python-win32] Re: Python-win32 Digest, Vol 21, Issue 13 In-Reply-To: <20041213110042.64E0A1E4015@bag.python.org> Message-ID: Does anyone have a Numeric module compiled for Python 2.4? Thankee, Dave From tony at tcapp.com Tue Dec 14 07:42:04 2004 From: tony at tcapp.com (Tony Cappellini) Date: Tue Dec 14 07:42:14 2004 Subject: [python-win32] DLL spec In-Reply-To: <20041209162834.63F321E4019@bag.python.org> References: <20041209162834.63F321E4019@bag.python.org> Message-ID: <6.1.2.0.0.20041213223845.01f57990@mail.yamato.com> This isn't really a purely-Python question, but ... I want to write a small Python app that dumps the contents of DLL's. I know there is a program called bindump or something similar that comes with VC6, which shows you the name of the callable routines, their entry points, and some other info, for a DLL whose name is passed to this utility. However, I don't know how this information is obtained. Is there a DLL "spec" that talks about the structure of a Microsoft DLL ? From niki at vintech.bg Tue Dec 14 10:40:45 2004 From: niki at vintech.bg (Niki Spahiev) Date: Tue Dec 14 10:40:55 2004 Subject: [python-win32] DLL spec In-Reply-To: <6.1.2.0.0.20041213223845.01f57990@mail.yamato.com> References: <20041209162834.63F321E4019@bag.python.org> <6.1.2.0.0.20041213223845.01f57990@mail.yamato.com> Message-ID: <41BEB51D.1070102@vintech.bg> Check py2exe. It contains some utility modules that do such things. HTH Niki Spahiev From Neil.Benn at cenix-bioscience.com Mon Dec 13 10:32:58 2004 From: Neil.Benn at cenix-bioscience.com (Neil Benn) Date: Tue Dec 14 17:03:42 2004 Subject: [python-win32] DispatchWithEvents call Message-ID: <1015977.1102930378171.SLOX.WebMail.wwwrun@exon.cenix-bioscience.com> Hello, I'm trying to use win32com to access a COM object with Events. After some searching I discovered the call to win32com.client.DispatchWithEvent can be used - passing a class with the method signatures for each event for thrown by the ActiveX component. However I'm getting a strange exception from somewhere inside the win32com code and can't find a great deal of documentation on this method on the web. Could anyone help me out as to what's going on. The code is beneath, followed by the exception that occurrs, if I make a call to dispatch the code is working. import win32com.client class ScannerEvents(object): bLoaded = False def DuplicateFound(self, nCount, strDuplicates): print "Duplicate Found" def ReadComplete(self): print "ReadComplete" def UIClosing(self): print "UIClosing" def UILoaded(self): print "UILoaded" bLoaded = True class Scanner(object): objVM = None objEvents = None def init(self): print "init" objEvents = ScannerEvents() print 'calling LoadUI' #objVM = win32com.client.Dispatch("VisionMate96.cVisionMate96") objVM = win32com.client.DispatchWithEvents("VisionMate96.cVisionMate96", objEvents) objVM.LoadUI() print 'Called LoadUI' if __name__ == '__main__': objScanner = Scanner() objScanner.init() >>> ## working on region in file c:\Documents and Settings\Neil\My >>> Documents\Python stuff\python-4ZAXnv.py... init caling LoadUI Traceback (most recent call last): File "", line 1, in ? File "c:\Documents and Settings\Neil\My Documents\Python stuff\python-4ZAXnv.py", line 33, in ? objScanner.init() File "c:\Documents and Settings\Neil\My Documents\Python stuff\python-4ZAXnv.py", line 28, in init objVM = win32com.client.DispatchWithEvents("VisionMate96.cVisionMate96", objEvents) File "C:\Python23\Lib\site-packages\win32com\client\__init__.py", line 264, in DispatchWithEvents result_class = new.classobj("COMEventClass", (disp_class, events_class, user_event_class), {"__setattr__" : _event_setattr_}) TypeError: default __new__ takes no parameters FYI - the component is an ActiveX control to control a flat bed scanner which then scans a load of plastic tubes containing 2D barcodes, decodes them and returns the barcodes of the tubes. Thanks, for any and all help. Cheers, Neil Cenix Bioscience GmbH From theller at python.net Tue Dec 14 17:20:22 2004 From: theller at python.net (Thomas Heller) Date: Tue Dec 14 17:19:21 2004 Subject: [python-win32] Re: DLL spec References: <20041209162834.63F321E4019@bag.python.org> <6.1.2.0.0.20041213223845.01f57990@mail.yamato.com> Message-ID: Tony Cappellini writes: > This isn't really a purely-Python question, but ... > I want to write a small Python app that dumps the contents of DLL's. > I know there is a program called bindump or something similar that > comes with VC6, which shows you the name of the callable routines, > their entry points, and some other info, for a DLL whose name is > passed to this utility. > > However, I don't know how this information is obtained. Is there a DLL > "spec" that talks about the structure of a Microsoft DLL ? Executable files on windows are in "Portable Executable Format". Wikipedia for example has some links. http://en.wikipedia.org/wiki/Portable_Executable For a script in Python, I posted something that may help you getting started to the ctypes-users list, some time ago: http://article.gmane.org/gmane.comp.python.ctypes.user/432 Thomas From benn at cenix-bioscience.com Tue Dec 14 17:34:45 2004 From: benn at cenix-bioscience.com (Neil Benn) Date: Tue Dec 14 17:34:43 2004 Subject: [python-win32] DispatchWithEvents call In-Reply-To: <1015977.1102930378171.SLOX.WebMail.wwwrun@exon.cenix-bioscience.com> References: <1015977.1102930378171.SLOX.WebMail.wwwrun@exon.cenix-bioscience.com> Message-ID: <41BF1625.2000606@cenix-bioscience.com> Neil Benn wrote: >Hello, > >I'm trying to use win32com to access a COM object with Events. After > some searching I discovered the call to > win32com.client.DispatchWithEvent can be used - passing a class > with the method signatures for each event for thrown by the > ActiveX component. > >However I'm getting a strange exception from somewhere inside the > win32com code and can't find a great deal of documentation on this > method on the web. Could anyone help me out as to what's going on. The > code is beneath, followed by the exception that occurrs, if I make a > call to dispatch the code is working. > > > Hello, Errr, worked it out by reading the PyDoc in the source file. I'm using getevents to create an object (still unsure about the DispatchWithEvents - pass in a class definition : how do I get a reference to the instance?). Anyways - I have a new problem, the object for the events - the events are not being fired on this instance, ie the methods on mt event object instance are not being called. Needless to say I've created the same implementation using other methodologies to check if the ActiveX component works (VB6) and I'm having no problem. Don't know if it matters but the component is an Out Of Process component (ie an exe). Thanks for listening. Cheers, Neil -- Neil Benn Senior Automation Engineer Cenix BioScience BioInnovations Zentrum Tatzberg 47 D-01307 Dresden Germany Tel : +49 (0)351 4173 154 e-mail : benn@cenix-bioscience.com Cenix Website : http://www.cenix-bioscience.com From neil.benn at arcor.de Wed Dec 15 17:52:18 2004 From: neil.benn at arcor.de (Neil Benn) Date: Wed Dec 15 17:52:19 2004 Subject: [python-win32] ActiveX components with Events Message-ID: <41C06BC2.7030004@arcor.de> Hello, FYI, this is the same Neil Benn who posted a couple of days ago - just from a different address. Thanks for your help Mark, however - I had made a silly mistake, I was passing an instance rather than a class to the DispatchWithEvents call. I didn't understand that the DispatchWithEvents call combines the Event interface and ActiveX component into one component. However, I have a problem that one of the methods on the ActiveX should show a UI and fire an event. The python code doesn't show the UI and no events get fired. This does the same thing in VB uncles I wait in a polling loop for my call to the ActiveX component and use the ubiquitous DoEvents call in VB6 - is there something which will allow me to yield control to the OS in the same way as VB6 in Python. I'm guessing that I'm wrestling with a poorly written ActiveX component (exe) but that's the life of someone working in laboratory automation!! Cheers for your help - I'll even be graceful if Australia manages to retain the ashes next year!!! Cheers, Neil -- Neil Benn Senior Automation Engineer Cenix BioScience BioInnovations Zentrum Tatzberg 47 D-01307 Dresden Germany Tel : +49 (0)351 4173 154 e-mail : benn@cenix-bioscience.com Cenix Website : http://www.cenix-bioscience.com From python at kareta.de Wed Dec 15 20:47:20 2004 From: python at kareta.de (python@kareta.de) Date: Wed Dec 15 20:58:52 2004 Subject: [python-win32] remote copy with compress/decompress Message-ID: <1103140040.41c094c87b1bc@webmail.ldc.de> Hello Jens, hello all, thanks for your replay. I tried your solution first and get some errors. Independing of the size in socket.recv and f.read I allways get an empty datastring after 1770 bytes. But I found a similiar solution here http://mail.python.org/pipermail/python-list/2002-July/111754.html. This code uses struct instead of pickle and that works for me. I don't know if one of this solutions has some advantages/disadvantages, but I will try it laiter again with pickle. But I have some more questions: 1) If the serverside runs in inifitiv loop, the 'break into running code' funktion of pythonwin doesn't works, because it is a system call. Is there a way to stop the programm using a shortcut ? 2) Maybe I want to install the serverside as a service like it is described in Mark's book. Then step 1) can be solved by stopping the service. Is it save to run it this way: >s = socket(AF_INET,SOCK_STREAM) >s.bind(('',PORT)) >s.listen(1) >while True: > q,v = s.accept() > ... rest of code, s and q are not closed or have I to use threads or what ever else to make sure that the socket is still listening ? When I tried this code, I get sometimes 'conection refused' errors after the serverside runs for longer time. regards, J?rgen ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/ From jens.jorgensen at tallan.com Wed Dec 15 22:03:13 2004 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Wed Dec 15 22:03:22 2004 Subject: [python-win32] remote copy with compress/decompress In-Reply-To: <1103140040.41c094c87b1bc@webmail.ldc.de> References: <1103140040.41c094c87b1bc@webmail.ldc.de> Message-ID: <41C0A691.5070305@tallan.com> python@kareta.de wrote: >Hello Jens, hello all, > >thanks for your replay. I tried your solution first and get some errors. >Independing of the size in socket.recv and f.read I allways get an empty >datastring after 1770 bytes. But I found a similiar solution here >http://mail.python.org/pipermail/python-list/2002-July/111754.html. This code >uses struct instead of pickle and that works for me. I don't know if one of this >solutions has some advantages/disadvantages, but I will try it laiter again with >pickle. > > That's weird. I cannot think of any reason why it would work with struct and not pickle. I specifically used pickle so I wouldn't have to worry about type truncation. etc. In Python a 'long' datatype is what os.stat returns for the size and is, specifically, potentially bigger than a 32-bit int. I figured that way I could very portably send the size without worrying about what architecture was on either end. In your case of course you could make stricter assumptions (same endianness, files less than 4GB) but I didn't want to post something for all the world to see that would have those types of limitations (of course, I didn't actually compile and test the code i sent per se--just check some of the statements--so clearly I wasn't being all /that/ careful). >But I have some more questions: >1) If the serverside runs in inifitiv loop, the 'break into running code' >funktion of pythonwin doesn't works, because it is a system call. Is there a way >to stop the programm using a shortcut ? > > Sure, there are plenty of ways to stop it. Actually I would imagine that at some point you'd probably want to go one of two routes: either make it run as an NT Service or give it a GUI that maybe shows you a little indication when something is going, a short log of transfers, etc. In either case there would be an appropriate way of stopping the program. In the case of a service I would probably run the above in a separate thread and create an NT Event (win32event.CreateEvent) and then in the loop you can set up to wait on either of this event of a socket acceptance coming. In the case of a gui I would do just about the same thing except that instead of the Service Control Manager dispatch being the place where the event gets signalled it you'd maybe add a button (and also in the close handler) to signal the event. >2) Maybe I want to install the serverside as a service like it is described in >Mark's book. Then step 1) can be solved by stopping the service. Is it save to >run it this way: > > > >>s = socket(AF_INET,SOCK_STREAM) >>s.bind(('',PORT)) >>s.listen(1) >>while True: >> q,v = s.accept() >> ... rest of code, s and q are not closed >> >> > > > Nope, not safe really. Well, you could just exit the program when the service stop happens but that would be uncouth. The more elegant solution would be to do as I mentioned above and use an event. Unfortunately this complicates things a little bit. Either you can make the listening socket asynchronous (or do a settimeout )and poll it in a loop with a delay in between or you can do the more windowsy way and add a windows event. So let's say that we have a close_evt to signal that it is time to exit and a accept_evt to signal that we've received a socket connection. The code to do this looks like: close_evt = win32event.CreateEvent(None, True, False, None) accept_evt = win32event.CreateEvent(None, False, False, None) win32file.WSAEventSelect(s, accept_evt, win32file.FD_ACCEPT) (assuming the socket we are listening on is 's') Then in our loop we do this: while True : retval = win32event.WaitForMultipleObjects((close_evt, accept_evt), False, win32event.INFINITE) if retval == win32event.WAIT_OBJECT_0 : # this means it is time to exit win32file.CloseHandle(accept_evt) s.close() return else if retval == win32event.WAIT_OBJECT_0 + 1 : # this means we have received a socket connection (client_sock, client_addr) = s.accept() # ... with the above construct we can make sure our "worker" thread isn't busy serving a client when we shut down. The way to complete this is to have the dispatch thread signal the event (win32event.SetEvent(close_evt)) and then wait for the worker thread to exit, then the program can exit. >or have I to use threads or what ever else to make sure that the socket is still >listening ? When I tried this code, I get sometimes 'conection refused' errors >after the serverside runs for longer time. > >regards, >J?rgen > >------------------------------------------------- >This mail sent through IMP: http://horde.org/imp/ >_______________________________________________ >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 mhammond at skippinet.com.au Wed Dec 15 23:35:29 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed Dec 15 23:35:35 2004 Subject: [python-win32] Problem building pywin32 In-Reply-To: <40E605146701DE428FAF21286A97D3091744F3@wphexa02.corp.lh.int> Message-ID: <125401c4e2f6$619eb640$0f0a0a0a@enfoldsystems.local> > I'm trying to build pywin32, and would like to know how to specify an > override for the include directories. > It's finding "shlobj.h" here: > "C:\Program Files\Microsoft SDK\include\shlobj.h" > > But I want it to use the one here: > "C:\Program Files\Microsoft Visual Studio .NET > 2003\Vc7\PlatformSDK\Include\ShlObj.h" > > Is there a way to pass this as a command line argument to setup.py ? Unfortunately, there is not. Why exactly do you want this? For Python 2.3, you don't want the MSVC7 header files, and for Python 2.4 (which does use VC7), things seem to work fine for me here, even though I also have the SDK installed. I did yesterday manage to make a change to win32com.shell that no longer builds on another box I have access to - I'm sorting that out now. I see breakage on 2.3 though which should never try and use the VC7 one, so I doubt it is exactly the same problem. Mark -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 2080 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20041216/5e8c6acd/winmail.bin From mhammond at skippinet.com.au Wed Dec 15 23:37:56 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed Dec 15 23:37:59 2004 Subject: [python-win32] ActiveX components with Events In-Reply-To: <41C06BC2.7030004@arcor.de> Message-ID: <125801c4e2f6$b9765a30$0f0a0a0a@enfoldsystems.local> > However, I have a problem that one of the methods on the ActiveX > should show a UI and fire an event. The python code doesn't > show the UI > and no events get fired. This does the same thing in VB > uncles I wait in > a polling loop for my call to the ActiveX component and use the > ubiquitous DoEvents call in VB6 - is there something which > will allow me > to yield control to the OS in the same way as VB6 in Python. ActiveX controls need an AX control "container" in order for them to work correctly. win32com by itself currently can not provide such an environment. However, Pythonwin and wxPython both can (Pythonwin by virtue of MFC, wxPython by virtue of wxWindows). I don't know much about wxPython's support, but see pythonwin\pywin\demos\ocx for examples of how to do it in pythonwin. Mark From neil.benn at arcor.de Thu Dec 16 00:58:41 2004 From: neil.benn at arcor.de (Neil Benn) Date: Thu Dec 16 00:58:41 2004 Subject: [python-win32] ActiveX components with Events In-Reply-To: <125801c4e2f6$b9765a30$0f0a0a0a@enfoldsystems.local> References: <125801c4e2f6$b9765a30$0f0a0a0a@enfoldsystems.local> Message-ID: <41C0CFB1.50506@arcor.de> Mark Hammond wrote: >> However, I have a problem that one of the methods on the ActiveX >>should show a UI and fire an event. The python code doesn't >>show the UI >>and no events get fired. This does the same thing in VB >>uncles I wait in >>a polling loop for my call to the ActiveX component and use the >>ubiquitous DoEvents call in VB6 - is there something which >>will allow me >>to yield control to the OS in the same way as VB6 in Python. >> >> > >ActiveX controls need an AX control "container" in order for them to work >correctly. win32com by itself currently can not provide such an >environment. However, Pythonwin and wxPython both can (Pythonwin by virtue >of MFC, wxPython by virtue of wxWindows). I don't know much about >wxPython's support, but see pythonwin\pywin\demos\ocx for examples of how to >do it in pythonwin. > >Mark > > > > Hello, Sorry that was a bad explanation - the control _is_ an ActiveX exe - not an ocx - it simply brings up a form (which in actual fact I then hide immediatly, I can't stop the form appearing in the first place - it has to appear for a few millisecs like a subliminal message). The component is an out of process exe - I did find something like DoEvents in pythoncom.PumpWaitingMessages - however I still can't get the win32com/python interation working, events are not simply not fired in my code. I think that I will have to write a thin wrapper in VB or C# to access the underlying ActiveX exe (and protect the exe from the vagarities of the interface) which can then be accesssed with win32com - bit of a pain because it means that I have a maintenance issue (I work in a pure python shop and VB/C# code cannot be maintained by anyone except for me) but hey, its a protection against future redundancies ! However if you know any gotchyas with ActiveX exe/win32com integration that I could look out for then that would be great. Thanks for your help. Cheers, Neil From rays at blue-cove.com Thu Dec 16 01:45:15 2004 From: rays at blue-cove.com (Ray S) Date: Thu Dec 16 01:38:29 2004 Subject: [python-win32] Windows process priority setting question... (cross-post) Message-ID: <5.2.0.4.2.20041215164409.07a58b48@blue-cove.com> Is it possible to have an app re-set its own priority, a-la task manager? I see that 2.4+ has the ability for sub-processes, but only on creation. Apparently win32process.SetPriorityClass(handle, dwPriorityClass) and PyCWinThread.SetThreadPriority(priority) allows one to change a sub while a the sub is running, but what about the current? Ray From Mark.English at liffe.com Thu Dec 16 12:07:56 2004 From: Mark.English at liffe.com (Mark English) Date: Thu Dec 16 12:07:59 2004 Subject: [python-win32] Problem building pywin32 Message-ID: <40E605146701DE428FAF21286A97D309022FC8D5@wphexa02.corp.lh.int> > From: Mark Hammond [mailto:mhammond@skippinet.com.au] > Sent: 15 December 2004 22:35 > To: Mark English; python-win32@python.org > Subject: RE: [python-win32] Problem building pywin32 > > > > Is there a way to pass this (include directory) as a command line argument to setup.py ? > > Unfortunately, there is not. Why exactly do you want this? > For Python 2.3, you don't want the MSVC7 header files, and > for Python 2.4 (which does use VC7), things seem to work fine > for me here, even though I also have the SDK installed. > > I did yesterday manage to make a change to win32com.shell > that no longer builds on another box I have access to - I'm > sorting that out now. I see breakage on 2.3 though which > should never try and use the VC7 one, so I doubt it is > exactly the same problem. > > Mark > I realise now this was laziness on my part. I have an out of date SDK installation, and normally rely on the version that ships with VC7.1 for what I need. Various structures and API methods were not being defined. Thanks, Mark (Another one) ----------------------------------------------------------------------- The information contained in this e-mail is confidential and solely for the intended addressee(s). Unauthorised reproduction, disclosure, modification, and/or distribution of this email may be unlawful. If you have received this email in error, please notify the sender immediately and delete it from your system. The views expressed in this message do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary companies. ----------------------------------------------------------------------- From mokumgast38-pancakes at yahoo.com Wed Dec 15 22:41:37 2004 From: mokumgast38-pancakes at yahoo.com (mokumgast38-pancakes@yahoo.com) Date: Thu Dec 16 16:38:45 2004 Subject: [python-win32] Calling ADO/XML from Python Message-ID: <20041215214137.18886.qmail@web54202.mail.yahoo.com> Currently I am testing a few samples in Python from: Programming Microsoft® SQL Server™ 2000 with XML, Second Edition (http://www.microsoft.com/mspress/books/6137.asp) The following fragment (from chapter 6) does not work: _conn = GenericUtil.CreateCOMObject('ADODB._connection') _conn._connectionString = "DATA PROVIDER=SQLOLEDB;SERVER=%s;Database=%s;Persist Security Info=False;User ID=%s;Password=%s" _conn.Provider = 'SQLXMLOLEDB.3.0' _conn.Open() _cmd = GenericUtil.CreateCOMObject('ADODB.Command') _cmd.Active_connection = _conn _cmd.Dialect = '{C8B522D7-5CF3-11CE-ADE5-00AA0044773D}' _outstr = GenericUtil.CreateCOMObject("ADODB.Stream") _outstr.Open() _cmd.Properties.Item('Output Stream').Value = _outstr _cmd.CommandText = "select * from test for xml auto" _cmd.Execute(Options = 1024) _outstr.Position = 0 print _outstr.ReadText(-1) Because COM is complaining about the output stream, which is supposted to be set in: _cmd.Properties.Item('Output Stream').Value = _outstr The same code in vbs does work. I am running winXP, ADO 2.8, python 2.3.4 From niki at vintech.bg Fri Dec 17 09:26:13 2004 From: niki at vintech.bg (Niki Spahiev) Date: Fri Dec 17 09:26:26 2004 Subject: [python-win32] ActiveX components with Events In-Reply-To: <41C0CFB1.50506@arcor.de> References: <125801c4e2f6$b9765a30$0f0a0a0a@enfoldsystems.local> <41C0CFB1.50506@arcor.de> Message-ID: <41C29825.4020003@vintech.bg> Neil Benn wrote: > Hello, > > Sorry that was a bad explanation - the control _is_ an ActiveX > exe - not an ocx - it simply brings up a form (which in actual fact I > then hide immediatly, I can't stop the form appearing in the first place > - it has to appear for a few millisecs like a subliminal message). The > component is an out of process exe - I did find something like DoEvents > in pythoncom.PumpWaitingMessages - however I still can't get the > win32com/python interation working, events are not simply not fired in > my code. > > I think that I will have to write a thin wrapper in VB or C# to > access the underlying ActiveX exe (and protect the exe from the > vagarities of the interface) which can then be accesssed with win32com - > bit of a pain because it means that I have a maintenance issue (I work > in a pure python shop and VB/C# code cannot be maintained by anyone > except for me) but hey, its a protection against future redundancies > ! However if you know any gotchyas with ActiveX exe/win32com > integration that I could look out for then that would be great. Check venster (sf.net) there is demo with flash OCX, and controlling it is OK. HTH Niki Spahiev From Jason.Hihn at verint.com Fri Dec 17 16:00:56 2004 From: Jason.Hihn at verint.com (Hihn, Jason) Date: Fri Dec 17 16:01:02 2004 Subject: [python-win32] ActiveX components with Events Message-ID: I will attempt to use my psychic powers and read into this situation more than you have told. That ActiveX is coded in VB, hence the OCX. The VB is calling form.show(). I bet (if all previous assumptiona are correct) that you could fix the subliminal message by calling form.load() I will stop now before people start thinking that I am proud of knowing VB. > > Sorry that was a bad explanation - the control _is_ an ActiveX > exe - not an ocx - it simply brings up a form (which in actual fact I > then hide immediatly, I can't stop the form appearing in the first place > - it has to appear for a few millisecs like a subliminal message). The > component is an out of process exe - I did find something like DoEvents > in pythoncom.PumpWaitingMessages - however I still can't get the > win32com/python interation working, events are not simply not fired in > my code. > > I think that I will have to write a thin wrapper in VB or C# to > access the underlying ActiveX exe (and protect the exe from the > vagarities of the interface) which can then be accesssed with win32com - > bit of a pain because it means that I have a maintenance issue (I work > in a pure python shop and VB/C# code cannot be maintained by anyone > except for me) but hey, its a protection against future redundancies > ! However if you know any gotchyas with ActiveX exe/win32com > integration that I could look out for then that would be great. > > Thanks for your help. > > Cheers, > > Neil > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 __________________________________________________________________________________________ This electronic message may contain proprietary and confidential information of Verint Systems Inc., its affiliates and/or subsidiaries. The information is intended to be for the use of the individual(s) or entity(ies) named above. If you are not the intended recipient (or authorized to receive this e-mail for the intended recipient), you may not use, copy, disclose or distribute to anyone this message or any information contained in this message. If you have received this electronic message in error, please notify us by replying to this e-mail. (1) From benn at cenix-bioscience.com Fri Dec 17 16:40:13 2004 From: benn at cenix-bioscience.com (Neil Benn) Date: Fri Dec 17 16:40:04 2004 Subject: [python-win32] ActiveX components with Events In-Reply-To: References: Message-ID: <41C2FDDD.2000008@cenix-bioscience.com> Hihn, Jason wrote: >I will attempt to use my psychic powers and read into this situation >more than you have told. > > >That ActiveX is coded in VB, hence the OCX. The VB is calling >form.show(). I bet (if all previous assumptiona are correct) that you >could fix the subliminal message by calling form.load() > >I will stop now before people start thinking that I am proud of knowing >VB. > > > Hello, I'm sorry but I'm having real trouble trying to get this across, please see the comment embedded in my original e-mail beneath : Sorry that was a bad explanation - the control _is_ an ActiveX exe - not an ocx - it simply brings up a form (which in actual fact I then hide immediately, I can't stop the form appearing in the first place - it has to appear for a few millisecs like a subliminal message). The component is _not_ an ocx - I don't even know (or care) what the original programming language was, I guess its C++ but it doesn't (or shouldn't) concern me. The component is an ActiveX exe which is an out of process exe - I didn't write it and I don't have the source code. I have successfully interacted with the ActiveX component using Java and Jacob (a Java/COM bridge) using the interface supplied by the manufacturer. The only reason that I'm quoting VB code is because I assumed that there would more people here who know VB than know Java/Jacob! Therefore the underlying component is trying to bring up a form, in order to give it the processor time to handle that I need to allow the OS to process the windows message (this is the bit that is written incorrectly in the ActiveX as they should be managing this themselves). The way to do this in VB is to use a method called DoEvents. The DoEvents method basically calls PeekMessage and DispatchMessage for all messages waiting on the events queue and then returns into my process. Essentially this is what pythoncom.PumpWaitingMessages does. However this still doesn't work, I cannot get events. Looking at the behavior in other code, an event is fired just before the form is shown, if this event is blocked in the EventHandkler then the ActiveX exe will hang on the completion. Thereby stopping the code which displays the form from being executed in the component ActiveX. However upon inserted the pythomcom.PumpWaitingMessages, I still cannot capture any events from this ActiveX exe. I even wrote a very very simple test case which creates an ActiveX dll with the following code : public event Event1 public sub FireEvent() RaiseEvent Event1 the python code had .>>>def class EventHandler: .>>> def Event1(self): .>>> print 'event fired' .>>>objTest = DispatchWithEvents("TestDll.cTest", EventHandler) .>>>objTest.FireEvent() This should have captured the event and displayed the test 'event fired' on the screen. Nothing happened - I know I have a correct install because the IE6 example supplied in the docs in the source file for win32\client\__init__.py works fine. If there is any other information that could help to determine my problem then please let me know. I appreciate your help - as I have managed to boil my problem down to a very simple test case then the fine details of the original ActiveX exe (__not__ an OCX) are by the by. This test case removes that element from the equation. Cheers, Neil -- Neil Benn Senior Automation Engineer Cenix BioScience BioInnovations Zentrum Tatzberg 47 D-01307 Dresden Germany Tel : +49 (0)351 4173 154 e-mail : benn@cenix-bioscience.com Cenix Website : http://www.cenix-bioscience.com From jimmy at retzlaff.com Fri Dec 17 17:30:43 2004 From: jimmy at retzlaff.com (Jimmy Retzlaff) Date: Fri Dec 17 19:10:53 2004 Subject: [python-win32] Windows process priority setting question...(cross-post) Message-ID: Ray S wrote: > Is it possible to have an app re-set its own priority, a-la task manager? > > I see that 2.4+ has the ability for sub-processes, but only on creation. > > Apparently > win32process.SetPriorityClass(handle, dwPriorityClass) > and > PyCWinThread.SetThreadPriority(priority) > allows one to change a sub while a the sub is running, but what about the > current? This should do the trick: win32process.SetPriorityClass( win32process.GetCurrentProcess(), win32process.IDLE_PRIORITY_CLASS ) For a description of the available priority classes, see: http://msdn.microsoft.com/library/en-us/dllproc/base/setpriorityclass.as p Jimmy From python at kareta.de Mon Dec 20 18:59:34 2004 From: python at kareta.de (python@kareta.de) Date: Mon Dec 20 19:10:35 2004 Subject: [python-win32] Re: remote copy wiht compress/decompress Message-ID: <1103565574.41c713066a1f4@webmail.ldc.de> Hello Jens, again thanks for your help and code examples. I think I can develop a full windows conform application with your code, Mark's book and the pipeTestService example - hope so :-). But there is one point: pythonservice.exe has to be registered once per computer and the register process fails if python is not installed on that machine. I have to install this service on a users computer without python. Normally I run Gordon McMillans Installer and ship the exe-file to the users computer. Is there a way to register the pythonservice without installing python, or run the service without register pythonservice ? regards, J?rgen ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/ From services at AndreasKrueger.de Mon Dec 20 18:50:38 2004 From: services at AndreasKrueger.de (Andreas Krueger) Date: Mon Dec 20 19:14:40 2004 Subject: [python-win32] Re: Damaged Pythonwin installation Message-ID: Hi ! No answer on the list? Same problem here: "LoadBarState failed (with win32 exception!)" Any ideas where this problem might originate from? If not: What can I do to further specify the problem? Reinstalling Python 2.3.4 and Pythonwin build 203 didn't solve the problem. thx a lot in advance! Andreas --- [python-win32] Damaged Pythonwin installation Greg Chapman glc at well.com Thu Jan 1 14:27:22 EST 2004 -------------------------------------------------------------------------------- I seem to have done something which has broken Pythonwin on one of my machines. It's using win32all build 163 and Python 2.3.2 (the OS is Windows 2000). The most immediate symptom is that things seem very sluggish inside Pythonwin. However there are other more spectacular problems. For example, I just started Pythonwin, created a new script document with the line "print 'hello'", and saved it as temp.py. I then pressed F11 twice. This first loads the debugger (very slowly) and then results in these error messages in the interactive window when the debugger attempts to step into winout.py: LoadBarState failed - LoadBarState failed (with win32 exception!) < snip traceback > win32ui: LoadFrame failed win32ui: CreateNewFrame() virtual handler (>) raised an exception TypeError: PyCTemplate::CreateNewFrame must return a PyCFrameWnd object. Whatever the error was, it had some global effects. After the error, my Windows Start Menu was hosed (it only had the four items which are normally above the top separator). Also, notepad.exe started after the error comes up without a menu bar. Everything is back to normal after a reboot. In case it's important, I had a newer version of scintilla.dll than the one which comes with Pythonwin in a directory on the system PATH (but not in python's sys.path). Several reboots ago I renamed the dll in case Pythonwin was somehow finding it instead of its own version, but that didn't seem to make any difference. I've already tried uninstalling and reinstalling win32all; unfortunately, that did not fix the problem. Anybody have any ideas on what's gone wrong here? Thanks. --- Greg Chapman From bgailer at alum.rpi.edu Mon Dec 20 20:01:57 2004 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Mon Dec 20 20:00:02 2004 Subject: [python-win32] Re: Damaged Pythonwin installation In-Reply-To: References: Message-ID: <6.1.2.0.0.20041220111840.032758f8@mail.mric.net> This is symptomatic of a long-standing unsolved Pythonwin problem in which Pythonwin keeps adding toobar entries to the registry until it chokes. Several outstanding bug reports comment on this. Unfortunately no one knows how to fix the problem. Here's a Python program to clean up the registry: import win32api import win32con subKey = r'Software\Python 2.3\Python for Win32' #HKEY_CURRENT_USER\Software\Python 2.3\Python for Win32\ToolbarDebugging-Bar0 k = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER,subKey,0,win32con.KEY_ALL_ACCESS) nsubkeys,nvalues,timeval = win32api.RegQueryInfoKey(k) keys = [] for i in range(nsubkeys): s = win32api.RegEnumKey(k,i) if (s.startswith('ToolbarDefault-Bar') or s.startswith('ToolbarDebugging-Bar')): keys.append(s) for i,key in enumerate(keys): subKey2 = subKey + '\\' + key print i,':', subKey2 win32api.RegDeleteKey(win32con.HKEY_CURRENT_USER,subKey2) if i>99999: break k.Close() print len(keys),"deleted." Do NOT run this from within Python win. Use a command prompt or another IDE. Bob Gailer bgailer@alum.rpi.edu 303 442 2625 home 720 938 2625 cell From mhammond at skippinet.com.au Mon Dec 20 23:45:44 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon Dec 20 23:45:48 2004 Subject: [python-win32] Re: remote copy wiht compress/decompress In-Reply-To: <1103565574.41c713066a1f4@webmail.ldc.de> Message-ID: <25ef01c4e6e5$a4dc3250$0300a8c0@enfoldsystems.local> > has to be registered once per computer and the register > process fails if python > is not installed on that machine. I have to install this > service on a users > computer without python. Normally I run Gordon McMillans > Installer and ship the > exe-file to the users computer. Is there a way to register > the pythonservice > without installing python, or run the service without > register pythonservice ? pythonservice.exe is like python.exe - it still relies on python23.dll and the rest of the python library to actually work. In the same way that you can't install just python.exe on someones machine and have it run Python scripts, you can't do it for pythonservice.exe I'm not sure about installer, but py2exe does allow you to package stand-alone services that don't require Python to be pre-installed. Mark From sseefeld at art.ca Tue Dec 21 16:58:49 2004 From: sseefeld at art.ca (Stefan Seefeld) Date: Tue Dec 21 17:17:30 2004 Subject: [python-win32] w32process documentation Message-ID: <20DCDD8F0FCED411AC4D001083CF504502380D41@MTL-EXCHANGE> Hello, I'm looking for documentation for the win32process module. The online docs don't seem to contain anything about it. Specifically, I'm looking for information concerning the 'CreateProcess' call. I'm debugging an application where a call to 'CreateProcess' generates an error about the file not being found. As the path is set in the system-wide environment, I'm wondering whether that environment is actually used during the call (I'm passing 'None' to the environment argument to CreateProcess()). Thanks for your help, Stefan From kontakt at michaelstather.com Tue Dec 21 19:22:54 2004 From: kontakt at michaelstather.com (Michael Stather) Date: Tue Dec 21 19:22:57 2004 Subject: [python-win32] 2.4 Installer not working Message-ID: <20041221181026.4D5A0518062@h8391.serverkompetenz.net> I?ve tried installing Python 2.4 on my development system, which is winxp pro with all updates installed. No other installer (neither MSI-based ones) has made trouble, but when I try to install python 2.4 after setting the target directory there?s an exception in the installer script. I?ve stepped into the MSVC .NET debugger: I get "VBScript runtime error: ActiveX component can?t create object: "Scripting.FileSystemObject"" in this line: Set FSO = CreateObject("Scripting.FileSystemObject") What can I do about this. I?m sure this has nothing to do with my system spec, because everything else (also installers) works like it should. Thanks for your help! Michael Stather ---------------------------------------- Ich verwende die kostenlose Version von SPAMfighter, die bis jetzt 1722 Spammails entfernt hat. Fr private Anwender ist SPAMfighter vllig kostenlos! Jetzt gratis testen: www.SPAMfighter.com From ai2009 at yandex.ru Tue Dec 21 19:45:27 2004 From: ai2009 at yandex.ru (Andrey Ivanov) Date: Tue Dec 21 19:39:02 2004 Subject: [python-win32] w32process documentation In-Reply-To: <20DCDD8F0FCED411AC4D001083CF504502380D41@MTL-EXCHANGE> References: <20DCDD8F0FCED411AC4D001083CF504502380D41@MTL-EXCHANGE> Message-ID: <1003969824.20041221214527@yandex.ru> Hello Stefan, Tuesday, December 21, 2004, 6:58:49 PM, you wrote: SS> Hello, SS> I'm looking for documentation for the win32process module. The online docs SS> don't seem to contain anything about it. Specifically, I'm looking for SS> information concerning the 'CreateProcess' call. SS> I'm debugging an application where a call to 'CreateProcess' generates SS> an error about the file not being found. As the path is set in the SS> system-wide SS> environment, I'm wondering whether that environment is actually used during SS> the call SS> (I'm passing 'None' to the environment argument to CreateProcess()). SS> Thanks for your help, SS> Stefan SS> _______________________________________________ SS> Python-win32 mailing list SS> Python-win32@python.org SS> http://mail.python.org/mailman/listinfo/python-win32 And how do you pass an executable name? CreateProcess() has two executable name related parameters (appName, commandLine) and Windows uses different search strategy for each one of them. If you want Windows to search for your executable using PATH you should use None instead of appName and pass the name of executable in commandLine parameter. As to environment parameter, you should always set it to None, unless you want to completely redefine the environment. By the way, you shouldn't count on pywin32 help. They don't aim to reproduce MSDN. So when in doubt use Microsoft's help. It is clear and well written. -- Andrey From jimmy at retzlaff.com Tue Dec 21 18:02:50 2004 From: jimmy at retzlaff.com (Jimmy Retzlaff) Date: Tue Dec 21 20:27:34 2004 Subject: [python-win32] w32process documentation Message-ID: Stefan Seefeld wrote: > I'm looking for documentation for the win32process module. The online docs > don't seem to contain anything about it. Specifically, I'm looking for > information concerning the 'CreateProcess' call. > I'm debugging an application where a call to 'CreateProcess' generates > an error about the file not being found. As the path is set in the > system-wide > environment, I'm wondering whether that environment is actually used > during > the call > (I'm passing 'None' to the environment argument to CreateProcess()). These functions are typically very thin wrappers around the corresponding Win32 API so you can usually use Microsoft's documentation to answer questions like these. In this case it would appear that if you specify the executable name in appName then the search path is not used. If, instead, you specify it in the commandLine parameter the search path is used. The details are at: http://msdn.microsoft.com/library/en-us/dllproc/base/createprocess.asp Does this explain what you are observing? Jimmy From ai2009 at yandex.ru Tue Dec 21 20:04:03 2004 From: ai2009 at yandex.ru (Andrey Ivanov) Date: Tue Dec 21 20:46:08 2004 Subject: [python-win32] 2.4 Installer not working In-Reply-To: <20041221181026.4D5A0518062@h8391.serverkompetenz.net> References: <20041221181026.4D5A0518062@h8391.serverkompetenz.net> Message-ID: <1395844803.20041221220403@yandex.ru> Hello Michael, Tuesday, December 21, 2004, 9:22:54 PM, you wrote: MS> I get "VBScript runtime error: ActiveX component can?t create object: MS> "Scripting.FileSystemObject"" MS> in this line: MS> Set FSO = CreateObject("Scripting.FileSystemObject") This is very strange. It seems that Windows Scripting Host on your machine is somehow damaged. You can try running: regsvr32 c:\windows\system32\scrrun.dll It might bring the FileSystemObject back, but I'm not sure. A much better way would be to reinstall Scripting host, but I don't know how to do that. -- Andrey From hongqn at gmail.com Wed Dec 22 12:06:07 2004 From: hongqn at gmail.com (Qiangning Hong) Date: Wed Dec 22 12:08:29 2004 Subject: [python-win32] how to set master volume and record volume? Message-ID: in windows 2000 pro, how can i write a script to set the master volume and record volume to max? From niki at vintech.bg Wed Dec 22 12:14:00 2004 From: niki at vintech.bg (Niki Spahiev) Date: Wed Dec 22 12:14:09 2004 Subject: [python-win32] Re: Damaged Pythonwin installation In-Reply-To: <6.1.2.0.0.20041220111840.032758f8@mail.mric.net> References: <6.1.2.0.0.20041220111840.032758f8@mail.mric.net> Message-ID: <41C956F8.8000202@vintech.bg> Bob Gailer wrote: > This is symptomatic of a long-standing unsolved Pythonwin problem in > which Pythonwin keeps adding toobar entries to the registry until it > chokes. This i have other programs (e.g. WinCVS) with same problem. Maybe its bug in MFC? Niki Spahiev From ian at kirbyfooty.com Tue Dec 28 02:12:00 2004 From: ian at kirbyfooty.com (Ian Cook) Date: Tue Dec 28 02:12:07 2004 Subject: [python-win32] How to send emails using Python via the default email client (eg Outlook Express) Message-ID: <000c01c4ec7a$3d74da50$0301010a@ianscomputer> Hi Everyone, Recently I found out how to send emails using Python via the default email client (eg Outlook Express) A suggestion was made to post a message here. The script will allow multiple recipients and multiple attachements. Syntax simplemapi.SendMail(recipient,subject,body,attachment) where: recipient - string: address to send to (multiple address sperated with a semicolin) subject - string: subject header body - string: message text attach - string: files to attach (multiple attachments sperated with a semicolin) Example usage import simplemapi simplemapi.SendMail("to1address@server.com;to2address@server.com","My Subject","My message body","c:\attachment1.txt;c:\attachment2") I hope it is of some help to others. You can download the script from http://www.kirbyfooty.com/simplemapi.py Kind regards Ian Cook www.kirbyfooty.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041228/5b527761/attachment.htm From luc.saffre at gmx.net Tue Dec 28 11:40:09 2004 From: luc.saffre at gmx.net (Luc Saffre) Date: Tue Dec 28 11:40:15 2004 Subject: [python-win32] How to send emails using Python via the default email client (eg Outlook Express) In-Reply-To: <000c01c4ec7a$3d74da50$0301010a@ianscomputer> References: <000c01c4ec7a$3d74da50$0301010a@ianscomputer> Message-ID: <41D13809.3070204@gmx.net> Ian, thanks for posting simplemapi.py. I can report that it works. I use Thunderbird as mail client. Thunderbird notifies me as follows about the MAPI request: Another application is attempting to send mail using your user profile. Are you sure you wxant to send mail? [x] Warn me whenever other applications try to send mail from me. TB does not let me edit the file before sending it (a feature that could be nice). Anyway I didn't yet find documentation about how to configure TB's behaviour with MAPI... Until now I solved the same problem with a different approach:: # source: # http://lsaffre.dyndns.org/websvn/filedetails.php?repname=lino\ # &path=%2Ftrunk%2Fsrc%2Flino%2Ftimtools%2Fmail.py&rev=0&sc=0 import urllib import webbrowser def mailto_url(to=None,subject=None,body=None,cc=None): """ encodes the content as a mailto link as described on http://www.faqs.org/rfcs/rfc2368.html """ url = "mailto:" + urllib.quote(to.strip(),"@,") sep = "?" if cc: url+= sep + "cc=" + urllib.quote(cc,"@,") sep = "&" if subject: url+= sep + "subject=" + urllib.quote(subject,"") sep = "&" if body: # Also note that line breaks in the body of a message MUST be # encoded with "%0D%0A". (RFC 2368) body="\r\n".join(body.splitlines()) url+= sep + "body=" + urllib.quote(body,"") sep = "&" return url def openmail(msg): url = mailto_url(msg.get('to'),msg.get("subject"),msg.get_payload()) webbrowser.open(url,new=1) I added your module to my own project "Lino" which I publish under the GPL. Here is a link to the SVN repository: http://lsaffre.dyndns.org/websvn/filedetails.php?repname=lino&path=%2Ftrunk%2Fsrc%2Fforum%2Fsimplemapi.py&rev=0&sc=0 Please let me know if you have a copyright problem with this. Luc Saffre On 28.12.2004 03:12, Ian Cook wrote: > > Hi Everyone, > Recently I found out how to send emails using Python via the default > email client (eg Outlook Express) > A suggestion was made to post a message here. > > The script will allow multiple recipients and multiple attachements. > > > *Syntax* > simplemapi.SendMail(recipient,subject,body,attachment) > > where: > recipient - string: address to send to (multiple address sperated > with a semicolin) > subject - string: subject header > body - string: message text > attach - string: files to attach (multiple attachments sperated with > a semicolin) > > *Example usage* > import simplemapi > simplemapi.SendMail("to1address@server.com;to2address@server.com","My > Subject","My message body","c:\attachment1.txt;c:\attachment2") > > > I hope it is of some help to others. > > You can download the script from http://www.kirbyfooty.com/simplemapi.py > > > Kind regards > Ian Cook > www.kirbyfooty.com > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From luc.saffre at gmx.net Tue Dec 28 12:17:14 2004 From: luc.saffre at gmx.net (Luc Saffre) Date: Tue Dec 28 12:17:19 2004 Subject: [python-win32] Selecting a font when printing with CDC.TextOut() Message-ID: <41D140BA.5000405@gmx.net> Hello, how can I select a font to use when printing to a PrinterDC using TextOut()? I couldn't find any answer from the documentation. Here is a simplified context: import win32ui import win32con dc = win32ui.CreateDC() dc.CreatePrinterDC(printerName) dc.StartDoc("hello") dc.SetMapMode(win32con.MM_TWIPS) dc.StartPage() dc.TextOut(200,-200,"Hello, World") dc.EndPage() dc.EndDoc() TIA for any hints! Luc From jens.jorgensen at tallan.com Tue Dec 28 16:06:55 2004 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Tue Dec 28 16:07:05 2004 Subject: [python-win32] Selecting a font when printing with CDC.TextOut() In-Reply-To: <41D140BA.5000405@gmx.net> References: <41D140BA.5000405@gmx.net> Message-ID: <41D1768F.6080302@tallan.com> As is true of win32* module use in general there is no substute for the msdn library documentation. Check out this documentation page to see an example of TextOut usage: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cdc.3a3a.beginpath.asp Luc Saffre wrote: > Hello, > > how can I select a font to use when printing to a PrinterDC using > TextOut()? I couldn't find any answer from the documentation. > > Here is a simplified context: > > import win32ui > import win32con > dc = win32ui.CreateDC() > dc.CreatePrinterDC(printerName) > dc.StartDoc("hello") > dc.SetMapMode(win32con.MM_TWIPS) > dc.StartPage() > dc.TextOut(200,-200,"Hello, World") > dc.EndPage() > dc.EndDoc() > > TIA for any hints! > Luc > _______________________________________________ > 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 steven.bethard at gmail.com Wed Dec 29 23:05:28 2004 From: steven.bethard at gmail.com (Steven Bethard) Date: Wed Dec 29 23:05:35 2004 Subject: [python-win32] PythonWin and calling functions across threads Message-ID: I posted this originally to the python-list[1], but then discovered that my problem only occurs in PythonWin. Any help would be appreciated: [1] http://mail.python.org/pipermail/python-list/2004-December/257666.html -------- Original Message -------- Subject: calling functions across threads Date: Wed, 29 Dec 2004 17:35:41 GMT From: Steven Bethard Newsgroups: comp.lang.python I'm playing around with some threading stuff right now, and I'm having a little trouble calling a function from one thread that affects another. Here's my setup: py> import os, threading, time py> def write(file_in, input_lines): ... for line in input_lines: ... time.sleep(0.5) ... file_in.write(line) ... file_in.flush() ... file_in.close() ... py> def read(file_out, output_list): ... while True: ... line = file_out.readline() ... if not line: ... break ... output_list.append(line) ... py> def runthreads(lst): ... file_in, file_out, file_err = os.popen3('cat') ... write_thread = threading.Thread( ... target=write, args=(file_in, ... ['%s\n' % x for x in range(10)])) ... read_thread = threading.Thread(target=read, ... args=(file_out, lst)) ... write_thread.start() ... read_thread.start() ... write_thread.join() ... read_thread.join() ... Basically, I start one thread to read and one thread to write (from a os.pipe). This all works fine for me: py> lst = [] py> runthreads(lst) py> lst ['0\n', '1\n', '2\n', '3\n', '4\n', '5\n', '6\n', '7\n', '8\n', '9\n'] I run into a problem though when I try to call an update method every time I read a line: py> class updatinglist(list): ... def __init__(self, updater): ... super(updatinglist, self).__init__() ... self.updater = updater ... def append(self, item): ... super(updatinglist, self).append(item) ... self.updater(len(self)) ... py> def update(i): ... print i ... py> lst = updatinglist(update) py> runthreads(lst) 1 2 3 4 5 6 7 8 9 10 py> lst ['0\n', '1\n', '2\n', '3\n', '4\n', '5\n', '6\n', '7\n', '8\n', '9\n'] I get the correct output, but if you run this yourself, you'll see that the numbers 1 through 10 aren't printed in sync with the writes (i.e. every half second); they're all printed at the end. Could someone explain to me why this happens, and how (if possible) I can get the numbers printed in sync with the appends to the list? Thanks, Steve From mhammond at skippinet.com.au Thu Dec 30 02:22:23 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Dec 30 02:22:22 2004 Subject: [python-win32] PythonWin and calling functions across threads In-Reply-To: Message-ID: <49ba01c4ee0e$046afdd0$0300a8c0@enfoldsystems.local> Internally, Pythonwin uses a queue for all sys.stdout writing, to ensure the actual window update only ever happens on the main thread (which is a requirement of Windows). To get a "smooth" effect, Pythonwin queues output until a newline is seen. This is probably the reason. To change this behaviour, open pywin\framework\winout.py, and find the line: def __init__(self, title=None, defSize=None, queueing = flags.WQ_LINE ... Change queueing to flags.WQ_NONE - this should dump output as it arrives, but will often make the output appear "chunky". I'd (obviously) be open to patches that exposed this via the UI, if it was felt necessary. Mark. > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of Steven Bethard > Sent: Thursday, 30 December 2004 9:05 AM > To: python-win32@python.org > Subject: [python-win32] PythonWin and calling functions across threads > > > I posted this originally to the python-list[1], but then discovered > that my problem only occurs in PythonWin. Any help would be > appreciated: > > [1] > http://mail.python.org/pipermail/python-list/2004-December/257666.html > -------- Original Message -------- > Subject: calling functions across threads > Date: Wed, 29 Dec 2004 17:35:41 GMT > From: Steven Bethard > Newsgroups: comp.lang.python > > I'm playing around with some threading stuff right now, and > I'm having a > little trouble calling a function from one thread that > affects another. > Here's my setup: > > py> import os, threading, time > py> def write(file_in, input_lines): > ... for line in input_lines: > ... time.sleep(0.5) > ... file_in.write(line) > ... file_in.flush() > ... file_in.close() > ... > py> def read(file_out, output_list): > ... while True: > ... line = file_out.readline() > ... if not line: > ... break > ... output_list.append(line) > ... > py> def runthreads(lst): > ... file_in, file_out, file_err = os.popen3('cat') > ... write_thread = threading.Thread( > ... target=write, args=(file_in, > ... ['%s\n' % x for x in range(10)])) > ... read_thread = threading.Thread(target=read, > ... args=(file_out, lst)) > ... write_thread.start() > ... read_thread.start() > ... write_thread.join() > ... read_thread.join() > ... > > Basically, I start one thread to read and one thread to write (from a > os.pipe). This all works fine for me: > > py> lst = [] > py> runthreads(lst) > py> lst > ['0\n', '1\n', '2\n', '3\n', '4\n', '5\n', '6\n', '7\n', '8\n', '9\n'] > > I run into a problem though when I try to call an update method every > time I read a line: > > py> class updatinglist(list): > ... def __init__(self, updater): > ... super(updatinglist, self).__init__() > ... self.updater = updater > ... def append(self, item): > ... super(updatinglist, self).append(item) > ... self.updater(len(self)) > ... > py> def update(i): > ... print i > ... > py> lst = updatinglist(update) > py> runthreads(lst) > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10 > py> lst > ['0\n', '1\n', '2\n', '3\n', '4\n', '5\n', '6\n', '7\n', '8\n', '9\n'] > > I get the correct output, but if you run this yourself, > you'll see that > the numbers 1 through 10 aren't printed in sync with the writes (i.e. > every half second); they're all printed at the end. Could someone > explain to me why this happens, and how (if possible) I can get the > numbers printed in sync with the appends to the list? > > Thanks, > > Steve > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32