From niki at vintech.bg Mon Nov 1 12:31:56 2004 From: niki at vintech.bg (Niki Spahiev) Date: Mon Nov 1 12:32:09 2004 Subject: [python-win32] Building extensions with non-MSVC compilers In-Reply-To: <20041031195639.58392.qmail@web11002.mail.yahoo.com> References: <20041031195639.58392.qmail@web11002.mail.yahoo.com> Message-ID: <41861EAC.1070708@vintech.bg> David Rushby wrote: > It's worth noting that the "free" command-line version of MSVC 7.1 > (http://msdn.microsoft.com/visualc/vctoolkit2003/ ) can be made to > compile and link both C and C++ extensions with Python 2.4, if you're > willing to go to a lot of trouble: > - Downloading and installing the .NET 1.1 runtime and .NET SDK. > - Downloading and installing the huge Windows Platform SDK, which has > a particularly annoying through-the-web, IE-only installer (this can be > circumvented and the files saved for offline installation). > - Overriding distutils' insistence that the full version of VStudio > 2003 be installed. > - Using the msvcrt.lib from the Platform SDK (msvcrt.lib is not > included with the command-line version of MSVC 7.1). I was unable to find msvcrt.lib in Platform SDK, maybe its in .NET SDK? > - Generating msvcprt.lib on the basis of msvcp71.dll (msvcprt.lib is > also not included with the command-line version of MSVC 7.1). This one too? Niki Spahiev From davidrushby at yahoo.com Mon Nov 1 16:40:49 2004 From: davidrushby at yahoo.com (David Rushby) Date: Mon Nov 1 16:40:57 2004 Subject: [python-win32] Building extensions with non-MSVC compilers In-Reply-To: <41861EAC.1070708@vintech.bg> Message-ID: <20041101154049.73803.qmail@web11001.mail.yahoo.com> --- Niki Spahiev wrote: > David Rushby wrote: > > > It's worth noting that the "free" command-line version of MSVC 7.1 > > (http://msdn.microsoft.com/visualc/vctoolkit2003/ ) can be made to > > compile and link both C and C++ extensions with Python 2.4, if > you're > > willing to go to a lot of trouble: > > - Downloading and installing the .NET 1.1 runtime and .NET SDK. > > - Downloading and installing the huge Windows Platform SDK, which > has > > a particularly annoying through-the-web, IE-only installer (this > can be > > circumvented and the files saved for offline installation). > > - Overriding distutils' insistence that the full version of > VStudio > > 2003 be installed. > > - Using the msvcrt.lib from the Platform SDK (msvcrt.lib is not > > included with the command-line version of MSVC 7.1). > > I was unable to find msvcrt.lib in Platform SDK, maybe its in .NET > SDK? I was mistaken in saying it comes with the Platform SDK; it's probably with the .NET SDK. On my Windows 2000 system, the operating system is installed on C:, while most development tools are on D:. Despite the fact that I ordered all of these SDKs to install on D:, directories "Microsoft Visual Studio .NET" and "Microsoft Visual Studio .NET 2003" were still created in "C:\Program Files". The msvcrt.lib of which I spoke is in "C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib", which I believe to be part of the .NET SDK. The .NET SDK includes a non-optimizing version of VC++; msvcrt.lib accompanies it, but seems to work fine with the optimizing VC++ included with the "Toolkit 2003". I think this overlap was an unintentional slip on Microsoft's part. > > - Generating msvcprt.lib on the basis of msvcp71.dll > > (msvcprt.lib is also not included with the command-line > > version of MSVC 7.1). > > This one too? No. To my knowledge, the official Microsoft C++ .lib file is not available with any of the free SDKs. It can be generated from msvcp71.dll, however (msvcp71.dll is included with both the .NET SDK and the Toolkit 2003). I've found instructions on how to do this in at least two places on the web. I'd link directly to them, but I'm not sure how Microsoft's legions of lawyers feel about them, since it seems that the omission of the dynamic runtime .lib files from the 2003 Toolkit was a deliberate bid to make it unsuitable as a replacement for the full version of VStudio for most developers except students. If you're Feeling Lucky, however, you might just strike it rich with "missing the import library msvcprt.lib needed during linking". _______________________________ Do you Yahoo!? Express yourself with Y! Messenger! Free. Download now. http://messenger.yahoo.com From rogerb at rogerbinns.com Tue Nov 2 07:44:28 2004 From: rogerb at rogerbinns.com (Roger Binns) Date: Tue Nov 2 07:49:20 2004 Subject: [python-win32] Re: how to load 2 python COM DLLs in single app? References: <4177E7A3.9030000@vintech.bg><08c701c4b7b2$c7efcde0$0300a8c0@enfoldsystems.local> <41791964.9060107@vintech.bg> <4179333E.4090700@vintech.bg> <8y9yllih.fsf@python.net> Message-ID: Thomas Heller wrote: > 3b. A hacky way may be this: It would be possible imo to create an PE > file parser/editor, which takes some dlls, reads the PE headers, > import tables, and whatever it needs and builds a new executable by > combining the code segments and creating new import tables. I don't > know if that's really possible... I would be overjoyed if there was something that could make a single executable merging together all the DLLs and the stub loader, especially if I could also feed it a zip file that gets added to the end. It would then be possible to make single file executables that don't need any form of installation. Unfortunately they would be quite large ... There was some discussion of this back on c.l.p a few weeks ago, as TCL already has it in the form of TclKit. (They "cheat" by requiring the extensions implement a particular API that means the dynamic linking can be done by the stub loader instead of the ld.so equivalent). Roger From python at kareta.de Tue Nov 2 16:56:09 2004 From: python at kareta.de (=?ISO-8859-1?B?SvxyZ2VuIEthcmV0YQ==?=) Date: Tue Nov 2 17:00:35 2004 Subject: [python-win32] keyboard macro Message-ID: <1099410969.4187ae19c4497@webmail.ldc.de> Hi all, I need to control a windows application from python in a way that I send this app some key strokes like a keyboard macro recorder. I've googled a lot, but can't find some hints how to build it. I found only some prebuild keyboard macro recorder. I'm not very familiar in programming with win32api. Can someone please tell me if it is possible with python/pywin and where can I start study the nessesary backround ? Thanks in advance regards, J?rgen From tony at tcapp.com Tue Nov 2 17:17:55 2004 From: tony at tcapp.com (Tony Cappellini) Date: Tue Nov 2 17:18:08 2004 Subject: [python-win32] win32com: How to Dispatch a Word document Message-ID: <6.1.2.0.0.20041102081116.03b68e78@mail.yamato.com> >>I think Pythonwin will autocomplete after you type doc. if you have run >>MakePy on Word. I've found that PythonWin doesn't always auto complete even after running Makepy, not necessarily just with Word though. This is one of the confusing aspects of using COM- even with autocomplete, when a method, constant or other attribute doesn't show up after you type the trailing '.' after an object name. Knowledge of the the object hierarchy is absolutely essential to do any COM programming, but still I've found myself following the hierarchy charts and not always seeing the same attributes in PythonWIn as in the hierarchy charts, and vice versa. It can be very maddening at times. The hierarchy charts can be found online at Microsoft under the MSDN, but I dont have the exact path at the moment. Thanks for the tip on the Oreilly book! From tim.golden at viacom-outdoor.co.uk Tue Nov 2 17:20:03 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Nov 2 17:25:07 2004 Subject: [python-win32] keyboard macro Message-ID: [J?rgen Kareta] | I need to control a windows application from python in a way | that I send this app some key strokes like a keyboard macro | recorder. I've googled a lot, but can't find some hints how | to build it. Google about for Simon Brunning's winGuiAuto which is a Python module (or series of modules) for driving Windows in various ways. It's been used (I think) in the PAMIE project for automating IE and also in someone's recently released Testing framework whose name escapes me -- ah yes, WATSUP. 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 blipbeep at gmail.com Thu Nov 4 20:32:15 2004 From: blipbeep at gmail.com (Alias Alias) Date: Thu Nov 4 20:32:24 2004 Subject: [python-win32] Problem with Adding a Custom Header to Outgoing E-mails from a python Outlook Addin In-Reply-To: <1099046298.513.12.camel@laptop> References: <1098964831.469.11.camel@laptop> <934895d004102810342b18ebbc@mail.gmail.com> <1099046298.513.12.camel@laptop> Message-ID: <934895d004110411321ed8fad7@mail.gmail.com> Are you already doing this (modifying the headers) in Visual Basic? If so, how? > I would make an easier question. We have put in some code and used > Inspectors and mailItems. But We are getting the message which we are > trying to send as a MAPIOBJECT. But I am not being able to understand > how do I add a header to the object or even, try and do something about > this. Can we make a Message Object from this MAPI Object. > > The message we are getting is infact a MailItem and we can at best make > a MAPIOBJECT Out of it. Plese help > > I recommend that you look to Visual Basic. There is a lot more > > support, examples, and documentation out there for Visual Basic. > > Then, once > > you have your prototype finished, come back to the Python example > > and things will make much more sense. > > > > Thanks for yor suggesstions, but we already have a working version of > our outlook addin in Visual Basic. We now are trying to port it to > Python. > -- blip beep From bjarni at trackwell.com Thu Nov 4 23:40:52 2004 From: bjarni at trackwell.com (Bjarni Ragnarsson) Date: Thu Nov 4 23:56:49 2004 Subject: [python-win32] listing win32com.client.constants Message-ID: Hi everyone I wonder if it's possible to list the contants in win32com.client.constants once they're availible (at runtime ofc)). Best ,regards, Bjarni Ragnarsson Trackwell Software bjarni@trackwell.com From mc at mclaveau.com Fri Nov 5 09:17:30 2004 From: mc at mclaveau.com (Michel Claveau) Date: Fri Nov 5 09:17:35 2004 Subject: [python-win32] Pb server COM with PHP Message-ID: <006f01c4c30f$e6807300$0501a8c0@PORTABLES> Bonjour ! Hi ! J'ai un serveur COM (avec Python + pyWin32) qui fonctionne bien, depuis VB, IE, Excel, Paradox, etc. etc. I have a COM-server (with Python + pyWin32) who run good, from VB, IE, Excel, Paradox, etc. etc. Mais, avec PHP : But, with PHP : $oa = new COM("Word.Application"); J'ai un probl?me : I have a problem : 'import site' failed; use -v for traceback pythoncom error: PythonCOM Server - The 'win32com.server.policy' module could not be loaded. Traceback (most recent call last): File "C:\Python23\lib\site-packages\win32com\__init__.py", line 5, in ? import win32api, sys, os exceptions.ImportError: No module named win32api Une id?e ? Any idea ? Merci d'avance. Thanks by advance, and sorry for my bad english. -- Michel Claveau From apocalypznow at yahoo.com Fri Nov 5 10:47:40 2004 From: apocalypznow at yahoo.com (apocalypznow) Date: Fri Nov 5 10:38:32 2004 Subject: [python-win32] How to code event handler for makepy generated output? Message-ID: Hello, I used makepy on a type library for a program that is an automation server with connection points. From python, calling inbound methods on the automation server is easy enough, but even after reading Mark Hammond's win32 python book I could not find any examples of how to code for connection points. Specifically, in the makepy generated file it states: # If you create handlers, they should have the following prototypes: # def OnTransfer(self, data=defaultNamedNotOptArg): # """method Transfer""" MY QUESTION IS THIS: how do I code a class that has the above method, and how do I pass an instance of that class to the automation server so that the automation server events are called on it? Here is the fully generated makepy file: # -*- coding: mbcs -*- # Created by makepy.py version 0.4.91 # By python version 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] # From type library 'DispServer.exe' # On Fri Nov 05 01:37:30 2004 """DispServer 1.0 Type Library""" makepy_version = '0.4.91' python_version = 0x20304f0 import win32com.client.CLSIDToClass, pythoncom import win32com.client.util from pywintypes import IID from win32com.client import Dispatch # The following 3 lines may need tweaking for the particular server # Candidates are pythoncom.Missing and pythoncom.Empty defaultNamedOptArg=pythoncom.Empty defaultNamedNotOptArg=pythoncom.Empty defaultUnnamedArg=pythoncom.Empty CLSID = IID('{F4FE2ED2-7EA7-4CA7-9858-7E294C25B30A}') MajorVersion = 1 MinorVersion = 0 LibraryFlags = 8 LCID = 0x0 from win32com.client import DispatchBaseClass class IDispServ(DispatchBaseClass): """IDispServ Interface""" CLSID = IID('{930FE977-4EE2-45E0-920B-B7CBCD7A2E49}') coclass_clsid = IID('{9434DB45-0B88-4D8D-9FF7-BBDF00BA641E}') def Send(self, data=defaultNamedNotOptArg): """method Send""" return self._oleobj_.InvokeTypes(1, LCID, 1, (24, 0), ((12, 1),),data) _prop_map_get_ = { } _prop_map_put_ = { } class _IDispServEvents: """_IDispServEvents Interface""" CLSID = CLSID_Sink = IID('{AF5CAD67-E412-4B61-8DB3-90BC97F259E3}') coclass_clsid = IID('{9434DB45-0B88-4D8D-9FF7-BBDF00BA641E}') _public_methods_ = [] # For COM Server support _dispid_to_func_ = { 1 : "OnTransfer", } def __init__(self, oobj = None): if oobj is None: self._olecp = None else: import win32com.server.util from win32com.server.policy import EventHandlerPolicy cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContainer) cp=cpc.FindConnectionPoint(self.CLSID_Sink) cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy)) self._olecp,self._olecp_cookie = cp,cookie def __del__(self): try: self.close() except pythoncom.com_error: pass def close(self): if self._olecp is not None: cp,cookie,self._olecp,self._olecp_cookie = self._olecp,self._olecp_cookie,None,None cp.Unadvise(cookie) def _query_interface_(self, iid): import win32com.server.util if iid==self.CLSID_Sink: return win32com.server.util.wrap(self) # Event Handlers # If you create handlers, they should have the following prototypes: # def OnTransfer(self, data=defaultNamedNotOptArg): # """method Transfer""" from win32com.client import CoClassBaseClass # This CoClass is known by the name 'DispServer.DispServ.1' class CDispServ(CoClassBaseClass): # A CoClass # DispServ Class CLSID = IID('{9434DB45-0B88-4D8D-9FF7-BBDF00BA641E}') coclass_sources = [ _IDispServEvents, ] default_source = _IDispServEvents coclass_interfaces = [ IDispServ, ] default_interface = IDispServ IDispServ_vtables_dispatch_ = 1 IDispServ_vtables_ = [ (('Send', 'data'), 1, (1, (), [(12, 1, None, None)], 1, 1, 4, 0, 28, (3, 0, None, None), 0)), ] RecordMap = { } CLSIDToClassMap = { '{930FE977-4EE2-45E0-920B-B7CBCD7A2E49}' : IDispServ, '{9434DB45-0B88-4D8D-9FF7-BBDF00BA641E}' : CDispServ, '{AF5CAD67-E412-4B61-8DB3-90BC97F259E3}' : _IDispServEvents, } CLSIDToPackageMap = {} win32com.client.CLSIDToClass.RegisterCLSIDsFromDict( CLSIDToClassMap ) VTablesToPackageMap = {} VTablesToClassMap = { '{930FE977-4EE2-45E0-920B-B7CBCD7A2E49}' : 'IDispServ', } NamesToIIDMap = { 'IDispServ' : '{930FE977-4EE2-45E0-920B-B7CBCD7A2E49}', '_IDispServEvents' : '{AF5CAD67-E412-4B61-8DB3-90BC97F259E3}', } From jens.jorgensen at tallan.com Fri Nov 5 14:41:33 2004 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Fri Nov 5 14:41:47 2004 Subject: [python-win32] listing win32com.client.constants In-Reply-To: References: Message-ID: <418B830D.6000206@tallan.com> Bjarni Ragnarsson wrote: >Hi everyone > >I wonder if it's possible to list the contants in >win32com.client.constants once they're availible (at runtime ofc)). > >Best ,regards, >Bjarni Ragnarsson >Trackwell Software >bjarni@trackwell.com > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > dir(win32com.client.constants) ? -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 2861 bytes Desc: S/MIME Cryptographic Signature Url : http://mail.python.org/pipermail/python-win32/attachments/20041105/6505c169/smime.bin From mhammond at skippinet.com.au Sat Nov 6 01:23:40 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat Nov 6 01:23:43 2004 Subject: [python-win32] How to code event handler for makepy generatedoutput? In-Reply-To: Message-ID: <543801c4c396$dea14c40$0300a8c0@enfoldsystems.local> > # If you create handlers, they should have the following prototypes: > # def OnTransfer(self, data=defaultNamedNotOptArg): > # """method Transfer""" > > > MY QUESTION IS THIS: how do I code a class that has the above method, > and how do I pass an instance of that class to the automation > server so > that the automation server events are called on it? The makepy generated code isn't actually used by event handlers - it is there as a "prototype" for a class you write. There is no need for your class to derive from anything - just implement those methods. As for the rest of the mechanics, check out the docsstrings and examples for win32com.client.WithEvents and DispatchWithEvents Mark From mhammond at skippinet.com.au Sat Nov 6 01:26:53 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat Nov 6 01:26:55 2004 Subject: [python-win32] Pb server COM with PHP In-Reply-To: <006f01c4c30f$e6807300$0501a8c0@PORTABLES> Message-ID: <543f01c4c397$51282540$0300a8c0@enfoldsystems.local> > But, with PHP : > $oa = new COM("Word.Application"); Presumably this is creating a Word object, not a Python object? > > 'import site' failed; use -v for traceback > pythoncom error: PythonCOM Server - The > 'win32com.server.policy' module > could not be loaded. > Traceback (most recent call last): > File "C:\Python23\lib\site-packages\win32com\__init__.py", > line 5, in ? > import win32api, sys, os > exceptions.ImportError: No module named win32api that "'import site' failed" is probably the root of the problem - site.py is what loads the .pth files and sets up your PythonPath so that win32api etc can be found. Try setting "PYTHONVERBOSE=2" in your environment before creating the object - this is the same as "python -v", and should show you the error importing site. Mark From apocalypznow at yahoo.com Sat Nov 6 02:33:28 2004 From: apocalypznow at yahoo.com (apocalypznow) Date: Sat Nov 6 02:24:24 2004 Subject: [python-win32] Dear Mark, Please produce another Win32 Python book! Message-ID: Hi Mark, I must say I loved your book "Python Programming on Win32". I refer to it often and have read a number of the chapters a few times already. Are you considering another book? Perhaps an 'Advanced Python Programming on Win32'? If so, I'll put my money down for it now. From bgailer at alum.rpi.edu Sat Nov 6 04:24:53 2004 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Sat Nov 6 04:23:53 2004 Subject: [python-win32] Dear Mark, Please produce another Win32 Python book! In-Reply-To: References: Message-ID: <6.1.2.0.0.20041105202446.04a28048@mail.mric.net> At 06:33 PM 11/5/2004, apocalypznow wrote: >Hi Mark, >I must say I loved your book "Python Programming on Win32". I refer to it >often and have read a number of the chapters a few times already. > >Are you considering another book? Perhaps an 'Advanced Python Programming >on Win32'? > >If so, I'll put my money down for it now. Me too. >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 Bob Gailer bgailer@alum.rpi.edu 303 442 2625 home 720 938 2625 cell From mc at mclaveau.com Sat Nov 6 11:17:06 2004 From: mc at mclaveau.com (Michel Claveau) Date: Sat Nov 6 11:17:14 2004 Subject: [python-win32] Pb server COM with PHP References: <543f01c4c397$51282540$0300a8c0@enfoldsystems.local> Message-ID: <000601c4c3e9$c8093760$0701a8c0@PORTABLES> Bonjour, Mark ! Hi, Mark ! Thank you for your answer. ||| > $oa = new COM("Word.Application"); ||| Presumably this is creating a Word object, not a Python object? D?sol?, je me suis tromp? dans mon copier/coller ; c'est : Sorry, error with copy/paste ; it's : $oa = new COM("Ponx.Mci"); ||| Try setting "PYTHONVERBOSE=2" in your environment before creating the object - this is the same as "python -v", and should show you the error importing site. Je vais essayer votre suggestion la prochaine nuit (je suis un peu programmeur nocturne) I try your suggestion next night (I am a little night programmer) Pour information, j'ai fait diff?rents essais, et j'ai trouv? que le probl?me n'existe que pour PHP en ligne de commande. Si PHP est accol? ? Apache, il n'y a pas de probl?me. For information, I had try various tests, and I found that the problem exists only for PHP in "command-line". If PHP is coupled in Apache, there is no problem. And *re-sorry for my bad english (powered by google-translation-tool) -- Michel Claveau From mc at mclaveau.com Sat Nov 6 11:21:10 2004 From: mc at mclaveau.com (Michel Claveau) Date: Sat Nov 6 11:21:18 2004 Subject: [python-win32] Dear Mark, Please produce another Win32 Python book! References: Message-ID: <000f01c4c3ea$594b57d0$0701a8c0@PORTABLES> >>> Hi Mark, >>> I must say I loved your book "Python Programming on Win32". I refer to it often and have read a number of the chapters a few times already. >>> >>> Are you considering another book? Perhaps an 'Advanced Python Programming on Win32'? >>> >>> If so, I'll put my money down for it now. +1 (no, +2, because, I think of offering some one to a friend) Michel Claveau From lehmanap at cs.purdue.edu Sun Nov 7 12:44:57 2004 From: lehmanap at cs.purdue.edu (Aaron Patrick Lehmann) Date: Sun Nov 7 12:45:03 2004 Subject: [python-win32] Connecting to Exchange in a MAPI.Session from a service. Message-ID: <20041107114457.GA23984@lore.cs.purdue.edu> Hello all-- I'm trying to use the following code to set up a MAPI.Session with an Exchange server. It works fine from the command prompt, but when I try to run it as a service it fails with a MAPI_E_LOGON_FAILED Error. def _getCDO(self, profile, password ): """ This method gets a CDOSession. Arguments: -------------------------------------------------------------- profile: Tracker's profile name on the Windows Computer. password: Tracker's password for this profile Returns: -------------------------------------------------------------- A CDO Session """ CoInitialize( ) #Initialize COM, if it hasn't been initialized already. cdo = Dispatch("MAPI.Session", "Tracker") cdo.Logon(profile, password, False) return cdo Is there something extra I need in order to run this code as a service? I appreciate your help. Aaron Lehmann -- Why do the Democrats complain about Nader losing them Presidential elections? Republicans don't complain about Libertarians. From Martin.Moellenbeck at t-online.de Sun Nov 7 12:52:26 2004 From: Martin.Moellenbeck at t-online.de (=?iso-8859-1?Q?Martin_M=F6llenbeck?=) Date: Sun Nov 7 12:52:50 2004 Subject: AW: [python-win32] Connecting to Exchange in a MAPI.Session from aservice. In-Reply-To: <20041107114457.GA23984@lore.cs.purdue.edu> Message-ID: maybe you use the system account to run the service and must use the 'loggedon' user account ciao martin > -----Urspr?ngliche Nachricht----- > Von: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org] Im Auftrag von Aaron > Patrick Lehmann > Gesendet: Sonntag, 7. November 2004 12:45 > An: python-win32@python.org > Betreff: [python-win32] Connecting to Exchange in a > MAPI.Session from aservice. > > Hello all-- > > I'm trying to use the following code to set up a MAPI.Session > with an Exchange > server. It works fine from the command prompt, but when I > try to run it as a > service it fails with a MAPI_E_LOGON_FAILED Error. > > > def _getCDO(self, profile, password ): > """ > This method gets a CDOSession. > > Arguments: > > -------------------------------------------------------------- > profile: Tracker's profile name on the > Windows Computer. > password: Tracker's password for this profile > > Returns: > > -------------------------------------------------------------- > A CDO Session > """ > > CoInitialize( ) > #Initialize COM, if it hasn't been initialized already. > cdo = Dispatch("MAPI.Session", "Tracker") > cdo.Logon(profile, password, False) > return cdo > > Is there something extra I need in order to run this code as > a service? I > appreciate your help. > > Aaron Lehmann > -- > Why do the Democrats complain about Nader losing them > Presidential elections? > Republicans don't complain about Libertarians. > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From lehmanap at cs.purdue.edu Sun Nov 7 13:07:12 2004 From: lehmanap at cs.purdue.edu (Aaron Patrick Lehmann) Date: Sun Nov 7 13:07:16 2004 Subject: [python-win32] Connecting to Exchange in a MAPI.Session from aservice. In-Reply-To: References: <20041107114457.GA23984@lore.cs.purdue.edu> Message-ID: <20041107120712.GB24131@lore.cs.purdue.edu> No, I'm running it as the "Tracker" account. Thanks, Aaron Lehmann On Sun, Nov 07, 2004 at 12:52:26PM +0100, Martin Möllenbeck wrote: > maybe you use the system account to run the service and must > use the 'loggedon' user account > > ciao > martin > > > -----Ursprüngliche Nachricht----- > > Von: python-win32-bounces@python.org > > [mailto:python-win32-bounces@python.org] Im Auftrag von Aaron > > Patrick Lehmann > > Gesendet: Sonntag, 7. November 2004 12:45 > > An: python-win32@python.org > > Betreff: [python-win32] Connecting to Exchange in a > > MAPI.Session from aservice. > > > > Hello all-- > > > > I'm trying to use the following code to set up a MAPI.Session > > with an Exchange > > server. It works fine from the command prompt, but when I > > try to run it as a > > service it fails with a MAPI_E_LOGON_FAILED Error. > > > > > > def _getCDO(self, profile, password ): > > """ > > This method gets a CDOSession. > > > > Arguments: > > > > -------------------------------------------------------------- > > profile: Tracker's profile name on the > > Windows Computer. > > password: Tracker's password for this profile > > > > Returns: > > > > -------------------------------------------------------------- > > A CDO Session > > """ > > > > CoInitialize( ) > > #Initialize COM, if it hasn't been initialized already. > > cdo = Dispatch("MAPI.Session", "Tracker") > > cdo.Logon(profile, password, False) > > return cdo > > > > Is there something extra I need in order to run this code as > > a service? I > > appreciate your help. > > > > Aaron Lehmann > > -- > > Why do the Democrats complain about Nader losing them > > Presidential elections? > > Republicans don't complain about Libertarians. > > _______________________________________________ > > Python-win32 mailing list > > Python-win32@python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > -- Why do the Democrats complain about Nader losing them Presidential elections? Republicans don't complain about Libertarians. From mhammond at skippinet.com.au Sun Nov 7 22:22:14 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun Nov 7 22:22:27 2004 Subject: [python-win32] Connecting to Exchange in a MAPI.Session from aservice. In-Reply-To: <20041107114457.GA23984@lore.cs.purdue.edu> Message-ID: <63fa01c4c50f$e0edd200$0300a8c0@enfoldsystems.local> > I'm trying to use the following code to set up a MAPI.Session > with an Exchange > server. It works fine from the command prompt, but when I > try to run it as a > service it fails with a MAPI_E_LOGON_FAILED Error. Services and MAPI are a little strange. Pretty much all I know is summarised at http://aspn.activestate.com/ASPN/Mail/Message/2186413 Mark From Shu-Chin.Cheeng at Shell.com Mon Nov 8 02:06:58 2004 From: Shu-Chin.Cheeng at Shell.com (Cheeng, Shu-Chin SC SITI-ITIBDO2) Date: Mon Nov 8 02:07:06 2004 Subject: [python-win32] Dear Mark, Please produce another Win32 Python book! Message-ID: Me Too Regards, Cheeng Shu Chin SA-Messaging Shell Information Technology International 2340 Century Square, Jalan Usahawan, 63000 Cyberjaya, Selangor D.E., Malaysia -----Original Message----- From: apocalypznow [mailto:apocalypznow@yahoo.com] Sent: Saturday, November 06, 2004 9:33 AM To: python-win32@python.org Subject: [python-win32] Dear Mark, Please produce another Win32 Python book! Hi Mark, I must say I loved your book "Python Programming on Win32". I refer to it often and have read a number of the chapters a few times already. Are you considering another book? Perhaps an 'Advanced Python Programming on Win32'? If so, I'll put my money down for it now. From ah_new at yahoo.com Mon Nov 8 01:51:36 2004 From: ah_new at yahoo.com (ah_new) Date: Mon Nov 8 02:15:28 2004 Subject: [python-win32] win service cant start ? why ? Message-ID: <20041108005136.45232.qmail@web53904.mail.yahoo.com> hey! I been wrote a window service in python with py2.2, win XP pro. After i installed & run it, found that it been not really started. Error msg will displayed after i'm trying to stop the service that been "started" before. the error msg is : " Error stopping service: The service has not been started. (1062) " ... So can you guys give me some guidelines? thanks.. ah_new@yahoo.com ___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com From paandev at yahoo.com Mon Nov 8 04:55:25 2004 From: paandev at yahoo.com (Wara Songkran) Date: Mon Nov 8 04:55:28 2004 Subject: [python-win32] Win 32 GUI + python tutorial Message-ID: <20041108035525.40860.qmail@web51305.mail.yahoo.com> Hi I have start learning python and I found that python have a nice win32 api wrapper. But I found that it does not wrap win32 api function by function. I know win32 programming but I look at the demo code it difference from normal win32 code. So someone please tell me where can I find the web page describe how python wrap win32 gui. May be more code sample. Regards Wara Songkran __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041107/05e73d92/attachment.htm From mhammond at skippinet.com.au Mon Nov 8 06:12:03 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon Nov 8 06:12:12 2004 Subject: [python-win32] win service cant start ? why ? In-Reply-To: <20041108005136.45232.qmail@web53904.mail.yahoo.com> Message-ID: <650101c4c551$7c9a0cf0$0300a8c0@enfoldsystems.local> > Error msg will displayed after i'm trying to stop the > service that been "started" before. the error msg is : > " Error stopping service: The service has not been > started. (1062) " ... That error message simply means you are trying to stop a service that is not running. Using "your_service.py start" does not actually wait until the service reports it started. If you have pywin32-203, try "your_service.py --wait=30 start", and see if it reports success. Alternatively, "net start service_name" *does* wait. Thus, if your service has a startup error, these commands aren't likely to mislead you into believing it has started. Note however that this could still happen if your service reported successful started, and then terminated (due to an error or any other reason). If there is an unhandled exception in your service (which will cause it to terminate), you should find the error in the eventlog. Mark From amonroe at columbus.rr.com Mon Nov 8 15:09:10 2004 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Mon Nov 8 15:09:25 2004 Subject: [python-win32] Translating vbs GetObject("LDAP://...") to Python? Message-ID: <126-1475645226.20041108090910@columbus.rr.com> What is the Python equivalent of this vbs two liner? set obj = GetObject("LDAP://cn=johndoe, ou=General Users, ou=Accounts, dc=na, dc=nisource, dc=net") wscript.echo obj.Get("description") I tried cobbling together this by looking at various google searches, but it doesn't work: import win32com.client adsi = win32com.client.Dispatch('ADsNameSpaces') ldap = adsi.GetObject("", "LDAP:") ds = ldap.OpenDSObject("LDAP://cn=johndoe, ou=General Users, ou=Accounts, dc=na, dc=nisource, dc=net", '', '', 0) desc = ds.Get("description") print desc The error I get: Traceback (most recent call last): File "ldapcomtest.py", line 11, in ? ds = ldap.OpenDSObject("LDAP://cn=U118919, ou=General Users, ou=Accounts, dc=na, dc=nisource, dc=net", '', '', 0) File ">", line 2, in OpenDSObject pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147016672), None) (Line 11 in the actual program is the ds = ldap.Open... line) From tim.golden at viacom-outdoor.co.uk Mon Nov 8 15:26:57 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon Nov 8 15:32:08 2004 Subject: [python-win32] Translating vbs GetObject("LDAP://...") to Pyt hon? Message-ID: [R. Alan Monroe] | What is the Python equivalent of this vbs two liner? | | set obj = GetObject("LDAP://cn=johndoe, ou=General Users, | ou=Accounts, dc=na, dc=nisource, dc=net") | wscript.echo obj.Get("description") Two answers (assuming you do in fact have a johndoe at the position indicated within the AD) 1) Try this (details changed to suit my local setup): import win32com.client obj = win32com.client.GetObject ("LDAP://CN=goldent,CN=Users,DC=gb,DC=vo,DC=local") print obj.Get ("description") 2) Try this: Get http://tgolden.sc.sabren.com/downloads/active_directory.py import active_directory johndoe = active_directory.find_user ("johndoe") print johndoe.description or import active_directory users = active_directory.AD_object (LDAP://ou=Accounts,dc=na,dc=nisource,dc=net) for user in users.search ("cn='johndoe'"): print user.description I keep meaning to put up a page to explain how the module works, but basically it just does a bit of the not-too-heavy lifting when it comes to common operations on Active Directory. 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 niki at vintech.bg Mon Nov 8 10:48:44 2004 From: niki at vintech.bg (Niki Spahiev) Date: Mon Nov 8 15:44:33 2004 Subject: [python-win32] Win 32 GUI + python tutorial In-Reply-To: <20041108035525.40860.qmail@web51305.mail.yahoo.com> References: <20041108035525.40860.qmail@web51305.mail.yahoo.com> Message-ID: <418F40FC.3070103@vintech.bg> Wara Songkran wrote: > Hi > > I have start learning python and I found that python have a nice win32 > api wrapper. But I found that it does not wrap win32 api function by > function. I know win32 programming but I look at the demo code it > difference from normal win32 code. > > So someone please tell me where can I find the web page describe how > python wrap win32 gui. May be more code sample. If you know win32 API, check ctypes module. It can call any function. HTH Niki Spahiev From amonroe at columbus.rr.com Mon Nov 8 16:27:22 2004 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Mon Nov 8 16:27:38 2004 Subject: [python-win32] Translating vbs GetObject("LDAP://...") to Pyt hon? In-Reply-To: References: Message-ID: <160-1470952929.20041108102722@columbus.rr.com> > import win32com.client > obj = win32com.client.GetObject > ("LDAP://CN=goldent,CN=Users,DC=gb,DC=vo,DC=local") > print obj.Get ("description") That worked. If it's so bloody simple, why do all the web sites have the (pretty useless) version I tried at first... grrrr. Anyway, you rock. Alan From mcicogni at libero.it Mon Nov 8 23:07:37 2004 From: mcicogni at libero.it (Mauro Cicognini) Date: Mon Nov 8 23:07:46 2004 Subject: [python-win32] Building extensions with non-MSVC compilers In-Reply-To: <20041031195639.58392.qmail@web11002.mail.yahoo.com> References: <20041031195639.58392.qmail@web11002.mail.yahoo.com> Message-ID: <418FEE29.5050005@libero.it> Hi guys, thanks to everybody for your kind answers, especially David Rushby and Paul Moore who really set me on the right track. The extension compiles fine with minimal effort (I just had to find out how to hack my way around mingw :-) and seems to be working, although I can't test the SSL communication for lack of an LDAPS server. If anybody's interested, the Python-LDAP site on Sourceforge (http://python-ldap.sourceforge.net/) does have links to download the binaries. BTW, one of the pages I read stated that the current release of mingw32 does all the necessary magic by itself with the import library, and it's true. All I had to do was put python23.dll right next to the MSVC import library python32.lib (in c:\python23\libs, in my case). I checked using the "traditional" way (running pexport, generating .a, etc.) and results are the same, just easier :-) All the best, Mauro From amonroe at columbus.rr.com Tue Nov 9 16:29:34 2004 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Tue Nov 9 16:29:53 2004 Subject: [python-win32] Translating vbs GetObject("LDAP://...") to Pyt hon? In-Reply-To: <160-1470952929.20041108102722@columbus.rr.com> References: <160-1470952929.20041108102722@columbus.rr.com> Message-ID: <175-1384421563.20041109102934@columbus.rr.com> >> import win32com.client >> obj = win32com.client.GetObject >> ("LDAP://CN=goldent,CN=Users,DC=gb,DC=vo,DC=local") >> print obj.Get ("description") Having gotten the object "obj" in this manner, how do I work backwards to find out its {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} code and/or Something.Something class name, and list its properties? I'm guessing I need to run makepy or somesuch, but it's not clear to me which thing to pick from makepy's list of classes in this instance, because it's not an immediately obvious one like, say, Microsoft Excel. I don't see any in the list starting with "LDAP" or "Microsoft LDAP". Alan From tim.golden at viacom-outdoor.co.uk Tue Nov 9 16:47:10 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Nov 9 16:52:25 2004 Subject: [python-win32] Translating vbs GetObject("LDAP://...") to Pyt hon? Message-ID: [R. Alan Monroe] | Having gotten the object "obj" in this manner, how do I work backwards | to find out its {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} code and/or | Something.Something class name, and list its properties? [Preamble: not at all an expert on this kind of thing, but...] It's not that kind of COM interface. You want to be Googling for ADSI (something like site:msdn.microsoft.com adsi will probably get some useful results). Having got hold of an object, you can interrogate its schema. Something like this: # # These first four lines are the same # as the GetObject you're doing if you # know your active directory root # from win32com.client import GetObject root = GetObject ("LDAP://rootDSE") context = root.Get ("defaultNamingContext") ad = GetObject ("LDAP://" + context) # # Get the schema (effectvely the class # object from which this instance derives) # schema = GetObject (ad.Schema) print schema.mandatoryProperties print schema.optionalProperties Once again, I'd offer my active directory module, which does some of this for you: http://tgolden.sc.sabren.com/python/active_directory.html 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 amonroe at columbus.rr.com Tue Nov 9 18:33:52 2004 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Tue Nov 9 18:34:10 2004 Subject: [python-win32] Translating vbs GetObject("LDAP://...") to Pyt hon? In-Reply-To: References: Message-ID: <129-1376963128.20041109123352@columbus.rr.com> > schema = GetObject (ad.Schema) > print schema.mandatoryProperties > print schema.optionalProperties I see what you're getting at, but I'm looking at the "PasswordLastChanged" property, which isn't part of the AD schema per se. It's a property of the in-memory object only. I want to see what other properties are available to me also. The question was a general one too, because I'm likely to want to find this information for any arbitrary (non-ADSI) COM object in the future. Alan From amonroe at columbus.rr.com Tue Nov 9 23:08:16 2004 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Tue Nov 9 23:08:33 2004 Subject: [python-win32] Translating vbs GetObject("LDAP://...") to Pyt hon? In-Reply-To: <129-1376963128.20041109123352@columbus.rr.com> References: <129-1376963128.20041109123352@columbus.rr.com> Message-ID: <47-1360499004.20041109170816@columbus.rr.com> > I'm looking at the > "PasswordLastChanged" property, Looking at the .tlb I can see that PasswordLastChanged returns: [id(0x0000003b), propget] HRESULT PasswordLastChanged([out, retval] DATE* retval); If I do type() on the variable I assign it to, it says 'time', and it prints a sensible looking date like 10/25/04 11:18:59 to the screen. But I can't figure out how to compare that to, say, time.time(). How do I find out the number of elapsed days between the date it returns and the current date? I naively tried just subtracting one from the other, but all that gets me is TypeError: unsupported operand type(s) for -: 'float' and 'time' Alan From the.count at count0.dyndns.org Tue Nov 9 23:45:40 2004 From: the.count at count0.dyndns.org (The Count) Date: Tue Nov 9 23:44:17 2004 Subject: [python-win32] Translating vbs GetObject("LDAP://...") to Pyt hon? In-Reply-To: <47-1360499004.20041109170816@columbus.rr.com> References: <129-1376963128.20041109123352@columbus.rr.com> <47-1360499004.20041109170816@columbus.rr.com> Message-ID: On Tue, 9 Nov 2004 17:08:16 -0500, R. Alan Monroe wrote: >> I'm looking at the >> "PasswordLastChanged" property, > > If I do type() on the variable I assign it to, it says 'time', and it > prints a sensible looking date like 10/25/04 11:18:59 to the screen. > But I can't figure out how to compare that to, say, time.time(). How > do I find out the number of elapsed days between the date it returns > and the current date? > > I naively tried just subtracting one from the other, but all that gets > me is TypeError: unsupported operand type(s) for -: 'float' and 'time' > Look at http://docs.python.org/lib/module-time.html you probably want something like mktime(strptime(your_time,"%m/%d/%y %H:%M:%S") if your_time is the "sensible looking date"-string from above ... if your time variable is a struct_time (9-tuple) just use mktime. HTH -- --- The Count From tim.golden at viacom-outdoor.co.uk Wed Nov 10 09:32:26 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed Nov 10 09:37:45 2004 Subject: [python-win32] RE: Finding attributes of COM objects (was: Translating vbs GetOb ject("LDAP://...") to Pyt hon?) Message-ID: [R. Alan Monroe] | > schema = GetObject (ad.Schema) | > print schema.mandatoryProperties | > print schema.optionalProperties | | I see what you're getting at, but I'm looking at the | "PasswordLastChanged" property, which isn't part of the AD schema per | se. It's a property of the in-memory object only. I want to see what | other properties are available to me also. This is always a slightly tricky one, I find. I hope that Mark H or someone equally knowledgeable can pitch in. My experience is that if you have done an EnsureDispatch on a Dispatchable object (or have otherwise generated the Python proxy module) then running the standard Python help on the dispatched object's class will show the methods in the usual way. eg, import win32com.client word = win32com.client.gencache.EnsureDispatch ("Word.Application") help (word.__class__) Other than that, I usually fall back on Googling in the way I described and/or looking for other people's examples. I don't believe there's any more official way than that. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From tim.golden at viacom-outdoor.co.uk Wed Nov 10 09:49:14 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed Nov 10 09:54:31 2004 Subject: [python-win32] Translating vbs GetObject("LDAP://...") to Pyt hon? Message-ID: [R. Alan Monroe] | > I'm looking at the | > "PasswordLastChanged" property, | | Looking at the .tlb I can see that PasswordLastChanged returns: | [id(0x0000003b), propget] | HRESULT PasswordLastChanged([out, retval] DATE* retval); | | If I do type() on the variable I assign it to, it says 'time', and it | prints a sensible looking date like 10/25/04 11:18:59 to the screen. | But I can't figure out how to compare that to, say, time.time(). How | do I find out the number of elapsed days between the date it returns | and the current date? The pywin32 docs for PyTime state that calling int () on a PyTime object will convert it to the result as if you'd used time.time (). So something like the following makes sense: import time [...] now = time.time () password_last_changed = int (me.PasswordLastChanged) print "Password changed on", time.asctime (time.localtime (password_last_changed)) print "Password changed", now - password_last_changed, "seconds ago" Obviously you can do what you like once you've got the time.time ()-like value. 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 the.count at count0.dyndns.org Wed Nov 10 10:07:10 2004 From: the.count at count0.dyndns.org (The Count) Date: Wed Nov 10 10:05:47 2004 Subject: [python-win32] makepy creates gen_py/123-ID.py but no gen_py/123-ID - Folder Message-ID: I'm currently having some trouble with the application I'm controlling via COM, it's update seems to break it's COM-ability. It has released a new type library version. After I ran makepy over it I noticed this didn't create a folder with the library's ID [the 123XYZ-ABC456-x0x0x0 thingy]. After moving the whole (old) stuff to a safe location (and downgrading the software) I reran makepy on the (old) library, it didn't create that folder either. The files contained therein where priceless to me since the official documentation didn't mention certain quirks ... but those sources empowered me to keep going. What am I missing? I do (sort of) remember they weren't there from the start but I have no clue as to how I created them, they're source claims them to be created by makepy ... If I could compare the files for both versions of the library I might find a work-around or at least pin-point the bug. -- --- The Count From tim.golden at viacom-outdoor.co.uk Wed Nov 10 10:10:50 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed Nov 10 10:16:17 2004 Subject: [python-win32] makepy creates gen_py/123-ID.py but no gen_py/ 123-ID - Folder Message-ID: [The Count] [... snip losing makepy folders etc. ...] | What am I missing? I do (sort of) remember they weren't there | from the start but I have no clue as to how I created them, | they're source claims them to be created by makepy ... Don't know why makepy isn't generating them, but if you haven't already, try using EnsureDispatch, so if it was Microsoft Word you were talking about, you'd be doing something like this: import win32com.client word = win32com.client.gencache.EnsureDispatch ("Word.Application") Also, I seem to remember that Mark has moved around the location in which makepy creates its proxy modules. I'm running the latest stable pywin32 and the proxies appear to be being created under my profile in "Local Settings\temp\gen_py\2.3". So, for me, that's C:\Documents and Settings\goldent\Local Settings\temp\gen_py\2.3 HTH 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 the.count at count0.dyndns.org Wed Nov 10 10:41:13 2004 From: the.count at count0.dyndns.org (The Count) Date: Wed Nov 10 10:39:52 2004 Subject: [python-win32] makepy creates gen_py/123-ID.py but no gen_py/ 123-ID - Folder In-Reply-To: References: Message-ID: On Wed, 10 Nov 2004 09:10:50 -0000, Tim Golden wrote: > [The Count] > > [... snip losing makepy folders etc. ...] > > | What am I missing? I do (sort of) remember they weren't there > | from the start but I have no clue as to how I created them, > | they're source claims them to be created by makepy ... > > Don't know why makepy isn't generating them, To clarify : I DO get - the $ID$.py / .pyc file - an __init__.py / .pyc and - a dicts.dat file in .../win32com/gen_py/ but I'm missing a folder of the same name. This contains files for all those items inside the type libraries branch displayed via combrowse.py, they're only the wrappers but - for example: Certain functions inside the application allow to do stuff like this : Data("foo") = "bar" This is not legal in python. Obviously they use a "SetData('foo','bar')" wrap around that, but it's not documented, those wrapper sources give the game away, though :-) > but if you haven't > already, try using EnsureDispatch, Well, that doesn't seem to change anything for me, could you maybe get me up to speed on gencache.EnsureDispatch vs. Dispatch?! What's the difference? > Also, I seem to remember that Mark has moved around the location > in which makepy creates its proxy modules. I'm running the latest > stable pywin32 and the proxies appear to be being created under > my profile in "Local Settings\temp\gen_py\2.3". So, for me, that's I checked my system temp folder and my "local settings" folder without finding anything, also I didn't change any part of my python installation since first running makepy on it, so the location should still be the same. I just remember one day clicking on part of a traceback and landing right inside the wrapper around the COM objects function I botched up with. -- --- The Count From c.walou at laposte.net Wed Nov 10 10:42:22 2004 From: c.walou at laposte.net (walou) Date: Wed Nov 10 10:42:42 2004 Subject: [python-win32] NT service Message-ID: <1100079742.1743.228.camel@kls> Hello, I'm writting a NT service which modify registry to apply some retrictions on XP clients when they open a session on a samba server. Our first method was that the samba server connect to the XP box which is listening on port 8788 and send him a list of registry keys. Keys are putted in HKEY_USERS\S-user's-SID\Software\Mi...\CurrentVersion. The problem is that when a user logs on for the first time, his registry hive doesn't exist and the service returns an error that the keys couldn't be written into the registry. My idea is that in fact the XP box should connect to the samba server but how can I get the event "user XXX is opening a session" or/and the event "user XXX's registry hive is ready to be modified" ? Our service is running under user "SYSTEM" I've joined the code. Klaas T. -------------- next part -------------- A non-text attachment was scrubbed... Name: servscribe.py Type: text/x-python Size: 3900 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20041110/5358ec0e/servscribe.py From simon.dahlbacka at gmail.com Wed Nov 10 10:51:50 2004 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Wed Nov 10 10:51:54 2004 Subject: [python-win32] makepy creates gen_py/123-ID.py but no gen_py/ 123-ID - Folder In-Reply-To: References: Message-ID: <5712472041110015179fb5535@mail.gmail.com> AFAIK depending on the optional bForDemand parameter to EnsureDispatch either one big file is generated or a directory containing the needed stuff as they are needed. On Wed, 10 Nov 2004 10:41:13 +0100, The Count wrote: > On Wed, 10 Nov 2004 09:10:50 -0000, Tim Golden > wrote: > > > [The Count] > > > > [... snip losing makepy folders etc. ...] > > > > | What am I missing? I do (sort of) remember they weren't there > > | from the start but I have no clue as to how I created them, > > | they're source claims them to be created by makepy ... > > > > Don't know why makepy isn't generating them, > > To clarify : I DO get > - the $ID$.py / .pyc file > - an __init__.py / .pyc and > - a dicts.dat file > in .../win32com/gen_py/ but I'm missing a folder of the same name. > This contains files for all those items inside the type libraries branch > displayed via combrowse.py, > they're only the wrappers but - for example: > Certain functions inside the application allow to do stuff like this : > Data("foo") = "bar" > This is not legal in python. > Obviously they use a "SetData('foo','bar')" wrap around that, but it's not > documented, > those wrapper sources give the game away, though :-) > > > but if you haven't > > already, try using EnsureDispatch, > > Well, that doesn't seem to change anything for me, > could you maybe get me up to speed on gencache.EnsureDispatch vs. > Dispatch?! > What's the difference? > > > Also, I seem to remember that Mark has moved around the location > > in which makepy creates its proxy modules. I'm running the latest > > stable pywin32 and the proxies appear to be being created under > > my profile in "Local Settings\temp\gen_py\2.3". So, for me, that's > > I checked my system temp folder and my "local settings" folder without > finding anything, > also I didn't change any part of my python installation since first > running makepy on it, > so the location should still be the same. > > I just remember one day clicking on part of a traceback and landing right > inside the wrapper around the COM objects function I botched up with. > > -- > --- > The Count > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From tim.golden at viacom-outdoor.co.uk Wed Nov 10 10:56:40 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed Nov 10 11:03:04 2004 Subject: [python-win32] makepy creates gen_py/123-ID.py but no gen_py/ 123-ID - Folder Message-ID: [The Count] | TG> but if you haven't | TG> already, try using EnsureDispatch, | | Well, that doesn't seem to change anything for me, | could you maybe get me up to speed on gencache.EnsureDispatch vs. | Dispatch?! What's the difference? Not much, I'm afraid. I haven't browsed the code lately, but I expect that the one routine simply calls the other if needed (EnsureDispatch won't regenerate if it's not needed). I was hoping that maybe there *was* some difference which would result in your files being generated. Sorry. | I checked my system temp folder and my "local settings" | folder without | finding anything, | also I didn't change any part of my python installation since first | running makepy on it, | so the location should still be the same. Oh, well. Again, just hoping. 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 the.count at count0.dyndns.org Wed Nov 10 11:09:00 2004 From: the.count at count0.dyndns.org (The Count) Date: Wed Nov 10 11:07:37 2004 Subject: [python-win32] makepy creates gen_py/123-ID.py but no gen_py/ 123-ID - Folder In-Reply-To: <5712472041110015179fb5535@mail.gmail.com> References: <5712472041110015179fb5535@mail.gmail.com> Message-ID: On Wed, 10 Nov 2004 11:51:50 +0200, Simon Dahlbacka wrote: > AFAIK depending on the optional bForDemand parameter to EnsureDispatch > either one big file is generated or a directory containing the needed > stuff as they are needed. If I had my webcam on you could now see me - blushing - banging my head around a bit and generally - looking very relaxed THX - Checking the filesize shouldn't really be problem, now, should it? Indeed - all is there. Still it remains a puzzle to me how I got the folder that first time around since I just now heard of EnsureDispatch ... ... which - as Tim's page on wmi suggests can work even with non-makepy-ed libraries, which seems to be it's only real asset over "pure" Dispatch, right? -- --- The Count From tim.golden at viacom-outdoor.co.uk Wed Nov 10 11:48:28 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed Nov 10 11:54:14 2004 Subject: [python-win32] makepy creates gen_py/123-ID.py but no gen_py/ 123-ID - Folder Message-ID: [The Count] | Still it remains a puzzle to me how I got the folder that first time | around since I just now heard of EnsureDispatch ... | ... which - as Tim's page on wmi suggests can work even with | non-makepy-ed libraries, which seems to be it's only real asset | over "pure" Dispatch, right? OK, just to clear the confusion which my posts have probably created: + Too all intents and purposes, EnsureDispatch is the same as running makepy.py on the library. I've had a quick glance at the source, and they don't appear to be sharing (much) code, but I think they can be considered functionally equal. + The only reason for my suggesting it earlier was because I hoped that some obscure problem might -- magically -- be resolved by trying to do the same thing a different way. + I personally call win32com.client.gencache.EnsureDispatch normally when my code is trying to dispatch something, because then I get the advantages of the proxy module without having to think about makepy.py. This is especially useful when you're handing out code to tun on other peoples' machines. + As long as an object can be Dispatch'd you've got a chance of running EnsureDispatch on it, even if it doesn't have an entry in that list of libraries which makepy.py presents you with. I'm afraid my knowledge of COM-related stuff has now been exceeded, and I don't have the time to go through the source for makepy.py etc. at the moment, much as I'd like to. 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 python at kareta.de Wed Nov 10 12:01:33 2004 From: python at kareta.de (=?ISO-8859-1?B?SvxyZ2VuIEthcmV0YQ==?=) Date: Wed Nov 10 12:06:25 2004 Subject: [python-win32] keyboard macro Message-ID: <1100084493.4191f50d78d78@webmail.ldc.de> Hello all, hello Tim, thanks for the links. I've played a bit with sendkeys, WinGuiAuto and WATSUP, is's really nice. I have one question (WinNT,Python2.3.3,pywin 203): I want to get the apps in a Citrix Metaframe client window. If I understand the win32api.hlp, the apps are collected in a ListViewControl(!=ListboxControl): [code] hwnd=WinGuiAuto.findTopWindow(wantedText='Citrix Program Neighborhood) controls=WinGuiAuto.findControls(hwnd) for c in controls: print c,win32gui.GetClassName(c), win32gui.GetWindowText(c) results in: 66080 ComboBox 66084 Edit 131622 ToolbarWindow32 66088 Static 66068 msctls_statusbar32 0 Objekt(e) 66070 SysListView32 66074 SysHeader32 66076 ReBarWindow32 66078 ComboBoxEx32 win32gui.SetForegroundWindow(hwnd) put the right window in front. I've tried a lot, but get always empty result sets. Any hints ? regards, J?rgen From tim.golden at viacom-outdoor.co.uk Wed Nov 10 12:26:48 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed Nov 10 12:32:07 2004 Subject: [python-win32] NT service Message-ID: [walou] | how can I get the event "user XXX is opening a session" or/and the | event "user XXX's registry hive is ready to be modified" ? Quick answer. I googled for "enumerating logon sessions" and came across a useful-looking Code Project article by Stefan Kuhr which suggests -- among other interesting ideas -- using WMI. Have a look at his article, but basically since you're on XP, you can use the Win32_Session class and you can use WMI event querying to detect when a session has been created (or, presumably destroyed). Haven't tried it, I'm afraid, beyond checking that you can get the Win32_Session object on XP, but it has potential. 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 amonroe at columbus.rr.com Wed Nov 10 13:05:22 2004 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Wed Nov 10 13:05:38 2004 Subject: [python-win32] Translating vbs GetObject("LDAP://...") to Pyt hon? In-Reply-To: References: Message-ID: <25-1310272763.20041110070522@columbus.rr.com> > | If I do type() on the variable I assign it to, it says 'time', and it > | prints a sensible looking date like 10/25/04 11:18:59 to the screen. > | But I can't figure out how to compare that to, say, time.time(). How > | do I find out the number of elapsed days between the date it returns > | and the current date? > The pywin32 docs for PyTime state that calling int () on a > PyTime object will convert it to the result as if you'd used > time.time (). Perfect, thanks! Alan From c.walou at laposte.net Wed Nov 10 15:08:53 2004 From: c.walou at laposte.net (walou) Date: Wed Nov 10 15:08:55 2004 Subject: [python-win32] NT service In-Reply-To: References: Message-ID: <1100095733.1740.239.camel@kls> Thanks, it's the vocabulary that misses to me. I've walking through the article and came to the conclusion that I better have to use dll interaction with winlogon.exe and to send a signal to the NT service. I'm now looking for a way to write such a dll in python so if someone has any idea ... even just tell me if it's possible ... Klaas Le mer 10/11/2004 ? 12:26, Tim Golden a ?crit : > [walou] > | how can I get the event "user XXX is opening a session" or/and the > | event "user XXX's registry hive is ready to be modified" ? > > Quick answer. I googled for "enumerating logon sessions" and > came across a useful-looking Code Project article by Stefan > Kuhr which suggests -- among other interesting ideas -- using > WMI. Have a look at his article, but basically since you're on XP, > you can use the Win32_Session class and you can use WMI event > querying to detect when a session has been created (or, presumably > destroyed). > > Haven't tried it, I'm afraid, beyond checking that you can get > the Win32_Session object on XP, but it has potential. > > TJG From tim.golden at viacom-outdoor.co.uk Wed Nov 10 15:24:55 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed Nov 10 15:30:18 2004 Subject: [python-win32] NT service Message-ID: [walou] | Thanks, it's the vocabulary that misses to me. I've walking through | the article and came to the conclusion that I better have to use | dll interaction with winlogon.exe and to send a signal to the NT service. | I'm now looking for a way to write such a dll in python so if someone | has any idea ... even just tell me if it's possible ... Strictly, you can't write a DLL in Python. If you were up to it, you could write a DLL in C (or whatever), catch the winlogon notifications, and then -- somehow -- notify your service. My advice stops there, because it's *years* since I had to write a DLL, and I've pretty much forgotten how. The WMI route is a possibility, however. It's a bit tricky to test because it has to run in a service (always painful to debug) but something like the following might serve: import wmi c = wmi.WMI () watcher = c.watch_for ( notification_type="Creation", wmi_class = "Win32_LogonSession" ) while 1: logon_event = watcher () print logon_event I've tested this (without cutting-and-pasting) on someone else's XP box by doing a RunAs to simulate someone's logging in and it seems to work. What I can't immediately see is how you go about working out *who* has logged in. I imagine that you can use the Win32_LogonSession's LogonId to interrogate some list of logons. But I'm afraid I don't have time to check at the moment. 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 bwinton at latte.ca Wed Nov 10 16:25:11 2004 From: bwinton at latte.ca (Blake Winton) Date: Wed Nov 10 16:25:15 2004 Subject: [python-win32] NT service In-Reply-To: References: Message-ID: <419232D7.7040903@latte.ca> Tim Golden wrote: > | Thanks, it's the vocabulary that misses to me. I've walking through > | the article and came to the conclusion that I better have to use > | dll interaction with winlogon.exe and to send a signal to the NT service. > | I'm now looking for a way to write such a dll in python so if someone > | has any idea ... even just tell me if it's possible ... > Strictly, you can't write a DLL in Python. Perhaps that's strictly true, but you could use Pyrex to write in a very Python-like language that then gets translated to C (and distutils will happily create a .pyd file, which is identical to a .dll file, other than the last three letters of the filename). > If you were up to it, > you could write a DLL in C (or whatever), catch the winlogon > notifications, and then -- somehow -- notify your service. > My advice stops there, because it's *years* since I had to > write a DLL, and I've pretty much forgotten how. If you need any help going down this route, please feel free to email me, and I'll show you what I've got working so far, and how the various pieces fit together. I should say that I'm only about halfway to getting my stuff working, and it's going kind of slowly, but it is moving forward, and I haven't hit any insurmountable blocks yet. Later, Blake. From t-meyer at ihug.co.nz Thu Nov 11 01:12:36 2004 From: t-meyer at ihug.co.nz (Tony Meyer) Date: Thu Nov 11 01:13:12 2004 Subject: [python-win32] Failure to import zlib in Windows services Message-ID: I can't import zlib from a script running as a Windows service. If I do, this entry appears in the event log: """ Python could not import the service's module [...] File "C:\Python24\Lib\gzip.py", line 9, in ? import zlib exceptions.ImportError: dynamic module does not define init function (initzlib) """ This occurs with Python 2.2.3, 2.3.4 and 2.4b1. If I import zlib from a regular script or from the interactive prompt, it works fine. To demonstrate (unless it's just me...) if you add "import zlib" to the pipeTestService.py script it installs (and removes) fine, but if you do "net start PyPipeTestService" that above errors appears in the log. However (and this just confuses me more) if you do "pipeTestService.py debug", it starts up fine. Any clues? This is Windows XP SP2, if that matters. I haven't tried it elsewhere, but could try Win2k if it's likely to be relevant. Thanks! =Tony.Meyer From mhammond at skippinet.com.au Thu Nov 11 01:48:31 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Nov 11 01:48:40 2004 Subject: [python-win32] Failure to import zlib in Windows services In-Reply-To: Message-ID: <79e401c4c788$2c5c6970$0300a8c0@enfoldsystems.local> Hi Tony, > I can't import zlib from a script running as a Windows > service. If I do, > this entry appears in the event log: I suspect you have a zlib.dll in your system32 directory - this is often the CWD when run as a service. I really should fix the service implementation to handle this common error. A quick hack would be something like: if sys.path[0]=="": sys.path[0] = os.path.dirname(__file__) (or something like that :) Mark. From t-meyer at ihug.co.nz Thu Nov 11 02:15:23 2004 From: t-meyer at ihug.co.nz (Tony Meyer) Date: Thu Nov 11 02:16:06 2004 Subject: [python-win32] Failure to import zlib in Windows services In-Reply-To: Message-ID: [Tony] >> I can't import zlib from a script running as a Windows >> service. If I do, this entry appears in the event log: [Mark] > I suspect you have a zlib.dll in your system32 directory - > this is often the CWD when run as a service. I knew posting a message asking for help would be quicker than trying to figure it out myself (although I had begun to suspect something like that) :) Thanks! > I really should fix the service implementation to handle this > common error. Is it that common? I googled about trying to find a solution, and couldn't find much. But yes, fixing would be good :) Want me to open a bug tracker? > A quick hack would be something like: > > if sys.path[0]=="": > sys.path[0] = os.path.dirname(__file__) > > (or something like that :) My problem was actually that the system32 directory was before the PythonXX\DLLs directory (i.e. the CWD didn't come into it). So I ran through sys.path and bumped that to the end if it was there. Hackish, but should do for now, anyway. Thanks for the (quick!) help :) Cheers, Tony From mhammond at skippinet.com.au Thu Nov 11 03:21:56 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Nov 11 03:22:03 2004 Subject: [python-win32] Failure to import zlib in Windows services In-Reply-To: Message-ID: <7a6201c4c795$37bc7a50$0300a8c0@enfoldsystems.local> > > I really should fix the service implementation to handle this > > common error. > > Is it that common? I googled about trying to find a > solution, and couldn't find much. It has come up with 'wmi' a few times. > But yes, fixing would be good :) Want me to open > a bug tracker? Please > > > A quick hack would be something like: > > > > if sys.path[0]=="": > > sys.path[0] = os.path.dirname(__file__) > > > > (or something like that :) > > My problem was actually that the system32 directory was before the > PythonXX\DLLs directory (i.e. the CWD didn't come into it). So I ran > through sys.path and bumped that to the end if it was there. > Hackish, but > should do for now, anyway. I think Python established that sys.path entry from the cwd. I think that for a service (or for any Python program for that matter), we don't want system32 on sys.path - either at the start or the end :) Mark From t-meyer at ihug.co.nz Thu Nov 11 03:37:08 2004 From: t-meyer at ihug.co.nz (Tony Meyer) Date: Thu Nov 11 03:37:43 2004 Subject: [python-win32] Failure to import zlib in Windows services In-Reply-To: Message-ID: > > But yes, fixing would be good :) Want me to open > > a bug tracker? > > Please Done: [ 1064265 ] Having system32 in sys.path causes problems for services https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1064265&group_i d=78018 So that I didn't just create more work , I looked through the open bugs and noted a duplicate for you. Cheers, Tony From Mark.Lake at aigfpc.com Wed Nov 10 23:56:13 2004 From: Mark.Lake at aigfpc.com (Lake, Mark ) Date: Thu Nov 11 16:51:03 2004 Subject: [python-win32] Calling Python functions from Excel Message-ID: <75ABDD2D2D569A439D18FFB90DC1494501D1344B@USEVS1.aigfpc.com> A couple of questions: 1. Is there documentation on how to call Python functions from within an Excel spreadsheet? 2. Is there a tool to automate the bindings? Thanks, Mark Lake ________________________________ The information contained herein is being furnished for discussion purposes only and may be subject to completion or amendment through the delivery of additional documentation. This communication does not constitute an offer to sell or the solicitation of an offer to purchase any security, future or other financial instrument or product. The information contained herein (including historical prices or values) has been obtained from sources that we consider to be reliable; however, we make no representation as to, and accept no responsibility or liability for, the accuracy or completeness of the information contained herein. Such information is presented as of the date and, if applicable, time indicated. We do not accept any responsibility for updating any such information. Any projections, valuations and statistical analyses contained herein have been provided to assist the recipient in the evaluation of the matters described herein; such projections, valuations and analyses may be based on subjective assessments and assumptions and may utilize one among alternative methodologies that produce differing results; accordingly, such projections, valuations and statistical analyses are not to be viewed as facts and should not be relied upon as an accurate representation of future events. Any market views or opinions expressed herein are those of the individual sender, except where such views or opinions are expressly attributed to our company or a named individual. Market views and opinions are current opinions only; we and the individual sender accept no responsibility to update such views and opinions or to notify the recipient when they have changed. We and our affiliates, officers, directors and employees may from time to time have long or short positions in, buy or sell (on a principal basis or otherwise), or act as market maker in, the securities, futures or other financial instruments or products mentioned herein. Subject to applicable law and notwithstanding anything that may be construed to the contrary, the recipient hereof and its employees, representatives, and other agents may disclose the U.S. federal income tax treatment and structure of any transactions described herein. We are not an advisor as to legal, taxation, accounting, regulatory or financial matters in any jurisdiction, and are not providing any advice as to any such matter to the recipient. The recipient should discuss such matters with the recipient's advisors or counsel and make an independent evaluation and judgment with respect to them. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041110/923ff366/attachment.html From STEVEN.M.FAULCONER at saic.com Thu Nov 11 16:54:29 2004 From: STEVEN.M.FAULCONER at saic.com (Faulconer, Steven M.) Date: Thu Nov 11 16:54:20 2004 Subject: [python-win32] Printing with a separator sheet? Message-ID: <207DA77D2384D411A48B0008C7095D810152B91B@us-melbourne.mail.saic.com> Hello everyone, I'm having a problem getting a stand-alone Windows system to print to a USB printer with a separator sheet using Python+COM. The code is: ----code---- from win32com.client import Dispatch myWord = Dispatch( 'Word.Application' ) #myWord.Visible = 1 myDoc = myWord.Documents.Add( r"c:\docs\report.doc" ) myDoc.PrintOut() myDoc.Close() ----code---- Now, when I open that Word document (5 pages, text only) by hand and print. Everything works correctly. The separator page is first, followed by the 5 page document. Running the above code gets the separator page to print, but nothing else. If I uncomment Visible=1, I can see the instance of Word spool 5 pages. However, the printer only prints the separator sheet. Now, to ensure it wasn't my separator sheet, using one of the separator pages that comes with Windows (SYSPRINT.SEP) does exactly the same thing. Has anyone encountered something like this before? Any help would be greatly appreciated. Thanks. Steven From c.walou at laposte.net Fri Nov 12 14:34:13 2004 From: c.walou at laposte.net (walou) Date: Fri Nov 12 14:34:15 2004 Subject: [python-win32] (no subject) Message-ID: <1100266452.1743.2781.camel@kls> Hello, In order to automatically update our NT service, we need to transfert some files or a zipped file from the server to the clients. My idea is to create a function that launches an other program which would stop the service, update it and start it. Have somebody already done that sort of update ? What's the best way to transfert files ? Klaas T. From tim.golden at viacom-outdoor.co.uk Fri Nov 12 15:44:23 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Fri Nov 12 15:49:39 2004 Subject: [python-win32] (no subject) Message-ID: [walou] | Hello, | In order to automatically update our NT service, we need to transfert | some files or a zipped file from the server to the clients. | My idea is to create a function that launches an other program which | would stop the service, update it and start it. | Have somebody already done that sort of update ? What's the | best way to | transfert files ? I haven't done this myself, but it looks like a case for WMI. Maybe something like the following (completely untested): import wmi import win32file clients = ["W001", "W002", "W003"] for client in clients: c = wmi.WMI (client) for s in c.Win32_Service (Name='MyService'): s.StopService () # or PauseService etc. # Use whatever method to copy the file, eg win32file.CopyFile ("info.dat", r"\\%s\share\info.dat" % client) s.StartService () # or ResumeService etc. print client, "updated successfully" Obviously, this is the barebones framework; you need exception checking, possibly threads depending on how many clients you have etc. As to what file transfer is best, I'd use a straight Win32 copy unless you had some performance or security-related reason not to. Then you could look in to ssh-based methods (scp, sftp, whatever) but there tend to be fewer implementations of these in Win32. 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 c.walou at laposte.net Fri Nov 12 16:16:47 2004 From: c.walou at laposte.net (walou) Date: Fri Nov 12 16:16:49 2004 Subject: [python-win32] (no subject) In-Reply-To: References: Message-ID: <1100272606.1740.2804.camel@kls> Thanks for your quick answer, I've thought a little more about it and ftp, ssh, and other external methods can't be used. Our servers are installed by teachers, or other tech assistants and we don't have any control on the server's accounts. So we have to use a built-in method to transfert files. XML-RPC should be a good solution. About the problem about registry modification, we've used a brutal method. ;-) user open a session on XP, samba preexec sends the remote registry function to the NT service which loops 300 times (2/10 seconds interval). The samba server doesn't wait for the registry to be modified, continue its process, user gets his registry hive, loop's still runing and can now modify the registry. I hope that one day we'll write a dll that gets the "open session" event and does the process cleanly. Klaas T. Le ven 12/11/2004 ? 15:44, Tim Golden a ?crit : > [walou] > | Hello, > | In order to automatically update our NT service, we need to transfert > | some files or a zipped file from the server to the clients. > | My idea is to create a function that launches an other program which > | would stop the service, update it and start it. > | Have somebody already done that sort of update ? What's the > | best way to > | transfert files ? > > I haven't done this myself, but it looks like a case for WMI. > Maybe something like the following (completely untested): > > > > import wmi > import win32file > > clients = ["W001", "W002", "W003"] > > for client in clients: > c = wmi.WMI (client) > for s in c.Win32_Service (Name='MyService'): > s.StopService () # or PauseService etc. > # Use whatever method to copy the file, eg > win32file.CopyFile ("info.dat", r"\\%s\share\info.dat" % client) > s.StartService () # or ResumeService etc. > > print client, "updated successfully" > > > > Obviously, this is the barebones framework; you need exception > checking, possibly threads depending on how many clients you > have etc. > > As to what file transfer is best, I'd use a straight Win32 copy > unless you had some performance or security-related reason not > to. Then you could look in to ssh-based methods (scp, sftp, whatever) > but there tend to be fewer implementations of these in Win32. > > 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 > ________________________________________________________________________ > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From c.walou at laposte.net Fri Nov 12 16:48:34 2004 From: c.walou at laposte.net (walou) Date: Fri Nov 12 16:48:44 2004 Subject: [python-win32] (no subject) In-Reply-To: <1100272606.1740.2804.camel@kls> References: <1100272606.1740.2804.camel@kls> Message-ID: <1100274514.1749.2828.camel@kls> I forgot to precise that the samba server doesn't wait for the registry to be modified because it's launched with an "at now". Le ven 12/11/2004 ? 16:16, walou a ?crit : > Thanks for your quick answer, I've thought a little more about it and > ftp, ssh, and other external methods can't be used. Our servers are > installed by teachers, or other tech assistants and we don't have any > control on the server's accounts. So we have to use a built-in method to > transfert files. XML-RPC should be a good solution. > > About the problem about registry modification, we've used a brutal > method. ;-) > > user open a session on XP, samba preexec sends the remote registry > function to the NT service which loops 300 times (2/10 seconds > interval). The samba server doesn't wait for the registry to be > modified, continue its process, user gets his registry hive, loop's > still runing and can now modify the registry. > > I hope that one day we'll write a dll that gets the "open session" event > and does the process cleanly. > > Klaas T. > > Le ven 12/11/2004 ? 15:44, Tim Golden a ?crit : > > [walou] > > | Hello, > > | In order to automatically update our NT service, we need to transfert > > | some files or a zipped file from the server to the clients. > > | My idea is to create a function that launches an other program which > > | would stop the service, update it and start it. > > | Have somebody already done that sort of update ? What's the > > | best way to > > | transfert files ? > > > > I haven't done this myself, but it looks like a case for WMI. > > Maybe something like the following (completely untested): > > > > > > > > import wmi > > import win32file > > > > clients = ["W001", "W002", "W003"] > > > > for client in clients: > > c = wmi.WMI (client) > > for s in c.Win32_Service (Name='MyService'): > > s.StopService () # or PauseService etc. > > # Use whatever method to copy the file, eg > > win32file.CopyFile ("info.dat", r"\\%s\share\info.dat" % client) > > s.StartService () # or ResumeService etc. > > > > print client, "updated successfully" > > > > > > > > Obviously, this is the barebones framework; you need exception > > checking, possibly threads depending on how many clients you > > have etc. > > > > As to what file transfer is best, I'd use a straight Win32 copy > > unless you had some performance or security-related reason not > > to. Then you could look in to ssh-based methods (scp, sftp, whatever) > > but there tend to be fewer implementations of these in Win32. > > > > 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 > > ________________________________________________________________________ > > _______________________________________________ > > Python-win32 mailing list > > Python-win32@python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From jhawk at innovativerobotics.com Fri Nov 12 01:20:19 2004 From: jhawk at innovativerobotics.com (Joseph D. Hawk) Date: Fri Nov 12 16:51:21 2004 Subject: [python-win32] memory limits Message-ID: <419401C3.6070505@innovativerobotics.com> Hello all, Python newbie here. I have a question on setting memory consumption limits. Is it possible in a windows environment? I am sorry if this is a repost. Thanks in avance, From tea2 at cornell.edu Fri Nov 12 20:40:06 2004 From: tea2 at cornell.edu (Terry Acree) Date: Fri Nov 12 21:21:57 2004 Subject: [python-win32] Installing Blt on XP Message-ID: Hello I can't get Blt to run under Py2.3 w/ Pmw1.2 on Xp. I have tried copying the dll's to SYSTEM and the Blt2.4 folder to tcl and tcl\tcl8.4. Still nothing. Anybody have an idea where to put the stuff? Terry From rwupole at msn.com Sat Nov 13 17:06:45 2004 From: rwupole at msn.com (Roger Upole) Date: Sat Nov 13 17:06:49 2004 Subject: [python-win32] memory limits References: <419401C3.6070505@innovativerobotics.com> Message-ID: You can use win32process.SetProcessWorkingSetSize. Roger ----- Original Message ----- From: "Joseph D. Hawk" To: Sent: Thursday, November 11, 2004 7:20 PM Subject: [python-win32] memory limits > Hello all, > > Python newbie here. I have a question on setting memory consumption > limits. Is it possible in a windows environment? I am sorry if this is > a repost. > > Thanks in avance, > > > > From tea2 at cornell.edu Tue Nov 16 02:21:55 2004 From: tea2 at cornell.edu (Terry Acree) Date: Tue Nov 16 02:22:04 2004 Subject: [python-win32] Installing Blt2.4 on XP Message-ID: I will try this again now that I am a member. Does anyone know how to install Blt 2.4 on XP. I have Pmw 1.2 in Py23 running nicely. Installing Blt 2.4z (tcl8.4) fails. Putting copies of the two dlls in windows/system and putting copies of the \blt2.4 on the path still yields :...no module named Blt..." Help Terry Acree From tony at tcapp.com Tue Nov 16 20:11:19 2004 From: tony at tcapp.com (Tony Cappellini) Date: Tue Nov 16 20:01:30 2004 Subject: [python-win32] Re: Python-win32 Digest, Vol 20, Issue 15 In-Reply-To: <20041116110104.C15A91E4015@bag.python.org> References: <20041116110104.C15A91E4015@bag.python.org> Message-ID: <20041116111031.M70493@yamato.yamato.com> > Message: 1 > Date: Mon, 15 Nov 2004 20:21:55 -0500 > From: Terry Acree > Subject: [python-win32] Installing Blt2.4 on XP > To: python-win32@python.org > Message-ID: > Content-Type: text/plain; charset=US-ASCII; format=flowed > > I will try this again now that I am a member. > > Does anyone know how to install Blt 2.4 on XP. > I have Pmw 1.2 in Py23 running nicely. > Installing Blt 2.4z (tcl8.4) fails. > Putting copies of the two dlls in windows/system and > putting copies of the \blt2.4 on the path still yields > :...no module named Blt..." > > Help > > Terry Acree > > This url may be of some help http://bebop.bigasterisk.com/scribblings/blt From naveed48 at wol.net.pk Tue Nov 16 23:08:06 2004 From: naveed48 at wol.net.pk (Naveed Ahmed Khan) Date: Tue Nov 16 23:08:19 2004 Subject: [python-win32] dictionary command Message-ID: <200411162205.iAGM5O5w027441@svmout.wol.net.pk> Dear friends, I am using python on windows and trying the dictionary command but its not working. dict = {} This command line works alright but when I try the below: >>> dict['boolean'] = "A value which is either true or false" I get the following error message: "Object does not support the item assignment" Kindly help me out why is that so. Please note that I am new in programming Regards, NAK -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041117/40f9398a/attachment.htm From tony at tcapp.com Tue Nov 16 23:50:21 2004 From: tony at tcapp.com (Tony Cappellini) Date: Tue Nov 16 23:40:22 2004 Subject: [python-win32] Finding screen size in a DOS window on Xp In-Reply-To: <20041116110104.C15A91E4015@bag.python.org> References: <20041116110104.C15A91E4015@bag.python.org> Message-ID: <20041116144807.P73878@yamato.yamato.com> Would someone point me to a way to find the number of lines per screen, when a NON-GUI python program is runnining in a DOS box on XP, that is NOT maximized ? From jens.jorgensen at tallan.com Wed Nov 17 00:25:59 2004 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Wed Nov 17 00:26:11 2004 Subject: [python-win32] Finding screen size in a DOS window on Xp In-Reply-To: <20041116144807.P73878@yamato.yamato.com> References: <20041116110104.C15A91E4015@bag.python.org> <20041116144807.P73878@yamato.yamato.com> Message-ID: <419A8C87.8030207@tallan.com> Tony Cappellini wrote: >Would someone point me to a way to find the number of lines per screen, >when a NON-GUI python program is runnining in a DOS box on XP, that is NOT >maximized ? > > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > I'm not sure there's a non-Python way to find out. Well, there must be. GetConsoleScreenBufferInfo will tell you about the screen buffer but that includes the "history" and all that. In the reference for the various win32 console functions I don't see anything that will tell you this. I did manage to call GetConsoleScreenBufferInfo using the ctypes module though. Ctypes is _impressive_. -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 2861 bytes Desc: S/MIME Cryptographic Signature Url : http://mail.python.org/pipermail/python-win32/attachments/20041116/9187d3b7/smime.bin From naveed48 at wol.net.pk Wed Nov 17 07:07:26 2004 From: naveed48 at wol.net.pk (Naveed Ahmed Khan) Date: Wed Nov 17 07:08:04 2004 Subject: [python-win32] Dictionary command Message-ID: <200411170604.iAH64i5w009916@svmout.wol.net.pk> Dear friends, Thanks a lot for your help my problem is solved. Though I am afraid to tell you of my real blunder. I mean you must understand that it's my first time with programming. I was trying to achieve the following: >>> dict = {} >>> dict['boolean'] = "A value which is either true or false" >>> dict['integer'] = "A whole number" >>> print dict['boolean'] A value which is either true or false What I was doing was that I was writing dict = () instead of dict = {}, got it, I was using the wrong bracket. It's really embarrassing, but true. For the next time I will try to figure out how to copy the "Python command line screen" so that you can see exactly what I have done there. Thanks a lot again. Regards, NAK -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041117/47ca146b/attachment.htm From lbates at syscononline.com Wed Nov 17 15:55:15 2004 From: lbates at syscononline.com (Larry Bates) Date: Wed Nov 17 15:55:23 2004 Subject: [python-win32] Dictionary command In-Reply-To: <20041117110044.9D33E1E4014@bag.python.org> Message-ID: <005201c4ccb5$7336e1e0$5d00a8c0@LABWXP> Nak, Another suggestion that will help you in the future. It is a REALLY bad idea to use built-in functions like dict, list, str, etc. as variable names. Once you have made an assignment like: dict={} You do have an empty dictionary called 'dict' but you have rebound the built-in dict function so it can no longer be used in your program (I'll let you refer to documentation on dict function). A mistake we see a lot is the following: str="abcdefg" then later in the program you want to coerce something to a string so you write a=1.0 x=str(a) You get traceback because str function has been kidnapped (e.g. it is now a string variable that contains "abcdefg". Good luck on learning programming/Python. Regards, Larry Bates Syscon, Inc. Message: 5 Date: Wed, 17 Nov 2004 11:07:26 +0500 From: "Naveed Ahmed Khan" Subject: [python-win32] Dictionary command To: "PYTHON TUTOR" , "Python For Windows" Cc: Paul Weimer , Kerry Oliphant , Alex Willmer , Mark Brown Message-ID: <200411170604.iAH64i5w009916@svmout.wol.net.pk> Content-Type: text/plain; charset="us-ascii" Dear friends, Thanks a lot for your help my problem is solved. Though I am afraid to tell you of my real blunder. I mean you must understand that it's my first time with programming. I was trying to achieve the following: >>> dict = {} >>> dict['boolean'] = "A value which is either true or false" >>> dict['integer'] = "A whole number" >>> print dict['boolean'] A value which is either true or false What I was doing was that I was writing dict = () instead of dict = {}, got it, I was using the wrong bracket. It's really embarrassing, but true. For the next time I will try to figure out how to copy the "Python command line screen" so that you can see exactly what I have done there. Thanks a lot again. Regards, NAK From tim.golden at viacom-outdoor.co.uk Wed Nov 17 16:02:58 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed Nov 17 16:08:22 2004 Subject: [python-win32] Finding screen size in a DOS window on Xp Message-ID: [Tony Cappellini] | Would someone point me to a way to find the number of lines | per screen, | when a NON-GUI python program is runnining in a DOS box on | XP, that is NOT | maximized ? Have a look at Chris Gonnerman's WConIO: http://newcenturycomputers.net/projects/wconio.html And I seem to remember seeing a ctypes-based equivalent somewhere, but I can't remember where. 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 fission6 at hotmail.com Wed Nov 17 16:12:07 2004 From: fission6 at hotmail.com (Kenley _) Date: Wed Nov 17 16:13:07 2004 Subject: [python-win32] NEWBIE QUESTION - 'NoneType' object has no attribute 'ActiveSheet' Message-ID: I'm learning Python and experimenting with the demo COM addin for Excel (excelAddin.py) that is included with win32com extension. I used makepy.py on the Excel Object Library and saved the file as Excel.py. The only test modification I made to the demo code was to the ButtonEvent class. Here is the ButtonEvent class I'm testing: class ButtonEvent: def OnClick(self, button, cancel): import win32ui # Possible, but not necessary, to use a Pythonwin GUI import win32con import Excel as xlApp xlApp = Dispatch("Excel.Application") xlApp.Visible = 1 xlApp.ActiveWorkbook.ActiveSheet.Cells(1).Rows.EntireRow.Delete(1) xlApp.ActiveWorkbook.ActiveSheet.Cells(2).Rows.EntireRow.Delete(1) xlApp.ActiveWorkbook.ActiveSheet.Cells(3).Rows.EntireRow.Delete(1) xlApp.ActiveWorkbook.SaveAs("C:\\test.csv") xlApp.ActiveWorkbook.Close(SaveChanges=0) xlApp.Quit() del xlApp All this is supposed to do is delete a few lines in whatever Excel document is currently open and save it as "test.csv". THE PROBLEM: What is puzzling is that everything works great ONLY IF the button is clicked twice. If the button is clicked only once, excel just flashes. After clicking the button a second time everything works great. I used the trace collector and this is what is shows the first time the button is clicked: Object with win32trace dispatcher created (object=None) OnConnection Microsoft Excel 1 A Simple Excel Addin (1,) OnAddInsUpdate None OnStartupComplete None Object with win32trace dispatcher created (object=None) OnConnection Microsoft Excel 1 A Simple Excel Addin (3,) OnAddInsUpdate None OnStartupComplete None pythoncom error: Python error invoking COM method. Traceback (most recent call last): File "D:\Python23\Lib\site-packages\win32com\server\policy.py", line 283, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "D:\Python23\Lib\site-packages\win32com\server\policy.py", line 288, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None) File "D:\Python23\Lib\site-packages\win32com\server\policy.py", line 581, in _invokeex_ return func(*args) File "D:\Python23\Lib\site-packages\Pythonwin\excelAddin_test.py", line 71, in OnClick xlApp.ActiveWorkbook.ActiveSheet.Cells(1).Rows.EntireRow.Delete(1) exceptions.AttributeError: 'NoneType' object has no attribute 'ActiveSheet' OnBeginShutdown None OnDisconnection ================================================ Is there something I'm missing in the class? What do I need to do to make the button do it's work on first click? Thanks in advance for any help, Ken (Enjoying Learning Python on Win32) From timr at probo.com Wed Nov 17 20:21:07 2004 From: timr at probo.com (Tim Roberts) Date: Wed Nov 17 20:21:12 2004 Subject: [python-win32] Dictionary command In-Reply-To: <20041117110044.9D33E1E4014@bag.python.org> References: <20041117110044.9D33E1E4014@bag.python.org> Message-ID: <419BA4A3.9090103@probo.com> On Wed, 17 Nov 2004 11:07:26 +0500, "Naveed Ahmed Khan" wrote: > Dear friends, Thanks a lot for your help my problem is solved. Though > I am afraid to tell you of my real blunder. I mean you must understand > that it's my first time with programming. I was trying to achieve the > following: > >>>>>>> dict = {} >>>>>>> dict['boolean'] = "A value which is either true or false" >>>>>>> dict['integer'] = "A whole number" >>>>>>> print dict['boolean'] >>>> >>>> >A value which is either true or false > >What I was doing was that I was writing dict = () instead of dict = {}, got >it, I was using the wrong bracket. > > There is another problem with this. "dict" is the name of a built-in type, along with "int", "str", "list", "tuple", and probably a couple more. It can be used, for example, to convert a list of pairs to a dictionary: xyz = dict( ( ('boolean', True), ('integer', 3 ) ) ) By naming your variable "dict", you have hidden the built-in meaning of that word. You should choose another name. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From wyvernlist at crm3.com Wed Nov 17 20:25:19 2004 From: wyvernlist at crm3.com (Jan Van Uytven (Wyvern)) Date: Wed Nov 17 20:26:22 2004 Subject: [python-win32] Monitoring the Event Log Message-ID: <1100719519.7026.20.camel@localhost> Hi, I have a RAID array on a server whose driver posts an event to the System Event Log when there's a change in the status of the array. I could just buy an event log monitor that will send me e-mail when that happens but I was wondering: Could I write a Python service to monitor the event log? I have Mark Hammond's excellent book, and with it's help the service & e-mailing itself shouldn't be a problem, but I'd appreciate advice on the best way to monitor the log. Is there any way for the service to register itself somehow so it gets notified whenever an event gets posted to the log? Failing that, can the service use the windows scheduler to search the log every hour on the hour? Or is there a much easier way I'm not seeing? Thanks, Jan --- Jan Van Uytven Computer Systems & Network Engineer Convergent Media Network wyvern@crm3.com Randomly selected from my quote-file: "Without warning came those deep, cracked, raucous vocal sounds which will never leave the memory of the stricken group who heard them. Not from any human throat were they born, for the organs of Man can yield no such acoustic perversions..." -"The Call of Cthulhu" >>> LEGAL STUFF <<< This electronic message transmission, including any attached files, contains information which may be confidential and/or privileged. The information is intended to be for the SOLE use of the individual or entity named above. If you are not the intended recipient, be aware that any review, disclosure, copying, distribution or use of the contents of this information is prohibited. This message is not to be forwarded for any reason without prior consent of the sender. If you have received this electronic transmission in error, please notify the sender immediately by telephone (250) 386-4266 or by a 'reply to sender only' message and destroy all electronic and hard copies of the communication, including attachments, without reading or saving in any manner. From paandev at yahoo.com Wed Nov 17 20:44:15 2004 From: paandev at yahoo.com (Wara Songkran) Date: Wed Nov 17 20:44:18 2004 Subject: [python-win32] Can't make parser Message-ID: <20041117194415.12842.qmail@web51310.mail.yahoo.com> Hi I'm using Python-2.3.4-arm-PPC2003. When I try to use sax the shell said >>> from xml import sax >>> parser = sax.make_parser() Traceback (most recent call last): File "binaries\lib\xml\sax\__init__.py", line 93, in make_parser SAXReaderNotAvaiable: No parsers found I guess beacause it need expat parser library which is a native dll to run. Please help. Regard Wara Songkran --------------------------------- Do you Yahoo!? Meet the all-new My Yahoo! – Try it today! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041117/080ed783/attachment.html From paandev at yahoo.com Wed Nov 17 21:00:23 2004 From: paandev at yahoo.com (Wara Songkran) Date: Wed Nov 17 21:00:32 2004 Subject: [python-win32] Can't make parser In-Reply-To: <20041117194415.12842.qmail@web51310.mail.yahoo.com> Message-ID: <20041117200024.12369.qmail@web51305.mail.yahoo.com> Hi I've just try PyXML from http://debris.demon.nl/PythonCE-2.3 and it's work. Any Idea why this happen. I also use PyXML on my Desktop PC but with standard xml package which come with python is also work. Why standard xml package on PythonCE does not work? Regrad Wara Songkran Wara Songkran wrote: Hi I'm using Python-2.3.4-arm-PPC2003. When I try to use sax the shell said >>> from xml import sax >>> parser = sax.make_parser() Traceback (most recent call last): File "binaries\lib\xml\sax\__init__.py", line 93, in make_parser SAXReaderNotAvaiable: No parsers found I guess beacause it need expat parser library which is a native dll to run. Please help. --------------------------------- Do you Yahoo!? The all-new My Yahoo! – Get yours free! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041117/56739225/attachment.htm From paandev at yahoo.com Wed Nov 17 21:00:30 2004 From: paandev at yahoo.com (Wara Songkran) Date: Wed Nov 17 21:00:34 2004 Subject: [python-win32] Can't make parser In-Reply-To: <20041117194415.12842.qmail@web51310.mail.yahoo.com> Message-ID: <20041117200030.67364.qmail@web51303.mail.yahoo.com> Hi I've just try PyXML from http://debris.demon.nl/PythonCE-2.3 and it's work. Any Idea why this happen. I also use PyXML on my Desktop PC but with standard xml package which come with python is also work. Why standard xml package on PythonCE does not work? Regrad Wara Songkran Wara Songkran wrote: Hi I'm using Python-2.3.4-arm-PPC2003. When I try to use sax the shell said >>> from xml import sax >>> parser = sax.make_parser() Traceback (most recent call last): File "binaries\lib\xml\sax\__init__.py", line 93, in make_parser SAXReaderNotAvaiable: No parsers found I guess beacause it need expat parser library which is a native dll to run. Please help. --------------------------------- Do you Yahoo!? Meet the all-new My Yahoo! – Try it today! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041117/29115d97/attachment-0001.html From wyvernlist at crm3.com Wed Nov 17 21:49:55 2004 From: wyvernlist at crm3.com (Jan Van Uytven (Wyvern)) Date: Wed Nov 17 21:49:59 2004 Subject: [python-win32] Monitoring the Event Log In-Reply-To: <1100719519.7026.20.camel@localhost> References: <1100719519.7026.20.camel@localhost> Message-ID: <1100724595.7839.6.camel@localhost> I found out I can capture the events as they're being generated using wmi: c = wmi.WMI() event_watcher=c.watch_for (notification_type="Creation",wmi_class="Win32_NTLogEvent",delay_secs=1) evt=event_watcher() I can see a problem with this approach - Windows generates events frequently, and I wouldn't want to miss a relevant event while the service is busy sending an e-mail. I think threading might be useful here - do the e-mailing in a separate thread while continuing to examine events. Jan On Wed, 2004-11-17 at 11:25 -0800, Jan Van Uytven (Wyvern) wrote: > Hi, > > I have a RAID array on a server whose driver posts an event to the > System Event Log when there's a change in the status of the array. I > could just buy an event log monitor that will send me e-mail when that > happens but I was wondering: Could I write a Python service to monitor > the event log? > > I have Mark Hammond's excellent book, and with it's help the service & > e-mailing itself shouldn't be a problem, but I'd appreciate advice on > the best way to monitor the log. Is there any way for the service to > register itself somehow so it gets notified whenever an event gets > posted to the log? Failing that, can the service use the windows > scheduler to search the log every hour on the hour? Or is there a much > easier way I'm not seeing? > > Thanks, > > Jan > --- > Jan Van Uytven > Computer Systems & Network Engineer > Convergent Media Network > wyvern@crm3.com > > Randomly selected from my quote-file: > > "Without warning came those deep, cracked, > raucous vocal sounds which will never leave the > memory of the stricken group who heard them. > Not from any human throat were they born, for > the organs of Man can yield no such acoustic > perversions..." > -"The Call of Cthulhu" > > > >>> LEGAL STUFF <<< > This electronic message transmission, including any attached files, > contains information which may be confidential and/or privileged. > The information is intended to be for the SOLE use of the individual or > entity named above. If you are not the intended recipient, be aware > that any review, disclosure, copying, distribution or use of the > contents of this information is prohibited. This message is not to be > forwarded for any reason without prior consent of the sender. > > If you have received this electronic transmission in error, please > notify the sender immediately by telephone (250) 386-4266 or by a > 'reply to sender only' message and destroy all electronic and hard > copies of the communication, including attachments, without reading > or saving in any manner. > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 --- Jan Van Uytven Computer Systems & Network Engineer Convergent Media Network wyvern@crm3.com Randomly selected from my quote-file: "There was a moment last night, when she was sandwiched between the two finnish dwarves and the maori tribesman, when I thought 'I could spend the rest of my life with this woman'" --- Zoolander >>> LEGAL STUFF <<< This electronic message transmission, including any attached files, contains information which may be confidential and/or privileged. The information is intended to be for the SOLE use of the individual or entity named above. If you are not the intended recipient, be aware that any review, disclosure, copying, distribution or use of the contents of this information is prohibited. This message is not to be forwarded for any reason without prior consent of the sender. If you have received this electronic transmission in error, please notify the sender immediately by telephone (250) 386-4266 or by a 'reply to sender only' message and destroy all electronic and hard copies of the communication, including attachments, without reading or saving in any manner. From jens.jorgensen at tallan.com Wed Nov 17 22:15:37 2004 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Wed Nov 17 22:15:46 2004 Subject: [python-win32] Monitoring the Event Log In-Reply-To: <1100719519.7026.20.camel@localhost> References: <1100719519.7026.20.camel@localhost> Message-ID: <419BBF79.20205@tallan.com> Monitoring the log is easy. You just open the log and then read it in a loop. This little transcript of an interactive session should give you an idea: >>> import win32evtlog >>> h = win32evtlog.OpenEventLog(None, 'Application') >>> win32evtlog.GetOldestEventLogRecord(h) 3702 >>> event = win32evtlog.ReadEventLog(h, win32evtlog.EVENTLOG_SEEK_READ|win32evtl og.EVENTLOG_FORWARDS_READ, 3702) >>> event [, , ] >>> event[2].EventID -1073741800 >>> event[2].EventType 1 >>> event[2].SourceName u'WinMgmt' >>> event[2].StringInserts (u'SELECT * FROM __InstanceDeletionEvent where TargetInstance ISA "BRCM_NetworkV irtualAdapter"', u'BRCM_NetworkVirtualAdapter') >>> event = win32evtlog.ReadEventLog(h, win32evtlog.EVENTLOG_SEQUENTIAL_READ|win 32evtlog.EVENTLOG_FORWARDS_READ, 0) >>> len(event) 4 So, that's the basic layout. You open up the event log (first param points to the computer you want to read from, None if you just want to read the local log), figure out what the first entry is, and then start reading. Alternatively you may wish to skip over entries that are in the past and not notify on them. When you reach the end of the log the ReadEvent will just hang until a new event arrives. Jan Van Uytven (Wyvern) wrote: >Hi, > >I have a RAID array on a server whose driver posts an event to the >System Event Log when there's a change in the status of the array. I >could just buy an event log monitor that will send me e-mail when that >happens but I was wondering: Could I write a Python service to monitor >the event log? > >I have Mark Hammond's excellent book, and with it's help the service & >e-mailing itself shouldn't be a problem, but I'd appreciate advice on >the best way to monitor the log. Is there any way for the service to >register itself somehow so it gets notified whenever an event gets >posted to the log? Failing that, can the service use the windows >scheduler to search the log every hour on the hour? Or is there a much >easier way I'm not seeing? > >Thanks, > >Jan >--- >Jan Van Uytven >Computer Systems & Network Engineer >Convergent Media Network >wyvern@crm3.com > >Randomly selected from my quote-file: > >"Without warning came those deep, cracked, > raucous vocal sounds which will never leave the > memory of the stricken group who heard them. > Not from any human throat were they born, for > the organs of Man can yield no such acoustic > perversions..." > -"The Call of Cthulhu" > > > > >>>>LEGAL STUFF <<< >>>> >>>> >This electronic message transmission, including any attached files, >contains information which may be confidential and/or privileged. >The information is intended to be for the SOLE use of the individual or >entity named above. If you are not the intended recipient, be aware >that any review, disclosure, copying, distribution or use of the >contents of this information is prohibited. This message is not to be >forwarded for any reason without prior consent of the sender. > >If you have received this electronic transmission in error, please >notify the sender immediately by telephone (250) 386-4266 or by a >'reply to sender only' message and destroy all electronic and hard >copies of the communication, including attachments, without reading >or saving in any manner. > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From davidrushby at yahoo.com Wed Nov 17 22:49:46 2004 From: davidrushby at yahoo.com (David Rushby) Date: Wed Nov 17 22:49:50 2004 Subject: [python-win32] Monitoring the Event Log In-Reply-To: <1100724595.7839.6.camel@localhost> Message-ID: <20041117214946.9927.qmail@web11008.mail.yahoo.com> --- "Jan Van Uytven (Wyvern)" wrote: > I found out I can capture the events as they're being > generated using wmi... > ... > I can see a problem with this approach - Windows generates > events frequently, and I wouldn't want to miss a relevant > event while the service is busy sending an e-mail. I think > threading might be useful here - do the e-mailing in a > separate thread while continuing to examine events. The easiest, least error-prone way to do this is to use Python's Queue module (http://docs.python.org/lib/module-Queue.html ), which was designed for situations like this one. Have one thread listen via WMI for Event Log entries and insert the resulting entries with Queue.put, while another thread retrieves the entries with Queue.get and e-mails them. This pattern is known as producer/consumer. __________________________________ Do you Yahoo!? The all-new My Yahoo! - Get yours free! http://my.yahoo.com From timr at probo.com Wed Nov 17 23:27:28 2004 From: timr at probo.com (Tim Roberts) Date: Wed Nov 17 23:27:36 2004 Subject: [python-win32] NEWBIE QUESTION - 'NoneType' object has no attribute 'ActiveSheet' In-Reply-To: <20041117200036.225971E4017@bag.python.org> References: <20041117200036.225971E4017@bag.python.org> Message-ID: <419BD050.7070907@probo.com> On Wed, 17 Nov 2004 09:12:07 -0600, "Kenley _" wrote: >I'm learning Python and experimenting with the demo COM addin for Excel >(excelAddin.py) that is included with win32com extension. > >I used makepy.py on the Excel Object Library and saved the file as Excel.py. > >The only test modification I made to the demo code was to the ButtonEvent >class. Here is the ButtonEvent class I'm testing: > >class ButtonEvent: > def OnClick(self, button, cancel): > import win32ui # Possible, but not necessary, to use a Pythonwin GUI > import win32con > import Excel as xlApp > > xlApp = Dispatch("Excel.Application") > xlApp.Visible = 1 > xlApp.ActiveWorkbook.ActiveSheet.Cells(1).Rows.EntireRow.Delete(1) > xlApp.ActiveWorkbook.ActiveSheet.Cells(2).Rows.EntireRow.Delete(1) > xlApp.ActiveWorkbook.ActiveSheet.Cells(3).Rows.EntireRow.Delete(1) > xlApp.ActiveWorkbook.SaveAs("C:\\test.csv") > > xlApp.ActiveWorkbook.Close(SaveChanges=0) > xlApp.Quit() > del xlApp > > Several problems with this. First, with few exceptions, "import" statements should always be at the top of your file. "import" is an executable statement, so with your code, the modules will get reimported every time you click the button. However, you aren't using anything in ANY of those three modules, so just delete the imports. Next, you import the Excel module as xlApp, and then promptly overwrite it with the results of Dispatch, which deletes the module you just imported. Consider that your code is basically identical to: import Excel xlApp = Excel del Excel xlApp = Dispatch("Excel.Application") Generally, you shouldn't have to manipulate the results of makepy.py. It stores its result in a cache within the Python site-packages area. win32com.client.Dispatch will look in that cache for a match when you create an object, and return the appropriate class. So, just delete the "import Excel as xlApp" altogether. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From amonroe at columbus.rr.com Thu Nov 18 00:32:39 2004 From: amonroe at columbus.rr.com (R. Alan Monroe) Date: Thu Nov 18 00:32:57 2004 Subject: [python-win32] Monitoring the Event Log In-Reply-To: <1100719519.7026.20.camel@localhost> References: <1100719519.7026.20.camel@localhost> Message-ID: <28276718349.20041117183239@columbus.rr.com> > I have a RAID array on a server whose driver posts an event to the > System Event Log when there's a change in the status of the array. I > could just buy an event log monitor that will send me e-mail when that > happens but I was wondering: Could I write a Python service to monitor > the event log? Probably, but why not set up a perfmon alert to do it for you? Perfmon alerts can execute arbitrary programs when they detect the event, including python. Alan From fission6 at hotmail.com Thu Nov 18 04:19:47 2004 From: fission6 at hotmail.com (Kenley _) Date: Thu Nov 18 04:20:05 2004 Subject: [python-win32] NEWBIE QUESTION - 'NoneType' object has no attribute 'ActiveSheet' Message-ID: Thanks for the lucid response Tim. I nixed the import statements; however, Excel still only flashes on first click of the button. The debug trace collector shows this on first click: >> OnStartupComplete None pythoncom error: Python error invoking COM method. Traceback (most recent call last): File "D:\Python23\Lib\site-packages\win32com\server\policy.py", line 283, in _Invoke_ return self._invoke_(dispid, lcid, wFlags, args) File "D:\Python23\Lib\site-packages\win32com\server\policy.py", line 288, in _invoke_ return S_OK, -1, self._invokeex_(dispid, lcid, wFlags, args, None, None) File "D:\Python23\Lib\site-packages\win32com\server\policy.py", line 581, in _invokeex_ return func(*args) File "D:\Python23\Lib\site-packages\Pythonwin\CheckSymAnalyzer\excelAddin_test.py", line 71, in OnClick xlApp.ActiveWorkbook.ActiveSheet.Cells(1).Rows.EntireRow.Delete(1) exceptions.AttributeError: 'NoneType' object has no attribute 'ActiveSheet' << And then it runs correctly on second click: >> OnBeginShutdown None OnDisconnection OnBeginShutdown None OnDisconnection << My theory is that the object isn't loaded into memory yet on first click and only gets correctly instantiated AFTER the first click... Which allows it to work the second time around. I have been trying to figure out how to preload the object into memory which is what caused my futile attempts with the import statement (Excel as xlApp). I've gone through Mark Hammond's book (and love it) but I'm just missing a key detail somewhere. Thoughts? From paandev at yahoo.com Thu Nov 18 04:48:24 2004 From: paandev at yahoo.com (Wara Songkran) Date: Thu Nov 18 04:48:53 2004 Subject: [python-win32] Can't make parser In-Reply-To: <20041117200030.67364.qmail@web51303.mail.yahoo.com> Message-ID: <20041118034824.8821.qmail@web51304.mail.yahoo.com> Hi Forgive my last post. the PyXML from http://debris.demon.nl/PythonCE-2.3 doesn't work. I can make parser by calling sax.make_parser() and it returned ExpatParser but when I call parser.parse("xxx.xml") the shell just terminated. So I try agian, this time with PyXML 0.8.3 and I just copied it from my python's Lib directory on my PC. It's really work this time I can create parser and parse some xml files. The last PyXML(the woring one) return "xml.sax.driver2.drv_xmlproc.XmlprocDriver" instead of ExpatParser. Xml Gurus please enlight me what this mean. Regard Wara Songkran Wara Songkran wrote: Hi I've just try PyXML from http://debris.demon.nl/PythonCE-2.3 and it's work. Any Idea why this happen. I also use PyXML on my Desktop PC but with standard xml package which come with python is also work. Why standard xml package on PythonCE does not work? Wara Songkran wrote: Hi I'm using Python-2.3.4-arm-PPC2003. When I try to use sax the shell said >>> from xml import sax >>> parser = sax.make_parser() Traceback (most recent call last): File "binaries\lib\xml\sax\__init__.py", line 93, in make_parser SAXReaderNotAvaiable: No parsers found I guess beacause it need expat parser library which is a native dll to run. Please help. --------------------------------- Do you Yahoo!? Discover all that’s new in My Yahoo! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041117/fc27ca64/attachment.htm From mhammond at skippinet.com.au Thu Nov 18 05:52:43 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Nov 18 05:52:51 2004 Subject: [python-win32] NEWBIE QUESTION - 'NoneType' object has no attribute'ActiveSheet' In-Reply-To: Message-ID: <061201c4cd2a$71944740$040a0a0a@enfoldsystems.local> > xlApp.ActiveWorkbook.ActiveSheet.Cells(1).Rows.EntireRow.Delete(1) > exceptions.AttributeError: 'NoneType' object has no attribute > 'ActiveSheet' That is telling you that 'xlApp.ActiveWorkbook' (ie, the object from which 'ActiveSheet' is being requested) is returning None - ie, no workbook is open. > My theory is that the object isn't loaded into memory yet on > first click and > only gets correctly instantiated AFTER the first click... I suspect that Excel's startup process is the reason. It probably gets to a very early point (ie, no sheets open, but still 'working') when your call to "Dispatch()" returns. It is probably after this that Excel does whatever it is configured to do at startup - generally load a blank worksheet. For a simple solution, just sleep a brief while. Mark From python at kareta.de Thu Nov 18 16:10:04 2004 From: python at kareta.de (=?ISO-8859-1?B?SvxyZ2VuIEthcmV0YQ==?=) Date: Thu Nov 18 16:15:59 2004 Subject: [python-win32] os.popen/winpipe Message-ID: <1100790604.419cbb4c13119@webmail.ldc.de> Hello, I am wondering about the following code pices: Nt04 python 2.3.3 pywin 203 [code 1] import win32pipe f = win32pipe.popen('dir ch*') print f.read() f.close() result ok [code 2] import win32pipe f = win32pipe.popen('net use') print f.read() f.close() result ok [code 3] import win32pipe f = win32pipe.popen('net use lpt2: \\server\printer') ##or 'net use ?' print f.read() f.close() empty result string If I send the 'dir' command with or without parameters I get a result string, same as 'net use' command without parameters, but 'net use' with parameters fire allways a empty resutlt string. Any hints ? Thanks in advance! regards, J?rgen From jens.jorgensen at tallan.com Thu Nov 18 16:50:58 2004 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Thu Nov 18 16:51:13 2004 Subject: [python-win32] os.popen/winpipe In-Reply-To: <1100790604.419cbb4c13119@webmail.ldc.de> References: <1100790604.419cbb4c13119@webmail.ldc.de> Message-ID: <419CC4E2.1000301@tallan.com> J?rgen Kareta wrote: >Hello, > >[code 3] >import win32pipe >f = win32pipe.popen('net use lpt2: \\server\printer') ##or 'net use ?' >print f.read() >f.close() > > perhaps: f = win32pipe.popen('net use lpt2: \\\\server\\printer') ##or 'net use ?' Don't forget that \ is an escape character. >empty result string > >If I send the 'dir' command with or without parameters I get a result string, >same as 'net use' command without parameters, but 'net use' with parameters fire >allways a empty resutlt string. Any hints ? > >Thanks in advance! >regards, >J?rgen >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From tim.golden at viacom-outdoor.co.uk Thu Nov 18 16:52:54 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu Nov 18 16:58:15 2004 Subject: [python-win32] os.popen/winpipe Message-ID: [J?rgen Kareta] [.. snip examples of "dir ch*" & "net use" ...] I realise that you're probably just using these snippets as examples of using popen etc. But, just in case these are real examples, you can achieve the first one by using os.listdir / glob.glob and the second by using win32net.NetUseAdd Just in case... 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 ah_new at yahoo.com Thu Nov 18 08:52:49 2004 From: ah_new at yahoo.com (ah_new) Date: Thu Nov 18 17:09:06 2004 Subject: [python-win32] run exe file in PythonWin Message-ID: <20041118075249.89910.qmail@web53901.mail.yahoo.com> hey! guys, i would like to ask something... how to run / start an .exe in python IDE (in the interactive window) ? i'm using win XP + PythonWIN IDE 2.3 thanks.. ah_new@yahoo.com ___________________________________________________________ Win a castle for NYE with your mates and Yahoo! Messenger http://uk.messenger.yahoo.com From python at kareta.de Thu Nov 18 17:04:10 2004 From: python at kareta.de (=?ISO-8859-1?B?SvxyZ2VuIEthcmV0YQ==?=) Date: Thu Nov 18 17:10:04 2004 Subject: [python-win32] os.popen/winpipe Message-ID: <1100793850.419cc7fa24f66@webmail.ldc.de> Hello Jens, thanks for your fast answer. Of, course that's the solution. Sorry for asking a stupid question :-( But I think, i have to sleep a night over to solve it by my self. J?rgen From python at kareta.de Thu Nov 18 17:38:12 2004 From: python at kareta.de (=?ISO-8859-1?B?SvxyZ2VuIEthcmV0YQ==?=) Date: Thu Nov 18 17:44:06 2004 Subject: AW: [python-win32] os.popen/winpipe Message-ID: <1100795892.419ccff4c1a7f@webmail.ldc.de> > I realise that you're probably just using these > snippets as examples of using popen etc. But, just > in case these are real examples, you can achieve the > first one by using os.listdir / glob.glob and the > second by using win32net.NetUseAdd > > Just in case... Yeah, it's in case... . I'm really new to win32api and like to hear helpful hints. Thanks J?rgen From tim.golden at viacom-outdoor.co.uk Thu Nov 18 18:14:05 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu Nov 18 18:19:29 2004 Subject: [python-win32] os.popen/winpipe Message-ID: [J?rgen Kareta] [Tim Golden] | > I realise that you're probably just using these | > snippets as examples of using popen etc. But, just | > in case these are real examples, you can achieve the | > first one by using os.listdir / glob.glob and the | > second by using win32net.NetUseAdd | > | > Just in case... | | Yeah, it's in case... . I'm really new to win32api and like | to hear helpful | hints. The first one's easy: (and, before anyone else chips in, there are of course several ways to skin this cat. I'm just going for initial simplicity.) import os for filename in os.listdir ("."): if filename.startswith ("ch"): print filename NET USE is a bit more messy. You'll need to read up on the way in which this works, but the following works: import win32net drives = {} resume = 0 while 1: (_drives, total, resume) = win32net.NetUseEnum (None, 0, resume) for drive in _drives: if drive['local']: drives[drive['local']] = drive['remote'] if not resume: break for k, v in drives.items (): print k, "=>", v and to map a drive / printer, something like this: import win32net # # The local / remote items could just as well # be LPT2: and \\printserver\printer # win32net.NetUseAdd ( None, 0, { 'local' : "K:", 'remote' : r"\\tdi_nt4a\user" } ) Happy Pythoning on win32! 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 python at kareta.de Thu Nov 18 19:59:16 2004 From: python at kareta.de (=?ISO-8859-1?B?SvxyZ2VuIEthcmV0YQ==?=) Date: Thu Nov 18 20:05:06 2004 Subject: [python-win32] os.popen/winpipe Message-ID: <1100804356.419cf1045245c@webmail.ldc.de> Hi Tim, # # The local / remote items could just as well # be LPT2: and \\printserver\printer # win32net.NetUseAdd ( None, 0, { 'local' : "K:", 'remote' : r"\\tdi_nt4a\user" } ) results in Error 124 INVALID LEVEL use_info = { 'local':'v:', 'remote':r'\\server\directory', 'asg_type':0, 'username':'user', 'password':'pwd'} win32net.NetUseAdd(None,2,use_info) works fine. So I found a solution, but Py_USE INFO 0 without user/pw is more charmy. I googled and found lots of lists in the errorcode/description manner, but found no description what that means. J?rgen From jens.jorgensen at tallan.com Thu Nov 18 22:59:34 2004 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Thu Nov 18 22:59:45 2004 Subject: [python-win32] os.popen/winpipe In-Reply-To: <1100804356.419cf1045245c@webmail.ldc.de> References: <1100804356.419cf1045245c@webmail.ldc.de> Message-ID: <419D1B46.2020501@tallan.com> According to the info in my MSDN Library 1999 edition only levels 1 & 2 are supported. Level 0 must've been phased out. J?rgen Kareta wrote: >Hi Tim, > ># ># The local / remote items could just as well ># be LPT2: and \\printserver\printer ># >win32net.NetUseAdd ( > None, > 0, > { > 'local' : "K:", > 'remote' : r"\\tdi_nt4a\user" > } >) > > >results in Error 124 INVALID LEVEL > >use_info = { >'local':'v:', >'remote':r'\\server\directory', >'asg_type':0, >'username':'user', >'password':'pwd'} >win32net.NetUseAdd(None,2,use_info) > >works fine. So I found a solution, but Py_USE INFO 0 without user/pw is more >charmy. I googled and found lots of lists in the errorcode/description manner, >but found no description what that means. > >J?rgen >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From howard at eegsoftware.com Fri Nov 19 00:50:05 2004 From: howard at eegsoftware.com (Howard Lightstone) Date: Fri Nov 19 00:49:33 2004 Subject: [python-win32] Default button change notification Message-ID: <419CC4AD.8603.1EA914AF@localhost> I have some buttons on a Canvas that act properly when Tab is used (a dim gray highlight 'ring" shows on the button). Is there some way to change the color of the ring (or any other color change) when the button is the "default" button? Focus events don't do the right thing. I saw a request for a event on a Tk list but that was too recent to actually be implemented on the 8.3 version I have available. I can't seem to find anything to hook onto when the "default" button (which takes action on the spacebar) changes. Thanks From tim.golden at viacom-outdoor.co.uk Fri Nov 19 09:20:22 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Fri Nov 19 09:25:52 2004 Subject: [python-win32] os.popen/winpipe Message-ID: [Jens B. Jorgensen] [re NetUseAdd] | According to the info in my MSDN Library 1999 edition only | levels 1 & 2 | are supported. Level 0 must've been phased out. Yes, sorry. I'd found that out when I was testing the code before I sent. Unfortunately, I obviously didn't update the copy in the email. 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 c.walou at laposte.net Fri Nov 19 09:38:49 2004 From: c.walou at laposte.net (walou) Date: Fri Nov 19 09:38:50 2004 Subject: [python-win32] Default button change notification In-Reply-To: <419CC4AD.8603.1EA914AF@localhost> References: <419CC4AD.8603.1EA914AF@localhost> Message-ID: <1100853528.1743.4155.camel@kls> Try to use GTK Le ven 19/11/2004 ? 00:50, Howard Lightstone a ?crit : > I have some buttons on a Canvas that act properly when Tab is used (a > dim gray highlight 'ring" shows on the button). > > Is there some way to change the color of the ring (or any other color > change) when the button is the "default" button? Focus events don't do > the right thing. I saw a request for a event on a Tk list but > that was too recent to actually be implemented on the 8.3 version I have > available. I can't seem to find anything to hook onto when the "default" > button (which takes action on the spacebar) changes. > > Thanks > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From fission6 at hotmail.com Fri Nov 19 15:48:25 2004 From: fission6 at hotmail.com (Kenley _) Date: Fri Nov 19 15:49:05 2004 Subject: [python-win32] NEWBIE QUESTION - 'NoneType' object has no attribute'ActiveSheet' Message-ID: Wow. Thanks Mark! Excel's startup process was the reason and the call to sleep allowed me to see what was really going on. You were right, the call to "Dispatch()" was spawning a new Excel process with no workbook, quicker than the eye could see. When clicking the button a second time, the call to Dispatch() does not spawn a new process for some reason and allows it to work correctly. I got it to work with an embarrassingly crude hack (calling 'Dispatch' twice) that doesn't seem like it should be legal or work at all. Here is the Button class code that works: class ButtonEvent: def OnClick(self, button, cancel): #import time xlApp = Dispatch("Excel.Application") xlApp.Visible = 1 del xlApp #seems to work ok with or without sleeping a few seconds #time.sleep(2) xlApp = Dispatch("Excel.Application") xlApp.Visible = 1 xlApp.ActiveWorkbook.ActiveSheet.Cells(1).Rows.EntireRow.Delete(1) xlApp.ActiveWorkbook.ActiveSheet.Cells(2).Rows.EntireRow.Delete(1) xlApp.ActiveWorkbook.ActiveSheet.Cells(3).Rows.EntireRow.Delete(1) xlApp.ActiveWorkbook.SaveAs("C:\\test.csv") xlApp.ActiveWorkbook.Close(SaveChanges=0) xlApp.Quit() del xlApp P.S. Mark your book rocks and I am part of the group that would buy a follow-up... Maybe you and Hugunin on Python with .Net? From timr at probo.com Fri Nov 19 18:33:40 2004 From: timr at probo.com (Tim Roberts) Date: Fri Nov 19 18:33:54 2004 Subject: [python-win32] Default button change notification In-Reply-To: <20041119082554.1BCFB1E400F@bag.python.org> References: <20041119082554.1BCFB1E400F@bag.python.org> Message-ID: <419E2E74.8080505@probo.com> On Thu, 18 Nov 2004 15:50:05 -0800, "Howard Lightstone" wrote: >I have some buttons on a Canvas that act properly when Tab is used (a >dim gray highlight 'ring" shows on the button). > >Is there some way to change the color of the ring (or any other color >change) when the button is the "default" button? Focus events don't do >the right thing. I saw a request for a event on a Tk list but >that was too recent to actually be implemented on the 8.3 version I have >available. I can't seem to find anything to hook onto when the "default" >button (which takes action on the spacebar) changes. > I'm not exactly sure we're on the same page. The term "default button" has a very specific meaning in Windows -- it is the button that fires when you hit Enter in a dialog, whether or not it has the focus. It is the "OK" button for the dialog. Spacebar fires the button with focus, which might or might not be the "default button". The default button has a thicker border at all time, using the default button highlight colors. A button with focus gets a slightly thicker border and a dotted line around the button text. Some of this can be changed by the Windows XP theme, but if you want something fancier than that, you'll have to use an owner draw button. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From phillip.watts at anvilcom.com Fri Nov 19 18:18:26 2004 From: phillip.watts at anvilcom.com (phil) Date: Fri Nov 19 19:15:52 2004 Subject: [python-win32] Help! missing dll Message-ID: <419E2AE2.7090005@anvilcom.com> settings.exe uses tkinter/Pmw remote.exe uses pyserial/win32all project polldir is built with py2exe. They work fine on any machine at my house, win2000, XP home, etc. At aonther location, Win XP pro with service pack 2 and win 2000, possibly svc pack 2, get the following: BTW, tcl\tcl8.4 is in \polldir, and what dll can remote not load? Thanks ========================================================== Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Documents and Settings\poltest>cd \polldir C:\polldir>settings C:\polldir>dir *.log Volume in drive C is IBM_PRELOAD Volume Serial Number is 147E-F07E Directory of C:\polldir 11/18/2004 09:59 AM 796 SETTINGS.EXE.log 1 File(s) 796 bytes 0 Dir(s) 30,047,117,312 bytes free C:\polldir>type settings.exe.log Traceback (most recent call last): File "settings.py", line 211, in ? File "settings.py", line 31, in __init__ File "settings.py", line 34, in mkmainwin File "Tkinter.pyc", line 1564, in __init__ _tkinter.TclError: Can't find a usable init.tcl in the following directories: C:/lib/tcl8.4 C:/lib/tcl8.4 C:/library This probably means that Tcl wasn't installed properly. C:\polldir> C:\polldir>remote Traceback (most recent call last): File "remote.py", line 3, in ? File "serial\__init__.pyc", line 13, in ? File "serial\serialwin32.pyc", line 9, in ? File "win32file.pyc", line 9, in ? File "win32file.pyc", line 7, in __load ImportError: DLL load failed: The specified module could not be found. From wap at openlink.com.br Sat Nov 20 07:31:53 2004 From: wap at openlink.com.br (Washington Coutinho Corrêa Jr) Date: Sat Nov 20 08:51:45 2004 Subject: [python-win32] Re: run exe file in PythonWin References: <20041118075249.89910.qmail@web53901.mail.yahoo.com> Message-ID: Do you mean... import os os.system("program.exe") ? Hugs, Junior "ah_new" escreveu na mensagem news:20041118075249.89910.qmail@web53901.mail.yahoo.com... hey! guys, i would like to ask something... how to run / start an .exe in python IDE (in the interactive window) ? i'm using win XP + PythonWIN IDE 2.3 thanks.. ah_new@yahoo.com ___________________________________________________________ Win a castle for NYE with your mates and Yahoo! Messenger http://uk.messenger.yahoo.com From inq1 at verizon.net Sun Nov 21 18:27:31 2004 From: inq1 at verizon.net (Jim D) Date: Sun Nov 21 18:36:27 2004 Subject: [python-win32] Win-95 v4.00.950 B 32 bit and python setup.py Message-ID: <200411211227.31228.inq1@verizon.net> > I've used "setup bdist_wininst" to build When I run the exe file I get a Windows error message : "This program has performed an illegal operation and will be shut down." The message references an error in module COMTL32.DLL at 0137:bff01a53 and then lists a series of registers. I get the same erron module COMTL32 msg when I try to install py2exe-0.5.4. Will setup.py and py2exe work on Win-95. Jim Rose From Thomas.Sprinzing at bielomatik.de Mon Nov 22 10:19:55 2004 From: Thomas.Sprinzing at bielomatik.de (Sprinzing, Thomas) Date: Mon Nov 22 10:20:11 2004 Subject: [python-win32] com server instantiation mess Message-ID: Hi Folks, first of all, a short introduction:my name is Thomas Sprinzing, i work for a company making heavy machinery for paper processing in Germany, and i use python on win32 for some administrative tasks. I've been using Mark Hammond's pywim32 for quite a while now, also i am a bit familiar with zope/plone. I have not been lurking around this list, so i'm a new kid in this town here. Anyway, here's my problem (i wrote this to mark, and he proposed to post it here) I wrote a com object which basically wraps the python logging module. Then, from within some strange application, i instantiate two different jscript threads running in an embedded Windows script host. These are for accessing the logging com object. So i want to have two distinctive loggers, one logger "A" logging to A.log, one logger B logging to B.log. I get them as expected, but: if i log a message to one of the loggers, it gets written to both logfiles. So there is a problem on python side with the instantiation. I'll append my pythonscript at the end. Actually, I'm not too familiar on how to solve this - where should i go and look? Thanks a lot in advance Thomas class loginterface: _reg_clsid_ = "{1B4F2902-0F6B-4388-96FD-D2F0BE0C0443}" _reg_desc_ = "Python COM Logging object" _reg_progid_ = "Bielo.Logger" _public_methods_ = ['append', 'initialize'] _public_attrs_ = ['formatter_string', 'logfile_size', 'logfile_count' ] _readonly_attrs_ = [] def __init__(self): import logging import logging.handlers self.logger=logging.getLogger('mylogger') self.hdlr='' self.logfile_size = 1048577 self.logfile_count = 10 self.formatter_string = '%(asctime)s %(message)s' self.loglevel = logging.INFO def initialize(self, filename): try: import os import winerror import win32com.server from win32com.server.exception import COMException import logging import logging.handlers self.abspath=os.path.abspath(str(filename)) self.hdlr=logging.handlers.RotatingFileHandler(self.abspath,'a',self.logfile _size,self.logfile_count) self.formatter = logging.Formatter(self.formatter_string) self.hdlr.setFormatter(self.formatter) self.logger.addHandler(self.hdlr) self.logger.setLevel(self.loglevel) except (TypeError,ValueError): raise COMException(desc="Fehler beim initialisieren des Loggers",scode=winerror.ERROR_GENERIC_NOT_MAPPED) def append(self, meldung): try: import logging import win32com.server import winerror from win32com.server.exception import COMException self.logger.info(meldung.encode('latin-1')) except (TypeError, ValueError): raise COMException(desc="Fehler beim loggen: " + ValueError, scode=winerror.ERROR_GENERIC_NOT_MAPPED) return 'message logged:' + meldung if __name__ == '__main__': import sys from win32com.server import register register.UseCommandLine(loginterface) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041122/7f13876b/attachment.html From niki at vintech.bg Mon Nov 22 11:02:09 2004 From: niki at vintech.bg (Niki Spahiev) Date: Mon Nov 22 11:02:21 2004 Subject: [python-win32] com server instantiation mess In-Reply-To: References: Message-ID: <41A1B921.8070207@vintech.bg> Sprinzing, Thomas wrote: > Anyway, here's my problem (i wrote this to mark, and he proposed to post > it here) > > I wrote a com object which basically wraps the python logging module. > Then, from within some strange application, i instantiate two > different jscript threads running in an embedded Windows script host. > These are for accessing the logging com object. So i want to have two > distinctive loggers, one logger "A" logging to A.log, one logger B > logging to B.log. > I get them as expected, but: if i log a message to one of the loggers, > it gets written to both logfiles. So there is a problem on python side > with the instantiation. I'll append my pythonscript at the end. > Actually, I'm not too familiar on how to solve this - where should i go > and look? try self.logger=logging.getLogger('myloggerA') for first object and self.logger=logging.getLogger('myloggerB') for second object HTH Niki Spahiev From Thomas.Sprinzing at bielomatik.de Mon Nov 22 11:18:58 2004 From: Thomas.Sprinzing at bielomatik.de (Sprinzing, Thomas) Date: Mon Nov 22 11:19:04 2004 Subject: AW: [python-win32] com server instantiation mess Message-ID: > Von: Niki Spahiev [mailto:niki@vintech.bg] > > try > > self.logger=logging.getLogger('myloggerA') > > for first object and > > self.logger=logging.getLogger('myloggerB') > > for second object I already did what you mean within my jscripts: var Logger=new ActiveXObject("Bielo.Logger"); And in the other thread: var LoggerB=new ActiveXObject("Bielo.Logger"); Where Bielo.Logger is the com object distributed by the Pythonscript i posted before. I thought COM is about re-use of a component within different progams on one computer. So i hope, i do not have to write two com servers-which surely would solve my special prblem now, but wouldn't be a cure for the real cause. Bye Thomas From mhammond at skippinet.com.au Mon Nov 22 12:06:58 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon Nov 22 12:07:26 2004 Subject: [python-win32] com server instantiation mess In-Reply-To: Message-ID: <121f01c4d083$6a0d82a0$040a0a0a@enfoldsystems.local> > > Von: Niki Spahiev [mailto:niki@vintech.bg] > > try > > self.logger=logging.getLogger('myloggerA') > > for first object and > > self.logger=logging.getLogger('myloggerB') > > for second object > > > I already did what you mean within my jscripts: As Niki hinted, the issue is related purely to the Python logging module. Try and re-create the issue in Python. Ignore COM, and ignore any external clients - pretend your application was purely Python: > var Logger=new ActiveXObject("Bielo.Logger"); Instead of that, write a Python program with 2 threads, and each thread does a: import your_module logger = your_module.loginterface() logger.initialize("Bielo.Logger") And you will find the exact same problem. The reason is that each thread does: logger=logging.getLogger('mylogger') ... logger.addHandler(handler) But, logging.getLogger() maintains a global set of loggers. The second time that the same process calls this code, you have a single logger object, but with *two* handler objects added. Each of these handlers prints the message. I've been burnt by this too :) Mark From Thomas.Sprinzing at bielomatik.de Mon Nov 22 13:58:31 2004 From: Thomas.Sprinzing at bielomatik.de (Sprinzing, Thomas) Date: Mon Nov 22 13:58:38 2004 Subject: AW: [python-win32] com server instantiation mess Message-ID: > As Niki hinted, the issue is related purely to the Python > logging module. > > The reason is that each thread does: > > logger=logging.getLogger('mylogger') > ... > logger.addHandler(handler) > > But, logging.getLogger() maintains a global set of loggers. > The second time that the same process calls this code, you > have a single logger object, but with *two* handler objects > added. Each of these handlers prints the message. > > I've been burnt by this too :) D'oh. Who could have guessed that. So the loggers i create are global within : an Application (=Task) or within a machine? I guess the latter. (Didin't try yet) Anyway, the fix was easily done: def __init__(self): import logging import logging.handlers import pythoncom loggerid = str(pythoncom.CreateGuid()) self.logger=logging.getLogger(loggerid) self.hdlr='' self.logfile_size = 1048577 self.logfile_count = 10 self.formatter_string = '%(asctime)s %(message)s' self.loglevel = logging.INFO Every new instance gets its own loggerid. Works like a charm so far. Thanks Mark & Niki Thomas Sprinzing From niki at vintech.bg Mon Nov 22 14:36:59 2004 From: niki at vintech.bg (Niki Spahiev) Date: Mon Nov 22 14:37:10 2004 Subject: AW: [python-win32] com server instantiation mess In-Reply-To: References: Message-ID: <41A1EB7B.4070706@vintech.bg> Sprinzing, Thomas wrote: > > D'oh. Who could have guessed that. So the loggers i create are global within > : an Application (=Task) or within a machine? > I guess the latter. (Didin't try yet) Depends from COM server - PythonCOM DLL (INPROCESS) servers are global per process due to using single pythonXY.dll. PythonCOM EXE (LOCAL) servers are per machine (maybe :). Niki Spahiev From rays at blue-cove.com Mon Nov 22 16:09:03 2004 From: rays at blue-cove.com (RayS) Date: Mon Nov 22 16:06:02 2004 Subject: [python-win32] phone/modem recording recipe? Message-ID: <5.2.1.1.2.20041122070635.05e8e320@pop-server.san.rr.com> I was reviewing win32ras, pyserial and such last night, and I found two Python VOIP packages (for ISDN), but in short, I would just like to capture/send from a POTS handset via the modem. Like video/audio capture, except with a modem. Has anyone a "Hello phone" recipe? Ray From c.walou at laposte.net Mon Nov 22 16:11:44 2004 From: c.walou at laposte.net (walou) Date: Mon Nov 22 16:11:45 2004 Subject: [python-win32] wmi and NT service Message-ID: <1101136304.1740.4416.camel@kls> Hello, While I was crawling python.org I found : """c = wmi.WMI() event_watcher=c.watch_for (notification_type="Creation",wmi_class="Win32_NTLogEvent",delay_secs=1) evt=event_watcher() """ I want to know any changes in Win32_Session in a NT service. So I tried : ... def SvcDoRun(self): import wmi c = wmi.WMI() event_watcher=c.watch_for(notification_type="Creation",wmi_class="Win32_Session",delay_secs=1) evt = event_watcher() fh = file('c:\montest.log','w') fh.write('coucou') fh.close ... Just pasted in a .py file, it works fine (I tested it by installing IIS FTP Server and opening sessions on it, note that if you want to retest, you have to use an other login) The entire code of the service comes from another which works fine, I just replace a few lines with the ones I wrote above. The service don't start anymore ... does somebody see why ? Klaas From c.walou at laposte.net Mon Nov 22 17:30:10 2004 From: c.walou at laposte.net (walou) Date: Mon Nov 22 17:30:16 2004 Subject: [python-win32] wmi and NT service In-Reply-To: <1101136304.1740.4416.camel@kls> References: <1101136304.1740.4416.camel@kls> Message-ID: <1101141009.1740.4462.camel@kls> It was just a ms-joke, because the service is launched by SYSTEM account, so the service tried to import %WINDIR%\Sytem32\wmi.dll .... renaming wmi.py to pywmi.py solved the problem But you know, with me, a solved problem always produces a new question and "here I am" : How can I get the name of the currently logged on user in a NT service ? os.environ['USERNAME'] don't work ... (hooooooo ) Klaas Le lun 22/11/2004 ? 16:11, walou a ?crit : > Hello, > While I was crawling python.org I found : > > """c = wmi.WMI() > event_watcher=c.watch_for > (notification_type="Creation",wmi_class="Win32_NTLogEvent",delay_secs=1) > > > evt=event_watcher() > """ > > I want to know any changes in Win32_Session in a NT service. So I tried : > > ... > def SvcDoRun(self): > import wmi > c = wmi.WMI() > event_watcher=c.watch_for(notification_type="Creation",wmi_class="Win32_Session",delay_secs=1) > evt = event_watcher() > fh = file('c:\montest.log','w') > fh.write('coucou') > fh.close > ... > > Just pasted in a .py file, it works fine (I tested it by installing IIS FTP Server and opening sessions on it, note that if you want to retest, you have to use an other login) > The entire code of the service comes from another which works fine, I just replace a few lines with the ones I wrote above. > The service don't start anymore ... does somebody see why ? > > > Klaas > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From tim.golden at viacom-outdoor.co.uk Mon Nov 22 17:36:11 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon Nov 22 17:41:37 2004 Subject: [python-win32] wmi and NT service Message-ID: [walou] | It was just a ms-joke, because the service is launched by SYSTEM | account, so the service tried to import %WINDIR%\Sytem32\wmi.dll .... | renaming wmi.py to pywmi.py solved the problem Well done for spotting that. It's come up a number of times on this list before (and the main Python one). I really should put a warning on the WMI page, but I keep forgetting. | How can I get the name of the currently logged on user in a | NT service ? 1 >>> import win32api 2 >>> win32api.GetUserName () 2 --> 'goldent' 3 >>> 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 steve at holdenweb.com Mon Nov 22 17:56:06 2004 From: steve at holdenweb.com (Steve Holden) Date: Mon Nov 22 17:58:00 2004 Subject: [python-win32] wmi and NT service In-Reply-To: References: Message-ID: <41A21A26.3070007@holdenweb.com> Tim Golden wrote: > [walou] > | It was just a ms-joke, because the service is launched by SYSTEM > | account, so the service tried to import %WINDIR%\Sytem32\wmi.dll .... > | renaming wmi.py to pywmi.py solved the problem > > Well done for spotting that. It's come up a number of times > on this list before (and the main Python one). I really should > put a warning on the WMI page, but I keep forgetting. > > | How can I get the name of the currently logged on user in a > | NT service ? > > 1 >>> import win32api > 2 >>> win32api.GetUserName () > 2 --> 'goldent' > 3 >>> > Given that there is a wmi.dll, might it not be better to give in and rename your package to pywmi? pragmatical-ly y'rs - steve -- http://www.holdenweb.com http://pydish.holdenweb.com Holden Web LLC +1 800 494 3119 From tim.golden at viacom-outdoor.co.uk Mon Nov 22 17:58:34 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon Nov 22 18:04:05 2004 Subject: [python-win32] wmi and NT service Message-ID: [Steve Holden] | Given that there is a wmi.dll, might it not be better to give in and | rename your package to pywmi? | | pragmatical-ly y'rs - steve Yes, I know. Every time this issue comes up I think "Shall I? Shan't I?". There are only two reasons not to, neither compelling: one, that I had an ingrained prejudice against the pyxxx school of naming; the other, that I'd have to go through a process of updating the web pages and then making something of an announcement so that anyone out in the field knows it's changed and doesn't think it's another WMI module coming into the field (a la pymssql, mssql). I shall continune to give it deliberate thought. 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 Jason.Hihn at verint.com Mon Nov 22 20:08:16 2004 From: Jason.Hihn at verint.com (Hihn, Jason) Date: Mon Nov 22 20:08:23 2004 Subject: [python-win32] Problems opening windows Message-ID: Hi, I have embedded Python in my MFC app, and it works, but it won't create windows. Originally I was using PyQt, but I hit my frustration limit and tried Tk. TK doesn't work for me either. I was hoping someone could shed on what it takes to open a window from python in an MFC appMFC apps. I'm hoping these two issues are related. I get no errors or warnings, just nothing happens. Here's my source: void CPyqttestDlg::OnOK() { // TODO: Add extra validation here // PyEval_InitThreads(); Py_Initialize(); PyObject *qt[2]; PyObject *err; char modules[][80]={"qt", "qtui"}; /* for (int h=0; h References: <20041122190824.7437F1E400D@bag.python.org> Message-ID: <41A24356.8070800@probo.com> On Mon, 22 Nov 2004 07:09:03 -0800, RayS wrote: >I was reviewing win32ras, pyserial and such last night, and I found two Python VOIP packages (for ISDN), but in short, I would just like to capture/send from a POTS handset via the modem. Like video/audio capture, except with a modem. > >Has anyone a "Hello phone" recipe? > > No. That's not how a modem works. It doesn't have the ability to pass the raw audio data through to you, nor to accept digital PCM data and ship it out the speaker. What you need to do is hook your handset up to your sound card. THAT'S the hardware that understands how to capture analog audio data. And as long as you're doing that, use a real headset/microphone; the mike and speaker in your POTS handset suck. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Mon Nov 22 23:24:33 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon Nov 22 23:24:42 2004 Subject: [python-win32] wmi and NT service In-Reply-To: Message-ID: <135f01c4d0e2$0b5bac00$040a0a0a@enfoldsystems.local> > [Steve Holden] > | Given that there is a wmi.dll, might it not be better to > give in and > | rename your package to pywmi? > | > | pragmatical-ly y'rs - steve > > Yes, I know. Every time this issue comes up I > think "Shall I? Shan't I?". There are only two > reasons not to, neither compelling: This problem has only ever been seen with Windows services, but it *has* been seen with modules other than WMI (ie, 'zlib' came up just a couple of weeks ago). I think pywin32 itself should avoid allowing SYSTEM32 to be on your sys.path in this environment, and that should solve 99% of the problems. Mark From c.walou at laposte.net Tue Nov 23 10:15:40 2004 From: c.walou at laposte.net (walou) Date: Tue Nov 23 10:15:41 2004 Subject: [python-win32] wmi and NT service In-Reply-To: References: Message-ID: <1101201340.3145.4495.camel@kls> Le lun 22/11/2004 ? 17:58, Tim Golden a ?crit : > [Steve Holden] > | Given that there is a wmi.dll, might it not be better to give in and > | rename your package to pywmi? > | > | pragmatical-ly y'rs - steve > > Yes, I know. Every time this issue comes up I > think "Shall I? Shan't I?". There are only two > reasons not to, neither compelling: one, that I had > an ingrained prejudice against the pyxxx school > of naming; the other, that I'd have to go through > a process of updating the web pages and then making > something of an announcement so that anyone out in > the field knows it's changed and doesn't think it's > another WMI module coming into the field (a la pymssql, > mssql). > > I shall continune to give it deliberate thought. > > TJG win32api.GetUserName() returns SYSTEM (account which launches the service), not the name of the guy who entered his name in the session opening dialogue box. Maybe I can get it somewhere in the registry (HKLM) or ask it to the samba logon server. The difficulty is that a NT service can't read HKey Current User, HKCU is only a link to HKU\SID-XXX-XXXX-...\ and there are many ways to log on a XP box. In the last case I'm serene because the XP boxes where the service will be installed on will never have an FTP, Terminal server or quick user switch installed on it. Maybe there's a way to get my information with wmi ... Klaas (why not "_wmi", "win32wmi", "2umi" ...) From niki at vintech.bg Tue Nov 23 10:17:23 2004 From: niki at vintech.bg (Niki Spahiev) Date: Tue Nov 23 10:17:37 2004 Subject: [python-win32] phone/modem recording recipe? In-Reply-To: <41A24356.8070800@probo.com> References: <20041122190824.7437F1E400D@bag.python.org> <41A24356.8070800@probo.com> Message-ID: <41A30023.3060102@vintech.bg> Tim Roberts wrote: > On Mon, 22 Nov 2004 07:09:03 -0800, RayS wrote: > >> I was reviewing win32ras, pyserial and such last night, and I found >> two Python VOIP packages (for ISDN), but in short, I would just like >> to capture/send from a POTS handset via the modem. Like video/audio >> capture, except with a modem. >> >> Has anyone a "Hello phone" recipe? >> >> > > No. That's not how a modem works. It doesn't have the ability to pass > the raw audio data through to you, nor to accept digital PCM data and > ship it out the speaker. Well not exactly true ;) Some modems can capture audio and send it to computer. With most raw data is in proprietary format, but some drivers make it accessible as multimedia audio device. Try pygame or pymedia. HTH Niki Spahiev From tim.golden at viacom-outdoor.co.uk Tue Nov 23 10:25:11 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Nov 23 10:30:50 2004 Subject: [python-win32] wmi and NT service Message-ID: [Walou] | win32api.GetUserName() returns SYSTEM (account which launches the | service), not the name of the guy who entered his name in the session | opening dialogue box. Ah, sorry. I should have realised what you were after. As far as I know, the service is running as SYSTEM, and only the Win32_Session object would have the details of which user had logged in. I don't run XP, so I can't check at the moment. I suggest Googling (possibly Google-Grouping) for: WMI win32_session username -- or something similar to see if anyone else has done the same. If they have I'm sure we can translate back to Python. | (why not "_wmi", "win32wmi", "2umi" ...) All possible, I know! it's just a question of deciding whether to or not. Did you see Mark H's email about having pywin32 exclude system32 from the path? (By the way, the 2umi one took me a couple of moments to work out!) 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 rays at blue-cove.com Tue Nov 23 16:44:41 2004 From: rays at blue-cove.com (RayS) Date: Tue Nov 23 16:41:42 2004 Subject: [python-win32] phone/modem recording recipe? In-Reply-To: <41A30023.3060102@vintech.bg> References: <41A24356.8070800@probo.com> <20041122190824.7437F1E400D@bag.python.org> <41A24356.8070800@probo.com> Message-ID: <5.2.1.1.2.20041123070612.077e4100@blue-cove.com> At 11:17 AM 11/23/2004 +0200, Niki Spahiev wrote: >Tim Roberts wrote: > >>On Mon, 22 Nov 2004 07:09:03 -0800, RayS wrote: >> >>>I was reviewing win32ras, pyserial and such last night, and I found two Python VOIP packages (for ISDN), but in short, I would just like to capture/send from a POTS handset via the modem. Like video/audio capture, except with a modem. >>> >>>Has anyone a "Hello phone" recipe? >>> >>No. That's not how a modem works. It doesn't have the ability to pass the raw audio data through to you, nor to accept digital PCM data and ship it out the speaker. > >Well not exactly true ;) Some modems can capture audio and send it to computer. With most raw data is in proprietary format, but some drivers make it accessible as multimedia audio device. Try pygame or pymedia. Thanks Kiki, pyMedia has a lot of audio possibilities, as do other modules, but I'm looking for the specific port/calls/interface that other apps use to do it. All my old modems had answering machine software, probably VB or C++; so basically, how did they do it? And, the 2 current VOIP Python packages I saw do it with ISDN modems http://0pointer.de/lennart/projects/ivam2/#overview so I the digitized data must be available via a port or a dll call. There are a number of Linux packages that are answering machines: http://frank.harvard.edu/~coldwell/answering_machine/ There is a PERL version http://www.fi.muni.cz/~kas/vgetty/ called mgetty-voice using http://mgetty.greenie.net/ I was just hoping to find something close to it and cross-platform already in Python... Ray From joe_magic at skynet.be Tue Nov 23 22:53:08 2004 From: joe_magic at skynet.be (magic joe) Date: Tue Nov 23 22:57:25 2004 Subject: [python-win32] execfile question In-Reply-To: <20041122190824.7437F1E400D@bag.python.org> Message-ID: I have a program generating dynamic code which is then launched with : execfile(file_out) However generated import statements appear not to work, only the modules that are imported in the program doing the exec call are recognized. How can I fix this ? (Well one way is importing everything in the calling module but that is a little bit ugly and may lead to huge load time ) ie: file contains: import time def f: return time.localtime() # 43 NameError: global name 'time' is not defined --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.786 / Virus Database: 532 - Release Date: 29/10/2004 From koliphant at qwest.net Tue Nov 23 23:18:53 2004 From: koliphant at qwest.net (Kerry Oliphant) Date: Tue Nov 23 23:14:44 2004 Subject: [python-win32] execfile question In-Reply-To: Message-ID: I have code that does what you are trying to do. It should work. I tried your little code snippet and it chokes for me on "def f:" shouldn't it be "def f():"? Or is that just a typo in your email. Kerry -----Original Message----- From: python-win32-bounces+koliphant=qwest.net@python.org [mailto:python-win32-bounces+koliphant=qwest.net@python.org]On Behalf Of magic joe Sent: Tuesday, November 23, 2004 2:53 PM To: python-win32@python.org Subject: [python-win32] execfile question I have a program generating dynamic code which is then launched with : execfile(file_out) However generated import statements appear not to work, only the modules that are imported in the program doing the exec call are recognized. How can I fix this ? (Well one way is importing everything in the calling module but that is a little bit ugly and may lead to huge load time ) ie: file contains: import time def f: return time.localtime() # 43 NameError: global name 'time' is not defined --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.786 / Virus Database: 532 - Release Date: 29/10/2004 _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From rogerb at rogerbinns.com Wed Nov 24 07:22:15 2004 From: rogerb at rogerbinns.com (Roger Binns) Date: Wed Nov 24 07:22:09 2004 Subject: [python-win32] Getting multiple properties in one go Message-ID: I have some code that is reading Outlook contacts, but it is very slow. I need to get every field/property of each contact. I get the list of known keys using: keys=[] for key in contact._prop_map_get_: # work out if it is a property or a method (last field is None for properties) if contact._prop_map_get_[key][-1] is None: keys.append(key) Then for each contact, I do this: record={} for key in keys: v=getattr(contact, key) if v not in (None, "", "\x00\x00"): if isinstance(v, pywintypes.TimeType): # convert from com time try: v=int(v) except ValueError: # illegal time value continue record[key]=v According to hotshot, the vast majority of my runtime is consumed by the _ApplyTypes_ function in the pythoncom wrappers. This is invoked by the getattr above. And most of the time the vast majority of the fields are empty. Is there a better way of getting all the properties without getting them one by one? Ideally I would like a C level function that I can give the desired list to, and have it return a dict, discarding those that are NULL or empty strings. There are typically 35 properties per record, and so reading 1,000 records involves 35,000 calls through the getattr stuff above. On my Athlon XP 2800 that takes around 70 seconds. Roger From mhammond at skippinet.com.au Wed Nov 24 11:22:52 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed Nov 24 11:23:01 2004 Subject: [python-win32] Getting multiple properties in one go In-Reply-To: Message-ID: <178201c4d20f$8f066580$040a0a0a@enfoldsystems.local> > I have some code that is reading Outlook contacts, but it is > very slow. > I need to get every field/property of each contact. I get the list > of known keys using: You probably want to investigate win32com.mapi. Check out the dump_props.py sample from SpamBayes (in the spambayes\Outlook2000\sandbox directory - view it via CVS at sourceforge) Mark From timr at probo.com Wed Nov 24 20:45:59 2004 From: timr at probo.com (Tim Roberts) Date: Wed Nov 24 20:46:03 2004 Subject: [python-win32] phone/modem recording recipe? In-Reply-To: <20041124110038.979EC1E403A@bag.python.org> References: <20041124110038.979EC1E403A@bag.python.org> Message-ID: <41A4E4F7.2030302@probo.com> On Tue, 23 Nov 2004 07:44:41 -0800, RayS wrote: > > > >>>>>On Mon, 22 Nov 2004 07:09:03 -0800, RayS wrote: >>>>> >>> >>> >>>>>>>I was reviewing win32ras, pyserial and such last night, and I found two Python VOIP packages (for ISDN), but in short, I would just like to capture/send from a POTS handset via the modem. Like video/audio capture, except with a modem. >>>> >hanks Kiki, > >pyMedia has a lot of audio possibilities, as do other modules, but I'm looking for the specific port/calls/interface that other apps use to do it. ... > >And, the 2 current VOIP Python packages I saw do it with ISDN modems >http://0pointer.de/lennart/projects/ivam2/#overview >so I the digitized data must be available via a port or a dll call. > > That's an entirely different thing altogether. ISDN lines are digital from end-to-end. That's what the "D" stands for. Even the voice channels are digital. The term "ISDN modem" is incorrect, because there isn't actually any demodulating going on. The term should be "ISDN terminal adapter". It is basically a demultiplexor, not unlike a net card.. >There are a number of Linux packages that are answering machines: >http://frank.harvard.edu/~coldwell/answering_machine/ > > But notice that this has only been tested with three very specific modems, which are advertised as having voice support. -- - Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc. From joe_magic at skynet.be Wed Nov 24 19:08:10 2004 From: joe_magic at skynet.be (magic joe) Date: Thu Nov 25 15:46:12 2004 Subject: [python-win32] RE: execfile question In-Reply-To: Message-ID: Yes ofcourse it should be def f() but the generated file which is much larger than this fragment by itself works but when you run it from execfile() inside an environment without the import it does not. If the file containing execfile already imported time then it also works. .... I have a program generating dynamic code which is then launched with : execfile(file_out) However generated import statements appear not to work, only the modules that are imported in the program doing the exec call are recognized. How can I fix this ? (Well one way is importing everything in the calling module but that is a little bit ugly and may lead to huge load time ) ie: file contains: import time def f: return time.localtime() # 43 NameError: global name 'time' is not defined --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.786 / Virus Database: 532 - Release Date: 29/10/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.786 / Virus Database: 532 - Release Date: 29/10/2004 From rogerb at rogerbinns.com Wed Nov 24 17:17:55 2004 From: rogerb at rogerbinns.com (Roger Binns) Date: Thu Nov 25 15:46:27 2004 Subject: [python-win32] Getting multiple properties in one go References: <178201c4d20f$8f066580$040a0a0a@enfoldsystems.local> Message-ID: <006801c4d241$27f4d340$3501a8c0@rogersqyvr14d3> > You probably want to investigate win32com.mapi. Check out the dump_props.py > sample from SpamBayes (in the spambayes\Outlook2000\sandbox directory - view > it via CVS at sourceforge) I don't think all the fields available via the VB COM API to Outlook are available via the MAPI api. Do you know if the performance is better via MAPI, since changing my code is going to take quite a while. Roger From niki at vintech.bg Thu Nov 25 16:42:56 2004 From: niki at vintech.bg (Niki Spahiev) Date: Thu Nov 25 16:43:14 2004 Subject: [python-win32] Re: how to load 2 python COM DLLs in single app? In-Reply-To: References: <4177E7A3.9030000@vintech.bg> <08c701c4b7b2$c7efcde0$0300a8c0@enfoldsystems.local> <41791964.9060107@vintech.bg> <4179333E.4090700@vintech.bg> <8y9yllih.fsf@python.net> <41823999.6050709@vintech.bg> Message-ID: <41A5FD80.1080300@vintech.bg> SUCCESS! Renaming scheme works for me (TM) and i can load 2 Inprocess COM servers. Attached patch is for py2exe 0.54 Option --unique=MN turns on renaming. MN are any 2 characters valid for filename. No debug-python support (_d.pyd). Thomas will you include it in py2exe? Niki Spahiev -------------- next part -------------- --- C:\Python23\Lib\site-packages\py2exe\build_exe.pyw Fri Oct 22 17:32:32 2004 +++ C:\Python23\Lib\site-packages\py2exe\build_exe.py Thu Nov 25 17:33:51 2004 @@ -69,6 +69,19 @@ del __load """ +BOOT_UNIQUE = """ +def __load(name,ext): + import imp, sys + dirname = sys.prefix + path = dirname + '/' + name + ext + mod = imp.load_dynamic(name, path) +## mod.frozen = 1 +__load('zlib','%(UN)s.pyd') +__load('pywintypes','%(UN)s.dll') +__load('pythoncom','%(UN)s.dll') +del __load +""" + # A very loosely defined "target". We assume either a "script" or "modules" # attribute. Some attributes will be target specific. class Target: @@ -139,7 +152,10 @@ "create a compressed zipfile"), ("xref", 'x', - "create and show a module crosss reference") + "create and show a module crosss reference"), + + ("unique", 'u', + "patch all DLLs to be unique"), ] boolean_options = ["compressed", "xref"] @@ -156,6 +172,7 @@ self.dist_dir = None self.dll_excludes = None self.typelibs = None + self.unique = '' def finalize_options (self): self.optimize = int(self.optimize) @@ -359,7 +376,10 @@ # magic which relies on this exact filename. # So we do it via a custom loader - see create_loader() dst = os.path.join(self.lib_dir, os.path.basename(item.__file__)) - self.copy_file(src, dst) + dst = patch_filename(dst, self.unique) + where,copied = self.copy_file(src, dst) + if copied: + patch_python_dll_import(where, self.unique) self.lib_files.append(dst) # create the shared zipfile containing all Python modules @@ -384,7 +404,10 @@ dst = os.path.join(self.exe_dir, base) else: dst = os.path.join(self.lib_dir, base) - self.copy_file(dll, dst) + dst = patch_filename(dst, self.unique) + where,copied = self.copy_file(dll, dst) + if copied: + patch_python_dll_import(where, self.unique) self.lib_files.append(dst) for target in self.distribution.isapi: @@ -577,6 +600,7 @@ old_force = self.force self.force = True self.copy_file(src, exe_path) + patch_python_dll_import(exe_path, self.unique) self.force = old_force # Make sure the file is writeable... @@ -602,6 +626,10 @@ code_object = compile(open(script, "U").read() + "\n", os.path.basename(script), "exec") code_objects.append(code_object) + if self.unique: + code_object = compile(BOOT_UNIQUE % dict(UN=self.unique), + "boot_unique", "exec") + code_objects.insert(0,code_object) code_bytes = marshal.dumps(code_objects) if self.distribution.zipfile is None: @@ -881,6 +909,7 @@ print "creating python loader for extension '%s'" % item.__name__ fname = os.path.basename(item.__file__) + fname = patch_filename(fname, self.unique) source = LOADER % fname if not self.dry_run: open(pathname, "w").write(source) @@ -1307,3 +1336,45 @@ if verbose: print grok_environment_error( exc, "error removing %s: " % directory) + +def patch_filename(fn, AB): + base = os.path.basename(fn).lower() + if not AB or base.startswith('tcl') or base.startswith('tk'): + return fn + pv = '%d%d' % sys.version_info[:2] + fn, ext = os.path.splitext( fn ) + if fn.endswith( pv ): + fn = fn[:-2] + fn += AB+ext + return fn + +def patch_python_dll_import(dll_name, AB): + base = os.path.basename(dll_name).lower() + if not AB or base.startswith('tcl') or base.startswith('tk'): + return + pv = '%d%d' % sys.version_info[:2] + # We preserve the times on the file, so the dependency tracker works. + st = os.stat(dll_name) + os.chmod(dll_name, stat.S_IREAD | stat.S_IWRITE) + f = open(dll_name, "r+b") + bytes = f.read() + for import_name in (python_dll, 'pywintypes%s.dll'%pv, + 'pythoncom%s.dll'%pv, 'pythoncom%s%s%s.dll\0'): + pos = bytes.find( import_name ) + if pos < 0: + if import_name == python_dll: + raise RuntimeError(import_name+' not in '+dll_name) + continue + dup = bytes.find(import_name, pos+1) + if dup >= 0 and pv in import_name: + raise RuntimeError('multi '+import_name) + if pv in import_name: + r = import_name.replace( pv, AB ) + else: + r = import_name.replace( '%s%s%s', AB ) + f.seek( pos, 0 ) + f.write( r ) + f.close() + + # restore the time. + os.utime(dll_name, (st[stat.ST_ATIME], st[stat.ST_MTIME])) From mhammond at skippinet.com.au Thu Nov 25 23:10:56 2004 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu Nov 25 23:11:03 2004 Subject: [python-win32] Getting multiple properties in one go In-Reply-To: <006801c4d241$27f4d340$3501a8c0@rogersqyvr14d3> Message-ID: <01b101c4d33b$a3db3580$0300a8c0@enfoldsystems.local> > > You probably want to investigate win32com.mapi. Check out > the dump_props.py > > sample from SpamBayes (in the spambayes\Outlook2000\sandbox > directory - view > > it via CVS at sourceforge) > > I don't think all the fields available via the VB COM API to Outlook > are available via the MAPI api. I'm fairly certain all mail related fields are available - some of the Contacts fields may not, but I suspect most are. > Do you know if the performance is better via MAPI, since changing my > code is going to take quite a while. Much much faster - orders of magnitude generally, especially when fetching many. Mark. From theller at python.net Fri Nov 26 17:25:26 2004 From: theller at python.net (Thomas Heller) Date: Fri Nov 26 17:24:40 2004 Subject: [python-win32] Re: how to load 2 python COM DLLs in single app? References: <4177E7A3.9030000@vintech.bg> <08c701c4b7b2$c7efcde0$0300a8c0@enfoldsystems.local> <41791964.9060107@vintech.bg> <4179333E.4090700@vintech.bg> <8y9yllih.fsf@python.net> <41823999.6050709@vintech.bg> <41A5FD80.1080300@vintech.bg> Message-ID: Niki Spahiev writes: > SUCCESS! > > Renaming scheme works for me (TM) and i can load 2 Inprocess COM servers. > Attached patch is for py2exe 0.54 Cool! > Option --unique=MN turns on renaming. MN are any 2 characters valid > for filename. Are two characters enough? Four would be better, imo. > No debug-python support (_d.pyd). > > Thomas will you include it in py2exe? My impression is that the patch still needs some work. First, it didn't apply completely to the CVS version - that's not your fault, I've made other changes in the meantime. Second, I had to make this change so that the unique option accepts a parameter: > + ("unique", 'u', > + "patch all DLLs to be unique"), must be changed to > + ("unique=", 'u', ^ > + "patch all DLLs to be unique"), Third, it doesn't work for other cases ;-). It tries to patch all dlls, except those that start with 'tcl' or 'tk'. For the 'simple' sample in the distribution, it fails patching the wxwindows dll, plus the w9xpopen.exe helper. IMO it would be better to first check whether a dll or an exe dynamically links to python23.dll, and only if it does the renaming and patching would take place. For finding out the dlls an image links to, the py2exe_util extension's 'depends' function could be used. Then, if I understand correctly, you simple replace all occurrences of 'python23.dll' in the image by the changed name. Wouldn't this be required to be case sesitive? And wouldn't it be required to only make this change in the import table (maybe you take care of this by only replaing the first string you find). Other comments: > +BOOT_UNIQUE = """ > +def __load(name,ext): > + import imp, sys > + dirname = sys.prefix > + path = dirname + '/' + name + ext > + mod = imp.load_dynamic(name, path) > +## mod.frozen = 1 > +__load('zlib','%(UN)s.pyd') > +__load('pywintypes','%(UN)s.dll') > +__load('pythoncom','%(UN)s.dll') > +del __load > +""" Why zlib? It may or may not be included... All in all, this is pretty cool, but still needs work, and there are a lot of details to get correct. Thanks, Thomas From wyvernlist at crm3.com Fri Nov 26 20:25:10 2004 From: wyvernlist at crm3.com (Jan Van Uytven (Wyvern)) Date: Fri Nov 26 20:25:15 2004 Subject: [python-win32] WMI Security Access? Message-ID: <1101497110.7193.8.camel@localhost> I'm trying to use wmi to 'catch' events as they are being sent to the event log. >>> import wmi >>> c=wmi.WMI() >>> event_watcher=c.watch_for (notification_type="Creation",wmi_class="Win32_NTLogEvent") C:\Python23\lib\site-packages\wmi.py:126: FutureWarning: hex()/oct() of negative int will return a signed string in Python 2.4 and up exception_string = ["%s - %s" % (hex (hresult_code), hresult_name)] C:\Python23\lib\site-packages\wmi.py:130: FutureWarning: hex()/oct() of negative int will return a signed string in Python 2.4 and up exception_string.append (" %s - %s" % (hex (scode), error_description.strip ())) Traceback (most recent call last): File "", line 1, in ? File "C:\Python23\Lib\site-packages\wmi.py", line 658, in watch_for handle_com_error (error_info) File "C:\Python23\Lib\site-packages\wmi.py", line 131, in handle_com_error raise x_wmi, "\n".join (exception_string) x_wmi: 0x80020009 - Exception occurred. Error in: SWbemServicesEx 0x80041003 - Access denied >>> What is causing this issue? I have it when logged in as a domain admin on XP Pro or as 'computer administrator' on XP Home, but not when logged in as an administrator on a Windows 2003 server. Can someone shed light on this? Thanks, Jan --- Jan Van Uytven Computer Systems & Network Engineer Convergent Media Network wyvern@crm3.com >>> LEGAL STUFF <<< This electronic message transmission, including any attached files, contains information which may be confidential and/or privileged. The information is intended to be for the SOLE use of the individual or entity named above. If you are not the intended recipient, be aware that any review, disclosure, copying, distribution or use of the contents of this information is prohibited. This message is not to be forwarded for any reason without prior consent of the sender. If you have received this electronic transmission in error, please notify the sender immediately by telephone (250) 386-4266 or by a 'reply to sender only' message and destroy all electronic and hard copies of the communication, including attachments, without reading or saving in any manner. From niki at vintech.bg Mon Nov 29 09:40:11 2004 From: niki at vintech.bg (Niki Spahiev) Date: Mon Nov 29 09:40:24 2004 Subject: [python-win32] Re: how to load 2 python COM DLLs in single app? In-Reply-To: References: <4177E7A3.9030000@vintech.bg> <08c701c4b7b2$c7efcde0$0300a8c0@enfoldsystems.local> <41791964.9060107@vintech.bg> <4179333E.4090700@vintech.bg> <8y9yllih.fsf@python.net> <41823999.6050709@vintech.bg> <41A5FD80.1080300@vintech.bg> Message-ID: <41AAE06B.9040400@vintech.bg> Thomas Heller wrote: > Are two characters enough? Four would be better, imo. Only two because i replace python23.dll with pythonMN.dll > Second, I had to make this change so that the unique option accepts a > parameter: > >>+ ("unique", 'u', >>+ "patch all DLLs to be unique"), > > must be changed to > >>+ ("unique=", 'u', > > ^ > >>+ "patch all DLLs to be unique"), OK > Third, it doesn't work for other cases ;-). It tries to patch all dlls, > except those that start with 'tcl' or 'tk'. For the 'simple' sample in > the distribution, it fails patching the wxwindows dll, plus the > w9xpopen.exe helper. I will fix that. It's meant for COM servers only not as universal solution. Probably wxwindows dll won't work if loaded twice and patching all references to it seems impossible. > > IMO it would be better to first check whether a dll or an exe > dynamically links to python23.dll, and only if it does the renaming and > patching would take place. For finding out the dlls an image links to, > the py2exe_util extension's 'depends' function could be used. OK > Then, if I understand correctly, you simple replace all occurrences of > 'python23.dll' in the image by the changed name. Wouldn't this be > required to be case sesitive? And wouldn't it be required to only make > this change in the import table (maybe you take care of this by only > replaing the first string you find). I replace only single reference. If there are more exception is raised. > Other comments: > > >>+BOOT_UNIQUE = """ >>+def __load(name,ext): >>+ import imp, sys >>+ dirname = sys.prefix >>+ path = dirname + '/' + name + ext >>+ mod = imp.load_dynamic(name, path) >>+## mod.frozen = 1 >>+__load('zlib','%(UN)s.pyd') >>+__load('pywintypes','%(UN)s.dll') >>+__load('pythoncom','%(UN)s.dll') >>+del __load >>+""" > > Why zlib? It may or may not be included... Because without zlib import from zip file is impossible :) Niki From p.f.moore at gmail.com Mon Nov 29 10:09:51 2004 From: p.f.moore at gmail.com (Paul Moore) Date: Mon Nov 29 10:09:54 2004 Subject: [python-win32] Re: how to load 2 python COM DLLs in single app? In-Reply-To: <41AAE06B.9040400@vintech.bg> References: <4177E7A3.9030000@vintech.bg> <41791964.9060107@vintech.bg> <4179333E.4090700@vintech.bg> <8y9yllih.fsf@python.net> <41823999.6050709@vintech.bg> <41A5FD80.1080300@vintech.bg> <41AAE06B.9040400@vintech.bg> Message-ID: <79990c6b04112901092e202e42@mail.gmail.com> On Mon, 29 Nov 2004 10:40:11 +0200, Niki Spahiev wrote: > > Why zlib? It may or may not be included... > > Because without zlib import from zip file is impossible :) IIRC, if zlib isn't present, you can still import from uncompressed zip files... (Quick check, yes that works...) Paul. From tim.golden at viacom-outdoor.co.uk Mon Nov 29 11:12:48 2004 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon Nov 29 11:12:59 2004 Subject: [python-win32] WMI Security Access? Message-ID: [Jan Van Uytven (Wyvern)] | I'm trying to use wmi to 'catch' events as they are being sent to the | event log. | | >>> import wmi | >>> c=wmi.WMI() | >>> event_watcher=c.watch_for | (notification_type="Creation",wmi_class="Win32_NTLogEvent") I seem to remember (and WMI security is often a messy business) that you need to acquire the Security privilege before interrogating event logs -- at least on some systems. Have a look at this example: http://tgolden.sc.sabren.com/python/wmi_cookbook.html#monitor_error_events 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 python at kareta.de Mon Nov 29 11:45:49 2004 From: python at kareta.de (=?ISO-8859-1?B?SvxyZ2VuIEthcmV0YQ==?=) Date: Mon Nov 29 11:56:00 2004 Subject: [python-win32] RE: os.popen/winpipe Message-ID: <1101725149.41aafddd5fe6b@webmail.ldc.de> Hello Tony, >Hello > >May I ask where you found this ? > >>'net use lpt2: \\server\printer' try 'net use ?' in the windows shell >I've never seen this before- and it looks very interesting. >I'd like to see what else can be done using this syntax- and other. google for 'unc path' > >thanks regards, J?rgen From craig at coot.net Tue Nov 30 16:52:33 2004 From: craig at coot.net (Craig H. Anderson) Date: Tue Nov 30 17:00:27 2004 Subject: [python-win32] Service not seen in Services list on XP? Message-ID: I am working on a windows service with info from Chapter 18 of Mark Hammond's book, Python Programming on Win32. The OS is Windows XP Pro. I can register and start the service by running the script with command line arguments install and start respectively. The event viewer shows the logs properly. I do not see PythonService or my service in the Services panel. I want the service to be auto started and start/stop available from the services panel. What is going on? From paandev at yahoo.com Tue Nov 30 20:25:09 2004 From: paandev at yahoo.com (Wara Songkran) Date: Tue Nov 30 20:25:35 2004 Subject: [python-win32] How to use Common Controls Message-ID: <20041130192509.26686.qmail@web51306.mail.yahoo.com> Hi I've try to use Common Controls like Date and Time Picker I Initializes specific common controls with win32gui.InitCommonControlsEx(flag) the parameter ICC_ constants is 256 which is ICC_DATE_CLASSES I found defined in COMMCTRL.h so I've call ICC_DATE_CLASSES = 0x00000100 win32gui.InitCommonControlsEx(ICC_DATE_CLASSES) but when I try to create Date and Time Picker Control with dateHwnd = CreateWindow("MONTHCAL_CLASS", None, WS_CHILD | WS_VISIBLE, 300, 300, 50, 50, self.hwnd, 0, GetWindowLong(self.hwnd, GWL_HINSTANCE), None) python report error: (1407, 'CreateWindow', 'Cannot find window class.') please help. Regard Wara Songkran --------------------------------- Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20041130/ec57d056/attachment.htm