From davesum99 at yahoo.com Tue Feb 1 05:43:05 2005 From: davesum99 at yahoo.com (david sumner) Date: Tue Feb 1 16:02:19 2005 Subject: [python-win32] Re: using MCI and related interfaces with pywin32 Message-ID: <20050201044306.3546.qmail@web31008.mail.mud.yahoo.com> On Sun, 30 Jan 2005 12:41:31 -0800 (PST) marek sez: >def mci(): > import ctypes > wm = ctypes.windll.WINMM > wm.mciSendStringA("Set CDAudio Door Open wait", 0, 0, 0) > wm.mciSendStringA("Set CDAudio Door Closed wait", 0, 0, 0) >I used this to open my cdrom tray. >It uses whe winmm.dll and ctypes (which is always a >nice thing to have) thx. ctypes rox! __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From williams13 at llnl.gov Tue Feb 1 11:38:05 2005 From: williams13 at llnl.gov (Dean N. Williams) Date: Tue Feb 1 16:02:20 2005 Subject: [python-win32] Building Python with Tcl/Tk on Cygwin Message-ID: <41FF5C0D.7080706@llnl.gov> Dear Python Community, I am trying to build Python with Tcl/Tk under the Cygwin_NT-5.1. Has anyone done this? Do I need to build tcl8.4.9 and tk8.4.9 under the unix directory or the win directory. I found that the unix directory worked just fine, and it built the libtcl8.4.a and libtk8.4.a libraries for use. But I don't think that Python is looking for this. If you've built Python with Tcl/Tck, is it possible for you to send me instructions on how you did it? Thanks in advance... Best regards, Dean P.S. "I'm trying to build on a Dell Latitude D600 laptop running Windows NT. I installed CYGWIN_NT-5.1 and Python 2.4." From jim.mccoy at gmail.com Tue Feb 1 23:12:35 2005 From: jim.mccoy at gmail.com (Jim McCoy) Date: Tue Feb 1 23:12:38 2005 Subject: [python-win32] Creating a COM singleton Message-ID: I am having a very difficult time enforcing a single running instance of a COM server and am hoping that someone out there might have a suggestion. The basic scenario is that we have a COM server (created with the assistance of win32com.server) which needs to perform a somewhat laborious data loading process when started. The problem is that a dll which makes calls to this COM server was spawning off a new server every time it called in a query. We eliminated part of the crushing burden of constantly spawned COM server instances by moving the heavy lifting into a singleton (the simple module-level singleton pattern) and having each COM server attach to this singleton. This solved our first problem with the start-up load but we still end up with way to many instances of our proxy to this singleton being created and wanted to figure out a way to make sure that only a single instance of this proxy was created. So,l first tried using the standard CreateMutex recipe to ensure that only one instance of the COM server would be created. Unfortunately this particular process works fine when I run a test script from the command line but the COM server is able to blow right by any attempts to use the mutex to limit the number of copies that are running. Next up was an attempt to create a lockfile. Same end-result, nothing seemed to stop the COM servers from each grabbing what was thought to be an exclusive lock. At this point I have run out of ideas. Does anyone have a suggestion of how to create a COM server in Python that can ensure that only a single instance of the COM server is running? Regards, Jim From guy at r-e-d.co.nz Wed Feb 2 11:18:04 2005 From: guy at r-e-d.co.nz (Guy Robinson) Date: Wed Feb 2 11:18:13 2005 Subject: [python-win32] Shellfolder.ParseDisplayName problem Message-ID: <4200A8DC.2050103@r-e-d.co.nz> Hello, I'm trying to get a handle to a file using parseDisplayName: sh = pythoncom.CoCreateInstance(shell.CLSID_ShellFSFolder, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellFolder) objtup = sh.ParseDisplayName(None,1,"E:\extractimage\sheet.txt") But I get an error: ""TypeError: an integer is required"" which I assume relates to the pbcReserved parameter. It wants a PyIBindCtx according to the documentation. How do I create the correct value for this? Any help appreciated. Regard, Guy From mhammond at skippinet.com.au Wed Feb 2 13:03:13 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed Feb 2 13:03:19 2005 Subject: [python-win32] Shellfolder.ParseDisplayName problem In-Reply-To: <4200A8DC.2050103@r-e-d.co.nz> Message-ID: <04f301c5091f$2c81afe0$050a0a0a@enfoldsystems.local> As indicated in the docs, ParseDisplayName takes 3 params - hwnd, bindContext, displayName. You are passing None for the hwnd, which is invalid. You probably want to pass (0, None, r"e:\...") Also documented, the return value is a tuple of (cchEaten, pidl, attr) - see the MS docs for this interface for details on what these actually are. Note that none are a "handle" to the file - the only useful thing coming back is a PIDL, which is only useful when passed back to other shell functions. Mark. > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of Guy Robinson > Sent: Wednesday, 2 February 2005 9:18 PM > To: python-win32@python.org > Subject: [python-win32] Shellfolder.ParseDisplayName problem > > > Hello, > > I'm trying to get a handle to a file using parseDisplayName: > > sh = pythoncom.CoCreateInstance(shell.CLSID_ShellFSFolder, > None, > pythoncom.CLSCTX_INPROC_SERVER, > shell.IID_IShellFolder) > > objtup = sh.ParseDisplayName(None,1,"E:\extractimage\sheet.txt") > > But I get an error: > > ""TypeError: an integer is required"" > > which I assume relates to the pbcReserved parameter. It wants > a PyIBindCtx > according to the documentation. > > How do I create the correct value for this? > > Any help appreciated. > > Regard, > > Guy > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From sdementen at hotmail.com Tue Feb 1 12:47:38 2005 From: sdementen at hotmail.com (Sébastien de Menten) Date: Wed Feb 2 16:32:59 2005 Subject: [python-win32] python ScriptControl error in Excel while running fine in python Message-ID: I am trying to use ScriptControl under Excel (Windows XP) with the code: Global sc As New MSScriptControl.ScriptControl Public Function os_getcwd() sc.Language = "python" sc.ExecuteStatement ("import os") os_getcwd = sc.Eval("os.getcwd()") End Function When setting the language to python I have the error "A script engine for the specified language..." On the other side, under python, the translated code: import win32com.client sc=win32com.client.Dispatch("ScriptControl") sc.Language = "python" sc.ExecuteStatement ("import os") print sc.Eval("os.getcwd()") works without any problem ! So, is it possible that a different set of permissions for languages available in ScriptControl is used when executed from Excel or from python ? Is it possible to ask the available languages to ScriptControl ? Well, in fact I am totally puzzled by this behaviour so any help is welcome :-) Sebastien PS: could you reply to my email address as I am not subscribed to the list ? thanks From jens.jorgensen at tallan.com Wed Feb 2 22:11:28 2005 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Wed Feb 2 22:11:43 2005 Subject: [python-win32] Creating a COM singleton In-Reply-To: References: Message-ID: <42014200.4070405@tallan.com> This is indeed an interesting thing do to. The 'right' way to create a singleton COM object is probably to run an NT Service that hosts the COM object. The COM Service Control Manager decides when to spin up new processes for LocalServer32 server object creation requests. You need a process to be already running and have registered the class object with the SCM. I'm not sure how to do this correctly in Python as I've only done this in C++. To get a better understanding of how this stuff works I'd recommend you take a look at Don Box's book Essential COM. I'm not sure what you were doing with the Mutex and file locking but I'm guessing all that stuff would not help since it is only getting called after the important part has happened: after the SCM has already decided to spin up a new a new process. But then again if process is already running and has registered the class object then you'd think the SCM would just forward the request to you. Sorry I can't be more help than this. I've done this same kind of thing before, but only in c++. Jim McCoy wrote: >I am having a very difficult time enforcing a single running instance >of a COM server and am hoping that someone out there might have a >suggestion. The basic scenario is that we have a COM server (created >with the assistance of win32com.server) which needs to perform a >somewhat laborious data loading process when started. The problem is >that a dll which makes calls to this COM server was spawning off a new >server every time it called in a query. We eliminated part of the >crushing burden of constantly spawned COM server instances by moving >the heavy lifting into a singleton (the simple module-level singleton >pattern) and having each COM server attach to this singleton. This >solved our first problem with the start-up load but we still end up >with way to many instances of our proxy to this singleton being >created and wanted to figure out a way to make sure that only a single >instance of this proxy was created. > >So,l first tried using the standard CreateMutex recipe to ensure that >only one instance of the COM server would be created. Unfortunately >this particular process works fine when I run a test script from the >command line but the COM server is able to blow right by any attempts >to use the mutex to limit the number of copies that are running. > >Next up was an attempt to create a lockfile. Same end-result, nothing >seemed to stop the COM servers from each grabbing what was thought to >be an exclusive lock. > >At this point I have run out of ideas. Does anyone have a suggestion >of how to create a COM server in Python that can ensure that only a >single instance of the COM server is running? > >Regards, > >Jim >_______________________________________________ >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 -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 2861 bytes Desc: S/MIME Cryptographic Signature Url : http://mail.python.org/pipermail/python-win32/attachments/20050202/beca8acb/smime.bin From jim.mccoy at gmail.com Wed Feb 2 23:23:14 2005 From: jim.mccoy at gmail.com (Jim McCoy) Date: Wed Feb 2 23:23:17 2005 Subject: [python-win32] Creating a COM singleton In-Reply-To: <42014200.4070405@tallan.com> References: <42014200.4070405@tallan.com> Message-ID: Argh! Well, it turns out that the real problem was that when creating a mutex for a module-level singleton you should not store a ref to the handle in an instance that might find itself getting popped. Assign to a class variable that will stick. D'oh! I will take a look at setting up the COM object as a service. One question that pops up is whether such a service would run "as the local user"? We use the COM service as an authentication bridge between an agent service that is always running in the background (but runs as the admin) and various users on the system. Hmmm, something to check out. Jim On Wed, 02 Feb 2005 15:11:28 -0600, Jens B. Jorgensen wrote: > This is indeed an interesting thing do to. The 'right' way to create a > singleton COM object is probably to run an NT Service that hosts the COM > object. The COM Service Control Manager decides when to spin up new > processes for LocalServer32 server object creation requests. You need a > process to be already running and have registered the class object with > the SCM. I'm not sure how to do this correctly in Python as I've only > done this in C++. To get a better understanding of how this stuff works > I'd recommend you take a look at Don Box's book Essential COM. > > I'm not sure what you were doing with the Mutex and file locking but I'm > guessing all that stuff would not help since it is only getting called > after the important part has happened: after the SCM has already decided > to spin up a new a new process. But then again if process is already > running and has registered the class object then you'd think the SCM > would just forward the request to you. > > Sorry I can't be more help than this. I've done this same kind of thing > before, but only in c++. > > Jim McCoy wrote: > > >I am having a very difficult time enforcing a single running instance > >of a COM server and am hoping that someone out there might have a > >suggestion. The basic scenario is that we have a COM server (created > >with the assistance of win32com.server) which needs to perform a > >somewhat laborious data loading process when started. The problem is > >that a dll which makes calls to this COM server was spawning off a new > >server every time it called in a query. We eliminated part of the > >crushing burden of constantly spawned COM server instances by moving > >the heavy lifting into a singleton (the simple module-level singleton > >pattern) and having each COM server attach to this singleton. This > >solved our first problem with the start-up load but we still end up > >with way to many instances of our proxy to this singleton being > >created and wanted to figure out a way to make sure that only a single > >instance of this proxy was created. > > > >So,l first tried using the standard CreateMutex recipe to ensure that > >only one instance of the COM server would be created. Unfortunately > >this particular process works fine when I run a test script from the > >command line but the COM server is able to blow right by any attempts > >to use the mutex to limit the number of copies that are running. > > > >Next up was an attempt to create a lockfile. Same end-result, nothing > >seemed to stop the COM servers from each grabbing what was thought to > >be an exclusive lock. > > > >At this point I have run out of ideas. Does anyone have a suggestion > >of how to create a COM server in Python that can ensure that only a > >single instance of the COM server is running? > > > >Regards, > > > >Jim > >_______________________________________________ > >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 glee at pharsight.com Wed Feb 2 23:55:12 2005 From: glee at pharsight.com (Greg Lee) Date: Thu Feb 3 17:28:38 2005 Subject: [python-win32] Working with a PyIDispatch object Message-ID: <08AAC77C2656414E91980F8EBB1E7F01037EFA3D@electra.corp.pharsight.com> I'm using MSXML2.SAXXMLReader.4.0 to validate XML. Following a hint posted July 2 by the estimable Mark Hammond, I implemented the error handler thus: class MyErrorHandler: _com_interfaces_ = ['IVBSAXErrorHandler'] _public_methods_ = ['error', 'fatalError', 'ignorableWarning'] def error(self, locator, strError, nErrorCode): .... When the error method is called, the locator turns out to be a PyIDispatch object for a win32com.gen_py.Microsoft XML, v4.0.IVBSAXLocator instance. The only way I've found to decode this locator is via the Invoke method, e.g.: def error(self, locator, strError, nErrorCode): id = locator.GetIDsOfNames('columnNumber') colno = locator.Invoke(id, 0x0, pythoncom.DISPATCH_PROPERTYGET, 1) ... 1. Is there a better way to do this? 2. What are the parameters for the Invoke method? I worked this out experimentally from win32com/dynamic.py, but I'd be happier knowing what the "1" means. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050202/8c3cce88/attachment.html From jens.jorgensen at tallan.com Thu Feb 3 17:41:55 2005 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Thu Feb 3 17:42:08 2005 Subject: [python-win32] Creating a COM singleton In-Reply-To: References: <42014200.4070405@tallan.com> Message-ID: <42025453.3000203@tallan.com> Jim McCoy wrote: >Argh! Well, it turns out that the real problem was that when creating >a mutex for a module-level singleton you should not store a ref to the >handle in an instance that might find itself getting popped. Assign >to a class variable that will stick. D'oh! > >I will take a look at setting up the COM object as a service. One >question that pops up is whether such a service would run "as the >local user"? We use the COM service as an authentication bridge >between an agent service that is always running in the background (but >runs as the admin) and various users on the system. Hmmm, something >to check out. > > Yes, this can be a problem. It's not strictly necessary of course to run as a service. The process could just ensure that once it starts it stays around. Then you'd have a question of when the process should go out of scope. In any case the key thing is to make sure that that class object stays registered with the SCM so it can be re-used. Then the class object itself needs to return the same object. It may be easier to have 2 different objects. One COM object would be the 'factory' object that would return a reference to the singleton class. Or, perhaps you're already doing this. That way you can control the creation of the singleton object in your own code. -- 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 -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 2861 bytes Desc: S/MIME Cryptographic Signature Url : http://mail.python.org/pipermail/python-win32/attachments/20050203/c583479a/smime.bin From mhammond at skippinet.com.au Fri Feb 4 03:08:20 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri Feb 4 03:08:29 2005 Subject: [python-win32] Working with a PyIDispatch object In-Reply-To: <08AAC77C2656414E91980F8EBB1E7F01037EFA3D@electra.corp.pharsight.com> Message-ID: <074301c50a5e$669f32c0$050a0a0a@enfoldsystems.local> You can convert it to a "friendly" object simply by doing: locator = win32com.client.Dispatch(locator) If you want to ensure early binding, try: locator = win32com.client.gencache.EnsureDispatch(locator) That should generate a makepy file for the interface on the fly (but doesn't work for all objects - suck it and see :) Mark -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org]On Behalf Of Greg Lee Sent: Thursday, 3 February 2005 9:55 AM To: python-win32@python.org Subject: [python-win32] Working with a PyIDispatch object I'm using MSXML2.SAXXMLReader.4.0 to validate XML. Following a hint posted July 2 by the estimable Mark Hammond, I implemented the error handler thus: class MyErrorHandler: _com_interfaces_ = ['IVBSAXErrorHandler'] _public_methods_ = ['error', 'fatalError', 'ignorableWarning'] def error(self, locator, strError, nErrorCode): .... When the error method is called, the locator turns out to be a PyIDispatch object for a win32com.gen_py.Microsoft XML, v4.0.IVBSAXLocator instance. The only way I've found to decode this locator is via the Invoke method, e.g.: def error(self, locator, strError, nErrorCode): id = locator.GetIDsOfNames('columnNumber') colno = locator.Invoke(id, 0x0, pythoncom.DISPATCH_PROPERTYGET, 1) ... 1. Is there a better way to do this? 2. What are the parameters for the Invoke method? I worked this out experimentally from win32com/dynamic.py, but I'd be happier knowing what the "1" means. -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 4796 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050204/05d05588/winmail.bin From mhammond at skippinet.com.au Fri Feb 4 03:11:15 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri Feb 4 03:11:27 2005 Subject: [python-win32] python ScriptControl error in Excel while runningfine in python In-Reply-To: Message-ID: <074701c50a5e$cf43d560$050a0a0a@enfoldsystems.local> > I am trying to use ScriptControl under Excel (Windows XP) > with the code: > > Global sc As New MSScriptControl.ScriptControl > > Public Function os_getcwd() > sc.Language = "python" > sc.ExecuteStatement ("import os") > os_getcwd = sc.Eval("os.getcwd()") > End Function > > When setting the language to python I have the error "A > script engine for > the specified language..." > > On the other side, under python, the translated code: > > import win32com.client > > sc=win32com.client.Dispatch("ScriptControl") > sc.Language = "python" > sc.ExecuteStatement ("import os") > print sc.Eval("os.getcwd()") > > works without any problem ! > > So, is it possible that a different set of permissions for languages > available in ScriptControl is used when executed from Excel > or from python ? > Is it possible to ask the available languages to ScriptControl ? I'm guessing that Excel is adding some restriction to the languages that can be used - maybe only those marked "safe for scripting". If you register the ActiveScript engine with debugging (win32comext\axscript\client\pyscript.py --debug), and view the Pythonwin "Remote Trace Collector" tool, you may end up with additional clues - eg, maybe Python is being instantiated, but then queried for an unknown interface, or an attempt is made to make the engine "restricted", which would fail. Mark From jiangsy at utstar.com Fri Feb 4 09:25:49 2005 From: jiangsy at utstar.com (Jiang Shanyi) Date: Fri Feb 4 17:31:36 2005 Subject: [python-win32] Hello everybody, I am a Python lover from china and I'm new to this mail list Message-ID: <90625507C4259B4CBF2FBDC3CF0AB3DC4122E3@CNMAIL12.cn.utstarcom.com> Best regards to every body. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050204/0fd98bf1/attachment.htm From sdementen at hotmail.com Fri Feb 4 16:55:58 2005 From: sdementen at hotmail.com (Sébastien de Menten) Date: Fri Feb 4 17:31:56 2005 Subject: [python-win32] python ScriptControl error in Excel while runningfine in python In-Reply-To: <074701c50a5e$cf43d560$050a0a0a@enfoldsystems.local> Message-ID: > > I am trying to use ScriptControl under Excel (Windows XP) > > with the code: > > > > Global sc As New MSScriptControl.ScriptControl > > > > Public Function os_getcwd() > > sc.Language = "python" > > sc.ExecuteStatement ("import os") > > os_getcwd = sc.Eval("os.getcwd()") > > End Function > > > > When setting the language to python I have the error "A > > script engine for > > the specified language..." > > > > On the other side, under python, the translated code: > > > > import win32com.client > > > > sc=win32com.client.Dispatch("ScriptControl") > > sc.Language = "python" > > sc.ExecuteStatement ("import os") > > print sc.Eval("os.getcwd()") > > > > works without any problem ! > > > > So, is it possible that a different set of permissions for languages > > available in ScriptControl is used when executed from Excel > > or from python ? > > Is it possible to ask the available languages to ScriptControl ? > >I'm guessing that Excel is adding some restriction to the languages that >can >be used - maybe only those marked "safe for scripting". > >If you register the ActiveScript engine with debugging >(win32comext\axscript\client\pyscript.py --debug), and view the Pythonwin >"Remote Trace Collector" tool, you may end up with additional clues - eg, >maybe Python is being instantiated, but then queried for an unknown >interface, or an attempt is made to make the engine "restricted", which >would fail. With debug enabled, I see the trace in the "Remote Trace Collector" when running the python script. But nothing happens when I run the VBA excel macro. I guess the security feature is higher in the stack of calls but I do not have a clue on how to change it. > >Mark > From robin at reportlab.com Sat Feb 5 14:10:08 2005 From: robin at reportlab.com (Robin Becker) Date: Sat Feb 5 14:09:42 2005 Subject: [python-win32] MFC71.dll Message-ID: <4204C5B0.4070302@jessikat.fsnet.co.uk> I guess I must have missed something out in my installation, any how, after flushing 2.3 from my home pc and reinstalling with 2.4 versions of my favourites I find that Pythonwin.exe has a missing dependency on MFC71.dll is this a known problem? The installer I used is pywin32-203.win32-py2.4.exe. -- Robin Becker From steve at holdenweb.com Sat Feb 5 14:18:30 2005 From: steve at holdenweb.com (Steve Holden) Date: Sat Feb 5 14:24:15 2005 Subject: [python-win32] MFC71.dll In-Reply-To: <4204C5B0.4070302@jessikat.fsnet.co.uk> References: <4204C5B0.4070302@jessikat.fsnet.co.uk> Message-ID: <4204C7A6.9050802@holdenweb.com> Robin Becker wrote: > I guess I must have missed something out in my installation, any how, > after flushing 2.3 from my home pc and reinstalling with 2.4 versions of > my favourites I find that Pythonwin.exe has a missing dependency on > MFC71.dll is this a known problem? The installer I used is > pywin32-203.win32-py2.4.exe. Yes, it's a known issue. See "MFC DLLs for PythonWin" on http://starship.python.net/crew/mhammond/win32/ regards Steve -- Steve Holden http://www.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 Python Web Programming http://pydish.holdenweb.com/ From tdsullivan at rogers.com Sat Feb 5 17:45:10 2005 From: tdsullivan at rogers.com (TREVOR SULLIVAN) Date: Sat Feb 5 17:44:03 2005 Subject: [python-win32] Printing out a given number of prime numbers. Message-ID: <000201c50ba2$0f035010$3d3ea8c0@develop> This is purely an academic query. I would like a recipe for printing out X number of prime numbers. I can do this quite easily with Java but not with Python 2.4. [ I am fairly new to Python]. I can print out primes up to given integer number, say for example 50, but not 50 prime numbers. Any help would be appreciated. Thanks, Trevor. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.8.5 - Release Date: 2/3/2005 From alastique at gmail.com Sat Feb 5 18:26:04 2005 From: alastique at gmail.com (Anthony Lastique) Date: Sat Feb 5 18:26:07 2005 Subject: [python-win32] Printing out a given number of prime numbers. In-Reply-To: <000201c50ba2$0f035010$3d3ea8c0@develop> References: <000201c50ba2$0f035010$3d3ea8c0@develop> Message-ID: <5ed9b7e005020509266b1a6d36@mail.gmail.com> On Sat, 5 Feb 2005 11:45:10 -0500, TREVOR SULLIVAN wrote: > This is purely an academic query. I would like a recipe for printing out X > number of prime numbers. I can do this quite easily with Java but not with > Python 2.4. [ I am fairly new to Python]. I can print out primes up to given > integer number, say for example 50, but not 50 prime numbers. > Any help would be appreciated. Thanks, > Trevor. > > -- > No virus found in this outgoing message. > Checked by AVG Anti-Virus. > Version: 7.0.300 / Virus Database: 265.8.5 - Release Date: 2/3/2005 > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > You aren't in the good group, but this should resolv ur problem regards.. -------------- next part -------------- A non-text attachment was scrubbed... Name: premier.py Type: application/octet-stream Size: 620 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050205/7f7d277e/premier.obj From rvm_1380 at yahoo.com Sun Feb 6 17:41:26 2005 From: rvm_1380 at yahoo.com (rozita raissi) Date: Sun Feb 6 17:41:30 2005 Subject: [python-win32] Download a file from FTP server to local machine Message-ID: <20050206164126.75026.qmail@web60209.mail.yahoo.com> Hello, I'm writing an ftp client script which must run in explorer. My script must be placed on and run from a web server. User can connect through it to a FTP server. If user requests to download a file from FTP server, file is downloaded to web server on which my script is running. How can I transfere downloaded file from web server to client local machine? Regards. --------------------------------- Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050206/51cccbe1/attachment.html From chris.stromberger at gmail.com Mon Feb 7 15:12:05 2005 From: chris.stromberger at gmail.com (Chris Stromberger) Date: Mon Feb 7 15:12:08 2005 Subject: [python-win32] Changing desktop color Message-ID: How can I change the desktop color? I want to set it to black. Can be just for the current session. Thanks, Chris http://www.fetidcascade.com/ From timr at probo.com Mon Feb 7 20:16:48 2005 From: timr at probo.com (Tim Roberts) Date: Mon Feb 7 20:16:49 2005 Subject: [python-win32] Re: Download a file from FTP server to local machine In-Reply-To: <20050207110118.0D7041E4012@bag.python.org> References: <20050207110118.0D7041E4012@bag.python.org> Message-ID: <4207BEA0.1010208@probo.com> On Sun, 6 Feb 2005 16:41:26 +0000 (GMT), rozita raissi wrote:: > >I'm writing an ftp client script which must run in explorer. My script must be placed on and run from a web server. User can connect through it to a FTP server. If user requests to download a file from FTP server, file is downloaded to web server on which my script is running. How can I transfere downloaded file from web server to client local machine? > So, basically, you want an FTP-to-HTTP gateway? A CGI script which fetches from an FTP site and relays it to the user? That isn't hard at all. Just define the Content-Type appropriately (application/binary if nothing else) and copy the fetched file to the script's stdout. But as an alternative, I would think it would be easier just to redirect to the FTP site and let IE do the download: print "Refresh: 0;URL=ftp://myftp.mysite.com/dir1/dir2/myfile.txt" -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From tim.golden at viacom-outdoor.co.uk Tue Feb 8 12:36:08 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Feb 8 12:33:59 2005 Subject: [python-win32] Changing desktop color Message-ID: <9A28C052FF32734DACB0A288A3533991035A6B@vogbs009.gb.vo.local> [Chris Stromberger] | How can I change the desktop color? I want to set it to black. Can | be just for the current session. Couple of options, neither from experience, just general knowledge. So YMM definitely V. 1) Investigate the SystemParametersInfo win32 function. That does quite a few things to do with the desktop, although not obviously the background colour. (There are things to do with wallpaper and so on). 2) Get the desktop window's window handle using GetDesktopWindow or its device context with GetDC (0) and do something with that. 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 rwupole at msn.com Tue Feb 8 15:26:58 2005 From: rwupole at msn.com (Roger Upole) Date: Tue Feb 8 15:28:25 2005 Subject: [python-win32] Re: Changing desktop color References: Message-ID: The Api call is SetSysColors. (not in pywin32 anywhere yet) You might be able to do something with ctypes. There's also a registry setting under HKCU\Control Panel\Colors if you want to change it permanently. hth Roger ----- Original Message ----- From: "Chris Stromberger" To: Sent: Monday, February 07, 2005 9:12 AM Subject: [python-win32] Changing desktop color > How can I change the desktop color? I want to set it to black. Can > be just for the current session. > > Thanks, > Chris > > http://www.fetidcascade.com/ > > From rays at blue-cove.com Tue Feb 8 19:44:33 2005 From: rays at blue-cove.com (Ray S) Date: Tue Feb 8 19:45:22 2005 Subject: [python-win32] launching an exe reboots XP... Message-ID: <5.2.0.4.2.20050208094606.044bf790@blue-cove.com> I'm trying to launch a 3rd party analyzer .exe on XP; double-clicking in explorer runs as normal. From Python, I've tried startfile(), system(), spawnl(), and popen(), with various modes, from scripts and command session. All start the program's GUI to load, then generate a "Data integrity has been compromised! Return to DOS?" error; clicking either Yes or No immediately reboots XP. The process can be killed from the task manager. os.startfile should "act like double-clicking the file in Windows Explorer", but it seems to not be the case. Is there a Win32 method that might be effective? I tried win32api.WinExec, win32process.CreateProcess (with various modes), same effect. Ray Schumacher -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050208/ed987243/attachment.htm From gagenellina at softlab.com.ar Wed Feb 9 02:57:20 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Wed Feb 9 02:58:01 2005 Subject: [python-win32] Changing desktop color (Chris Stromberger) In-Reply-To: <20050208110010.AC8AA1E4031@bag.python.org> References: <20050208110010.AC8AA1E4031@bag.python.org> Message-ID: <6.2.0.14.0.20050208213806.02ebb9e0@192.168.0.115> At Tuesday 8/2/2005 08:00, python-win32-request@python.org wrote: >How can I change the desktop color? I want to set it to black. Can >be just for the current session. SetSysColors: Ouch, unfortunately that function isn't available thru win32all Using ctypes: from ctypes.wintypes import windll, c_int, byref, RGB COLOR_BACKGROUND = 1 # from winuser.h or win32con SetSysColors = windll.user32.SetSysColors which_color = RGB(255,0,0) # red SetSysColors(1, byref(c_int(COLOR_BACKGROUND)), byref(c_int(which_color))) Gabriel Genellina Softlab SRL From harald.massa at suedvers.de Wed Feb 9 13:19:31 2005 From: harald.massa at suedvers.de (Massa, Harald) Date: Wed Feb 9 13:19:38 2005 Subject: [python-win32] pythonw.exe hardcrash on py2exe wmi-sample / Pythin 2.4 Message-ID: <8EC7886AFFBC4748A75B124B1C2D7F1618CC2F@EXCH2.suedvers.local> (xposting from py2exe users) Hello, I just upgraded my system to Python 2.4. I tried to do an former 2.3-setup.py script to repackage my application within Python 2.4 This application uses wmi and therefor has an typelib-argumentlist. on **generating typelib stubs** the run fails. I went down to py2exe/samples/advanced where the wmitest is, and used the setup.py there. same error. py2exe tries to generate typelib stubs, and crashes HARD. Not a simple traceback, but """Fehler in Anwendung" ... "Die Anweisung in 0x1e03ab43??verweist auf Speicher in "0x34202c39". Der Vorgang "read" konnte nicht auf dem Speicher duchgef??hrt werden.""" (that is the german error from windows, when Memory at not allowed areas is being accessed) After that, only "ok" and "Abbrechen" (which do the same :( ) I tracked that down to the line (in build_exe) makepy.GenerateFromTypeLibSpec(info, bForDemand = False) that is the one that crashes badly. It kills everything ... I put debugging-prints around it, and even the debugging-prints immediately before are not flushed to stdout anymor. What can I do? OS is Windows XP prof SP2, acual updates. Is there an old pywin32 bug exposed just through sp2?? Harald -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050209/56bae1a3/attachment.html From theller at python.net Wed Feb 9 15:10:47 2005 From: theller at python.net (Thomas Heller) Date: Wed Feb 9 15:09:35 2005 Subject: [python-win32] Re: pythonw.exe hardcrash on py2exe wmi-sample / Pythin 2.4 References: <8EC7886AFFBC4748A75B124B1C2D7F1618CC2F@EXCH2.suedvers.local> Message-ID: "Massa, Harald" writes: > (xposting from py2exe users) > > > Hello, > > I just upgraded my system to Python 2.4. I tried to do an former > 2.3-setup.py script to repackage my application within Python 2.4 > > > This application uses wmi and therefor has an typelib-argumentlist. > > on **generating typelib stubs** the run fails. I went down to > py2exe/samples/advanced where the wmitest is, and used the setup.py there. > > same error. py2exe tries to generate typelib stubs, and crashes HARD. > Not a simple traceback, but > > """Fehler in Anwendung" ... "Die Anweisung in 0x1e03ab43??verweist auf > Speicher in "0x34202c39". Der Vorgang "read" konnte nicht auf dem > Speicher duchgef??hrt werden.""" > > > (that is the german error from windows, when Memory at not allowed areas > is being accessed) > > After that, only "ok" and "Abbrechen" (which do the same :( ) > > I tracked that down to the line (in build_exe) > > makepy.GenerateFromTypeLibSpec(info, bForDemand = False) > > that is the one that crashes badly. It kills everything ... I put > debugging-prints around it, and even the debugging-prints immediately > before are not flushed to stdout anymor. > > What can I do? OS is Windows XP prof SP2, acual updates. Is there an old > pywin32 bug exposed just through sp2?? I seem to rememeber that this was a problem, reported somewhere, with makepy generating source code with line length > 512 characters, and / or had it to do something with the coding declaration at the top of the file? And could it be that the bForDemand=... value did also have something to do with it? And did it only occur with Python 2.4? But I don't remember more details... Thomas From rwupole at msn.com Wed Feb 9 17:29:48 2005 From: rwupole at msn.com (Roger Upole) Date: Wed Feb 9 17:29:54 2005 Subject: [python-win32] Re: pythonw.exe hardcrash on py2exe wmi-sample / Pythin Message-ID: This is caused by a bug in Python's tokenizer. See sourceforge bug # [ 1085454 ] for details and a workaround. Roger From gabrielcnr at gmail.com Wed Feb 9 21:06:23 2005 From: gabrielcnr at gmail.com (Gabriel Reis) Date: Wed Feb 9 21:06:31 2005 Subject: [python-win32] Getting path+executable associated with a process Message-ID: <1f2e8c7205020912066b5ac131@mail.gmail.com> Hi, I want to get the executable filename and its path from a process. Imagine that I have an application installed in two different directories. The rule is: the user can't run an instance of this application if another instance, from the *same* directory, is already running. I've read PyWin32 documentation and browsed this maillist's history and I couldn't find anything specifically. With the method MakeCounterPath I can get information (items) such as Memory, Process ID or % CPU... so I am wondering if I can get the executable path too, once I have the PID. Best regards, Gabriel Reis From rwupole at msn.com Wed Feb 9 21:23:28 2005 From: rwupole at msn.com (Roger Upole) Date: Wed Feb 9 21:23:32 2005 Subject: [python-win32] Re: Getting path+executable associated with a process Message-ID: These functions in win32process should be able to get that for you: OpenProcess, EnumProcessModules and GetModuleFileNameEx The executable will be the first module returned from EnumProcessModules. Roger Gabriel Reis wrote: > Hi, > > I want to get the executable filename and its path from a process. > Imagine that I have an application installed in two different > directories. The rule is: the user can't run an instance of this > application if another instance, from the *same* directory, is already > running. > > I've read PyWin32 documentation and browsed this maillist's history > and I couldn't find anything specifically. With the method > MakeCounterPath I can get information (items) such as Memory, Process > ID or % CPU... so I am wondering if I can get the executable path too, > once I have the PID. > > Best regards, > > Gabriel Reis From gabrielcnr at gmail.com Thu Feb 10 14:48:37 2005 From: gabrielcnr at gmail.com (Gabriel Reis) Date: Thu Feb 10 14:48:40 2005 Subject: [python-win32] Re: Getting path+executable associated with a process In-Reply-To: References: Message-ID: <1f2e8c72050210054818e35c22@mail.gmail.com> Hi again, thanks for the tips. I didn't use EnumProcessModules, but I got the solution as shown below: import win32api, win32con, win32process def IsRunning(filename): processes = win32process.EnumProcesses() # get PID list for pid in processes: try: handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, False, pid) exe = win32process.GetModuleFileNameEx(handle, 0) if exe.lower() == filename.lower(): return True except: pass return False This function gets a 'filename' (full path to the executable file) and compares it to each process' executable name. It is very useful to determine wheter a program is running or not. E.g.: IsRunning('C:\\Program Files\\Mozilla Firefox\\firefox.exe') should return True, if Firefox browser is opened. Thanks again, Gabriel Reis Reason Tecnologia S.A. - http://www.reason.com.br/ Florianopolis, SC, Brazil On Wed, 9 Feb 2005 15:23:28 -0500, Roger Upole wrote: > These functions in win32process should be able to get that for you: > OpenProcess, EnumProcessModules and GetModuleFileNameEx > The executable will be the first module returned from EnumProcessModules. > Roger > > > Gabriel Reis wrote: > > Hi, > > > > I want to get the executable filename and its path from a process. > > Imagine that I have an application installed in two different > > directories. The rule is: the user can't run an instance of this > > application if another instance, from the *same* directory, is already > > running. > > > > I've read PyWin32 documentation and browsed this maillist's history > > and I couldn't find anything specifically. With the method > > MakeCounterPath I can get information (items) such as Memory, Process > > ID or % CPU... so I am wondering if I can get the executable path too, > > once I have the PID. > > > > Best regards, > > > > Gabriel Reis > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From thaddon at equilar.com Thu Feb 10 23:33:50 2005 From: thaddon at equilar.com (Tom Haddon) Date: Thu Feb 10 23:33:53 2005 Subject: [python-win32] Memory Usage for Processes Message-ID: <0E52D69E86D25840AAE3611CB657F9F83658BB@millenium.equilar.com> Hi Folks, I'm trying to get memory usage for all processes on a windows box and then later on I want to set up alerts if certain applications are using over a certain amount of memory. Here's what I have so far, but it's not working as expected. Any help appreciated. Basically it looks like my problem is in getting the process handle... Thanks, Tom import win32process import win32api class WinProcesses: def __init__(self): pass def listprocesses(self): for process in self.proclist(): try: han = win32api.OpenProcess(1, 0, process) print self.meminfo(han) except: print "Couldn't get process %s" % (process,) def proclist(self): return win32process.EnumProcesses() def meminfo(self, handle): return win32process.GetProcessMemoryInfo(handle) if __name__=="__main__": processes = WinProcesses() test = processes.listprocesses() print test --------------------------------------- Tom Haddon Equilar, Inc. 1710 South Amphlett Boulevard Suite 312 San Mateo, CA 94402 650-286-4528 (phone) 650-286-4513 (fax) thaddon@equilar.com CONFIDENTIALITY NOTICE: This is a transmission from Equilar, Inc. and may contain information which is confidential and proprietary. If you are not the addressee, any disclosure, copying or distribution or use of the contents of this message is expressly prohibited. If you have received this transmission in error, please destroy it and notify us immediately at 650-286-4512. Internet and e-mail communications are Equilar's property and Equilar reserves the right to retrieve and read any message created, sent and received. From rwupole at msn.com Fri Feb 11 01:51:22 2005 From: rwupole at msn.com (Roger Upole) Date: Fri Feb 11 01:51:30 2005 Subject: [python-win32] Re: Memory Usage for Processes Message-ID: You'll need to specify more access in OpenProcess. It's 1 now, which is only PROCESS_TERMINATE. Most likely you're getting an access denied in the GetProcessMemoryInfo call. (This is why a bare except: is not generally a good thing to do) Try changing the access mode to win32con.PROCESS_QUERY_INFORMATION|win32con.PROCESS_VM_READ. hth Roger From thaddon at equilar.com Fri Feb 11 02:40:22 2005 From: thaddon at equilar.com (Tom Haddon) Date: Fri Feb 11 02:40:26 2005 Subject: [python-win32] Re: Memory Usage for Processes Message-ID: <0E52D69E86D25840AAE3611CB657F9F83658CC@millenium.equilar.com> Hi Roger, I tried both of these but was getting the following messages. Is there any way of confirming which parameter it's refering to? Could it be my "process" parameter? Thanks, Tom Traceback (most recent call last): File "C:\test\memusage.py", line 24, in ? test = processes.listprocesses() File "C:\test\memusage.py", line 11, in listprocesses han = win32api.OpenProcess(win32con.PROCESS_VM_READ, 0, process) error: (87, 'OpenProcess', 'The parameter is incorrect.') >>> Traceback (most recent call last): File "C:\test\memusage.py", line 24, in ? test = processes.listprocesses() File "C:\test\memusage.py", line 11, in listprocesses han = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION, 0, process) error: (87, 'OpenProcess', 'The parameter is incorrect.') -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org]On Behalf Of Roger Upole Sent: Thursday, February 10, 2005 4:51 PM To: python-win32@python.org Subject: [python-win32] Re: Memory Usage for Processes You'll need to specify more access in OpenProcess. It's 1 now, which is only PROCESS_TERMINATE. Most likely you're getting an access denied in the GetProcessMemoryInfo call. (This is why a bare except: is not generally a good thing to do) Try changing the access mode to win32con.PROCESS_QUERY_INFORMATION|win32con.PROCESS_VM_READ. hth Roger _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From rwupole at msn.com Fri Feb 11 03:09:19 2005 From: rwupole at msn.com (Roger Upole) Date: Fri Feb 11 03:09:45 2005 Subject: [python-win32] Re: Memory Usage for Processes References: <0E52D69E86D25840AAE3611CB657F9F83658CC@millenium.equilar.com> Message-ID: Probably. You get that error if you pass a PID for a process that no longer exists. (if you had a process exit between the calls to EnumProcesses and OpenProcess) Roger From thaddon at equilar.com Fri Feb 11 03:15:44 2005 From: thaddon at equilar.com (Tom Haddon) Date: Fri Feb 11 03:15:47 2005 Subject: [python-win32] Re: Memory Usage for Processes Message-ID: <0E52D69E86D25840AAE3611CB657F9F83658CF@millenium.equilar.com> Sorry, a little quick on the trigger there. I have it working as below (as you can see this is just testing code). I'm now having trouble retrieving the name of the process. I'm trying: win32process.GetModuleFileNameEx(handle, ) The module handle is escaping me. I've tried using the win32con.PROCESS_QUERY_INFORMATION, and then I've tried iterating through integers from 1 to 100,000 to be sure, but no dice. Am I missing something? import win32process import win32con import win32api class WinProcesses: def __init__(self): pass def listprocesses(self): for process in self.proclist(): try: han = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION, 0, process) except: han = "" if han != "": procmeminfo = self.meminfo(han) procmemusage = (procmeminfo["WorkingSetSize"]/1024) print "PID: %s Mem: %sK" % (process, procmemusage) def proclist(self): return win32process.EnumProcesses() def meminfo(self, handle): return win32process.GetProcessMemoryInfo(handle) if __name__=="__main__": processes = WinProcesses() test = processes.listprocesses() print test -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org]On Behalf Of Roger Upole Sent: Thursday, February 10, 2005 4:51 PM To: python-win32@python.org Subject: [python-win32] Re: Memory Usage for Processes You'll need to specify more access in OpenProcess. It's 1 now, which is only PROCESS_TERMINATE. Most likely you're getting an access denied in the GetProcessMemoryInfo call. (This is why a bare except: is not generally a good thing to do) Try changing the access mode to win32con.PROCESS_QUERY_INFORMATION|win32con.PROCESS_VM_READ. hth Roger _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From rwupole at msn.com Fri Feb 11 04:14:22 2005 From: rwupole at msn.com (Roger Upole) Date: Fri Feb 11 04:14:29 2005 Subject: [python-win32] Re: Memory Usage for Processes Message-ID: You'll need to use PROCESS_QUERY_INFORMATION and PROCESS_VM_READ. win32process.EnumProcessModules returns the list of module handles, with the main executable being the first one returned. Somebody also reported you can just use 0 for the module handle to get the executable. Also, on Win2k and XP I get an error trying to do do EnumProcessModules for the System process no matter what access I specify, you might have to take that into account. Roger From xavi at code4net.com Fri Feb 11 13:33:54 2005 From: xavi at code4net.com (Xavi Beumala) Date: Fri Feb 11 13:34:03 2005 Subject: [python-win32] python crash with IE Activex Message-ID: <420CA632.5080109@code4net.com> Hi all, I'm playing with the demo example ActiveXWrapper_IE.py. What I want is avoid users access some url's. To accomplish this I'm using OnBeforeNavigate2 event, returning a true value should cancel the request... def OnBeforeNavigate2(self, pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel) : self.log.write('OnBeforeNavigate2: %s\n' % URL) if URL == "http://www.microsoft.com/": return 1 The problem is that if I return a true value, python crashes :s I've been searching some info, but got no luck :( Any ideas? Thanks Xavi Beumala From scottmallory at gmail.com Fri Feb 11 18:02:32 2005 From: scottmallory at gmail.com (s mallory) Date: Fri Feb 11 18:02:36 2005 Subject: [python-win32] ScrolledMessageDialog problem Message-ID: Greetings, I am having a strange display behavior with the ScrolledMessageDialog. When I pass it a string or just type in a string, only 8 chars are visible in the upper left hand corner of the window. All of the string is there, it just doesn't display. The scroll bar behaviors as if it is working but all if the text display is only in that small area. I am using the example form wxPython 2.5. What's interesting is that it used to work just fine, but I am not sure when it broke. python 2.4 wxPython 2.5.3.1 WinXp sp 2 Thanks for any help any one can give me, Scott From russiansouljah at yahoo.com Sun Feb 13 00:33:13 2005 From: russiansouljah at yahoo.com (Ridwan Sami) Date: Sun Feb 13 00:33:16 2005 Subject: [python-win32] getting win32clipboard In-Reply-To: Message-ID: <20050212233313.9356.qmail@web50510.mail.yahoo.com> i've searched my python installation folder, and looked online, but can't seem to find the win32clipboard module. where can i download win32clipboard and other modules i may need to use it? __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com From rwupole at msn.com Sun Feb 13 01:02:40 2005 From: rwupole at msn.com (Roger Upole) Date: Sun Feb 13 01:02:45 2005 Subject: [python-win32] Re: getting win32clipboard Message-ID: It's part of the Pywin32 package: http://sourceforge.net/projects/pywin32/ (formerly known as win32all) Roger "Ridwan Sami" wrote: > i've searched my python installation folder, and looked online, but > can't seem to find the win32clipboard module. where can i download > win32clipboard and other modules i may need to use it? > > From Martin.Gfeller at comit.ch Mon Feb 14 19:41:51 2005 From: Martin.Gfeller at comit.ch (Gfeller Martin) Date: Mon Feb 14 19:41:54 2005 Subject: [python-win32] Windows Low Fragementation Heap yields speedup of ~15% Message-ID: Dear all, I'm running a large Zope application on a 1x1GHz CPU 1GB mem Window XP Prof machine using Zope 2.7.3 and Py 2.3.4 The application typically builds large lists by appending and extending them. We regularly observed that using a given functionality a second time using the same process was much slower (50%) than when it ran the first time after startup. This behavior greatly improved with Python 2.3 (thanks to the improved Python object allocator, I presume). Nevertheless, I tried to convert the heap used by Python to a Windows Low Fragmentation Heap (available on XP and 2003 Server). This improved the overall run time of a typical CPU-intensive report by about 15% (overall run time is in the 5 minutes range), with the same memory consumption. I consider 15% significant enough to let you know about it. For information about the Low Fragmentation Heap, see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/low_fragmentation_heap.asp Best regards, Martin PS: Since I don't speak C, I used ctypes to convert all heaps in the process to LFH (I don't know how to determine which one is the C heap). ________________________ COMIT AG Risk Management Systems Pflanzschulstrasse 7 CH-8004 Z?rich Telefon +41 (44) 1 298 92 84 http://www.comit.ch http://www.quantax.com - Quantax Trading and Risk System From tim.peters at gmail.com Mon Feb 14 20:13:57 2005 From: tim.peters at gmail.com (Tim Peters) Date: Mon Feb 14 20:58:12 2005 Subject: [python-win32] Re: [Zope] Windows Low Fragementation Heap yields speedup of ~15% In-Reply-To: References: Message-ID: <1f7befae050214111319abbda@mail.gmail.com> [Gfeller Martin] > I'm running a large Zope application on a 1x1GHz CPU 1GB mem > Window XP Prof machine using Zope 2.7.3 and Py 2.3.4 > The application typically builds large lists by appending > and extending them. That's historically been an especially bad case for Windows systems, although the behavior varied across specific Windows flavors. Python has changed lots of things over time to improve it, including yet another twist on list-reallocation strategy new in Python 2.4. > We regularly observed that using a given functionality a > second time using the same process was much slower (50%) > than when it ran the first time after startup. Heh. On Win98SE, the _first_ time you ran pystone after rebooting the machine, it ran twice as fast as the second (or third, fourth, ...) time you tried it. The only way I ever found to get back the original speed without a reboot was to run a different process in-between that allocated almost all physical memory in one giant chunk. Presumably that convinced Win98SE to throw away its fragmented heap and start over again. > This behavior greatly improved with Python 2.3 (thanks > to the improved Python object allocator, I presume). The page you reference later describes a scheme that's (at least superficially) a lot like pymalloc uses for "small objects". In effect, pymalloc takes over buckets 1-32 in the table. > Nevertheless, I tried to convert the heap used by Python > to a Windows Low Fragmentation Heap (available on XP > and 2003 Server). This improved the overall run time > of a typical CPU-intensive report by about 15% > (overall run time is in the 5 minutes range), with the > same memory consumption. > > I consider 15% significant enough to let you know about it. Yes, and thank you. FYI, Python doesn't call any of the Win32 heap functions directly; the behavior it sees is inherited from whatever Microsoft's C implementation uses to support C's malloc()/realloc()/free(). pymalloc requests 256KB at a time from the platform malloc, and carves it up itself, so pymalloc isn't affected by LFH (LFH punts on requests over 16KB, much as pymalloc punts on requests over 256 bytes). But "large objects" (including list guts) don't go thru pymalloc to begin with, so as long as your list guts fit in 16KB, LFH could make a real difference to how they behave. Well, actually, it's probably more the case that LFH gives a boost by keeping small objects _out_ of the general heap. Then growing a giant list doesn't bump into gazillions of small objects. > For information about the Low Fragmentation Heap, see > > > Best regards, > Martin > > PS: Since I don't speak C, I used ctypes to convert all > heaps in the process to LFH (I don't know how to determine > which one is the C heap). It's the one consuming all the time . From ionel.mc at gmail.com Tue Feb 15 10:20:31 2005 From: ionel.mc at gmail.com (ionel) Date: Tue Feb 15 10:20:34 2005 Subject: [python-win32] How to implement a file lock ?? Message-ID: is there a cross-platform library or module for file locking? or at least a win32 implementation. i'm trying to get a lock on some file in a cgi script. ( i got my data erased a few times :P ) -- ionel. From fredrik at pythonware.com Tue Feb 15 10:26:42 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue Feb 15 12:23:07 2005 Subject: [python-win32] Re: How to implement a file lock ?? References: Message-ID: "ionel" wrote: > is there a cross-platform library or module for file locking? > or at least a win32 implementation. for windows, see the third example on this page: http://www.effbot.org/librarybook/msvcrt.htm for unix, see: http://www.effbot.org/librarybook/fcntl.htm From miki.tebeka at zoran.com Tue Feb 15 10:56:06 2005 From: miki.tebeka at zoran.com (Miki Tebeka) Date: Tue Feb 15 15:57:19 2005 Subject: [python-win32] Re: How to implement a file lock ?? In-Reply-To: References: Message-ID: <20050215095545.GD3336@zoran.com> Hello ionel, > is there a cross-platform library or module for file locking? > or at least a win32 implementation. > > i'm trying to get a lock on some file in a cgi script. ( i got my data > erased a few times :P ) I'm using: --------- from os import open as _open, O_CREAT, O_EXCL, O_RDWR lockfile = "/tmp/some_lock" lockfd = None def lock(): global lockfd try: lockfd = _open(lockfile, O_CREAT|O_EXCL|O_RDWR) write(lockfd, "%d" % getpid()) return 1 except OSError: # Already locked lockfd = None return 0 def unlock(): if not lockfd: return 0 try: close(lockfd) remove(lockfile) return 1 except OSError: return 0 --------- You can wrap it in a class. However make sure you unlock either on __del__ with is a bit tricky or atexit.register(unlock) which is better. HTH. -- ------------------------------------------------------------------------ Miki Tebeka http://tebeka.bizhat.com The only difference between children and adults is the price of the toys From martin at v.loewis.de Thu Feb 17 00:42:05 2005 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu Feb 17 02:27:25 2005 Subject: [python-win32] Re: [Python-Dev] Windows Low Fragementation Heap yields speedup of ~15% In-Reply-To: References: Message-ID: <4213DA4D.8090502@v.loewis.de> Gfeller Martin wrote: > Nevertheless, I tried to convert the heap used by Python > to a Windows Low Fragmentation Heap (available on XP > and 2003 Server). This improved the overall run time > of a typical CPU-intensive report by about 15% > (overall run time is in the 5 minutes range), with the > same memory consumption. I must admit that I'm surprised. I would have expected that most allocations in Python go through obmalloc, so the heap would only see "large" allocations. It would be interesting to find out, in your application, why it is still an improvement to use the low-fragmentation heaps. Regards, Martin From xeoicq at netscape.net Thu Feb 17 13:21:56 2005 From: xeoicq at netscape.net (Frank Guenther) Date: Thu Feb 17 13:22:21 2005 Subject: [python-win32] keeping a COM server alive Message-ID: <42148C64.6040101@netscape.net> Hi, I posted this some days ago in comp.lang.python but didn't get a real solution. Perhaps someone here can help me. I have implemented a local COM Server with win32com framework where all clients use the same global object (test_obj). So far it works, but when the last client is closed the gobal object is deleted because the pythonw.exe is closed. When I create a new client a new pythonw process is started. I need that the new client gets the same global object. How can I prevent the Python COM enviornment (pythonw.exe) to close when no client exist. I figured out a workaround, but there must be real solution to the problem. The code looks like: class test: ... test_obj=test() class test_F: _reg_clsid_ = ... _reg_progid_ = "test.cl" _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER _public_methods_ = ... def __init__(self): self.delegate=test_obj .... ... ####Workaround to keep the local server alive if not __name__=='__main__': import win32com.client dummy=win32com.client.Dispatch("test.cl") ########################################################## if __name__=='__main__': import win32com.server.register win32com.server.register.UseCommandLine(test_F, debug=0) From mhammond at skippinet.com.au Thu Feb 17 14:55:38 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Feb 17 14:56:01 2005 Subject: [python-win32] keeping a COM server alive In-Reply-To: <42148C64.6040101@netscape.net> Message-ID: <03e201c514f8$615a25f0$140a0a0a@enfoldsystems.local> Currently there is no nice solution to your problem. I'm sure you understand it is by design pythonw.exe closes when the last reference is closed, and why your work-around is effective. When hosted as a localserver, win32com\server\localserver.py is used as the main program. This is configured in win32com\server\register.py, but there is no facility for overriding this. I'd be happy to accept a patch which allowed you to specify a custom driver program, and this would be free to ignore the shutdown request (ie, simply not call pythoncom.EnableQuitMessage()) Mark > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of Frank Guenther > Sent: Thursday, 17 February 2005 11:22 PM > To: python-win32@python.org > Subject: [python-win32] keeping a COM server alive > > > Hi, > > I posted this some days ago in comp.lang.python > but > didn't get a > real solution. > Perhaps someone here can help me. > > I have implemented a local COM Server with win32com framework > where all > clients > use the same global object (test_obj). So far it works, but when the > last client is closed the gobal object is deleted because the > pythonw.exe is > closed. When I create a new client a new pythonw process is > started. I > need that the > new client gets the same global object. How can I prevent the > Python COM > enviornment (pythonw.exe) to close when no client exist. I > figured out a > workaround, but there must be real solution to the problem. > > The code looks like: > > class test: > ... > > test_obj=test() > > class test_F: > > _reg_clsid_ = ... > _reg_progid_ = "test.cl" > _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER > _public_methods_ = ... > > def __init__(self): > self.delegate=test_obj > .... > ... > > ####Workaround to keep the local server alive > if not __name__=='__main__': > import win32com.client > dummy=win32com.client.Dispatch("test.cl") > ########################################################## > > if __name__=='__main__': > import win32com.server.register > win32com.server.register.UseCommandLine(test_F, debug=0) > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From ted_lilley at yahoo.com Fri Feb 18 11:28:41 2005 From: ted_lilley at yahoo.com (Thomas Lilley) Date: Fri Feb 18 17:01:57 2005 Subject: [python-win32] COM+metaclass+property issue Message-ID: <20050218102841.14987.qmail@web51902.mail.yahoo.com> I'm trying to manufacture a class that provides attributes which mimic the HTML collections offered by the Internet Explorer COM object. My platform is Win32 (Windows XP) and ActiveState's latest Python 2.3. The problem is, my attributes are based on properties, which work fine except for when I have a win32com collection returned, they don't appear to have any information in them. Part of my code: from win32com.client import Dispatch class metaie(type): def __init__(cls, name, bases, dict): super(metaie, cls).__init__(name, bases, dict) for tag in cls.tags: setattr(cls, tag, property(lambda self: self.ie.Document.getElementsByTagName(tag))) class ie(object): __metaclass__ = metaie tags = ["a", "area", "body", "button", "fieldset", "form", "frame", "head", "html", "img", "li", "link", "ol", "table", "td", "tr", "ul"] def __init__(self): self.ie = Dispatch("InternetExplorer.Application") An example of the problem: >>>myie = ie() >>>myie.ie.Document.Navigate(http://www.google.com/) >>>myie.table.length 0 >>>myie.ie.getElementsByTagName("table").length 2 A quick note: ie is my wrapper class, while ie.ie is the win32com Dispatch object representing Internet Explorer. My code should be creating a property attribute for each tag in the tags list and binding it to getElementsByTagName() with the tag pre-loaded by the lambda expression. This means that reading the attribute myie.table should be equivalent to a call to ie.ie.Document.getElementsByTagName("table"). But for some reason, it's not working. Other property assignments in the metaclass that don't refer to getElementsByTagName work fine (for example, I make ie.url an attribute that navigates to whatever location you assign to it). Is there any guru who understands these tools out there who can help? In case you're wondering, the reason I brought metaclasses into the picture is that you can't iterate through a list of attribute assignments within the class definition using setattr or __dict__ because the former requires a class name (doesn't exist until the class statement completes) and the latter doesn't seem to exist for classes, at least, I couldn't find a class __dict__. --------------------------------- Do you Yahoo!? Meet the all-new My Yahoo! – Try it today! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050218/f751c28a/attachment.html From guy at r-e-d.co.nz Sat Feb 19 00:18:21 2005 From: guy at r-e-d.co.nz (Guy Robinson) Date: Sat Feb 19 00:18:31 2005 Subject: [python-win32] OT: win32 python small job offer Message-ID: <421677BD.2070301@r-e-d.co.nz> Hello, I'm looking at engaging someone to implement a couple of missing shell32 methods in python win32. The required methods are on MSDN here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/ shell/reference/ifaces/iextractimage/iextractimage.asp http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/ shell/reference/ifaces/iextractimage2/iextractimage2.asp As an amateur programmer I have no knowledge of how to engage programming services or how much this would cost. So please contact me off list to discuss. For ease of payment if you live in New Zealand that would be perfect :-) My intention is for the developed code to be released to the community and I guess integrated into the win32 distribution if accepted. Regards, Guy Robinson guy AT r-e-d.co.nz From luc.saffre at gmx.net Sat Feb 19 15:21:18 2005 From: luc.saffre at gmx.net (Luc Saffre) Date: Sat Feb 19 15:21:25 2005 Subject: [python-win32] StartDoc failed Message-ID: <42174B5E.6080904@gmx.net> Hello, if my default windows printer is a network printer and not available, then dc.StartDoc() causes a traceback which I cannot catch using try...except. According to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_CDC.3a3a.StartDoc.asp I would have expected it to simply return 0 or negative on failure. Example: #file startjob.py import win32ui dc = win32ui.CreateDC() dc.CreatePrinterDC(None) try: dc.StartDoc("foo") # ... print to printer dc.EndDoc() except Exception,e: print "your default printer is not reachable" If I run this, I get: Traceback (most recent call last): File "startjob.py", line 6, in ? dc.StartDoc("foo") win32ui: StartDoc failed Is there a workaround? How can I catch and handle the case of a non-ready printer? (i'm using pywin32 build 203 and python 2.3) tia, Luc From rwupole at msn.com Tue Feb 22 00:14:01 2005 From: rwupole at msn.com (Roger Upole) Date: Tue Feb 22 00:14:08 2005 Subject: [python-win32] Re: StartDoc failed References: <42174B5E.6080904@gmx.net> Message-ID: You should be able to use win32print.GetPrinter to check the state. Either the status or the attributes (or both) should change when it's not available. (Atributes are element 13 of the returned tuple, Status is element 18) hth Roger ----- Original Message ----- From: "Luc Saffre" To: Sent: Saturday, February 19, 2005 9:21 AM Subject: [python-win32] StartDoc failed > Hello, > > if my default windows printer is a network printer and not available, then > dc.StartDoc() causes a traceback which I cannot catch using try...except. > According to > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_CDC.3a3a.StartDoc.asp > I would have expected it to simply return 0 or negative on failure. > > Example: > > #file startjob.py > import win32ui > dc = win32ui.CreateDC() > dc.CreatePrinterDC(None) > try: > dc.StartDoc("foo") > # ... print to printer > dc.EndDoc() > except Exception,e: > print "your default printer is not reachable" > > If I run this, I get: > > Traceback (most recent call last): > File "startjob.py", line 6, in ? > dc.StartDoc("foo") > win32ui: StartDoc failed > > Is there a workaround? How can I catch and handle the case of a non-ready > printer? > > (i'm using pywin32 build 203 and python 2.3) > > tia, > Luc > > From luc.saffre at gmx.net Tue Feb 22 05:43:34 2005 From: luc.saffre at gmx.net (Luc Saffre) Date: Tue Feb 22 05:43:41 2005 Subject: [python-win32] Re: StartDoc failed In-Reply-To: References: <42174B5E.6080904@gmx.net> Message-ID: <421AB876.9010603@gmx.net> On 22.02.2005 01:14, Roger Upole wrote: > You should be able to use win32print.GetPrinter to check > the state. Either the status or the attributes (or both) should > change when it's not available. (Atributes are element 13 > of the returned tuple, Status is element 18) Roger, thanks for the hint. I saw that GetPrinter() needs a handle, which I can find out -as I suppose- using EnumPrinters(). Unfortunately, EnumPrinters(PRINTER_ENUM_DEFAULT) seems to not work. It always raises: pywintypes.error: (0, 'EnumPrinters', 'No error message is available') even if the default printer is defined and ready. I'd guess that EnumPrinters() does not forward PRINTER_ENUM_DEFAULT correctly, because for example EnumPrinters(PRINTER_ENUM_LOCAL) works well. Tja... Luc From rwupole at msn.com Tue Feb 22 06:06:30 2005 From: rwupole at msn.com (Roger Upole) Date: Tue Feb 22 06:06:36 2005 Subject: [python-win32] Re: StartDoc failed References: <42174B5E.6080904@gmx.net> <421AB876.9010603@gmx.net> Message-ID: PRINTER_ENUM_DEFAULT only works on Windows 95/98. win32print.OpenPrinter(win32print.GetDefaultPrinter()) should get a handle that you can pass to GetPrinter. Roger ----- Original Message ----- From: "Luc Saffre" To: "Roger Upole" Cc: Sent: Monday, February 21, 2005 11:43 PM Subject: Re: [python-win32] Re: StartDoc failed > On 22.02.2005 01:14, Roger Upole wrote: >> You should be able to use win32print.GetPrinter to check >> the state. Either the status or the attributes (or both) should >> change when it's not available. (Atributes are element 13 >> of the returned tuple, Status is element 18) > > Roger, thanks for the hint. I saw that GetPrinter() needs a handle, which > I can find out -as I suppose- using EnumPrinters(). > > Unfortunately, EnumPrinters(PRINTER_ENUM_DEFAULT) seems to not work. It > always raises: > > pywintypes.error: (0, 'EnumPrinters', 'No error message is available') > > even if the default printer is defined and ready. > > I'd guess that EnumPrinters() does not forward PRINTER_ENUM_DEFAULT > correctly, because for example EnumPrinters(PRINTER_ENUM_LOCAL) works > well. > > Tja... > Luc From harald.massa at suedvers.de Tue Feb 22 11:37:27 2005 From: harald.massa at suedvers.de (Massa, Harald) Date: Tue Feb 22 11:37:31 2005 Subject: [python-win32] Massive Speedup py 2.3 -> 2.4 with COM Message-ID: <8EC7886AFFBC4748A75B124B1C2D7F1618CC43@EXCH2.suedvers.local> I have deployed an application doing massive data transfers to excel. Lately I updated to python 2.4 and all fitting libs, had the hurts with win32com.client makepy and mbcs, which is quite documented now. after using the fix most worked good. Now: there are reports of MASSIVE speedups. I know about the improvements within Python; esp. with List processing etc. BUT--- this application has 2 areas of speed challenges a) getting data from the database (IO, server query time) b) !important: transfer of the data to excel via COM-Interface The usual tricks are applied (using early bound COM, transfering data in Bulk blocks etc. etc.) And now that speedup. Was there anything changed within doing the COM-transfer? Is it because of the removed MBCS-Encoding within genpy? (I am lucky about the massive speedup, but ... would really like to know its origin, to be sure it is not sth going wrong) Harald -- -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050222/e8e95a3e/attachment.htm From luc.saffre at gmx.net Tue Feb 22 12:34:36 2005 From: luc.saffre at gmx.net (Luc Saffre) Date: Tue Feb 22 12:34:40 2005 Subject: [python-win32] Re: StartDoc failed In-Reply-To: References: <42174B5E.6080904@gmx.net> <421AB876.9010603@gmx.net> Message-ID: <421B18CC.4070507@gmx.net> On 22.02.2005 07:06, Roger Upole wrote: > PRINTER_ENUM_DEFAULT only works on Windows 95/98. > win32print.OpenPrinter(win32print.GetDefaultPrinter()) > should get a handle that you can pass to GetPrinter. Roger, thank you again for your reply. Your hints work, except that element 18 doesn't seem to be the printer status. The whole information returned by GetPrinter() is always the same, no matter whether network unavailable, network available but printer off-line, or nw available and printer on-line. Here is the code I am using to test: while True: h = win32print.OpenPrinter(win32print.GetDefaultPrinter()) t = win32print.GetPrinter(h) win32print.ClosePrinter(h) if t[18]: break print t if not confirm("printer not ready. retry?"): raise PrinterNotReady Here is the content of t: ('\\\\KYLLIKI', '\\\\KYLLIKI\\Samsung ML-1200 Series', 'ML-1200', 'LPT1:', 'Samsung ML-1200 Series', 'Samsung ML-1210/ML-1220M', '', None, '', 'WinPrint', 'RAW', '', None, 24, 1, 0, 0, 0, 0, 1, 0) All this is very funny... Luc From olivier.riff at id3semiconductors.com Tue Feb 22 18:05:18 2005 From: olivier.riff at id3semiconductors.com (Olivier RIFF) Date: Tue Feb 22 18:06:22 2005 Subject: [python-win32] opposite of "import module" Message-ID: <001301c51900$afe87a30$1acaa8c0@gen.id3.lan> Hello, what is the opposite of "import module" ? I have create my own module (implemented in C and generate with SWIG) and I use it under PythonWin. But once I have imported it, I cannot compile my module anymore because PythonWin is still using it (moreover, I do not find the way to do a restart of the PythonWin shell, which is possible with the standard Python GUI) and I do not want to have close PythonWin each time I have to change something in the implementation of my module. Have a nice day Olivier ************************************************************************ *********** Olivier Riff id3 Semiconductors 5, rue de la Verrerie F-38120 LE FONTANIL-CORNILLON Fax : (33) 04 76 75 52 30 Web: http://www.id3semiconductors.com mailto:olivier.riff@id3semiconductors.com ************************************************************************ *********** -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050222/02f87d4a/attachment.html From steve at holdenweb.com Tue Feb 22 19:04:28 2005 From: steve at holdenweb.com (Steve Holden) Date: Tue Feb 22 19:04:10 2005 Subject: [python-win32] opposite of "import module" In-Reply-To: <001301c51900$afe87a30$1acaa8c0@gen.id3.lan> References: <001301c51900$afe87a30$1acaa8c0@gen.id3.lan> Message-ID: <421B742C.6060603@holdenweb.com> Olivier RIFF wrote: > Hello, > > what is the opposite of "import module" ? > > I have create my own module (implemented in C and generate with SWIG) > and I use it under PythonWin. But once I have imported it, I cannot > compile my module anymore because PythonWin is still using it (moreover, > I do not find the way to do a restart of the PythonWin shell, which is > possible with the standard Python GUI) and I do not want to have close > PythonWin each time I have to change something in the implementation of > my module. > As I understand it, unlike pure Python modules it is impossible to reload extension modules. My main reason for piping up at this point is to encourage someone to prove me wrong, thereby giving you what you need ;-) regards Steve -- Steve Holden +1 703 861 4237 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ From b.hall at irl.cri.nz Wed Feb 23 04:14:02 2005 From: b.hall at irl.cri.nz (Blair Hall) Date: Wed Feb 23 04:14:18 2005 Subject: [python-win32] Openning the IDE from Windows Explorer Message-ID: <5.2.0.9.1.20050223160905.00c5a7f0@127.0.0.1> I've just upgraded to Python 2.4 and build 203 of the extensions. My earlier installation (Python 2.2.2, not sure which build of the extensions) allowed me to right-click on a file from the Windows Explorer window and select 'Edit' to open that file in the PythonWin IDE. Now my latest installation has not provided me with this rather convenient tool, (although the Edit with IDL is still there) and I can't figure out how to add it myself! Can anyone help? From rwupole at msn.com Wed Feb 23 07:01:24 2005 From: rwupole at msn.com (Roger Upole) Date: Wed Feb 23 07:01:32 2005 Subject: [python-win32] Openning the IDE from Windows Explorer Message-ID: >From the Explorer menu: Tools->Folder Options->File Types, and scroll down to PY. From there you can add, change, or remove any of the right-click options for python scripts. hth Roger "Blair Hall" b.hall@irl.cri.nz wrote: > I've just upgraded to Python 2.4 and build 203 of the extensions. > > My earlier installation (Python 2.2.2, not sure which build of the > extensions) > allowed me to right-click on a file from the Windows Explorer window and > select 'Edit' > to open that file in the PythonWin IDE. > > Now my latest installation has not provided me with this rather convenient > tool, > (although the Edit with IDL is still there) and I can't figure out how to > add it myself! > > Can anyone help? From matt2 at roffs.com Thu Feb 24 17:24:34 2005 From: matt2 at roffs.com (Matt Upton) Date: Thu Feb 24 17:26:12 2005 Subject: [python-win32] Need some Python Help! In-Reply-To: Message-ID: Hello, I am new to Python and am trying to produce script to run batch processes for ArcGIS 9.0 (ArcView). I have upgraded to Phython 2.4 from 2.1 and am using the Pythonwin to try to code but am running into a problem. Whenever I try to debug my program or run any code past the following code it gets hung up and crashes, quits, no warning, and no messages. HELP, what is the problem, it is getting very frustrating. >> import win32com.client, sys, os >> gp = win32com.client.Dispatch("esriGeoprocessing.GPDispatch.1") >> gp.workspace = "c:/Program Files/ArcGIS/NASA" It ALWAYS crashes and quits 30 sec or so after line 2 of the code above???? I can't get Python to do anything in ArcGIS so far, none of the tools can be called or used? I am assuming there is some sort of path or link that is not working properly between ArcGIS and Python? Using the same coding in the IDLE Python environment results in the same crashing results. Oh yes, I am running everything on Windows XP Thank you. Matthew Upton From tony at tcapp.com Thu Feb 24 17:57:16 2005 From: tony at tcapp.com (Tony Cappellini) Date: Thu Feb 24 17:57:39 2005 Subject: [python-win32] Problems with PythonWin Debugger and interactive window In-Reply-To: <20050222110201.095911E4006@bag.python.org> References: <20050222110201.095911E4006@bag.python.org> Message-ID: <6.1.2.0.0.20050224084855.01f4ee08@mail.yamato.com> I've been trying to debug a short program with the PythonWin debugger, on XP. I'm using 2.3 Build 202. I keep seeing problems where variables I am watching don't always get updated, as well as just erratic operation. Restarting doesn't help, I usually have to exit PythonWin, and start over again. Another problem is that the bottom most line of the interactive window is not visible, unless PythonWin is in full-screen mode. This means I'm usually tying blind, and can't see the results unless I press enter several times. This has been a recurring problem at least since 2.2. it would be very helpfull to be able to look at a help file in the upper part of the display, while working with PythonWin minimized to half screen height, in the lower half of the display. But since the bottom several lines aren't visible (they are hidden), I have to always run in full screen mode. I see this problem on 3 different computers that I work with. Has anyone else seen any problems like this in the debugger or the interactive window ? From xeoicq at netscape.net Fri Feb 25 07:50:16 2005 From: xeoicq at netscape.net (Frank Guenther) Date: Fri Feb 25 07:50:23 2005 Subject: [python-win32] keeping a COM server alive Message-ID: <421ECAA8.2090804@netscape.net> Hi, thanks for your answer. I changed the localserver.py like you suggested by skipping to call pythoncom.EnableQuitMessage(). But what is the best way to close the pythonw process when desired? I tried to call sys.exit() in the COM-Server Modul and got an error. A patch to specify a custom driver program would be to insert a registration-related attribute on the COM Object (e.g. _reg_custom_driver_) with the absolute path of the file of custom driver program? Would this be sufficient when py2exe is used to compile the hole server? What about an extension of the _reg_clsctx_ attribute to take a switch like pythoncom.CLSCTX_LOCAL_SERVER_NO_QUIT? Ciao, Frank mhammond@skippinet.com.au wrote: >Currently there is no nice solution to your problem. I'm sure you >understand it is by design pythonw.exe closes when the last reference is >closed, and why your work-around is effective. > >When hosted as a localserver, win32com\server\localserver.py is used as the >main program. This is configured in win32com\server\register.py, but there >is no facility for overriding this. I'd be happy to accept a patch which >allowed you to specify a custom driver program, and this would be free to >ignore the shutdown request (ie, simply not call >pythoncom.EnableQuitMessage()) > >Mark > > > >>-----Original Message----- >>From: python-win32-bounces@python.org >>[mailto:python-win32-bounces@python.org]On Behalf Of Frank Guenther >>Sent: Thursday, 17 February 2005 11:22 PM >>To: python-win32@python.org >>Subject: [python-win32] keeping a COM server alive >> >> >>Hi, >> >>I posted this some days ago in comp.lang.python >> but >>didn't get a >>real solution. >>Perhaps someone here can help me. >> >>I have implemented a local COM Server with win32com framework >>where all >>clients >>use the same global object (test_obj). So far it works, but when the >>last client is closed the gobal object is deleted because the >>pythonw.exe is >>closed. When I create a new client a new pythonw process is >>started. I >>need that the >>new client gets the same global object. How can I prevent the >>Python COM >>enviornment (pythonw.exe) to close when no client exist. I >>figured out a >>workaround, but there must be real solution to the problem. >> >>The code looks like: >> >>class test: >> ... >> >>test_obj=test() >> >>class test_F: >> >> _reg_clsid_ = ... >> _reg_progid_ = "test.cl" >> _reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER >> _public_methods_ = ... >> >> def __init__(self): >> self.delegate=test_obj >> .... >> ... >> >>####Workaround to keep the local server alive >>if not __name__=='__main__': >> import win32com.client >> dummy=win32com.client.Dispatch("test.cl") >>########################################################## >> >>if __name__=='__main__': >> import win32com.server.register >> win32com.server.register.UseCommandLine(test_F, debug=0) >> >> >> >>_______________________________________________ >>Python-win32 mailing list >>Python-win32@python.org >>http://mail.python.org/mailman/listinfo/python-win32 >> >> > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050225/06a621b3/attachment.htm From tony at tcapp.com Fri Feb 25 19:24:19 2005 From: tony at tcapp.com (Tony Cappellini) Date: Fri Feb 25 19:21:57 2005 Subject: [python-win32] More problems with Python Win debugger In-Reply-To: <20050225110041.AEC841E4014@bag.python.org> References: <20050225110041.AEC841E4014@bag.python.org> Message-ID: <20050225101726.F19586@yamato.yamato.com> This is really getting bizarre. Is it normal for the debugging toolbar to go away, after running a program in the debugger? Occasionally after running a proram, the debugging toolbar dissappears and has to be re-enabled. But it doesn't happen every time- this is what is confusing. From alex at moreati.org.uk Fri Feb 25 20:19:43 2005 From: alex at moreati.org.uk (Alex Willmer) Date: Fri Feb 25 20:19:45 2005 Subject: [python-win32] Need some Python Help! In-Reply-To: References: Message-ID: <421F7A4F.7060100@moreati.org.uk> Matt Upton wrote: >Hello, I am new to Python and am trying to produce script to run batch >processes for ArcGIS 9.0 (ArcView). I have upgraded to Phython 2.4 from 2.1 >and am using the Pythonwin to try to code but am running into a problem. >Whenever I try to debug my program or run any code past the following code >it gets hung up and crashes, quits, no warning, and no messages. HELP, what >is the problem, it is getting very frustrating. > > > >>>import win32com.client, sys, os >>>gp = win32com.client.Dispatch("esriGeoprocessing.GPDispatch.1") >>>gp.workspace = "c:/Program Files/ArcGIS/NAS >>> Python extensions such as pywin32 and ESRIs ArcGIS libraries are compiled against a paticular major version of the python binaries. Hence you can't use extensions compiled for Python 2.1 with Python 2.4, it crashes, as you've discovered. This is why ESRI distribute Python 2.1 with ArcGIS 9.0. Uninstall Python and reinstall it from the ArcGIS CD. Regards Alex From mhammond at skippinet.com.au Mon Feb 28 02:40:37 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon Feb 28 02:40:43 2005 Subject: [python-win32] StartDoc failed In-Reply-To: <42174B5E.6080904@gmx.net> Message-ID: <039e01c51d36$812e1e90$f502a8c0@enfoldsystems.local> > if my default windows printer is a network printer and not available, > then dc.StartDoc() causes a traceback which I cannot catch using > try...except. You can catch it via try/except. In your specific example, you would want to catch win32ui.error. The reason catching Exception doesn't work is because win32ui.error does not sub-class Exception. Mark. From luc.saffre at gmx.net Mon Feb 28 03:23:26 2005 From: luc.saffre at gmx.net (Luc Saffre) Date: Mon Feb 28 03:23:37 2005 Subject: [python-win32] StartDoc failed In-Reply-To: <039e01c51d36$812e1e90$f502a8c0@enfoldsystems.local> References: <039e01c51d36$812e1e90$f502a8c0@enfoldsystems.local> Message-ID: <4222809E.5070209@gmx.net> On 28.02.2005 03:40, Mark Hammond wrote: >>if my default windows printer is a network printer and not available, >>then dc.StartDoc() causes a traceback which I cannot catch using >>try...except. > > You can catch it via try/except. In your specific example, you would want > to catch win32ui.error. The reason catching Exception doesn't work is > because win32ui.error does not sub-class Exception. Thanks! This helped! Luc From jiangsy at utstar.com Mon Feb 28 12:02:29 2005 From: jiangsy at utstar.com (Jiang Shanyi) Date: Mon Feb 28 12:01:44 2005 Subject: [python-win32] How to use Python to develop virtual printer? Message-ID: <90625507C4259B4CBF2FBDC3CF0AB3DC48D978@CNMAIL12.cn.utstarcom.com> I want to develop a virtual printer, can anybody tell me where can I find an existing open source virtual printer project? or Can anybody tell me how to develop virtual printer? and how about use of python? Best Regards!!