From greglandrum at mindspring.com Tue Jun 1 10:24:15 2004 From: greglandrum at mindspring.com (greg Landrum) Date: Tue Jun 1 10:35:39 2004 Subject: [python-win32] Problems with automation in newer versions ofwin32all In-Reply-To: <10d301c44626$dde83220$0200a8c0@eden> References: <5.1.0.14.2.20040528142400.045433e0@mail.earthlink.net> Message-ID: <5.1.0.14.2.20040601072208.02fe9788@mail.mindspring.com> Mark, At 02:17 AM 5/30/2004, Mark Hammond wrote: >My guess is that the default params are causing some problems. Try >explicitly passing each param, passing either pythoncom.Missing, or >pythoncom.Empty, for the params you would otherwise exclude. Using pythoncom.Missing cleared the problem up, everything works now. Thank you, thank you, thank you! -greg From Franz.Steinhaeusler at amatic.com Wed Jun 2 11:45:59 2004 From: Franz.Steinhaeusler at amatic.com (Franz Steinhaeusler) Date: Wed Jun 2 12:07:47 2004 Subject: [python-win32] Explorer like right mouse click context menue Message-ID: Hello, I want to enhance my little wxpython-filemanager with a shell context menu. Can anybody please advise, how and/or if it is possible to add to a given File (Win XP) an explorer file context menue? Is it possible to manage this with python-win, or have I to play around with ctypes and the windows system dlls? If nothing is serviceable; could this be achieved with embedding C-Code? Thank you for any help! ( http://sourceforge.net/projects/wxpyatol/ ) -- Franz Steinh?usler From kf7xm at netscape.net Wed Jun 2 18:16:21 2004 From: kf7xm at netscape.net (Vernon Cole) Date: Wed Jun 2 18:16:37 2004 Subject: [python-win32] datetime.datetime.now(tz=WHAT?????) Message-ID: <40BE51B5.6060704@netscape.net> I suppose that there is an easy answer to this question... if I only could find the correct document to read. Environment: Python 2.3.4 on Windows2000 Application: Trying to construct a date string for use by smtplib.sendmail() ... It should look like: "27 Aug 2020 09:32:31 MDT" ... or "27 Aug 2020 09:32:31 +0700" What I have tried (latest vain attempt): import datetime date = datetime.datetime.strftime( datetime.datetime.now(), '%d %b %Y %H:%M:%S %z') print date The date prints WITHOUT TIME ZONE -- as documented. In order to print the timezone I must provide an object of type tzinfo to supply to datetime.datetime.now(tz= ????) . Questions: 1) I could hard code the timezone, but the documents show only use of tz=None, which is the not helpful. How do I create an instance of a tzinfo for a specific time zone? 2) Windows already knows my timezone. How do I get it so that I can plug it in? 3) Am I trying a completly wrong approach and should be using some other module? ---------- Vernon From jens.jorgensen at tallan.com Wed Jun 2 18:59:19 2004 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Wed Jun 2 18:59:28 2004 Subject: [python-win32] datetime.datetime.now(tz=WHAT?????) In-Reply-To: <40BE51B5.6060704@netscape.net> References: <40BE51B5.6060704@netscape.net> Message-ID: <40BE5BC7.4000801@tallan.com> My first question would be: do you really need the tz? Why not just put in the UTC time and put +0000 in for the timezone info. In fact, documentation under the built-in time module demonstrates: > Here is an example, a format for dates compatible with that specified > in the RFC 2822 Internet email > standard. ^6.1 <#foot25196> > >>>> from time import gmtime, strftime >>>> strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()) >'Thu, 28 Jun 2001 14:17:15 +0000' > > > Additional directives may be supported on certain platforms, but only > the ones listed here have a meaning standardized by ANSI C. > Vernon Cole wrote: > I suppose that there is an easy answer to this question... if I only > could find the correct document to read. > Environment: Python 2.3.4 on Windows2000 > Application: Trying to construct a date string for use by > smtplib.sendmail() > ... It should look like: "27 Aug 2020 09:32:31 MDT" > ... or "27 Aug 2020 09:32:31 +0700" > What I have tried (latest vain attempt): > import datetime > date = datetime.datetime.strftime( > datetime.datetime.now(), > '%d %b %Y %H:%M:%S %z') > print date > > The date prints WITHOUT TIME ZONE -- as documented. > In order to print the timezone I must provide an object of type tzinfo > to supply to > datetime.datetime.now(tz= ????) . > > Questions: 1) I could hard code the timezone, but the documents > show only use of tz=None, which is the not helpful. How do I create > an instance of a tzinfo for a specific time zone? > > 2) Windows already knows my timezone. How do I get it so that I > can plug it in? > > 3) Am I trying a completly wrong approach and should be using some > other module? > > ---------- > Vernon > > > > _______________________________________________ > 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 tim.golden at viacom-outdoor.co.uk Thu Jun 3 03:41:35 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu Jun 3 03:44:03 2004 Subject: [python-win32] Explorer like right mouse click context menue Message-ID: | I want to enhance my little wxpython-filemanager with | a shell context menu. | | Can anybody please advise, how and/or if it is possible | to add to a given File (Win XP) an explorer file context menue? Bit of a two-part response, really. First, it *is* possible, as of recent versions of pywin32, to add shell context menus. It's a bit messy, but there are some examples somewhere in the pywin32 distribution, although for the life of me I can't remember where. Secondly, I had a quick look at wxpyatol and it looks to me rather as though you just want to trap right-click events on your file windows, which is different from going to the lengths of telling the operating system to ask you code for extra menus whenever you right click on something in an explorer window. Have I misunderstood? Or are you really just asking: how do I manage right-click menus under a wxPython Frame? TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. 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 jpersson1 at yahoo.com Thu Jun 3 07:11:27 2004 From: jpersson1 at yahoo.com (Jan Persson) Date: Thu Jun 3 07:11:32 2004 Subject: [python-win32] Explorer like right mouse click context menue In-Reply-To: Message-ID: <20040603111127.80051.qmail@web61307.mail.yahoo.com> Hi, --- Tim Golden wrote: > First, it *is* possible, as of recent versions of pywin32, to > add shell context menus. It's a bit messy, but there are some > examples somewhere in the pywin32 distribution, although for > the life of me I can't remember where. On my machine they are installed in c:\Python23\Lib\site-packages\win32comext\shell\demos Best Regards //Jan Persson __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ From Franz.Steinhaeusler at amatic.com Thu Jun 3 06:13:13 2004 From: Franz.Steinhaeusler at amatic.com (Franz Steinhaeusler) Date: Thu Jun 3 09:57:32 2004 Subject: Antw: RE: [python-win32] Explorer like right mouse click context menue Message-ID: >>> Tim Golden 06/03 9:41 >>> >| I want to enhance my little wxpython-filemanager with >| a shell context menu. >| >| Can anybody please advise, how and/or if it is possible >| to add to a given File (Win XP) an explorer file context menue? >Bit of a two-part response, really. Hello Tim, thank you for your response. >First, it *is* possible, as of recent versions of pywin32, to >add shell context menus. It's a bit messy, but there are some >examples somewhere in the pywin32 distribution, although for >the life of me I can't remember where. I'm aware, that this wouldn't be an easy task. I found some samples with google (but all in C or C++, and it seems to be rather complicated). Also I didn't find for example following function in pywin, which are essential for building the shell context menu: IContextMenu2 and IContextMenu3 ,... Finally I found maybe something useful: PyIContextMenu.QueryContextMenu in pywin32.chm PyIContextMenu Object but how to apply this (I saw no example code)? >Secondly, I had a quick look at wxpyatol and it looks to me >rather as though you just want to trap right-click events on >your file windows. No, it's not the case. >which is different from going to the lengths >of telling the operating system to ask you code for extra menus >whenever you right click on something in an explorer window. >Have I misunderstood? In short: I want to have in my app the same context menu, as I get, when i right-click a given file in explorer. >Or are you really just asking: how do I >manage right-click menus under a wxPython Frame? No, this should not be the problem. best regards and sorry for my english, -- Franz Steinh?usler From mli at deform.com Thu Jun 3 10:18:50 2004 From: mli at deform.com (Michael Li) Date: Thu Jun 3 10:19:29 2004 Subject: [python-win32] how to run python in background on Windows ? Message-ID: <40BF334A.1030801@deform.com> Hi, I was trying to run my python program as a server in background on Windows, but I failed. On Unix, I can do : % python myscript.py & On Windows, I use Windows' service to start/stop the python. In the same login session, I got success, I can see python program from TaskManager. but when I log out and log in again, my python server is gone, I can not see python program from TaskManager. Is there anyone there knowing how to run python in background as Windows' service ? best regards. Michael Li From tim.golden at viacom-outdoor.co.uk Thu Jun 3 10:35:18 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu Jun 3 10:37:41 2004 Subject: Antw: RE: [python-win32] Explorer like right mouse click cont ext menue Message-ID: | >>> Tim Golden 06/03 9:41 >>> | >| I want to enhance my little wxpython-filemanager with | >| a shell context menu. | >| | >| Can anybody please advise, how and/or if it is possible | >| to add to a given File (Win XP) an explorer file context menue? | | Also I didn't find for example following function in pywin, which | are essential for building the shell context menu: | IContextMenu2 and IContextMenu3 ,... | | Finally I found maybe something useful: | PyIContextMenu.QueryContextMenu in pywin32.chm | PyIContextMenu Object | but how to apply this (I saw no example code)? It's been pointed out that sample code is in: c:\python22\lib\site-packages\win32comext\shell\demos but I'm hoping that someone else will chip in and give some better explanation. | In short: I want to have in my app the same context menu, as | I get, when i right-click a given file in explorer. My little expertise on this matter has already run dry, but just to clarify for anyone else who's hopefully going to provide suggestions, is the following what you want to do? Within your file manager (where right-clicks are managed by you and not by the Shell) you want to mimic the Shell-based right-click by interrogating the shell context menu for the given file type and providing the same set of options, so a .ZIP file, for example, might show various WinZip options, while another file might show Open or Edit. Over to the many people who know more than I do about this topic... TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. 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 twhittin at wharton.upenn.edu Thu Jun 3 10:38:53 2004 From: twhittin at wharton.upenn.edu (Whittingham, Thomas) Date: Thu Jun 3 10:38:57 2004 Subject: [python-win32] how to run python in background on Windows ? Message-ID: <0DE40D17E4B6D34F9CB8CB444DECF6330223B596@COURIER.wharton.upenn.edu> This may be obvious but did you set up the service to start automatically? In the same dialog boxes that let you start/stop Windows services you can specify whether a service should run at startup. ~Tom Tom Whittingham Data Analyst Treatment Research Center Whittingham_T@mail.trc.upenn.edu 215-222-3200 x143 (work) 215-386-5106 (fax @ work) 267-456-6802 (cell/home) "For You so loved the unlovable That You gave the Ineffable That who so believes the unbelievable Will gain the unattainable." -- "There You Go" lyrics, by Caedmon's Call -----Original Message----- From: Michael Li [mailto:mli@deform.com] Sent: Thursday, June 03, 2004 10:19 AM To: python-win32@python.org Subject: [python-win32] how to run python in background on Windows ? Hi, I was trying to run my python program as a server in background on Windows, but I failed. On Unix, I can do : % python myscript.py & On Windows, I use Windows' service to start/stop the python. In the same login session, I got success, I can see python program from TaskManager. but when I log out and log in again, my python server is gone, I can not see python program from TaskManager. Is there anyone there knowing how to run python in background as Windows' service ? best regards. Michael Li _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From mli at deform.com Thu Jun 3 11:13:37 2004 From: mli at deform.com (Michael Li) Date: Thu Jun 3 11:17:58 2004 Subject: [python-win32] how to run python in background on Windows ? In-Reply-To: <0DE40D17E4B6D34F9CB8CB444DECF6330223B596@COURIER.wharton.upenn.edu> References: <0DE40D17E4B6D34F9CB8CB444DECF6330223B596@COURIER.wharton.upenn.edu> Message-ID: <40BF4021.2080406@deform.com> Hi, Tom Thank you very much for your reply. This is not a "automatically startup" issue. I can start/stop python by using of Windows control program in the same login session, but when I logout and login again, the python service is gone. I have to go to control panel to start again. Do you know that is there a way to run python as a service ? Whittingham, Thomas wrote: > This may be obvious but did you set up the service to start > automatically? In the same dialog boxes that let you start/stop Windows > services you can specify whether a service should run at startup. > > ~Tom > > Tom Whittingham > Data Analyst > Treatment Research Center > Whittingham_T@mail.trc.upenn.edu > 215-222-3200 x143 (work) > 215-386-5106 (fax @ work) > 267-456-6802 (cell/home) > > "For You so loved the unlovable > That You gave the Ineffable > That who so believes the unbelievable > Will gain the unattainable." > > -- "There You Go" lyrics, by Caedmon's Call > > -----Original Message----- > From: Michael Li [mailto:mli@deform.com] > Sent: Thursday, June 03, 2004 10:19 AM > To: python-win32@python.org > Subject: [python-win32] how to run python in background on Windows ? > > Hi, > > I was trying to run my python program as a server in background > on Windows, but I failed. > > On Unix, I can do : > % python myscript.py & > > On Windows, I use Windows' service to start/stop > the python. In the same login session, I got success, > I can see python program from TaskManager. > but when I log out and log in again, my python server > is gone, I can not see python program from TaskManager. > > Is there anyone there knowing how to run python > in background as Windows' service ? > > best regards. > Michael Li > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From bgailer at alum.rpi.edu Thu Jun 3 15:29:32 2004 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Thu Jun 3 15:27:28 2004 Subject: [python-win32] how to run python in background on Windows ? In-Reply-To: <40BF334A.1030801@deform.com> References: <40BF334A.1030801@deform.com> Message-ID: <6.1.0.6.0.20040603132751.026e6798@mail.mric.net> At 08:18 AM 6/3/2004, Michael Li wrote: >[snip] >Is there anyone there knowing how to run python in background as Windows' >service ? Another option is to run it as a Scheduled Task. This is a lot easier than creating a service, and has most of the benefits. Bob Gailer bgailer@alum.rpi.edu 303 442 2625 home 720 938 2625 cell From Jim.Vickroy at noaa.gov Fri Jun 4 12:09:07 2004 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Jun 4 12:09:15 2004 Subject: [python-win32] how to run python in background on Windows ? In-Reply-To: <40BF4021.2080406@deform.com> Message-ID: Hi Michael, Could you post a short sample script that demonstrates the behavior. I have several Python scripts running as MS Windows Services 24x7 on machines where no one is logged in and I have not seen this behavior. What version of Windows are you using? -- jv -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org]On Behalf Of Michael Li Sent: Thursday, June 03, 2004 9:14 AM To: python-win32@python.org Subject: Re: [python-win32] how to run python in background on Windows ? Hi, Tom Thank you very much for your reply. This is not a "automatically startup" issue. I can start/stop python by using of Windows control program in the same login session, but when I logout and login again, the python service is gone. I have to go to control panel to start again. Do you know that is there a way to run python as a service ? Whittingham, Thomas wrote: > This may be obvious but did you set up the service to start > automatically? In the same dialog boxes that let you start/stop Windows > services you can specify whether a service should run at startup. > > ~Tom > > Tom Whittingham > Data Analyst > Treatment Research Center > Whittingham_T@mail.trc.upenn.edu > 215-222-3200 x143 (work) > 215-386-5106 (fax @ work) > 267-456-6802 (cell/home) > > "For You so loved the unlovable > That You gave the Ineffable > That who so believes the unbelievable > Will gain the unattainable." > > -- "There You Go" lyrics, by Caedmon's Call > > -----Original Message----- > From: Michael Li [mailto:mli@deform.com] > Sent: Thursday, June 03, 2004 10:19 AM > To: python-win32@python.org > Subject: [python-win32] how to run python in background on Windows ? > > Hi, > > I was trying to run my python program as a server in background > on Windows, but I failed. > > On Unix, I can do : > % python myscript.py & > > On Windows, I use Windows' service to start/stop > the python. In the same login session, I got success, > I can see python program from TaskManager. > but when I log out and log in again, my python server > is gone, I can not see python program from TaskManager. > > Is there anyone there knowing how to run python > in background as Windows' service ? > > best regards. > Michael Li > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From lbates at syscononline.com Fri Jun 4 13:01:24 2004 From: lbates at syscononline.com (Larry Bates) Date: Fri Jun 4 13:01:32 2004 Subject: [python-win32] Re: how to run python in background on Windows ? In-Reply-To: <200406041602.i54G2wYA008773@host9.apollohosting.com> Message-ID: <00a501c44a55$91e758f0$5d00a8c0@LABWXP> >[snip] >Is there anyone there knowing how to run python in background as Windows' >service ? You can write an NT Service that runs all the time in the background and sleeps for predetermined intervals then wakes up and does something. This program never exits unless you stop the service. This is good for things that need to be running all the time to take action when something happens. Services are somewhat hard to write, but are more efficient if startup cost of the program is high and/or the times between when you wish to check are short. An alternative method would be to schedule jobs in the Task Scheduler. If you schedule jobs to close together, you can run into the problem of the first job not completing before the second one starts. NT services run to completion, then sleeps for a predetermined number of milliseconds so overlap is not a problem and the sleep mechanism doesn't tie up the CPU. If you want to learn about writing Python services you should get a copy of Mark Hammond's Python Programming on Win32. It has several examples that helped me a lot. HTH, Larry Bates Syscon, Inc. From mli at deform.com Fri Jun 4 13:25:10 2004 From: mli at deform.com (Michael Li) Date: Fri Jun 4 13:25:23 2004 Subject: [python-win32] how to run python in background on Windows ? In-Reply-To: References: Message-ID: <40C0B076.40806@deform.com> Hi, Jim: Thank you very much. My scripts are little bit longer, it's not easy to post here. I just want to put this into background to run 24x7 : python myscript.py In Unix, it's very easy: % python myscript.py & In Windows, I wrote myinstall.cpp, myrun.cpp. myrun.cpp is a small program just following the pattern of Windows service program. "myinstall" will install the "myrun.exe" service into Windows service control manager. From Control Panel->Service, when I click start button of myservice, it will start python. I can see python is running from Task Manager. When I log out and log in again, the python is gone. I can see myrun.exe is still there from Task Manager. I use Windows XP Home Edition. Does this matter ? I have a pure Windows program running as a service without any problems. Also I got two strange thing: 1. I have to use my login account to start python. After installation, I saw that "Log On" of my service is "Local System account". After reboot the machine, I can see "myrun.exe", but no python started. I have to change to my login account with login name/password in the properties of my service in Control panel. Then I reboot my machine, no python is running, I have a client program in another computer to check it. After I log into my account, I saw python is running. But my pure Windows program runs well without login. After login, I saw that the user name of my pure Windows program is "SYSTEM". 2. In my python scripts, I have to check whether a file exists or not. I use "nRetCode = os.access(file_name, F_OK)" to check it. When the file is in local harddisk, I don't have any problems. But when the file is in mapped harddisk, I got problem. Let's say that my file is C:\temp\t.txt. No matter I run python in DOS window or in service, it always return the correct value, that is, "nRetCode" is True. When the file is X:\temp\t.txt, where X is mapped drive. If I run python in DOS window, it returns the correct value. If I run python in service mode(background), it returns the wrong value, that is, "nRetCode" is False. I believe that this is related to Windows security check, but I dont know how to fix it. Do you have any idea ? How do you run your python scripts in background ? Best regards. Michael Li Jim Vickroy wrote: > Hi Michael, > > Could you post a short sample script that demonstrates the behavior. > > I have several Python scripts running as MS Windows Services 24x7 on > machines where no one is logged in and I have not seen this behavior. What > version of Windows are you using? > > -- jv > > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of Michael Li > Sent: Thursday, June 03, 2004 9:14 AM > To: python-win32@python.org > Subject: Re: [python-win32] how to run python in background on Windows ? > > > Hi, Tom > Thank you very much for your reply. > This is not a "automatically startup" issue. > > I can start/stop python by using of Windows control > program in the same login session, but when I logout > and login again, the python service is gone. I have > to go to control panel to start again. > Do you know that is there a way to run python as > a service ? > > > Whittingham, Thomas wrote: > >>This may be obvious but did you set up the service to start >>automatically? In the same dialog boxes that let you start/stop Windows >>services you can specify whether a service should run at startup. >> >>~Tom >> >>Tom Whittingham >>Data Analyst >>Treatment Research Center >>Whittingham_T@mail.trc.upenn.edu >>215-222-3200 x143 (work) >>215-386-5106 (fax @ work) >>267-456-6802 (cell/home) >> >>"For You so loved the unlovable >>That You gave the Ineffable >>That who so believes the unbelievable >>Will gain the unattainable." >> >>-- "There You Go" lyrics, by Caedmon's Call >> >>-----Original Message----- >>From: Michael Li [mailto:mli@deform.com] >>Sent: Thursday, June 03, 2004 10:19 AM >>To: python-win32@python.org >>Subject: [python-win32] how to run python in background on Windows ? >> >>Hi, >> >>I was trying to run my python program as a server in background >>on Windows, but I failed. >> >>On Unix, I can do : >>% python myscript.py & >> >>On Windows, I use Windows' service to start/stop >>the python. In the same login session, I got success, >>I can see python program from TaskManager. >>but when I log out and log in again, my python server >>is gone, I can not see python program from TaskManager. >> >>Is there anyone there knowing how to run python >>in background as Windows' service ? >> >>best regards. >>Michael Li >> >> >>_______________________________________________ >>Python-win32 mailing list >>Python-win32@python.org >>http://mail.python.org/mailman/listinfo/python-win32 >> >>_______________________________________________ >>Python-win32 mailing list >>Python-win32@python.org >>http://mail.python.org/mailman/listinfo/python-win32 > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From mli at deform.com Fri Jun 4 13:54:41 2004 From: mli at deform.com (Michael Li) Date: Fri Jun 4 13:55:19 2004 Subject: [python-win32] Re: how to run python in background on Windows ? In-Reply-To: <00a501c44a55$91e758f0$5d00a8c0@LABWXP> References: <00a501c44a55$91e758f0$5d00a8c0@LABWXP> Message-ID: <40C0B761.7080404@deform.com> Hi, Larry: Thank you very much. My python scripts not only run on Windows, but also run on Unix. If I run my python scripts in DOS window, I don't have any problems. I can leave the DOS window open 24x7, but this is not the right way. I want my python program running in background 24x7. If I run it in service mode, I got problems. The problems are : 1. I can not run my python program as 24X7 after reboot/login/ logout. 2. My python program behaves differently between running in DOS window and running in service mode. I use Windows XP Home Edition. I don't know this matters or not. But I have a pure Windows program running 24x7 in background. Here is the details of my problem(my reply to Jim Vickroy's post). ------------begin here-------------------------------------- Hi, Jim: Thank you very much. My scripts are little bit longer, it's not easy to post here. I just want to put this into background to run 24x7 : python myscript.py In Unix, it's very easy: % python myscript.py & In Windows, I wrote myinstall.cpp, myrun.cpp. myrun.cpp is a small program just following the pattern of Windows service program. "myinstall" will install the "myrun.exe" service into Windows service control manager. From Control Panel->Service, when I click start button of myservice, it will start python. I can see python is running from Task Manager. When I log out and log in again, the python is gone. I can see myrun.exe is still there from Task Manager. I use Windows XP Home Edition. Does this matter ? I have a pure Windows program running as a service without any problems. Also I got two strange thing: 1. I have to use my login account to start python. After installation, I saw that "Log On" of my service is "Local System account". After reboot the machine, I can see "myrun.exe", but no python started. I have to change to my login account with login name/password in the properties of my service in Control panel. Then I reboot my machine, no python is running, I have a client program in another computer to check it. After I log into my account, I saw python is running. But my pure Windows program runs well without login. After login, I saw that the user name of my pure Windows program is "SYSTEM". 2. In my python scripts, I have to check whether a file exists or not. I use "nRetCode = os.access(file_name, F_OK)" to check it. When the file is in local harddisk, I don't have any problems. But when the file is in mapped harddisk, I got problem. Let's say that my file is C:\temp\t.txt. No matter I run python in DOS window or in service, it always return the correct value, that is, "nRetCode" is True. When the file is X:\temp\t.txt, where X is mapped drive. If I run python in DOS window, it returns the correct value. If I run python in service mode(background), it returns the wrong value, that is, "nRetCode" is False. I believe that this is related to Windows security check, but I dont know how to fix it. Do you have any idea ? How do you run your python scripts in background ? -------------------end here-------------------------------------- Larry Bates wrote: >>[snip] >>Is there anyone there knowing how to run python in background as Windows' >>service ? > > > You can write an NT Service that runs all the time in the > background and sleeps for predetermined intervals then > wakes up and does something. This program never exits > unless you stop the service. This is good for things > that need to be running all the time to take action when > something happens. > > Services are somewhat hard to write, but are more efficient if > startup cost of the program is high and/or the times > between when you wish to check are short. An alternative > method would be to schedule jobs in the Task Scheduler. > If you schedule jobs to close together, you can run into > the problem of the first job not completing before the > second one starts. NT services run to completion, then > sleeps for a predetermined number of milliseconds so > overlap is not a problem and the sleep mechanism doesn't > tie up the CPU. > > If you want to learn about writing Python services you > should get a copy of Mark Hammond's Python Programming > on Win32. It has several examples that helped me a lot. > > HTH, > Larry Bates > Syscon, Inc. > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From somesh at qviqsoft.com Sat Jun 5 06:16:28 2004 From: somesh at qviqsoft.com (Somesh Bartakke) Date: Sat Jun 5 06:15:14 2004 Subject: [python-win32] Python DLL - Part 2 Message-ID: <057f01c44ae6$2fca5820$436a640a@qsoft25> hello guys, i want to work with VC++ and Python. where i wanna write a dll or dll like interface with Python which will be called thru VC++ is it possible to write in this way ? apart from embeding interpreter and bla-bla. Somesh Bartakke Q-Soft Pvt Ltd, Pune (India) -- Every Pawn can be Queen on chess-board, just wait for seven moves. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040605/bc982ab5/attachment.html From david at graniteweb.com Sat Jun 5 13:06:55 2004 From: david at graniteweb.com (David Rock) Date: Sat Jun 5 13:06:57 2004 Subject: [python-win32] Re: how to run python in background on Windows ? In-Reply-To: <40C0B761.7080404@deform.com> References: <00a501c44a55$91e758f0$5d00a8c0@LABWXP> <40C0B761.7080404@deform.com> Message-ID: <20040605170655.GA29181@wdfs.graniteweb.com> * Michael Li [2004-06-04 13:54]: > Hi, Larry: > Thank you very much. > My python scripts not only run on Windows, but also > run on Unix. If I run my python scripts in DOS window, > I don't have any problems. I can leave the DOS window > open 24x7, but this is not the right way. I want my python > program running in background 24x7. > If I run it in service mode, I got problems. > The problems are : > 1. I can not run my python program as 24X7 after reboot/login/ > logout. > 2. My python program behaves differently between running in DOS window > and running in service mode. If you install the service, it should run regardless of anyone being logged in or not. If it isn't, something is wrong. As for behaving differently running in a command window or running as a service, that's not surprising. The environments are pretty different. It sounds like you are trying to test in a command window and then run as a service, that won't work very well. If you want to test the service, you have to run it AS a service while testing. -- David Rock david@graniteweb.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20040605/73bada5b/attachment.bin From tony at tcapp.com Sat Jun 5 13:51:12 2004 From: tony at tcapp.com (Tony Cappellini) Date: Sat Jun 5 13:51:29 2004 Subject: [python-win32] re:python-win32] Python DLL - Part 2 Message-ID: <6.0.0.22.0.20040605105004.0472af18@smtp.sbcglobal.net> Take a look at ctypes, for Python. Also look at swig, but I think Ctypes is more straightforward. Message: 5 Date: Sat, 5 Jun 2004 15:46:28 +0530 From: "Somesh Bartakke" Subject: [python-win32] Python DLL - Part 2 To: Message-ID: <057f01c44ae6$2fca5820$436a640a@qsoft25> Content-Type: text/plain; charset="iso-8859-1" hello guys, i want to work with VC++ and Python. where i wanna write a dll or dll like interface with Python which will be called thru VC++ is it possible to write in this way ? apart from embeding interpreter and bla-bla. Somesh Bartakke Q-Soft Pvt Ltd, Pune (India) From cgadgil_list at cxoindia.dnsalias.com Sun Jun 6 08:56:03 2004 From: cgadgil_list at cxoindia.dnsalias.com (Chetan Gadgil) Date: Sun Jun 6 08:58:02 2004 Subject: [python-win32] Python DLL - Part 2 In-Reply-To: <057f01c44ae6$2fca5820$436a640a@qsoft25> Message-ID: <002801c44bc5$a032c9a0$5b0aa8c0@cxodt03> Actually, embedding the interpreter is quite simple. If for some reason you don't want to do this, you can use the windows "LoadLibrary" api. For more info on runtime loading of libraries and using them: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc /base/using_run_time_dynamic_linking.asp 1) Dynamically load python library 2) Then you can call Python methods by name However, this would be silly, in my opinion; instead, just try embedding the Python interpreter. Chetan "Contrariwise," continued Tweedledee, "if it was so, it might be, and if it were so, it would be; but as it isn't, it ain't. That's logic!" -- Lewis Carroll, "Through the Looking Glass" -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org] On Behalf Of Somesh Bartakke Sent: Saturday, June 05, 2004 3:46 PM To: python-win32@python.org Subject: [python-win32] Python DLL - Part 2 hello guys, i want to work with VC++ and Python. where i wanna write a dll or dll like interface with Python which will be called thru VC++ is it possible to write in this way ? apart from embeding interpreter and bla-bla. Somesh Bartakke Q-Soft Pvt Ltd, Pune (India) -- Every Pawn can be Queen on chess-board, just wait for seven moves. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040606/3e119bbb/attachment.html From janez.jere at void.si Tue Jun 8 08:51:20 2004 From: janez.jere at void.si (Janez Jere) Date: Tue Jun 8 08:48:16 2004 Subject: [python-win32] win32ui tabcontrol Message-ID: Hi, I cant find any example how to use tabcontrol in python! I would like to use tabcontrol. UI should be like in pywin menu "/Tools/Edit python path" (python23\lib\site-packages\pythonwin\pywin\tools\regedit.py). Only difference is that on right site would be a tabcontrol with 3 sheets: - edit control, (docview.EditView?) - listview (docview.ListView?) - embedded browser Is the above construct possible? PyCTabCtrl should be the class encapsulating tabcontrol, but i cant figure out how to use it. Janez From somesh at qviqsoft.com Tue Jun 8 09:42:57 2004 From: somesh at qviqsoft.com (Somesh Bartakke) Date: Tue Jun 8 09:41:39 2004 Subject: [python-win32] PyQt on Windows ? Message-ID: <007301c44d5e$8714ac00$436a640a@qsoft25> i want to get/run PyQt on windows. i installed PyQt Edu version but its not working asking for more PyQt dll / developement env. i went thru trolltech site but there is not any separate Runtime env available. Can anyone suggest eaZy way to get out of this ? weather its preferred to use PyQt ? or Qt for GUI on win32 Somesh Bartakke Q-Soft Pvt Ltd, Pune (India) -- Every Pawn can be Queen on chess-board, just wait for seven moves. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040608/69bdf9d1/attachment.html From keldar_atavian at yahoo.com Wed Jun 9 23:41:51 2004 From: keldar_atavian at yahoo.com (Keldar Keldariad) Date: Wed Jun 9 23:41:55 2004 Subject: [python-win32] wxPython and COM: creating multiple LocalServer Instances Message-ID: <20040610034151.75682.qmail@web50207.mail.yahoo.com> When trying to create 2 different COM objects running wxPython apps, I ran into the problem of wxPython complaining and crashing when started in more than one thread. The solution to this was easy enough - I simply made the 2 objects to start as LocalServers, which launched them both in separate interpreter processes, keeping the wxPython threads separate. However, now a new problem came up - all instances of the same object are started in the same interpreter process, so when trying to create more than one instance of the same object I run into exactly the same threading issue as before. Is there a way to force the object to be created in a new process regardless of whether there's already an instance of that object running or not? Where would I have to look to do that. I tried going through policy.py but that doesn't seem to help much, or maybe I am looking at it wrong. Thanks in advance. __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ From stanlx at yahoo.com Fri Jun 11 21:44:12 2004 From: stanlx at yahoo.com (stan lysiak) Date: Fri Jun 11 21:44:15 2004 Subject: [python-win32] Having ODBC and Excel problems with Python 2.3.4/PyWin 201.1 on Windows Xp Message-ID: <20040612014412.45799.qmail@web42004.mail.yahoo.com> Hi, Until this week I have been using Python 2.3.3 and win32all build 163 on a Windows XP machine to connect to a Sybase server using Sybase 11 ODBC and process and place the results into Excel 2002 worksheets. The only problem I encountered was that Python longs between 2**31 and 2**32 were interpreted as signed integers when I placed them into Excel and displayed as negative values. I just converted them to floats and they displayed correctly. I decided to upgrade to Python 2.3.4 and PyWin build 201.1. I've been having strange problems. First excel. Using PyWin 201.1, if I write a second range onto a worksheet, I get an access error and Python abends with an uncaught exception. Moving back to build 200 seems to fix this problem. Then ODBC. In some python programs, if I use parameterized selects in 201.1, the ODBC module complains that there is a missing column in an insert. If I perform the substitution before calling ODBC with the cursor, it works fine. I tried using an explicit tuple conversion instead of the , style, and the calls worked as well. e.g. curs.execute (query, tuple (subval)) instead of curs.execute (query, (subval,)) In other programs the ODBC code that worked under 2.3.3 and build 163 worked flawlessly in build 200 and 201.1. Am I doing something wrong or are these known problems under later builds of Python and Pywin? I'll probably just go back to the earlier win32all build 163 if these are known problems with no workarounds. I looked at the ODBC.cpp module, and as near as I could figure, everything looked OK. Is it possible that these are problems with my Windows XP configuration? I'm not very familiar with the Windows programming API. Thanks, Stan __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ From mattfmcti at yahoo.com Mon Jun 14 14:29:31 2004 From: mattfmcti at yahoo.com (Matthew Minton) Date: Mon Jun 14 14:29:43 2004 Subject: [python-win32] looking for beta tester(s) Message-ID: <20040614182931.49457.qmail@web14610.mail.yahoo.com> Hello Everyone! Since this is my first message, I want to introduce myself. I am Matt, an amateur programmer from Texas. Python is the first language I've been able to work with since Pascal (BOO! HISS!) in HS, and I love it. I've written my first program, a small, text-based RPG, and am looking for beta testers/anyone who wants to to play it, look at the code, find bugs, suggest improvements (in code and/or game play), or utterly lambast it. Please respond either via the list or private e-mail. Thanks! Matt --------------------------------- Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040614/bcd59794/attachment.html From anand at easi.soft.net Tue Jun 15 06:44:34 2004 From: anand at easi.soft.net (Anand K Raydu) Date: Tue Jun 15 20:31:48 2004 Subject: [python-win32] C objects array through python COM layer Message-ID: <40CED312.70105@easi.soft.net> Hi all, I have one requirement, can some one please suggest if this can be done through python COM layer. I have an array which has C objects. I want to pass the same array to a COM interface. I am getting error Objects of type 'PyCObject' can not be converted to a COM VARIANT Can some one Please suggest, Regards, Anand From christian at treesforlife.org Thu Jun 17 21:40:57 2004 From: christian at treesforlife.org (Christian Junker) Date: Thu Jun 17 23:06:46 2004 Subject: [python-win32] Calling (D)COM Server from another PC Message-ID: Hello together, this question might be foolish, but after quite some search I could not find how to make use of DCOM with the current win32com package. I tested out the DispatchEx which takes as its second parameter a 'machine', probably either the hostname or the IP. I tried to invoke methods of the Internet Explorer on other PCs in the network, and actually it worked (no exception thrown), but on the target machine no changes could be seen (IE.Visible=1 would make a IE Window visible but it didn't do anything on the other pc). So does someone of you know how to make use of DCOM, ie calling COM or OLE objects on other PCs. Thanks in advance. Best regards Christian From mhammond at skippinet.com.au Thu Jun 17 19:11:30 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun Jun 20 23:30:34 2004 Subject: [python-win32] Having ODBC and Excel problems with Python2.3.4/PyWin 201.1 on Windows Xp In-Reply-To: <20040612014412.45799.qmail@web42004.mail.yahoo.com> Message-ID: <2a6201c454c0$6d636120$0200a8c0@eden> > Until this week I have been using Python 2.3.3 and > win32all build 163 on a Windows XP machine to connect > to a Sybase server using Sybase 11 ODBC and process > and place the results into Excel 2002 worksheets. The > only problem I encountered was that Python longs > between 2**31 and 2**32 were interpreted as signed > integers when I placed them into Excel and displayed > as negative values. I just converted them to floats > and they displayed correctly. This should be fixed in the next build (I only just discovered that myself) > First excel. Using PyWin 201.1, if I write a second > range onto a worksheet, I get an access error and > Python abends with an uncaught exception. Moving back > to build 200 seems to fix this problem. Can you please send me an example of this? > Then ODBC. In some python programs, if I use > parameterized selects in 201.1, the ODBC module > complains that there is a missing column in an insert. > If I perform the substitution before calling ODBC > with the cursor, it works fine. I tried using an > explicit tuple conversion instead of the , style, and > the calls worked as well. e.g. curs.execute (query, > tuple (subval)) > instead of curs.execute (query, (subval,)) In other > programs the ODBC code that worked under 2.3.3 and > build 163 worked flawlessly in build 200 and 201.1. > > Am I doing something wrong or are these known problems > under later builds of Python and Pywin? I'll probably > just go back to the earlier win32all build 163 if > these are known problems with no workarounds. > > I looked at the ODBC.cpp module, and as near as I > could figure, everything looked OK. Is it possible > that these are problems with my Windows XP > configuration? I'm not very familiar with the Windows > programming API. I'm afraid these aren't known problems. I would be quite surprised about ODBC - between build 200 and 201, there was a single change: revision 1.10 date: 2004/04/25 04:31:41; author: mhammond; state: Exp; lines: +0 -1 Remove apparently unnecessary lowercase of the column names, as requested in [ 937779 ] ODBC-Metadata. diff -r1.9 -r1.10 1029d1028 < _strlwr(name); It seems unlikely this is the problem - it was only lowercasing the name returned to you in the result tuple, not the case of the name passed to the driver itself. But anything is possible. If you would like to be sure, I could build a 2.3 version of ODBC before that change and see if your problem goes away. A quick look at bug 937779 probably wouldn't hurt too. Mark From mhammond at skippinet.com.au Thu Jun 17 19:02:45 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon Jun 21 00:29:16 2004 Subject: [python-win32] C objects array through python COM layer In-Reply-To: <40CED312.70105@easi.soft.net> Message-ID: <2a5501c454bf$34509700$0200a8c0@eden> > I have one requirement, can some one please suggest if this > can be done > through python COM layer. > I have an array which has C objects. I want to pass the same > array to a > COM interface. > I am getting error > Objects of type 'PyCObject' can not be converted to a COM VARIANT There is no facility for copying arbitrary data through COM, as COM doesn't know to do do its magic (eg, marshalling) for them. If you want to pass Python objects around, you should consider using pickle(), then moving them as strings. Mark. From byo at myrealbox.com Thu Jun 17 21:08:57 2004 From: byo at myrealbox.com (byo) Date: Mon Jun 21 00:31:05 2004 Subject: [python-win32] How to monitor the stdout/stderr of somecmd.exe Message-ID: <1087520937.ba3bc9fcbyo@myrealbox.com> I'd like to write a python program that will monitor the stdout/stderr of an executable (somecmd.exe) running on W2K. (simulated by sometask.py as below) I'm trying to react to it's output *as it is happening* (eg. thru monitor_sometask.py) by using win32pipe, but I find that I'm only getting the pipe's output too long after the fact. How can I monitor the output of somecmd.exe as it happens ? Thanks in advance. # # monitor_sometask.py # import win32pipe import time f = win32pipe.popen("c:\python23\python sometask.py", 'r') while 1: aLine = f.readline() if not aLine: break print 'now:', time.asctime(), ' process :', aLine # do something with aLine here f.close() # # sometask.py # import time for i in range(0,3): print time.asctime() time.sleep(2) # # sample output # now: Fri Jun 18 10:22:43 2004 process : Fri Jun 18 10:22:36 2004 now: Fri Jun 18 10:22:43 2004 process : Fri Jun 18 10:22:38 2004 now: Fri Jun 18 10:22:43 2004 process : Fri Jun 18 10:22:40 2004 From rwupole at msn.com Sat Jun 19 14:05:24 2004 From: rwupole at msn.com (Roger Upole) Date: Mon Jun 21 00:41:26 2004 Subject: [python-win32] Re: Calling (D)COM Server from another PC Message-ID: <000601c45628$0046d860$6111780a@rupole> Check to see if an instance of iexplore.exe is started on the target machine. Most likely it can't create a visible window on the desktop. DCOM runs thru the RPC service, which by default can't interact with the desktop. If the executable is getting started, try changing the RPC service config on the target machine so that it can, restart it, and try the script again. hth Roger -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040619/a142983a/attachment.html From byo at myrealbox.com Sat Jun 19 20:36:17 2004 From: byo at myrealbox.com (byo) Date: Mon Jun 21 00:49:52 2004 Subject: [python-win32] How to monitor the stdout/stderr of somecmd.exe Message-ID: <40D4DC01.4020400@myrealbox.com> I'd like to write a python program that will monitor the stdout/stderr of an executable (somecmd.exe) running on W2K. (simulated by sometask.py as below) I'm trying to react to it's output *as it is happening* (eg. thru monitor_sometask.py) by using win32pipe, but I find that I'm only getting the pipe's output too long after the fact. How can I monitor the output of somecmd.exe as it happens ? Thanks in advance. Newbie # # monitor_sometask.py # import win32pipe import time f = win32pipe.popen("c:\python23\python sometask.py", 'r') while 1: aLine = f.readline() if not aLine: break print 'now:', time.asctime(), ' process :', aLine # do something with aLine here f.close() # # sometask.py # import time for i in range(0,3): print time.asctime() time.sleep(2) # # sample output # now: Fri Jun 18 10:22:43 2004 process : Fri Jun 18 10:22:36 2004 now: Fri Jun 18 10:22:43 2004 process : Fri Jun 18 10:22:38 2004 now: Fri Jun 18 10:22:43 2004 process : Fri Jun 18 10:22:40 2004 From Martin.Gfeller at comit.ch Sun Jun 20 08:02:41 2004 From: Martin.Gfeller at comit.ch (Gfeller Martin) Date: Mon Jun 21 01:04:32 2004 Subject: [python-win32] Calling (D)COM Server from another PC Message-ID: Christian, I sucessfully used the Windows 2000 utility dcomcnfg.exe to transparently map COM calls to another machine. There was no need to modify any Python code - just use DCOMCNFG declare that the called COM object is actually on the other machine. On the target machine, DCOMCNFG can be used to allow the originating machine/user to invoke the object. Best regards, Martin -----Original Message----- From: Christian Junker [mailto:christian@treesforlife.org] Sent: Friday, June 18, 2004 3:41 AM To: python-win32@python.org Subject: [python-win32] Calling (D)COM Server from another PC Hello together, this question might be foolish, but after quite some search I could not find how to make use of DCOM with the current win32com package. I tested out the DispatchEx which takes as its second parameter a 'machine', probably either the hostname or the IP. I tried to invoke methods of the Internet Explorer on other PCs in the network, and actually it worked (no exception thrown), but on the target machine no changes could be seen (IE.Visible=1 would make a IE Window visible but it didn't do anything on the other pc). So does someone of you know how to make use of DCOM, ie calling COM or OLE objects on other PCs. Thanks in advance. Best regards Christian From tim.golden at viacom-outdoor.co.uk Mon Jun 21 03:18:32 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon Jun 21 04:25:20 2004 Subject: [python-win32] Calling (D)COM Server from another PC Message-ID: | Hello together, | this question might be foolish, but after quite some search I | could not find | how to make use of DCOM with the current win32com package. | I tested out the DispatchEx which takes as its second | parameter a 'machine', | probably either the hostname or the IP. I tried to invoke | methods of the | Internet Explorer on other PCs in the network, and actually | it worked (no | exception thrown), but on the target machine no changes could be seen | (IE.Visible=1 would make a IE Window visible but it didn't do | anything on | the other pc). | So does someone of you know how to make use of DCOM, ie | calling COM or OLE | objects on other PCs. Certainly DispatchEx works ok for automating via DCOM. However, I don't know what's defined for how visible the thing is on the other machine's desktop. For example, the following code will correctly create a new Excel Workbook, put 5 in its top-left cell and save it on the other machine's disk: import win32com.client xl = win32com.client.DispatchEx ("Excel.Application", "VOGBP200") # # Otherwise it may popup an "Are you sure?" # dialog box -- which you won't see and # can't respond to! # xl.DisplayAlerts = 0 ws = xl.Workbooks.Add ().ActiveSheet ws.Cells (1, 1).Value = 5 xl.ActiveWorkbook.SaveAs ("temp.xls") xl.Quit () Now, I tried putting a "Visible = 1" in and nothing happened, so I'm guessing that -- since DCOM's not really intended to be a LanDesk / NetOp sort of thing -- that you can't make remote apps Visible. But I'm guessing. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. 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 Chris.Cottee at WallStreetSystems.com Thu Jun 10 12:57:21 2004 From: Chris.Cottee at WallStreetSystems.com (Chris Cottee) Date: Mon Jun 21 10:37:58 2004 Subject: [python-win32] automating Internet Explorer for functional testing of web pages Message-ID: Hi, I'm trying to use Internet explorer (automated via win32com) to test our website (which uses frames and javascript heavily) and I wondered if anyone could answer a couple of questions: 1. Has anyone done this already? (I know about PAMIE, I was after any other resources that might be about the place) 2. When I use WithEvents IE slows right down and I can't interact with it any more, it's like it's blocking waiting for some response to the event. Is this normal ? Or am I doing something wrong ? My code looks like this class EventSink(object): """ an event sink for the com events""" def OnError(self,*someargs): print "Error",someargs def OnNavigateComplete2(self,*args): print "complete" ,args class IE(object): def __init__(self): """abbreviated""" self._ie = Dispatch('InternetExplorer.Application') self.events=WithEvents(self._ie,EventSink) 3. More of an IE question than a python question: does anyone know how to detect JavaScript errors via the WebBrowserControl2 interface? Thanks, Chris Cottee From Chris.Cottee at WallStreetSystems.com Thu Jun 17 12:43:17 2004 From: Chris.Cottee at WallStreetSystems.com (Chris Cottee) Date: Mon Jun 21 10:38:02 2004 Subject: [python-win32] win32com and Internet Explorer Message-ID: Hi, I am trying to automate Internet Explorer using python and win32com to use it as a functional testing tool. My questions are 1. Has anyone done this before ? -I am aware of PAMIE and am trying to extend it. 2. When I use event handling IE takes about ten times longer to navigate and generally becomes sluggish even if my event handler does nothing. Am I missing something or is this just normal? I have included pythoncom.PumpWaitingMessages in the vague hope that it might make a difference rather than actually knowing what it does... My test code looks like this: from win32com.client import Dispatch,WithEvents import time,threading,pythoncom,sys stopEvent=threading.Event() class EventSink(object): def OnNavigateComplete2(self,*args): print "complete",args stopEvent.set() def waitUntilReady(ie): if ie.ReadyState!=4: while 1: print "waiting" pythoncom.PumpWaitingMessages() stopEvent.wait(.2) if stopEvent.isSet() or ie.ReadyState==4: stopEvent.clear() break; time.clock() ie=Dispatch('InternetExplorer.Application',EventSink) ev=WithEvents(ie,EventSink) ie.Visible=1 ie.Navigate("file:///c:/success.html") waitUntilReady(ie) print "location",ie.LocationName ie.Navigate("file:///c:/checkbox.html") waitUntilReady(ie) print "location",ie.LocationName print ie.LocationName,time.clock() print ie.ReadyState Thanks for your help, Chris From jens.jorgensen at tallan.com Mon Jun 21 11:00:04 2004 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Mon Jun 21 11:00:13 2004 Subject: [python-win32] Calling (D)COM Server from another PC In-Reply-To: References: Message-ID: <40D6F7F4.6060809@tallan.com> I have a bit of experience with this and I can tell you you're in for some fun. When I was doing something like this (not controlling IE but rather my own COM object) I found that if a COM object has a InprocServer32 entry on the machine you're running this on then your attempt to create an instance on a remote machine will succeed but in fact instead an instance is created on the local machine. In order to convince COM to actually create an instance on the remote machine you'd have to remove the InprocServer32 entry. This was my experience anyway. Note that this has nothing to do with anything wrong with Python or anything like that. The code I was working with was in C++. If you haven't already done it you need to go out and get yourself a copy of Don Box' "Essential COM" : The title ain't just kiddin'. For the kind of stuff you're talking about doing you'll need this level of understanding. The next thing you're probably going to find is that getting the permissions set such that you can create a graphical application on the logged-in user's desktop will be even more interesting. There's all sorts of security stuff that has to be in line for this kind of thing to happen. Christian Junker wrote: >Hello together, >this question might be foolish, but after quite some search I could not find >how to make use of DCOM with the current win32com package. >I tested out the DispatchEx which takes as its second parameter a 'machine', >probably either the hostname or the IP. I tried to invoke methods of the >Internet Explorer on other PCs in the network, and actually it worked (no >exception thrown), but on the target machine no changes could be seen >(IE.Visible=1 would make a IE Window visible but it didn't do anything on >the other pc). >So does someone of you know how to make use of DCOM, ie calling COM or OLE >objects on other PCs. > >Thanks in advance. > >Best regards >Christian > > > > >_______________________________________________ >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" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040621/9813a5d2/attachment-0001.html From christian at TreesforLife.org Mon Jun 21 14:30:19 2004 From: christian at TreesforLife.org (Christian Junker) Date: Mon Jun 21 19:54:06 2004 Subject: [python-win32] Calling (D)COM Server from another PC Message-ID: <8643B74BC5B4C045B96E7031CA94CBBD35F5BA@tfls02.tfl.net> Your explanation perfectly makes sense, Mr. Jorgensen. Maybe I'll get the book you suggested, but for right now: Where is this InprocServer32 entry and how can I delete it? And are there any other issues (local functionality or network issues) that could occur when this entry is missing. Thanks anyway for all your replies up till now. Another question I have is: Couldn't these programs possibly be reached with OLE Automation? Or does the command CreateOLEObject() not support any actions on another pc and I am stuck with DCOM? Is it right to say OLE 'inherits' from COM? Still you see I have not got very much knowledge of all these concepts, but I am currently writing a documentation for OOo's (OpenOffice.org) ability to be accessed from 'outside' its own component model called UNO: http://www.oooforum.org/forum/viewtopic.php?t=9815 If you have any suggestions or comments (or even if something is wrong in this text) then let me know. Best regards Christian Junker -----Original Message----- From: Jens B. Jorgensen [mailto:jens.jorgensen@tallan.com] Sent: Monday, June 21, 2004 10:00 AM To: Christian Junker Cc: python-win32@python.org Subject: Re: [python-win32] Calling (D)COM Server from another PC I have a bit of experience with this and I can tell you you're in for some fun. When I was doing something like this (not controlling IE but rather my own COM object) I found that if a COM object has a InprocServer32 entry on the machine you're running this on then your attempt to create an instance on a remote machine will succeed but in fact instead an instance is created on the local machine. In order to convince COM to actually create an instance on the remote machine you'd have to remove the InprocServer32 entry. This was my experience anyway. Note that this has nothing to do with anything wrong with Python or anything like that. The code I was working with was in C++. If you haven't already done it you need to go out and get yourself a copy of Don Box' "Essential COM": The title ain't just kiddin'. For the kind of stuff you're talking about doing you'll need this level of understanding. The next thing you're probably going to find is that getting the permissions set such that you can create a graphical application on the logged-in user's desktop will be even more interesting. There's all sorts of security stuff that has to be in line for this kind of thing to happen. Christian Junker wrote: Hello together, this question might be foolish, but after quite some search I could not find how to make use of DCOM with the current win32com package. I tested out the DispatchEx which takes as its second parameter a 'machine', probably either the hostname or the IP. I tried to invoke methods of the Internet Explorer on other PCs in the network, and actually it worked (no exception thrown), but on the target machine no changes could be seen (IE.Visible=1 would make a IE Window visible but it didn't do anything on the other pc). So does someone of you know how to make use of DCOM, ie calling COM or OLE objects on other PCs. Thanks in advance. Best regards Christian _______________________________________________ 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" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040621/3be99b06/attachment.html From t-meyer at ihug.co.nz Mon Jun 21 21:12:30 2004 From: t-meyer at ihug.co.nz (Tony Meyer) Date: Mon Jun 21 21:14:15 2004 Subject: [python-win32] Having ODBC and Excel problems withPython2.3.4/PyWin 201.1 on Windows Xp In-Reply-To: <1ED4ECF91CDED24C8D012BCF2B034F1306C37A07@its-xchg4.massey.ac.nz> Message-ID: <1ED4ECF91CDED24C8D012BCF2B034F1304677F90@its-xchg4.massey.ac.nz> > > First excel. Using PyWin 201.1, if I write a second > > range onto a worksheet, I get an access error and > > Python abends with an uncaught exception. Moving back > > to build 200 seems to fix this problem. > > Can you please send me an example of this? This sounds quite similar to the problem I had when upgrading from 200 to 201. At the time the problem seemed to be resolved by recreating the gen_py cache, but I did experience the odd problem after that. I was busy at the time so just dropped back to 200. If Stan isn't able to produce something that replicates this, then I'm happy to go back to 201 and try to find it again (I had a lot of trouble trying to isolate code that would trigger the problem). (FWIW, a simple double write of a range works fine here.) =Tony Meyer (Excel 2002/XP with WinXP) From null-python-win32 at tinfoilhat.ca Wed Jun 23 18:19:51 2004 From: null-python-win32 at tinfoilhat.ca (Sean) Date: Wed Jun 23 18:19:57 2004 Subject: [python-win32] How to monitor the stdout/stderr of somecmd.exe In-Reply-To: <1087520937.ba3bc9fcbyo@myrealbox.com> Message-ID: ->f = win32pipe.popen("c:\python23\python sometask.py", 'r') while 1: Redirect stderr (descriptor 2) to stdout (descriptor 1) and set the io buffer size to some number at least as small as your smalled expected output (could be 0 as well but I'm not 100% sure on how that will affect things). buffersize=len("now: Fri Jun 18 10:22:43 2004 process : Fri Jun 18 10:22:36 2004") f = win32pipe.popen("c:\python23\python sometask.py 2>1", 'r', buffersize) Hopefully that points you in the right direction. That is all, -- Sean From byo at myrealbox.com Fri Jun 25 01:46:26 2004 From: byo at myrealbox.com (Boris O) Date: Fri Jun 25 01:46:38 2004 Subject: [python-win32] How to monitor the stdout/stderr of somecmd.exe In-Reply-To: References: Message-ID: <40DBBC32.2040002@myrealbox.com> Hi Sean, I tried it and it doesn't work for a variety of reasons : win32pipe.popen takes only 2 arguments, it won't accept buffersize - I tried os.popen but it insists that the buffersize parameter is set to -1 (very strange) Perhaps this is another question for another forum ... Also, f = win32pipe.popen("c:\python23\python sometask.py 2>1", 'r') simply redirects the output to a file called "1". I suspect that "2" is passed as a command line parameter. At any rate, it doesn't address how to read the output as it is happening. I'm open to any other suggestions ... Thanks ps. apologies to the list for posting my question twice. Sean wrote: > ->f = win32pipe.popen("c:\python23\python sometask.py", 'r') while 1: > > Redirect stderr (descriptor 2) to stdout (descriptor 1) and set the io > buffer size to some number at least as small as your smalled expected > output (could be 0 as well but I'm not 100% sure on how that will affect things). > > buffersize=len("now: Fri Jun 18 10:22:43 2004 process : Fri Jun 18 10:22:36 2004") > f = win32pipe.popen("c:\python23\python sometask.py 2>1", 'r', buffersize) > > Hopefully that points you in the right direction. > > That is all, > From Jim.Vickroy at noaa.gov Fri Jun 25 11:41:56 2004 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri Jun 25 11:42:00 2004 Subject: [python-win32] How to monitor the stdout/stderr of somecmd.exe In-Reply-To: <40D4DC01.4020400@myrealbox.com> Message-ID: You could try using sys.stdout.flush(), after print statements in sometask.py. If that does not help, you might look at the mmap module. If mmap does not meet your needs, you may have to try other forms of message passing to get the "realtime" performance you desire. -----Original Message----- From: python-win32-bounces+jim.vickroy=noaa.gov@python.org [mailto:python-win32-bounces+jim.vickroy=noaa.gov@python.org]On Behalf Of byo Sent: Saturday, June 19, 2004 6:36 PM To: python-win32@python.org Subject: [python-win32] How to monitor the stdout/stderr of somecmd.exe I'd like to write a python program that will monitor the stdout/stderr of an executable (somecmd.exe) running on W2K. (simulated by sometask.py as below) I'm trying to react to it's output *as it is happening* (eg. thru monitor_sometask.py) by using win32pipe, but I find that I'm only getting the pipe's output too long after the fact. How can I monitor the output of somecmd.exe as it happens ? Thanks in advance. Newbie # # monitor_sometask.py # import win32pipe import time f = win32pipe.popen("c:\python23\python sometask.py", 'r') while 1: aLine = f.readline() if not aLine: break print 'now:', time.asctime(), ' process :', aLine # do something with aLine here f.close() # # sometask.py # import time for i in range(0,3): print time.asctime() time.sleep(2) # # sample output # now: Fri Jun 18 10:22:43 2004 process : Fri Jun 18 10:22:36 2004 now: Fri Jun 18 10:22:43 2004 process : Fri Jun 18 10:22:38 2004 now: Fri Jun 18 10:22:43 2004 process : Fri Jun 18 10:22:40 2004 _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From tim.golden at viacom-outdoor.co.uk Fri Jun 25 11:41:57 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Fri Jun 25 11:44:39 2004 Subject: [python-win32] How to monitor the stdout/stderr of somecmd.ex e Message-ID: | I'd like to write a python program that will monitor the stdout/stderr | of an executable (somecmd.exe) running on W2K. (simulated by | sometask.py | as below) I'm trying to react to it's output *as it is happening* (eg. | thru monitor_sometask.py) by using win32pipe, but I find that I'm only | getting the pipe's output too long after the fact. How can I | monitor the | output of somecmd.exe as it happens ? Thanks in advance. Haven't followed this thread (so apologies if someone's suggested this) but have you looked at Peter Astrand's Process/popen5 module: http://www.lysator.liu.se/~astrand/popen5/ It looks as though it will do what you want, although I freely admit I haven't tried it myself. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. 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 rays at blue-cove.com Fri Jun 25 12:17:35 2004 From: rays at blue-cove.com (Ray Schumacher) Date: Fri Jun 25 12:16:30 2004 Subject: [python-win32] How to monitor the stdout/stderr of somecmd.exe In-Reply-To: References: <40D4DC01.4020400@myrealbox.com> Message-ID: <5.2.0.4.2.20040625090956.114f67c8@blue-cove.com> >-----Original Message----- >From: python-win32-bounces+jim.vickroy=noaa.gov@python.org >[mailto:python-win32-bounces+jim.vickroy=noaa.gov@python.org]On Behalf >Of byo >Sent: Saturday, June 19, 2004 6:36 PM >To: python-win32@python.org >Subject: [python-win32] How to monitor the stdout/stderr of somecmd.exe > > >I'd like to write a python program that will monitor the stdout/stderr >of an executable (somecmd.exe) running on W2K. (simulated by sometask.py >as below) I'm trying to react to it's output *as it is happening* (eg. >thru monitor_sometask.py) by using win32pipe, but I find that I'm only >getting the pipe's output too long after the fact. How can I monitor the >output of somecmd.exe as it happens ? Thanks in advance. This test interactively controls an old FORTRAN 85 program by using pipedream.py http://www.speakeasy.org/~bob_green/pipedream/: import pipedream, time pd = pipedream.PipeDream("frbpv5.exe") pd.SendLine("") pd.SendLine("1") time.sleep(1) while pd.HasDataWaiting(): print pd.ReadLine(1) time.sleep(1) pd.SendLine("2") pd.ConsumeUpTo("", num = 1) try: while pd.HasDataWaiting(): print pd.ReadLine(timeout = 1) except: pass pd.HasDataWaiting() pd.SendLine("1") pd.ReturnUpTo("SPEEDS -->", num = 1) pd.ReceiveProtocol(" Continue") pd.Shutd Ray Schumacher http://rjs.org From Peter.Winstanley at scotland.gsi.gov.uk Wed Jun 30 02:31:59 2004 From: Peter.Winstanley at scotland.gsi.gov.uk (Peter.Winstanley@scotland.gsi.gov.uk) Date: Wed Jun 30 02:32:04 2004 Subject: [python-win32] Converting VB to Python Message-ID: <5D7E001D106BA1468625E7905D088F4FE592F7@MC25GLG.scotland.gov.uk> ******************************************************************************************************************************************************* This email and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed. ******************************************************************************************************************************************************* > I would be grateful for help and advice on the following: > > I am trying to convert into Python an example VB program that uses > MSXML 4.0 and the SAXXMLReader40 and XMLSchemaCache40 to validate an > XML file against an XSD schema and to provide exhaustive errors. The > routine is given here: > http://support.microsoft.com/default.aspx?scid=kb;en-us;Q315497 > > In the VB version a class module is created to act as an error > handler. The class starts with the statement > > "Implements MSXML2.IVBSAXErrorHandler" > > > How do I convert an "Implements" statement to Python? > > Thanks for your help > > > The original of this email was scanned for viruses by the Government Secure Intranet (GSi) virus scanning service supplied exclusively by Energis in partnership with MessageLabs. On leaving the GSi this email was certified virus-free -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040630/9f7d7a17/attachment.html From greg.lindstrom at novasyshealth.com Tue Jun 22 15:01:53 2004 From: greg.lindstrom at novasyshealth.com (Greg Lindstrom) Date: Fri Jul 2 10:53:15 2004 Subject: [python-win32] Connecting to MySQL Message-ID: <000701c4588b$628cce70$054b12ac@D18SYX41> Hello- I am running MySQL 4. (just pulled it today) on Windows XP "Professional". What package(s) is/are available to connect to it from Python and how do I go about doing it? Thanks! --greg Greg Lindstrom (501) 975-4859 NovaSys Health greg.lindstrom@novasyshealth.com "We are the music makers, and we are the dreamers of dreams" W.W. From Peter.Winstanley at scotland.gsi.gov.uk Fri Jun 25 04:14:05 2004 From: Peter.Winstanley at scotland.gsi.gov.uk (Peter.Winstanley@scotland.gsi.gov.uk) Date: Fri Jul 2 10:53:18 2004 Subject: [python-win32] Converting VB to Python Message-ID: <5D7E001D106BA1468625E7905D088F4F0D3369@MC25GLG.scotland.gov.uk> ******************************************************************************************************************************************************* This email and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed. ******************************************************************************************************************************************************* I would be grateful for help and advice on the following: I am trying to convert into Python an example VB program that uses MSXML 4.0 and the SAXXMLReader40 and XMLSchemaCache40 to validate an XML file against an XSD schema and to provide exhaustive errors. The routine is given here: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q315497 In the VB version a class module is created to act as an error handler. The class starts with the statement "Implements MSXML2.IVBSAXErrorHandler" How do I convert an "Implements" statement to Python? Thanks for your help The original of this email was scanned for viruses by the Government Secure Intranet (GSi) virus scanning service supplied exclusively by Energis in partnership with MessageLabs. On leaving the GSi this email was certified virus-free -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040625/f95f5abd/attachment-0001.html From Peter.Winstanley at scotland.gsi.gov.uk Fri Jun 25 05:27:20 2004 From: Peter.Winstanley at scotland.gsi.gov.uk (Peter.Winstanley@scotland.gsi.gov.uk) Date: Fri Jul 2 10:53:19 2004 Subject: [python-win32] FW: Converting VB to Python Message-ID: <5D7E001D106BA1468625E7905D088F4FE592EC@MC25GLG.scotland.gov.uk> ******************************************************************************************************************************************************* This email and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed. ******************************************************************************************************************************************************* > I would be grateful for help and advice on the following: > > I am trying to convert into Python an example VB program that uses > MSXML 4.0 and the SAXXMLReader40 and XMLSchemaCache40 to validate an > XML file against an XSD schema and to provide exhaustive errors. The > routine is given here: > http://support.microsoft.com/default.aspx?scid=kb;en-us;Q315497 > > In the VB version a class module is created to act as an error > handler. The class starts with the statement > > "Implements MSXML2.IVBSAXErrorHandler" > > > How do I convert an "Implements" statement to Python? > > Thanks for your help > > > The original of this email was scanned for viruses by the Government Secure Intranet (GSi) virus scanning service supplied exclusively by Energis in partnership with MessageLabs. On leaving the GSi this email was certified virus-free -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040625/dd97fb01/attachment-0001.html From bac at OCF.Berkeley.EDU Tue Jun 29 15:01:54 2004 From: bac at OCF.Berkeley.EDU (Brett Cannon) Date: Fri Jul 2 10:53:21 2004 Subject: [python-win32] Any way to get PyHANDLE for any running process? Message-ID: <40E1BCA2.5080802@ocf.berkeley.edu> I am having a problem of a process not closing when it should, actually stemming from IE's COM object, and it prevents me from creating another IE COM object. I would like to have some way to check if IEXPLORE.EXE is already running, and if so, then kill it. I noticed win32process.TerminateProcess(), but it wants a PyHANDLE and I can't figure out how to create one for any process other than the currently running one. Any help on this would be great. Already sick of doing it manually through the Task Manager. -Brett From Peter.Winstanley at scotland.gsi.gov.uk Wed Jun 30 02:19:13 2004 From: Peter.Winstanley at scotland.gsi.gov.uk (Peter.Winstanley@scotland.gsi.gov.uk) Date: Fri Jul 2 10:53:24 2004 Subject: [python-win32] Converting VB to Python Message-ID: <5D7E001D106BA1468625E7905D088F4FE592F6@MC25GLG.scotland.gov.uk> ******************************************************************************************************************************************************* This email and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed. ******************************************************************************************************************************************************* > I would be grateful for help and advice on the following: > > I am trying to convert into Python an example VB program that uses > MSXML 4.0 and the SAXXMLReader40 and XMLSchemaCache40 to validate an > XML file against an XSD schema and to provide exhaustive errors. The > routine is given here: > http://support.microsoft.com/default.aspx?scid=kb;en-us;Q315497 > > In the VB version a class module is created to act as an error > handler. The class starts with the statement > > "Implements MSXML2.IVBSAXErrorHandler" > > > How do I convert an "Implements" statement to Python? > > Thanks for your help > > > The original of this email was scanned for viruses by the Government Secure Intranet (GSi) virus scanning service supplied exclusively by Energis in partnership with MessageLabs. On leaving the GSi this email was certified virus-free -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20040630/e2663339/attachment.html