From mhammond at skippinet.com.au Fri Jul 1 00:09:29 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 1 Jul 2005 08:09:29 +1000 Subject: [python-win32] detect mapped network path In-Reply-To: <571247205063000383376501c@mail.gmail.com> Message-ID: <05cd01c57dc0$6353db40$090a0a0a@enfoldsystems.local> > ..but how do i find out if let's say X:\foo\bar\blarg.baz is a local > path or in fact a mapped network path? win32api.GetLogicalDriveStrings() may also help. Mark From simon.dahlbacka at gmail.com Fri Jul 1 08:21:23 2005 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Fri, 1 Jul 2005 09:21:23 +0300 Subject: [python-win32] detect mapped network path In-Reply-To: <05cd01c57dc0$6353db40$090a0a0a@enfoldsystems.local> References: <571247205063000383376501c@mail.gmail.com> <05cd01c57dc0$6353db40$090a0a0a@enfoldsystems.local> Message-ID: <57124720506302321615e5ba8@mail.gmail.com> On 7/1/05, Mark Hammond wrote: > > ..but how do i find out if let's say X:\foo\bar\blarg.baz is a local > > path or in fact a mapped network path? > > win32api.GetLogicalDriveStrings() may also help. I was going to say that it does not help, but then I found win32file.GetDriveType so for future reference, here is a solution that WorksForMe(tm) >>> def IsMappedDrive(name): ... allDrives = win32api.GetLogicalDriveStrings().split("\x00") ... return name.upper() in [drive for drive in allDrives if win32file.GetDriveType(drive) == win32file.DRIVE_REMOTE] >>> IsMappedDrive("z:\\") True >>> IsMappedDrive("c:\\") False ..so thanks for the pointer /Simon From gijs at globaltrack.com Fri Jul 1 14:36:29 2005 From: gijs at globaltrack.com (gijs@globaltrack.com) Date: Fri, 1 Jul 2005 14:36:29 +0200 Subject: [python-win32] coinitialize problem Message-ID: <1120221389.42c538cd6290f@mail.globaltrack.com> Hi, I'm extending a Python application that uses several com objects and threads. The origional programmer set the main thread to multithreaded by doing this: * sys.coinit_flags = 0 * import pythoncom This is nessacary because otherwise a com (MapObjects2 from ESRI) can't run in a thread, but now I need to use another com object, which is running in a thread as well. This com object, made by one of our clients, needs to run in a single threading model. For some reason, these two com object won't work together in one application. MapObjects2 works when the coini_flags is set to 0 but then the other com object isn't working and the other way around. I've tried a lot of things to solve this: 1) don't import pythoncom in the main thread -- set the mapobjects thread with coInitializeEx(COINIT_MULTITHREADED) -- set the other trhead with CoInitialize() 2) tried the same things but then with initializing coinit in the mainthread with both models 3) Made a some test programs, but I had always the same problems, except when I made 2 functions for the 2 com objects, and started them with beginthreadex (like described on page 626 from Mark Hammonds book Python programming on win32) and then coinitialize in the functions, but unfortunately, this is not an option in our main program Strange enough, we use 2 other comobjects, adotable for mssql and a com object for sending smses, and these two are always working. Can anyone help me with a solution? and maybe som examples? Kind Regards, Gijs -- This message has been scanned for viruses and dangerous content by Network Sentry, and is believed to be clean. http://www.networksentry.co.za From p.f.moore at gmail.com Fri Jul 1 17:28:28 2005 From: p.f.moore at gmail.com (Paul Moore) Date: Fri, 1 Jul 2005 16:28:28 +0100 Subject: [python-win32] detect mapped network path In-Reply-To: <57124720506302321615e5ba8@mail.gmail.com> References: <571247205063000383376501c@mail.gmail.com> <05cd01c57dc0$6353db40$090a0a0a@enfoldsystems.local> <57124720506302321615e5ba8@mail.gmail.com> Message-ID: <79990c6b05070108281db2ce2@mail.gmail.com> On 7/1/05, Simon Dahlbacka wrote: > On 7/1/05, Mark Hammond wrote: > > > ..but how do i find out if let's say X:\foo\bar\blarg.baz is a local > > > path or in fact a mapped network path? > > > > win32api.GetLogicalDriveStrings() may also help. > > I was going to say that it does not help, but then I found > win32file.GetDriveType > > so for future reference, here is a solution that WorksForMe(tm) > > >>> def IsMappedDrive(name): > ... allDrives = win32api.GetLogicalDriveStrings().split("\x00") > ... return name.upper() in [drive for drive in allDrives if > win32file.GetDriveType(drive) == win32file.DRIVE_REMOTE] > > >>> IsMappedDrive("z:\\") > True > >>> IsMappedDrive("c:\\") > False Um, surely def IsMappedDrive(name): return win32file.GetDriveType(name) == win32file.DRIVE_REMOTE works, in that case...? Paul. From mhammond at skippinet.com.au Sun Jul 3 10:06:05 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 3 Jul 2005 18:06:05 +1000 Subject: [python-win32] coinitialize problem In-Reply-To: <1120221389.42c538cd6290f@mail.globaltrack.com> Message-ID: <09c501c57fa6$10daca80$090a0a0a@enfoldsystems.local> > I'm extending a Python application that uses several com > objects and threads. > The origional programmer set the main thread to multithreaded > by doing this: > * sys.coinit_flags = 0 > * import pythoncom > This is nessacary because otherwise a com (MapObjects2 from > ESRI) can't run in > a thread, but now I need to use another com object, which is > running in a > thread as well. What do you mean exactly by "running in a thread"? Do these objects run in their own thread, or is there only a single thread that uses both objects? It is critically important that any threads you create follow the COM rules regarding marshalling of COM objects to other threads. Not doing that can cause strange results. See below for more details. > This com object, made by one of our clients, > needs to run in a > single threading model. For some reason, these two com object > won't work > together in one application. MapObjects2 works when the > coini_flags is set to 0 > but then the other com object isn't working and the other way around. They should be able to run together in the same process, but possibly not in the same thread. That's unusual though - most free-threaded applications set their threading model to be "both" - meaning that if a single-threaded apartment tries to use it, it can. What is the exact error you get? > 3) Made a some test programs, but I had always the same > problems, except when > I made 2 functions for the 2 com objects, and started them > with beginthreadex > (like described on page 626 from Mark Hammonds book Python > programming on > win32) and then coinitialize in the functions, but > unfortunately, this is not > an option in our main program You should read appendix D (Threads), and specifically the information regarding COM threading models. It is very important you undertand COMs threading model when trying to do these things. What you may be able to do is spin up a new thread *just* to create the free-threaded object - then use CoMarshalThreadInterfaceInStream() to marshal it back to your main (single-threaded apartment) thread, and use it from there. > Strange enough, we use 2 other comobjects, adotable for mssql > and a com object > for sending smses, and these two are always working. Almost certainly because these objects are marked as supporting "both" threading models, so don't care what apartment they are created from. Mark From simon.dahlbacka at gmail.com Mon Jul 4 07:49:28 2005 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Mon, 4 Jul 2005 08:49:28 +0300 Subject: [python-win32] detect mapped network path In-Reply-To: <79990c6b05070108281db2ce2@mail.gmail.com> References: <571247205063000383376501c@mail.gmail.com> <05cd01c57dc0$6353db40$090a0a0a@enfoldsystems.local> <57124720506302321615e5ba8@mail.gmail.com> <79990c6b05070108281db2ce2@mail.gmail.com> Message-ID: <57124720507032249a4d0228@mail.gmail.com> On 7/1/05, Paul Moore wrote: > On 7/1/05, Simon Dahlbacka wrote: > > On 7/1/05, Mark Hammond wrote: > > > > ..but how do i find out if let's say X:\foo\bar\blarg.baz is a local > > > > path or in fact a mapped network path? > > > > > > win32api.GetLogicalDriveStrings() may also help. > > > > I was going to say that it does not help, but then I found > > win32file.GetDriveType > > > > so for future reference, here is a solution that WorksForMe(tm) > > > > >>> def IsMappedDrive(name): > > ... allDrives = win32api.GetLogicalDriveStrings().split("\x00") > > ... return name.upper() in [drive for drive in allDrives if > > win32file.GetDriveType(drive) == win32file.DRIVE_REMOTE] > > > > >>> IsMappedDrive("z:\\") > > True > > >>> IsMappedDrive("c:\\") > > False > > Um, surely > > def IsMappedDrive(name): > return win32file.GetDriveType(name) == win32file.DRIVE_REMOTE > hmm.. well yes, (apart from the fact that GetDriveType expects just :\ ) I guess I should think before posting examples next time ;) /Simon From martin.kuner at thomson.net Mon Jul 4 15:25:47 2005 From: martin.kuner at thomson.net (Kuner Martin) Date: Mon, 4 Jul 2005 15:25:47 +0200 Subject: [python-win32] Activex call delivers only unicode string, but ASCII is needed Message-ID: <5FBC042194FEC54C9EFEA97D1EA8B3680140E6CB@villsmail01.eu.thmulti.com> Hi list, I have the following code to call a LabVIEW VI via the Activex interface. The string "strDataOut" holds the expected data result of the call . Now I realized that the string coming back from the ActiveX call contains Unicode and that is fatal! The string on the Python side should always be ASCII. I found no way to convert them back, strDataOut.enocde() raises a exception when I try to convert to ASCII Here?s the relevant code. intCmdcnt = 0; strDataOut = r"" cluError = [False,0,""] cluSenseKey = [0,0,0] print "strDataOut = %r" % strDataOut arParNames = ["intChannel","strCDB","strDataIn","intDirection", "intLength","cluError","cluSenseKey","intCmdcnt","strDataOut"] arParVals = [0, strCDB, strBuffer, intDataToHost,intBuffLen, cluError, cluSenseKey, intCmdcnt, strDataOut] retval = self.__refGenericATAPI.Call(arParNames, arParVals) # call VI print retval The printout: strDataOut = '' ((u'intChannel', u'strCDB', u'strDataIn', u'intDirection', u'intLength', u'cluError', u'cluSenseKey', u'intCmdcnt', u'strDataOut'), (0, u'\xa8\x08\x00\x10\x00\x00\x00\x00\x00\x10\x00\x00', u'', 1, 16, (False, 0, u''), (0, 0, 0), 37, u'\x00\x00\x01\xbaD\xa5?\x14\x0c\xab\x01\u2030\xc3\xf8\x00\x00')) Here?s another data example: String on LabVIEW side : 00 00 01 BA 44 A5 3F 14 0C AB 01 89 C3 F8 00 00 String on python side u'\x00\x00\x01\xbaD\xa5?\x14\x0c\xab\x01\u2030\xc3\xf8\x00\x00' Any ideas ? Thanks, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050704/2f01b5fd/attachment.htm From guy.lateur at b-b.be Mon Jul 4 16:36:08 2005 From: guy.lateur at b-b.be (Guy Lateur) Date: Mon, 4 Jul 2005 16:36:08 +0200 Subject: [python-win32] Outlook COM: how to create a MailItem from a .msg file Message-ID: Hi again, I've also tried using my_MItem = win32com.client.CastTo(my_DItem, 'MailItem'), but it doesn't work. It says "The interface name 'MailItem' does not appear in the same library as object '". Any help would be greatly appreciated. g ________________________________ From: Guy Lateur Sent: donderdag 30 juni 2005 10:53 To: 'python-win32 at python.org' Subject: Outlook COM: how to create a MailItem from a .msg file Hi all, I've been writing some code to move some data into and out of Outlook (2003 + Exchange 2003). I have some email .msg files on our file server, and I can't seem to get them back into the Outlook object I need, ie a MailItem. I've tried to use App.CopyFile() to (temporarily) put the file in an OL folder. Problem is, however, this returns a DocumentItem and not a MailItem. Is there any way I could 'cast' this DItem into a MItem? Apparently, OL treats it as any general document - which, btw, shows in the view, too; it has another icon and you have to open it to view it). Or maybe there's another way to open it; I really only need the object in memory. Any ideas? TIA, g PS: This may get double-posted due to some subscription issues I was having earlier. Sorry for the inconvenience. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050704/a5ffce64/attachment.htm From jbrunen at datasolid.de Mon Jul 4 11:11:03 2005 From: jbrunen at datasolid.de (Johannes Brunen) Date: Mon, 4 Jul 2005 11:11:03 +0200 Subject: [python-win32] COM server AddIn Message-ID: <23D83A07C60A0E47AD964F74DA96940102936F@mail.datasolid.de> Hi, I have a problem implementing a simple COM server AddIn which should satisfy a special COM interface provided by an application I'm using. The server application: CADdy.exe => type library CADdy.tlb The AddIn interface of CADdy.tlb: ICADdyAddIn From gencache.EnsureModule('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 2, bForDemand=True) # CADdy.tlb I got class ICADdyAddIn(DispatchBaseClass): """ICADdyAddIn Interface""" CLSID = IID('{14F65AE1-4671-11D4-8B1A-00105A49278B}') coclass_clsid = None def Exit(self): """method Exit""" return self._oleobj_.InvokeTypes(2, LCID, 1, (24, 0), (),) def Init(self, theCADdy=defaultNamedNotOptArg): """method Init""" return self._oleobj_.InvokeTypes(1, LCID, 1, (24, 0), ((9, 1),),theCADdy ) _prop_map_get_ = { "CLSID": (3, 2, (8, 0), (), "CLSID", None), "Description": (5, 2, (8, 0), (), "Description", None), "ProgId": (4, 2, (8, 0), (), "ProgId", None), } _prop_map_put_ = { } My AddIn COM server Addin.py: ## ## Addin1.py - A very simple CADdy AddIn COM server ## from win32com import universal from win32com.client import gencache import pythoncom import sys gencache.EnsureModule('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 2, bForDemand=True) # CADdy.tlb universal.RegisterInterfaces('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 2, ['ICADdyAddIn']) class AddIn1: _com_interfaces_ = ['ICADdyAddIn'] _public_methods_ = [] _reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER _reg_clsid_ = "{AB6C657A-2C26-4BD0-ABB8-D777BC91F199}" # From pythoncom.CreateGuid() _reg_progid_ = "CADdyAddIn.PythonTest1" _reg_policy_spec_ = "win32com.server.policy.EventHandlerPolicy" def __init__(self): self.appHostApp = None def Init(self, theCADdy): """method Init""" self.appHostApp = theCADdy def Exit(self): """method Exit""" self.appHostApp = None def getCLSID(self): return _reg_clsid_ def getProgId(self): return _reg_progid_ def getDescription(self): return "CADdy++ CADdyAddIn.PythonTest1" if __name__ == '__main__': import win32com.server.register win32com.server.register.UseCommandLine(AddIn1) This won't work! I can't start this COM server from my application. First some questions: Do I have to write _public_methods_ = ['Init', 'Exit'] in order to satisfy the required interface ICADdyAddIn? How do I handle the properties from ICADdyAddIn _prop_map_get_ = { "CLSID": (3, 2, (8, 0), (), "CLSID", None), "Description": (5, 2, (8, 0), (), "Description", None), "ProgId": (4, 2, (8, 0), (), "ProgId", None), } correctly? Do have to use _public_attrs_ and if so how do I use it correctly? I used the methods getCLSID, getProgId and getDescription just to give it a try but they seem to be totaly wrong. I used the excelAddIn.py demo as a start. However, is this the recommended way for writing a COM server addin? I have to mention that I'm quite new to Python as well as to PythonCOM. So my questions may be quite naive, but I would very much appreciate some help for this topic. With best regards Johannes From haraldarminmassa at gmail.com Mon Jul 4 15:49:03 2005 From: haraldarminmassa at gmail.com (Harald Armin Massa) Date: Mon, 4 Jul 2005 15:49:03 +0200 Subject: [python-win32] testing windows services Message-ID: <7be3f35d05070406497826e17c@mail.gmail.com> Hello, within the win32-extensions under demo I found the pipetestservice.py and am developping my own services out of it. With each development step I have to stop the running service remove the existing one install the new one start the service of course, I can script that... but it still takes time. Is there something quicker? a "fake service environment" in pure python or that like? Harald -- GHUM Harald Massa persuasion python postgresql Harald Armin Massa Reinsburgstra?e 202b 70197 Stuttgart 0173/9409607 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050704/40d87b2f/attachment.htm From kveretennicov at gmail.com Tue Jul 5 15:43:21 2005 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Tue, 5 Jul 2005 16:43:21 +0300 Subject: [python-win32] Activex call delivers only unicode string, but ASCII is needed In-Reply-To: <5FBC042194FEC54C9EFEA97D1EA8B3680140E6CB@villsmail01.eu.thmulti.com> References: <5FBC042194FEC54C9EFEA97D1EA8B3680140E6CB@villsmail01.eu.thmulti.com> Message-ID: <4660fe3005070506437932165d@mail.gmail.com> On 7/4/05, Kuner Martin wrote: > > > Hi list, > > I have the following code to call a LabVIEW VI via the Activex interface. > The string "strDataOut" holds the expected data result of the call . > Now I realized that the string coming back from the ActiveX call contains > Unicode and that is fatal! > The string on the Python side should always be ASCII. > I found no way to convert them back, strDataOut.enocde() raises a exception > when I try to convert to ASCII Which encoding do you use with strDataOut.encode(...) ? > > Here?s the relevant code. > > intCmdcnt = 0; > strDataOut = r"" > cluError = [False,0,""] > cluSenseKey = [0,0,0] > print "strDataOut = %r" % strDataOut > > arParNames = > ["intChannel","strCDB","strDataIn","intDirection", > "intLength","cluError","cluSenseKey","intCmdcnt","strDataOut"] > > arParVals = [0, strCDB, strBuffer, intDataToHost,intBuffLen, > cluError, cluSenseKey, intCmdcnt, strDataOut] > > retval = self.__refGenericATAPI.Call(arParNames, > arParVals) # call VI > print retval > > The printout: > strDataOut = '' > ((u'intChannel', u'strCDB', u'strDataIn', u'intDirection', u'intLength', > u'cluError', u'cluSenseKey', u'intCmdcnt', u'strDataOut'), (0, > u'\xa8\x08\x00\x10\x00\x00\x00\x00\x00\x10\x00\x00', u'', > 1, 16, (False, 0, u''), (0, 0, 0), 37, > u'\x00\x00\x01\xbaD\xa5?\x14\x0c\xab\x01\u2030\xc3\xf8\x00\x00')) > > Here?s another data example: > > String on LabVIEW side : > 00 00 01 BA 44 A5 3F 14 0C AB 01 89 C3 F8 00 00 > String on python side > > u'\x00\x00\x01\xbaD\xa5?\x14\x0c\xab\x01\u2030\xc3\xf8\x00\x00' > > Any ideas ? LabVIEW seems to use cp1252 encoding: >>> s = u'\x00\x00\x01\xbaD\xa5?\x14\x0c\xab\x01\u2030\xc3\xf8\x00\x00' >>> s.encode('cp1252') '\x00\x00\x01\xbaD\xa5?\x14\x0c\xab\x01\x89\xc3\xf8\x00\x00' Does this string look familiar? :) - kv From theller at python.net Tue Jul 5 16:54:29 2005 From: theller at python.net (Thomas Heller) Date: Tue, 05 Jul 2005 16:54:29 +0200 Subject: [python-win32] testing windows services References: <7be3f35d05070406497826e17c@mail.gmail.com> Message-ID: Harald Armin Massa writes: > Hello, > > within the win32-extensions under demo I found the pipetestservice.py and am > developping my own services out of it. > > With each development step I have to > > stop the running service > remove the existing one > install the new one > start the service AFAIK, if you simply change some code in your service, there's no need to remove and install it again (unless you change code that is registerd with windows - the service name or such stuff). > > of course, I can script that... but it still takes time. > > Is there something quicker? a "fake service environment" in pure python or > that like? I think you can start the service like this: pipetestservice.py debug An additional advantage is that you can see printouts from the service on the console, without even using the trace collector tool: c:\Python23\Lib\site-packages\win32\Demos\service>pipeTestService.py debug Debugging service PyPipeTestService - press Ctrl+C to stop. Info 0x40001002 - The PyPipeTestService service has started. (here I hit ^C) Stopping debug service. Info 0x40001004 - The PyPipeTestService service has stopped after processing 0 connections. c:\Python23\Lib\site-packages\win32\Demos\service> Thomas From ausum_studio at hotmail.com Tue Jul 5 18:12:16 2005 From: ausum_studio at hotmail.com (Ausum Studio) Date: Tue, 5 Jul 2005 11:12:16 -0500 Subject: [python-win32] Converting web pages to MHT with python Message-ID: Is it possible to convert web pages to MHT files using Dispatch and Internet Explorer? Thanks in advance, Ausum From Jim.Vickroy at noaa.gov Tue Jul 5 18:11:02 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Tue, 05 Jul 2005 10:11:02 -0600 Subject: [python-win32] testing windows services In-Reply-To: References: <7be3f35d05070406497826e17c@mail.gmail.com> Message-ID: <42CAB116.3060707@noaa.gov> Thomas Heller wrote: >Harald Armin Massa writes: > > > >>Hello, >> >>within the win32-extensions under demo I found the pipetestservice.py and am >>developping my own services out of it. >> >>With each development step I have to >> >>stop the running service >>remove the existing one >>install the new one >>start the service >> >> > >AFAIK, if you simply change some code in your service, there's no need >to remove and install it again (unless you change code that is registerd >with windows - the service name or such stuff). > > That has been my experience; changing code in a service (with the exceptions noted by Thomas) does not require the service to be reinstalled. [snip] From mhammond at skippinet.com.au Wed Jul 6 01:31:50 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 6 Jul 2005 09:31:50 +1000 Subject: [python-win32] COM server AddIn In-Reply-To: <23D83A07C60A0E47AD964F74DA96940102936F@mail.datasolid.de> Message-ID: <01a301c581b9$b874c380$0b0a0a0a@enfoldsystems.local> > This won't work! I can't start this COM server from my application. > > First some questions: Do I have to write _public_methods_ = > ['Init', 'Exit'] in order to satisfy the required interface > ICADdyAddIn? No - but _public_methods_ must exist (ie, your code is fine) > How do I handle the properties from ICADdyAddIn > _prop_map_get_ = { > "CLSID": (3, 2, (8, 0), (), "CLSID", None), > "Description": (5, 2, (8, 0), (), "Description", None), > "ProgId": (4, 2, (8, 0), (), "ProgId", None), > } IIRC you can either provide a simple attribute of that name, or a function of that name for a "getter", and "Set{name}" as a setter. eg, either: def __init__(self): ... self.Description = foo or def Description(self): return "foo" def SetDescription(self, val): ... FYI, that is implemented in win32com\server\policy.py > correctly? Do have to use _public_attrs_ and if so how do I > use it correctly? I believe not. > I used the methods getCLSID, getProgId and > getDescription > just to give it a try but they seem to be totaly wrong. > > I used the excelAddIn.py demo as a start. However, is this > the recommended way for writing a COM server addin? Yep. You need to know how to debug Python COM objects. Basically: * Register your object with "--debug" on the command-line. * Start Pythonwin and select Tools->Remote Trace Collector * Restart the app which creates the object. You should see every COM call (including low-level ones, such as QueryInterface), and you should also see any exceptions generated by your object. This is likely to give you a much better insight into what is happening. Mark -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 2540 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050706/ceec2445/winmail.bin From b_papadopoulos at iris.gr Wed Jul 6 10:27:54 2005 From: b_papadopoulos at iris.gr (Bill Papadopoulos) Date: Wed, 6 Jul 2005 11:27:54 +0300 Subject: [python-win32] 'get__doc__' attribute Message-ID: <006f01c58204$9b0986a0$2700000a@themeliodomi.gr> Hi List, Running py2exe raises an AttributeError: DistributionMetadata instance has no attribute 'get__doc__' Anyone knows why this happens? Regards Bill Vax PAPADOPOULOS __________________________ b_papadopoulos at iris.gr bpapadopoulos at hotmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050706/83499356/attachment-0001.htm From stephen.dicks at rawflow.com Wed Jul 6 11:51:39 2005 From: stephen.dicks at rawflow.com (Stephen Dicks) Date: Wed, 06 Jul 2005 10:51:39 +0100 Subject: [python-win32] Problems with XML COM server Message-ID: <42CBA9AB.3020209@rawflow.com> Hi, I have a simple COM server in python which parses an XML file via SAX, and I want to distribute it via py2exe as the target machines will not have python installed (and in some cases could not have it installed) However I have tried several (recent) versions of py2exe, python itself and the various fixes suggested by various people in the past, but I still can't get it to work in any configuration using either python 2.3.5/2.4.1 or py2exe 0.4.2/0.5.4 with Windows XP Using python 2.3 and py2exe 0.4.2, a standalone EXE builds and works fine, but the COM server fails the --register command line with 'Cannot locate Python module win32com.server.localserver' while executing UseCommandLine() Using python 2.4 and py2exe 0.5.4, the standalone executable fails with: Traceback (most recent call last): File "fred.py", line 39, in ? parser.parseFile(file(sys.argv[1])) File "xml\sax\drivers\drv_pyexpat.pyc", line 68, in parseFile File "xml\sax\drivers\drv_pyexpat.pyc", line 45, in startElement AttributeError: "module" object has no attribute "AttributeMap" which no-one else seems to have had trouble with. Using python 2.3 and py2exe 0.5.4, the py2exe setup stage fails with errors like: 'Cant find module linecache' 'Cant find module xml' and the parse stops with 'Cannot find parser' (not surprisingly) if I try to run the resulting executable. Does anyone know of a combination that works? From jbrunen at datasolid.de Wed Jul 6 11:43:35 2005 From: jbrunen at datasolid.de (Johannes Brunen) Date: Wed, 6 Jul 2005 11:43:35 +0200 Subject: [python-win32] COM server AddIn References: <23D83A07C60A0E47AD964F74DA96940102936F@mail.datasolid.de> <01a301c581b9$b874c380$0b0a0a0a@enfoldsystems.local> Message-ID: Hi Mark, unfortunately I do not make any progress. The trace collector gives me the following output. Object with win32trace dispatcher created (object=None) pythoncom error: Failed to call the universal dispatcher Traceback (most recent call last): File "C:\Programme\Python\Lib\site-packages\win32com\universal.py", line 173, in dispatch retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None) File "C:\Programme\Python\Lib\site-packages\win32com\server\policy.py", line 330, in _InvokeEx_ return self._invokeex_(dispid, lcid, wFlags, args, kwargs, serviceProvider) File "C:\Programme\Python\Lib\site-packages\win32com\server\policy.py", line 647, in _invokeex_ return DesignatedWrapPolicy.c( self, dispid, lcid, wFlags, args, kwArgs, serviceProvider) File "C:\Programme\Python\Lib\site-packages\win32com\server\policy.py", line 593, in _invokeex_ raise COMException(scode=winerror.DISP_E_MEMBERNOTFOUND) # not found win32com.server.exception.COMException: (-2147352573, 'Mitglied nicht gefunden.', None, -1) How can I see the values of the arguments passed to function ._InvokeEx_? Below I added the 'AddIn1.py' server script and the script generated by gencache. Additionally, I have added a properly working Visual Basic file 'Addin4.cls', which I used as a starting point for my PythonCOM Addin1 test. Do you have any ideas what is going wrong here? Is there any way to get the debugger stop in one of the _InvokeEx_ functions? Any help would be very much appreciated. With kind regards Johannes My script now looks as follows: ## ## Addin1.py - A very simple CADdy++ AddIn server ## from win32com import universal from win32com.server.exception import COMException from win32com.client import gencache #from win32com.client import DispatchWithEvents #import winerror import pythoncom #from win32com.client import constants, Dispatch import sys # # Support for COM objects we use. # gencache.EnsureModule('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 2, bForDemand=True) # CADdy.tlb # # The TLB defining the interfaces we implement # universal.RegisterInterfaces('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 2, ['ICADdyAddIn']) class AddIn1: _com_interfaces_ = ['ICADdyAddIn'] _public_methods_ = ['Exit','Init','CLSID','ProgId','Description'] _reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER _reg_clsid_ = "{AB6C657A-2C26-4BD0-ABB8-D777BC91F199}" _reg_progid_ = "CADdyAddIn.PythonTest1" _reg_policy_spec_ = "win32com.server.policy.EventHandlerPolicy" def __init__(self): self.appHostApp = None def Exit(self): """method Exit""" self.appHostApp = None def Init(self, theCADdy): """method Init""" self.appHostApp = theCADdy self.CLSID = _reg_clsid_ self.ProgId = _reg_progid_ self.Description = "CADdy++ CADdyAddIn.PythonTest1" pUIManager = theCADdy.UIManager pUIManager.Information("Init Python Test AddIn1...") def CLSID(self): return self.CLSID def ProgId(self): return self.ProgId def Description(self): return self.Description def RegisterAddin(klass): pass def UnregisterAddin(klass): pass if __name__ == '__main__': import win32com.server.register win32com.server.register.UseCommandLine(AddIn1) if "--unregister" in sys.argv: UnregisterAddin(AddIn1) else: RegisterAddin(AddIn1) And my gencache generated python script: # Created by makepy.py version 0.4.93 # By python version 2.4.1 (#65, Mar 30 2005, 09:33:37) [MSC v.1310 32 bit (Intel)] # From type library '{9C3BB401-114D-11D4-AC72-00105A4925FC}' # On Wed Jun 29 17:14:19 2005 """CADdyCOM 1.2 (CADdy) Type Library""" makepy_version = '0.4.93' python_version = 0x20401f0 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('{9C3BB401-114D-11D4-AC72-00105A4925FC}') MajorVersion = 1 MinorVersion = 2 LibraryFlags = 8 LCID = 0x0 class constants: ADDIN_E_ALREADYSTARTED =-2147220991 # from enum ADDINHRESULTS ADDIN_E_CANTCREATESERVER =-2147220989 # from enum ADDINHRESULTS ADDIN_E_ERRONEOUSADDIN =-2147220992 # from enum ADDINHRESULTS ADDIN_E_INAPPROPRIATESERVER =-2147220990 # from enum ADDINHRESULTS from win32com.client import DispatchBaseClass class ICADdy(DispatchBaseClass): """ICADdy Interface""" CLSID = IID('{D330F3E0-0F91-11D4-AC6E-00105A4925FC}') coclass_clsid = IID('{D330F3E1-0F91-11D4-AC6E-00105A4925FC}') # The method Manager is actually a property, but must be used as a method to correctly pass the arguments def Manager(self, _MIDL_0025_=defaultNamedNotOptArg): """property Manager""" ret = self._oleobj_.InvokeTypes(4, LCID, 2, (9, 0), ((8, 1),),_MIDL_0025_ ) if ret is not None: ret = Dispatch(ret, 'Manager', None, UnicodeToString=0) return ret _prop_map_get_ = { "ExeDirectory": (5, 2, (8, 0), (), "ExeDirectory", None), "FrameManager": (1, 2, (9, 0), (), "FrameManager", None), "HomeDirectory": (6, 2, (8, 0), (), "HomeDirectory", None), "ModelManager": (2, 2, (9, 0), (), "ModelManager", None), "Name": (7, 2, (8, 0), (), "Name", None), "ReleaseNo": (9, 2, (3, 0), (), "ReleaseNo", None), "UIManager": (3, 2, (9, 0), (), "UIManager", None), "VersionNo": (8, 2, (3, 0), (), "VersionNo", None), } _prop_map_put_ = { } class ICADdyAddIn(DispatchBaseClass): """ICADdyAddIn Interface""" CLSID = IID('{14F65AE1-4671-11D4-8B1A-00105A49278B}') coclass_clsid = None def Exit(self): """method Exit""" return self._oleobj_.InvokeTypes(2, LCID, 1, (24, 0), (),) def Init(self, theCADdy=defaultNamedNotOptArg): """method Init""" return self._oleobj_.InvokeTypes(1, LCID, 1, (24, 0), ((9, 1),),theCADdy ) _prop_map_get_ = { "CLSID": (3, 2, (8, 0), (), "CLSID", None), "Description": (5, 2, (8, 0), (), "Description", None), "ProgId": (4, 2, (8, 0), (), "ProgId", None), } _prop_map_put_ = { } class ICADdyAddIns(DispatchBaseClass): """ICADdyAddIns Interface""" CLSID = IID('{14F65AE2-4671-11D4-8B1A-00105A49278B}') coclass_clsid = IID('{3F5B2591-4768-11D4-8B1C-00105A49278B}') # Result is of type ICADdyAddIn # The method Item is actually a property, but must be used as a method to correctly pass the arguments def Item(self, _MIDL_0018_=defaultNamedNotOptArg): """Item""" ret = self._oleobj_.InvokeTypes(0, LCID, 2, (9, 0), ((3, 1),),_MIDL_0018_ ) if ret is not None: ret = Dispatch(ret, 'Item', '{14F65AE1-4671-11D4-8B1A-00105A49278B}', UnicodeToString=0) return ret # Result is of type ICADdyAddIn def Start(self, _MIDL_0022_=defaultNamedNotOptArg): """Start""" ret = self._oleobj_.InvokeTypes(2, LCID, 1, (9, 0), ((8, 1),),_MIDL_0022_ ) if ret is not None: ret = Dispatch(ret, 'Start', '{14F65AE1-4671-11D4-8B1A-00105A49278B}', UnicodeToString=0) return ret def Stop(self, _MIDL_0024_=defaultNamedNotOptArg): """Stop""" return self._oleobj_.InvokeTypes(3, LCID, 1, (24, 0), ((9, 1),),_MIDL_0024_ ) def StopAll(self): """StopAll""" return self._oleobj_.InvokeTypes(4, LCID, 1, (24, 0), (),) _prop_map_get_ = { "Count": (1, 2, (3, 0), (), "Count", None), } _prop_map_put_ = { } # Default method for this class is 'Item' def __call__(self, _MIDL_0018_=defaultNamedNotOptArg): """Item""" ret = self._oleobj_.InvokeTypes(0, LCID, 2, (9, 0), ((3, 1),),_MIDL_0018_ ) if ret is not None: ret = Dispatch(ret, '__call__', '{14F65AE1-4671-11D4-8B1A-00105A49278B}', UnicodeToString=0) return ret # str(ob) and int(ob) will use __call__ def __unicode__(self, *args): try: return unicode(self.__call__(*args)) except pythoncom.com_error: return repr(self) def __str__(self, *args): return str(self.__unicode__(*args)) def __int__(self, *args): return int(self.__call__(*args)) def __iter__(self): "Return a Python iterator for this object" ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),'{14F65AE1-4671-11D4-8B1A-00105A49278B}') def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) #This class has Count() property - allow len(ob) to provide this def __len__(self): return self._ApplyTypes_(*(1, 2, (3, 0), (), "Count", None)) #This class has a __len__ - this is needed so 'if object:' always returns TRUE. def __nonzero__(self): return True from win32com.client import CoClassBaseClass # This CoClass is known by the name 'AddIns.CADdyAddIns.1' class CADdyAddIns(CoClassBaseClass): # A CoClass # CADdyAddIn Collection CLSID = IID('{3F5B2591-4768-11D4-8B1C-00105A49278B}') coclass_sources = [ ] coclass_interfaces = [ ICADdyAddIns, ] default_interface = ICADdyAddIns # This CoClass is known by the name 'CADdy.CADdy.1' class CoCADdy(CoClassBaseClass): # A CoClass # CADdy Class CLSID = IID('{D330F3E1-0F91-11D4-AC6E-00105A4925FC}') coclass_sources = [ ] coclass_interfaces = [ ICADdy, ] default_interface = ICADdy ICADdy_vtables_dispatch_ = 1 ICADdy_vtables_ = [ (( 'FrameManager' , 'ppICADdyFrameManager' , ), 1, (1, (), [ (16393, 10, None, None) , ], 1 , 2 , 4 , 0 , 28 , (3, 0, None, None) , 0 , )), (( 'ModelManager' , 'ppICADdyModelManager' , ), 2, (2, (), [ (16393, 10, None, None) , ], 1 , 2 , 4 , 0 , 32 , (3, 0, None, None) , 0 , )), (( 'UIManager' , 'ppICADdyUIManager' , ), 3, (3, (), [ (16393, 10, None, None) , ], 1 , 2 , 4 , 0 , 36 , (3, 0, None, None) , 0 , )), (( 'Manager' , '__MIDL_0025' , 'ppICADdyDimensionManager' , ), 4, (4, (), [ (8, 1, None, None) , (16393, 10, None, None) , ], 1 , 2 , 4 , 0 , 40 , (3, 0, None, None) , 0 , )), (( 'ExeDirectory' , 'pbstrDirectory' , ), 5, (5, (), [ (16392, 10, None, None) , ], 1 , 2 , 4 , 0 , 44 , (3, 0, None, None) , 0 , )), (( 'HomeDirectory' , 'pbstrDirectory' , ), 6, (6, (), [ (16392, 10, None, None) , ], 1 , 2 , 4 , 0 , 48 , (3, 0, None, None) , 0 , )), (( 'Name' , 'pbstrName' , ), 7, (7, (), [ (16392, 10, None, None) , ], 1 , 2 , 4 , 0 , 52 , (3, 0, None, None) , 0 , )), (( 'VersionNo' , 'lVersion' , ), 8, (8, (), [ (16387, 10, None, None) , ], 1 , 2 , 4 , 0 , 56 , (3, 0, None, None) , 0 , )), (( 'ReleaseNo' , 'lRelease' , ), 9, (9, (), [ (16387, 10, None, None) , ], 1 , 2 , 4 , 0 , 60 , (3, 0, None, None) , 0 , )), ] ICADdyAddIn_vtables_dispatch_ = 1 ICADdyAddIn_vtables_ = [ (( 'Init' , 'theCADdy' , ), 1, (1, (), [ (9, 1, None, "IID('{D330F3E0-0F91-11D4-AC6E-00105A4925FC}')") , ], 1 , 1 , 4 , 0 , 28 , (3, 0, None, None) , 0 , )), (( 'Exit' , ), 2, (2, (), [ ], 1 , 1 , 4 , 0 , 32 , (3, 0, None, None) , 0 , )), (( 'CLSID' , 'pcCLSID' , ), 3, (3, (), [ (16392, 10, None, None) , ], 1 , 2 , 4 , 0 , 36 , (3, 0, None, None) , 0 , )), (( 'ProgId' , 'pcProgId' , ), 4, (4, (), [ (16392, 10, None, None) , ], 1 , 2 , 4 , 0 , 40 , (3, 0, None, None) , 0 , )), (( 'Description' , 'pcDescription' , ), 5, (5, (), [ (16392, 10, None, None) , ], 1 , 2 , 4 , 0 , 44 , (3, 0, None, None) , 0 , )), ] ICADdyAddIns_vtables_dispatch_ = 1 ICADdyAddIns_vtables_ = [ (( 'Item' , '__MIDL_0018' , '__MIDL_0019' , ), 0, (0, (), [ (3, 1, None, None) , (16393, 10, None, "IID('{14F65AE1-4671-11D4-8B1A-00105A49278B}')") , ], 1 , 2 , 4 , 0 , 28 , (3, 0, None, None) , 0 , )), (( '_NewEnum' , '__MIDL_0020' , ), -4, (-4, (), [ (16397, 10, None, None) , ], 1 , 2 , 4 , 0 , 32 , (3, 0, None, None) , 1 , )), (( 'Count' , '__MIDL_0021' , ), 1, (1, (), [ (16387, 10, None, None) , ], 1 , 2 , 4 , 0 , 36 , (3, 0, None, None) , 0 , )), (( 'Start' , '__MIDL_0022' , '__MIDL_0023' , ), 2, (2, (), [ (8, 1, None, None) , (16393, 10, None, "IID('{14F65AE1-4671-11D4-8B1A-00105A49278B}')") , ], 1 , 1 , 4 , 0 , 40 , (3, 0, None, None) , 0 , )), (( 'Stop' , '__MIDL_0024' , ), 3, (3, (), [ (9, 1, None, "IID('{14F65AE1-4671-11D4-8B1A-00105A49278B}')") , ], 1 , 1 , 4 , 0 , 44 , (3, 0, None, None) , 0 , )), (( 'StopAll' , ), 4, (4, (), [ ], 1 , 1 , 4 , 0 , 48 , (3, 0, None, None) , 0 , )), ] IEnumCADdyAddIn_vtables_dispatch_ = 0 IEnumCADdyAddIn_vtables_ = [ (( 'Next' , 'i4Count' , '__MIDL_0015' , 'pi4Fetched' , ), 1, (1, (), [ (19, 1, None, None) , (16393, 2, None, "IID('{14F65AE1-4671-11D4-8B1A-00105A49278B}')") , (16403, 2, None, None) , ], 1 , 1 , 4 , 0 , 12 , (3, 0, None, None) , 0 , )), (( 'Skip' , '__MIDL_0016' , ), 2, (2, (), [ (19, 1, None, None) , ], 1 , 1 , 4 , 0 , 16 , (3, 0, None, None) , 0 , )), (( 'Reset' , ), 3, (3, (), [ ], 1 , 1 , 4 , 0 , 20 , (3, 0, None, None) , 0 , )), (( 'Clone' , '__MIDL_0017' , ), 4, (4, (), [ (16397, 2, None, "IID('{14F65AE3-4671-11D4-8B1A-00105A49278B}')") , ], 1 , 1 , 4 , 0 , 24 , (3, 0, None, None) , 0 , )), ] ISupportErrorInfo_vtables_dispatch_ = 0 ISupportErrorInfo_vtables_ = [ (( 'InterfaceSupportsErrorInfo' , 'riid' , ), 1610678272, (1610678272, (), [ (36, 1, None, None) , ], 1 , 1 , 4 , 0 , 12 , (3, 0, None, None) , 0 , )), ] RecordMap = { } CLSIDToClassMap = { '{14F65AE1-4671-11D4-8B1A-00105A49278B}' : ICADdyAddIn, '{D330F3E1-0F91-11D4-AC6E-00105A4925FC}' : CoCADdy, '{D330F3E0-0F91-11D4-AC6E-00105A4925FC}' : ICADdy, '{14F65AE2-4671-11D4-8B1A-00105A49278B}' : ICADdyAddIns, '{3F5B2591-4768-11D4-8B1C-00105A49278B}' : CADdyAddIns, } CLSIDToPackageMap = {} win32com.client.CLSIDToClass.RegisterCLSIDsFromDict( CLSIDToClassMap ) VTablesToPackageMap = {} VTablesToClassMap = { '{14F65AE2-4671-11D4-8B1A-00105A49278B}' : 'ICADdyAddIns', '{14F65AE3-4671-11D4-8B1A-00105A49278B}' : 'IEnumCADdyAddIn', '{D330F3E0-0F91-11D4-AC6E-00105A4925FC}' : 'ICADdy', '{DF0B3D60-548F-101B-8E65-08002B2BD119}' : 'ISupportErrorInfo', '{14F65AE1-4671-11D4-8B1A-00105A49278B}' : 'ICADdyAddIn', } NamesToIIDMap = { 'ICADdyAddIn' : '{14F65AE1-4671-11D4-8B1A-00105A49278B}', 'ICADdy' : '{D330F3E0-0F91-11D4-AC6E-00105A4925FC}', 'ISupportErrorInfo' : '{DF0B3D60-548F-101B-8E65-08002B2BD119}', 'IEnumCADdyAddIn' : '{14F65AE3-4671-11D4-8B1A-00105A49278B}', 'ICADdyAddIns' : '{14F65AE2-4671-11D4-8B1A-00105A49278B}', } win32com.client.constants.__dicts__.append(constants.__dict__) The Visual Basic example: VERSION 1.0 CLASS BEGIN MultiUse = -1 'True Persistable = 0 'NotPersistable DataBindingBehavior = 0 'vbNone DataSourceBehavior = 0 'vbNone MTSTransactionMode = 0 'NotAnMTSObject END Attribute VB_Name = "AddIn4" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = True ' ' Implementation of the addin4 COM component. To communicate with CADdy++ ' the component implements the CADdy++ provided interface ICADdyAddIn. ' This contains mainly the implementation of such things you want to do ' on starting and exiting an addin. ' Option Explicit Implements ICADdyAddIn Private Type GUID Data1 As Long Data2 As Integer Data3 As Integer Data4(7) As Byte End Type ' a commandpool for this addins's commands Private pCmdPool As CmdPoolAddIn4 Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long) Private Declare Function CLSIDFromProgID Lib "ole32.dll" (ByVal lpszProgID As Long, pCLSID As GUID) As Long Private Declare Function StringFromCLSID Lib "ole32.dll" (pCLSID As GUID, lpszProgID As Long) As Long ' ' ' init method ' This method is called on initialization of every CADdyAddIn. ' You can set your global vars and if required AddIn specific data. ' ' Private Sub ICADdyAddIn_Init(ByVal theCADdy As CoCADdy) MsgBox "Init AddIn4", vbOKOnly, "AddIn4" Set pICADdy = theCADdy Set pIFrameManager = pICADdy.FrameManager Set pUIManager = pICADdy.UIManager ' attach commands in CADdy++ Set pCmdPool = New CmdPoolAddIn4 End Sub ' ' ' This method is called while exiting a CADdyAddIn. Here normaly globals are ' cleaned and commandpools removed. ' ' Private Sub ICADdyAddIn_Exit() MsgBox "Exit AddIn4", vbOKOnly, "AddIn4" ' detach commands from CADdy++ Set pCmdPool = Nothing Set pICADdy = Nothing Set pIFrameManager = Nothing Set pUIManager = Nothing oNonModalForm.UnloadAddIn4Form Set oNonModalForm = Nothing End Sub ' ' ' An utility method which returns the AddIn's ClassId ' ' Private Property Get ICADdyAddIn_CLSID() As String Dim hr As Long Dim pCLSID As Long Dim strCLSID As String * 255 Dim pGUID As GUID Dim strProgID As String strProgID = "CADdyAddIn.AddIn4" hr = CLSIDFromProgID(StrPtr(strProgID), pGUID) hr = StringFromCLSID(pGUID, pCLSID) StringFromPointer pCLSID, strCLSID ICADdyAddIn_CLSID = strCLSID End Property ' ' ' An utility method which returns the AddIn's ProgID ' ' Private Property Get ICADdyAddIn_ProgId() As String ICADdyAddIn_ProgId = "CADdyAddIn.AddIn4" End Property ' ' ' An utility method which returns the AddIn's Description ' ' Private Property Get ICADdyAddIn_Description() As String ICADdyAddIn_Description = "DLL(Visual Basic 6) AddIn4" End Property ' ' ' An utility method which returns the String from the given Pointer ' ' Private Sub StringFromPointer(pOLESTR As Long, strOut As String) Dim ByteArray(255) As Byte Dim intTemp As Integer Dim intCount As Integer Dim i As Integer intTemp = 1 While intTemp <> 0 CopyMemory intTemp, ByVal pOLESTR + i, 2 ByteArray(intCount) = intTemp intCount = intCount + 1 i = i + 2 Wend CopyMemory ByVal strOut, ByteArray(0), intCount End Sub From theller at python.net Wed Jul 6 12:25:42 2005 From: theller at python.net (Thomas Heller) Date: Wed, 06 Jul 2005 12:25:42 +0200 Subject: [python-win32] Problems with XML COM server References: <42CBA9AB.3020209@rawflow.com> Message-ID: <1x6c9qop.fsf@python.net> Stephen Dicks writes: > Hi, > I have a simple COM server in python which parses an XML file via > SAX, and I want to distribute it via py2exe as the target machines will > not have python installed (and in some cases could not have it installed) > > However I have tried several (recent) versions of py2exe, python itself > and the various fixes suggested by various people in the past, but I > still can't get it to work in any configuration using either python > 2.3.5/2.4.1 or py2exe 0.4.2/0.5.4 with Windows XP > > Using python 2.3 and py2exe 0.4.2, a standalone EXE builds and works > fine, but the COM server fails the --register command line with 'Cannot > locate Python module win32com.server.localserver' while executing > UseCommandLine() > > Using python 2.4 and py2exe 0.5.4, the standalone executable fails with: > > Traceback (most recent call last): > File "fred.py", line 39, in ? > parser.parseFile(file(sys.argv[1])) > File "xml\sax\drivers\drv_pyexpat.pyc", line 68, in parseFile > File "xml\sax\drivers\drv_pyexpat.pyc", line 45, in startElement > AttributeError: "module" object has no attribute "AttributeMap" > > which no-one else seems to have had trouble with. > > Using python 2.3 and py2exe 0.5.4, the py2exe setup stage fails with errors like: > > 'Cant find module linecache' > 'Cant find module xml' > > and the parse stops with 'Cannot find parser' (not surprisingly) if I try to run the resulting executable. > > Does anyone know of a combination that works? Do you have PyXML installed for Python 2.4, and not Python 2.3? Maybe this is the reason that the 2.4 build fails - but this is just a guess. For the 'Cant find module linecache' (speculation again) please take a look at this page: http://adelux.c2a.fr/libre/howto/deployTwistedWindows/#bug-in-py2exe-0-5-4 You could try out a similar fix to the boot_com_servers.py script. Thomas From upadhyay at gmail.com Wed Jul 6 13:32:22 2005 From: upadhyay at gmail.com (Amit Upadhyay) Date: Wed, 6 Jul 2005 17:02:22 +0530 Subject: [python-win32] Problems with XML COM server In-Reply-To: <42CBA9AB.3020209@rawflow.com> References: <42CBA9AB.3020209@rawflow.com> Message-ID: <349edb38050706043223577e56@mail.gmail.com> > > Using python 2.3 and py2exe 0.4.2, a standalone EXE builds and works > fine, but the COM server fails the --register command line with 'Cannot > locate Python module win32com.server.localserver' while executing > UseCommandLine() Hi, I am new to this too, but I tried using py2exe for packaging a COM server, and used a setup.py something like: import mymodule opts = { "py2exe": { "includes": "encodings,encodings.*" } } setup(com_server=["mymodule"], options=opts and running this script I got comple of dll, pyd files and some exe file. I ignored the exe, registered the mymodule.dll using regsvr32 and was able to access it using COM clients. -- Amit Upadhyay Blog: http://www.rootshell.be/~upadhyay +91-9820-859-701 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050706/ff000d12/attachment.htm From ludovic.reenaers at be.unisys.com Wed Jul 6 13:01:55 2005 From: ludovic.reenaers at be.unisys.com (Reenaers, Ludovic) Date: Wed, 6 Jul 2005 13:01:55 +0200 Subject: [python-win32] polling values from physical sensors Message-ID: Hello, I'm using python for years now, but it seems that going a bit too deep for my poor knowledge. I know this is may-be not best place for such a question, but I feel a bit disappointed right now. I'm currently trying to write service in python (prototyping), this service will, ideally, poll physical sensors (such as temperature sensor, light sensor,...) to get range of values. I want to write it on a Win32 platform. But, My problem is: I don't have any idea of the necessary hardware and, never the less, I don't know which python/win32 module I will have to use in order to communicate with those sensor. Will I have to buy a kind of controller for sensors? What kind? Is there some normalization about that? Does some body Has any Idea where I could start my investigations? Thanks in advance, Ludo -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050706/acf6ae65/attachment-0001.htm From emlynj at gmail.com Wed Jul 6 18:27:12 2005 From: emlynj at gmail.com (Emlyn Jones) Date: Wed, 6 Jul 2005 17:27:12 +0100 Subject: [python-win32] polling values from physical sensors In-Reply-To: References: Message-ID: Have you had a look at the Python robotics toolkit? http://emergent.brynmawr.edu/~dblank/pyro/ I'm not sure of the windows support but someone there might be able to help you. Cheers, Emlyn. On 7/6/05, Reenaers, Ludovic wrote: > > > > Hello, > > > > I'm using python for years now, but it seems that going a bit too deep for > my poor knowledge. I know this is may-be not best place for such a question, > but I feel a bit disappointed right now. > > > > I'm currently trying to write service in python (prototyping), this service > will, ideally, poll physical sensors (such as temperature sensor, light > sensor,?) to get range of values. I want to write it on a Win32 platform. > But, My problem is: I don't have any idea of the necessary hardware and, > never the less, I don't know which python/win32 module I will have to use in > order to communicate with those sensor. Will I have to buy a kind of > controller for sensors? What kind? Is there some normalization about that? > Does some body Has any Idea where I could start my investigations? > > > > Thanks in advance, > > > > Ludo > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > From mhammond at skippinet.com.au Thu Jul 7 00:36:23 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 7 Jul 2005 08:36:23 +1000 Subject: [python-win32] polling values from physical sensors In-Reply-To: Message-ID: <05db01c5827b$24740a20$0b0a0a0a@enfoldsystems.local> > I'm currently trying to write service in python (prototyping), > this service will, ideally, poll physical sensors (such as temperature sensor, > light sensor,...) to get range of values. I want to write it on a Win32 platform. > But, My problem is: I don't have any idea of the necessary hardware and, > never the less, I don't know which python/win32 module I will have to use > in order to communicate with those sensor. You will need to answer this question without considering Python - eg, how would you talk to the hardware from *any* language. I assume it depends on the specific sensors. Once you can answer that question, we can help you apply the solution to Python - it is quite likely you would need to use the ctypes module for this, but you need to answer that generic question first. Mark -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 2072 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20050707/c0c95262/winmail.bin From timr at probo.com Thu Jul 7 02:24:41 2005 From: timr at probo.com (Tim Roberts) Date: Wed, 06 Jul 2005 17:24:41 -0700 Subject: [python-win32] polling values from physical sensors In-Reply-To: References: Message-ID: <42CC7649.3020803@probo.com> On Wed, 6 Jul 2005 13:01:55 +0200, "Reenaers, Ludovic" wrote: > >I'm currently trying to write service in python (prototyping), this >service will, ideally, poll physical sensors (such as temperature >sensor, light sensor,...) to get range of values. I want to write it on >a Win32 platform. But, My problem is: I don't have any idea of the >necessary hardware and, never the less, I don't know which python/win32 >module I will have to use in order to communicate with those sensor. >Will I have to buy a kind of controller for sensors? What kind? Is there >some normalization about that? Does some body Has any Idea where I could >start my investigations? > There are many different ways to connect sensors to personal computers, all the way from sophisticated sensors that have USB controllers built in, down to simple boards that are wired directly to pins on a parallel port. You need to get your hardware settled before you start worrying about how to communicate. Where are you getting the sensors? Most of the places that supply sensors have interface kits as well. B&B Electronics, Digikey, and Jameco are all electronic suppliers that have sensors and interface kits available. You might do some web searches for robotics suppliers. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Thu Jul 7 04:42:59 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 7 Jul 2005 12:42:59 +1000 Subject: [python-win32] COM server AddIn In-Reply-To: Message-ID: <067001c5829d$983f2a80$0b0a0a0a@enfoldsystems.local> > unfortunately I do not make any progress. The trace collector > gives me the > following output. > > Object with win32trace dispatcher created (object=None) > pythoncom error: Failed to call the universal dispatcher > > Traceback (most recent call last): > File > "C:\Programme\Python\Lib\site-packages\win32com\universal.py", line > 173, in dispatch > retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, > args, None, None) > File > "C:\Programme\Python\Lib\site-packages\win32com\server\policy.py", > line 330, in _InvokeEx_ > return self._invokeex_(dispid, lcid, wFlags, args, kwargs, > serviceProvider) > File > "C:\Programme\Python\Lib\site-packages\win32com\server\policy.py", > line 647, in _invokeex_ > return DesignatedWrapPolicy.c( self, dispid, lcid, > wFlags, args, kwArgs, > serviceProvider) > File > "C:\Programme\Python\Lib\site-packages\win32com\server\policy.py", > line 593, in _invokeex_ > raise COMException(scode=winerror.DISP_E_MEMBERNOTFOUND) > # not found > win32com.server.exception.COMException: (-2147352573, 'Mitglied nicht > gefunden.', None, -1) > > How can I see the values of the arguments passed to function > ._InvokeEx_? Yes, sadly the logging facilities of the "universal" code isn't as good as the standard IDispatch code. It would be nice to upgrade that. For now you are probably limited to adding print statements to the relevant code referenced in the traceback. At the top of the traceback (universal.py), the lines around the error are: ob._dispid_to_func_[meth.dispid] = meth.name retVal = ob._InvokeEx_(meth.dispid, 0, meth.invkind, args, None, None) printing meth.name should give you an indication. > Is there any way to get the debugger stop in one of the _InvokeEx_ > functions? It depends on your debugger - most have a way to break into the debugger by having your code call some special function provided by the debugger. You could add a call to such a function in universal.py. Mark From lreenaers at ressource-toi.org Thu Jul 7 09:00:05 2005 From: lreenaers at ressource-toi.org (Ludovic Reenaers) Date: Thu, 7 Jul 2005 09:00:05 +0200 (CEST) Subject: [python-win32] polling values from physical sensors In-Reply-To: <05db01c5827b$24740a20$0b0a0a0a@enfoldsystems.local> References: <05db01c5827b$24740a20$0b0a0a0a@enfoldsystems.local> Message-ID: <37497.193.191.208.4.1120719605.squirrel@mail.ressource-toi.org> Actually, I discovered that such sensor can be mounted on a serial or parralel port. I guess It should exists a python interface for one of these port. I'm still wondering about protocols but I assume could write some. -- Ludovic Reenaers |if (getLife(ME)==Null):ME.Life.magnify()| >> I'm currently trying to write service in python (prototyping), >> this service will, ideally, poll physical sensors (such as temperature > sensor, >> light sensor,...) to get range of values. I want to write it on a Win32 > platform. >> But, My problem is: I don't have any idea of the necessary hardware and, >> never the less, I don't know which python/win32 module I will have to >> use >> in order to communicate with those sensor. > > You will need to answer this question without considering Python - eg, how > would you talk to the hardware from *any* language. I assume it depends > on > the specific sensors. Once you can answer that question, we can help you > apply the solution to Python - it is quite likely you would need to use > the > ctypes module for this, but you need to answer that generic question > first. > > Mark > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From jbrunen at datasolid.de Thu Jul 7 13:22:57 2005 From: jbrunen at datasolid.de (Johannes Brunen) Date: Thu, 7 Jul 2005 13:22:57 +0200 Subject: [python-win32] COM server AddIn References: <067001c5829d$983f2a80$0b0a0a0a@enfoldsystems.local> Message-ID: Hi Mark, now I have made some progress! Using the win32traceutil worked well. However the real essential part was the addition of the _typelib_guid_ variable to the server class. Below, I have added the working example. Could you confirm that this is the proper way of using the modules? Two questions remains: 1.) The following code line seems to be unnecessary. The AddIn sever works without it as well. What is the idea for this line? Do I need it? universal.RegisterInterfaces('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 2, ['ICADdyAddIn']) 2.) Debugging the server gives me now the following lines in the trace debug window, which I don't understand. Can you explain what their meaning is? Object with win32trace dispatcher created (object=None) in ._QueryInterface_ with unsupported IID IMarshal ({00000003-0000-0000-C000-000000000046}) in ._QueryInterface_ with unsupported IID IMarshal ({00000003-0000-0000-C000-000000000046}) in ._QueryInterface_ with unsupported IID {0000001B-0000-0000-C000-000000000046} ({0000001B-0000-0000-C000-000000000046}) in ._QueryInterface_ with unsupported IID IStdMarshalInfo ({00000018-0000-0000-C000-000000000046}) in ._QueryInterface_ with unsupported IID IExternalConnection ({00000019-0000-0000-C000-000000000046}) in ._QueryInterface_ with unsupported IID {4C1E39E1-E3E3-4296-AA86-EC938D896E92} ({4C1E39E1-E3E3-4296-AA86-EC938D896E92}) Thank you very much for your supporting help and time!! Best wishes Johannes ## ## Addin1.py - A very simple CADdy++ AddIn server ## from win32com import universal from win32com.server.exception import COMException from win32com.client import gencache import pythoncom import sys # # Support for COM objects we use. # gencache.EnsureModule('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 2, bForDemand=True) # CADdy.tlb # # The TLB defining the interfaces we implement # #universal.RegisterInterfaces('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 2, ['ICADdyAddIn']) class AddIn1: _com_interfaces_ = ['ICADdyAddIn'] _public_methods_ = [] _reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER _reg_clsid_ = "{AB6C657A-2C26-4BD0-ABB8-D777BC91F199}" _reg_progid_ = "CADdyAddIn.PythonTest1" _reg_policy_spec_ = "win32com.server.policy.EventHandlerPolicy" _typelib_guid_ = '{9C3BB401-114D-11D4-AC72-00105A4925FC}' def __init__(self): self.appHostApp = None self.CLSID = "{AB6C657A-2C26-4BD0-ABB8-D777BC91F199}" self.ProgId = "CADdyAddIn.PythonTest1" self.Description = "CADdyAddIn.PythonTest1" def Exit(self): """method Exit""" self.appHostApp = None def Init(self, theCADdy): """method Init""" self.appHostApp = theCADdy pUIManager = theCADdy.UIManager pUIManager.Information("Init Python Test AddIn1...") def RegisterAddin(klass): pass def UnregisterAddin(klass): pass if __name__ == '__main__': import win32com.server.register win32com.server.register.UseCommandLine(AddIn1) if "--unregister" in sys.argv: UnregisterAddin(AddIn1) else: RegisterAddin(AddIn1) From mhammond at skippinet.com.au Thu Jul 7 13:53:43 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 7 Jul 2005 21:53:43 +1000 Subject: [python-win32] COM server AddIn In-Reply-To: Message-ID: <07d401c582ea$8705f580$0b0a0a0a@enfoldsystems.local> Glad you spotted that - if you feel there is something I could add to the docs or examples to make that error less likely in the future, please let me know. > Two questions remains: > 1.) The following code line seems to be unnecessary. The > AddIn sever works > without it as well. What is > the idea for this line? Do I need it? > universal.RegisterInterfaces('{9C3BB401-114D-11D4-AC72-00105A4 > 925FC}', 0, 1, > 2, ['ICADdyAddIn']) You will (probably!) find that line is needed when makepy has not been run over the module (ie, delete your win32com\gen_py directory and try again). It is similar to a gencache.EnsureModule call. Please try it and let me know if that is not true :) > 2.) Debugging the server gives me now the following lines in > the trace debug > window, which I don't understand. Can you explain what their > meaning is? > Object with win32trace dispatcher created (object=None) > in ._QueryInterface_ > with unsupported > IID IMarshal ({00000003-0000-0000-C000-000000000046}) The short version: it is recording every unsupported QueryInterface call made on your (Python)COM object. Longer: It means that something, somewhere is querying your object to see what interfaces it supports. Things like IMarshall are queried by COM itself, whereas others will be called by your host application. The ones with names as well as IIDs are known by win32com - the ones with the IID repeated twice are not known. In many cases, the caller is quite prepared for the object to not support the interface, so things continue as normal - ie, in most cases they can be ignored - but in other cases can give you good clues about what the host application is expecting of you. > Thank you very much for your supporting help and time!! My pleasure - I like to see people get this stuff working :) Mark From jbrunen at datasolid.de Thu Jul 7 14:51:43 2005 From: jbrunen at datasolid.de (Johannes Brunen) Date: Thu, 7 Jul 2005 14:51:43 +0200 Subject: [python-win32] COM server AddIn References: <07d401c582ea$8705f580$0b0a0a0a@enfoldsystems.local> Message-ID: Hi Mark, "Mark Hammond" schrieb im Newsbeitrag news:07d401c582ea$8705f580$0b0a0a0a at enfoldsystems.local... > Glad you spotted that - if you feel there is something I could add to the > docs or examples to make that error less likely in the future, please let > me > know. For me a well written example with sufficient documentation works best. Originally, I have had a bad time because our CADdy COM server has had a intrinsically implementation error. After removing that I made good progress. What is really important for me, is that the examples are correct and state of the art. However, I'm unable to make a judgement for the given ones. >> Two questions remains: >> 1.) The following code line seems to be unnecessary. The >> AddIn sever works >> without it as well. What is >> the idea for this line? Do I need it? >> universal.RegisterInterfaces('{9C3BB401-114D-11D4-AC72-00105A4 >> 925FC}', 0, 1, >> 2, ['ICADdyAddIn']) > > You will (probably!) find that line is needed when makepy has not been run > over the module (ie, delete your win32com\gen_py directory and try again). > It is similar to a gencache.EnsureModule call. Please try it and let me > know if that is not true :) I do not have any problem with removing the cache directory. But I always run the gencache.EnsureModule('{9C3BB401-114D-11D4-AC72-00105A4925FC}', 0, 1, 2, bForDemand=True) # CADdy.tlb statement to ensure at runtime the existence of the typelibrary wrapper modules. Actually, I won't run makepy.py at all. Thank you very much Johannes From guy.lateur at b-b.be Fri Jul 8 15:41:45 2005 From: guy.lateur at b-b.be (Guy Lateur) Date: Fri, 8 Jul 2005 15:41:45 +0200 Subject: [python-win32] Outlook COM: how to create a MailItem from a .msg file Message-ID: Yes! I finally got it to work. I've written a VBscript which I'll call from python. It uses Outlook.Redemption's SafeMailItem. No need to use IMAP or whatever services. Only weird thing is it doesn't put the msg in the Inbox, as I intended, but in the Drafts folder. Well, never mind that, it's a temp object anyway. Here's the code: Dim sItem, oItem Dim myDestBox, myNS, myOL Set myOL = CreateObject("Outlook.Application") Set myNS = myOL.GetNamespace("MAPI") Set sItem = CreateObject("Redemption.SafeMailItem") Set myDestBox = myNS.GetDefaultFolder(6) Set oItem = myDestBox.Items.Add(0) sItem.Item = oItem sItem.Import "H:\Inhoud-iedereen\Inhoud-Guy\app\BBProject\data\test\Leemarchitect.msg ", 3 sItem.Save Cheers, g -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050708/9c8321fd/attachment.htm From guy.lateur at b-b.be Fri Jul 8 16:29:41 2005 From: guy.lateur at b-b.be (Guy Lateur) Date: Fri, 8 Jul 2005 16:29:41 +0200 Subject: [python-win32] Outlook COM: how to create a MailItem from a .msg file Message-ID: python version: import win32com.client myOL = win32com.client.Dispatch("Outlook.Application") myNS = myOL.GetNamespace("MAPI") sItem = win32com.client.Dispatch("Redemption.SafeMailItem") myDestBox = myNS.GetDefaultFolder(6) oItem = myDestBox.Items.Add(0) sItem.Item = oItem sItem.Import("H:\\Inhoud-iedereen\\Inhoud-Guy\\app\\BBProject\\data\\tes t\\Leemarchitect.msg", 3) sItem.Save() -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050708/a4cae2d9/attachment.htm From jonkelly at fastmail.fm Sun Jul 10 06:53:24 2005 From: jonkelly at fastmail.fm (Jonathan Kelly) Date: Sun, 10 Jul 2005 14:53:24 +1000 Subject: [python-win32] Can't install pythonwin Message-ID: <42D0A9C4.10300@fastmail.fm> Hi, When I try to install python win, after clicking throught the install options, it comes up with an error "pywin32-204.win.exe has generated errors and will be closed ...". I have python-2.4.1 installed and that seems OK. This is on Windows 2000 sp4 plus all updates. Any ideas? Jonathan. From newgat11 at yahoo.com Sun Jul 10 20:29:40 2005 From: newgat11 at yahoo.com (the New me) Date: Sun, 10 Jul 2005 11:29:40 -0700 (PDT) Subject: [python-win32] reading linked excel spreadsheet Message-ID: <20050710182940.3728.qmail@web54504.mail.yahoo.com> I used EasyExcel class from Python Programming on Win32 by Mr. Hammond to open an excel worksheet and read the data. the excell is linked to another data feed (DDE). it works fine on regular files but when I try to getContiguousRange every hour for example, it asks if I want to open the Excel worksheet again. I'd like to run this program unattended, I do not want it to ask to open the file to update the data, just do it automatically. I tried to have the options ready from the Excel side (automatic updates to links, lower security levels, etc... ). I'd like to automate this process so that it could do it without having to attend to it. there must be some command from Python to tell excell to update the DDE and links and get results without having excell to ask. (or not having to open the sheet every time? or soemthing) I am missing something but dont know what it is. must be soem VBA stuff or some command from the python side to bypass the asking part. Thanks for any help Newt __________________________________ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail From upadhyay at gmail.com Mon Jul 11 15:59:33 2005 From: upadhyay at gmail.com (Amit Upadhyay) Date: Mon, 11 Jul 2005 19:29:33 +0530 Subject: [python-win32] com server with py2exe fails to import standard module Message-ID: <349edb3805071106592fc01ec0@mail.gmail.com> Hi, I have a COM server which is working fine on my development machine, and I am trying to create a distributable using py2exe. Setup.py file is something like this: # setup.py from distutils.core import setup import py2exe import sys sys.argv.append("py2exe") import mycomsvr opts = { "py2exe": { "includes": "encodings,encodings.*" } } setup(com_server=["mycomsvr"], options=opts) and it successfully creates the COM server, and i register it using regsvr32.exe, and I can then win32com.client.Dispatch from python command line on my machine. But when I tranfer it to some other machine, i can not create an inproc instance of it using win32com.client.dispatch, it gives me: Python 2.3.5 (#62, Feb 8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import win32com.client >>> w = win32com.client.Dispatch("webaroo.btdownloader") Traceback (most recent call last): File "boot_com_servers.py", line 44, in ? File "btdownloader.pyc", line 14, in ? File "socket.pyc", line 44, in ? File "_socket.pyc", line 9, in ? File "_socket.pyc", line 7, in __load ImportError: DLL load failed: The specified module could not be found. pythoncom error: ERROR: server.policy could not create an instance. Traceback (most recent call last): File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 144, in C reateInstance File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 202, in _ CreateInstance_ File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 727, in c all_func File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 717, in r esolve_func exceptions.AttributeError: 'module' object has no attribute 'BTDownloader' pythoncom error: CPyFactory::CreateInstance failed to create instance. (80004005 ) Traceback (most recent call last): File "", line 1, in ? File "C:\Python23\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c lsctx) File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 91, in _ GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 79, in _ GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II D_IDispatch) pywintypes.com_error: (-2147467259, 'Unspecified error', None, None) >>> sys.path ['C:\\Documents and Settings\\webaroo\\Desktop\\amitu\\code\\client\\Windows\\br anches\\b_p2p-multi\\P2P\\py-bittorrent\\dist\\library.zip'] >>> import socket >>> w = win32com.client.Dispatch("webaroo.btdownloader") pythoncom error: ERROR: server.policy could not create an instance. Traceback (most recent call last): File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 144, in C reateInstance File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 202, in _ CreateInstance_ File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 727, in c all_func File "C:\Python23\Lib\site-packages\win32com\server\policy.py", line 717, in r esolve_func exceptions.AttributeError: 'module' object has no attribute 'BTDownloader' pythoncom error: CPyFactory::CreateInstance failed to create instance. (80004005 ) Traceback (most recent call last): File "", line 1, in ? File "C:\Python23\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c lsctx) File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 91, in _ GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py", line 79, in _ GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II D_IDispatch) pywintypes.com_error: (-2147467259, 'Unspecified error', None, None) >>> I have tried the same thing with Python2.4 too, but there I cant import standard modules like socket, select etc either. Please suggest me how to solve this problem, TIA. -- Amit Upadhyay Blog: http://www.rootshell.be/~upadhyay +91-9820-859-701 From xeoicq at netscape.net Mon Jul 11 17:41:24 2005 From: xeoicq at netscape.net (Frank Guenther) Date: Mon, 11 Jul 2005 17:41:24 +0200 Subject: [python-win32] win32pipe and buffer size Message-ID: <42D29324.2070307@netscape.net> Hi All, I try to automate a command line tool and have the problem that I can't read the stdout-pipe. I think the reason is the tool doesn't flush the pipe so it is first readable when the process was closed. Can I set the buffer size of the stdout-pipe by win32pipe to force the tool to write to the pipe? Is there a possibility to use win32file to get a low-level access to the pipes or some other solution to the problem? I would be thankful for some hints and example code. Has someone experiences with 'Excpect'-tools like ExcpectNT or Excpect from ActiveState? Could this be an easy solution for my problem? Ciao, Frank From kveretennicov at gmail.com Tue Jul 12 04:38:02 2005 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Tue, 12 Jul 2005 04:38:02 +0200 Subject: [python-win32] win32pipe and buffer size In-Reply-To: <42D29324.2070307@netscape.net> References: <42D29324.2070307@netscape.net> Message-ID: <4660fe3005071119383c484406@mail.gmail.com> On 7/11/05, Frank Guenther wrote: > Hi All, > > I try to automate a command line tool and have the problem that I can't > read the stdout-pipe. > I think the reason is the tool doesn't flush the pipe so it is first > readable when the process was closed. > Can I set the buffer size of the stdout-pipe by win32pipe to force the > tool to write to the pipe? > > Is there a possibility to use win32file to get a low-level access to the > pipes or some other solution to the problem? Have you tried standard subprocess module? It uses unbuffered i/o by default. > I would be thankful for some hints and example code. Hope this helps: ---- echo.py import sys if __name__ == '__main__': print 'echo>', print sys.stdin.readline() ---- caller.py import subprocess if __name__ == '__main__': child = subprocess.Popen( ['python', 'echo.py'], stdin=subprocess.PIPE, stdout=subprocess.PIPE ) child.stdin.write('spam\n') print 'received:', child.stdout.readline() child.wait() - kv From xeoicq at netscape.net Tue Jul 12 10:41:16 2005 From: xeoicq at netscape.net (Frank Guenther) Date: Tue, 12 Jul 2005 10:41:16 +0200 Subject: [python-win32] win32pipe and buffer size In-Reply-To: <4660fe3005071119383c484406@mail.gmail.com> References: <42D29324.2070307@netscape.net> <4660fe3005071119383c484406@mail.gmail.com> Message-ID: <42D3822C.2080505@netscape.net> Thanks for the reply, but it seems I run into the same problem like before when I use the subprocess module. I modified your example in the following way: ---- echo.py import sys if __name__ == '__main__': while 1: indata = sys.stdin.readline() if indata=='end\n': break sys.stdout.write( 'echo>'+indata) sys.stdout.flush() #!!!!!!!!!!!! don't work without ---- caller.py import subprocess if __name__ == '__main__': child = subprocess.Popen( ['python', 'echo.py'], stdin=subprocess.PIPE, stdout=subprocess.PIPE ) i=1 while i<10: child.stdin.write('spam'+str(i)+'\n') data = child.stdout.readline() print data i+=1 child.stdin.write('end\n') Now the problem arises if I comment line 8 "sys.stdout.flush()" or replace line 7 and 8 by "print 'echo>'+indata" The tool I try to automate has the same behavior. But there must be a way to get the text that is printed by the tool. Is it necessary to use more low-level access and in which way, win32file, etc... ? Tschau, Frank kveretennicov at gmail.com wrote: >On 7/11/05, Frank Guenther wrote: > > >>Hi All, >> >>I try to automate a command line tool and have the problem that I can't >>read the stdout-pipe. >>I think the reason is the tool doesn't flush the pipe so it is first >>readable when the process was closed. >>Can I set the buffer size of the stdout-pipe by win32pipe to force the >>tool to write to the pipe? >> >>Is there a possibility to use win32file to get a low-level access to the >>pipes or some other solution to the problem? >> >> > >Have you tried standard subprocess module? It uses unbuffered i/o by default. > > > >>I would be thankful for some hints and example code. >> >> > >Hope this helps: > >---- echo.py > >import sys > >if __name__ == '__main__': > print 'echo>', > print sys.stdin.readline() > >---- caller.py > >import subprocess > >if __name__ == '__main__': > child = subprocess.Popen( > ['python', 'echo.py'], > stdin=subprocess.PIPE, > stdout=subprocess.PIPE > ) > child.stdin.write('spam\n') > print 'received:', child.stdout.readline() > child.wait() > >- kv > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050712/922344e0/attachment.htm From mhammond at skippinet.com.au Tue Jul 12 11:11:01 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 12 Jul 2005 19:11:01 +1000 Subject: [python-win32] win32pipe and buffer size In-Reply-To: <42D3822C.2080505@netscape.net> Message-ID: <012401c586c1$a1d63f70$0b0a0a0a@enfoldsystems.local> > if __name__ == '__main__': > child = subprocess.Popen( > ['python', 'echo.py'], Try adding "-u" as an option to Python - this will force Python to reopen stdout etc as unbuffered (ie, the problem is the client is buffering) Mark From b_papadopoulos at iris.gr Tue Jul 12 12:13:56 2005 From: b_papadopoulos at iris.gr (Bill Papadopoulos) Date: Tue, 12 Jul 2005 13:13:56 +0300 Subject: [python-win32] com server with py2exe fails to import standard module References: Message-ID: <003801c586ca$6981d7c0$2700000a@themeliodomi.gr> Dear Amit Upadhyay, Try using cx_Freeze http://starship.python.net/crew/atuining/cx_Freeze/ Bill Vax PAPADOPOULOS __________________________ b_papadopoulos at iris.gr bpapadopoulos at hotmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050712/aa42177e/attachment.htm From kveretennicov at gmail.com Tue Jul 12 15:46:48 2005 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Tue, 12 Jul 2005 15:46:48 +0200 Subject: [python-win32] com server with py2exe fails to import standard module In-Reply-To: <349edb3805071106592fc01ec0@mail.gmail.com> References: <349edb3805071106592fc01ec0@mail.gmail.com> Message-ID: <4660fe300507120646746fd5cc@mail.gmail.com> On 7/11/05, Amit Upadhyay wrote: > Hi, > > I have a COM server which is working fine on my development machine, [snip] > But when I tranfer it to some other machine, i can not create an > inproc instance of it using win32com.client.dispatch, it gives me: > > Python 2.3.5 (#62, Feb 8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import win32com.client > >>> w = win32com.client.Dispatch("webaroo.btdownloader") > Traceback (most recent call last): > File "boot_com_servers.py", line 44, in ? > File "btdownloader.pyc", line 14, in ? > File "socket.pyc", line 44, in ? > File "_socket.pyc", line 9, in ? > File "_socket.pyc", line 7, in __load > ImportError: DLL load failed: The specified module could not be found. Try viewing your exe's dependencies with Microsoft's Dependency Walker tool. You'lI see which dlls are required by exe and which of them are missing. Latest version also has Profile mode, which lets you observe dlls loaded dynamically at run-time. (You should do it at "the other machine", not development machine.) - kv From xeoicq at netscape.net Tue Jul 12 18:09:05 2005 From: xeoicq at netscape.net (Frank Guenther) Date: Tue, 12 Jul 2005 18:09:05 +0200 Subject: [python-win32] win32pipe and buffer size In-Reply-To: <012401c586c1$a1d63f70$0b0a0a0a@enfoldsystems.local> References: <012401c586c1$a1d63f70$0b0a0a0a@enfoldsystems.local> Message-ID: <42D3EB21.4070608@netscape.net> mhammond at skippinet.com.au wrote: >>if __name__ == '__main__': >> child = subprocess.Popen( >> ['python', 'echo.py'], >> >> > >Try adding "-u" as an option to Python - this will force Python to reopen >stdout etc as unbuffered (ie, the problem is the client is buffering) > >Mark > > That is exactly the problem, but how can I get the text which the buffering client prints to the screen? The C++ Code looks like: printf ("1. Run Static Tests contained in Sections 5 through 9.\n"); printf ("2. Run Dynamic Tests contained in Sections 10 through 11.\n\n"); printf ("Enter choice (1 or 2): "); scanf ("%d", &nTestChoice); If I use the program manually the stdout is displayed on the screen. A solution would be to change the program, but I don't have the possibility to change it. Is there an other way? Tschau, Frank -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050712/3589c47d/attachment.htm From rays at blue-cove.com Tue Jul 12 19:04:05 2005 From: rays at blue-cove.com (Ray Schumacher) Date: Tue, 12 Jul 2005 10:04:05 -0700 Subject: [python-win32] list/kill processes on Win9x and NT+... Message-ID: <5.2.0.4.2.20050712095149.107eb630@blue-cove.com> I had looked over the methods to list/kill processes on Win32, and could not (yet) find a "pure" Python way to do it that works on 9x, since I could not get win32pdhutil to work on 98. So, I combined subprocess.py and pv.exe from http://www.xmlsp.com/pview/PrcView.zip and wrote a quick app to kill unauthorized process and compiled with py2exe. Does anyone have a way to list/kill without the external process that works in all 9x and XP? Ray Schumacher #!/usr/bin/env python import win32process, win32con import time import subprocess whiteList = ["Eudora.exe", "Explorer.EXE", "MSTask.exe", "WCESCOMM.EXE", "WinMgmt.exe", "WnvIRQ32.exe", "cmd.exe", "explorer.exe", "firefox.exe", "hh.exe", "lsass.exe", "mdm.exe", "mplayer2.exe", "pv.exe", "python.exe", "pythonw.exe", "services.exe", "smss.exe", "spoolsv.exe", "svchost.exe", "taskmgr.exe", "winlogon.exe"] def launchWithoutConsole(command, args): """Launches 'command' windowless and waits until finished""" startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW proc = subprocess.Popen([command] + args, startupinfo=startupinfo, shell=True, bufsize=1000, stdin=subprocess.PIPE, stdout=subprocess.PIPE, ) #print dir(proc) return proc.stdout.readlines() def getProcList(): pList = [] result = launchWithoutConsole("pv\\pv", ["-fq",]) result.sort() for i in result: pList.append((i.strip()).split('\t')) ## print the running processes #for i in pList: # print '"'+i[0]+'",', return pList def killProcess(proc): result = launchWithoutConsole("pv\\pv", ["-kfq", proc]) def main(): while True: processList = getProcList() for i in processList: if i[0] not in whiteList: print i[0]+'is bad' killProcess(i[0]) time.sleep(1) if __name__ == '__main__': # Import Psyco if available try: import psyco #psyco.log() psyco.profile() #psyco.full() except ImportError: pass main() -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050712/e8d3e91d/attachment.htm From gagenellina at softlab.com.ar Wed Jul 13 04:12:12 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Tue, 12 Jul 2005 23:12:12 -0300 Subject: [python-win32] win32pipe and buffer size In-Reply-To: <42D3EB21.4070608@netscape.net> References: <012401c586c1$a1d63f70$0b0a0a0a@enfoldsystems.local> <42D3EB21.4070608@netscape.net> Message-ID: <6.2.1.2.0.20050712224429.03047eb0@192.168.0.115> At Tuesday 12/7/2005 13:09, Frank Guenther wrote: >That is exactly the problem, but how can I get the text which the >buffering client prints to the screen? > >The C++ Code looks like: > > printf ("1. Run Static Tests contained in Sections 5 through > 9.\n"); > printf ("2. Run Dynamic Tests contained in Sections 10 through > 11.\n\n"); > printf ("Enter choice (1 or 2): "); > scanf ("%d", &nTestChoice); > >If I use the program manually the stdout is displayed on the screen. > >A solution would be to change the program, but I don't have the >possibility to change it. >Is there an other way? See the C FAQ on this topic: http://www.eskimo.com/~scs/C-faq/q12.4.html If the OS is buffering the output, perhaps a call to FlushFileBuffers (on the other end of the pipe) would help. But if the buffering is at the C run-time library, I'm afraid there is nothing you could do to flush the output without rewriting the code or hacking the RTL DLLs. To disable buffering on stdout, put any of these calls at the very beginning of the program: setbuf(stdout, NULL) or: setvbuf(stdout, NULL, _IONBF, 0) Gabriel Genellina Softlab SRL From gagenellina at softlab.com.ar Wed Jul 13 04:46:15 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Tue, 12 Jul 2005 23:46:15 -0300 Subject: [python-win32] list/kill processes on Win9x and NT+... In-Reply-To: <5.2.0.4.2.20050712095149.107eb630@blue-cove.com> References: <5.2.0.4.2.20050712095149.107eb630@blue-cove.com> Message-ID: <6.2.1.2.0.20050712234400.0303c800@192.168.0.115> At Tuesday 12/7/2005 14:04, Ray Schumacher wrote: >I had looked over the methods to list/kill processes on Win32, and could >not (yet) find a "pure" Python way to do it that works on 9x, since I >could not get win32pdhutil to work on 98. >So, I combined subprocess.py and pv.exe from >http://www.xmlsp.com/pview/PrcView.zip >and wrote a quick app to kill unauthorized process and compiled with py2exe. > >Does anyone have a way to list/kill without the external process that >works in all 9x and XP? PDH will work for NT, 2000 and up. For Win95/98 you can enumerate processes using ToolHelp32: http://support.microsoft.com/kb/q175030/ Gabriel Genellina Softlab SRL From rays at blue-cove.com Wed Jul 13 05:30:36 2005 From: rays at blue-cove.com (RayS) Date: Tue, 12 Jul 2005 20:30:36 -0700 Subject: [python-win32] list/kill processes on Win9x and NT+... In-Reply-To: <6.2.1.2.0.20050712234400.0303c800@192.168.0.115> References: <5.2.0.4.2.20050712095149.107eb630@blue-cove.com> <6.2.1.2.0.20050712234400.0303c800@192.168.0.115> Message-ID: <6.2.1.2.2.20050712202739.02b262f0@blue-cove.com> Ah, now I just found after searching for "CreateToolhelp32Snapshot" http://sourceforge.net/mailarchive/message.php?msg_id=8291643 Thanks Gabriel, Ray At 07:46 PM 7/12/2005, Gabriel Genellina wrote: >At Tuesday 12/7/2005 14:04, Ray Schumacher wrote: > >>I had looked over the methods to list/kill processes on Win32, and could not (yet) find a "pure" Python way to do it that works on 9x, since I could not get win32pdhutil to work on 98. >>So, I combined subprocess.py and pv.exe from >>http://www.xmlsp.com/pview/PrcView.zip >>and wrote a quick app to kill unauthorized process and compiled with py2exe. >> >>Does anyone have a way to list/kill without the external process that works in all 9x and XP? > >PDH will work for NT, 2000 and up. For Win95/98 you can enumerate processes using ToolHelp32: http://support.microsoft.com/kb/q175030/ > > >Gabriel Genellina >Softlab SRL From gagenellina at softlab.com.ar Wed Jul 13 06:52:04 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Wed, 13 Jul 2005 01:52:04 -0300 Subject: [python-win32] list/kill processes on Win9x and NT+... In-Reply-To: <6.2.1.2.2.20050712202739.02b262f0@blue-cove.com> References: <5.2.0.4.2.20050712095149.107eb630@blue-cove.com> <6.2.1.2.0.20050712234400.0303c800@192.168.0.115> <6.2.1.2.2.20050712202739.02b262f0@blue-cove.com> Message-ID: <6.2.1.2.0.20050713014853.03173a30@192.168.0.115> At Wednesday 13/7/2005 00:30, RayS wrote: >Ah, now I just found after searching for "CreateToolhelp32Snapshot" >http://sourceforge.net/mailarchive/message.php?msg_id=8291643 > >>Does anyone have a way to list/kill without the external process that > works in all 9x and XP? > > > >PDH will work for NT, 2000 and up. For Win95/98 you can enumerate > processes using ToolHelp32: http://support.microsoft.com/kb/q175030/ If you eventually craft a function for enumerating all processes which works on all platforms, would be nice if you could post it here... Gabriel Genellina Softlab SRL From spastor at center.com Wed Jul 13 18:37:25 2005 From: spastor at center.com (sebastien Pastor) Date: Wed, 13 Jul 2005 18:37:25 +0200 Subject: [python-win32] list/kill processes on Win9x and NT+... In-Reply-To: <6.2.1.2.0.20050713014853.03173a30@192.168.0.115> References: <5.2.0.4.2.20050712095149.107eb630@blue-cove.com> <6.2.1.2.0.20050712234400.0303c800@192.168.0.115> <6.2.1.2.2.20050712202739.02b262f0@blue-cove.com> <6.2.1.2.0.20050713014853.03173a30@192.168.0.115> Message-ID: <42D54345.6030906@center.com> I am using wmi and win32api. so it goes like : import wmi c = wmi.WMI () try: for p in c.Win32_Process (): if p.Name=="process.exe": print "killing " + str(p.ProcessId) + str(p.Name) win32api.TerminateProcess(handle,-1) win32api.CloseHandle(handle) except win32api.error: blablabla Hope this helps .. Cheers seb Gabriel Genellina wrote: >At Wednesday 13/7/2005 00:30, RayS wrote: > > > >>Ah, now I just found after searching for "CreateToolhelp32Snapshot" >>http://sourceforge.net/mailarchive/message.php?msg_id=8291643 >> >> >>>>Does anyone have a way to list/kill without the external process that >>>> >>>> >>works in all 9x and XP? >> >> >>>PDH will work for NT, 2000 and up. For Win95/98 you can enumerate >>> >>> >>processes using ToolHelp32: http://support.microsoft.com/kb/q175030/ >> >> > >If you eventually craft a function for enumerating all processes which >works on all platforms, would be nice if you could post it here... > > >Gabriel Genellina >Softlab SRL > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > > > From kimwaic888-pythonwin32 at yahoo.com Thu Jul 14 19:50:35 2005 From: kimwaic888-pythonwin32 at yahoo.com (kimwaic888-pythonwin32@yahoo.com) Date: Thu, 14 Jul 2005 10:50:35 -0700 (PDT) Subject: [python-win32] Task Scheduler Message-ID: <20050714175035.1421.qmail@web51402.mail.yahoo.com> Hello list, I am having trouble working with the Windows XP Task Scheduler. I know this might not be exactly a PythonWin32 question because as I searched the web for clue on how I can control the Task Scheduler using PythonWin32, nobody appears to know. The one message I found suggested using the CLI program schtasks.exe. The program with that program is that it prompts you with questions like "Is this okay?" and unlike other cls programs, it doesn't have a "shut-up" flag. There is also a at.exe program which is suppose to have been replaced by the schtasks.exe. It's a lot simpler then schtasks.exe and doesn't prompt you for anything - it simply creates a simplified task object in the Scheduler folder for you. However, when the time come to execute, nothing happens. Does anybody know of any other way to interact with the Scheduler? Hopefully, this is something that can be accessed from Pythonwin32, rather then through the CLI programs. Regards, -- John From kveretennicov at gmail.com Thu Jul 14 20:41:53 2005 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Thu, 14 Jul 2005 20:41:53 +0200 Subject: [python-win32] Task Scheduler In-Reply-To: <20050714175035.1421.qmail@web51402.mail.yahoo.com> References: <20050714175035.1421.qmail@web51402.mail.yahoo.com> Message-ID: <4660fe3005071411416f553734@mail.gmail.com> On 7/14/05, kimwaic888-pythonwin32 at yahoo.com wrote: > Hello list, > > I am having trouble working with the Windows XP Task > Scheduler. ... > There is also a at.exe program which is suppose to > have been replaced by the schtasks.exe. It's a lot > simpler then schtasks.exe and doesn't prompt you for > anything - it simply creates a simplified task object > in the Scheduler folder for you. However, when the > time come to execute, nothing happens. At.exe + subprocess module should be fine. Are you able to schedule tasks with at.exe manually from command line? You may need to double-check datetime format and "/interactive" switch. > > Does anybody know of any other way to interact with > the Scheduler? Hopefully, this is something that can > be accessed from Pythonwin32, rather then through the > CLI programs. I guess you can control it via ITaskScheduler COM interface: http://msdn.microsoft.com/library/en-us/taskschd/taskschd/task_scheduler_start_page.asp But calling at.exe is simpler IMO. - kv From kimwaic888-pythonwin32 at yahoo.com Thu Jul 14 21:36:17 2005 From: kimwaic888-pythonwin32 at yahoo.com (kimwaic888-pythonwin32@yahoo.com) Date: Thu, 14 Jul 2005 12:36:17 -0700 (PDT) Subject: [python-win32] Task Scheduler Message-ID: <20050714193617.20686.qmail@web51406.mail.yahoo.com> Thanks for the reply. Yes, at.exe is very simple but as I said, after the object gets created, it doesn't run. For example, I issued the CLI command: at "12:30" /interactive "python.exe example.py" where example.py is some sample Python program. Well, 12:30 came and gone and nothing happened. Regards, -- John Konstantin Veretennicov wrote: > On 7/14/05, kimwaic888-pythonwin32 at yahoo.com > wrote: > >>Hello list, >> >>I am having trouble working with the Windows XP Task >>Scheduler. > > > ... > > >>There is also a at.exe program which is suppose to >>have been replaced by the schtasks.exe. It's a lot >>simpler then schtasks.exe and doesn't prompt you for >>anything - it simply creates a simplified task object >>in the Scheduler folder for you. However, when the >>time come to execute, nothing happens. > > > At.exe + subprocess module should be fine. Are you able to schedule > tasks with at.exe manually from command line? You may need to > double-check datetime format and "/interactive" switch. > > >>Does anybody know of any other way to interact with >>the Scheduler? Hopefully, this is something that can >>be accessed from Pythonwin32, rather then through the >>CLI programs. > > > I guess you can control it via ITaskScheduler COM interface: > http://msdn.microsoft.com/library/en-us/taskschd/taskschd/task_scheduler_start_page.asp > But calling at.exe is simpler IMO. > > - kv > > From rwupole at msn.com Thu Jul 14 22:29:06 2005 From: rwupole at msn.com (Roger Upole) Date: Thu, 14 Jul 2005 16:29:06 -0400 Subject: [python-win32] Task Scheduler Message-ID: There's a taskscheduler module in Pywin32 that gives you access to the Task Scheduler COM interfaces. The scripts in \win32comext\taskscheduler\test have some examples of how they're used. Roger From kimwaic888-pythonwin32 at yahoo.com Fri Jul 15 05:44:46 2005 From: kimwaic888-pythonwin32 at yahoo.com (kimwaic888-pythonwin32@yahoo.com) Date: Thu, 14 Jul 2005 20:44:46 -0700 (PDT) Subject: [python-win32] Task Scheduler Message-ID: <20050715034446.38483.qmail@web51407.mail.yahoo.com> Thank you, Roger, for pointing that out. I tried the test sample and it did create the scheduler object as one would expect. However, same as the at.exe attempt I did from CLI, the object doesn't run when the time came. I manually requested "Run" and the task runs fine (with the message dialog poping up). I retried several times by playing around with the settings (manually entering password and so forth) but nothing worked. Any clues? Thanks, > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org] On Behalf Of Roger Upole > Sent: Thursday, July 14, 2005 1:29 PM > To: python-win32 at python.org > Subject: [python-win32] Task Scheduler > > > There's a taskscheduler module in Pywin32 that gives > you access to the Task Scheduler COM interfaces. > The scripts in \win32comext\taskscheduler\test have > some examples of how they're used. > > Roger > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- John Henry From rwupole at msn.com Fri Jul 15 09:12:08 2005 From: rwupole at msn.com (Roger Upole) Date: Fri, 15 Jul 2005 03:12:08 -0400 Subject: [python-win32] Re: Task Scheduler Message-ID: You can use GetExitCode to return the reason it couldn't start. One thing to check is that the user account it's running under has the log on as batch job privilege. Roger > Thank you, Roger, for pointing that out. I tried the > test sample and it did create the scheduler object as > one would expect. > > However, same as the at.exe attempt I did from CLI, > the object doesn't run when the time came. I manually > requested "Run" and the task runs fine (with the > message dialog poping up). > > I retried several times by playing around with the > settings (manually entering password and so forth) but > nothing worked. > > Any clues? > > Thanks, > From tony at tcapp.com Fri Jul 15 17:59:54 2005 From: tony at tcapp.com (Tony Cappellini) Date: Fri, 15 Jul 2005 08:59:54 -0700 Subject: [python-win32] win32pipe and buffer size Message-ID: <6.1.2.0.0.20050715085817.01fbbe50@mail.yamato.com> Hi There is a pure-python version of expect called pExpect- use google to find it in sourceforge It's not from Active State- but Active State is not such a big deal. Message: 2 Date: Mon, 11 Jul 2005 17:41:24 +0200 From: Frank Guenther Subject: [python-win32] win32pipe and buffer size To: python-win32 at python.org Message-ID: <42D29324.2070307 at netscape.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hi All, I try to automate a command line tool and have the problem that I can't read the stdout-pipe. I think the reason is the tool doesn't flush the pipe so it is first readable when the process was closed. Can I set the buffer size of the stdout-pipe by win32pipe to force the tool to write to the pipe? Is there a possibility to use win32file to get a low-level access to the pipes or some other solution to the problem? I would be thankful for some hints and example code. Has someone experiences with 'Excpect'-tools like ExcpectNT or Excpect from ActiveState? Could this be an easy solution for my problem? Ciao, Frank From yeo_man007 at yahoo.com Sat Jul 16 01:49:29 2005 From: yeo_man007 at yahoo.com (Yeo Man) Date: Fri, 15 Jul 2005 16:49:29 -0700 (PDT) Subject: [python-win32] Problem creating a COM from Python and then using it from another Python program Message-ID: <20050715234930.40208.qmail@web53901.mail.yahoo.com> I'm probably doing something very silly here, but I'm having trouble creating a COM from a Python program, and then using that COM object. I've followed the steps in Chapter 5 of: Python Programming on Win32 and in the article: http://pyzine.com/Issue007/index.html http://www.pyzine.com/Issue007/Section_Articles/article_PythonCOM.html?printit=1 It gives the appearance of creating the COM object, because when I run the script (from within PythonWin), I get this: Registered: Nassco.TribonComDxComponent I can see it with REGEDIT: Nassco.TribonComDxComponent CLSID -> (GUID from my _reg_clsid_ statement) But when I try to run makepy (from the Tools menu inside the PythonWin IDE), I can't find the Text Library for it. And my test program can't instantiate the class with a Dispatch call. (But that's probably because the makepy can't be run on it.) I'm probably doing something very silly here, but I've been looking at this for too long to see what that is. Would someone be able to give me a pointer on what I'm doing wrong? Thanks in advance. Johan -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: NaComDxComponent.py Url: http://mail.python.org/pipermail/python-win32/attachments/20050715/c6fc42bd/NaComDxComponent.diff -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Test_COM5_Driver_03.py Url: http://mail.python.org/pipermail/python-win32/attachments/20050715/c6fc42bd/Test_COM5_Driver_03.diff -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: VersionInfo.PythonWin.txt Url: http://mail.python.org/pipermail/python-win32/attachments/20050715/c6fc42bd/VersionInfo.PythonWin.txt From mhammond at skippinet.com.au Sat Jul 16 02:17:12 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 16 Jul 2005 10:17:12 +1000 Subject: [python-win32] Problem creating a COM from Python and then using itfrom another Python program In-Reply-To: <20050715234930.40208.qmail@web53901.mail.yahoo.com> Message-ID: The "problem" is that creating a COM object in Python does *not* create a typelib. Therefore, you are unable to run makepy for the object. However, simply creating the object and using it should work fine. Mark > -----Original Message----- > From: python-win32-bounces+mhammond=keypoint.com.au at python.org > [mailto:python-win32-bounces+mhammond=keypoint.com.au at python.org]On > Behalf Of Yeo Man > Sent: Saturday, 16 July 2005 9:49 AM > To: python-win32 at python.org > Cc: Yeo_Man at_Home > Subject: [python-win32] Problem creating a COM from Python and then > using itfrom another Python program > > > I'm probably doing something very silly here, but > I'm having trouble creating a COM from a Python > program, and then using that COM object. I've > followed the steps in Chapter 5 of: > > Python Programming on Win32 > > and in the article: > > http://pyzine.com/Issue007/index.html > http://www.pyzine.com/Issue007/Section_Articles/article_PythonCOM. > html?printit=1 > > It gives the appearance of creating the COM object, > because when I run the script (from within > PythonWin), I get this: > > Registered: Nassco.TribonComDxComponent > > I can see it with REGEDIT: > > Nassco.TribonComDxComponent > CLSID -> (GUID from my _reg_clsid_ statement) > > But when I try to run makepy (from the Tools > menu inside the PythonWin IDE), I can't find the > Text Library for it. And my test program can't > instantiate the class with a Dispatch call. > (But that's probably because the makepy can't > be run on it.) > > I'm probably doing something very silly here, > but I've been looking at this for too long to > see what that is. > Would someone be able to give me a pointer on > what I'm doing wrong? > > Thanks in advance. > > Johan > > From magoldfish at gmail.com Tue Jul 19 23:53:05 2005 From: magoldfish at gmail.com (Marcus Goldfish) Date: Tue, 19 Jul 2005 17:53:05 -0400 Subject: [python-win32] getting a list of internet explorer instances? Message-ID: <5e183f3d0507191453543de8@mail.gmail.com> I've seen some posts on launching internet explorer, but not one on getting a list of running Internet Explorer instances. I imagine this is a 1-2 liner in pywin32-- any COM/win32all experts out there know how to do this? My goal is to write a script that can take a snapshot of the Internet Explorer instances running on my machine, pull the urls, and save them to a file. Any help appreciated! Thanks, Marcus From gagenellina at softlab.com.ar Wed Jul 20 01:50:00 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Tue, 19 Jul 2005 20:50:00 -0300 Subject: [python-win32] Task Scheduler In-Reply-To: <20050715034446.38483.qmail@web51407.mail.yahoo.com> References: <20050715034446.38483.qmail@web51407.mail.yahoo.com> Message-ID: <6.2.1.2.0.20050719203316.02e03240@192.168.0.115> At Friday 15/7/2005 00:44, kimwaic888-pythonwin32 at yahoo.com wrote: >Thank you, Roger, for pointing that out. I tried the >test sample and it did create the scheduler object as >one would expect. > >However, same as the at.exe attempt I did from CLI, >the object doesn't run when the time came. I manually >requested "Run" and the task runs fine (with the >message dialog poping up). > >I retried several times by playing around with the >settings (manually entering password and so forth) but >nothing worked. > >Any clues? Does the process depends on its startup directory? Runs under any user account? Needs any privilege? Is interactive? (use /interactive) Gabriel Genellina Softlab SRL From kimwaic888-pythonwin32 at yahoo.com Wed Jul 20 02:34:39 2005 From: kimwaic888-pythonwin32 at yahoo.com (kimwaic888-pythonwin32@yahoo.com) Date: Tue, 19 Jul 2005 17:34:39 -0700 (PDT) Subject: [python-win32] Task Scheduler Message-ID: <20050720003439.6982.qmail@web51407.mail.yahoo.com> Gabriel, If you have an installed copy of PythonWin32 running under XP, you can try the sample app too and see if it works for you. It's in the win32comext\taskscheduler\test directory. Just double-click on test_addtask.py. On my system, the object gets created but it doesn't run unless I do it manually. Regards, -- John Gabriel Genellina wrote: > At Friday 15/7/2005 00:44, kimwaic888-pythonwin32 at yahoo.com wrote: > >> Thank you, Roger, for pointing that out. I tried the >> test sample and it did create the scheduler object as >> one would expect. >> >> However, same as the at.exe attempt I did from CLI, >> the object doesn't run when the time came. I manually >> requested "Run" and the task runs fine (with the >> message dialog poping up). >> >> I retried several times by playing around with the >> settings (manually entering password and so forth) but >> nothing worked. >> >> Any clues? > > > Does the process depends on its startup directory? > Runs under any user account? > Needs any privilege? > Is interactive? (use /interactive) > > > Gabriel Genellina > Softlab SRL > > -- John Henry From rwupole at msn.com Wed Jul 20 18:16:40 2005 From: rwupole at msn.com (Roger Upole) Date: Wed, 20 Jul 2005 12:16:40 -0400 Subject: [python-win32] Re: getting a list of internet explorer instances? Message-ID: import win32com.client sw=win32com.client.Dispatch('{9BA05972-F6A8-11CF-A442-00A0C90A8F39}') for w in sw: print w.LocationURL The GUID represents the ShellWindows class, found in the makepy file for "microsoft internet controls". hth Roger "Marcus Goldfish" wrote: > I've seen some posts on launching internet explorer, but not one on > getting a list of running Internet Explorer instances. I imagine this > is a 1-2 liner in pywin32-- any COM/win32all experts out there know > how to do this? > > My goal is to write a script that can take a snapshot of the Internet > Explorer instances running on my machine, pull the urls, and save them > to a file. > > Any help appreciated! > Thanks, > Marcus From kimwaic888-pythonwin32 at yahoo.com Thu Jul 21 00:23:50 2005 From: kimwaic888-pythonwin32 at yahoo.com (kimwaic888-pythonwin32@yahoo.com) Date: Wed, 20 Jul 2005 15:23:50 -0700 (PDT) Subject: [python-win32] constants problem Message-ID: <20050720222350.54627.qmail@web51401.mail.yahoo.com> Hi, list: This is puzzling. For the PythonWin32 based Word script I developed, everything works fine on my machine. However, when I run the script on another machine, it would fail whenever it comes across any of the constants variables (such as, for example, constants.wdLine, constants.wdStory, or any of them). I checked and rechecked and the machines are all running the same version of Python (2.3) and same versions of PythonWin32. Anybody?? Thanks, -- -- John Henry From kimwaic888-pythonwin32 at yahoo.com Thu Jul 21 01:51:12 2005 From: kimwaic888-pythonwin32 at yahoo.com (kimwaic888-pythonwin32@yahoo.com) Date: Wed, 20 Jul 2005 16:51:12 -0700 (PDT) Subject: [python-win32] constants problem Message-ID: <20050720235112.52862.qmail@web51405.mail.yahoo.com> Regarding my previous message, here's sample code I am using. It runs fine on my computer but not others. These computers have same versions of Word, Python, and Python-win32: #### from win32com.client import Dispatch, constants wordApp = Dispatch("Word.Application") print constants.wdTextWrappingBreak print constants.wdLine wordApp.Quit() #### > Hi, list: > > This is puzzling. For the PythonWin32 based Word > script I developed, everything works fine on my > machine. However, when I run the script on another > machine, it would fail whenever it comes across any of > the constants variables (such as, for example, > constants.wdLine, constants.wdStory, or any of them). > I checked and rechecked and the machines are all > running the same version of Python (2.3) and same > versions of PythonWin32. > > Anybody?? > > Thanks, > > -- > > -- > John Henry > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- John Henry From magoldfish at gmail.com Thu Jul 21 04:01:12 2005 From: magoldfish at gmail.com (Marcus Goldfish) Date: Wed, 20 Jul 2005 22:01:12 -0400 Subject: [python-win32] getting a list of internet explorer instances? In-Reply-To: References: Message-ID: <5e183f3d05072019012cdea17b@mail.gmail.com> > import win32com.client > sw=win32com.client.Dispatch('{9BA05972-F6A8-11CF-A442-00A0C90A8F39}') > for w in sw: > print w.LocationURL > > The GUID represents the ShellWindows class, found in > the makepy file for "microsoft internet controls". Yes, that helps a lot! Can you explain the ShellWindows class a little more, or point me to a URL reference? Also, for others interested in this problem, I found two recipes in the Python cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/305273 (long) http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/269345 (similar to this solution) Thanks, Marcus From rwupole at msn.com Thu Jul 21 06:08:12 2005 From: rwupole at msn.com (Roger Upole) Date: Thu, 21 Jul 2005 00:08:12 -0400 Subject: [python-win32] Re: getting a list of internet explorer instances? Message-ID: The MSDN docs are here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/objects/shellwindows/shellwindows.asp Roger "Marcus Goldfish" wrote: >> import win32com.client >> sw=win32com.client.Dispatch('{9BA05972-F6A8-11CF-A442-00A0C90A8F39}') >> for w in sw: >> print w.LocationURL >> >> The GUID represents the ShellWindows class, found in >> the makepy file for "microsoft internet controls". > Yes, that helps a lot! Can you explain the ShellWindows class a > little more, or point me to a URL reference? > > Also, for others interested in this problem, I found two recipes in > the Python cookbook: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/305273 (long) > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/269345 > (similar to this solution) > > Thanks, > Marcus From rwupole at msn.com Thu Jul 21 06:20:47 2005 From: rwupole at msn.com (Roger Upole) Date: Thu, 21 Jul 2005 00:20:47 -0400 Subject: [python-win32] Re: constants problem Message-ID: For the constants to be available, you'll need to run makepy on the machines your script will run on. win32com.client.gencache.EnsureDispatch will create the generated file for an object if it doesn't already exist. Roger kimwaic888-pythonwin32 at yahoo.com wrote: > Hi, list: > > This is puzzling. For the PythonWin32 based Word > script I developed, everything works fine on my > machine. However, when I run the script on another > machine, it would fail whenever it comes across any of > the constants variables (such as, for example, > constants.wdLine, constants.wdStory, or any of them). > I checked and rechecked and the machines are all > running the same version of Python (2.3) and same > versions of PythonWin32. > > Anybody?? > > Thanks, > > -- > > -- > John Henry From kimwaic888-pythonwin32 at yahoo.com Thu Jul 21 18:15:01 2005 From: kimwaic888-pythonwin32 at yahoo.com (kimwaic888-pythonwin32@yahoo.com) Date: Thu, 21 Jul 2005 09:15:01 -0700 (PDT) Subject: [python-win32] constants problem Message-ID: <20050721161501.89517.qmail@web51408.mail.yahoo.com> Roger, Thank you for the reply. Could you please elaborate a little further. I don't fully understand the message. You said: >For the constants to be available, you'll need to run makepy on the machines your script will run on. I tried to run makepy.py and a menu of "types" poped up. What should I be doing with that? More importantly, I didn't have to do that on my own machine and everything has been working fine. Why's that? >win32com.client.gencache.EnsureDispatch will create Is that a class method I should invoke from my code? Or is that something I should be doing via an import statement? Or what exactly is that? Thanks again, >-----Original Message----- >From: python-win32-bounces+kimwaic888-pythonwin32=yahoo.com at python.org >[mailto:python-win32-bounces+kimwaic888-pythonwin32=yahoo.com at python.org] On >Behalf Of Roger Upole >Sent: Wednesday, July 20, 2005 9:21 PM >To: python-win32 at python.org >Subject: [python-win32] Re: constants problem > > >For the constants to be available, you'll need to run makepy >on the machines your script will run on. >win32com.client.gencache.EnsureDispatch will create the generated file for >an object if it doesn't already exist. > > Roger > > >kimwaic888-pythonwin32 at yahoo.com wrote: > > > Hi, list: > > > > This is puzzling. For the PythonWin32 based Word > > script I developed, everything works fine on my > > machine. However, when I run the script on another > > machine, it would fail whenever it comes across any of > > the constants variables (such as, for example, constants.wdLine, > > constants.wdStory, or any of them). I checked and rechecked and the > > machines are all running the same version of Python (2.3) and same > > versions of PythonWin32. > > > > Anybody?? > > > > Thanks, > > > > -- > > > > -- > > John Henry >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 > -- John Henry From kimwaic888-pythonwin32 at yahoo.com Thu Jul 21 18:57:56 2005 From: kimwaic888-pythonwin32 at yahoo.com (kimwaic888-pythonwin32@yahoo.com) Date: Thu, 21 Jul 2005 09:57:56 -0700 (PDT) Subject: [python-win32] constants problem Message-ID: <20050721165756.24073.qmail@web51410.mail.yahoo.com> Okay, Roger, I got it. It's the Microsoft Word 11.0 Object Library that I have to do. Thanks, kimwaic888-pythonwin32 at yahoo.com wrote: > Roger, > > Thank you for the reply. Could you please elaborate a > little further. I don't fully understand the message. > > You said: > > >>For the constants to be available, you'll need to run > > makepy on the machines your script will run on. > > I tried to run makepy.py and a menu of "types" poped > up. What should I be doing with that? More > importantly, I didn't have to do that on my own > machine and everything has been working fine. Why's > that? > > >>win32com.client.gencache.EnsureDispatch will create > > > Is that a class method I should invoke from my code? > Or is that something I should be doing via an import > statement? Or what exactly is that? > > Thanks again, > > > > >>-----Original Message----- >>From: > > python-win32-bounces+kimwaic888-pythonwin32=yahoo.com at python.org > >>[mailto:python-win32-bounces+kimwaic888-pythonwin32=yahoo.com at python.org] > > On > >>Behalf Of Roger Upole >>Sent: Wednesday, July 20, 2005 9:21 PM >>To: python-win32 at python.org >>Subject: [python-win32] Re: constants problem >> >> >>For the constants to be available, you'll need to run > > makepy > >>on the machines your script will run on. >>win32com.client.gencache.EnsureDispatch will create > > the generated file for > >>an object if it doesn't already exist. >> >> Roger >> >> >>kimwaic888-pythonwin32 at yahoo.com wrote: >> >> >>>Hi, list: >>> >>>This is puzzling. For the PythonWin32 based Word >>>script I developed, everything works fine on my >>>machine. However, when I run the script on > > another > >>>machine, it would fail whenever it comes across > > any of > >>>the constants variables (such as, for example, > > constants.wdLine, > >>>constants.wdStory, or any of them). I checked and > > rechecked and the > >>>machines are all running the same version of > > Python (2.3) and same > >>>versions of PythonWin32. >>> >>>Anybody?? >>> >>>Thanks, >>> >>>-- >>> >>>-- >>>John Henry >> >>_______________________________________________ >>Python-win32 mailing list >>Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > -- > John Henry > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- Kim Cheung Executive Consultant PowerSystemAdvisors.COM (626)475-4373 kimwaic at powersystemadvisors.com -- John Henry From tea2 at cornell.edu Fri Jul 22 03:25:10 2005 From: tea2 at cornell.edu (Terry Acree) Date: Thu, 21 Jul 2005 21:25:10 -0400 Subject: [python-win32] BLT autorange Message-ID: <2fdd335da51a1019d2048c4b19b695fd@cornell.edu> Can anyone give me an example of the BLT expression axis_configure('x', autorange = 0.0) having an effect on a graph after min and max has been set once mnually. The first default works fine cycling through many graph ranges but once the min and max have been set manually autorange does not help. Thanks Terry From benn at cenix-bioscience.com Fri Jul 22 14:32:15 2005 From: benn at cenix-bioscience.com (Neil Benn) Date: Fri, 22 Jul 2005 14:32:15 +0200 Subject: [python-win32] Registry Entries on a win32 install Message-ID: <42E0E74F.2070402@cenix-bioscience.com> Hello, We have an enterprise app running and I'd like to reduce maintenance efforts by loading third party packages from a central location. One of the third party packages is win32, I'm looking to load this off the server however I need to determine if this is possible. The thing I need to determine is whether there are any registry entries that win32 is depending upon - does anyone know if that is the case or can I execute on files which are loading on the server? I'm aware of the PythonPath issues and will be working on that as well. Cheers, Neil -- Neil Benn Senior Automation Engineer Cenix BioScience BioInnovations Zentrum Tatzberg 47 D-01307 Dresden Germany Tel : +49 (0)351 4173 154 e-mail : benn at cenix-bioscience.com Cenix Website : http://www.cenix-bioscience.com From hjiwani at wscm.net Fri Jul 22 15:20:39 2005 From: hjiwani at wscm.net (Hussain Jiwani) Date: Fri, 22 Jul 2005 08:20:39 -0500 Subject: [python-win32] Registry Entries on a win32 install Message-ID: <9E0CC1A9D55BE54CAD39E562649F1716901A55@wscmmail.wscm.corp> I have been using PythonPath to do something similar and it works very well. Just set your PythonPath to the shared directory. Hussain -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Neil Benn Sent: Friday, July 22, 2005 7:32 AM To: python-win32 at python.org Subject: [python-win32] Registry Entries on a win32 install Hello, We have an enterprise app running and I'd like to reduce maintenance efforts by loading third party packages from a central location. One of the third party packages is win32, I'm looking to load this off the server however I need to determine if this is possible. The thing I need to determine is whether there are any registry entries that win32 is depending upon - does anyone know if that is the case or can I execute on files which are loading on the server? I'm aware of the PythonPath issues and will be working on that as well. Cheers, Neil -- Neil Benn Senior Automation Engineer Cenix BioScience BioInnovations Zentrum Tatzberg 47 D-01307 Dresden Germany Tel : +49 (0)351 4173 154 e-mail : benn at cenix-bioscience.com Cenix Website : http://www.cenix-bioscience.com _______________________________________________ Python-win32 mailing list Python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From miles.chris at gmail.com Sun Jul 24 23:45:08 2005 From: miles.chris at gmail.com (Chris Miles) Date: Sun, 24 Jul 2005 22:45:08 +0100 Subject: [python-win32] Fetching network interface instance names Message-ID: <951991EC-38DC-45DF-8269-EF1212753F4F@gmail.com> Hi, I am querying win32pdh to fetch statistics from each network interface on the machine. I am able to fetch the stats I need, using the code below, from each network interface, provided I already know the network interface instance name (eg: intf below). My Q is: how can I programmatically find out what the network interface instance names are? I can see the instance names manually from the GUI using win32pdhutil.browse() but that doesn't help my program do it. >>> intf = 'Intel[R] PRO_100 Network Connection - Packet Scheduler Miniport' >>> import win32pdh >>> hq = win32pdh.OpenQuery() >>> cp = win32pdh.MakeCounterPath( (None, 'Network Interface', intf, None, -1, 'Bytes Sent/sec') ) >>> hc = win32pdh.AddCounter( hq, cp ) >>> type,val = win32pdh.GetFormattedCounterValue( hc, win32pdh.PDH_FMT_LONG ) >>> type 272696320 >>> val 0 Cheers, Chris -- Chris Miles http://chrismiles.info/ From mhammond at skippinet.com.au Mon Jul 25 00:45:37 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 25 Jul 2005 08:45:37 +1000 Subject: [python-win32] Fetching network interface instance names In-Reply-To: <951991EC-38DC-45DF-8269-EF1212753F4F@gmail.com> Message-ID: http://www.microsoft.com/technet/scriptcenter/scripts/python/pyindex.mspx has some scripts that appear to do what you need. (Quite cool that we can now post a microsoft.com address for help with Python scripts ;) Mark. > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of Chris Miles > Sent: Monday, 25 July 2005 7:45 AM > To: python-win32 at python.org > Subject: [python-win32] Fetching network interface instance names > > > Hi, I am querying win32pdh to fetch statistics from each network > interface on the machine. I am able to fetch the stats I need, using > the code below, from each network interface, provided I already know > the network interface instance name (eg: intf below). > > My Q is: how can I programmatically find out what the network > interface instance names are? > > I can see the instance names manually from the GUI using > win32pdhutil.browse() but that doesn't help my program do it. > > >>> intf = 'Intel[R] PRO_100 Network Connection - Packet Scheduler > Miniport' > >>> import win32pdh > >>> hq = win32pdh.OpenQuery() > >>> cp = win32pdh.MakeCounterPath( (None, 'Network Interface', intf, > None, -1, 'Bytes Sent/sec') ) > >>> hc = win32pdh.AddCounter( hq, cp ) > >>> type,val = win32pdh.GetFormattedCounterValue( hc, > win32pdh.PDH_FMT_LONG ) > >>> type > 272696320 > >>> val > 0 > > Cheers, > Chris > > -- > Chris Miles > http://chrismiles.info/ > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From Benjamin.Schollnick at xerox.com Mon Jul 25 14:53:22 2005 From: Benjamin.Schollnick at xerox.com (Schollnick, Benjamin) Date: Mon, 25 Jul 2005 08:53:22 -0400 Subject: [python-win32] Fetching network interface instance names Message-ID: <266589E1B9392B4C9195CC25A07C73B90183CF55@usa0300ms04.na.xerox.net> > http://www.microsoft.com/technet/scriptcenter/scripts/python/p > yindex.mspx > has some scripts that appear to do what you need. > > (Quite cool that we can now post a microsoft.com address for > help with Python scripts ;) Except that they do not seem to work.... I have tried three so far, and they all fail with object has no attribute errors... Either that, or there is a significant difference with ActiveState & standard Python 2.4.1 with the Win32all extensions... (I don't remember a significant difference... I have previously used ActivateState back in the v2.0 / v2.1 days...) For example... def windows_installed_software ( host_computer = "."): import win32com.client strComputer = host_computer objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator") objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2") colItems = objSWbemServices.ExecQuery("Select * from Win32_Product") for objItem in colItems: print "Caption: ", objItem.Caption print "Description: ", objItem.Description print "Identifying Number: ", objItem.IdentifyingNumber print "Install Date: ", objItem.InstallDate print "Install Date 2: ", objItem.InstallDate2 print "Install Location: ", objItem.InstallLocation print "Install State: ", objItem.InstallState print "Name: ", objItem.Name print "Package Cache: ", objItem.PackageCache print "SKU Number: ", objItem.SKUNumber print "Vendor: ", objItem.Vendor print "Version: ", objItem.Version They are obviously missing a step, because the colItems / ExecQuerry is working, but objItems does not have any of the Caption / Description, etc variables.... So there must be a missing step.... - Benjamin > > Mark. > > > -----Original Message----- > > From: python-win32-bounces at python.org > > [mailto:python-win32-bounces at python.org]On Behalf Of Chris Miles > > Sent: Monday, 25 July 2005 7:45 AM > > To: python-win32 at python.org > > Subject: [python-win32] Fetching network interface instance names > > > > > > Hi, I am querying win32pdh to fetch statistics from each network > > interface on the machine. I am able to fetch the stats I > need, using > > the code below, from each network interface, provided I > already know > > the network interface instance name (eg: intf below). > > > > My Q is: how can I programmatically find out what the network > > interface instance names are? > > > > I can see the instance names manually from the GUI using > > win32pdhutil.browse() but that doesn't help my program do it. > > > > >>> intf = 'Intel[R] PRO_100 Network Connection - Packet Scheduler > > Miniport' >>> import win32pdh > > >>> hq = win32pdh.OpenQuery() > > >>> cp = win32pdh.MakeCounterPath( (None, 'Network > Interface', intf, > > None, -1, 'Bytes Sent/sec') ) > > >>> hc = win32pdh.AddCounter( hq, cp ) > > >>> type,val = win32pdh.GetFormattedCounterValue( hc, > > win32pdh.PDH_FMT_LONG ) > > >>> type > > 272696320 > > >>> val > > 0 > > > > Cheers, > > Chris > > > > -- > > Chris Miles > > http://chrismiles.info/ > > > > _______________________________________________ > > Python-win32 mailing list > > Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From simon.dahlbacka at gmail.com Mon Jul 25 15:07:39 2005 From: simon.dahlbacka at gmail.com (Simon Dahlbacka) Date: Mon, 25 Jul 2005 16:07:39 +0300 Subject: [python-win32] Fetching network interface instance names In-Reply-To: <266589E1B9392B4C9195CC25A07C73B90183CF55@usa0300ms04.na.xerox.net> References: <266589E1B9392B4C9195CC25A07C73B90183CF55@usa0300ms04.na.xerox.net> Message-ID: <57124720507250607ee5eabf@mail.gmail.com> WorksForMe both 2.3.2 and 2.4.1 (ActiveState versions) (actually I only tried the .Caption, but since you said that that also failed..) On 7/25/05, Schollnick, Benjamin wrote: > > http://www.microsoft.com/technet/scriptcenter/scripts/python/p > > yindex.mspx > > has some scripts that appear to do what you need. > > > > (Quite cool that we can now post a microsoft.com address for > > help with Python scripts ;) > > Except that they do not seem to work.... I have tried three so far, and > they all fail with object has no attribute errors... > > Either that, or there is a significant difference with ActiveState & > standard > Python 2.4.1 with the Win32all extensions... (I don't remember a > significant difference... > I have previously used ActivateState back in the v2.0 / v2.1 days...) > > For example... > > def windows_installed_software ( host_computer = "."): > import win32com.client > strComputer = host_computer > objWMIService = > win32com.client.Dispatch("WbemScripting.SWbemLocator") > objSWbemServices = > objWMIService.ConnectServer(strComputer,"root\cimv2") > colItems = objSWbemServices.ExecQuery("Select * from Win32_Product") > for objItem in colItems: > print "Caption: ", objItem.Caption > print "Description: ", objItem.Description > print "Identifying Number: ", objItem.IdentifyingNumber > print "Install Date: ", objItem.InstallDate > print "Install Date 2: ", objItem.InstallDate2 > print "Install Location: ", objItem.InstallLocation > print "Install State: ", objItem.InstallState > print "Name: ", objItem.Name > print "Package Cache: ", objItem.PackageCache > print "SKU Number: ", objItem.SKUNumber > print "Vendor: ", objItem.Vendor > print "Version: ", objItem.Version > > They are obviously missing a step, because the colItems / > ExecQuerry is working, but > objItems does not have any of the Caption / Description, etc > variables.... > > So there must be a missing step.... > > - Benjamin > > > > Mark. > > > > > -----Original Message----- > > > From: python-win32-bounces at python.org > > > [mailto:python-win32-bounces at python.org]On Behalf Of Chris Miles > > > Sent: Monday, 25 July 2005 7:45 AM > > > To: python-win32 at python.org > > > Subject: [python-win32] Fetching network interface instance names > > > > > > > > > Hi, I am querying win32pdh to fetch statistics from each network > > > interface on the machine. I am able to fetch the stats I > > need, using > > > the code below, from each network interface, provided I > > already know > > > the network interface instance name (eg: intf below). > > > > > > My Q is: how can I programmatically find out what the network > > > interface instance names are? > > > > > > I can see the instance names manually from the GUI using > > > win32pdhutil.browse() but that doesn't help my program do it. > > > > > > >>> intf = 'Intel[R] PRO_100 Network Connection - Packet Scheduler > > > Miniport' >>> import win32pdh > > > >>> hq = win32pdh.OpenQuery() > > > >>> cp = win32pdh.MakeCounterPath( (None, 'Network > > Interface', intf, > > > None, -1, 'Bytes Sent/sec') ) > > > >>> hc = win32pdh.AddCounter( hq, cp ) > > > >>> type,val = win32pdh.GetFormattedCounterValue( hc, > > > win32pdh.PDH_FMT_LONG ) > > > >>> type > > > 272696320 > > > >>> val > > > 0 > > > > > > Cheers, > > > Chris > > > > > > -- > > > Chris Miles > > > http://chrismiles.info/ > > > > > > _______________________________________________ > > > Python-win32 mailing list > > > Python-win32 at python.org > > > http://mail.python.org/mailman/listinfo/python-win32 > > > > _______________________________________________ > > Python-win32 mailing list > > Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > _______________________________________________ > Python-win32 mailing list > Python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From Benjamin.Schollnick at xerox.com Mon Jul 25 15:11:52 2005 From: Benjamin.Schollnick at xerox.com (Schollnick, Benjamin) Date: Mon, 25 Jul 2005 09:11:52 -0400 Subject: [python-win32] Fetching network interface instance names Message-ID: <266589E1B9392B4C9195CC25A07C73B90183CF57@usa0300ms04.na.xerox.net> Weird, must be a difference between ActiveState & Standard Python.... Hmmm.... I wonder what else is different... - Benjamin > -----Original Message----- > From: Simon Dahlbacka [mailto:simon.dahlbacka at gmail.com] > Sent: Monday, July 25, 2005 9:08 AM > To: Schollnick, Benjamin > Cc: Mark Hammond; Chris Miles; python-win32 at python.org > Subject: Re: [python-win32] Fetching network interface instance names > > > WorksForMe both 2.3.2 and 2.4.1 (ActiveState versions) > (actually I only tried the .Caption, but since you said that > that also failed..) > > > > On 7/25/05, Schollnick, Benjamin > wrote: > > > http://www.microsoft.com/technet/scriptcenter/scripts/python/p > > > yindex.mspx > > > has some scripts that appear to do what you need. > > > > > > (Quite cool that we can now post a microsoft.com address for help > > > with Python scripts ;) > > > > Except that they do not seem to work.... I have tried three so far, > > and they all fail with object has no attribute errors... > > > > Either that, or there is a significant difference with > ActiveState & > > standard Python 2.4.1 with the Win32all extensions... (I don't > > remember a significant difference... > > I have previously used ActivateState back in the v2.0 / > v2.1 days...) > > > > For example... > > > > def windows_installed_software ( host_computer = "."): > > import win32com.client > > strComputer = host_computer > > objWMIService = > > win32com.client.Dispatch("WbemScripting.SWbemLocator") > > objSWbemServices = > > objWMIService.ConnectServer(strComputer,"root\cimv2") > > colItems = objSWbemServices.ExecQuery("Select * from > Win32_Product") > > for objItem in colItems: > > print "Caption: ", objItem.Caption > > print "Description: ", objItem.Description > > print "Identifying Number: ", objItem.IdentifyingNumber > > print "Install Date: ", objItem.InstallDate > > print "Install Date 2: ", objItem.InstallDate2 > > print "Install Location: ", objItem.InstallLocation > > print "Install State: ", objItem.InstallState > > print "Name: ", objItem.Name > > print "Package Cache: ", objItem.PackageCache > > print "SKU Number: ", objItem.SKUNumber > > print "Vendor: ", objItem.Vendor > > print "Version: ", objItem.Version > > > > They are obviously missing a step, because the colItems / > > ExecQuerry is working, but objItems does not have any of > the Caption / > > Description, etc variables.... > > > > So there must be a missing step.... > > > > - Benjamin > > > > > > Mark. > > > > > > > -----Original Message----- > > > > From: python-win32-bounces at python.org > > > > [mailto:python-win32-bounces at python.org]On Behalf Of Chris Miles > > > > Sent: Monday, 25 July 2005 7:45 AM > > > > To: python-win32 at python.org > > > > Subject: [python-win32] Fetching network interface > instance names > > > > > > > > > > > > Hi, I am querying win32pdh to fetch statistics from > each network > > > > interface on the machine. I am able to fetch the stats I > > > need, using > > > > the code below, from each network interface, provided I > > > already know > > > > the network interface instance name (eg: intf below). > > > > > > > > My Q is: how can I programmatically find out what the network > > > > interface instance names are? > > > > > > > > I can see the instance names manually from the GUI using > > > > win32pdhutil.browse() but that doesn't help my program do it. > > > > > > > > >>> intf = 'Intel[R] PRO_100 Network Connection - Packet > > > > Scheduler Miniport' >>> import win32pdh >>> hq = > > > > win32pdh.OpenQuery() >>> cp = win32pdh.MakeCounterPath( (None, > > > > 'Network > > > Interface', intf, > > > > None, -1, 'Bytes Sent/sec') ) > > > > >>> hc = win32pdh.AddCounter( hq, cp ) > > > > >>> type,val = win32pdh.GetFormattedCounterValue( hc, > > > > win32pdh.PDH_FMT_LONG ) >>> type > > > > 272696320 > > > > >>> val > > > > 0 > > > > > > > > Cheers, > > > > Chris > > > > > > > > -- > > > > Chris Miles > > > > http://chrismiles.info/ > > > > > > > > _______________________________________________ > > > > Python-win32 mailing list > > > > Python-win32 at python.org > > > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > _______________________________________________ > > > Python-win32 mailing list > > > Python-win32 at python.org > > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > _______________________________________________ > > Python-win32 mailing list > > Python-win32 at python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > From miles.chris at gmail.com Tue Jul 26 01:04:08 2005 From: miles.chris at gmail.com (Chris Miles) Date: Tue, 26 Jul 2005 00:04:08 +0100 Subject: [python-win32] Fetching network interface instance names In-Reply-To: References: Message-ID: Thanks Mark. The "List Network Adapter Properties" script did the trick. And it didn't need ActiveState Python to work, thankfully. I would have preferred a solution that used win32pdh, and not win32com, just for consistency, but at least I get the results I'm after. Cheers, Chris -- Chris Miles http://chrismiles.info/ On 24 Jul 2005, at 23:45, Mark Hammond wrote: > http://www.microsoft.com/technet/scriptcenter/scripts/python/ > pyindex.mspx > has some scripts that appear to do what you need. > > (Quite cool that we can now post a microsoft.com address for help with > Python scripts ;) > > Mark. From haraldarminmassa at gmail.com Tue Jul 26 11:59:13 2005 From: haraldarminmassa at gmail.com (Harald Armin Massa) Date: Tue, 26 Jul 2005 11:59:13 +0200 Subject: [python-win32] Fetching network interface instance names In-Reply-To: References: Message-ID: <7be3f35d05072602595ffa7336@mail.gmail.com> Mark, >http://www.microsoft.com/technet/scriptcenter/scripts/python/pyindex.mspx > >has some scripts that appear to do what you need. > > >(Quite cool that we can now post a microsoft.com address for help with > >Python scripts ;) Really, really cool. It's a hug of a giant. But the sad thing: I quite randomly selected 4 different scripts out of that list, and not 1 worked ... they allways try to access attributes on COM-generated objects which are not available. Has anyone had some more positive experience? Harald -- GHUM Harald Massa persuasion python postgresql Harald Armin Massa Reinsburgstra?e 202b 70197 Stuttgart 0173/9409607 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050726/fb3a22e6/attachment.htm From graham.bloice at trihedral.com Tue Jul 26 17:12:26 2005 From: graham.bloice at trihedral.com (Graham Bloice) Date: Tue, 26 Jul 2005 16:12:26 +0100 Subject: [python-win32] Fetching network interface instance names In-Reply-To: <7be3f35d05072602595ffa7336@mail.gmail.com> Message-ID: >>http://www.microsoft.com/technet/scriptcenter/scripts/python/pyindex.mspx >>has some scripts that appear to do what you need. > >>(Quite cool that we can now post a microsoft.com address for help with >>Python scripts ;) > >Really, really cool. It's a hug of a giant. > >But the sad thing: I quite randomly selected 4 different scripts out of that list, and not 1 worked ... they allways try to >access attributes on COM-generated objects which are not available. Has anyone had some more positive experience? I must be a better picker then ! The two I tried worked fine (video resolutions and system slots). Graham Bloice From Benjamin.Schollnick at xerox.com Tue Jul 26 17:24:02 2005 From: Benjamin.Schollnick at xerox.com (Schollnick, Benjamin) Date: Tue, 26 Jul 2005 11:24:02 -0400 Subject: [python-win32] Fetching network interface instance names Message-ID: <266589E1B9392B4C9195CC25A07C73B90183CF66@usa0300ms04.na.xerox.net> > >>http://www.microsoft.com/technet/scriptcenter/scripts/python > /pyindex.mspx > >>has some scripts that appear to do what you need. > > > >>(Quite cool that we can now post a microsoft.com address > for help with > >>Python scripts ;) > > > >Really, really cool. It's a hug of a giant. > > > >But the sad thing: I quite randomly selected 4 different > scripts out of > that list, and not 1 worked ... they allways try to > >access attributes on COM-generated objects which are not > available. Has > anyone had some more positive experience? > > I must be a better picker then ! The two I tried worked fine > (video resolutions and system slots). I ran into the same issue. I was unable to use the scripts, but of course, according to the web page they were written using ActiveState Python. I am using Stock Python 2.4.1 with Win32all... - Benjamin From miles.chris at gmail.com Wed Jul 27 01:05:43 2005 From: miles.chris at gmail.com (Chris Miles) Date: Wed, 27 Jul 2005 00:05:43 +0100 Subject: [python-win32] Fetching network interface instance names In-Reply-To: References: Message-ID: <465D8555-819F-44AF-BE9D-071E8DD4B7AD@gmail.com> On 26 Jul 2005, at 00:04, Chris Miles wrote: > Thanks Mark. The "List Network Adapter Properties" script did the > trick. And it didn't need ActiveState Python to work, thankfully. I spoke too soon. Unfortunately the answers I get from COM are not compatible with win32pdh. Example: win32com tells me my network interface is called: "Intel(R) PRO/100 Network Connection" But win32pdh calls it: "Intel[R] PRO_100 Network Connection - Packet Scheduler Miniport" Notice the almost subtle "(R)" and "[R]" differences and "PRO/100" vs "PRO_100". Nice and inconsistent! Who knows why ... crazy Microsoft. Anyway, further digging showed me that win32pdh can indeed tell me all the available instance names for the "Network Interface" object, exactly what I was looking for. >>> items, instances = win32pdh.EnumObjectItems(None, None, 'Network Interface', win32pdh.PERF_DETAIL_WIZARD) >>> items ['Bytes Total/sec', 'Packets/sec', 'Packets Received/sec', 'Packets Sent/sec', 'Current Bandwidth', 'Bytes Received/sec', 'Packets Received Unicast/sec', 'Packets Received Non-Unicast/sec', 'Packets Received Discarded', 'Packets Received Errors', 'Packets Received Unknown', 'Bytes Sent/sec', 'Packets Sent Unicast/sec', 'Packets Sent Non-Unicast/sec', 'Packets Outbound Discarded', 'Packets Outbound Errors', 'Output Queue Length'] >>> instances ['ORiNOCO Wireless LAN Mini PCI Card - Packet Scheduler Miniport', 'Intel[R] PRO_100 Network Connection - Packet Scheduler Miniport', 'MS TCP Loopback interface'] instances is a list of network interface names that win32pdh can provide counters for, and items is a list of all the counters that can be provided. Hope this helps others. Cheers, Chris -- Chris Miles http://chrismiles.info/ > On 24 Jul 2005, at 23:45, Mark Hammond wrote: >> http://www.microsoft.com/technet/scriptcenter/scripts/python/ >> pyindex.mspx From rwupole at msn.com Tue Jul 26 02:58:04 2005 From: rwupole at msn.com (Roger Upole) Date: Mon, 25 Jul 2005 20:58:04 -0400 Subject: [python-win32] Re: Fetching network interface instance names Message-ID: "Schollnick, Benjamin" wrote: > Except that they do not seem to work.... I have tried three so far, and > they all fail with object has no attribute errors... > > Either that, or there is a significant difference with ActiveState & > standard > Python 2.4.1 with the Win32all extensions... (I don't remember a > significant difference... > I have previously used ActivateState back in the v2.0 / v2.1 days...) > > For example... > > def windows_installed_software ( host_computer = "."): > import win32com.client > strComputer = host_computer > objWMIService = > win32com.client.Dispatch("WbemScripting.SWbemLocator") > objSWbemServices = > objWMIService.ConnectServer(strComputer,"root\cimv2") > colItems = objSWbemServices.ExecQuery("Select * from Win32_Product") > for objItem in colItems: > print "Caption: ", objItem.Caption > print "Description: ", objItem.Description > print "Identifying Number: ", objItem.IdentifyingNumber > print "Install Date: ", objItem.InstallDate > print "Install Date 2: ", objItem.InstallDate2 > print "Install Location: ", objItem.InstallLocation > print "Install State: ", objItem.InstallState > print "Name: ", objItem.Name > print "Package Cache: ", objItem.PackageCache > print "SKU Number: ", objItem.SKUNumber > print "Vendor: ", objItem.Vendor > print "Version: ", objItem.Version > > They are obviously missing a step, because the colItems / > ExecQuerry is working, but > objItems does not have any of the Caption / Description, etc > variables.... > > So there must be a missing step.... > WMI properties work differently depending on whether you've created the makepy generated file. Delete everything in the folder \win32com\gen_py and the above code should work. You can also use win32com.client.dynamic.DumbDispatch in place of win32com.client.Dispatch to explicitely avoid using it. hth Roger From benn at cenix-bioscience.com Wed Jul 27 10:46:38 2005 From: benn at cenix-bioscience.com (Neil Benn) Date: Wed, 27 Jul 2005 10:46:38 +0200 Subject: [python-win32] win32 version Message-ID: <42E749EE.9000103@cenix-bioscience.com> Hello, If I have an installed instance of win32 et al, is there a way to get the version number that is installed on a box (preferably without having to start python up - ie is it written in a text file somewhere in the install?). Cheers, Neil -- Neil Benn Senior Automation Engineer Cenix BioScience BioInnovations Zentrum Tatzberg 47 D-01307 Dresden Germany Tel : +49 (0)351 4173 154 e-mail : benn at cenix-bioscience.com Cenix Website : http://www.cenix-bioscience.com From gagenellina at softlab.com.ar Wed Jul 27 12:42:16 2005 From: gagenellina at softlab.com.ar (Gabriel Genellina) Date: Wed, 27 Jul 2005 07:42:16 -0300 Subject: [python-win32] win32 version In-Reply-To: <42E749EE.9000103@cenix-bioscience.com> References: <42E749EE.9000103@cenix-bioscience.com> Message-ID: <6.2.1.2.0.20050727073930.02d1ab20@192.168.0.115> At Wednesday 27/7/2005 05:46, Neil Benn wrote: > If I have an installed instance of win32 et al, is there a way >to get the version number that is installed on a box (preferably >without having to start python up - ie is it written in a text file >somewhere in the install?). You could enumerate the uninstall keys and see what "looks like" a Python installation... HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\pywin32-py2.3 (I hope there is a better way) Gabriel Genellina Softlab SRL From benn at cenix-bioscience.com Wed Jul 27 13:08:47 2005 From: benn at cenix-bioscience.com (Neil Benn) Date: Wed, 27 Jul 2005 13:08:47 +0200 Subject: [python-win32] win32 version In-Reply-To: <6.2.1.2.0.20050727073930.02d1ab20@192.168.0.115> References: <42E749EE.9000103@cenix-bioscience.com> <6.2.1.2.0.20050727073930.02d1ab20@192.168.0.115> Message-ID: <42E76B3F.7030203@cenix-bioscience.com> Gabriel Genellina wrote: > At Wednesday 27/7/2005 05:46, Neil Benn wrote: > >> If I have an installed instance of win32 et al, is there a way >> to get the version number that is installed on a box (preferably >> without having to start python up - ie is it written in a text file >> somewhere in the install?). > > > You could enumerate the uninstall keys and see what "looks like" a > Python installation... > HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\pywin32-py2.3 > > (I hope there is a better way) > Hello, Yeah the problem is that the place where the win32 files are sitting is not where the win32 package was installed (I can install it on my local box and dump it onto the server). Cheers, Neil -- Neil Benn Senior Automation Engineer Cenix BioScience BioInnovations Zentrum Tatzberg 47 D-01307 Dresden Germany Tel : +49 (0)351 4173 154 e-mail : benn at cenix-bioscience.com Cenix Website : http://www.cenix-bioscience.com From "tim.nospam at capsu.org" at bag.python.org Wed Jul 27 00:01:27 2005 From: "tim.nospam at capsu.org" at bag.python.org (Tim Howgego) Date: Tue, 26 Jul 2005 23:01:27 +0100 Subject: [python-win32] Monitoring CPU Usage Message-ID: I'm trying to use Python to monitor CPU usage (simple percentage) on Windows 98. First thoughts were to use win32pdh (code similar to http://mail.python.org/pipermail/python-win32/2002-April/000347.html ), but pdh.dll is not available for Windows 98. Second thought was to use WMI. WMI isn't native on 98, but it can be downloaded and installed. This seems to work, except that Win32_Processor "LoadPercentage" returns "None" when running under Windows 98. from win32com.client import GetObject wmi=GetObject('winmgmts:') cpu=wmi.InstancesOf('Win32_Processor') for x in cpu: ... do something with x.Properties_('LoadPercentage').Value The basic function works, because it does successfully extract other data, such as "Name". For reference: http://msdn.microsoft.com/library/default.asp?url= /library/en-us/wmisdk/wmi/win32_processor.asp I'm running Python 2.4.1 with pywin32-204. If as I suspect, the problem lies in partial WMI support under Windows 98, does anyone have a better way of trying to extract CPU usage values? Thanks, -- Tim Howgego http://tim.capsu.org/ From justinjohnson at gmail.com Wed Jul 27 22:19:49 2005 From: justinjohnson at gmail.com (Justin Johnson) Date: Wed, 27 Jul 2005 15:19:49 -0500 Subject: [python-win32] GetMessage/PeekMessage not defined AND Building win32all with MinGW Message-ID: <94a776e7050727131956582874@mail.gmail.com> Hi, I recently noticed that GetMessage and PeekMessage aren't wrapped in any of the win32* modules, although PostThreadMessage is. I submitted https://sourceforge.net/tracker/index.php?func=detail&aid=1246207&group_id=78018&atid=551954to document the problem. Does anyone know of some special reason why these are missing? I really need these functions defined. My first thought was to add them myself, but I can't compile the code without MSVC++. Has anyone here attempted to compile win32all with MinGW? My experience so far indicates that it wouldn't compile with MinGW unless perhaps someone has some modified version of the distutils setup file. Thanks. Justin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050727/7ac56203/attachment.htm From mhammond at skippinet.com.au Thu Jul 28 03:37:27 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 28 Jul 2005 11:37:27 +1000 Subject: [python-win32] win32 version In-Reply-To: <42E749EE.9000103@cenix-bioscience.com> Message-ID: > If I have an installed instance of win32 et al, is there a way > to get the version number that is installed on a box (preferably > without having to start python up - ie is it written in a text file > somewhere in the install?). In build 205 and later, there will be a pywin32.version.txt file installed into site-packages. For 204 and earlier there is no real way of knowing other than the uninstall registry key. You could get a clue from the version number in win32com\client\genpy.py - 'makepy_version' generally has changed for all releases. You would have to use CVS to find the exact number for each release though. Mark From mhammond at skippinet.com.au Thu Jul 28 03:47:41 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 28 Jul 2005 11:47:41 +1000 Subject: [python-win32] GetMessage/PeekMessage not defined AND Buildingwin32all with MinGW In-Reply-To: <94a776e7050727131956582874@mail.gmail.com> Message-ID: As it turns out these have been added to win32gui (all except PeekMessage - but I just added that). Let me know the version of Python you are using and I will mail you a new win32gui. I can't answer the MinGW question as I have never used it - but would be happy to accept patches to setup.py to make things work. Cheers, Mark -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org]On Behalf Of Justin Johnson Sent: Thursday, 28 July 2005 6:20 AM To: python-win32 at python.org Subject: [python-win32] GetMessage/PeekMessage not defined AND Buildingwin32all with MinGW Hi, I recently noticed that GetMessage and PeekMessage aren't wrapped in any of the win32* modules, although PostThreadMessage is. I submitted https://sourceforge.net/tracker/index.php?func=detail&aid=1246207&group_id=7 8018&atid=551954 to document the problem. Does anyone know of some special reason why these are missing? I really need these functions defined. My first thought was to add them myself, but I can't compile the code without MSVC++. Has anyone here attempted to compile win32all with MinGW? My experience so far indicates that it wouldn't compile with MinGW unless perhaps someone has some modified version of the distutils setup file. Thanks. Justin From upadhyay at gmail.com Thu Jul 28 08:38:03 2005 From: upadhyay at gmail.com (Amit Upadhyay) Date: Thu, 28 Jul 2005 12:08:03 +0530 Subject: [python-win32] OT: how to get function signature Message-ID: <349edb3805072723381a099658@mail.gmail.com> Hi, I was working on a dir like function that gives more information than the usual dir, but I am not satisfied with the way I get function arguments for callable members of an object. Take a look at it here: http://nerdierthanthou.nfshost.com/2005/07/mdir-for-python.html. I have seen PythonWin showing function arguments as tooltips, can anyone please let me know how to get it. TIA, -- Amit Upadhyay Blog: http://www.rootshell.be/~upadhyay +91-9867-359-701 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050728/90321e0f/attachment.htm From michael.lieschnegg at virtuellesfahrzeug.at Thu Jul 28 13:05:43 2005 From: michael.lieschnegg at virtuellesfahrzeug.at (Michael Lieschnegg) Date: Thu, 28 Jul 2005 13:05:43 +0200 Subject: [python-win32] Inter Process Communication Troubles Message-ID: <067FFD3D085A1E4B860486DD33A23DF8336BBB@vifs1.vif.intern> hello! I wrote a python parent script which starts a separate script in a new process (under Windows XP Pro SP2, Python 2.4.1). Through anonymous pipes I have made a bidirectional communication to the child. I also embedded the parent script in cpp and it works too! Now I have exported the parent functions in a dll, but when I call the dll in visual basic 6, the client script does not start and I cannot communicate over the pipes. When I use the dll in CPP it works too!. Perhaps you can help me and can tell me the problem why my program does not run in visual basic 6. Thank you! Regards, Michael lieschnegg I embedded following code in the dll for creating the pipes and starting the new process: class master_interface: def __init__(self, iPort): command='C:\Programme\Python24\python.exe' #win32api.GetModuleFileName(0) print command args=['-u', 'dispatcher.py', str(iPort)] environment=None path=None # security attributes for pipes sAttrs = win32security.SECURITY_ATTRIBUTES() sAttrs.bInheritHandle = 1 # create pipes hStdin_r, self.hStdin_w = win32pipe.CreatePipe(sAttrs, 0) self.hStdout_r, hStdout_w = win32pipe.CreatePipe(sAttrs, 0) self.hStderr_r, hStderr_w = win32pipe.CreatePipe(sAttrs, 0) # set the info structure for the new process. StartupInfo = win32process.STARTUPINFO() StartupInfo.hStdInput = hStdin_r StartupInfo.hStdOutput = hStdout_w StartupInfo.hStdError = hStderr_w StartupInfo.dwFlags = win32process.STARTF_USESTDHANDLES # Create new output read handles and the input write handle. Set # the inheritance properties to FALSE. Otherwise, the child inherits # these handles; pid = win32api.GetCurrentProcess() tmp = win32api.DuplicateHandle( pid, self.hStdin_w, pid, 0, 0, # non-inheritable!! win32con.DUPLICATE_SAME_ACCESS) # Close the inhertible version of the handle win32file.CloseHandle(self.hStdin_w) self.hStdin_w = tmp tmp = win32api.DuplicateHandle( pid, self.hStdout_r, pid, 0, 0, # non-inheritable! win32con.DUPLICATE_SAME_ACCESS) # Close the inhertible version of the handle win32file.CloseHandle(self.hStdout_r) self.hStdout_r = tmp tmp = win32api.DuplicateHandle( pid, self.hStderr_r, pid, 0, 0, # non-inheritable! win32con.DUPLICATE_SAME_ACCESS) # Close the inhertible version of the handle win32file.CloseHandle(self.hStderr_r) self.hStderr_r = tmp # start the process. print "creating process" cmdline = "%s %s" % (command, string.join(args, ' ')) hProcess, hThread, dwPid, dwTid = win32process.CreateProcess( None, # program cmdline,# command line None, # process security attributes None, # thread attributes 1, # inherit handles, or USESTDHANDLES won't work. # creation flags. Don't access the console. 0, # Don't need anything here. # If you're in a GUI app, you should use # CREATE_NEW_CONSOLE here, or any subprocesses # might fall victim to the problem described in: # KB article: Q156755, cmd.exe requires # an NT console in order to perform redirection.. environment, # new environment path, # new directory StartupInfo) # normally, we would save the pid etc. here... print "process created" # Child is launched. Close the parents copy of those pipe handles # that only the child should have open. # You need to make sure that no handles to the write end of the # output pipe are maintained in this process or else the pipe will # not close when the child process exits and the ReadFile will hang. win32file.CloseHandle(hStderr_w) win32file.CloseHandle(hStdout_w) win32file.CloseHandle(hStdin_r) self.outQueue = Queue.Queue() self.closed = 0 self.stdoutClosed = 0 self.stderrClosed = 0 ..........and so on......... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050728/65898fed/attachment-0001.htm From justinjohnson at gmail.com Thu Jul 28 15:41:38 2005 From: justinjohnson at gmail.com (Justin Johnson) Date: Thu, 28 Jul 2005 08:41:38 -0500 Subject: [python-win32] GetMessage/PeekMessage not defined AND Buildingwin32all with MinGW In-Reply-To: References: <94a776e7050727131956582874@mail.gmail.com> Message-ID: <94a776e705072806415c1af5ae@mail.gmail.com> Great! I'm running Python 2.4.1. On 7/27/05, Mark Hammond wrote: > > As it turns out these have been added to win32gui (all except PeekMessage > - > but I just added that). Let me know the version of Python you are using > and > I will mail you a new win32gui. > > I can't answer the MinGW question as I have never used it - but would be > happy to accept patches to setup.py to make things work. > > Cheers, > > Mark > -----Original Message----- > From: python-win32-bounces at python.org > [mailto:python-win32-bounces at python.org]On Behalf Of Justin Johnson > Sent: Thursday, 28 July 2005 6:20 AM > To: python-win32 at python.org > Subject: [python-win32] GetMessage/PeekMessage not defined AND > Buildingwin32all with MinGW > > > Hi, > > I recently noticed that GetMessage and PeekMessage aren't wrapped in any > of > the win32* modules, although PostThreadMessage is. I submitted > > https://sourceforge.net/tracker/index.php?func=detail&aid=1246207&group_id=7 > 8018&atid=551954 to document the problem. Does anyone know of some special > reason why these are missing? > > I really need these functions defined. My first thought was to add them > myself, but I can't compile the code without MSVC++. Has anyone here > attempted to compile win32all with MinGW? My experience so far indicates > that it wouldn't compile with MinGW unless perhaps someone has some > modified > version of the distutils setup file. > > Thanks. > Justin > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050728/be535a68/attachment.htm From inugroh at uark.edu Thu Jul 28 19:31:35 2005 From: inugroh at uark.edu (Irmawaty Nugroh Nugroho) Date: Thu, 28 Jul 2005 12:31:35 -0500 Subject: [python-win32] Internet Explorer COM issues with XP SP2? Message-ID: <1cf1731cd7f9.1cd7f91cf173@uark.edu> I am encountering the same problem for Samie (perl)... I got that error on IEObject->{Document} I found this after googling for a long time: http://support.microsoft.com/?kbid=889386 Or I found another thread in python said that if you change fireEvent('onchange') to FireEvent('onchange') it will work. From oleg_python at yahoo.de Fri Jul 29 16:11:53 2005 From: oleg_python at yahoo.de (Oleg Novychny) Date: Fri, 29 Jul 2005 16:11:53 +0200 (CEST) Subject: [python-win32] Problems with Implementing Callback Python/C++-DLL Message-ID: <20050729141153.38621.qmail@web25705.mail.ukl.yahoo.com> Dear friends, I?m hoping to receive some tips to my problem. At the moment I?m trying to implement a callback between Python and my C++-DLL. My DLL calculates permanently some values and stores them in member-variables in one of the DLL-classes. There are some exported functions in my DLL for starting and ending the evaluating and for reading out of values from the member-variables of my DLL. My wish is to implement my DLL in such a way that my Python-script witch I use for starting my DLL will receive a notice from my DLL to that time when the new values were calculated. I can call then my Python-Function for reading out the values from the DLL synchronized. This is my DLL-header: SOUNDPROCLIB_API int StartProcessing(int fSourceRec, int fNoiseRec, int fCrackRec, int fAudioOnRec, int fBeepRec, unsigned long ulTimeMS ); SOUNDPROCLIB_API int GetResults(unsigned long* ulHz, double* dNoise, int* bAudio, int* bCrackFlag, double* dSNR, int* bBeep); SOUNDPROCLIB_API int EndProcessing(void); So I want to call my GetResults function from Python only if my DLL ?tells? to my Python-Script ?do it?. Here is my Python-DLL-wrapper: from ctypes import* import sys class SoundProcLib(object): def __init__(self, library): self.library = library @cdecl(c_int, library, [c_int, c_int, c_int, c_int, c_int, c_ulong]) def StartProcessing(f1, f2, f3, f4, f5, ul1): if 0 == StartProcessing._api_(f1, f2, f3, f4, f5, ul1): raise WinError() return None self.StartProcessing = StartProcessing @cdecl(c_int, library, [POINTER(c_ulong), POINTER(c_double), POINTER(c_int), POINTER(c_int), POINTER(c_double), POINTER(c_int)]) def GetResults(): ulHz,dNoise,bAudio,bCrackFlag,dSNR,bBeep = c_ulong(), c_double(), c_int(), c_int(), c_double(), c_int() if 0 == GetResults._api_(byref(ulHz),byref(dNoise),byref(bAudio),byref(bCrackFlag),byref(dSNR),byref(bBeep)): raise WinError() return ulHz.value,dNoise.value,bAudio.value,bCrackFlag.value,dSNR.value,bBeep.value self.GetResults = GetResults @cdecl(c_int, library, [c_void_p]) def EndProcessing(): if 0 == EndProcessing._api_(None): raise WinError() return None self.EndProcessing = EndProcessing @cdecl(c_void_p, library, [c_void_p]) def inittestcallback(): if 0 == inittestcallback._api_(None): raise WinError() return None self.inittestcallback = inittestcallback At the moment I started to implement my callback in such a way (I found it in a python-tutorial): PyObject *ppyobjArgList; PyObject *ppyobjResult; static PyObject *my_callback = NULL; static PyObject *my_set_callback(PyObject *dummy, PyObject *args) { PyObject *result = NULL; PyObject *temp; if (PyArg_ParseTuple(args, "O:set_callback", &temp)) { if (!PyCallable_Check(temp)) { PyErr_SetString(PyExc_TypeError, "parameter must be callable"); return NULL; } Py_XINCREF(temp); /* Add a reference to new callback */ Py_XDECREF(my_callback); /* Dispose of previous callback */ my_callback = temp; /* Remember new callback */ /* Boilerplate to return "None" */ Py_INCREF(Py_None); result = Py_None; bPyCallBackFlag = true; } return result; }; static PyMethodDef SoundMethods[] = { {"callback", my_set_callback, METH_VARARGS, "Execute a callback."}, {NULL, NULL, 0, NULL} /* Sentinel */ }; So I?m not sure how can I ?register? my_set_callback function in the already started Python-Interpreter and to ?explain? my DLL which Python-Function is to call when the new values in my DLL were calculated. Thank you very much for your suggestions Oleg --------------------------------- Gesendet von Yahoo! Mail - Jetzt mit 1GB kostenlosem Speicher -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050729/bae427f2/attachment-0001.htm From John.Gooch at echostar.com Fri Jul 29 19:38:38 2005 From: John.Gooch at echostar.com (Gooch, John) Date: Fri, 29 Jul 2005 11:38:38 -0600 Subject: [python-win32] Querying Password Change Privilege on an Active Directory User Ac count Message-ID: <15A1FDA26DAD524DA7A7AF77313EBA8F0F60D5C2@riv-excha5.echostar.com> I have a script that changes user passwords, and it throws exceptions then executing the SetPassword() or SetInfo() commands on a AD user account that it does not have "set password" privileges on. To avoid the exception being thrown, I would like to have the script check whether or not it has permission to change the password before trying to change it ( make sense? ), but I cannot find any good documentation on this after a few hours of Googling for it. Do anyone have guidance ( or better yet, an answer ) on figuring out how to implement this. here is a small snippet of the code I have now : adsuser = getADSUser( trans.adspath )#Retrieve a copy of the users AD Account if ( adsuser ): trans.email = adsuser.mail trans.firstname = adsuser.givenName trans.lastname = adsuser.sn trans.displayname = adsuser.displayname #trans.pwdLastChanged1 = adsuser.PasswordLastChanged #trans.pwdLastChanged1 = time.strftime( "%Y-%m-%d %H:%M:%S", time.gmtime( adsuser.PasswordLastChanged ) ) trans.pwdLastChanged1 = str( adsuser.PasswordLastChanged ) error = NewPassword( trans ) if ( not error ): if ( validEmail( trans.email ) ): try: print "new password is %s" % trans.password adsuser.SetPassword( trans.password ) #x=1 #adsuser.SetInfo() print "Password change successful. %s" % trans.username except pythoncom.com_error, error: #print "Password change failed. for %s" % trans.username return "Set Password failure. COM Error:%s" % str( error ) except Exception, error: return "Set Password failure. General Error:%s" % str(error) try: adsuser = None adsuser = getADSUser( trans.adspath ) #Retrieve a copy of the users AD Account trans.pwdLastChanged2 = str( adsuser.PasswordLastChanged ) except: return "Password change verification failure - Unable to retrieve PasswordLastChanged Timestamp after changing the password." % ( trans.pwdLastChanged1,trans.pwdLastChanged2 ) if ( trans.pwdLastChanged1 == trans.pwdLastChanged2 ): return "Password change verification failure - PasswordLastChange Value did not change after executing the SetPassword Command.Before:%s Date After Date:%s" % ( trans.pwdLastChanged1,trans.pwdLastChanged2 ) else: #print "Password change verification success - PasswordLastChange Value did change after executing the SetPassword Command.Before:%s Date After Date:%s" % ( trans.pwdLastChanged1,trans.pwdLastChanged2 ) return None Thank You, John A. Gooch "May the Python-force be with you...always." Systems Administrator EchoStar Satellite L.L.C. Desk: 720-514-5708 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20050729/6b57345e/attachment.htm From Jim.Vickroy at noaa.gov Fri Jul 29 20:33:52 2005 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri, 29 Jul 2005 12:33:52 -0600 Subject: [python-win32] Querying Password Change Privilege on an Active Directory User Ac count In-Reply-To: <15A1FDA26DAD524DA7A7AF77313EBA8F0F60D5C2@riv-excha5.echostar.com> References: <15A1FDA26DAD524DA7A7AF77313EBA8F0F60D5C2@riv-excha5.echostar.com> Message-ID: <42EA7690.9050701@noaa.gov> Hello John, Why does it matter? Why not just ignore the specific type of exception raised by an invalid SetPassword() or SetInfo() request as follows: try: adsuser.SetPassword(trans.password) adsuser.SetInfo() except : pass # or whatever except : pass # or whatever except Exception, details: pass # or take whatever action is desired -- jv Gooch, John wrote: > I have a script that changes user passwords, and it throws exceptions > then executing the SetPassword() or SetInfo() commands on a AD user > account that it does not have "set password" privileges on. To avoid > the exception being thrown, I would like to have the script check > whether or not it has permission to change the password before trying > to change it ( make sense? ), but I cannot find any good documentation > on this after a few hours of Googling for it. > > Do anyone have guidance ( or better yet, an answer ) on figuring out > how to implement this. > > here is a small snippet of the code I have now : > > > adsuser = getADSUser( trans.adspath )#Retrieve a copy of the > users AD Account > if ( adsuser ): > trans.email = adsuser.mail > trans.firstname = adsuser.givenName > trans.lastname = adsuser.sn > trans.displayname = adsuser.displayname > #trans.pwdLastChanged1 = adsuser.PasswordLastChanged > #trans.pwdLastChanged1 = time.strftime( "%Y-%m-%d %H:%M:%S", > time.gmtime( adsuser.PasswordLastChanged ) ) > trans.pwdLastChanged1 = str( adsuser.PasswordLastChanged ) > error = NewPassword( trans ) > if ( not error ): > if ( validEmail( trans.email ) ): > try: > print "new password is %s" % trans.password > adsuser.SetPassword( trans.password ) > #x=1 > #adsuser.SetInfo() > print "Password change successful. %s" % trans.username > except pythoncom.com_error, error: > #print "Password change failed. for %s" % > trans.username > return "Set Password failure. COM Error:%s" % str( > error ) > except Exception, error: > return "Set Password failure. General Error:%s" % > str(error) > try: > adsuser = None > adsuser = getADSUser( trans.adspath ) #Retrieve a > copy of the users AD Account > trans.pwdLastChanged2 = str( > adsuser.PasswordLastChanged ) > except: > return "Password change verification failure - > Unable to retrieve PasswordLastChanged Timestamp after changing the > password." % ( trans.pwdLastChanged1,trans.pwdLastChanged2 ) > > if ( trans.pwdLastChanged1 == trans.pwdLastChanged2 ): > return "Password change verification failure - > PasswordLastChange Value did not change after executing the > SetPassword Command.Before:%s Date After Date:%s" % ( > trans.pwdLastChanged1,trans.pwdLastChanged2 ) > else: > #print "Password change verification success - > PasswordLastChange Value did change after executing the SetPassword > Command.Before:%s Date After Date:%s" % ( > trans.pwdLastChanged1,trans.pwdLastChanged2 ) > return None > Thank You, > > > > John A. Gooch > "May the Python-force be with you...always." > Systems Administrator > EchoStar Satellite L.L.C. > Desk: 720-514-5708 > > > > > >------------------------------------------------------------------------ > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > From John.Gooch at echostar.com Sat Jul 30 00:14:17 2005 From: John.Gooch at echostar.com (Gooch, John) Date: Fri, 29 Jul 2005 16:14:17 -0600 Subject: [python-win32] Querying Password Change Privilege on an Activ e Directory User Ac count Message-ID: <15A1FDA26DAD524DA7A7AF77313EBA8F0F60D5C5@riv-excha5.echostar.com> It's mostly for testing purposes. The password change affect a few thousand of our customers, so the group I wrote the script for wants to be able to disable the SetPassword/SetInfo command to do a test run of the script and see if it will encounter any permission/other problems before the "Production" run kicks off. It's all about being proactive, and not having anything happen that will come to the attention of upper management, who will want to know why we are not being proactive instead of reactive. That is, solving problems before they actually are problems, instead of reacting to error messages after the fact. Plus, with an explicit message stating exactly why a password change would fail, I won't get paged at home at 2am in the morning like I have for the last three days. Instead they Windows admin can be paged to fix the any permissions problems while I sleep. :) -----Original Message----- From: Jim Vickroy [mailto:Jim.Vickroy at noaa.gov] Sent: Friday, July 29, 2005 12:34 PM To: Gooch, John Cc: python-win32 at python.org Subject: Re: [python-win32] Querying Password Change Privilege on an Active Directory User Ac count Hello John, Why does it matter? Why not just ignore the specific type of exception raised by an invalid SetPassword() or SetInfo() request as follows: try: adsuser.SetPassword(trans.password) adsuser.SetInfo() except : pass # or whatever except : pass # or whatever except Exception, details: pass # or take whatever action is desired -- jv Gooch, John wrote: > I have a script that changes user passwords, and it throws exceptions > then executing the SetPassword() or SetInfo() commands on a AD user > account that it does not have "set password" privileges on. To avoid > the exception being thrown, I would like to have the script check > whether or not it has permission to change the password before trying > to change it ( make sense? ), but I cannot find any good documentation > on this after a few hours of Googling for it. > > Do anyone have guidance ( or better yet, an answer ) on figuring out > how to implement this. > > here is a small snippet of the code I have now : > > > adsuser = getADSUser( trans.adspath )#Retrieve a copy of the > users AD Account > if ( adsuser ): > trans.email = adsuser.mail > trans.firstname = adsuser.givenName > trans.lastname = adsuser.sn > trans.displayname = adsuser.displayname > #trans.pwdLastChanged1 = adsuser.PasswordLastChanged > #trans.pwdLastChanged1 = time.strftime( "%Y-%m-%d %H:%M:%S", > time.gmtime( adsuser.PasswordLastChanged ) ) > trans.pwdLastChanged1 = str( adsuser.PasswordLastChanged ) > error = NewPassword( trans ) > if ( not error ): > if ( validEmail( trans.email ) ): > try: > print "new password is %s" % trans.password > adsuser.SetPassword( trans.password ) > #x=1 > #adsuser.SetInfo() > print "Password change successful. %s" % trans.username > except pythoncom.com_error, error: > #print "Password change failed. for %s" % > trans.username > return "Set Password failure. COM Error:%s" % str( > error ) > except Exception, error: > return "Set Password failure. General Error:%s" % > str(error) > try: > adsuser = None > adsuser = getADSUser( trans.adspath ) #Retrieve a > copy of the users AD Account > trans.pwdLastChanged2 = str( > adsuser.PasswordLastChanged ) > except: > return "Password change verification failure - > Unable to retrieve PasswordLastChanged Timestamp after changing the > password." % ( trans.pwdLastChanged1,trans.pwdLastChanged2 ) > > if ( trans.pwdLastChanged1 == trans.pwdLastChanged2 ): > return "Password change verification failure - > PasswordLastChange Value did not change after executing the > SetPassword Command.Before:%s Date After Date:%s" % ( > trans.pwdLastChanged1,trans.pwdLastChanged2 ) > else: > #print "Password change verification success - > PasswordLastChange Value did change after executing the SetPassword > Command.Before:%s Date After Date:%s" % ( > trans.pwdLastChanged1,trans.pwdLastChanged2 ) > return None > Thank You, > > > > John A. Gooch > "May the Python-force be with you...always." > Systems Administrator > EchoStar Satellite L.L.C. > Desk: 720-514-5708 > > > > > >----------------------------------------------------------------------- >- > >_______________________________________________ >Python-win32 mailing list >Python-win32 at python.org >http://mail.python.org/mailman/listinfo/python-win32 > > From mhammond at skippinet.com.au Sat Jul 30 07:28:46 2005 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 30 Jul 2005 15:28:46 +1000 Subject: [python-win32] Problems with Implementing Callback Python/C++-DLL In-Reply-To: <20050729141153.38621.qmail@web25705.mail.ukl.yahoo.com> Message-ID: > So I?m not sure how can I ?register? my_set_callback function in the already > started Python-Interpreter and to ?explain? my DLL which Python-Function is > to call when the new values in my DLL were calculated. I'm not sure I understand your problem. The tail of the code you posted looks like a standard Python module - although you did not show the "module init" code. Assuming this was a normal module, Python code would be able to say: import foo foo.callback(some_func) Which is how my_set_callback will be called. However, if you have no module init code, there will be no entry point to the function. How is your DLL loaded by Python (or is it your DLL that loads Python?). Mark