From Smola at farbspender.de Sun May 1 18:55:03 2005 From: Smola at farbspender.de (Stephan Smola) Date: Sun May 1 19:01:28 2005 Subject: [python-win32] Getting Icon as bitmapdata Message-ID: <427509E7.8040402@farbspender.de> Hello, I know how to get the icon (the id?) for a specific extension unsing SHGetFileInfo. Is there a way to get the image data for this icon, so that I can send it using a webserver e.g. as an image/bmp? I'm very clueless about win32 programming so any hint is very much appreciated. Thanks. Stephan From cedric.delfosse at linbox.com Mon May 2 11:48:25 2005 From: cedric.delfosse at linbox.com (Cedric Delfosse) Date: Mon, 02 May 2005 11:48:25 +0200 Subject: [python-win32] Problem with .exe for COM server Message-ID: <1115027306.905.28.camel@replic.metz> Hello, I try to get a working .exe from the COM server available at the "Quick Start to Server side COM and Python" [1]. With py2exe and Gordon McMillan's Python Installer, the generated .exe can register/unregister the COM server without problem, but it looks like the COM client get a timeout while connecting to the COM server: Traceback (most recent call last): File "comclient.py", line 8, in ? o = win32com.client.Dispatch("Python.TestServer") File "C:\Python23\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c lsctx) File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 91, in _ GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 79, in _ GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II D_IDispatch) pywintypes.com_error: (-2146959355, "\xc9chec de l'ex\xe9cution du serveur", Non e, None) The fun is that the COM server and COM client work fine together when using the python scripts, but they don't work when using the .exe. Any ideas ? Best regards, [1] http://www.python.org/windows/win32com/QuickStartServerCom.html -- C?dric Delfosse Linbox / Free&ALter Soft 152, rue de Grigy - Technopole Metz 57070 Metz - FRANCE t?l: +33 (0)3 87 50 87 90 http://linbox.org http://linbox.com From ulrich.berning at desys.de Mon May 2 12:06:38 2005 From: ulrich.berning at desys.de (Ulrich Berning) Date: Mon, 02 May 2005 12:06:38 +0200 Subject: [python-win32] Incomplete ZIP source files at sourceforge.net Message-ID: <4275FBAE.2050602@desys.de> Hi, can anybody tell me, why the ZIP source archives at sourceforge.net are always absolutely incomplete and do not reflect the tagged versions in CVS? In fact, the ZIP archives are unusable. I always have to checkout from CVS using the build number as the revision tag to get a complete and usable set of sources. I thought, it would be no problem to create a complete ZIP archive from a commited tagged CVS revision (just checkout, remove the CVS subdirectories and the .cvsignore files and create a ZIP archive contining the complete pywin32 directory), but the rules for the ZIP archive seem to be more complicated (or random?) and change from build to build. I have no problem using the CVS sources, but I think providing an incomplete source archive at sourceforge is absolutely useless. By the way, am I the only one that tries to build the win32 extensions from source, and if not, do all others always use the sources from CVS? Ulli From mhammond at skippinet.com.au Mon May 2 14:19:18 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 2 May 2005 22:19:18 +1000 Subject: [python-win32] Incomplete ZIP source files at sourceforge.net In-Reply-To: <4275FBAE.2050602@desys.de> Message-ID: <010701c54f11$2ada6000$0a0a0a0a@enfoldsystems.local> > can anybody tell me, why the ZIP source archives at > sourceforge.net are > always absolutely incomplete and do not reflect the tagged > versions in CVS? In what way? > In fact, the ZIP archives are unusable. I always have to > checkout from > CVS using the build number as the revision tag to get a complete and > usable set of sources. What files are missing? What errors do you see? > I thought, it would be no problem to create a complete ZIP > archive from > a commited tagged CVS revision (just checkout, remove the CVS > subdirectories and the .cvsignore files and create a ZIP archive > contining the complete pywin32 directory), but the rules for the ZIP > archive seem to be more complicated (or random?) and change > from build to build. pywin32 uses distutils to create the releases, including the source archive. All this is managed in setup.py. As you pull from CVS, you can create your own source distribution by running: setup.py sdist > I have no problem using the CVS sources, but I think providing an > incomplete source archive at sourceforge is absolutely useless. I agree, and admit to not running a test build of the source archive before releasing 204. It currently fails building the new DirectSound module. I've checked the change for that into CVS (MANIFEST.in did not know about that directory), so build 205 should build from source without modification (unless another new major module is introduced and I make the same omission again) > By the way, am I the only one that tries to build the win32 > extensions > from source, and if not, do all others always use the sources > from CVS? Apparently you are the first to try building release 204 from the source .zip, or the first to report failure. I'm fairly sure 203 worked (but only due to people filing bug reports against 202 . In general, the more detail you can provide about your problems, the better. If you really want to help prove that 205 will work for you, then you could try updating from CVS(ensure you see rev 1.9 of MANIFEST.in - anonymous CVS is generally behind), running "setup.py sdist", then testing the resulting .zip file. I've still only (now) tested on my dev machine. Mark. From mhammond at skippinet.com.au Mon May 2 14:25:10 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 2 May 2005 22:25:10 +1000 Subject: [python-win32] Problem with .exe for COM server In-Reply-To: <1115027306.905.28.camel@replic.metz> Message-ID: <010801c54f11$fc6d5870$0a0a0a0a@enfoldsystems.local> > With py2exe and Gordon McMillan's Python Installer, the generated .exe > can register/unregister the COM server without problem, but it looks > like the COM client get a timeout while connecting to the COM server: I've never used py2exe and Gordon McMillan's Python Installer together. I'd suggest starting with py2exe alone. Register the py2exe created .exe, and use a simple VB script application to test the object: set ob = CreateObject("Python.TestServer") and take things from there. Ensuring the COM object is registered for debugging, and that the Pythonwin "Trace Collector" is running should help diagnose most problems. Once you have it working on your dev machine, just have something like inno install the entire py2exe built "dist" directory to the target machine. Hope that still makes sense given my haste :) Mark From ulrich.berning at desys.de Tue May 3 10:59:07 2005 From: ulrich.berning at desys.de (Ulrich Berning) Date: Tue, 03 May 2005 10:59:07 +0200 Subject: [python-win32] Incomplete ZIP source files at sourceforge.net In-Reply-To: <010701c54f11$2ada6000$0a0a0a0a@enfoldsystems.local> References: <010701c54f11$2ada6000$0a0a0a0a@enfoldsystems.local> Message-ID: <42773D5B.7070100@desys.de> Mark Hammond schrieb: >>can anybody tell me, why the ZIP source archives at >>sourceforge.net are >>always absolutely incomplete and do not reflect the tagged >>versions in CVS? >> >> > >In what way? > > > >>In fact, the ZIP archives are unusable. I always have to >>checkout from >>CVS using the build number as the revision tag to get a complete and >>usable set of sources. >> >> > >What files are missing? What errors do you see? > The relevant files/directories from a diff output of the last three releases: --- build 202: Only in pywin32-202-cvs/com/win32comext/adsi: __init__.py Only in pywin32-202-cvs/com/win32comext/ifilter/src: PyIFilter.h Only in pywin32-202-cvs/com/win32comext/ifilter/src: stdafx.h Only in pywin32-202-cvs: swig.bat Only in pywin32-202-cvs: AutoDuck --- build 203: Only in pywin32-203-cvs: swig.bat --- build 204: Only in pywin32-204-cvs/com/win32comext/directsound/src: PyDSCBCAPS.cpp Only in pywin32-204-cvs/com/win32comext/directsound/src: PyDSCBUFFERDESC.cpp Only in pywin32-204-cvs/com/win32comext/directsound/src: PyDSCCAPS.cpp Only in pywin32-204-cvs/com/win32comext/directsound/src: PyIDirectSound.h Only in pywin32-204-cvs/com/win32comext/directsound/src: PyIDirectSoundBuffer.h Only in pywin32-204-cvs/com/win32comext/directsound/src: PyIDirectSoundCapture.cpp Only in pywin32-204-cvs/com/win32comext/directsound/src: PyIDirectSoundCapture.h Only in pywin32-204-cvs/com/win32comext/directsound/src: PyIDirectSoundCaptureBuffer.cpp Only in pywin32-204-cvs/com/win32comext/directsound/src: PyIDirectSoundCaptureBuffer.h Only in pywin32-204-cvs/com/win32comext/directsound/src: PyIDirectSoundNotify.h Only in pywin32-204-cvs/com/win32comext/directsound/src: directsound_pch.h Only in pywin32-204-cvs: swig.bat --- Ok, it seems that swig.bat is no longer needed, so build 203 was complete. With build 202, AutoDuck is missing, so there is no chance to build the documentation. The header files for the ifilter extension are missing and adsi has no package file. With build 204, a number of files of the new DirectSound interface are missing. > > > >>I thought, it would be no problem to create a complete ZIP >>archive from >>a commited tagged CVS revision (just checkout, remove the CVS >>subdirectories and the .cvsignore files and create a ZIP archive >>contining the complete pywin32 directory), but the rules for the ZIP >>archive seem to be more complicated (or random?) and change >>from build to build. >> >> > >pywin32 uses distutils to create the releases, including the source archive. >All this is managed in setup.py. As you pull from CVS, you can create your >own source distribution by running: > > setup.py sdist > Sure, I can do that, but if I have to do it, providing a source distribution at sourceforge is useless. > > > >>I have no problem using the CVS sources, but I think providing an >>incomplete source archive at sourceforge is absolutely useless. >> >> > >I agree, and admit to not running a test build of the source archive before >releasing 204. It currently fails building the new DirectSound module. >I've checked the change for that into CVS (MANIFEST.in did not know about >that directory), so build 205 should build from source without modification >(unless another new major module is introduced and I make the same omission >again) > > If I can't be sure, that a source package has been tested before it is released, I always have the unpleasent feeling, that something is missing or not up to date. On my development machine, it requires only 5 minutes to do a complete build cycle (clean previous build, unpack, patch, build, create docs, install), so what's the problem with testing that the packages builds before you release it? > > >>By the way, am I the only one that tries to build the win32 >>extensions >>from source, and if not, do all others always use the sources >>from CVS? >> >> > >Apparently you are the first to try building release 204 from the source >.zip, or the first to report failure. I'm fairly sure 203 worked (but only >due to people filing bug reports against 202 . In general, the more >detail you can provide about your problems, the better. > >If you really want to help prove that 205 will work for you, then you could >try updating from CVS(ensure you see rev 1.9 of MANIFEST.in - anonymous CVS >is generally behind), running "setup.py sdist", then testing the resulting >.zip file. I've still only (now) tested on my dev machine. > >Mark. > > Another point is, that some directoy names have an inconsistent case style in the source distribution and in CVS: In CVS, I find Pythonwin, com/win32comext/axdebug and com/win32comext/axscript. In the source distribution, I find pythonwin, com/win32comext/AXDebug and com/win32comext/AXScript. I know, the Windows filesystems are case insensitive, but I'm building a Python runtime environment for Linux, AIX, HP-UX, IRIX and Windows. I make all modifications and create patches on my Linux development system. If there is a chance, to be a little bit more consistent in case style for directory/file names, it would make my live much easier and it would improve the readability of the sources. Ulli. From rwupole at msn.com Tue May 3 13:31:25 2005 From: rwupole at msn.com (Roger Upole) Date: Tue, 3 May 2005 07:31:25 -0400 Subject: [python-win32] Re: Getting Icon as bitmapdata Message-ID: I think SHGetFileInfo returns an icon handle rather than an id. You might be able to look in the registry under HKEY_CLASSES_ROOT for the file extension, and there should be a DefaultIcon entry with the location of the icon. If it's not a simple .ico file, you should be able to use win32api.LoadResource to extract the data using the specified module and index. Roger From cedric.delfosse at linbox.com Tue May 3 14:10:13 2005 From: cedric.delfosse at linbox.com (Cedric Delfosse) Date: Tue, 03 May 2005 14:10:13 +0200 Subject: [python-win32] Problem with .exe for COM server In-Reply-To: <010801c54f11$fc6d5870$0a0a0a0a@enfoldsystems.local> References: <010801c54f11$fc6d5870$0a0a0a0a@enfoldsystems.local> Message-ID: <1115122213.11934.8.camel@replic.metz> Le lundi 02 mai 2005 ? 22:25 +1000, Mark Hammond a ?crit : > > With py2exe and Gordon McMillan's Python Installer, the generated .exe > > can register/unregister the COM server without problem, but it looks > > like the COM client get a timeout while connecting to the COM server: > > I've never used py2exe and Gordon McMillan's Python Installer together. I did not use them together, but separately :) I generated an .exe with Gordon McMillan's Python Installer, and then with py2exe, but got the same results. > I'd > suggest starting with py2exe alone. Register the py2exe created .exe, and > use a simple VB script application to test the object: > > set ob = CreateObject("Python.TestServer") > > and take things from there. Ensuring the COM object is registered for > debugging, and that the Pythonwin "Trace Collector" is running should help > diagnose most problems. Ok, I will try this next week. Thanks a lot for your help and your time. -- C?dric Delfosse Linbox / Free&ALter Soft 152, rue de Grigy - Technopole Metz 57070 Metz - FRANCE t?l: +33 (0)3 87 50 87 90 http://linbox.org http://linbox.com From mhammond at skippinet.com.au Tue May 3 14:14:01 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 3 May 2005 22:14:01 +1000 Subject: [python-win32] Incomplete ZIP source files at sourceforge.net In-Reply-To: <42773D5B.7070100@desys.de> Message-ID: <039f01c54fd9$98104db0$0a0a0a0a@enfoldsystems.local> > >What files are missing? What errors do you see? > > > The relevant files/directories from a diff output of the last three > releases: All releases bar the last are of no real relevance (I'm not going to re-release them), but I believe you confirmed what I said about these previos releases. I believe you are also confirming that only the DirectSound files are missing from 204, and that one file has yet to be removed from CVS? > >pywin32 uses distutils to create the releases, including the > source archive. > >All this is managed in setup.py. As you pull from CVS, you > can create your > >own source distribution by running: > > > > setup.py sdist > > > Sure, I can do that, but if I have to do it, providing a source > distribution at sourceforge is useless. Sorry - I didn't meant you *should* do that - I meant you *could* do that if you wanted to assist me in refining this process. > If I can't be sure, that a source package has been tested > before it is > released, I always have the unpleasent feeling, that something is > missing or not up to date. I'm afraid I can't help with the unpleasant feelings :) All contributions towards a fool-proof, single-step process that does a clean build from the primary source tree for all supported Python versions, executes all tests (for all versions) and builds the .zip source archive (all versions again?) would be more than appreciated! Until such a process exists, I can do no more than apologize for any errors I make. > On my development machine, it requires only 5 minutes to do a > complete > build cycle (clean previous build, unpack, patch, build, create docs, > install), so what's the problem with testing that the packages builds > before you release it? Perhaps you would care to take over the release of these extensions? It certainly would help me to have someone else take care of the mechanics of the release process, and give me more time to work on the extensions themselves. If not, perhaps a contribution towards a single-step build process as mentioned that I can run? > Another point is, that some directoy names have an inconsistent case > style in the source distribution and in CVS: > In CVS, I find Pythonwin, com/win32comext/axdebug and > com/win32comext/axscript. > In the source distribution, I find pythonwin, com/win32comext/AXDebug > and com/win32comext/AXScript. > > I know, the Windows filesystems are case insensitive, but I'm > building a > Python runtime environment for Linux, AIX, HP-UX, IRIX and Windows. I > make all modifications and create patches on my Linux development > system. If there is a chance, to be a little bit more > consistent in case > style for directory/file names, it would make my live much > easier and it > would improve the readability of the sources. I have already explained the process of building the .zip distribution, and I'd be happy to receive patches that tweak this process so your life is easier. As a general rule, it takes more than one person complaining about some pedantic corner before I am inclined to spend alot of time worrying about it - but if you want to spend *your* time worrying about it (and only ask a little of my time in review and checkin), I'm generally happy to oblige. Mark. From timr at probo.com Tue May 3 18:03:39 2005 From: timr at probo.com (Tim Roberts) Date: Tue, 03 May 2005 09:03:39 -0700 Subject: [python-win32] Incomplete ZIP source files at sourceforge.net In-Reply-To: References: Message-ID: <4277A0DB.1050408@probo.com> On Mon, 02 May 2005 12:06:38 +0200, Ulrich Berning wrote: >By the way, am I the only one that tries to build the win32 extensions >from source, and if not, do all others always use the sources from CVS? > > I use the binary releases. In 10 years of Python, I have not yet encountered an issue that required me to build pywin32 on my own. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From theller at python.net Wed May 4 21:11:56 2005 From: theller at python.net (Thomas Heller) Date: Wed, 04 May 2005 21:11:56 +0200 Subject: [python-win32] CoUninitialize Message-ID: I'm experimenting with a pythoncom client which uses a ctypes.com server. I have the impression that DispatchWithEvents somehow doesn't clean up correctly. If I call pythoncom.CoUninitialize() before exiting the client script, the server will be closed. Not calling CoUninitialize() will leave the server running. Is there a reason why pythoncom doesn't call CoUninitialize() itself? Thomas From mhammond at skippinet.com.au Thu May 5 00:58:24 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 5 May 2005 08:58:24 +1000 Subject: [python-win32] CoUninitialize In-Reply-To: Message-ID: <083601c550fc$c77f5a40$0a0a0a0a@enfoldsystems.local> > I'm experimenting with a pythoncom client which uses a ctypes.com > server. I have the impression that DispatchWithEvents somehow doesn't > clean up correctly. That is possible. Most leaks of COM objects should be evident by querying pythoncom._GetInterfaceCount() and pythoncom._GetGatewayCount() - it would be interesting to know if these were both zero and you still had the problem. > Is there a reason why pythoncom doesn't call CoUninitialize() itself? We had a few problems trying to do that. In some cases when not all COM objects were explicitly closed, we found that system shutdown time could cause the object to attempt to release the COM pointer - but *after* CoUninit had been called. But I have found very few errors *not* calling it - especially when all COM objects have been cleaned up. I guess that is really just a matter of finding the correct hook (but note that in a COM DLL case, Python itself will never be Uninitialized! Mark From eric.powell at srs.gov Thu May 5 15:08:21 2005 From: eric.powell at srs.gov (eric.powell@srs.gov) Date: Thu, 05 May 2005 09:08:21 -0400 Subject: [python-win32] Excel and Graphing Message-ID: I am close to finishing a project using Excel objects in python to generate a series of graphs. However.... I can't get the series to add to the chart properly. I have an Excel chart with no series on it, so I am trying to add new series using the Chart.SeriesCollection.NewSeries call, but get the following error message: Traceback (most recent call last): File "O:\gis\projects\Reactors\Code\Python_Scripts\CMP_PITS_Chart_Tool\chart_tool.py", line 133, in ? create_series(filename, graph, series, scell, data, scount) File "O:\gis\projects\Reactors\Code\Python_Scripts\CMP_PITS_Chart_Tool\chart_tool.py", line 70, in create_series se = chart.SeriesCollection.NewSeries AttributeError: 'function' object has no attribute 'NewSeries' Code: def create_series(filename, graph, series, startcell, data, scount):#Assumes data is list, graph is a tuple, series is a tuple, startcell is a tuple #instatiate the Excel object xl = win32com.client.Dispatch("Excel.Application") #Open the workbook wb = xl.Workbooks.Open (filename) sh = wb.Sheets('ALLDATA') #write the data to the proper spot on the spreadsheet try: sh.Cells(startcell[0], startcell[1]).Value = series[2] + '_' + graph[0] + '_' + graph[5] n = 1 for row in data: sh.Cells(startcell[0]+n, startcell[1]).Value = row[0] sh.Cells(startcell[0]+n, startcell[1]+1).Value = row[1] n = n + 1 chart = wb.Charts(graph[0] + "_" + graph[5]) se = chart.SeriesCollection.NewSeries se.Name = series[2] se.XValues = '"=' + graph[0] + '_' + graph[5] + '!R' + str(startcell[0] +1) + 'C' + str(startcell[1]) + ':R' + str(startcell[0]+n) + 'C' + str(startcell[1]) + '"' se.Values = '"=' + graph[0] + '_' + graph[5] + '!R' + str(startcell[0] +1) + 'C' + str(startcell[1]+1) + ':R' + str(startcell[0]+n) + 'C' + str(startcell[1]+1) + '"' xl.ActiveWorkbook.Close(SaveChanges=1) except: raise print "Error Occurred writing data" xl.ActiveWorkbook.Close(SaveChanges=1) #Close the workbook xl.Quit del xl Any suggestions as to what exactly I am doing wrong? Eric B. Powell E&GIS BSRI (803)952-7783 When a true genius appears in this world you may know him by this sign, that the dunces are all in confederacy against him. (Swift) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050505/4a760d5c/attachment.html From villari at studenti.unina.it Thu May 5 15:57:59 2005 From: villari at studenti.unina.it (Matteo Villari) Date: Thu, 05 May 2005 15:57:59 +0200 Subject: [python-win32] [Newbie] KeyError: '__str__' Message-ID: <427A2667.4010405@studenti.unina.it> Hi. I'm not intended to learn Python actually but i have a little problem. I have to run a Python script under my Apache/win32 server. After solved some problems now the script runs but doesn't work properly. That's the output error Traceback (most recent call last): File "C:/Programmi/Apache Group/Apache2/cgi-bin/cacheability.py", line 901, in cgi_wrap cgi_main() File "C:/Programmi/Apache Group/Apache2/cgi-bin/cacheability.py", line 870, in cgi_main print " ", f, " " File "C:/Programmi/Apache Group/Apache2/cgi-bin/cacheability.py", line 111, in __repr__ p(" %s\n" % (self._hdrs.get('Cache-Control', " " + self.no_data))) File "C:\Programmi\Apache Group\Apache2\cgi-bin\httpheadertypes.py", line 280, in __getattr__ return self.__dict__[attr] KeyError: '__str__' The script is the cacheability engine by mnot (http://www.mnot.net/cacheability/) and i have no idea to how to solve this problem. Thank you very much for your patience, Matteo Villari From simon.brunning at gmail.com Thu May 5 16:11:48 2005 From: simon.brunning at gmail.com (Simon Brunning) Date: Thu, 5 May 2005 15:11:48 +0100 Subject: [python-win32] [Newbie] KeyError: '__str__' In-Reply-To: <427A2667.4010405@studenti.unina.it> References: <427A2667.4010405@studenti.unina.it> Message-ID: <8c7f10c60505050711dd3ee10@mail.gmail.com> On 5/5/05, Matteo Villari wrote: > Hi. > I'm not intended to learn Python actually but i have a little problem. I > have to run a Python script under my Apache/win32 server. After solved > some problems now the script runs but doesn't work > properly. (snip) > The script is the cacheability engine by mnot > (http://www.mnot.net/cacheability/) and i have no idea to how to solve > this problem. Well, neither have we with only that to go on. What where your original problems, and what did you do to fix them? -- Cheers, Simon B, simon at brunningonline.net, http://www.brunningonline.net/simon/blog/ From greg.landrum at gmail.com Thu May 5 16:15:39 2005 From: greg.landrum at gmail.com (Greg Landrum) Date: Thu, 5 May 2005 07:15:39 -0700 Subject: [python-win32] Excel and Graphing In-Reply-To: References: Message-ID: <60825b0f050505071512bfdbc2@mail.gmail.com> On 5/5/05, eric.powell at srs.gov wrote: > > I am close to finishing a project using Excel objects in python to generate > a series of graphs. > However.... > > I can't get the series to add to the chart properly. > > I have an Excel chart with no series on it, so I am trying to add new series > using the Chart.SeriesCollection.NewSeries call, but get > the following error message: > > Traceback (most recent call last): > File > "O:\gis\projects\Reactors\Code\Python_Scripts\CMP_PITS_Chart_Tool\chart_tool.py", > line 133, in ? > create_series(filename, graph, series, scell, data, scount) > File > "O:\gis\projects\Reactors\Code\Python_Scripts\CMP_PITS_Chart_Tool\chart_tool.py", > line 70, in create_series > se = chart.SeriesCollection.NewSeries > AttributeError: 'function' object has no attribute 'NewSeries' The error message is telling you that chart.SeriesCollection is a method, not an attribute (this is reinforced by the Excel Visual Basic reference). So you probably need to do: se = chart.SeriesCollection().NewSeries() -greg From villari at studenti.unina.it Thu May 5 17:04:07 2005 From: villari at studenti.unina.it (Matteo Villari) Date: Thu, 05 May 2005 17:04:07 +0200 Subject: [python-win32] [Newbie] KeyError: '__str__' In-Reply-To: <8c7f10c60505050711dd3ee10@mail.gmail.com> References: <427A2667.4010405@studenti.unina.it> <8c7f10c60505050711dd3ee10@mail.gmail.com> Message-ID: <427A35E7.7080203@studenti.unina.it> Simon Brunning ha scritto: >On 5/5/05, Matteo Villari wrote: > > >>Hi. >>I'm not intended to learn Python actually but i have a little problem. I >>have to run a Python script under my Apache/win32 server. After solved >>some problems now the script runs but doesn't work >>properly. >> >> > >(snip) > > > >>The script is the cacheability engine by mnot >>(http://www.mnot.net/cacheability/) and i have no idea to how to solve >>this problem. >> >> > >Well, neither have we with only that to go on. What where your >original problems, and what did you do to fix them? > > > My "problems" were related with python and apache configuration: I set path variables and i changed this entries in httpd.conf file Options Indexes ExecCGI Options FollowSymLinks ExecCGI then I set in the first line of scripts #!C:\programmi\Python\python.exe and according to IDLE "suggest" I Untabified all script sustituting with four blank spaces. After copying scripts in cgi-bin directory i started my browser conncting to 127.0.0.1:8080/cgi-bin/caheability.py and it run. but when i try to evaluate a page in my lan it says that message. I think it's all. Thank you very much again. Matteo Villari From bgailer at alum.rpi.edu Thu May 5 17:54:39 2005 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Thu, 05 May 2005 08:54:39 -0700 Subject: [python-win32] Excel and Graphing In-Reply-To: References: Message-ID: <6.1.2.0.0.20050505084418.03778008@pop.sbcglobal.yahoo.com> At 06:08 AM 5/5/2005, eric.powell at srs.gov wrote: >I am close to finishing a project using Excel objects in python to >generate a series of graphs. >However.... > >I can't get the series to add to the chart properly. > >I have an Excel chart with no series on it, so I am trying to add new >series using the Chart.SeriesCollection.NewSeries call, but get the >following error message: > >Traceback (most recent call last): > File > "O:\gis\projects\Reactors\Code\Python_Scripts\CMP_PITS_Chart_Tool\chart_tool.py", > line 133, in ? > create_series(filename, graph, series, scell, data, scount) > File > "O:\gis\projects\Reactors\Code\Python_Scripts\CMP_PITS_Chart_Tool\chart_tool.py", > line 70, in create_series > se = chart.SeriesCollection.NewSeries >AttributeError: 'function' object has no attribute 'NewSeries' "Function object" hmm... Try se = chart.SeriesCollection().NewSeries >Code: > > >def create_series(filename, graph, series, startcell, data, >scount):#Assumes data is list, graph is a tuple, series is a tuple, >startcell is a tuple > #instatiate the Excel object > xl = win32com.client.Dispatch("Excel.Application") > #Open the workbook > wb = xl.Workbooks.Open (filename) > sh = wb.Sheets('ALLDATA') > #write the data to the proper spot on the spreadsheet > try: > sh.Cells(startcell[0], startcell[1]).Value = series[2] + '_' + > graph[0] + '_' + graph[5] > n = 1 > for row in data: > sh.Cells(startcell[0]+n, startcell[1]).Value = row[0] > sh.Cells(startcell[0]+n, startcell[1]+1).Value = row[1] > n = n + 1 > chart = wb.Charts(graph[0] + "_" + graph[5]) > se = chart.SeriesCollection.NewSeries > se.Name = series[2] > se.XValues = '"=' + graph[0] + '_' + graph[5] + '!R' + > str(startcell[0] +1) + 'C' + str(startcell[1]) + ':R' + > str(startcell[0]+n) + 'C' + str(startcell[1]) + '"' > se.Values = '"=' + graph[0] + '_' + graph[5] + '!R' + > str(startcell[0] +1) + 'C' + str(startcell[1]+1) + ':R' + > str(startcell[0]+n) + 'C' + str(startcell[1]+1) + '"' > xl.ActiveWorkbook.Close(SaveChanges=1) > except: > raise > print "Error Occurred writing data" > xl.ActiveWorkbook.Close(SaveChanges=1) > #Close the workbook > xl.Quit > del xl > > >Any suggestions as to what exactly I am doing wrong? > >Eric B. Powell >E&GIS >BSRI >(803)952-7783 > >When a true genius appears in this world you may know him by this sign, >that the dunces are all in confederacy against him. (Swift) >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 Bob Gailer mailto:bgailer at alum.rpi.edu 510 558 3275 home 720 938 2625 cell -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050505/a6e44efe/attachment-0001.htm From eric.powell at srs.gov Thu May 5 17:58:47 2005 From: eric.powell at srs.gov (eric.powell@srs.gov) Date: Thu, 05 May 2005 11:58:47 -0400 Subject: [python-win32] Excel and Graphin - Solved Message-ID: Greg and Bob- That fixed it. Thanks! Everyone else: The problem was missing parentheses (sp?) Line: se = chart.SeriesCollection.NewSeries Should be: se = chart.SeriesCollection().NewSeries() Thanks for the help! Eric Eric B. Powell E&GIS BSRI (803)952-7783 When a true genius appears in this world you may know him by this sign, that the dunces are all in confederacy against him. (Swift) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050505/0b53c22f/attachment.html From theller at python.net Fri May 6 11:00:22 2005 From: theller at python.net (Thomas Heller) Date: Fri, 06 May 2005 11:00:22 +0200 Subject: [python-win32] CoUninitialize References: <083601c550fc$c77f5a40$0a0a0a0a@enfoldsystems.local> Message-ID: <8y2s6861.fsf@python.net> >> I'm experimenting with a pythoncom client which uses a ctypes.com >> server. I have the impression that DispatchWithEvents somehow doesn't >> clean up correctly. > > That is possible. Most leaks of COM objects should be evident by querying > pythoncom._GetInterfaceCount() and pythoncom._GetGatewayCount() - it would > be interesting to know if these were both zero and you still had the > problem. Here is the program I use, it is accessing a localserver COM object: """ # ctypes client code, using the CSum COM object from win32com.client import Dispatch, DispatchWithEvents import pythoncom class events: def OnAdded(self, *args): print "OnAdded", args def test(): s = DispatchWithEvents("ctypes.SumObject", events) ## s = Dispatch("ctypes.SumObject") print "Adding" print s.Add(3.14, 2.78) del s print "pythoncom._GetInterfaceCount():", pythoncom._GetInterfaceCount() print "pythoncom._GetGatewayCount():", pythoncom._GetGatewayCount() print "pythoncom.CoUninitialize()" pythoncom.CoUninitialize() print "pythoncom._GetInterfaceCount():", pythoncom._GetInterfaceCount() print "pythoncom._GetGatewayCount():", pythoncom._GetGatewayCount() if __name__ == "__main__": test() """ and the output: """ C:\sf\ctypes_dist\win32\com\samples\server>py23 w32_user.py Adding OnAdded () 5.92 pythoncom._GetInterfaceCount(): 1 pythoncom._GetGatewayCount(): 3 pythoncom.CoUninitialize() pythoncom._GetInterfaceCount(): 0 pythoncom._GetGatewayCount(): 0 C:\sf\ctypes_dist\win32\com\samples\server> """ >> Is there a reason why pythoncom doesn't call CoUninitialize() itself? > > We had a few problems trying to do that. In some cases when not all COM > objects were explicitly closed, we found that system shutdown time could > cause the object to attempt to release the COM pointer - but *after* > CoUninit had been called. But I have found very few errors *not* calling > it - especially when all COM objects have been cleaned up. I guess that is > really just a matter of finding the correct hook (but note that in a COM DLL > case, Python itself will never be Uninitialized! ctypes.com uses this strategy to initialize and deinitialize (the code is part of the ctypes.com module): """ ole32.CoInitialize(None) class _Cleaner(object): def __del__(self, func=ole32.CoUninitialize): # Sometimes, CoUnititialize, running at Python shutdown, raises an exception. # We suppress this when __debug__ is False. if __debug__: func() else: try: func() except WindowsError: pass __cleaner = _Cleaner() del _Cleaner def _clean_exc_info(): # the purpose of this function is to ensure that no com object # pointers are in sys.exc_info() try: 1//0 except: pass import atexit atexit.register(_clean_exc_info) """ Thomas From python-win32 at ols.inorganic.org Fri May 6 11:45:21 2005 From: python-win32 at ols.inorganic.org (Roy S. Rapoport) Date: Fri, 6 May 2005 02:45:21 -0700 Subject: [python-win32] Python win32 version of Variant Message-ID: <20050506094521.GA133@puppy.inorganic.org> Having done Python programming for a while on UNIX platforms, I'm finding that win32 com stuff is ... interesting. My main current challenge is that I need to drive Internet Explorer to do some web testing. Now, this is actually somewhat decently done (and IEC.py does some of the heavy lifting anyway). The problem I'm running into is trying to actually authenticate using basic auth. Now, I know how basic auth works -- I just need to make IE navigate to a given URL after having added a header with the authentication information. IE's com interface even lets me do that, as http://msdn.microsoft.com/workshop/browser/webbrowser/reference/methods/navigate.asp documents -- I just need to give it a Headers variable as the fifth argument. What I'm trying to figure out, however, is how to do that. The doc indicates the headers are to be given as a Variant, but I have no idea what that means in Python-land. I've tried ie.Navigate(, None, None, None, ) and ie.Navigate(, None, None, None,
) to no avail. Any suggestions as to what I'm missing or, even better, what documentation I might be able to find that answers this question? This definitely seems like an RTFM sort of thing -- I just don't know what to look for. -roy From rwupole at msn.com Fri May 6 15:14:52 2005 From: rwupole at msn.com (Roger Upole) Date: Fri, 6 May 2005 09:14:52 -0400 Subject: [python-win32] Re: Python win32 version of Variant References: <20050506094521.GA133@puppy.inorganic.org> Message-ID: The Headers parm is just a string containing normal http request headers, something like 'User-Agent: fakebrowser\nReferer: somepage.html\nMethod: POST\n\n' hth Roger ----- Original Message ----- From: "Roy S. Rapoport" To: Sent: Friday, May 06, 2005 5:45 AM Subject: [python-win32] Python win32 version of Variant > Having done Python programming for a while on UNIX platforms, I'm finding > that win32 com stuff is ... interesting. My main current challenge is > that > I need to drive Internet Explorer to do some web testing. Now, this is > actually somewhat decently done (and IEC.py does some of the heavy lifting > anyway). The problem I'm running into is trying to actually authenticate > using basic auth. > > Now, I know how basic auth works -- I just need to make IE navigate to a > given URL after having added a header with the authentication information. > IE's com interface even lets me do that, as > http://msdn.microsoft.com/workshop/browser/webbrowser/reference/methods/navigate.asp > > documents -- I just need to give it a Headers variable as the fifth > argument. What I'm trying to figure out, however, is how to do that. The > doc indicates the headers are to be given as a Variant, but I have no idea > what that means in Python-land. I've tried > ie.Navigate(, None, None, None, ) > and > ie.Navigate(, None, None, None,
) > > to no avail. > > Any suggestions as to what I'm missing or, even better, what documentation > I might be able to find that answers this question? This definitely seems > like an RTFM sort of thing -- I just don't know what to look for. > > -roy > > From b6y9eq902 at sneakemail.com Sat May 7 21:52:11 2005 From: b6y9eq902 at sneakemail.com (b6y9eq902@sneakemail.com) Date: 7 May 2005 19:52:11 -0000 Subject: [python-win32] Click detection in Windows (was 'HookMessage Failure?') Message-ID: <24455-56712@sneakemail.com> Sorry for lack of reply to this, I've had some other stuff come up. To rehash: I'm basically trying to detect clicks to a particular windows application. I've tried registering a callback via PyCWnd.HookMessage (as in the reply quoted below), but it didn't seem to work at all. Is there any way to simply detect *all* mouse clicks in Windows? I'd prefer to detect when it's clicked in the application, but if necessary I'm fine just trying to detect all of them and seeing if my desired application is the foreground window. Is this possible? How would I go about doing this? Thanks, -Mark On Apr 10, 2005 1:12 AM, Marcus Goldfish wrote: Did you get this to work? I tried the following snippet to no avail. Anyone have suggestions? import winGuiAuto import win32ui, win32con def handler(*args): print "handler called" hwnd = winGuiAuto.findTopWindow("calculator") pwin = win32ui.CreateWindowFromHandle(hwnd) pwin.HookMessage(handler, win32con.WM_LBUTTONDOWN) From mhammond at skippinet.com.au Sun May 8 12:59:32 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 8 May 2005 20:59:32 +1000 Subject: [python-win32] Click detection in Windows (was 'HookMessageFailure?') In-Reply-To: <24455-56712@sneakemail.com> Message-ID: <136701c553bd$04824de0$0a0a0a0a@enfoldsystems.local> > To rehash: I'm basically trying to detect clicks to a > particular windows application. I've tried registering a > callback via PyCWnd.HookMessage (as in the reply quoted > below), but it didn't seem to work at all. HookMessage has nothing to do with a "Windows Message Hook" - it only works when the message has its WNDPROC implemented in MFC. > Is there any way to simply detect *all* mouse clicks in > Windows? I'd prefer to detect when it's clicked in the > application, but if necessary I'm fine just trying to detect > all of them and seeing if my desired application is the > foreground window. > > Is this possible? How would I go about doing this? You probably want something like SetWindowsHookEx - see MSDN. This is not wrapped by pywin32 - you may find ctypes useful for using it. Mark From nanotube at gmail.com Sun May 8 22:23:54 2005 From: nanotube at gmail.com (Daniel F) Date: Sun, 8 May 2005 16:23:54 -0400 Subject: [python-win32] Click detection in Windows (was 'HookMessageFailure?') In-Reply-To: <136701c553bd$04824de0$0a0a0a0a@enfoldsystems.local> References: <24455-56712@sneakemail.com> <136701c553bd$04824de0$0a0a0a0a@enfoldsystems.local> Message-ID: > > Is there any way to simply detect *all* mouse clicks in > > Windows? I'd prefer to detect when it's clicked in the > > application, but if necessary I'm fine just trying to detect > > all of them and seeing if my desired application is the > > foreground window. > > > > Is this possible? How would I go about doing this? > > You probably want something like SetWindowsHookEx - see MSDN. This is not > wrapped by pywin32 - you may find ctypes useful for using it. > or even better, try using the pyHook module (which wraps SetWindowHookEx through ctypes for you already, presenting a convenient python interface). just google "pyhook". -d From python at kareta.de Mon May 9 11:26:37 2005 From: python at kareta.de (=?ISO-8859-15?Q?J=FCrgen_Kareta?=) Date: Mon, 09 May 2005 11:26:37 +0200 Subject: [python-win32] win32pipe.popen and stdout Message-ID: <427F2CCD.2000308@kareta.de> Hi, I have two questions about win32pipe popen methods and stdin and stdout: I played with the ps2pdf batch in ghostscript. If I call the batch from python with win32pipe.popen, giving two real files as soure and destination, it works fine. Calling the batch with a '-' for destination, the output is send to stdout. But if I try to fetch it inside python I get only roundabout 300 bytes and the rest is lost (with the read method). If I add another read statement I get a few other bytes from the stdout. code: pipe = win32pipe.popen('..\\ps2pdf.bat test.ps -','r') msvcrt.setmode(pipe.fileno(),O_BINARY) pdf_file=pipe.read() pipe.close() /code Is there a way the fetch the hole content of stdout ? second question: I'm wondering how to set the stdin for the subprocess: (input,output) = win32pipe.popen2('my_command input.write(my_content)) would the above statement set the stdin pipe of my_command with my_content ? thanks in advance J?rgen From tim.leeuwvander at nl.unisys.com Mon May 9 11:47:39 2005 From: tim.leeuwvander at nl.unisys.com (Leeuw van der, Tim) Date: Mon, 9 May 2005 11:47:39 +0200 Subject: [python-win32] win32pipe.popen and stdout Message-ID: Just continue reading until end-of-file, just like you'd read any other file! (for instance when reading a file line-by-line). The PDF is still being produced as you read it, so just read on until end of file and append it to your buffer. (Perhaps you can read it line-by-line, isn't PDF as sort of text format?) cheers, --Tim -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Jurgen Kareta Sent: Monday, May 09, 2005 11:27 AM To: python-win32 Mailinglist Subject: [python-win32] win32pipe.popen and stdout Hi, I have two questions about win32pipe popen methods and stdin and stdout: I played with the ps2pdf batch in ghostscript. If I call the batch from python with win32pipe.popen, giving two real files as soure and destination, it works fine. Calling the batch with a '-' for destination, the output is send to stdout. But if I try to fetch it inside python I get only roundabout 300 bytes and the rest is lost (with the read method). If I add another read statement I get a few other bytes from the stdout. code: pipe = win32pipe.popen('..\\ps2pdf.bat test.ps -','r') msvcrt.setmode(pipe.fileno(),O_BINARY) pdf_file=pipe.read() pipe.close() /code Is there a way the fetch the hole content of stdout ? second question: I'm wondering how to set the stdin for the subprocess: (input,output) = win32pipe.popen2('my_command input.write(my_content)) would the above statement set the stdin pipe of my_command with my_content ? thanks in advance J?rgen _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From eric.powell at srs.gov Mon May 9 18:54:44 2005 From: eric.powell at srs.gov (eric.powell@srs.gov) Date: Mon, 09 May 2005 12:54:44 -0400 Subject: [python-win32] (no subject) Message-ID: Hello again, all- I am still trying to understand Windows COM from Python. This time, I am trying to access a custom COM object an in-house developer has developed in C++. The class is stored in a dll registered with my system, and can be called from VB as follows: >From a working VB project: ' set up the input Dim pConv As New SRS_CONLib.Point2D However, when I try to call the clas via win32com, I get error messages. In Python: srs = win32com.client.Dispatch(r'SRS_CONLib.Point2D') The error: Traceback (most recent call last): File "", line 1, in -toplevel- srs = win32com.client.Dispatch(r'SRS_CONLib.Point2D') File "C:\PYTHON23\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\PYTHON23\lib\site-packages\win32com\client\dynamic.py", line 84, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\PYTHON23\lib\site-packages\win32com\client\dynamic.py", line 72, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221005, 'Invalid class string', None, None) The developer tells me the IDispatch interface is enabled, and the SRSCON_Lib.Point2D should be in the registry. Thanks in advance for any assistance.... Eric Eric B. Powell E&GIS BSRI (803)952-7783 When a true genius appears in this world you may know him by this sign, that the dunces are all in confederacy against him. (Swift) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050509/5aa92d33/attachment.htm From dcrespo at grupozoom.com Mon May 9 17:13:10 2005 From: dcrespo at grupozoom.com (Daniel Crespo) Date: Mon, 9 May 2005 11:13:10 -0400 Subject: [python-win32] PyShell's code completion into DrPython Message-ID: I would like to adapt the PyShell code completion to DrPython, because both programs are very good... Any clue for start finding the code location in both programs to accomplish this? Thanks From b6y9eq902 at sneakemail.com Mon May 9 21:10:58 2005 From: b6y9eq902 at sneakemail.com (b6y9eq902@sneakemail.com) Date: 9 May 2005 19:10:58 -0000 Subject: [python-win32] Click detection in Windows (was 'HookMessageFailure?') Message-ID: <28892-07492@sneakemail.com> Excellent! That's exactly what I was hoping to find. Thanks! -Mark On 5/8/05, Daniel F wrote: > or even better, try using the pyHook module (which wraps > SetWindowHookEx through ctypes for you already, presenting a > convenient python interface). just google "pyhook". > > -d > From mli at deform.com Mon May 9 21:59:02 2005 From: mli at deform.com (Michael Li) Date: Mon, 09 May 2005 15:59:02 -0400 Subject: [python-win32] how to browse another computer's folder treestructure ? In-Reply-To: <4272511F.6000906@holdenweb.com> References: <0a0101c54a32$8d69d270$0a00a8c0@enfoldsystems.local> <42713CDD.5050700@deform.com> <4272511F.6000906@holdenweb.com> Message-ID: <427FC106.2080700@deform.com> Steve Holden wrote: > Michael Li wrote: > >> Hi, Mark >> >> Thank you very much. >> It works, but only shows shared folders, not all the folders, >> is it possible to show all folders ? >> > [...] > Assuming you don't have permission to access administrative shares, what > legitimate use case could there be for accessing non-shared materials on > other computers? In a clustering environment, sometimes a job has been submitted from computer A to computer B, the job runs on a local drive at computer B, so you want to monitor running situation at computer B from computer A. Sometimes before you submit a job to computer B, you want to know the local path in the computer B, so you can specify the local folder as your running folder from computer A. My point or my questions is that assume it's in a trusted computer cluster(there is no security concern), is there an easy way to browse local folder tree at computer B from computer A ? > > regards > Steve From mhammond at skippinet.com.au Tue May 10 00:38:53 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 10 May 2005 08:38:53 +1000 Subject: [python-win32] (no subject) In-Reply-To: Message-ID: <17ad01c554e7$e19a6de0$0a0a0a0a@enfoldsystems.local> "SRS_CONLib.Point2D" is not the "ProgID" of the object - it is the name of the typelib and interface in that typelib. If your object can be used with Dispatch, it should be possible to create the object in VB using "CreateObject" - CreateObject wants the ProgID too - ie, it will fail with "SRS_CONLib.Point2D". Whatever you can pass to CreateObject can be passed to Python's dispatch. Ask the developer what the "ProgID" of the object is. Cheers, Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of eric.powell at srs.gov Sent: Tuesday, 10 May 2005 2:55 AM To: python-win32 Mailinglist Subject: [python-win32] (no subject) Hello again, all- I am still trying to understand Windows COM from Python. This time, I am trying to access a custom COM object an in-house developer has developed in C++. The class is stored in a dll registered with my system, and can be called from VB as follows: >From a working VB project: ' set up the input Dim pConv As New SRS_CONLib.Point2D However, when I try to call the clas via win32com, I get error messages. In Python: srs = win32com.client.Dispatch(r'SRS_CONLib.Point2D') The error: Traceback (most recent call last): File "", line 1, in -toplevel- srs = win32com.client.Dispatch(r'SRS_CONLib.Point2D') File "C:\PYTHON23\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\PYTHON23\lib\site-packages\win32com\client\dynamic.py", line 84, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\PYTHON23\lib\site-packages\win32com\client\dynamic.py", line 72, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221005, 'Invalid class string', None, None) The developer tells me the IDispatch interface is enabled, and the SRSCON_Lib.Point2D should be in the registry. Thanks in advance for any assistance.... Eric Eric B. Powell E&GIS BSRI (803)952-7783 When a true genius appears in this world you may know him by this sign, that the dunces are all in confederacy against him. (Swift) From dave at psys.org Tue May 10 00:48:34 2005 From: dave at psys.org (d.w. harks) Date: Mon, 9 May 2005 17:48:34 -0500 Subject: [python-win32] how to browse another computer's folder treestructure ? In-Reply-To: <427FC106.2080700@deform.com> References: <0a0101c54a32$8d69d270$0a00a8c0@enfoldsystems.local> <42713CDD.5050700@deform.com> <4272511F.6000906@holdenweb.com> <427FC106.2080700@deform.com> Message-ID: <20050509224833.GK24249@psys.org> With carefully-arranged electrons, Michael Li wrote: > > > Steve Holden wrote: > > Michael Li wrote: > > > >> Hi, Mark > >> > >> Thank you very much. > >> It works, but only shows shared folders, not all the folders, > >> is it possible to show all folders ? > >> > > [...] > > Assuming you don't have permission to access administrative shares, what > > legitimate use case could there be for accessing non-shared materials on > > other computers? > In a clustering environment, sometimes a job has been submitted from > computer A to computer B, the job runs on a local drive at computer B, > so you want to monitor running situation at computer B from computer A. > Sometimes before you submit a job to computer B, you want to know > the local path in the computer B, so you can specify the local folder > as your running folder from computer A. My point or my questions is > that assume it's in a trusted computer cluster(there is no security > concern), is there an easy way to browse local folder tree at > computer B from computer A ? > > > > regards > > Steve Share the relevant subtree and browse it as a network share. Even better, don't depend on local storage except as temporary space; either set up a central storage area over a network or build a SAN. Then it doesn't matter which computer is handling the process; the path can remain the same and is accessible from any station in the cluster. d -- David W. Harks http://www.pseudointellect.com From nalli.dinesh at gmail.com Tue May 10 01:23:08 2005 From: nalli.dinesh at gmail.com (Nalli Dinesh) Date: Mon, 9 May 2005 16:23:08 -0700 Subject: [python-win32] Setting environment variables in windows from Python Programs Message-ID: Folks, This seems very easy, as every programming language provides this. But I don;t know why I have this not working for me in Python scripts. The problem: I am trying to create and set environment variable LANG under windows from Python file. I am using OS module's putenv or environ to do so. But it is not really creating the environment variable or neither set the same from the code. This seems to be a easy fix, if anyone has a reason and fix for this problem, please shoot it back to me. I am using python2.4 Thanks Dinesh From Paul.Weimer at harlandfs.com Tue May 10 07:12:55 2005 From: Paul.Weimer at harlandfs.com (Paul Weimer) Date: Mon, 9 May 2005 22:12:55 -0700 Subject: [python-win32] Python embedded in an MFC app question Message-ID: I have an MFC app that uses Python. All is working well but I was asked to put in an enhancement whose behavior has me stumped. We use the login dialog that lives in pywin\dialogs and have never had a problem. My users want the cursor to auto tab to the password control after a specified number of characters are entered. I made a copy of the script, and added: self.userIDCtl = self.GetDlgItem(win32ui.IDC_EDIT1) self.passwordCtl = self.GetDlgItem(win32ui.IDC_EDIT2) # Set a handler so that any keystrokes entered in the userid edit control will be processed in OnUserIDKeyDown self.userIDCtl.HookAllKeyStrokes(self.OnUserIDKeyDown) along with OnUserIDKeyDown(self, std). Now here's the problem: it works fine when run in PythonWin and when I run the debug version of my MFC app with the non-debug python22.dll but when I run the release version of my app the handler OnUserIDKeyDown(self, std) never gets called. My suspicion is message pump confusion. Does anyone have any ideas? Thanks Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050509/87989fb1/attachment.htm From p.f.moore at gmail.com Tue May 10 10:38:24 2005 From: p.f.moore at gmail.com (Paul Moore) Date: Tue, 10 May 2005 09:38:24 +0100 Subject: [python-win32] Setting environment variables in windows from Python Programs In-Reply-To: References: Message-ID: <79990c6b0505100138f967b2@mail.gmail.com> On 5/10/05, Nalli Dinesh wrote: > Folks, > This seems very easy, as every programming language provides this. But > I don;t know why I have this not working for me in Python scripts. > The problem: > I am trying to create and set environment variable LANG under windows > from Python file. I am using OS module's putenv or environ to do so. > But it is not really creating the environment variable or neither set > the same from the code. > This seems to be a easy fix, if anyone has a reason and fix for this > problem, please shoot it back to me. I am using python2.4 No program, in any language, can set an environment variable which will affect the shell from which that program was launched. The only exceptions are: - batch files, which are interpreted by the shell itself - languages with some form of intimate relationship with the shell (some shells have this relationship with the REXX language) - Windows API calls to set the global environment, and then notify running shells to pick up the changes I'm assuming you don't mean the third option (and I don't know the details of the calls required, if you do). Perhaps you can give an example of what you want to do (using another language, as you can't get it to work in Python)? But if I have understood your description correctly, I'm afraid it isn't "very easy". Paul. From eric.powell at srs.gov Tue May 10 14:19:33 2005 From: eric.powell at srs.gov (eric.powell@srs.gov) Date: Tue, 10 May 2005 08:19:33 -0400 Subject: [python-win32] (no subject) In-Reply-To: <17ad01c554e7$e19a6de0$0a0a0a0a@enfoldsystems.local> Message-ID: Mark- The example application I am working from does the following (but never actually does a CreateObject with the dll): ' set up the input Dim pConv As New SRS_CONLib.Point2D pConv.x = CDbl(m_sX) pConv.y = CDbl(m_sY) pConv.Projection = m_inProj ' check to see if the range is valid (or the user wants to override) If checkRange(pConv.x, pConv.y, m_inProj) = False Then Exit Sub The reference the the dll is as follows: Reference=*\G{A816BA3B-2465-11D5-9122-000629432AA8}#1.0#0#C:\Program Files\EGIS Utilities\ArcMap\17_srs_con.dll#srs_con 1.0 Type Library Is what I need in either of these places? Or can I get to it from either of these two places. As you can tell, I am baffled by COM.... Thanks again, Eric PS I forwarded your message to the developer, but haven't heard back yet. Eric B. Powell E&GIS BSRI (803)952-7783 When a true genius appears in this world you may know him by this sign, that the dunces are all in confederacy against him. (Swift) "Mark Hammond" 05/09/2005 06:38 PM To , "'python-win32 Mailinglist'" cc Subject RE: [python-win32] (no subject) "SRS_CONLib.Point2D" is not the "ProgID" of the object - it is the name of the typelib and interface in that typelib. If your object can be used with Dispatch, it should be possible to create the object in VB using "CreateObject" - CreateObject wants the ProgID too - ie, it will fail with "SRS_CONLib.Point2D". Whatever you can pass to CreateObject can be passed to Python's dispatch. Ask the developer what the "ProgID" of the object is. Cheers, Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of eric.powell at srs.gov Sent: Tuesday, 10 May 2005 2:55 AM To: python-win32 Mailinglist Subject: [python-win32] (no subject) Hello again, all- I am still trying to understand Windows COM from Python. This time, I am trying to access a custom COM object an in-house developer has developed in C++. The class is stored in a dll registered with my system, and can be called from VB as follows: >From a working VB project: ' set up the input Dim pConv As New SRS_CONLib.Point2D However, when I try to call the clas via win32com, I get error messages. In Python: srs = win32com.client.Dispatch(r'SRS_CONLib.Point2D') The error: Traceback (most recent call last): File "", line 1, in -toplevel- srs = win32com.client.Dispatch(r'SRS_CONLib.Point2D') File "C:\PYTHON23\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\PYTHON23\lib\site-packages\win32com\client\dynamic.py", line 84, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\PYTHON23\lib\site-packages\win32com\client\dynamic.py", line 72, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221005, 'Invalid class string', None, None) The developer tells me the IDispatch interface is enabled, and the SRSCON_Lib.Point2D should be in the registry. Thanks in advance for any assistance.... Eric Eric B. Powell E&GIS BSRI (803)952-7783 When a true genius appears in this world you may know him by this sign, that the dunces are all in confederacy against him. (Swift) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050510/d24f4a55/attachment.html From les.novotny at progressive-solutions.com Tue May 10 02:58:38 2005 From: les.novotny at progressive-solutions.com (Les Novotny) Date: Mon, 9 May 2005 17:58:38 -0700 Subject: [python-win32] Looking for Serial I/O python driver Message-ID: Hi, I am looking for a python module for serial I/O such that from python on windows I can send a sequence of characters out COM1 followed by a carriage return to an intelligent device (that interprets the data) and then I need to capture a returned string of characters that comes back from the device (the string that comes back also terminates in a carriage return). I have tried the pyserial module, which works for the sending of the data, but receiving seems to be a problem. Essentially I want to send a sequence and then capture the received data back into a variable, which I can then parse through. I am not subscribed to the newgroups, but if anyone has any ideas or seen any open source code that would work , please email it to me at les-novotny at shaw.ca Thanks, les From glee at pharsight.com Tue May 10 02:23:17 2005 From: glee at pharsight.com (Greg Lee) Date: Mon, 9 May 2005 17:23:17 -0700 Subject: [python-win32] win32all-155/genpy/universal incompatibility Message-ID: <08AAC77C2656414E91980F8EBB1E7F01037EFBBE@electra.corp.pharsight.com> It appears that win32com/client/genpy.py and win32com/universal.py in win32all-155 are incompatible: genpy.py/VTableItem.WriteVTableMap writes vtable entries as six-tuples but universal.py/Method.__init__ unpacks them as three-tuples. This manifests itself as an unpack error in win32com.universal.RegisterInterfaces. Is my diagnosis correct? And what is the minimal upgrade that would eliminate this error? We're using Python 2.3, win32all-155, py2exe-0.4.2, and PyXML-0.8.3. I'm aware that these are 18-month-old versions, but they've been quite stable. This incompatibility appears to have vanished sometime before pywin32-203, which I'm using with an experimental Python 2.4 system. Thanks -------------------------------------------- Greg Lee / Pharsight Corporation / Suite 200 800 W El Camino / Mountain View CA 94040 voice: 650-314-3860 / fax: 650-314-3810 This email message (including any attachments) is for the sole use of the intended recipient and may contain confidential and proprietary information. Any disclosure or distribution to third parties that is not specifically authorized by the sender is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. Thank you. From niki at vintech.bg Tue May 10 17:54:19 2005 From: niki at vintech.bg (Niki Spahiev) Date: Tue, 10 May 2005 18:54:19 +0300 Subject: [python-win32] Looking for Serial I/O python driver In-Reply-To: References: Message-ID: <4280D92B.1000401@vintech.bg> Les Novotny wrote: > Hi, > I am looking for a python module for serial I/O such that from python on > windows I can send a sequence of characters out COM1 followed by a > carriage return to an intelligent device (that interprets the data) and > then I need to capture a returned string of characters that comes back > from the device (the string that comes back also terminates in a > carriage return). > > I have tried the pyserial module, which works for the sending of the > data, but receiving seems to be a problem. > > Essentially I want to send a sequence and then capture the received data > back into a variable, which I can then parse through. > > I am not subscribed to the newgroups, but if anyone has any ideas or > seen any open source code that would work , please email it to me at > les-novotny at shaw.ca I have no problem using pyserial with dumb devices (CNC). IMO it should work with smart devices too. Niki Spahiev From timr at probo.com Tue May 10 19:54:13 2005 From: timr at probo.com (Tim Roberts) Date: Tue, 10 May 2005 10:54:13 -0700 Subject: [python-win32] Setting environment variables in windows from Python Programs In-Reply-To: References: Message-ID: <4280F545.2090301@probo.com> On Mon, 9 May 2005 16:23:08 -0700, Nalli Dinesh wrote: >This seems very easy, as every programming language provides this. But >I don;t know why I have this not working for me in Python scripts. >The problem: >I am trying to create and set environment variable LANG under windows >from Python file. I am using OS module's putenv or environ to do so. >But it is not really creating the environment variable or neither set >the same from the code. >This seems to be a easy fix, if anyone has a reason and fix for this >problem, please shoot it back to me. I am using python2.4 > > Paul is exactly right. You cannot change the environment of the shell from which you started, in any language, on any (popular) operating system. You can only affect your own environment, and those of any processes you start. This is usually enough: C:\Tmp>set LANG Environment variable LANG not defined C:\Tmp>python Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.environ['LANG'] Traceback (most recent call last): File "", line 1, in ? File "c:\apps\python23\lib\os.py", line 417, in __getitem__ return self.data[key.upper()] KeyError: 'LANG' >>> os.environ['LANG']='language' >>> os.system('set L') LANG=language LIB=C:\VS.NET\VC7\ATLMFC\LIB;C:\VS.NET\VC7\LIB;C:\VS.NET\VC7\PlatformSDK\lib\pre release;C:\VS.NET\VC7\PlatformSDK\lib;C:\VS.NET\SDK\v1.1\lib; LOGNAME=timr LOGONSERVER=\\DOUG 0 >>> ^Z C:\Tmp>set LANG Environment variable LANG not defined C:\Tmp> -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Wed May 11 00:17:32 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 11 May 2005 08:17:32 +1000 Subject: [python-win32] win32all-155/genpy/universal incompatibility In-Reply-To: <08AAC77C2656414E91980F8EBB1E7F01037EFBBE@electra.corp.pharsight.com> Message-ID: <19dc01c555ae$107d3a40$0a0a0a0a@enfoldsystems.local> > It appears that win32com/client/genpy.py and > win32com/universal.py in win32all-155 are incompatible: > genpy.py/VTableItem.WriteVTableMap writes vtable entries as > six-tuples but > universal.py/Method.__init__ unpacks them as three-tuples. > This manifests itself as an unpack error in > win32com.universal.RegisterInterfaces. > > Is my diagnosis correct? It rings a bell. > And what is the minimal upgrade that would eliminate this error? I really can't recall. I expect that simply upgrading "universal" would work. Mark -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 1816 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050511/31d85991/winmail-0001.bin From cappy2112 at gmail.com Wed May 11 00:41:30 2005 From: cappy2112 at gmail.com (Tony C) Date: Tue, 10 May 2005 15:41:30 -0700 Subject: [python-win32] Python-win32 Digest, Vol 26, Issue 12 In-Reply-To: References: Message-ID: <8249c4ac050510154111e5c73c@mail.gmail.com> Your example didn't try to define the variable, it only attempted to look at it's current value try this >> C:\Tmp>set LANG >> Environment variable LANG not defined C:\tmp> set LANG="SOME_LANGUAGE" set LANG LANG="SOME_LANGUAGE" Message: 5 Date: Tue, 10 May 2005 10:54:13 -0700 From: Tim Roberts Subject: Re: [python-win32] Setting environment variables in windows from Python Programs To: python-win32 at python.org Message-ID: <4280F545.2090301 at probo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed On Mon, 9 May 2005 16:23:08 -0700, Nalli Dinesh wrote: >This seems very easy, as every programming language provides this. But >I don;t know why I have this not working for me in Python scripts. >The problem: >I am trying to create and set environment variable LANG under windows >from Python file. I am using OS module's putenv or environ to do so. >But it is not really creating the environment variable or neither set >the same from the code. >This seems to be a easy fix, if anyone has a reason and fix for this >problem, please shoot it back to me. I am using python2.4 > > Paul is exactly right. You cannot change the environment of the shell from which you started, in any language, on any (popular) operating system. You can only affect your own environment, and those of any processes you start. This is usually enough: C:\Tmp>set LANG Environment variable LANG not defined C:\Tmp>python Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.environ['LANG'] Traceback (most recent call last): File "", line 1, in ? File "c:\apps\python23\lib\os.py", line 417, in __getitem__ return self.data[key.upper()] KeyError: 'LANG' >>> os.environ['LANG']='language' >>> os.system('set L') LANG=language LIB=C:\VS.NET\VC7\ATLMFC\LIB;C:\VS.NET\VC7\LIB;C:\VS.NET\VC7\PlatformSDK\lib\pre release;C:\VS.NET\VC7\PlatformSDK\lib;C:\VS.NET\SDK\v1.1\lib; LOGNAME=timr LOGONSERVER=\\DOUG 0 >>> ^Z C:\Tmp>set LANG Environment variable LANG not defined C:\Tmp> From mjmaurer at yahoo.com Wed May 11 05:46:23 2005 From: mjmaurer at yahoo.com (Michael Maurer) Date: Tue, 10 May 2005 20:46:23 -0700 (PDT) Subject: [python-win32] PyCListCtrl.GetItem() across processes Message-ID: <20050511034623.63668.qmail@web54404.mail.yahoo.com> Hello, I am trying to read the contents of a CListCtrl. The control is in a window owned by a non-python process. I can get pretty close but ultimately get a failure from PyCListCtrl.GetItem(). I think it's because the python layer is passing a pointer from its own address space to a different process when it asks the CListCtrl to respond to GetItem(). Specifically, I have: * Process A, non-python process, has window with CListCtrl control * Process B, python process, executes the following steps: - win32gui.EnumWindows to find the window in process A - win32gui.EnumChildWindows to find the list control in that window - win32ui.CreateWindowFromHandle to wrap the control's handle with a PyCListCtrl object - PyCListCtrl.GetItemCount() works fine, as do other getters and setters that don't require pointers - PyCListCtrl.GetItem() fails with the message: "GetItem failed" The error seems to be coming from win32ctrlList.cpp PyCListCtrl_GetItem() function, which allocates a local LV_ITEM on the stack and then passes the address to CListCtrl->GetItem(). I found this article that explains how to use the VirtualAllocEx(), ReadProcessMemory() and WriteProcessMemory() functions to do something very similar to what I want, but in C: http://www.codeproject.com/threads/int64_memsteal.asp So my questions are: 1. is my diagnosis of the problem correct? 2. is there any way to do a cross-process GetItem() from python? 3. more important, is there another way to do what I want from python, which is to read the contents of a CListCtrl contained in a window owned by another process? Thanks, Michael M __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ From timr at probo.com Wed May 11 19:43:16 2005 From: timr at probo.com (Tim Roberts) Date: Wed, 11 May 2005 10:43:16 -0700 Subject: [python-win32] Setting environment variables in windows from Python Programs In-Reply-To: References: Message-ID: <42824434.9060008@probo.com> On Tue, 10 May 2005 15:41:30 -0700, Tony C wrote: >Your example didn't try to define the variable, it only attempted to >look at it's current value > >try this > > >>> C:\Tmp>set LANG >>> Environment variable LANG not defined >>> >>> > >C:\tmp> set LANG="SOME_LANGUAGE" >set LANG >LANG="SOME_LANGUAGE" > > I replied to Tony privately, because I did not see that he responded both to me and to the list. I'll repeat the reply here. This misses the point. I DID define the variable inside the Python code, and the process that I launched from Python (using os.system) DID inherit that variable. That's the best you can do: you can change the environment for the processes you start, but you cannot change the environment of the process that started you. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From nalli.dinesh at gmail.com Wed May 11 20:49:52 2005 From: nalli.dinesh at gmail.com (Nalli Dinesh) Date: Wed, 11 May 2005 11:49:52 -0700 Subject: [python-win32] LOCALE related stuff Re: Setting environment variables in windows from Python Programs- In-Reply-To: <42824434.9060008@probo.com> References: <42824434.9060008@probo.com> Message-ID: Tim/Paul/Tony Thanks for the suggestions and bringing clarity to the issue. After understanding your suggestions, I want to go striaght to the actual issue down below that made me to post environment issue. The actual issue/Problem: Its kind of funny tome right now, but letme shoot the problem so that we can have a clear cut idea as in whats the bug in python, or may be I don;t know I am missing on something. I using locale.setlocale and u guys know when we use this setlocale. Yes I am working on Localising my application-a pygtk application. When one says import locale locale.setlocale(locale.LC_ALL, ' ') This sets the locale for all categories to the user's default setting (typically specified in the LANG environment variable). I use Python2.4 Before I start my application from the DOS command prompt, run this command at the cmd prompt to set LANG environment. Which is "set LANG=ja_JP" And now if I run my python(that uses pygtk ) application it starts up and locale.setlocale able to read this LANG variable and do the needed setting for the locale. But if I don;t define this variable at the command prompt before I start the python application, but I define the environmen variable LANG like os.environ['LANG'] = 'ja_JP'. Then the setlocale doesn't set the locale as needed. But here is the catch. If I am using python2.3 and do the above, the setlocole set the locale as needede on the fly. Whats going on ......I don;t know. If u guys know your suggestions are needed. On 5/11/05, Tim Roberts wrote: > On Tue, 10 May 2005 15:41:30 -0700, Tony C wrote: > > >Your example didn't try to define the variable, it only attempted to > >look at it's current value > > > >try this > > > > > >>> C:\Tmp>set LANG > >>> Environment variable LANG not defined > >>> > >>> > > > >C:\tmp> set LANG="SOME_LANGUAGE" > >set LANG > >LANG="SOME_LANGUAGE" > > > > > > I replied to Tony privately, because I did not see that he responded > both to me and to the list. I'll repeat the reply here. > > This misses the point. I DID define the variable inside the Python > code, and the process that I launched from Python (using os.system) DID > inherit that variable. That's the best you can do: you can change the > environment for the processes you start, but you cannot change the > environment of the process that started you. > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From timr at probo.com Wed May 11 21:05:55 2005 From: timr at probo.com (Tim Roberts) Date: Wed, 11 May 2005 12:05:55 -0700 Subject: [python-win32] LOCALE related stuff Re: Setting environment variables in windows from Python Programs- In-Reply-To: References: <42824434.9060008@probo.com> Message-ID: <42825793.1050804@probo.com> Nalli Dinesh wrote: >I using locale.setlocale and u guys know when we use this setlocale. >Yes I am working on Localising my application-a pygtk application. >When one says >import locale >locale.setlocale(locale.LC_ALL, ' ') > > You don't really have a blank space between those quotes, do you? >This sets the locale for all categories to the user's default setting >(typically specified in the LANG environment variable). >I use Python2.4 >Before I start my application from the DOS command prompt, run this >command at the cmd prompt to set LANG environment. Which is "set >LANG=ja_JP" >And now if I run my python(that uses pygtk ) application it starts up >and locale.setlocale able to read this LANG variable and do the needed >setting for the locale. >But if I don;t define this variable at the command prompt before I >start the python application, but I define the environmen variable >LANG like os.environ['LANG'] = 'ja_JP'. >Then the setlocale doesn't set the locale as needed. > > When do you set the variable? It must be before ANY import that might read the locale. So, for example, the first lines of your file might need to be: import os os.environ['LANG'] = 'ja_JP' import locale locale.setlocale(locale.LC_ALL, '') import sys import pygtk ... -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From nalli.dinesh at gmail.com Wed May 11 21:31:05 2005 From: nalli.dinesh at gmail.com (Nalli Dinesh) Date: Wed, 11 May 2005 12:31:05 -0700 Subject: [python-win32] LOCALE related stuff Re: Setting environment variables in windows from Python Programs- In-Reply-To: <42825793.1050804@probo.com> References: <42824434.9060008@probo.com> <42825793.1050804@probo.com> Message-ID: There is no space between the quotes in locale.setlocale(locale.LC_ALL, ''). And I tried setting the Variable like the way u suggested: > import os > os.environ['LANG'] = 'ja_JP' > import locale > locale.setlocale(locale.LC_ALL, '') > import sys > import pygtk It doesn;t change my state of my appliation. I don;tknow where the issue lies now. I print LANG environment everywhere in the code and it does say the LANG is set by os.environ. But setlocale is not understaning this. But remmember, Python2.3.5 works fine with setting env LANG set within the code. On 5/11/05, Tim Roberts wrote: > Nalli Dinesh wrote: > > >I using locale.setlocale and u guys know when we use this setlocale. > >Yes I am working on Localising my application-a pygtk application. > >When one says > >import locale > >locale.setlocale(locale.LC_ALL, ' ') > > > > > > You don't really have a blank space between those quotes, do you? > > >This sets the locale for all categories to the user's default setting > >(typically specified in the LANG environment variable). > >I use Python2.4 > >Before I start my application from the DOS command prompt, run this > >command at the cmd prompt to set LANG environment. Which is "set > >LANG=ja_JP" > >And now if I run my python(that uses pygtk ) application it starts up > >and locale.setlocale able to read this LANG variable and do the needed > >setting for the locale. > >But if I don;t define this variable at the command prompt before I > >start the python application, but I define the environmen variable > >LANG like os.environ['LANG'] = 'ja_JP'. > >Then the setlocale doesn't set the locale as needed. > > > > > > When do you set the variable? It must be before ANY import that might > read the locale. So, for example, the first lines of your file might > need to be: > import os > os.environ['LANG'] = 'ja_JP' > import locale > locale.setlocale(locale.LC_ALL, '') > import sys > import pygtk > ... > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > From rwupole at msn.com Wed May 11 22:50:13 2005 From: rwupole at msn.com (Roger Upole) Date: Wed, 11 May 2005 16:50:13 -0400 Subject: [python-win32] Re: LOCALE related stuff Re: Setting environment Message-ID: > Tim/Paul/Tony > Thanks for the suggestions and bringing clarity to the issue. After > understanding your suggestions, I want to go striaght to the actual > issue down below that made me to post environment issue. > The actual issue/Problem: > Its kind of funny tome right now, but letme shoot the problem so that > we can have a clear cut idea as in whats the bug in python, or may be > I don;t know I am missing on something. > I using locale.setlocale and u guys know when we use this setlocale. > Yes I am working on Localising my application-a pygtk application. > When one says > import locale > locale.setlocale(locale.LC_ALL, ' ') > > This sets the locale for all categories to the user's default setting > (typically specified in the LANG environment variable). > I use Python2.4 Have you tried 2.4.1 ? There was a bug fix related to updating os.environ. http://python.org/sf/1110478 Roger From nalli.dinesh at gmail.com Wed May 11 23:27:50 2005 From: nalli.dinesh at gmail.com (Nalli Dinesh) Date: Wed, 11 May 2005 14:27:50 -0700 Subject: [python-win32] LOCALE related stuff Re: Setting environment In-Reply-To: References: Message-ID: wow.Thanks Roger for letting the group know about the bug fix on this os.environ issue. I never used python2.4.1. But I don;t intend as of now to move to 2.4.1 from 2.4. And the link u gave me to see the bug fix has a patch code below to add to os.py file in python2.4 as a bug fix. How do I integrate this patch. Do I just need to copy this patch and put it somewhere in os.py file under python2.4 On 5/11/05, Roger Upole wrote: > > > Tim/Paul/Tony > > Thanks for the suggestions and bringing clarity to the issue. After > > understanding your suggestions, I want to go striaght to the actual > > issue down below that made me to post environment issue. > > The actual issue/Problem: > > Its kind of funny tome right now, but letme shoot the problem so that > > we can have a clear cut idea as in whats the bug in python, or may be > > I don;t know I am missing on something. > > I using locale.setlocale and u guys know when we use this setlocale. > > Yes I am working on Localising my application-a pygtk application. > > When one says > > import locale > > locale.setlocale(locale.LC_ALL, ' ') > > > > This sets the locale for all categories to the user's default setting > > (typically specified in the LANG environment variable). > > I use Python2.4 > > Have you tried 2.4.1 ? There was a bug fix related to updating os.environ. > http://python.org/sf/1110478 > > Roger > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From nalli.dinesh at gmail.com Thu May 12 00:09:56 2005 From: nalli.dinesh at gmail.com (Nalli Dinesh) Date: Wed, 11 May 2005 15:09:56 -0700 Subject: [python-win32] LOCALE related stuff Re: Setting environment In-Reply-To: References: Message-ID: Hmm. I tried out this patch. This patch is about adding update function to os.py. Update is removed in python2.4, now adding this patch gave me access to use update in python2.4 My problem persists. locale.setlocale doesn't work even though we set LANG environment variable using update function. I don;t know whats going on. locale.setlocale worked perfectly when I set LANG environment variable with os.putenv,under python 2.3.5. On 5/11/05, Nalli Dinesh wrote: > wow.Thanks Roger for letting the group know about the bug fix on this > os.environ issue. I never used python2.4.1. But I don;t intend as of > now to move to 2.4.1 from 2.4. And the link u gave me to see the bug > fix has a patch code below to add to os.py file in python2.4 as a bug > fix. How do I integrate this patch. Do I just need to copy this patch > and put it somewhere in os.py file under python2.4 > > On 5/11/05, Roger Upole wrote: > > > > > Tim/Paul/Tony > > > Thanks for the suggestions and bringing clarity to the issue. After > > > understanding your suggestions, I want to go striaght to the actual > > > issue down below that made me to post environment issue. > > > The actual issue/Problem: > > > Its kind of funny tome right now, but letme shoot the problem so that > > > we can have a clear cut idea as in whats the bug in python, or may be > > > I don;t know I am missing on something. > > > I using locale.setlocale and u guys know when we use this setlocale. > > > Yes I am working on Localising my application-a pygtk application. > > > When one says > > > import locale > > > locale.setlocale(locale.LC_ALL, ' ') > > > > > > This sets the locale for all categories to the user's default setting > > > (typically specified in the LANG environment variable). > > > I use Python2.4 > > > > Have you tried 2.4.1 ? There was a bug fix related to updating os.environ. > > http://python.org/sf/1110478 > > > > Roger > > _______________________________________________ > > Python-win32 mailing list > > Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > From Andrew.MacIntyre at aba.gov.au Thu May 12 02:17:53 2005 From: Andrew.MacIntyre at aba.gov.au (Andrew MacIntyre) Date: Thu, 12 May 2005 10:17:53 +1000 Subject: [python-win32] LOCALE related stuff Re: Setting environment Message-ID: > From: Nalli Dinesh > > Hmm. I tried out this patch. This patch is about adding > update function to os.py. > Update is removed in python2.4, now adding this patch gave me > access to use update in python2.4 My problem persists. > locale.setlocale doesn't work even though we set LANG > environment variable using update function. > I don;t know whats going on. locale.setlocale worked > perfectly when I set LANG environment variable with > os.putenv,under python 2.3.5. As this is on Windows, you'll also need to keep in mind that the standard Python 2.4[.x] distribution is built with MSVC 7.1, whereas Python 2.3.x distributions were built with MSVC 6. There are 2 different C runtime libraries involved, and the issue you see may be due to differences at this level rather than in the Python codebase. Python 2.4[.x] is still buildable with MSVC 6 (thanks to Raymond Hettinger), so if you have access to that compiler you can check this out. ---------------------------------------------------------------------- Andrew MacIntyre \ email: andrew.macintyre at aba.gov.au Planning Branch \ tel: +61 2 6256 2812 Australian Broadcasting Authority \ fax: +61 2 6253 3277 -> "These thoughts are mine alone!" <--------------------------------- From nalli.dinesh at gmail.com Thu May 12 02:42:18 2005 From: nalli.dinesh at gmail.com (Nalli Dinesh) Date: Wed, 11 May 2005 17:42:18 -0700 Subject: [python-win32] LOCALE related stuff Re: Setting environment In-Reply-To: References: Message-ID: I really don;t think so. I looked at process mamangement in python. By default child process inherits all the environment variables from parent process. In case if a python application uses popen3 to run a command in a subprocess(child) then, before that whatever Environment variables u create or set in the code are passed on to the sub process and the sub process setlocale is picking up the LANG environment variable defined in the parent process. But the problem remains, if a process sets environment variable from the code, and other part of code which uses setlocale need be able to see this environment variable. Which is not happening. But if I print the environment variable in the other parts of the code, they all printing that the environmental variable is set. On 5/11/05, Andrew MacIntyre wrote: > > From: Nalli Dinesh > > > > Hmm. I tried out this patch. This patch is about adding > > update function to os.py. > > Update is removed in python2.4, now adding this patch gave me > > access to use update in python2.4 My problem persists. > > locale.setlocale doesn't work even though we set LANG > > environment variable using update function. > > I don;t know whats going on. locale.setlocale worked > > perfectly when I set LANG environment variable with > > os.putenv,under python 2.3.5. > > As this is on Windows, you'll also need to keep in mind that the > standard Python 2.4[.x] distribution is built with MSVC 7.1, whereas > Python 2.3.x distributions were built with MSVC 6. There are 2 > different C runtime libraries involved, and the issue you see may > be due to differences at this level rather than in the Python codebase. > > Python 2.4[.x] is still buildable with MSVC 6 (thanks to Raymond > Hettinger), so if you have access to that compiler you can check this > out. > > ---------------------------------------------------------------------- > Andrew MacIntyre \ email: andrew.macintyre at aba.gov.au > Planning Branch \ tel: +61 2 6256 2812 > Australian Broadcasting Authority \ fax: +61 2 6253 3277 > -> "These thoughts are mine alone!" <--------------------------------- > From Andrew.MacIntyre at aba.gov.au Thu May 12 02:56:44 2005 From: Andrew.MacIntyre at aba.gov.au (Andrew MacIntyre) Date: Thu, 12 May 2005 10:56:44 +1000 Subject: [python-win32] LOCALE related stuff Re: Setting environment Message-ID: > From: Nalli Dinesh > > I really don;t think so. I looked at process mamangement in > python. By default child process inherits all the environment > variables from parent process. In case if a python > application uses popen3 to run a command in a > subprocess(child) then, before that whatever Environment > variables u create or set in the code are passed on to the > sub process and the sub process setlocale is picking up the > LANG environment variable defined in the parent process. > > But the problem remains, if a process sets environment > variable from the code, and other part of code which uses > setlocale need be able to see this environment variable. > Which is not happening. But if I print the environment > variable in the other parts of the code, they all printing > that the environmental variable is set. My reply did not make this clear, but the behaviour of the locale code in the two runtimes is what I was alluding to. I wouldn't mind betting that MSVC 7.1's C library initialises the locale at process initialisation, whereas MSVC 6's C library defers locale initialisation until the first call. If the former is true, subsequently setting the environment variable is a complete waste of time because its far too late. ---------------------------------------------------------------------- Andrew MacIntyre \ email: andrew.macintyre at aba.gov.au Planning Branch \ tel: +61 2 6256 2812 Australian Broadcasting Authority \ fax: +61 2 6253 3277 -> "These thoughts are mine alone!" <--------------------------------- From arvind.manutd at gmail.com Thu May 12 08:32:40 2005 From: arvind.manutd at gmail.com (Arvind Ashok) Date: Thu, 12 May 2005 12:02:40 +0530 Subject: [python-win32] win32inet Message-ID: <6b42500505112332aa911c5@mail.gmail.com> Hello, I am a beginner to python win32 and I want to know how to make a connection using the win32inet module. yes, the functions are there but where do I say what device to connect or where ... am sorry for such a basic question but I couldnt find anything in the documentation. What I want to do is dial my connection( InternetDial() in VC++) and then hangup. it would be great if someone could send me some code to do this... just a simple dial and hangup... Thanks Arvind From tim.golden at viacom-outdoor.co.uk Thu May 12 17:07:09 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu, 12 May 2005 16:07:09 +0100 Subject: [python-win32] win32inet Message-ID: <9A28C052FF32734DACB0A288A3533991EBB80B@vogbs009.gb.vo.local> [Arvind Ashok] | | What I want to do is dial my connection( InternetDial() in VC++) and | then hangup. it would be great if someone could send me some code to | do this... just a simple dial and hangup... You might want to be looking at win32ras. Something like this: win32ras.Dial ( None, None, (ras_entry_name, "", "", username, password, ""), None ) win32ras.HangUp () 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 lstrigeus at accuratetechnologies.com Fri May 13 11:08:13 2005 From: lstrigeus at accuratetechnologies.com (Ludvig Strigeus) Date: Fri, 13 May 2005 05:08:13 -0400 Subject: [python-win32] Bug with system()/popen() ? Message-ID: <3E26E7A199CABA49822B3E6B741434F9011286B5@exch.accuratetechnologies.com> I'm trying to use system to run the following command: cmd = C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe Argv[1] = /command:update Argv[2] = /path:"C:\Temp\Test" Argv[3] = /notempfile Argv[4] = /closeonend But all my attempts to convert this to a linearalized command line fails... This is my most successful try (don't ask me why i have "" at the start, it doesn't work at all otherwise): os.system('""C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe" /command:update /path:"C:\Temp\Test" /notempfile /closeonend') But this puts /path:C:\Temp /notempfile /closeonend into Argv[2]. Doing just: os.system('"C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe" /command:update /path:"C:\Temp\Test" /notempfile /closeonend') Prints that C:\Program is not a valid command or program. Any ideas? Is there some python function that doesn't require me to linearalize the command line, or is there some workaround so the above example works? (I need the functionality of popen()) /Ludvig -- Ludvig Strigeus - Software Development - ATI Sweden email: phone: +46-(0)31-7737143 | mobile phone: +46-(0)707-838540 us phone: +1-248-327-3222 | skype name: strigeus From bhanu.nukala at neilsoft.com Fri May 13 14:21:15 2005 From: bhanu.nukala at neilsoft.com (Bhanuprakash) Date: Fri, 13 May 2005 17:51:15 +0530 Subject: [python-win32] how to run exe from python with out using command prompt Message-ID: <006d01c557b6$41f2e930$6901010a@nsess.com> Hi I would like to ask something How to run .exe from python without using following code Import os Os.system ('some.exe') Am awaiting for your response With regards Bhanu Prakash Nukala, Neilsoft Ltd, PUNE Phone : +912026052851/52 ext : 239, Mobile: 9850757838 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050513/86793b38/attachment.html From nalli.dinesh at gmail.com Fri May 13 17:59:21 2005 From: nalli.dinesh at gmail.com (Nalli Dinesh) Date: Fri, 13 May 2005 08:59:21 -0700 Subject: [python-win32] how to run exe from python with out using command prompt In-Reply-To: <006d01c557b6$41f2e930$6901010a@nsess.com> References: <006d01c557b6$41f2e930$6901010a@nsess.com> Message-ID: Use popen3 to do the same. Eg: code for u import os FILENAME='test2.py' env={};env['ENVIRON_UPDATE']='123';os.environ.update(env) os.environ['ENVIRON_DIRECT_SETTING']='123' cmdline='c:\python24\python.exe -u %s'%FILENAME fs=os.popen3(cmdline,'b') print fs[1].read() On 5/13/05, Bhanuprakash wrote: > > > Hi > > I would like to ask something > > How to run .exe from python without using following code > > > > > > Import os > > Os.system ('some.exe') > > > > Am awaiting for your response > > > > With regards > > > > Bhanu Prakash Nukala, > > Neilsoft Ltd, > > PUNE > > Phone : +912026052851/52 ext : 239, > > Mobile: 9850757838 > > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > From bgailer at alum.rpi.edu Fri May 13 18:25:43 2005 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Fri, 13 May 2005 09:25:43 -0700 Subject: [python-win32] Bug with system()/popen() ? In-Reply-To: <3E26E7A199CABA49822B3E6B741434F9011286B5@exch.accuratetech nologies.com> References: <3E26E7A199CABA49822B3E6B741434F9011286B5@exch.accuratetechnologies.com> Message-ID: <6.1.2.0.0.20050513091637.0365b198@pop.sbcglobal.yahoo.com> At 02:08 AM 5/13/2005, Ludvig Strigeus wrote: >I'm trying to use system to run the following command: > >cmd = C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe >Argv[1] = /command:update >Argv[2] = /path:"C:\Temp\Test" >Argv[3] = /notempfile >Argv[4] = /closeonend > >But all my attempts to convert this to a linearalized command line >fails... > >This is my most successful try (don't ask me why i have "" at the start, >it doesn't work at all otherwise): >os.system('""C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe" >/command:update /path:"C:\Temp\Test" /notempfile /closeonend') At the interactive prompt type: >>> '""C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe"/command:update /path:"C:\Temp\Test" /notempfile /closeonend And what you get is: '""C:\\Program Files\\Tortoise SVN\x08in\\TortoiseProc.exe"/command:update /path:"C:\\Temp\\Test" /notempfile /closeonend' Notice something odd? What happened to the \b? From the Refernce Manual: "Unless an "r" or "R" prefix is present, escape sequences in strings are interpreted according to rules similar to those used by Standard C." \b is the escape sequence for backspace. That might help! >[snip] Bob Gailer mailto:bgailer at alum.rpi.edu 510 558 3275 home 720 938 2625 cell -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050513/f4a31cd2/attachment.html From lstrigeus at accuratetechnologies.com Fri May 13 18:31:13 2005 From: lstrigeus at accuratetechnologies.com (Ludvig Strigeus) Date: Fri, 13 May 2005 12:31:13 -0400 Subject: [python-win32] Bug with system()/popen() ? Message-ID: <3E26E7A199CABA49822B3E6B741434F901128712@exch.accuratetechnologies.com> Hm sorry, I missed the r"" in my code below. I used r"" in my tests. system still fails. Thanks anyway. Someone told me to prepend "; " to the command line, that seems to work. Any idea why? /Ludvig -----Original Message----- From: Bob Gailer [mailto:bgailer at alum.rpi.edu] Sent: den 13 maj 2005 18:26 To: Ludvig Strigeus; python-win32 at python.org Subject: Re: [python-win32] Bug with system()/popen() ? At 02:08 AM 5/13/2005, Ludvig Strigeus wrote: I'm trying to use system to run the following command: cmd = C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe Argv[1] = /command:update Argv[2] = /path:"C:\Temp\Test" Argv[3] = /notempfile Argv[4] = /closeonend But all my attempts to convert this to a linearalized command line fails... This is my most successful try (don't ask me why i have "" at the start, it doesn't work at all otherwise): os.system('""C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe" /command:update /path:"C:\Temp\Test" /notempfile /closeonend') At the interactive prompt type: >>> '""C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe"/command:update /path:"C:\Temp\Test" /notempfile /closeonend And what you get is: '""C:\\Program Files\\Tortoise SVN\x08in\\TortoiseProc.exe"/command:update /path:"C:\\Temp\\Test" /notempfile /closeonend' Notice something odd? What happened to the \b? >From the Refernce Manual: "Unless an "r" or "R" prefix is present, escape sequences in strings are interpreted according to rules similar to those used by Standard C." \b is the escape sequence for backspace. That might help! [snip] Bob Gailer mailto:bgailer at alum.rpi.edu 510 558 3275 home 720 938 2625 cell -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050513/bbc7369d/attachment.htm From timr at probo.com Fri May 13 19:19:22 2005 From: timr at probo.com (Tim Roberts) Date: Fri, 13 May 2005 10:19:22 -0700 Subject: [python-win32] Bug with system()/popen() ? In-Reply-To: References: Message-ID: <4284E19A.9020108@probo.com> On Fri, 13 May 2005 05:08:13 -0400, "Ludvig Strigeus" wrote: >I'm trying to use system to run the following command: > >cmd = C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe >Argv[1] = /command:update >Argv[2] = /path:"C:\Temp\Test" >Argv[3] = /notempfile >Argv[4] = /closeonend > >But all my attempts to convert this to a linearalized command line >fails... > >This is my most successful try (don't ask me why i have "" at the start, >it doesn't work at all otherwise): >os.system('""C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe" >/command:update /path:"C:\Temp\Test" /notempfile /closeonend') > > You know that you need to escape all of those backslashes, right? You either need to use an r"xxx" string or double the backslashes. \b (as in ...\bin) is the character with ASCII code 7. >But this puts /path:C:\Temp /notempfile /closeonend into Argv[2]. > >Doing just: >os.system('"C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe" >/command:update /path:"C:\Temp\Test" /notempfile /closeonend') > >Prints that C:\Program is not a valid command or program. > >Any ideas? Is there some python function that doesn't require me to >linearalize the command line, or is there some workaround so the above >example works? (I need the functionality of popen()) > > This is one reason why I always override the installation directory to one without spaces. One alternative is to fall back to: os.system('c:\\progra~1\\tortoi~1\\bin\\TortoiseProc.exe /command:update /path:c:\\temp\\test /notempfile /closeonend') Or: os.environ['PATH'] = os.environ['PATH'] + ';c:\\Program Files\\Tortoise SVN\\bin' os.system('TortoiseProc.exe /command: ...') -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From lstrigeus at accuratetechnologies.com Fri May 13 19:28:11 2005 From: lstrigeus at accuratetechnologies.com (Ludvig Strigeus) Date: Fri, 13 May 2005 13:28:11 -0400 Subject: [python-win32] [SPAM-Keyword] - Re: Bug with system()/popen() ? - Found word(s) XXX in the Text body Message-ID: <3E26E7A199CABA49822B3E6B741434F901128716@exch.accuratetechnologies.com> Hi Tim. When I did my tests I used r"", but I forgot it when i wrote the email below. Even if I use r"" it doesn't work. The wrong stuff is put into Argv[2] /path:C:\Temp /notempfile /closeonend Instead of /path:"C:\Temp" /Ludvig -----Original Message----- From: Tim Roberts [mailto:timr at probo.com] Sent: den 13 maj 2005 19:19 To: python-win32 at python.org Subject: [SPAM-Keyword] - Re: [python-win32] Bug with system()/popen() ? - Found word(s) XXX in the Text body On Fri, 13 May 2005 05:08:13 -0400, "Ludvig Strigeus" wrote: >I'm trying to use system to run the following command: > >cmd = C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe Argv[1] = >/command:update Argv[2] = /path:"C:\Temp\Test" >Argv[3] = /notempfile >Argv[4] = /closeonend > >But all my attempts to convert this to a linearalized command line >fails... > >This is my most successful try (don't ask me why i have "" at the >start, it doesn't work at all otherwise): os.system('""C:\Program >Files\Tortoise SVN\bin\TortoiseProc.exe" /command:update >/path:"C:\Temp\Test" /notempfile /closeonend') > > You know that you need to escape all of those backslashes, right? You either need to use an r"xxx" string or double the backslashes. \b (as in ...\bin) is the character with ASCII code 7. >But this puts /path:C:\Temp /notempfile /closeonend into Argv[2]. > >Doing just: >os.system('"C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe" >/command:update /path:"C:\Temp\Test" /notempfile /closeonend') > >Prints that C:\Program is not a valid command or program. > >Any ideas? Is there some python function that doesn't require me to >linearalize the command line, or is there some workaround so the above >example works? (I need the functionality of popen()) > > This is one reason why I always override the installation directory to one without spaces. One alternative is to fall back to: os.system('c:\\progra~1\\tortoi~1\\bin\\TortoiseProc.exe /command:update /path:c:\\temp\\test /notempfile /closeonend') Or: os.environ['PATH'] = os.environ['PATH'] + ';c:\\Program Files\\Tortoise SVN\\bin' os.system('TortoiseProc.exe /command: ...') -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From bhanu.nukala at neilsoft.com Sat May 14 08:36:13 2005 From: bhanu.nukala at neilsoft.com (Bhanuprakash) Date: Sat, 14 May 2005 12:06:13 +0530 Subject: [python-win32] Actually my question is: Message-ID: <004001c5584f$394856f0$6901010a@nsess.com> Hi Actually my question is: I have written a class in python. I would like to run one exe from that class. That exe returns something which I would like to redirect to text file. Also I don't want to display a command prompt. Bhanu Prakash Nukala, Neilsoft Ltd, PUNE Phone : +912026052851/52 ext : 239, Mobile: 9850757838 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050514/23ab1ffe/attachment.html From graemeglass at gmail.com Mon May 16 10:42:38 2005 From: graemeglass at gmail.com (Graeme Glass) Date: Mon, 16 May 2005 10:42:38 +0200 Subject: [python-win32] Actually my question is: In-Reply-To: <004001c5584f$394856f0$6901010a@nsess.com> References: <004001c5584f$394856f0$6901010a@nsess.com> Message-ID: Then os.popen(), popen2(), popen3() is your man/men/woman. You can call the .exe without bringing up a command prompt and then redirect the return data as you feel fit. On 5/14/05, Bhanuprakash wrote: > > > > Hi > > Actually my question is: > > > > I have written a class in python. I would like to run one exe from that > class. That exe returns something which I would like to redirect to text > file. Also I don't want to display a command prompt. > > > > Bhanu Prakash Nukala, > > Neilsoft Ltd, > > PUNE > > Phone : +912026052851/52 ext : 239, > > Mobile: 9850757838 > > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > From xavim at fqingenieria.es Tue May 17 14:02:24 2005 From: xavim at fqingenieria.es (Xavier Martinez) Date: Tue, 17 May 2005 14:02:24 +0200 Subject: [python-win32] Actually my question is: In-Reply-To: <004001c5584f$394856f0$6901010a@nsess.com> References: <004001c5584f$394856f0$6901010a@nsess.com> Message-ID: <4289DD50.5080308@fqingenieria.es> Bhanuprakash wrote: > I have written a class in python. I would like to run one exe from > that class. That exe returns something which I would like to redirect > to text file. Also I don't want to display a command prompt. > If you are running Python 2.4, you can use the 'subprocess' module (see http://www.python.org/doc/2.4.1/lib/module-subprocess.html). If you are running an earlier Python version, there is a package available at http://www.lysator.liu.se/~astrand/popen5/. -- Xavier Mart?nez Hidalgo FQ Ingenier?a Electr?nica, S.A. From dja at info.ucl.ac.be Wed May 18 01:05:49 2005 From: dja at info.ucl.ac.be (David Janssens) Date: Wed, 18 May 2005 01:05:49 +0200 Subject: [python-win32] COM server with events and multiple threads Message-ID: <428A78CD.1030507@info.ucl.ac.be> Hello, I am trying to build an application where the GUI is implemented as a VB6 exe and most of the core functionality is implemented as a python COM server that is called by the GUI. The python COM server has multiple threads running in it and sends events once in a while to the VB6 GUI. The python COM server needs to be run in the MTA of the application's process because all the events from the server to the GUI need to be marshalled, so I set the threading model of the python COM server to "free". I distribute the whole application using py2exe. However, I get the following error on some machines: "Class does not support Automation or does not support expected interface" when the python com server is loaded. When I set the threading model to "both" instead of "free", the error disappears. But of course that doesn't suit me because then some VB6 gui code that handles COM server events gets called in threads that are different from the main gui thread. I would like to know if someone has encountered this problem before or if there exists some samples that illustrate how to use a VB6 gui in conjunction with a python COM server that generates events and has multiple threads. Thanks, David Janssens Here is the test code I use for the python COM server: import sys import pythoncom import win32com.server import win32com.server.connect from win32com.server.exception import COMException import winerror IID_IServerWithEvents_Event = pythoncom.MakeIID('{11AEB37F-0CAB-4DE2-B975-F05567EADC8E}') IID_IServerWithEvents = pythoncom.MakeIID('{938F1121-21ED-47A0-B0B7-47D7D6E99A7B}') class Node(win32com.server.connect.ConnectableServer): _reg_desc_ = 'MyProject Node Component' _reg_clsid_ = '{49604ea4-bb2a-d04a-7fdd-b20e7e79cb40}' _reg_progid_ = 'MyProject.Node' _reg_threading_ = 'free' # Generates error, no errors with 'both'! _public_methods_ = ['run'] + win32com.server.connect.ConnectableServer._public_methods_ _connect_interfaces_ = [IID_IServerWithEvents_Event] # Need to overload this method to tell that we support IID_IServerWithEvents def _query_interface_(self, iid): if iid == IID_IServerWithEvents: return win32com.server.util.wrap(self) def run(self): pass if __name__=='__main__': import win32com.server.register win32com.server.register.UseCommandLine(Node, debug=1) From mhammond at skippinet.com.au Wed May 18 03:30:53 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 18 May 2005 11:30:53 +1000 Subject: [python-win32] COM server with events and multiple threads In-Reply-To: <428A78CD.1030507@info.ucl.ac.be> Message-ID: <534101c55b49$3c184190$120a0a0a@enfoldsystems.local> > I am trying to build an application where the GUI is implemented as a > VB6 exe and most of the core functionality is implemented as a python > COM server that is called by the GUI. > > The python COM server has multiple threads running in it and sends > events once in a while to the VB6 GUI. > > The python COM server needs to be run in the MTA of the application's > process because all the events from the server to the GUI need to be > marshalled, so I set the threading model of the python COM > server to "free". A COM server can only indicate the threading options it supports - the *creator* of the COM object is responsible for setting the actual thread mode used. If the server doesn't support the mode, you get that error. Consider: The thread mode is set by a CoInitialize(Ex) call. Such a call must be made before your COM object can be used or instantiated by that thread. Therefore, by the time your server has been created/called, the thread mode must have already been set. You need to tell VB to use free-threading if you want your object to be only used that way. > disappears. But of course that doesn't suit me because then > some VB6 gui > code that handles COM server events gets called in threads that are > different from the main gui thread. COM itself should take care of that. Earlier you mentioned: > The python COM server has multiple threads running in it and sends > events once in a while to the VB6 GUI. How do you pass the event sink objects to the threads? If ever a COM objects crosses thread boundaries, it must do so via CoMarshalInterThreadInterfaceInStream(). If you fail to do that, then you will not get COM's proxying. Note however that the call you make in this thread will still block until the other thread could handle it - ie, the event delivery is unlikely to be asynch. Mark From rays at blue-cove.com Wed May 18 19:00:23 2005 From: rays at blue-cove.com (Ray S) Date: Wed, 18 May 2005 10:00:23 -0700 Subject: [python-win32] Python disk usage in Add-remove Programs Message-ID: <5.2.0.4.2.20050518095546.168f4260@blue-cove.com> I noticed that my new install of 2.4 etc. has some large(!) numbers. ActivePython 78MB (true) ctypes.9.2 148MB numarray 1.1.1 148MB Numeric23.6 148MB py2exe .5.4 148MB It appears that they are reporting the size of the entire c:\Python24 directory tree "size on disk" Just an observation... Ray Schumacher From theller at python.net Wed May 18 22:11:50 2005 From: theller at python.net (Thomas Heller) Date: Wed, 18 May 2005 22:11:50 +0200 Subject: [python-win32] Python disk usage in Add-remove Programs References: <5.2.0.4.2.20050518095546.168f4260@blue-cove.com> Message-ID: <3bskuwe1.fsf@python.net> Ray S writes: > I noticed that my new install of 2.4 etc. has some large(!) numbers. > ActivePython 78MB (true) > ctypes.9.2 148MB > numarray 1.1.1 148MB > Numeric23.6 148MB > py2exe .5.4 148MB > > It appears that they are reporting the size of the entire c:\Python24 directory tree "size on disk" > Windows does a lot of guessing to determine the size and freuency of use of an installed program. For some explanation, see this blog entry by Raymond Chen: http://blogs.msdn.com/oldnewthing/archive/2004/07/09/178342.aspx Some time ago I experimented a little bit to add hints to the registry, as he describes above, but didn't get it to work. Eventually I decided that it's not worth the effort to add this to bdist_wininst. Thomas From dja at info.ucl.ac.be Thu May 19 16:21:59 2005 From: dja at info.ucl.ac.be (David Janssens) Date: Thu, 19 May 2005 16:21:59 +0200 Subject: [python-win32] COM server with events and multiple threads In-Reply-To: <534101c55b49$3c184190$120a0a0a@enfoldsystems.local> References: <534101c55b49$3c184190$120a0a0a@enfoldsystems.local> Message-ID: <428CA107.4020409@info.ucl.ac.be> Thanks for the reply, The reason I chose to set the threading model of the python server component to "free" was that if I do this, then the component gets created in the MTA of the VB6 GUI process. If I don't do this, the VB6 event handlers are run in different threads than the GUI thread and many problem arise. I don't know how to tell VB6 to use free-threading or how to spawn new threads in VB6 that belong to the MTA. Are you sure it's possible, do you have more information on how to do this? I suppose the problem is quite common to all people who whish to use a VB6 GUI with a python COM server backend. If I can get it working, I would like to submit a sample that shows how to do it, because I think it could be useful to many people. Thanks for your help, David Janssens The events are sent to the GUI as follows: (This is based on a sample I found on the same mailing list, except the sample didn't set the threading model of the component to "free") import sys import pythoncom import win32com.server import win32com.server.connect from win32com.server.exception import COMException import winerror IID_IServerWithEvents_Event = pythoncom.MakeIID('{11AEB37F-0CAB-4DE2-B975-F05567EADC8E}') IID_IServerWithEvents = pythoncom.MakeIID('{938F1121-21ED-47A0-B0B7-47D7D6E99A7B}') class Node(win32com.server.connect.ConnectableServer): _reg_desc_ = 'MyProject Node Component' _reg_clsid_ = '{49604ea4-bb2a-d04a-7fdd-b20e7e79cb40}' _reg_progid_ = 'MyProject.Node' _reg_threading_ = 'free' _public_methods_ = ['run'] + win32com.server.connect.ConnectableServer._public_methods_ _connect_interfaces_ = [IID_IServerWithEvents_Event] # Need to overload this method to tell that we support IID_IServerWithEvents def _query_interface_(self, iid): if iid == IID_IServerWithEvents: return win32com.server.util.wrap(self) ### node methods called from gui ################################## def run(self): try: pass except Exception,e: raise COMException(str(e),winerror.OLE_E_OLEVERB) ### node events sent to gui ####################################### def connected(self): self._BroadcastNotify(self.NotifyConnected, (None,)) def disconnected(self): self._BroadcastNotify(self.NotifyDisconnected, (None,)) def NotifyConnected(self, interface, args): interface.Invoke(0x000003ea, 0, pythoncom.DISPATCH_METHOD, 1) def NotifyDisconnected(self, interface, args): interface.Invoke(0x000003eb, 0, pythoncom.DISPATCH_METHOD, 1) if __name__=='__main__': print 'Registering COM Server...' import win32com.server.register win32com.server.register.UseCommandLine(Node, debug=1) The corrresponding IDL file is: [ uuid(d77f974c-234f-0795-cf3e-aced80d9fc89), version(1.0), helpstring("MyProject 1.0 Type Library") ] library MyProject { importlib("stdole32.tlb"); [ uuid(938F1121-21ED-47A0-B0B7-47D7D6E99A7B), version(0.1) ] dispinterface IServerWithEvents { properties: methods: [id(0x000003e8)] VARIANT run(); }; [ uuid(11AEB37F-0CAB-4DE2-B975-F05567EADC8E), version(0.1) ] dispinterface IServerWithEvents_Event { properties: methods: VARIANT connected(); [id(0x000003eb)] VARIANT disconnected(); [id(0x000003ec)] }; [ uuid(49604ea4-bb2a-d04a-7fdd-b20e7e79cb40), version(0.1) ] coclass Node { [default] dispinterface IServerWithEvents; [default, source] dispinterface IServerWithEvents_Event; }; }; (I generate a TLB file from the IDL file and import that into VB6) Mark Hammond wrote: >>I am trying to build an application where the GUI is implemented as a >>VB6 exe and most of the core functionality is implemented as a python >>COM server that is called by the GUI. >> >>The python COM server has multiple threads running in it and sends >>events once in a while to the VB6 GUI. >> >>The python COM server needs to be run in the MTA of the application's >>process because all the events from the server to the GUI need to be >>marshalled, so I set the threading model of the python COM >>server to "free". >> >> > >A COM server can only indicate the threading options it supports - the >*creator* of the COM object is responsible for setting the actual thread >mode used. If the server doesn't support the mode, you get that error. > >Consider: The thread mode is set by a CoInitialize(Ex) call. Such a call >must be made before your COM object can be used or instantiated by that >thread. Therefore, by the time your server has been created/called, the >thread mode must have already been set. > >You need to tell VB to use free-threading if you want your object to be only >used that way. > > > >>disappears. But of course that doesn't suit me because then >>some VB6 gui >>code that handles COM server events gets called in threads that are >>different from the main gui thread. >> >> > >COM itself should take care of that. Earlier you mentioned: > > > >>The python COM server has multiple threads running in it and sends >>events once in a while to the VB6 GUI. >> >> > >How do you pass the event sink objects to the threads? If ever a COM >objects crosses thread boundaries, it must do so via >CoMarshalInterThreadInterfaceInStream(). If you fail to do that, then you >will not get COM's proxying. Note however that the call you make in this >thread will still block until the other thread could handle it - ie, the >event delivery is unlikely to be asynch. > >Mark > > > From dja at info.ucl.ac.be Fri May 20 12:58:34 2005 From: dja at info.ucl.ac.be (David Janssens) Date: Fri, 20 May 2005 12:58:34 +0200 Subject: [python-win32] COM server with events and multiple threads In-Reply-To: <534101c55b49$3c184190$120a0a0a@enfoldsystems.local> References: <534101c55b49$3c184190$120a0a0a@enfoldsystems.local> Message-ID: <428DC2DA.5080107@info.ucl.ac.be> I tried to run the python COM server from a VB6 ActiveX EXE where I checked the option "Thread per Object" in the project properties window. This way, the python COM server component is created in a different thread. But I still get the error "Class does not support Automation or does not support expected interface". Does anyone know how to debug this problem, ie how to find out what the "expected interface" is? I tried to look into the VB6 "Err" object, but I couldn't find more details. Thanks, David Janssens Mark Hammond wrote: >>I am trying to build an application where the GUI is implemented as a >>VB6 exe and most of the core functionality is implemented as a python >>COM server that is called by the GUI. >> >>The python COM server has multiple threads running in it and sends >>events once in a while to the VB6 GUI. >> >>The python COM server needs to be run in the MTA of the application's >>process because all the events from the server to the GUI need to be >>marshalled, so I set the threading model of the python COM >>server to "free". >> >> > >A COM server can only indicate the threading options it supports - the >*creator* of the COM object is responsible for setting the actual thread >mode used. If the server doesn't support the mode, you get that error. > >Consider: The thread mode is set by a CoInitialize(Ex) call. Such a call >must be made before your COM object can be used or instantiated by that >thread. Therefore, by the time your server has been created/called, the >thread mode must have already been set. > >You need to tell VB to use free-threading if you want your object to be only >used that way. > > > >>disappears. But of course that doesn't suit me because then >>some VB6 gui >>code that handles COM server events gets called in threads that are >>different from the main gui thread. >> >> > >COM itself should take care of that. Earlier you mentioned: > > > >>The python COM server has multiple threads running in it and sends >>events once in a while to the VB6 GUI. >> >> > >How do you pass the event sink objects to the threads? If ever a COM >objects crosses thread boundaries, it must do so via >CoMarshalInterThreadInterfaceInStream(). If you fail to do that, then you >will not get COM's proxying. Note however that the call you make in this >thread will still block until the other thread could handle it - ie, the >event delivery is unlikely to be asynch. > >Mark > > > From iain.reid at gp-w91005.wales.nhs.uk Fri May 20 23:42:26 2005 From: iain.reid at gp-w91005.wales.nhs.uk (Iain Reid) Date: Fri, 20 May 2005 22:42:26 +0100 Subject: [python-win32] COM question - objects available from VB not available to Python COM Message-ID: <000301c55d84$d106b0b0$0b05da0a@W91005TOREX.wales.nhs.uk> Probably an old chestnut this but, after several days of unsuccesful google'ing, I thought I'd join the list and seek wise counsel. I have a piece of medical software that exposes its API via COM. In VB (or C#) I can access a wider range of objects than in Python and I'm not clear why. Reading to date suggests that Python will only (easily) expose objects with an IDispatch Interface whereas VB can expose objects with 'other' interfaces. In VB, I can say: Dim pt as ClinicLib.Patient dim pt as ClinicLib.S6Patient And both will return valid objects. In Python, I get: >>> import win32com.client; >>> pt = win32com.client.Dispatch('Clinic.Patient'); >>> pt which works, and >>> pt = win32com.client.Dispatch('Clinic.S6Patient'); Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 79, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147467262, 'No such interface supported', None, None) >>> which fails. Trying: o=pythoncom.CoCreateInstance ("Clinic.S6Patient", None, wc.pythoncom.CLSCTX_ALL, wc.pythoncom.IID_IUnknown); Gives In essence, I'm looking for the same functionality as VB.... Perhaps pt = win32com.client.Object('Clinic.S6Patient'); My reading to date suggests that VB probably uses CreateStdInterface and QueryInterface to do what it needs to do. Does this seem plausible (I'm new to the guts of COM) and, if so, does anyone have a code fragment which demonstrates it? Iain From washort at divmod.com Sat May 21 21:51:01 2005 From: washort at divmod.com (washort@divmod.com) Date: Sat, 21 May 2005 19:51:01 GMT Subject: [python-win32] async COM calls from python In-Reply-To: 0 Message-ID: <20050521195101.559.316965087.divmod.quotient.6384@ohm> I'm trying to integrate a Python event loop (specifically, Twisted's reactor) into a COM in-process server. I've discovered CoWaitForMultipleHandles and it seems like it might be part of such a solution. Also, I notice that ICallFactory::CreateCall allows for calling a COM method and not waiting for it to return, which it seems like I'd need (since I want my other COM methods to be callable while my event loop runs). However, it seems like i need to create a new interface to do this, since CreateCall doesn't work with IDispatch. Is it even possible to create a new COM interface from python? If not, how much C++ am I going to have to write? Is there a better way to do event loop integration with COM? From mhammond at skippinet.com.au Mon May 23 09:08:23 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 23 May 2005 17:08:23 +1000 Subject: [python-win32] COM server with events and multiple threads In-Reply-To: <428CA107.4020409@info.ucl.ac.be> Message-ID: > I don't know how to tell VB6 to use free-threading or how to > spawn new > threads in VB6 that belong to the MTA. Are you sure it's possible, do > you have more information on how to do this? I doubt it is possible for the main GUI thread. I believe VB can create threads via API calls, so they are up for grabs. I meant to say something like "the host (in thise case VB) must set the thread-mode. I doubt VB can". > I suppose the problem is > quite common to all people who whish to use a VB6 GUI with a > python COM server backend. I'm not aware of normal single threaded apps doing similarly strange things for people. Using connection-points directly is not common, so maybe VB is doing something stange with them. > The events are sent to the GUI as follows: (This is based on > a sample I > found on the same mailing list, except the sample didn't set the > threading model of the component to "free") Your original query said "the python COM server has multiple threads running in it" - but its still not clear to me what these threads are, or where they are created. Are these multiple-threads just an observed side-effect of the code as posted? Mark From mhammond at skippinet.com.au Mon May 23 10:29:37 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 23 May 2005 18:29:37 +1000 Subject: [python-win32] async COM calls from python In-Reply-To: <20050521195101.559.316965087.divmod.quotient.6384@ohm> Message-ID: > I'm trying to integrate a Python event loop (specifically, > Twisted's reactor) into a COM in-process server. I've > discovered CoWaitForMultipleHandles and it seems like it > might be part of such a solution. Sadly that is missing from the current pythoncom. However, WaitForMultipleObjects is, which does the same thing in a free-threaded apartment. > Also, I notice that > ICallFactory::CreateCall allows for calling a COM method and > not waiting for it to return, which it seems like I'd need > (since I want my other COM methods to be callable while my > event loop runs). However, it seems like i need to create a > new interface to do this, since CreateCall doesn't work with > IDispatch. Is it even possible to create a new COM interface > from python? Not easily. You may be able to use either ctypes, or abuse some other interface that has methods which are "close enough". The connection-point related ones might be suitable. > Is there a better way to do event loop integration with COM? I'm not completely clear on what you are trying to do. I assume that you want this event-loop to never block - one way to do this would be to use WaitForMultipleObjects, a queue and a thread-pool. I'm not sure how ICallFactory is implemented, so I'm not sure how efficient it is to create a huge number of pending calls - a queue etc would let you have more control over this process. Mark. From Benjamin.Schollnick at xerox.com Mon May 23 14:38:46 2005 From: Benjamin.Schollnick at xerox.com (Schollnick, Benjamin) Date: Mon, 23 May 2005 08:38:46 -0400 Subject: [python-win32] Odd py2exe & Win32 error.... Message-ID: <266589E1B9392B4C9195CC25A07C73B9124C72@usa0300ms04.na.xerox.net> Folks, I have run into a problem that is py2exe & win32 related, but I am not sure which toolkit has the problem... ---- from win32com.client import gencache gencache.EnsureModule('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1, 2) ---- Has anyone used py2exe, and started to get the following errors when you use a typelib with py2exe? (I am working through this on the py2exe mailing list, but since it's related to the win32 libraries, I thought I would ask here as well...) I think I figured what is causing it... But I am not sure how to fix it... >running py2exe >*** generate typelib stubs *** >error: >C:\develope\security\build\bdist.win32\winexe\temp\win32com\gen_py\5657 83 >C6-CB41-11D1-8B02-00600806D9B6x0x1x2\SWbemObject.py: No such file or >directory I believe from moving the build location around that somehow an IMP import is preventing py2exe from properly gathering the typelib stubs.... The following code is a general purpose build routine that I use.... (BAS_init is a general purpose start routine, that includes configparser, logging, and other commonly used routines.... bas_common is similar but contains general purpose code that I use in a lot of programs... Those modules can be reverse engineered easily... Or let me know if you want copies of the modules) But what happens is that I use the IMP module to load the application so that I can grab the author, name, description, and version data from the application. This way I can use the same build routines for *every* application. If I move the build code to before the IMP load, it seems to work fine. If I move it after the IMP load, it fails with the "No such file or directory...." error... Any suggestions? - Benjamin --------------------------------------------------------------------- from distutils.core import setup import py2exe import bas_init import sys import os import imp import bas_common initialization_data = bas_init.initialization_wrapper () initialization_data.cmd_line_interface.add_option ("-b", "--build", action="store", type="string", dest="app_to_build", help="Application to Build", default="source.py") initialization_data.cmd_line_interface.add_option ("-w", "--windows", action="store_true", dest="Windows_Mode", help="Windows Mode", default=False) initialization_data.run_cmd_line_parse ( ) application_name = initialization_data.cmd_line_options.app_to_build application_name = os.path.splitext( application_name )[0] windows_mode = initialization_data.cmd_line_options.Windows_Mode try: file, path, description = imp.find_module(application_name) except ImportError: print "Unable to find Build Target" sys.exit(5)# deal however you wish with the module not being found else: try: tool = imp.load_module("application", file,path,description) finally: file.close() #>>> # Use these commands in Python code to auto generate .py support #from win32com.client import gencache #gencache.EnsureModule('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1, 2) if windows_mode: print "Windows" setup(windows=[initialization_data.cmd_line_options.app_to_build], author = tool.__author__ , name = tool.__application_name__, description = tool.__description__, version = tool.__version__, zipfile="system_files\\library.zip", options = {"py2exe":{ "optimize":2, "typelibs" : [('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1, 2)], "packages": ["encodings"], "compressed": 1}} ) else: print "Console" setup(console=[initialization_data.cmd_line_options.app_to_build], author = tool.__author__ , name = tool.__application_name__, description = tool.__description__, version = tool.__version__, zipfile="system_files\\library.zip", options = { "py2exe":{"optimize":2, "typelibs" : [('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1, 2)], "packages": ["encodings"], "compressed": 1}} ) From replytodirk at web.de Tue May 24 00:43:32 2005 From: replytodirk at web.de (replytodirk@web.de) Date: Tue, 24 May 2005 00:43:32 +0200 Subject: [python-win32] Q: daemon spawn from within apache cgi blocks parent process Message-ID: <002601c55fe8$d9372b50$0c64a8c0@Bender> Hi all! I want to create a daemon process from within a python cgi script running on apache/win32. This daemon's lifetime is longer than that of the creating cgi script - of course, because the script starts the daemon, writes some html code to stdout and then exits. This simple task kept me busy for weeks! What I'm doing in the script is to spawn a new process with win32process.CreateProcess() or subprocess.Popen() and then it writes html code which dynamically creates a web-page consisting of 3 frames. The frame references are pointing to the very same script which will then be executed by apache multiple times until all frames are rendered (this times bypassing the daemon creation code). The strange thing is that the script execution for rendering the last frame is delayed until the daemon process exits! I completely do not understand this. The daemon process starts and the script is executed repeatedly for all frame references but the last one, leaving the browser in a 'page loading' state. As soon as the daemon process exits, the script is executed again to generate the last frame and the page is loaded completely. When the script doesn't start the daemon, the frames are filled without any delay. Does anybody have an idea what goes wrong here? Is there any connection between a parent and a child process which has to be released before the processes can die independently? Are there any Apache-specific things to handle when spawning processes? Your help would be greatly appreciated! Dirk From peter.mctaggart at gmail.com Tue May 24 06:50:05 2005 From: peter.mctaggart at gmail.com (Peter McTaggart) Date: Tue, 24 May 2005 14:50:05 +1000 Subject: [python-win32] Getting file security access info on network Message-ID: Hi, I'm trying to write a little python prog to list the groups and their members that have access to a directory or file on a network device. I can get info for a local file (on C drive) but this doesn't seem to work on a network drive: I get teh following error ------------------------------- Traceback (most recent call last): File "C:\software\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\projects\access_groups\AccessList.py", line 36, in ? accounts = getAccountList(domain, sidList) File "C:\projects\access_groups\AccessList.py", line 20, in getAccountList accounts = [ win32security.LookupAccountSid(domain,x) for x in sidList] error: (1332, 'LookupAccountSid', 'No mapping between account names and security IDs was done.') ------------------------------ I'm not sure what this means. Can anyone enlighten me or point me in the right direction. thanks Peter .............. Here is the code that I have managed to write so far: import win32security, sys from optparse import OptionParser def getAceList(filename): secDes = win32security.GetNamedSecurityInfo(filename, \ win32security.SE_FILE_OBJECT, \ win32security.DACL_SECURITY_INFORMATION \ | win32security.GROUP_SECURITY_INFORMATION \ | win32security.OWNER_SECURITY_INFORMATION) dacl = secDes.GetSecurityDescriptorDacl() aceList = [] for i in range(dacl.GetAceCount()): aceList.append(dacl.GetAce(i)) return aceList def getAccountList(domain, sidList): accounts = [ win32security.LookupAccountSid(domain,x) for x in sidList] return accounts if __name__ == "__main__": parser = OptionParser() parser.add_option("-f", "--file", dest='filename', help="list access names and groups for FILE", metavar="FILE") parser.add_option("-d", "--domain", dest='domain', help="domain to use for the security info", metavar="DOMAIN") (options, args) = parser.parse_args() filename = options.filename domain = options.domain aceList = getAceList(filename) sidList = [x[2] for x in aceList] accounts = getAccountList(domain, sidList) for account in accounts: print str(account) From mjmaurer at yahoo.com Tue May 24 18:27:33 2005 From: mjmaurer at yahoo.com (Michael Maurer) Date: Tue, 24 May 2005 09:27:33 -0700 (PDT) Subject: [python-win32] PyCListCtrl.GetItem() across processes Message-ID: <20050524162733.50504.qmail@web54407.mail.yahoo.com> > Hello, I am trying to read the contents of a CListCtrl. The > control is in a window owned by a non-python process. I answered my own question... The problem was indeed that the PyCListCtrl implementation assumes the LV_ITEM memory is in the same process as the list control. If you allocate some virtual memory in the process that owns the control, then use that memory for your LV_ITEM, and call SendMessage yourself, you can make it work. I followed the same approach explained here: http://www.codeproject.com/threads/int64_memsteal.asp -Michael M __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new Resources site http://smallbusiness.yahoo.com/resources/ From timr at probo.com Tue May 24 18:48:58 2005 From: timr at probo.com (Tim Roberts) Date: Tue, 24 May 2005 09:48:58 -0700 Subject: [python-win32] Q: daemon spawn from within apache cgi blocks parent process In-Reply-To: References: Message-ID: <42935AFA.8030102@probo.com> On Tue, 24 May 2005 00:43:32 +0200, wrote: >I want to create a daemon process from within a python cgi script running on >apache/win32. This daemon's lifetime is longer than that of the creating cgi >script - of course, because the script starts the daemon, writes some html >code to stdout and then exits. This simple task kept me busy for weeks! >... >Does anybody have an idea what goes wrong here? Is there any connection >between a parent and a child process which has to be released before the >processes can die independently? Are there any Apache-specific things to >handle when spawning processes? > > Yes. A CGI connection is considered "open" until the stdout file handle closes. Your spawned process is inheriting all of your handles, so stdout remains open until the spawned process closes it. Normally, that only happens when the process exits. You have a couple of choices. If you are using CreateProess, you can specify that handles are not to be inherited (it's the 5th parameter to CreateProcess API; I don't know where it lives in PyWin32). Or, you can have the daemon close the stdout handle as soon as it starts. Either solution should solve your problem. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rwupole at msn.com Tue May 24 22:30:49 2005 From: rwupole at msn.com (Roger Upole) Date: Tue, 24 May 2005 16:30:49 -0400 Subject: [python-win32] Re: Getting file security access info on network Message-ID: Basically it means the sid in question doesn't exist on that domain. It could be a sid for an account that's been removed, or a local account on the remote machine, or even a sid for an account on another domain. Roger "Peter McTaggart" wrote: > Hi, > > I'm trying to write a little python prog to list the groups and their > members that have access to a directory or file on a network device. > > I can get info for a local file (on C drive) but this doesn't seem to > work on a network drive: > > I get teh following error > ------------------------------- > Traceback (most recent call last): > File > "C:\software\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", > line 310, in RunScript > exec codeObject in __main__.__dict__ > File "C:\projects\access_groups\AccessList.py", line 36, in ? > accounts = getAccountList(domain, sidList) > File "C:\projects\access_groups\AccessList.py", line 20, in > getAccountList > accounts = [ win32security.LookupAccountSid(domain,x) for x in sidList] > error: (1332, 'LookupAccountSid', 'No mapping between account names > and security IDs was done.') > ------------------------------ > I'm not sure what this means. > From replytodirk at web.de Tue May 24 23:48:30 2005 From: replytodirk at web.de (replytodirk@web.de) Date: Tue, 24 May 2005 23:48:30 +0200 Subject: [python-win32] Q: daemon spawn from within apache cgi blocks parent process References: <42935AFA.8030102@probo.com> Message-ID: <000001c560ac$0ba03fa0$0c64a8c0@Bender> > On Tue, 24 May 2005 00:43:32 +0200, wrote: > > >I want to create a daemon process from within a python cgi script running on > >apache/win32. This daemon's lifetime is longer than that of the creating cgi > >script - of course, because the script starts the daemon, writes some html > >code to stdout and then exits. This simple task kept me busy for weeks! > >... > >Does anybody have an idea what goes wrong here? Is there any connection > >between a parent and a child process which has to be released before the > >processes can die independently? Are there any Apache-specific things to > >handle when spawning processes? Thanks to Robin Becker and Tim Roberts this problem is solved! CreateProcess(..., InheritHandles=0, creationflags=DETACHED_PROCESS) does the trick. I could not get the other idea regarding closing stdout in the daemon to work as well, though. I tried the following: In the daemon-creator: Child = Popen(CommandLine, stdin=PIPE, stdout=PIPE, stderrPIPE, creationflags=DETACHED_PROCESS) Child.stderr.close() Child.stdout.close() Child.stdin.close() And in the daemon: os.close(0) os.close(1) os.close(2) But it didn't work. The creator still was somehow connected to the daemon, because it didn't terminate until the daemon itself terminated. It's not that much of a problem because I use the InhertiHandles=0 method, but still strange and not understood... Thanks again guys, Dirk From LeegleechN at charter.net Wed May 25 05:07:22 2005 From: LeegleechN at charter.net (Nisarg Kothari) Date: Tue, 24 May 2005 22:07:22 -0500 Subject: [python-win32] Windows drag and drop functionality Message-ID: <4293EBEA.3090603@charter.net> I need a way to drag and drop file[names] from windows into some Python based gui. The only thing I found remotely close to what I'm looking for is Tkdnd.py, but that only works within the program. I need support for dragging from the windows desktop or explorer window. As I have not yet begun making the GUI, I'm open to any kind of solution. If it is necessary I can use a compiled snippet of some other language (Java?) to call my python, either in script or executable form (via py2exe). This is a windows only project so cross-platform support is not necessary. Any suggestions? From dohope2001 at yahoo.com.cn Wed May 25 15:15:42 2005 From: dohope2001 at yahoo.com.cn (yuan ye) Date: Wed, 25 May 2005 21:15:42 +0800 (CST) Subject: [python-win32] convert encoding from UNIX/MAC to DOS Message-ID: <20050525131543.55196.qmail@web15806.mail.cnb.yahoo.com> Hello everyone, If you have ever used UltraEdit, you will know that it can convert encoding from Unix/Mac to Dos. Does anybody know how I can do it in Python without the help of UltraEdit? For example, to convert the encoding from Unix/Mac to Dos for a TXT file. Regards Ye _________________________________________________________ Do You Yahoo!? 150万曲MP3疯狂搜,带您闯入音乐殿堂 http://music.yisou.com/ 美女明星应有尽有,搜遍美图、艳图和酷图 http://image.yisou.com 1G就是1000兆,雅虎电邮自助扩容! http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/ From tim.golden at viacom-outdoor.co.uk Wed May 25 17:22:42 2005 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed, 25 May 2005 16:22:42 +0100 Subject: [python-win32] Windows drag and drop functionality Message-ID: <9A28C052FF32734DACB0A288A3533991EBB855@vogbs009.gb.vo.local> [Nisarg Kothari] | I need a way to drag and drop file[names] from windows into | some Python based gui. The only thing I found remotely close | to what I'm looking for is Tkdnd.py, but that only works within | the program. I need support for dragging from the windows desktop | or explorer window. You can certainly do this from wxPython: http://wiki.wxpython.org/index.cgi/DragAndDrop 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 Thu May 26 01:03:24 2005 From: rwupole at msn.com (Roger Upole) Date: Wed, 25 May 2005 19:03:24 -0400 Subject: [python-win32] Re: Windows drag and drop functionality Message-ID: If you're using native windows, you can catch the WM_DROPFILES window message and use win32api.DragQueryFile to get the names of dropped files. Roger "Nisarg Kothari" wrote: >I need a way to drag and drop file[names] from windows into some Python > based gui. The only thing I found remotely close to what I'm looking for > is Tkdnd.py, but that only works within the program. I need support for > dragging from the windows desktop or explorer window. As I have not yet > begun making the GUI, I'm open to any kind of solution. If it is > necessary I can use a compiled snippet of some other language (Java?) to > call my python, either in script or executable form (via py2exe). This > is a windows only project so cross-platform support is not necessary. > Any suggestions? From mhammond at skippinet.com.au Thu May 26 02:54:00 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 26 May 2005 10:54:00 +1000 Subject: [python-win32] Windows drag and drop functionality In-Reply-To: Message-ID: > If you're using native windows, you can catch the WM_DROPFILES > window message and use win32api.DragQueryFile to get the > names of dropped > files. It may also be necessary to call DragAcceptFiles. This is missing from win32gui (but has been addded), but does exist in win32ui. You may need to do something like: win32ui.CreateWindowFromHandle(hwnd).DragAcceptFiles(True) In builds 205 and later you will be able to say: win32gui.DragAcceptFiles(hwnd, True) Mark From amonroe at columbus.rr.com Thu May 26 03:40:40 2005 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Wed, 25 May 2005 21:40:40 -0400 Subject: [python-win32] can dev-cpp's "winanim" example be duplicated with win32gui etc? Message-ID: <46288357586.20050525214040@columbus.rr.com> How feasible is it to write programs like the supplied example in pure python, ideally without resorting to ctypes? (ctypes is bloody useful but if I'm going to that amount of trouble I could just write plain C) By extension can you make a decent barebones Windows screensaver with not too much code? Skimming over the Lucian Wischik screensaver article it seems vaguely possible. WRT to the supplied example, I couldn't find the GetMessage function in the win32gui module. Seems like it would be nearly mandatory, from my very sketchy knowledge of Windows. Googling around I found this old post to the list http://mail.python.org/pipermail/python-win32/2004-December/002771.html but had the same problems as the original poster and I couldn't find any followups on the thread with fixes. Alan -------------- next part -------------- A non-text attachment was scrubbed... Name: Main.c Type: application/octet-stream Size: 4523 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050525/e37d441f/Main.obj From list.repository at gmail.com Thu May 26 07:37:28 2005 From: list.repository at gmail.com (list repository) Date: Thu, 26 May 2005 00:37:28 -0500 Subject: [python-win32] Python 2.4:win32com:ADODB.Connection:py2exe:KeyError Message-ID: <6a64100b05052522373612222d@mail.gmail.com> Hello win32, Python 2.4 Problem: Works fine when running python test.py but fails when executing test.exe. [Note test.exe was created using py2exe] conn = win32com.client.gencache .EnsureDispatch('ADODB.Connection') conn.Open("Provider='SQLOLEDB';Data Source='.';Initial Catalog='mydatabase';User ID='user';Password='pwd';") Traceback (most recent call last): File "test.py", line 66, in ? File "test.py", line 57, in main File "test.py", line 16, in test_status File "win32com\client\gencache.pyc", line 540, in EnsureDispatch File "win32com\client\CLSIDToClass.pyc", line 50, in GetClass KeyError: '{00000550-0000-0010-8000-00AA006D2EA4}' Any suggestions... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050526/485a864a/attachment.htm From mhammond at skippinet.com.au Thu May 26 09:00:00 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 26 May 2005 17:00:00 +1000 Subject: [python-win32] Python 2.4:win32com:ADODB.Connection:py2exe:KeyError In-Reply-To: <6a64100b05052522373612222d@mail.gmail.com> Message-ID: EnsureDispatch will not generate in frozen applications. You can specify 'typelibs' in the py2exe options dict. The format is the same as passed to EnsureModule and printed by "makepy -i" eg, to include the MSOffice typelib you could say: py2exe_options = { 'typelibs': [ ('{00062FFF-0000-0000-C000-000000000046}', 0, 9, 0), ] } ... setup(name=... options = {"py2exe": py2exe_options} -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of list repository Sent: Thursday, 26 May 2005 3:37 PM To: python-win32 at python.org Subject: [python-win32] Python 2.4:win32com:ADODB.Connection:py2exe:KeyError Hello win32, Python 2.4 Problem: Works fine when running python test.py but fails when executing test.exe. [Note test.exe was created using py2exe] conn = win32com.client.gencache .EnsureDispatch('ADODB.Connection') conn.Open("Provider='SQLOLEDB';Data Source='.';Initial Catalog='mydatabase';User ID='user';Password='pwd';") Traceback (most recent call last): File "test.py", line 66, in ? File "test.py", line 57, in main File "test.py", line 16, in test_status File "win32com\client\gencache.pyc", line 540, in EnsureDispatch File "win32com\client\CLSIDToClass.pyc", line 50, in GetClass KeyError: '{00000550-0000-0010-8000-00AA006D2EA4}' Any suggestions... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050526/3a6f616e/attachment.html From mhammond at skippinet.com.au Thu May 26 09:26:42 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 26 May 2005 17:26:42 +1000 Subject: [python-win32] can dev-cpp's "winanim" example be duplicated withwin32gui etc? In-Reply-To: <46288357586.20050525214040@columbus.rr.com> Message-ID: > How feasible is it to write programs like the supplied example in pure > python, ideally without resorting to ctypes? (ctypes is bloody useful > but if I'm going to that amount of trouble I could just write plain C) It should be quite feasable. Obviously a few things would need to be done differently, including the WndProc, and the timer would use the win32 "timer" module with a callback function. Note that there is no reason you can't use ctypes for any missing corners - that still gives you better productivity than C. Of course, if you have a C compiler and the missing functions are quite simple (ie, take simple types as params), then adding them to win32gui and submitting the patch to me is another option. > WRT to the supplied example, I couldn't find the GetMessage function > in the win32gui module. Seems like it would be nearly mandatory, from > my very sketchy knowledge of Windows. The internal "message loop" is built into win32gui in PumpMessages() - internally we do that Get/Translate/Dispatch dance, and delegate the message itself to a Python function via the Python "message map". For completeness though I have just added GetMessage() - but it should only be used in rare cases - the performance of the loop in C will be much better. > Googling around I found this old post to the list > http://mail.python.org/pipermail/python-win32/2004-December/002771.html > but had the same problems as the original poster and I couldn't find > any followups on the thread with fixes. That question seemed to have been re-asked in January, and I saw that one :) See http://mail.python.org/pipermail/python-win32/2005-January/002859.html - and note that build 204 already has the modified demo as mentioned in that mail. Alan From amonroe at columbus.rr.com Thu May 26 12:37:45 2005 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Thu, 26 May 2005 06:37:45 -0400 Subject: [python-win32] can dev-cpp's "winanim" example be duplicated withwin32gui etc? In-Reply-To: References: Message-ID: <159320582072.20050526063745@columbus.rr.com> > The internal "message loop" is built into win32gui in PumpMessages() - > internally we do that Get/Translate/Dispatch dance, and delegate the message > itself to a Python function via the Python "message map". For completeness > though I have just added GetMessage() - but it should only be used in rare > cases - the performance of the loop in C will be much better. Interesting. This isn't mentioned at all in PyWin32.chm. Where could/should I have learnt about it? Alan From simon.brunning at gmail.com Thu May 26 13:09:07 2005 From: simon.brunning at gmail.com (Simon Brunning) Date: Thu, 26 May 2005 12:09:07 +0100 Subject: [python-win32] convert encoding from UNIX/MAC to DOS In-Reply-To: <20050525131543.55196.qmail@web15806.mail.cnb.yahoo.com> References: <20050525131543.55196.qmail@web15806.mail.cnb.yahoo.com> Message-ID: <8c7f10c605052604091321927d@mail.gmail.com> On 5/25/05, yuan ye wrote: > Hello everyone, > If you have ever used UltraEdit, you will know that it > can convert encoding from Unix/Mac to Dos. Does > anybody know how I can do it in Python without the > help of UltraEdit? For example, to convert the > encoding from Unix/Mac to Dos for a TXT file. See \Tools\Scripts\lfcr.py under Python's home directory. -- Cheers, Simon B, simon at brunningonline.net, http://www.brunningonline.net/simon/blog/ From quadric at primenet.com Thu May 26 18:40:53 2005 From: quadric at primenet.com (quadric@primenet.com) Date: Thu, 26 May 2005 09:40:53 -0700 Subject: [python-win32] Inserting a dictionary of lists into '__main__' of an embedded interpreter Message-ID: <5.1.1.6.2.20050526092038.0303c208@pop3.globalcrossing.net> Hi, I have an application that has an embedded interpreter. This application loads many DLL's and passes a PyObject * to each DLL that was gotten from the following call: PyObject * pmod = PyImport_AddModule("__main__") ; Later, in one of the many DLL's that interact with the embedded interpreter, I attempt to insert a dictionary of lists into the module represented by the pointer 'pmod' passed to the DLL from the main application. The dictionary of lists is created with the following call: PyObject * abm_dict = Py_BuildValue( "{s:O,s:O,s:O,s:O,s:O,s:O,s:O,s:O,s:O}" , "i_list" , i_list , "l_list" , l_list , "bpl_list" , bpl_list, "rt_list" , rt_list , "st_list" ,st_list , "u2_list" , u2_list , "t_list" , t_list ,"ot_list" , ot_list , "plt_list" , plt_list ); where each item following a quoted string is a PyObject * created by another Py_BuildValue statement. After building 'abm_dict' , I attempt to insert it into the embedded interpreter with the following call: PyModule_AddObject( pmod , "abm_dict" , abm_dict ); The application crashes at this point. Being a bit new to embedded Python, I don't readily see what I'm doing wrong. Could one of you more experienced guys save me a whole lot of time and point out the obvious to me. Thanks for your help. From rays at blue-cove.com Thu May 26 19:51:05 2005 From: rays at blue-cove.com (Ray Schumacher) Date: Thu, 26 May 2005 10:51:05 -0700 Subject: [python-win32] dde.pyd always dies after exactly 16378 Requests Message-ID: <5.2.0.4.2.20050526104738.0713d990@blue-cove.com> In the attached .py test, I start an external program that provides data access via DDE. create a server do a number of CreateConversation-s, one for each channel make connections do lots of .Request on the connections I tried just one channel, one connection, still 16378, so it seems to be the total number of requests, irrespective of connections/Conversations. Do I need to periodically clean up resources somehow? The docs at Activestate are a bit sparse, and I could not find the answer from MSDN.com: "The maximum number of DDE conversations that can be open simultaneously is determined by Microsoft Windows and your computer's memory and resources. If the conversation can't be initiated because application isn't running or doesn't recognize topic, or if the maximum number of conversations has already been reached, the DDE function returns a Null. " But, conversations is not the issue. Am I doing DDE in a fundamentally inefficient manner? Would using 'CreateServerSystemTopic', 'CreateStringItem', 'CreateTopic' help at all? When I run this script (or similar, counting requests), it always ends up like this: C:\python ddeclient_tst.py ... 16362 same 16363 16364 16365 16366 16367 16368 16369 16370 16371 same 16372 16373 16374 16375 16376 16377 16378 <---- dies here with Windows error >> C:\ I could shut down the server and reconnect it all, but that takes significant time. Thanks, Ray -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050526/9f583409/attachment-0001.htm -------------- next part -------------- import os, sys import win32ui import dde import win32api import win32process import time pathpy = 'C:/Program Files/PRO 4.0/' oldPath = os.getcwd( ) os.chdir(pathpy) STARTUPINFO=win32process.STARTUPINFO() execute_target=pathpy+'prog.exe' commandLine=None processAttributes=None threadAttributes=None bInheritHandles=0 dwCreationFlags=win32process.NORMAL_PRIORITY_CLASS newEnvironment=None processHndl, primary_thread, pid, tid = win32process.CreateProcess(execute_target, commandLine, processAttributes, threadAttributes, bInheritHandles, dwCreationFlags, newEnvironment, os.getcwd( ), STARTUPINFO) time.sleep(6) print 'start', processHndl, primary_thread os.chdir(oldPath) server = dde.CreateServer() server.Create("Py") channels = 4 ## make a list of pre-connected conversations ## 0 is STATUS ## 1 is COMMAND ## 2-8 are channels ddeConvList = [] for c in range(2+channels*2): ddeConvList.append(dde.CreateConversation(server)) ddeConvList[0].ConnectTo("CV90", "STATUS") ddeConvList[1].ConnectTo("CV90", "COMMAND") for chnl in range(2, 2+channels): ddeConvList[chnl].ConnectTo("CV90", "CHANNEL_"+str(chnl)) try: ddeConvList[1].Exec("LOAD CNFG C:\\GenIM.cfg") except: pass time.sleep(3) ddeConvList[1].Exec("CTRL WATR START") start = time.time()-.00001 caught = 0 reqs = 0 lastreq = '' while caught<20000 and time.time() References: Message-ID: <429614A2.3070805@probo.com> On Wed, 25 May 2005 21:15:42 +0800 (CST), yuan ye wrote: >Hello everyone, >If you have ever used UltraEdit, you will know that it >can convert encoding from Unix/Mac to Dos. Does >anybody know how I can do it in Python without the >help of UltraEdit? For example, to convert the >encoding from Unix/Mac to Dos for a TXT file. > I think this is not a proper use of the word "encoding". There is no such thing as a "DOS encoding" or a "Unix/Mac encoding". Instead, I rather suspect that this is translating the end-of-line characters, which ARE different between the three environments. Unix marks end-of-line with a single linefeed (0x0A). The Mac marks end-of-line with a single carriage return (0x0D). DOS uses both (0x0D, 0x0A). If you have Python 2.3 or greater, it allows you to open a file for "universal newlines", where it will detect the standard in use and handle it appropriately. So, for short files, you can do this: open('localEndings.txt','w').write( open('unknownEndings.txt','rU').read() ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Fri May 27 01:16:48 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 27 May 2005 09:16:48 +1000 Subject: [python-win32] dde.pyd always dies after exactly 16378 Requests In-Reply-To: <5.2.0.4.2.20050526104738.0713d990@blue-cove.com> Message-ID: <00c301c56248$fe996400$030a0a0a@enfoldsystems.local> I can see no obvious leaks in the dde code. It is possible the problem is at the "other end" of the conversation? If it possible to create a repro case using Python code at both ends? Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Ray Schumacher Sent: Friday, 27 May 2005 3:51 AM To: python-win32 at python.org Subject: [python-win32] dde.pyd always dies after exactly 16378 Requests In the attached .py test, I start an external program that provides data access via DDE. create a server do a number of CreateConversation-s, one for each channel make connections do lots of .Request on the connections I tried just one channel, one connection, still 16378, so it seems to be the total number of requests, irrespective of connections/Conversations. Do I need to periodically clean up resources somehow? The docs at Activestate are a bit sparse, and I could not find the answer from MSDN.com: "The maximum number of DDE conversations that can be open simultaneously is determined by Microsoft Windows and your computer's memory and resources. If the conversation can't be initiated because application isn't running or doesn't recognize topic, or if the maximum number of conversations has already been reached, the DDE function returns a Null. " But, conversations is not the issue. Am I doing DDE in a fundamentally inefficient manner? Would using 'CreateServerSystemTopic', 'CreateStringItem', 'CreateTopic' help at all? When I run this script (or similar, counting requests), it always ends up like this: C:\python ddeclient_tst.py ... 16362 same 16363 16364 16365 16366 16367 16368 16369 16370 16371 same 16372 16373 16374 16375 16376 16377 16378 <---- dies here with Windows error >> C:\ I could shut down the server and reconnect it all, but that takes significant time. Thanks, Ray -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050527/0f544022/attachment.htm From amonroe at columbus.rr.com Fri May 27 03:26:52 2005 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Thu, 26 May 2005 21:26:52 -0400 Subject: [python-win32] can dev-cpp's "winanim" example be duplicated withwin32gui etc? In-Reply-To: <159320582072.20050526063745@columbus.rr.com> References: <159320582072.20050526063745@columbus.rr.com> Message-ID: <65373929091.20050526212652@columbus.rr.com> >> The internal "message loop" is built into win32gui in PumpMessages() - >> internally we do that Get/Translate/Dispatch dance, and delegate the message >> itself to a Python function via the Python "message map". For completeness >> though I have just added GetMessage() - but it should only be used in rare >> cases - the performance of the loop in C will be much better. > Interesting. This isn't mentioned at all in PyWin32.chm. Where > could/should I have learnt about it? FWIW, I got a basic window working after loads more Googling and finding this: http://groups-beta.google.com/group/comp.lang.python/msg/f5d8e18c31603d38?hl=en I still wouldn't mind a pointer to any "message map" docs, if anyone has a link. Alan From rays at blue-cove.com Fri May 27 04:08:23 2005 From: rays at blue-cove.com (RayS) Date: Thu, 26 May 2005 19:08:23 -0700 Subject: [python-win32] dde.pyd always dies after exactly 16378 Requests In-Reply-To: <00c301c56248$fe996400$030a0a0a@enfoldsystems.local> References: <5.2.0.4.2.20050526104738.0713d990@blue-cove.com> <00c301c56248$fe996400$030a0a0a@enfoldsystems.local> Message-ID: <6.2.1.2.2.20050526190638.02b45c10@blue-cove.com> Hi Mark, I'll try a version calling Excel via DDE as time permits. It's not a show stopper, I just have to be careful. Thanks, Ray At 04:16 PM 5/26/2005, Mark Hammond wrote: >I can see no obvious leaks in the dde code. It is possible the problem is at the "other end" of the conversation? If it possible to create a repro case using Python code at both ends? >-----Original Message----- >From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Ray Schumacher >Sent: Friday, 27 May 2005 3:51 AM >To: python-win32 at python.org >Subject: [python-win32] dde.pyd always dies after exactly 16378 Requests > >In the attached .py test, I start an external program that provides data access via DDE. >create a server >do a number of CreateConversation-s, one for each channel >make connections >do lots of .Request on the connections > >I tried just one channel, one connection, still 16378, so it seems to be the total number of requests, irrespective of connections/Conversations. > >Do I need to periodically clean up resources somehow? > >The docs at Activestate are a bit sparse, and I could not find the answer from MSDN.com: >"The maximum number of DDE conversations that can be open simultaneously is determined by Microsoft Windows and your computer's memory and resources. If the conversation can't be initiated because application isn't running or doesn't recognize topic, or if the maximum number of conversations has already been reached, the DDE function returns a Null. " >But, conversations is not the issue. > >Am I doing DDE in a fundamentally inefficient manner? >Would using 'CreateServerSystemTopic', 'CreateStringItem', 'CreateTopic' help at all? > >When I run this script (or similar, counting requests), it always ends up like this: >C:\python ddeclient_tst.py > >... >16362 same >16363 >16364 >16365 >16366 >16367 >16368 >16369 >16370 >16371 same >16372 >16373 >16374 >16375 >16376 >16377 >16378 <---- dies here with Windows error >>> C:\ > >I could shut down the server and reconnect it all, but that takes significant time. > >Thanks, >Ray -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050526/798ef197/attachment.html From jeffpeery at seametrics.com Fri May 27 15:21:15 2005 From: jeffpeery at seametrics.com (Jeff Peery) Date: Fri, 27 May 2005 06:21:15 -0700 Subject: [python-win32] frame within frame placement? In-Reply-To: Message-ID: <000601c562be$f6a31b80$7600000a@seametrics.local> Hello, I am working on an application (wxpython 2.5, python 2.4, windows XP) and I am having trouble. I would like to place a frame within a frame and I would like it to be constrained so that the child frame cannot move out of the parent frame. What is the best way to do this? Thanks. Jeff From mark.kels at gmail.com Fri May 27 18:35:25 2005 From: mark.kels at gmail.com (Mark Kels) Date: Fri, 27 May 2005 18:35:25 +0200 Subject: [python-win32] Program to lock folders under win32 Message-ID: Hi list. I want to make a program to lock folders (so the user can only access them if he knows the password) under win32, the only problem is that I have no idea how to start or what to do. Do you guys have any ideas about how to do it? Thanks! -- 1. The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners. 2. Unix is user friendly - it's just picky about it's friends. 3. Documentation is like sex: when it is good, it is very, very good. And when it is bad, it is better than nothing. - Dick Brandon From quadric at primenet.com Fri May 27 23:38:23 2005 From: quadric at primenet.com (quadric@primenet.com) Date: Fri, 27 May 2005 14:38:23 -0700 Subject: [python-win32] Parsing a Python dictionary inside a Python extension Message-ID: <5.1.1.6.2.20050527142336.0303ac08@pop3.globalcrossing.net> Hi, I would like to pass a dictionary from my Python code to my Python extension, extract various values from the dictionary (from within the extension) , modify the values for the relevant keys and return the modified dictionary to Python. Can someone point me to an example of what the C code might look like to do this? I tried something like this and it has not worked. static PyObject * ModifyDictionary( PyObject * self , PyObject * args ) { int atab1 = 0 , atab2 = 0; PyObject * vdict = NULL; PyObject * item = NULL; PyObject * ndict = NULL; PyArg_ParseTuple( args , "O" , & vdict ); if ( (item = PyDict_GetItemString( vdict , "atab1")) != NULL ) PyArg_ParseTuple( item , "i" , &atab1 ); if ( (item = PyDict_GetItemString( vdict , "atab2")) != NULL ) PyArg_ParseTuple( item , "i" , &atab2 ); // modify values here and rebuild the dictionary // ndict = Py_BuildValue( ........create dictionary here ..........) return ndict ; } Can someone tell me where I am going wrong or point me to an example? Thanks for your help. From quadric at primenet.com Fri May 27 23:39:22 2005 From: quadric at primenet.com (quadric@primenet.com) Date: Fri, 27 May 2005 14:39:22 -0700 Subject: [python-win32] Inserting a dictionary of lists into '__main__' of an embedded interpreter Message-ID: <5.1.1.6.2.20050527143832.0304d440@pop3.globalcrossing.net> Hi, I have an application that has an embedded interpreter. This application loads many DLL's and passes a PyObject * to each DLL that was gotten from the following call: PyObject * pmod = PyImport_AddModule("__main__") ; Later, in one of the many DLL's that interact with the embedded interpreter, I attempt to insert a dictionary of lists into the module represented by the pointer 'pmod' passed to the DLL from the main application. The dictionary of lists is created with the following call: PyObject * abm_dict = Py_BuildValue( "{s:O,s:O,s:O,s:O,s:O,s:O,s:O,s:O,s:O}" , "i_list" , i_list , "l_list" , l_list , "bpl_list" , bpl_list, "rt_list" , rt_list , "st_list" ,st_list , "u2_list" , u2_list , "t_list" , t_list ,"ot_list" , ot_list , "plt_list" , plt_list ); where each item following a quoted string is a PyObject * created by another Py_BuildValue statement. After building 'abm_dict' , I attempt to insert it into the embedded interpreter with the following call: PyModule_AddObject( pmod , "abm_dict" , abm_dict ); The application crashes at this point. Being a bit new to embedded Python, I don't readily see what I'm doing wrong. Could one of you more experienced guys save me a whole lot of time and point out the obvious to me? Thanks for your help. From rwupole at msn.com Sat May 28 08:53:36 2005 From: rwupole at msn.com (Roger Upole) Date: Sat, 28 May 2005 02:53:36 -0400 Subject: [python-win32] Re: Parsing a Python dictionary inside a Python extension Message-ID: wrote: > Hi, > > I would like to pass a dictionary from my Python code to my Python > extension, extract > various values from the dictionary (from within the extension) , modify > the > values for the > relevant keys and return the modified dictionary to Python. > > Can someone point me to an example of what the C code might look like to > do > this? > > > I tried something like this and it has not worked. > > > static PyObject * ModifyDictionary( PyObject * self , PyObject * args ) > { > int atab1 = 0 , atab2 = 0; > PyObject * vdict = NULL; > PyObject * item = NULL; > PyObject * ndict = NULL; > > PyArg_ParseTuple( args , "O" , & vdict ); You really should be checking if this call succeeded. > > if ( (item = PyDict_GetItemString( vdict , "atab1")) != NULL You should verify that the object is actually a dictionary, see PyDict_Check. > ) PyArg_ParseTuple( item , "i" , &atab1 ); PyArg_ParseTuple only parses tuples. You can use one one of the conversion functions (eg PyInt_AsLong) to convert this. > if ( (item = PyDict_GetItemString( vdict , "atab2")) != NULL > ) PyArg_ParseTuple( item , "i" , &atab2 ); > > // modify values here and rebuild the dictionary > // ndict = Py_BuildValue( ........create dictionary here ..........) > > return ndict ; > } > > > Can someone tell me where I am going wrong or point me to an example? > > Thanks for your help. > You can also use (mis)use PyArg_ParseTupleAndKeywords to extract items en masse from a dict, see PyACL.cpp for an example: http://cvs.sourceforge.net/viewcvs.py/*checkout*/pywin32/pywin32/win32/src/PyACL.cpp Roger From rwupole at msn.com Sat May 28 09:20:50 2005 From: rwupole at msn.com (Roger Upole) Date: Sat, 28 May 2005 03:20:50 -0400 Subject: [python-win32] Program to lock folders under win32 Message-ID: If you're using Win 2000 or later, you can use NTFS encryption. This is based on user certificates, and works transparently so the users don't even need a password. There are functions for managing NTFS encryption in win32file. Roger "Mark Kels" wrote: > Hi list. > > I want to make a program to lock folders (so the user can only access > them if he knows the password) under win32, the only problem is that I > have no idea how to start or what to do. Do you guys have any ideas about > how to do it? > > Thanks! > From python at kareta.de Tue May 31 14:01:53 2005 From: python at kareta.de (=?ISO-8859-15?Q?J=FCrgen_Kareta?=) Date: Tue, 31 May 2005 14:01:53 +0200 Subject: [python-win32] getting email adresses from outlook Message-ID: <429C5231.8040007@kareta.de> Hello, I'm trying to get some email addresses with the following pythoncode: import win32com.client O = win32com.client.gencache.EnsureDispatch('Outlook.Application') mapi=O.GetNamespace('MAPI') adr_li=mapi.AddressLists.Item('Global Addressbook') members=adr_li.AddressEntries.Item('MyGroup').Members for num in range(0, members.__len__()-1): name=entr.GetNext() print name.Name,name.Address That works fine, except that I get the x400 address: paul panther /o=panter group/ou=venus/cn=Recipients/cn=PaulP instead of the expected SMTP adress: paul.panther at pantergoup.com How can I get the SMPT addresses ? regards, J?rgen From steve at holdenweb.com Tue May 31 14:46:26 2005 From: steve at holdenweb.com (Steve Holden) Date: Tue, 31 May 2005 08:46:26 -0400 Subject: [python-win32] getting email adresses from outlook In-Reply-To: <429C5231.8040007@kareta.de> References: <429C5231.8040007@kareta.de> Message-ID: <429C5CA2.6050307@holdenweb.com> J?rgen Kareta wrote: > Hello, > > I'm trying to get some email addresses with the following pythoncode: > > import win32com.client > O = win32com.client.gencache.EnsureDispatch('Outlook.Application') > mapi=O.GetNamespace('MAPI') > adr_li=mapi.AddressLists.Item('Global Addressbook') > members=adr_li.AddressEntries.Item('MyGroup').Members > for num in range(0, members.__len__()-1): > name=entr.GetNext() > print name.Name,name.Address > entr.GetNext? Is it possible you aren't dealing with what you think you are dealing with? Don't see any other reference to this in your code. > That works fine, except that I get the x400 address: > paul panther /o=panter group/ou=venus/cn=Recipients/cn=PaulP > instead of the expected SMTP adress: > paul.panther at pantergoup.com > > How can I get the SMPT addresses ? > >>> members = "iterable" >>> members.__len__() 8 >>> len(members) 8 >>> range(0, 8-1) [0, 1, 2, 3, 4, 5, 6] >>> range(8) [0, 1, 2, 3, 4, 5, 6, 7] >>> [members[x] for x in range(0, members.__len__()-1)] ['i', 't', 'e', 'r', 'a', 'b', 'l'] ^^^ ??? no "e" ??? >>> [x for x in members] ['i', 't', 'e', 'r', 'a', 'b', 'l', 'e'] >>> Try: for num in range(len(members)): name=entr.GetNext() print name.Name,name.Address Seems to me like the X.400 address may be just the first one, and your code is accidentally not handling the last (second, Internet) address. If members is being wrapped by pythoncom as a Python iterable then you might be able to get away with (something like, untested): for entry in adr_li.AddressEntries.Item('MyGroup').Members: for name in entry.Members: print name.Name,name.Address HTH. Just a few ideas. 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 simon.brunning at gmail.com Tue May 31 15:20:30 2005 From: simon.brunning at gmail.com (Simon Brunning) Date: Tue, 31 May 2005 14:20:30 +0100 Subject: [python-win32] getting email adresses from outlook In-Reply-To: <429C5231.8040007@kareta.de> References: <429C5231.8040007@kareta.de> Message-ID: <8c7f10c60505310620324dd877@mail.gmail.com> On 5/31/05, J?rgen Kareta wrote: > Hello, > > I'm trying to get some email addresses with the following pythoncode: > > import win32com.client > O = win32com.client.gencache.EnsureDispatch('Outlook.Application') > mapi=O.GetNamespace('MAPI') > adr_li=mapi.AddressLists.Item('Global Addressbook') > members=adr_li.AddressEntries.Item('MyGroup').Members > for num in range(0, members.__len__()-1): > name=entr.GetNext() > print name.Name,name.Address > > That works fine, except that I get the x400 address: > paul panther /o=panter group/ou=venus/cn=Recipients/cn=PaulP > instead of the expected SMTP adress: > paul.panther at pantergoup.com > > How can I get the SMPT addresses ? Anything here help - ? -- Cheers, Simon B, simon at brunningonline.net, http://www.brunningonline.net/simon/blog/ From python at kareta.de Tue May 31 15:20:49 2005 From: python at kareta.de (=?ISO-8859-15?Q?J=FCrgen_Kareta?=) Date: Tue, 31 May 2005 15:20:49 +0200 Subject: [python-win32] getting email adresses from outlook In-Reply-To: <429C5CA2.6050307@holdenweb.com> References: <429C5231.8040007@kareta.de> <429C5CA2.6050307@holdenweb.com> Message-ID: <429C64B1.9040007@kareta.de> Steve Holden schrieb: > J?rgen Kareta wrote: > >> Hello, >> >> I'm trying to get some email addresses with the following pythoncode: >> >> import win32com.client >> O = win32com.client.gencache.EnsureDispatch('Outlook.Application') >> mapi=O.GetNamespace('MAPI') >> adr_li=mapi.AddressLists.Item('Global Addressbook') >> members=adr_li.AddressEntries.Item('MyGroup').Members >> for num in range(0, members.__len__()-1): >> name=entr.GetNext() >> print name.Name,name.Address >> > entr.GetNext? Is it possible you aren't dealing with what you think > you are dealing with? Don't see any other reference to this in your code. sorry, entr.GetNext should be members.GetNext name= ' ' dir(name) = ['CLSID', 'Delete', 'Details', 'GetFreeBusy', 'Update', 'UpdateFreeBusy', '_ApplyTypes_', '__cmp__', '__doc__', '__getattr__', '__init__', '__module__', '__repr__', '__setattr__', '_get_good_object_', '_get_good_single_object_', '_oleobj_', '_prop_map_get_', '_prop_map_put_', 'coclass_clsid'] name._prop_map_get_ = {'Name': (12289, 2, (8, 0), (), 'Name', None), 'Parent': (61441, 2, (9, 0), (), 'Parent', None), 'DisplayType': (14592, 2, (3, 0), (), 'DisplayType', None), 'MAPIOBJECT': (61696, 2, (13, 0), (), 'MAPIOBJECT', None), 'Class': (61450, 2, (3, 0), (), 'Class', None), 'Application': (61440, 2, (9, 0), (), 'Application', '{00063001-0000-0000-C000-000000000046}'), 'Manager': (771, 2, (9, 0), (), 'Manager', '{0006304B-0000-0000-C000-000000000046}'), 'Session': (61451, 2, (9, 0), (), 'Session', '{00063002-0000-0000-C000-000000000046}'), 'Members': (772, 2, (9, 0), (), 'Members', '{0006304A-0000-0000-C000-000000000046}'), 'Address': (12291, 2, (8, 0), (), 'Address', None), 'Type': (12290, 2, (8, 0), (), 'Type', None), 'ID': (61470, 2, (8, 0), (), 'ID', None)} I found an example on the net for reading/writing contacts with python. There is a property 'AddressType' with value 'SMTP' available. But here, I can't found anything similar. regards, J?rgen