From champipi at belgique.com Tue Jul 1 19:23:35 2003 From: champipi at belgique.com (Champ Hippy) Date: Tue Jul 1 12:24:09 2003 Subject: [python-win32] Encapsulating a wxWindows component with COM/ActiveX Message-ID: <1057076615.3f01b587a94c9@belgique.alinto.com> Hello, I would like to know if it is possible to create a COM/ActiveX component that would encapsulate a wxPython graphical object. You may think for instance of an OpenGL canvas created with PyOpenGL that would plot some graph (this is indeed my final target). This component would not create its own window but would be part of a parent window created with another programming language (C++ or Delphi). My idea would be to create a component that could be integrated in any COM aware Microsoft application and especially in Internet Explorer. I also have a trivial question related to this general problem: is there really no difference between activeX and COM? If there is one (even small), I am interested in any simple sample code creating an activeX. Thank you, Bernard From justinjohnson at fastmail.fm Thu Jul 3 09:43:45 2003 From: justinjohnson at fastmail.fm (Justin Johnson) Date: Thu Jul 3 10:44:32 2003 Subject: [python-win32] win32service problem Message-ID: <20030703144345.775F21A50F@www.fastmail.fm> I just posted this to python-list, but then found out there is a win32 list. Sorry for the double post. -------- Hello, I created an NT service using win32service. This service runs as a particular user on the domain and accepts connections to run commands on the server. The service is working great on most of the servers I have, but on one server it fails to start, with the following error message. --- Error starting service: The service did not respond to the start or control request in a timely fashion. --- And I get the following dumped to the event logs... --- Timeout (30000 milliseconds) waiting for the Twisted ClearCase Service service to connect. --- The Twisted ClearCase Service service failed to start due to the following error: The service did not respond to the start or control request in a timely fashion. --- However, when I install the service without specifying my domain level user it starts fine. Also when I start it in debug mode it works fine. I checked the local policy settings to make sure the domain level user has the same rights as he has on my other servers and there is no difference. Does anyone have any ideas why this is happening? Also, do you know of anywhere I can look to get better debug info, or to debug using my domain level user? Thanks much. -Justin From henning.i.fagge at ericsson.com Thu Jul 3 15:27:49 2003 From: henning.i.fagge at ericsson.com (Henning Fagge I (GR/ETO)) Date: Thu Jul 3 11:54:38 2003 Subject: [python-win32] Missing COM Events Message-ID: <6F936E2F8E16234BA8D88B2EE833833203906EB9@esealnt912.al.sw.ericsson.se> The result of makepy command is attached at the end: My problem is that I just get the "IDebugMuxEvents", I never get the two other "ITargetEvents" and "IDataProvidersEvent". The result from running the program look like this: Starting DBGMux method OnTargetConnected Available DataProviders: Print Server Channel Available DataProviders: SDKSERVER Available DataProviders: Tvp Available DataProviders: Interactive Debug Connect to: Interactive Debug Connect SUCCESS Sending dir command, which should return something which should cause a event(OnDataAvailable) Available DataProviders: Print Server Channel Available DataProviders: SDKSERVER Available DataProviders: Tvp Available DataProviders: Interactive Debug My simple program look like this: *********** My program: *********** from win32com.client import DispatchWithEvents, Dispatch import msvcrt, pythoncom import time, sys import types import threading defaultNamedOptArg=pythoncom.Empty defaultNamedNotOptArg=pythoncom.Empty defaultUnnamedArg=pythoncom.Empty class IDataProviderEvents: def OnDisconnect(self): """method OnDisconnect""" print "****************************OnDisconnect*****************************" def OnDataAvailable(self, DataPacket=defaultNamedNotOptArg): """method OnDataAvailable""" print "************************OnDataAvailable******************************" class ITargetEvents: def OnDataProviderRemoved(self, DataProvider=defaultNamedNotOptArg): """method OnDataProviderRemoved""" print "method OnDataProviderRemoved" def OnNewDataProvider(self, DataProvider=defaultNamedNotOptArg): """method OnNewDataProvider""" print "method OnNewDataProvider" def OnDataProviderUnavailable(self, DataProvider=defaultNamedNotOptArg): """method OnDataProviderUnavailable""" print "method OnDataProviderUnavailable" class IDebugMuxEvents: def OnTargetConnected(self, Target=None): """method OnTargetConnected""" print "method OnTargetConnected" def OnTargetDisconnected(self, Target=None): """method OnTargetDisconnected""" print "method OnTargetDisconnected" def TestDBGMux(): connected=0 print 20*"\n"+"Starting DBGMux" object=DispatchWithEvents("DebugMuxSrv.DebugMux",IDebugMuxEvents) object.Configure(0) start=time.time() while (time.time()-start)<20: pythoncom.PumpWaitingMessages() time.sleep(2) for Target in object.Targets: DispatchWithEvents(Target,ITargetEvents) DataProviders=Target.DataProviders for DataProvider in DataProviders: print "Available DataProviders:",DataProvider.Name if str(DataProvider.Name)=="Interactive Debug": if DataProvider.Available and not connected: print "Connect to: ",DataProvider.Name if DataProvider.Connect(): print "Connect SUCCESS" else: print "Connect FAILED" DispatchWithEvents(DataProvider,IDataProviderEvents) connected=1 packet=Dispatch("DebugMuxSrv.DataPacket.1") #Sending this command(DIR) gives som result and should cause an event(OnDataAvailable)!!!!!! print "Sending dir command, which should return something which should cause a event(OnDataAvailable)" packet.Data="dir\n" DataProvider.Send(packet) print "Exit timeout" TestDBGMux() ***************************************************** Running the command makepy gave the following result: ***************************************************** # Created by makepy.py version 0.4.4 # By python version 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] # From type library 'DEBUGM~1.EXE' # On Wed Jul 02 11:39:05 2003 """DebugMuxSrv 1.0 Type Library""" makepy_version = '0.4.4' python_version = 0x20203f0 import win32com.client.CLSIDToClass, pythoncom 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('{0C003D28-B1B8-43B6-829D-D7E32446575D}') MajorVersion = 1 MinorVersion = 0 LibraryFlags = 8 LCID = 0x0 from win32com.client import DispatchBaseClass class IDataPacket(DispatchBaseClass): """IDataPacket Interface""" CLSID = IID('{3E2DF654-9B5A-4836-8196-6BAF284A7080}') coclass_clsid = IID('{DDB38397-77ED-4A7E-914D-CF66F15935DA}') def GetDataAsString(self, StringData=defaultNamedNotOptArg): """method GetDataAsString""" return self._oleobj_.InvokeTypes(3, LCID, 1, (24, 0), ((16392, 0),),StringData) def SetStringAsData(self, StringData=defaultNamedNotOptArg): """method SetStringAsData""" return self._oleobj_.InvokeTypes(4, LCID, 1, (24, 0), ((8, 0),),StringData) _prop_map_get_ = { "Data": (2, 2, (8209, 0), (), "Data", None), "DataLength": (1, 2, (3, 0), (), "DataLength", None), } _prop_map_put_ = { "Data": ((2, LCID, 4, 0),()), } class IDataProvider(DispatchBaseClass): """IDataProvider Interface""" CLSID = IID('{863A0E7B-963D-44FD-849B-1E540B0017CA}') coclass_clsid = IID('{E81B5D02-43EA-4EE4-957C-E569D048F0A7}') def Connect(self): """method Connect""" return self._oleobj_.InvokeTypes(4, LCID, 1, (11, 0), (),) def Disconnect(self): """method Disconnect""" return self._oleobj_.InvokeTypes(5, LCID, 1, (11, 0), (),) def Send(self, DataPacket=defaultNamedNotOptArg): """method Send""" return self._oleobj_.InvokeTypes(6, LCID, 1, (11, 0), ((9, 0),),DataPacket) _prop_map_get_ = { "Available": (3, 2, (11, 0), (), "Available", None), "DataPacketLimit": (7, 2, (2, 0), (), "DataPacketLimit", None), "Id": (1, 2, (2, 0), (), "Id", None), "Name": (2, 2, (8, 0), (), "Name", None), } _prop_map_put_ = { } class IDataProviders(DispatchBaseClass): """IDataProviders Interface""" CLSID = IID('{C4DEAE67-22FF-4F2E-BE49-D22D0B5C5B44}') coclass_clsid = IID('{DB71C9CB-EB66-4D9F-85FD-D7B6EB034D63}') # The method Item is actually a property, but must be used as a method to correctly pass the arguments def Item(self, Index=defaultNamedNotOptArg): return self._ApplyTypes_(0, 2, (12, 0), ((3, 1),), 'Item', None,Index) _prop_map_get_ = { "Count": (1, 2, (3, 0), (), "Count", None), } _prop_map_put_ = { } # Default method for this class is 'Item' def __call__(self, Index=defaultNamedNotOptArg): return self._ApplyTypes_(0, 2, (12, 0), ((3, 1),), '__call__', None,Index) # str(ob) and int(ob) will use __call__ def __unicode__(self, *args): try: return unicode(apply( self.__call__, args)) except pythoncom.com_error: return repr(self) def __str__(self, *args): return str(apply(self.__unicode__, args)) def __int__(self, *args): return int(apply( self.__call__, args)) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),None) def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): import win32com.client.util 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 apply(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 1 class IDebugMux(DispatchBaseClass): """IDebugMux Interface""" CLSID = IID('{01146C8E-79FD-4AC5-BF8A-30F5165E9640}') coclass_clsid = IID('{D8677026-F045-4A10-A69C-971939E434A0}') def Configure(self, hWndParent=defaultNamedNotOptArg): """method Configure""" return self._oleobj_.InvokeTypes(2, LCID, 1, (24, 0), ((3, 0),),hWndParent) _prop_map_get_ = { "Targets": (1, 2, (12, 0), (), "Targets", None), } _prop_map_put_ = { } class ITarget(DispatchBaseClass): """ITarget Interface""" CLSID = IID('{DEBD2C08-6AD6-4154-B459-CB8E0C07F1CE}') coclass_clsid = IID('{292B446E-D483-459F-9BBA-F268694D84EA}') _prop_map_get_ = { "DataProviders": (3, 2, (12, 0), (), "DataProviders", None), "Id": (1, 2, (3, 0), (), "Id", None), "Name": (2, 2, (8, 0), (), "Name", None), } _prop_map_put_ = { } class ITargets(DispatchBaseClass): """ITargets Interface""" CLSID = IID('{D90098E0-0070-4585-A5FD-D4043BCFB431}') coclass_clsid = IID('{B5532A26-93E5-47BB-8735-FB36D4A2FA05}') # The method Item is actually a property, but must be used as a method to correctly pass the arguments def Item(self, Index=defaultNamedNotOptArg): return self._ApplyTypes_(0, 2, (12, 0), ((3, 1),), 'Item', None,Index) _prop_map_get_ = { "Count": (1, 2, (3, 0), (), "Count", None), } _prop_map_put_ = { } # Default method for this class is 'Item' def __call__(self, Index=defaultNamedNotOptArg): return self._ApplyTypes_(0, 2, (12, 0), ((3, 1),), '__call__', None,Index) # str(ob) and int(ob) will use __call__ def __unicode__(self, *args): try: return unicode(apply( self.__call__, args)) except pythoncom.com_error: return repr(self) def __str__(self, *args): return str(apply(self.__unicode__, args)) def __int__(self, *args): return int(apply( self.__call__, args)) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),None) def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): import win32com.client.util 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 apply(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 1 class _IDataProviderEvents: """_IDataProviderEvents Interface""" CLSID = CLSID_Sink = IID('{BEFC1C36-47D4-45F0-BAD4-DB6AE32B5F9E}') coclass_clsid = IID('{E81B5D02-43EA-4EE4-957C-E569D048F0A7}') _public_methods_ = [] # For COM Server support _dispid_to_func_ = { 2 : "OnDisconnect", 1 : "OnDataAvailable", } def __init__(self, oobj = None): if oobj is None: self._olecp = None else: import win32com.server.util from win32com.server.policy import EventHandlerPolicy cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContainer) cp=cpc.FindConnectionPoint(self.CLSID_Sink) cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy)) self._olecp,self._olecp_cookie = cp,cookie def __del__(self): try: self.close() except pythoncom.com_error: pass def close(self): if self._olecp is not None: cp,cookie,self._olecp,self._olecp_cookie = self._olecp,self._olecp_cookie,None,None cp.Unadvise(cookie) def _query_interface_(self, iid): import win32com.server.util if iid==self.CLSID_Sink: return win32com.server.util.wrap(self) # Event Handlers # If you create handlers, they should have the following prototypes: # def OnDisconnect(self): # """method OnDisconnect""" # print "KOKKKKOOKKKO2" # def OnDataAvailable(self, DataPacket=defaultNamedNotOptArg): # """method OnDataAvailable""" # print "KOKOOOOOO" class _IDebugMuxEvents: """_IDebugMuxEvents Interface""" CLSID = CLSID_Sink = IID('{73292CCD-DBEB-497E-A03D-10AC71C10AFF}') coclass_clsid = IID('{D8677026-F045-4A10-A69C-971939E434A0}') _public_methods_ = [] # For COM Server support _dispid_to_func_ = { 1 : "OnTargetConnected", 2 : "OnTargetDisconnected", } def __init__(self, oobj = None): if oobj is None: self._olecp = None else: import win32com.server.util from win32com.server.policy import EventHandlerPolicy cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContainer) cp=cpc.FindConnectionPoint(self.CLSID_Sink) cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy)) self._olecp,self._olecp_cookie = cp,cookie def __del__(self): try: self.close() except pythoncom.com_error: pass def close(self): if self._olecp is not None: cp,cookie,self._olecp,self._olecp_cookie = self._olecp,self._olecp_cookie,None,None cp.Unadvise(cookie) def _query_interface_(self, iid): import win32com.server.util if iid==self.CLSID_Sink: return win32com.server.util.wrap(self) # Event Handlers # If you create handlers, they should have the following prototypes: # def OnTargetConnected(self, Target=defaultNamedNotOptArg): # """method OnTargetConnected""" # def OnTargetDisconnected(self, Target=defaultNamedNotOptArg): # """method OnTargetDisconnected""" class _ITargetEvents: """_ITargetEvents Interface""" CLSID = CLSID_Sink = IID('{B11E84F7-F674-4E99-9FAC-E49C8A495E28}') coclass_clsid = IID('{292B446E-D483-459F-9BBA-F268694D84EA}') _public_methods_ = [] # For COM Server support _dispid_to_func_ = { 2 : "OnDataProviderRemoved", 1 : "OnNewDataProvider", 3 : "OnDataProviderUnavailable", } def __init__(self, oobj = None): if oobj is None: self._olecp = None else: import win32com.server.util from win32com.server.policy import EventHandlerPolicy cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContainer) cp=cpc.FindConnectionPoint(self.CLSID_Sink) cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy)) self._olecp,self._olecp_cookie = cp,cookie def __del__(self): try: self.close() except pythoncom.com_error: pass def close(self): if self._olecp is not None: cp,cookie,self._olecp,self._olecp_cookie = self._olecp,self._olecp_cookie,None,None cp.Unadvise(cookie) def _query_interface_(self, iid): import win32com.server.util if iid==self.CLSID_Sink: return win32com.server.util.wrap(self) # Event Handlers # If you create handlers, they should have the following prototypes: # def OnDataProviderRemoved(self, DataProvider=defaultNamedNotOptArg): # """method OnDataProviderRemoved""" # def OnNewDataProvider(self, DataProvider=defaultNamedNotOptArg): # """method OnNewDataProvider""" # def OnDataProviderUnavailable(self, DataProvider=defaultNamedNotOptArg): # """method OnDataProviderUnavailable""" from win32com.client import CoClassBaseClass # This CoClass is known by the name 'DebugMuxSrv.DataPacket.1' class DataPacket(CoClassBaseClass): # A CoClass # DataPacket Class CLSID = IID('{DDB38397-77ED-4A7E-914D-CF66F15935DA}') coclass_sources = [ ] coclass_interfaces = [ IDataPacket, ] default_interface = IDataPacket # This CoClass is known by the name 'DebugMuxSrv.DataProvider.1' class DataProvider(CoClassBaseClass): # A CoClass # DataProvider Class CLSID = IID('{E81B5D02-43EA-4EE4-957C-E569D048F0A7}') coclass_sources = [ _IDataProviderEvents, ] default_source = _IDataProviderEvents coclass_interfaces = [ IDataProvider, ] default_interface = IDataProvider # This CoClass is known by the name 'DebugMuxSrv.DataProviders.1' class DataProviders(CoClassBaseClass): # A CoClass # DataProviders Class CLSID = IID('{DB71C9CB-EB66-4D9F-85FD-D7B6EB034D63}') coclass_sources = [ ] coclass_interfaces = [ IDataProviders, ] default_interface = IDataProviders # This CoClass is known by the name 'DebugMuxSrv.DebugMux.1' class DebugMux(CoClassBaseClass): # A CoClass # DebugMux Class CLSID = IID('{D8677026-F045-4A10-A69C-971939E434A0}') coclass_sources = [ _IDebugMuxEvents, ] default_source = _IDebugMuxEvents coclass_interfaces = [ IDebugMux, ] default_interface = IDebugMux # This CoClass is known by the name 'DebugMuxSrv.Target.1' class Target(CoClassBaseClass): # A CoClass # Target Class CLSID = IID('{292B446E-D483-459F-9BBA-F268694D84EA}') coclass_sources = [ _ITargetEvents, ] default_source = _ITargetEvents coclass_interfaces = [ ITarget, ] default_interface = ITarget # This CoClass is known by the name 'DebugMuxSrv.Targets.1' class Targets(CoClassBaseClass): # A CoClass # Targets Class CLSID = IID('{B5532A26-93E5-47BB-8735-FB36D4A2FA05}') coclass_sources = [ ] coclass_interfaces = [ ITargets, ] default_interface = ITargets IDataPacket_vtables_dispatch_ = 1 IDataPacket_vtables_ = [ ('DataLength', 1, 2, ((16387,10,None, None),), (3, 0, None, None), ('pVal',)), ('Data', 2, 2, ((24593,10,None, None),), (3, 0, None, None), ('pData',)), ('Data', 2, 4, ((24593,1,None, None),), (3, 0, None, None), ('pData',)), ('GetDataAsString', 3, 1, ((16392,0,None, None),), (3, 0, None, None), ('StringData',)), ('SetStringAsData', 4, 1, ((8,0,None, None),), (3, 0, None, None), ('StringData',)), ] IDataProvider_vtables_dispatch_ = 1 IDataProvider_vtables_ = [ ('Id', 1, 2, ((16386,10,None, None),), (3, 0, None, None), ('pVal',)), ('Name', 2, 2, ((16392,10,None, None),), (3, 0, None, None), ('pVal',)), ('Available', 3, 2, ((16395,10,None, None),), (3, 0, None, None), ('pVal',)), ('Connect', 4, 1, ((16395,10,None, None),), (3, 0, None, None), ('pConnected',)), ('Disconnect', 5, 1, ((16395,10,None, None),), (3, 0, None, None), ('pSuccess',)), ('Send', 6, 1, ((9,0,None, IID('{3E2DF654-9B5A-4836-8196-6BAF284A7080}')),(16395,10,None, None),), (3, 0, None, None), ('DataPacket', 'pSuccess')), ('DataPacketLimit', 7, 2, ((16386,10,None, None),), (3, 0, None, None), ('pVal',)), ] IDataProviders_vtables_dispatch_ = 1 IDataProviders_vtables_ = [ ('_NewEnum', -4, 2, ((16397,10,None, None),), (3, 0, None, None), ('ppUnk',)), ('Item', 0, 2, ((3,1,None, None),(16396,10,None, None),), (3, 0, None, None), ('Index', 'pVal')), ('Count', 1, 2, ((16387,10,None, None),), (3, 0, None, None), ('pVal',)), ] IDebugMux_vtables_dispatch_ = 1 IDebugMux_vtables_ = [ ('Targets', 1, 2, ((16396,10,None, None),), (3, 0, None, None), ('pVal',)), ('Configure', 2, 1, ((3,0,None, None),), (3, 0, None, None), ('hWndParent',)), ] ITarget_vtables_dispatch_ = 1 ITarget_vtables_ = [ ('Id', 1, 2, ((16387,10,None, None),), (3, 0, None, None), ('pVal',)), ('Name', 2, 2, ((16392,10,None, None),), (3, 0, None, None), ('pVal',)), ('DataProviders', 3, 2, ((16396,10,None, None),), (3, 0, None, None), ('pVal',)), ] ITargets_vtables_dispatch_ = 1 ITargets_vtables_ = [ ('_NewEnum', -4, 2, ((16397,10,None, None),), (3, 0, None, None), ('ppUnk',)), ('Item', 0, 2, ((3,1,None, None),(16396,10,None, None),), (3, 0, None, None), ('Index', 'pVal')), ('Count', 1, 2, ((16387,10,None, None),), (3, 0, None, None), ('pVal',)), ] _IInternalDataPacket_vtables_dispatch_ = 0 _IInternalDataPacket_vtables_ = [ ('PutData', 1610678272, 1, ((16401,0,None, None),(2,0,None, None),), (3, 0, None, None), ('pData', 'sDataLen')), ('GetData', 1610678273, 1, ((16401,0,None, None),(16386,0,None, None),), (3, 0, None, None), ('ppData', 'lpsDataLen')), ] _IInternalDataProvider_vtables_dispatch_ = 0 _IInternalDataProvider_vtables_ = [ ('Id', 1, 4, ((2,1,None, None),), (3, 0, None, None), ()), ('ConRef', 2, 2, ((16386,10,None, None),), (3, 0, None, None), ('pVal',)), ('ConRef', 2, 4, ((2,1,None, None),), (3, 0, None, None), ('pVal',)), ('Available', 3, 4, ((11,1,None, None),), (3, 0, None, None), ()), ('Name', 4, 4, ((8,1,None, None),), (3, 0, None, None), ()), ('DataProviderInstance', 5, 2, ((16393,10,None, IID('{863A0E7B-963D-44FD-849B-1E540B0017CA}')),), (3, 0, None, None), ('pVal',)), ('ChildId', 6, 4, ((2,1,None, None),), (3, 0, None, None), ('pVal',)), ('ChildId', 6, 2, ((16386,10,None, None),), (3, 0, None, None), ('pVal',)), ('DataPacketLimit', 7, 2, ((16386,10,None, None),), (3, 0, None, None), ('pVal',)), ('PacketCount', 8, 2, ((16386,10,None, None),), (3, 0, None, None), ('pVal',)), ('InternalConnect', 1610678282, 1, ((2,0,None, None),(16395,0,None, None),), (3, 0, None, None), ('sChildId', 'pConnected')), ('SetTarget', 1610678283, 1, ((9,0,None, IID('{DEBD2C08-6AD6-4154-B459-CB8E0C07F1CE}')),), (3, 0, None, None), ('pTarget',)), ('SetParentDataProvider', 1610678284, 1, ((9,0,None, IID('{863A0E7B-963D-44FD-849B-1E540B0017CA}')),), (3, 0, None, None), ('pParentDataProvider',)), ('OnConnected', 1610678285, 1, ((2,0,None, None),(2,0,None, None),), (3, 0, None, None), ('sConRef', 'sBlockLimit')), ('OnDisconnected', 1610678286, 1, ((2,0,None, None),), (3, 0, None, None), ('sConRef',)), ('OnDataBlock', 1610678287, 1, ((2,0,None, None),(9,0,None, IID('{3E2DF654-9B5A-4836-8196-6BAF284A7080}')),), (3, 0, None, None), ('sConRef', 'pDataPacket')), ('OnNewCredits', 1610678288, 1, ((2,0,None, None),(17,0,None, None),), (3, 0, None, None), ('sConRef', 'bCredits')), ] _IInternalDataProviders_vtables_dispatch_ = 0 _IInternalDataProviders_vtables_ = [ ('Init', 1610678272, 1, ((36,0,None, None),), (3, 0, None, None), ('pArray',)), ] _IInternalDebugMux_vtables_dispatch_ = 0 _IInternalDebugMux_vtables_ = [ ('ConnectDataProvider', 1610678272, 1, ((3,0,None, None),(2,0,None, None),), (3, 0, None, None), ('lTargetId', 'sDataProviderId')), ('DisconnectDataProvider', 1610678273, 1, ((3,0,None, None),(2,0,None, None),(2,0,None, None),), (3, 0, None, None), ('lTargetId', 'sDataProviderId', 'sConRef')), ('SendDataBlock', 1610678274, 1, ((3,0,None, None),(2,0,None, None),(2,0,None, None),(9,0,None, IID('{3E2DF654-9B5A-4836-8196-6BAF284A7080}')),), (3, 0, None, None), ('lTargetId', 'sDataProviderId', 'sConRef', 'pDataPacket')), ] _IInternalTarget_vtables_dispatch_ = 0 _IInternalTarget_vtables_ = [ ('Id', 1, 4, ((3,1,None, None),), (3, 0, None, None), ()), ('Name', 2, 4, ((8,1,None, None),), (3, 0, None, None), ()), ('AddDataProvider', 1610678274, 1, ((9,0,None, IID('{863A0E7B-963D-44FD-849B-1E540B0017CA}')),), (3, 0, None, None), ('pDataProvider',)), ('RemoveDataProvider', 1610678275, 1, ((2,0,None, None),), (3, 0, None, None), ('sDataProviderId',)), ('RemoveAllDataProviders', 1610678276, 1, (), (3, 0, None, None), ()), ('SetDebugMux', 1610678277, 1, ((9,1,None, IID('{01146C8E-79FD-4AC5-BF8A-30F5165E9640}')),), (3, 0, None, None), ('pDebugMux',)), ('ConnectDataProvider', 1610678278, 1, ((2,0,None, None),), (3, 0, None, None), ('sDataProviderId',)), ('DisconnectDataProvider', 1610678279, 1, ((2,0,None, None),(2,0,None, None),), (3, 0, None, None), ('sDataProviderId', 'sConRef')), ('SendDataBlock', 1610678280, 1, ((2,0,None, None),(2,0,None, None),(9,0,None, IID('{3E2DF654-9B5A-4836-8196-6BAF284A7080}')),), (3, 0, None, None), ('sDataProviderId', 'sConRef', 'pDataPacket')), ('OnDataProviderConnected', 1610678281, 1, ((2,0,None, None),(2,0,None, None),(2,0,None, None),), (3, 0, None, None), ('sDataProviderId', 'sConRef', 'sBlockLimit')), ('OnDataProviderDisconnected', 1610678282, 1, ((2,0,None, None),(2,0,None, None),), (3, 0, None, None), ('sDataProviderId', 'sConRef')), ('OnDataBlock', 1610678283, 1, ((2,0,None, None),(16401,0,None, None),), (3, 0, None, None), ('sConRef', 'lpDataBlock')), ('OnNewCredits', 1610678284, 1, ((2,0,None, None),(17,0,None, None),), (3, 0, None, None), ('sConRef', 'bCredits')), ('FireDataProviderUnAvailable', 1610678285, 1, ((9,0,None, IID('{863A0E7B-963D-44FD-849B-1E540B0017CA}')),), (3, 0, None, None), ('pDataProvider',)), ] _IInternalTargets_vtables_dispatch_ = 0 _IInternalTargets_vtables_ = [ ('Init', 1610678272, 1, ((36,0,None, None),), (3, 0, None, None), ('pArray',)), ] RecordMap = { 'tagSAFEARRAYBOUND': '{00000000-0000-0000-0000-000000000000}', } CLSIDToClassMap = { '{01146C8E-79FD-4AC5-BF8A-30F5165E9640}' : IDebugMux, '{D90098E0-0070-4585-A5FD-D4043BCFB431}' : ITargets, '{DDB38397-77ED-4A7E-914D-CF66F15935DA}' : DataPacket, '{B5532A26-93E5-47BB-8735-FB36D4A2FA05}' : Targets, '{863A0E7B-963D-44FD-849B-1E540B0017CA}' : IDataProvider, '{73292CCD-DBEB-497E-A03D-10AC71C10AFF}' : _IDebugMuxEvents, '{D8677026-F045-4A10-A69C-971939E434A0}' : DebugMux, '{BEFC1C36-47D4-45F0-BAD4-DB6AE32B5F9E}' : _IDataProviderEvents, '{C4DEAE67-22FF-4F2E-BE49-D22D0B5C5B44}' : IDataProviders, '{E81B5D02-43EA-4EE4-957C-E569D048F0A7}' : DataProvider, '{B11E84F7-F674-4E99-9FAC-E49C8A495E28}' : _ITargetEvents, '{292B446E-D483-459F-9BBA-F268694D84EA}' : Target, '{3E2DF654-9B5A-4836-8196-6BAF284A7080}' : IDataPacket, '{DB71C9CB-EB66-4D9F-85FD-D7B6EB034D63}' : DataProviders, '{DEBD2C08-6AD6-4154-B459-CB8E0C07F1CE}' : ITarget, } CLSIDToPackageMap = {} win32com.client.CLSIDToClass.RegisterCLSIDsFromDict( CLSIDToClassMap ) VTablesToPackageMap = {} VTablesToClassMap = { '{01146C8E-79FD-4AC5-BF8A-30F5165E9640}' : 'IDebugMux', '{D90098E0-0070-4585-A5FD-D4043BCFB431}' : 'ITargets', '{60021A43-C220-4F5D-9B3B-609A84B8F9F5}' : '_IInternalTarget', '{863A0E7B-963D-44FD-849B-1E540B0017CA}' : 'IDataProvider', '{181A18AA-2875-42C7-93E9-D67596D0D595}' : '_IInternalDataProvider', '{5A4DF1D7-A3E3-475F-A610-5306ADA3E355}' : '_IInternalDebugMux', '{C4DEAE67-22FF-4F2E-BE49-D22D0B5C5B44}' : 'IDataProviders', '{2AE27694-6DDC-473A-A662-64DF1A6E3A70}' : '_IInternalDataPacket', '{8251B0C5-B7CC-49BA-B802-99020D6EAD01}' : '_IInternalTargets', '{3E2DF654-9B5A-4836-8196-6BAF284A7080}' : 'IDataPacket', '{C1F5D088-B4E2-4A09-AB86-8F62E6D415F6}' : '_IInternalDataProviders', '{DEBD2C08-6AD6-4154-B459-CB8E0C07F1CE}' : 'ITarget', } NamesToIIDMap = { '_IInternalDebugMux' : '{5A4DF1D7-A3E3-475F-A610-5306ADA3E355}', 'ITargets' : '{D90098E0-0070-4585-A5FD-D4043BCFB431}', '_IDebugMuxEvents' : '{73292CCD-DBEB-497E-A03D-10AC71C10AFF}', '_IInternalDataProviders' : '{C1F5D088-B4E2-4A09-AB86-8F62E6D415F6}', 'IDebugMux' : '{01146C8E-79FD-4AC5-BF8A-30F5165E9640}', 'IDataProvider' : '{863A0E7B-963D-44FD-849B-1E540B0017CA}', '_IInternalDataProvider' : '{181A18AA-2875-42C7-93E9-D67596D0D595}', 'IDataPacket' : '{3E2DF654-9B5A-4836-8196-6BAF284A7080}', 'ITarget' : '{DEBD2C08-6AD6-4154-B459-CB8E0C07F1CE}', '_ITargetEvents' : '{B11E84F7-F674-4E99-9FAC-E49C8A495E28}', '_IInternalTarget' : '{60021A43-C220-4F5D-9B3B-609A84B8F9F5}', '_IInternalTargets' : '{8251B0C5-B7CC-49BA-B802-99020D6EAD01}', 'IDataProviders' : '{C4DEAE67-22FF-4F2E-BE49-D22D0B5C5B44}', '_IDataProviderEvents' : '{BEFC1C36-47D4-45F0-BAD4-DB6AE32B5F9E}', '_IInternalDataPacket' : '{2AE27694-6DDC-473A-A662-64DF1A6E3A70}', } From sudhirchauhan1 at yahoo.co.in Fri Jul 4 06:31:39 2003 From: sudhirchauhan1 at yahoo.co.in (=?iso-8859-1?q?sudhir=20chauhan?=) Date: Fri Jul 4 00:32:16 2003 Subject: [python-win32] Finding installed softwares on the remote machine using WMI In-Reply-To: Message-ID: <20030704043139.5169.qmail@web8201.mail.in.yahoo.com> Hi, I am trying to write a script which can access the remote windows 2000/XP machines and read all the installed software using WMI in python. I dont know how to proceed on this . I have some experience in python on unix and some exposure to WMI. Any pointer will be very help ful. regards, sudhir SMS using the Yahoo! Messenger;Download latest version. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20030704/024e0c1b/attachment.htm From tim.golden at viacom-outdoor.co.uk Fri Jul 4 09:49:02 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Fri Jul 4 03:53:12 2003 Subject: [python-win32] Finding installed softwares on the remote mach ine using WMI Message-ID: First of all, get hold of this module: http://tgolden.sc.sabren.com/python/wmi.html Then do something like this: computer = wmi.WMI () # or wmi.WMI ("other_computer") for product in computer.Win32_Product (): print product.Caption, product.Description I'm not an WMI expert; we use it for a bit of day-to-day database checking; if you want to know the innards of WMI classes, better Google for things like "WMI installed software". HTH TJG -----Original Message----- From: sudhir chauhan [mailto:sudhirchauhan1@yahoo.co.in] Sent: 04 July 2003 05:32 To: Python Win32 (E-mail) Subject: [python-win32] Finding installed softwares on the remote machine using WMI Hi, I am trying to write a script which can access the remote windows 2000/XP machines and read all the installed software using WMI in python. I dont know how to proceed on this . I have some experience in python on unix and some exposure to WMI. Any pointer will be very help ful. regards, sudhir Yahoo! India Mobile SMS using the Yahoo! Messenger; Download latest version. ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20030704/c6d4427e/attachment.htm From redarch at ihug.co.nz Sat Jul 5 12:13:58 2003 From: redarch at ihug.co.nz (Guy Robinson) Date: Fri Jul 4 19:11:42 2003 Subject: [python-win32] thumbnail extraction Message-ID: <002501c34281$fd4d45a0$02d5fea9@wendy> Hello, I have a number of files that generate a thumbnail using the shell extension as discussed in this article http://msdn.microsoft.com/msdnmag/issues/0600/w2kui2/w2kui2.asp I would like to extract this thumbnail to an image file. Unfortunately I have only basic knowledge of C and limited knowledge of winapi's so the code might as well be in russian:-) As far as I can make out I need to call at least the IExtractImage,GetLocation methods but how? Can anyone give me some pointers as to how I can do this. Even a starting point would be helpful. Regards, Guy Robinson From tim.golden at viacom-outdoor.co.uk Mon Jul 7 10:19:28 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon Jul 7 04:23:36 2003 Subject: [python-win32] Finding installed softwares on the remote mach ine using WMI Message-ID: Anthony Catalfo: > Would you have an Idea how to use > FindFirstPrinterChangeNotification in python(to > monitor printer status) or how to use vb.net from > python? I'm afraid the answer to both these questions is No, altho' the first is probably best answered by looking at ctypes (there's a good worked example at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/208699); and the second is slightly more vague: what exactly do you mean by "use vb.net from python"? I suspect you mean that you've come across an example which does what you want and which runs in VB.NET. If that is the case then you're either going to have to translate it into the equivalent Python (which is probably what your first question's about) or find someone more knowledgeable than I am about the .NET framework who could talk about interoperation. Meanwhile, the following snippet will watch for print jobs using WMI. Hope it's of some use, if only as a starting point: # # uses the WMI module at http://tgolden.sc.sabren.com/python/wmi.html # import wmi c = wmi.WMI () new_print_jobs = c.watch_for ( notification_type="Creation", wmi_class="Win32_PrintJob", delay_secs=1 ) while 1: new_print_job = new_print_jobs () print new_print_job TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From tim.golden at viacom-outdoor.co.uk Mon Jul 7 16:02:44 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Mon Jul 7 10:08:04 2003 Subject: [python-win32] thumbnail extraction Message-ID: Guy Robinson: GR> I have a number of files that generate GR> a thumbnail using the shell extension GR> as discussed in this article GR> http://msdn.microsoft.com/msdnmag/issues/0600/w2kui2/w2kui2.asp GR> Can anyone give me some pointers as to how I can do this. GR> Even a starting point would be helpful. Little more than a starting point, I'm afraid, but it seems to be a slightly more complete / concise example of how to do what you want. http://netez.com/2xExplorer/shellFAQ/bas_infos.html#thumb I'm not a COM person, so I don't know if this is easily translated to Python using win32 or ctypes, but hopefully someone else on this list could say yea or nay to that. By the way, thanks for pointing out an interesting article. Altho' I work (professionally) in a Win32 environment, I rarely take the trouble to look around the Microsoft world for potentially useful titbits. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From null-python-win32 at tinfoilhat.ca Mon Jul 7 18:17:14 2003 From: null-python-win32 at tinfoilhat.ca (Sean) Date: Mon Jul 7 18:41:35 2003 Subject: [python-win32] Executing a remote process via WMI in Win32. Message-ID: I apologize for the cross post on comp.lang.python but I've yet to get any reply. I can connect to a machine remotely with no problems but I'm having trouble trying to create a process remotely. Initially this was a perl and VB script which I'm converting to python. Its entire purpose is to start a process remotely. The problem initially was that the perl script could not 'see' any mapped drives as it would alway return 'access denied' so I'm trying to not only rewrite the script but fix this problem and my idea was to connect with the Administrator account. Now the following script sort of works. I can get the set of running processes but it dies out when I try to create one. ## being ## import win32com.client wmi = win32com.client.Dispatch('wbemscripting.swbemlocator') remote_machine = wmi.ConnectServer('','root\\cimv2',Administrator','') process = remote_machine.InstancesOf("Win32_Process") for proc in process: size = int(proc.WorkingSetSize)/1024 print proc.Caption, size,"kb" # test to see if we can 'see' what's on a mapped drive. # doesn't seem to go. process.Create("cmd.exe /K dir w:\\") ## END ## The script will print out all the processes fine but once it get's to 'Create' it dies out with and error message I don't understand. NOTEPAD.EXE 80 kb Traceback (most recent call last): File "C:\Documents and Settings\scody\test.py", line 14, in ? process.Create("cmd.exe /K dir w:\\") File "C:\Python23\lib\site-packages\win32com\client\dynamic.py", line 460, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: InstancesOf.Create The process method should only have the one parameter as defined at: http://userpages.umbc.edu/~kbradl1/wsz/ref/WMIref.html#process I just tried using the 'Terminate' process but that didn't work either.... So I'm going to assume that the WMI objects are not instantiated as python classes (hence why the methods are not working). Am I completely off base here (meaning it is a syntax problem)? The whole point of this is that I'd like to automate software updates on a large set of machines and in order for this to work I need to copy files from a common share and run a specific application on each machine to finalize the installation. Any suggestions or pointers to the right direction would be creately appriciated... -- Sean From tim.golden at viacom-outdoor.co.uk Tue Jul 8 10:55:15 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Jul 8 04:59:25 2003 Subject: [python-win32] Executing a remote process via WMI in Win32. Message-ID: > Sean [... needs to control processes via WMI ...] Initial brief answer is: get hold of this module: http://tgolden.sc.sabren.com/python/wmi.html which eases the (not inconsiderable) pain of using WMI within Python. I haven't played around with the kind of authentication you need (ie Admin on remote machine) since I have Domain Admin rights on all the machines I'm interested in. It should work, however; I just haven't tried it. I've certainly terminated processes successfully. I tried doing a quick CreateProcess and it didn't like it too much, but I don't have lots of time to look into why at the moment. Promise I'll try to later. Here the first bit of your code more-or-less translated: import wmi computer = wmi.WMI () # computer = wmi.WMI ("") for process in computer.Win32_Process (): size = int (process.WorkingSetSize) / 1024 print process.Caption, size, "kb" Just to show how you could terminate processes: # # Close down any notepad processes # two seconds after they've been # started. # (Good party trick, eh?) # watcher = computer.watch_for ( notification_type="Creation", wmi_class="Win32_Process", delay_secs=2, Name="notepad.exe" ) while 1: notepad_process = watcher () print "Found notepad" notepad_process.Terminate () Note that the WMI module doesn't do much; it's forte is in keeping the kind of plumbing code hidden that you had to expose, and then doing a bit of __getattr__ magic so that you can call class instances directly, and do things like: c = wmi.WMI () process = c.Win32_Process ("notepad.exe")[0] print process.Terminate to get a list of the parameters to the process method, which must be passed by keyword. Play around with the module it and look at the code; you'll see what it can and can't do quite easily. Apart from simply Googling on "create process WMI" or some similar search term, I've found this site to be a good starting point: http://www.activxperts.com/activmonitor/windowsmanagement/wmi/samples/ Good luck, and I'll try to get hold of process creation when I can. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From Paul.Moore at atosorigin.com Tue Jul 8 11:20:35 2003 From: Paul.Moore at atosorigin.com (Moore, Paul) Date: Tue Jul 8 05:21:52 2003 Subject: [python-win32] Executing a remote process via WMI in Win32. Message-ID: <16E1010E4581B049ABC51D4975CEDB88619AB6@UKDCX001.uk.int.atosorigin.com> From: Sean [mailto:null-python-win32@tinfoilhat.ca] > Now the following script sort of works. I can get the set of running > processes but it dies out when I try to create one. First point - Create() is a method on Win32_Process, but "process" in your code is a WMI emumerator (SWbemObjectSet), not an object. > process = remote_machine.InstancesOf("Win32_Process") > # test to see if we can 'see' what's on a mapped drive. > # doesn't seem to go. > process.Create("cmd.exe /K dir w:\\") > The script will print out all the processes fine but once it get's to > 'Create' it dies out with and error message I don't understand. > AttributeError: InstancesOf.Create Means that (approximately - there are a lot of levels of complexity here) a SWbemObjectSet object doesn't have a Create method. It's the SWbemObject object that (sort of) has a Create method. > Any suggestions or pointers to the right direction would be creately > appriciated... If you look in MSDN, you'll find more incomprehensible gibberish than you have any interest in knowing. But if you work at it, and ignore the fact that there always seem to be 10 ways of doing anything, and only the most complicated one seems to actually *work*, you can get there :-) Here's a bit of code which spawns an instance of Notepad on the local machine. Once you've followed that, you should be well away. And with luck, you may be able to tweak it to work for you without needing to follow all the details (I'm not being obtuse here - I just don't have an easy way of testing exactly what you're doing, and in my experience, using this stuff without understanding it is fragile...) ----------- Cut Here ----------------- from win32com.client import GetObject # Get the "Win32_Process" object process = GetObject("winmgmts:Win32_Process") # Get an object which represents the input parameters of the "Create" # method of the Win32_Process object params = process.Methods_("Create").InParameters.SpawnInstance_() # The "CommandLine" parameter wants to be "notepad.exe" params.Properties_.Item("CommandLine").Value = "notepad.exe" # Execute the Create method on the Win32Process object process.ExecMethod_("Create", params) ----------- Cut Here ----------------- One particularly nasty issue is that method and attribute names are often case sensitive, and the VB examples in MSDN don't always use the correct case (as VB is *not* case sensitive). Hope this helps, Paul. PS I tried starting a remote process on another computer with this, but I hit errors ("The RPC server is unavailable.") This may be because of the security settings on my server - I don't know, sorry. You'll have to experiment to get that bit working... From tim.golden at viacom-outdoor.co.uk Tue Jul 8 11:37:31 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Jul 8 05:41:39 2003 Subject: [python-win32] Executing a remote process via WMI in Win32. Message-ID: From: Moore, Paul [mailto:Paul.Moore@atosorigin.com] > If you look in MSDN, you'll find more incomprehensible gibberish than you > have any interest in knowing. But if you work at it, and ignore the fact > that there always seem to be 10 ways of doing anything, and only the most > complicated one seems to actually *work*, you can get there :-) Not half! The fact that I am a relative ignoramus in matters of COM / OLE / whatever-the-hell-it's-called-this-week means that translating the examples from VB-esque languages into Python is a suck-it-and-see process for me. [... snip example of creating notepad ...] Thanks for the clear example; I've managed to add a small bolt-on to my WMI module which lets me create a new instance of a WMI class on which I can then call the Create method. And it works (on the local machine). But it won't then let me call Terminate on it (or GetOwner, or anything else). So that's got me beat. There's too much to WMI. It's great and it solves loads of problems which would otherwise require all sorts of specialist plumbing. But there's too much to it and there's too many ways to do it. > Hope this helps, > Paul. Well it helped me. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From tim.golden at viacom-outdoor.co.uk Tue Jul 8 12:10:55 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Jul 8 06:15:05 2003 Subject: [python-win32] Executing a remote process via WMI in Win32. Message-ID: > Sean [... needs to run a remote process ...] Well I updated my wmi module to allow creation of a new instance so you can do this: import wmi c = wmi.WMI () p = c.new_instance_of ("Win32_Process") p.Create (CommandLine="notepad.exe") but, like Paul Moore in his earlier post, I get kicked back with "RPC unavailable..." errors if I try it on a remote machine. I haven't messed with permissions, impersonations and so on, so it could be to do with that. I'd be keen to know if you get it working. When I have a moment, I'll dabble further but if someone gets there first I'll be very glad. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From Paul.Moore at atosorigin.com Tue Jul 8 14:18:15 2003 From: Paul.Moore at atosorigin.com (Moore, Paul) Date: Tue Jul 8 08:19:32 2003 Subject: [python-win32] Executing a remote process via WMI in Win32. Message-ID: <16E1010E4581B049ABC51D4975CEDB88619AB7@UKDCX001.uk.int.atosorigin.com> From: Tim Golden [mailto:tim.golden@viacom-outdoor.co.uk] > I'd be keen to know if you get it working. When I > have a moment, I'll dabble further but if someone > gets there first I'll be very glad. I've not got much further - I tried giving myself the "logon as a batch job" privilege, but that didn't make much difference. However, the original poster was after a way of running a process remotely. Rather than fighting with WMI, it might be worth looking at http://www.sysinternals.com and checking the "psutils" package. This includes a lot of command line utilities, one of which is psexec, for running a process on a remote computer. It may be easier to spawn psexec instead of trying to get WMI working... Paul. PS One note I saw is that WMI doesn't allow creation of interactive processes "for security reasons". Pah. This won't be the problem here, as Notepad runs non-interactively quite happily (but uselessly). Nevertheless, it might be worth knowing... From tim.golden at viacom-outdoor.co.uk Tue Jul 8 14:20:22 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Jul 8 08:24:35 2003 Subject: [python-win32] Executing a remote process via WMI in Win32. Message-ID: Paul Moore> > [...] it might be worth looking at http://www.sysinternals.com It always is, in my experience > and checking the "psutils" package ... one of which is psexec Probably depends on how much control is needed once the process is run. > PS One note I saw is that WMI doesn't allow creation of > interactive processes "for security reasons". Another note (somewhere, forget where) suggests that it'll run the process but that as soon as you try to interact, it'll die silently. However... that doesn't seem to apply to processes created this way on the local machine, as I created a cmd.exe (can't get much more insecurely interactive than that) on my machine with a Win32_Process.Create and it played along just fine. Well, who ever knows? TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From tim.golden at viacom-outdoor.co.uk Tue Jul 8 17:07:19 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Jul 8 11:11:29 2003 Subject: [python-win32] Executing a remote process via WMI in Win32. Message-ID: After a bit of to-ing and fro-ing (and help from Paul Moore) I've had some success with the following: import wmi c = wmi.WMI ("remote_machine") for p in c.Win32_Process (name="notepad.exe"): print p c.new ("Win32_Process").Create (CommandLine="notepad.exe") for p in c.Win32_Process (name="notepad.exe"): print p p.Terminate () for p in c.Win32_Process (name="notepad.exe"): print p (Don't do this to a colleague's machine where notepad is already running!) Notes: This example uses the updated version of the wmi module (at http://tgolden.sc.sabren.com/python/wmi.html) but if you're not bothered, all it's doing is attaching to the remote server and then doing a .Get on the class name and calling .Create on the resulting class object. The process you create won't be visible on the other machine, but you can see it via Task Manager (and via WMI as shown above, obviously). Microsoft caveats state that any remote process created this way will be non-interactive. Both Paul & I had Admin privs on the machines we were creating processes on, and I haven't checked what happens when you try without. However, I expect that you'll have some kind of Admin right before you try to do this kind of thing anyway. Hope this helps. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From apc1964 at yahoo.com Tue Jul 8 09:27:09 2003 From: apc1964 at yahoo.com (Anthony Catalfo) Date: Tue Jul 8 11:31:42 2003 Subject: [python-win32] Finding installed softwares on the remote mach ine using WMI In-Reply-To: Message-ID: <20030708152710.44209.qmail@web21407.mail.yahoo.com> this code works great on my xp machine and on one of my 2000 machines but fails on another 2000 machine with these errors. PythonWin 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (mhammond@skippinet.com.au) - see 'Help/About PythonWin' for further copyright information. >>> SELECT * FROM __InstanceCreationEvent WITHIN 2 WHERE TargetInstance ISA 'Win32_PrintJob' Traceback (most recent call last): File "C:\Python22\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\python\f3.py", line 16, in ? delay_secs=2 File "C:\python\wmi.py", line 365, in watch_for return _wmi_watcher (self.wmi.ExecNotificationQuery (wql)) File "C:\Python22\lib\site-packages\win32com\gen_py\565783C6-CB41-11D1-8B02-00600806D9B6x0x1x1\ISWbemServices.py", line 63, in ExecNotificationQuery return self._ApplyTypes_(15, 1, (9, 32), ((8, 1), (8, 49), (3, 49), (9, 49)), 'ExecNotificationQuery', '{27D54D92-0EBE-11D2-8B22-00600806D9B6}',strQuery, strQueryLanguage, iFlags, objWbemNamedValueSet) File "C:\Python22\lib\site-packages\win32com\client\__init__.py", line 445, in _ApplyTypes_ return self._get_good_object_(apply(self._oleobj_.InvokeTypes, (dispid, 0, wFlags, retType, argTypes) + args), user, resultCLSID) com_error: (-2147352567, 'Exception occurred.', (0, 'SWbemServices', 'Generic failure\r\n', None, 0, -2147217407), None) >>> any ideas why? thanks Anthony --- Tim Golden wrote: > Anthony Catalfo: > > > Would you have an Idea how to use > > > FindFirstPrinterChangeNotification in python(to > > monitor printer status) or how to use vb.net from > > python? > > I'm afraid the answer to both these questions > is No, altho' the first is probably best answered > by looking at ctypes (there's a good worked example > at > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/208699); > > and the second is slightly more vague: what exactly > do > you mean by "use vb.net from python"? I suspect you > > mean that you've come across an example which does > what you want and which runs in VB.NET. If that is > the > case then you're either going to have to translate > it > into the equivalent Python (which is probably what > your first question's about) or find someone more > knowledgeable than I am about the .NET framework > who > could talk about interoperation. > > Meanwhile, the following snippet will watch for > print > jobs using WMI. Hope it's of some use, if only as a > starting point: > > # > # uses the WMI module at > http://tgolden.sc.sabren.com/python/wmi.html > # > > import wmi > > c = wmi.WMI () > new_print_jobs = c.watch_for ( > notification_type="Creation", > wmi_class="Win32_PrintJob", > delay_secs=1 > ) > while 1: > new_print_job = new_print_jobs () > print new_print_job > > TJG > > ________________________________________________________________________ > This e-mail has been scanned for all viruses by Star > Internet. The > service is powered by MessageLabs. For more > information on a proactive > anti-virus service working around the clock, around > the globe, visit: > http://www.star.net.uk > ________________________________________________________________________ __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com From tim.golden at viacom-outdoor.co.uk Tue Jul 8 17:38:12 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Jul 8 11:42:38 2003 Subject: [python-win32] Finding installed softwares on the remote mach ine using WMI Message-ID: > From: Anthony Catalfo [mailto:apc1964@yahoo.com] > this code works great on my xp machine and on one of > my 2000 machines but fails on another 2000 machine > with these errors. [for those who can't see it, the piece of code is this: wql = """ SELECT * FROM __InstanceCreationEvent WITHIN 2 WHERE TargetInstance ISA 'Win32_PrintJob' """ ExecNotificationQuery (wql) ] [... snip horrendous looking COM error dump ...] In short, I've no idea. Does the machine in question definitely have WMI installed? The most recent version of the wmi module has slightly prettier error handling, but it still wouldn't point to much. Very difficult to diagnose at a distance, I'm afraid (and probably close up, too). Any one else got any ideas? TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From janez.jere at void.si Tue Jul 8 11:08:05 2003 From: janez.jere at void.si (Janez Jere) Date: Tue Jul 8 14:25:28 2003 Subject: [python-win32] ado DispatchWithEvents Message-ID: Hi, I wrote some wrappers around microsoft xml parser and ado. the code is quite debugged, except one bug I am unable to trace and fix. I would like to log all events on ado connection, so I need to do con = DispatchWithEvents("AdoDB.Connection"). which works for con.Execute(), but not for all other objects which are using con as a property (command, recordset). The same stuff works in c++ builder and delphi, which I done in previous life. If someone is willing to tests his skills: requirements: - mssql server, northwind database - extract in directory x http://freeweb.siol.net/voidconn/jj/msxml_and_ado.zip - save connect string in connstr.txt - run test_ado.py ado # this are tests which must all pass - run test_ado.py events # this test will fail, (same code as above, just different dispatch) BTW. I think that problem is not in my code, but in pythoncom libraries. Thanks in advance, Janez From theller at python.net Tue Jul 8 23:05:38 2003 From: theller at python.net (Thomas Heller) Date: Tue Jul 8 16:05:45 2003 Subject: [python-win32] Re: thumbnail extraction References: Message-ID: Tim Golden writes: > Guy Robinson: > GR> I have a number of files that generate > GR> a thumbnail using the shell extension > GR> as discussed in this article > > GR> http://msdn.microsoft.com/msdnmag/issues/0600/w2kui2/w2kui2.asp > > GR> Can anyone give me some pointers as to how I can do this. > GR> Even a starting point would be helpful. > > Little more than a starting point, I'm afraid, but it > seems to be a slightly more complete / concise example > of how to do what you want. > > http://netez.com/2xExplorer/shellFAQ/bas_infos.html#thumb > > I'm not a COM person, so I don't know if this is easily > translated to Python using win32 or ctypes, but hopefully > someone else on this list could say yea or nay to that. I want to try this (in ctypes of course), but unfortunately I don't know when I can find the time ;-) Lame excuse, I know. > > By the way, thanks for pointing out an interesting article. > Altho' I work (professionally) in a Win32 environment, > I rarely take the trouble to look around the Microsoft > world for potentially useful titbits. Thomas From tony at tcapp.com Sun Jul 13 01:05:20 2003 From: tony at tcapp.com (Tony Cappellini) Date: Sun Jul 13 03:08:22 2003 Subject: [python-win32] Are small attachments allowed ? Message-ID: <5.1.0.14.0.20030713000415.01ae2bf8@smtp.sbcglobal.net> I want to send a screenshot of the PythonWin IDE, to illustrate a problem that i'm having. Are small (< 100K ) attachments allowed ? thanks From janeaustine50 at hotmail.com Mon Jul 14 15:52:02 2003 From: janeaustine50 at hotmail.com (Austine Jane) Date: Mon Jul 14 01:52:36 2003 Subject: [python-win32] Accessing IE from GetForegroundWindow()? Message-ID: I can get to the foreground IE instance via win32ui.GetForegroundWindow(). I'd like to access the Document object from it. How can I do it? Thanks in advance, Jane _________________________________________________________________ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail From henni at brainbot.com Mon Jul 14 15:52:11 2003 From: henni at brainbot.com (Thorsten Henninger) Date: Mon Jul 14 08:54:13 2003 Subject: [python-win32] Replace Common Windows Dialogs Message-ID: <3F12A77B.60402@brainbot.com> Hi all, I would like to replace the Windows Save-As Dialog systemwide. If a user hits "SaveAs" in any application, my own SaveAs-Dialog (e.g. my application) should be opened instead. Does anybody know, if this is possible and how to do this? thanks for any help on this topic, regards, Thorsten Henninger From amapy at snafu.de Tue Jul 15 17:33:10 2003 From: amapy at snafu.de (Andreas Maurer) Date: Tue Jul 15 12:33:17 2003 Subject: [python-win32] Quoting Blanks in Command Line Message-ID: Hi folks, I've a little script which gets a list of files from the command line. myscript.py -f file1,file2,"file3 with blank" Some filenames will contain blanks and sys.argv[1:] will give me that result: ['-f,'file1,file2,"file3','with','blanks"'] and not the expected list ['-f,'file1,file2,"file3 with blanks"'] I've tried to quote the blanks "\ ", but this attempt doesn't work. Has anybody an idea to fix this problem? Many thanks Andi From tim.golden at viacom-outdoor.co.uk Tue Jul 15 18:35:13 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Jul 15 12:39:27 2003 Subject: [python-win32] Quoting Blanks in Command Line Message-ID: Andreas Maurer> > I've a little script which gets a list of files from > the command line. > myscript.py -f file1,file2,"file3 with blank" > gives > ['-f,'file1,file2,"file3','with','blanks"'] > and not > ['-f,'file1,file2,"file3 with blanks"'] Simplest suggestion is to use: myscript.py -f file1 file2 "file3 with blank" which will give: C:\temp>temp.py file1 file2 "file3 with space" ['file1', 'file2', 'file3 with space'] or, if you must: C:\temp>python Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> argv = ['-f', 'file1,file2,"file3 with space"'] >>> [s.split (",") for s in argv] [['-f'], ['file1', 'file2', '"file3 with space"']] >>> depending on what you're after. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From Jim.Vickroy at noaa.gov Wed Jul 16 11:55:53 2003 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Jul 16 12:55:57 2003 Subject: [python-win32] win32process.TerminateProcess error Message-ID: <3F158399.BC1F3C64@noaa.gov> Howdy, I have added the following line: win32process.TerminateProcess(hProcess, 9) to the runproc demo distributed with Pythonwin which produces the following error: pywintypes.error: (5, 'TerminateProcess', 'Access is denied.') How can a child process be aborted by its parent? Thanks, -- jv From null-python-win32 at tinfoilhat.ca Wed Jul 16 13:41:12 2003 From: null-python-win32 at tinfoilhat.ca (Sean) Date: Wed Jul 16 14:06:12 2003 Subject: [python-win32] win32process.TerminateProcess error In-Reply-To: <3F158399.BC1F3C64@noaa.gov> Message-ID: -> pywintypes.error: (5, 'TerminateProcess', 'Access is denied.') -> I've been working remotely (via WMI) and I've found you have to connect as the local Administrator for this to work. Since you are working locally things might be different though. -- Sean "A computer lets you make more mistakes faster than any other human invention in history, with the possible exception of handguns and tequila." - Mitch Ratcliffe From Jim.Vickroy at noaa.gov Wed Jul 16 13:39:37 2003 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Jul 16 14:39:50 2003 Subject: [python-win32] win32process.TerminateProcess error References: Message-ID: <3F159BE9.B4DAEE45@noaa.gov> Thanks for the info Sean. Since my original posting, I've continued to experiment and have just isolated the problem to the anonymous pipes in the example. Without the pipes TerminateProcess works as expected. I'm continuing to experiment, but so far I do not really understand the behavior. Sean wrote: > -> pywintypes.error: (5, 'TerminateProcess', 'Access is denied.') > -> > I've been working remotely (via WMI) and I've found you have to connect as > the local Administrator for this to work. Since you are working locally > things might be different though. > > -- > Sean > > "A computer lets you make more mistakes faster than any other human invention > in history, with the possible exception of handguns and tequila." > - Mitch Ratcliffe > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From tony at tcapp.com Thu Jul 17 00:13:49 2003 From: tony at tcapp.com (Tony Cappellini) Date: Thu Jul 17 02:17:03 2003 Subject: [python-win32] Last 6 lines on screen are not visible, when PythonWin is not Maximized In-Reply-To: Message-ID: <5.1.0.14.0.20030716225608.047c2050@tcapp.com> I'm using Win32all Build 152, on Windows 2000, and Win 98 SE. If I don't Maximize the window, then the Last several lines will not be visible, (I have to type without seeing what I'm typing) This occurs on 3 different computers that I use. 2 Have Windows 2000 SP3, the other runs Win 98 SE. See these images for an example. http://www.tcapp.com/pub/incoming/Win32IDE_1.jpg http://www.tcapp.com/pub/incoming/Win32IDE_2.jpg Maximizing the window does fix the problem, but it's much more practical to have several windows visible at once. I'm running 1024 * 768, small fonts on one Win2k machine, and a much higher resolution (also small fonts) on the Win 98 machine. All of the machines use completely different graphics cards/drives (one is a Laptop with an LCD) Is there a fix/work around ? thanks From bgailer at alum.rpi.edu Thu Jul 17 10:04:47 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Thu Jul 17 11:06:05 2003 Subject: [python-win32] Last 6 lines on screen are not visible, when PythonWin is not Maximized In-Reply-To: <5.1.0.14.0.20030716225608.047c2050@tcapp.com> References: Message-ID: <5.2.1.1.0.20030717085808.027f8140@66.28.54.253> At 11:13 PM 7/16/2003 -0700, Tony Cappellini wrote: >I'm using Win32all Build 152, on Windows 2000, and Win 98 SE. >If I don't Maximize the window, then the Last several lines will not be >visible, (I have to type without seeing what I'm typing) > >This occurs on 3 different computers that I use. 2 Have Windows 2000 SP3, >the other runs Win 98 SE. >See these images for an example. > >http://www.tcapp.com/pub/incoming/Win32IDE_1.jpg >http://www.tcapp.com/pub/incoming/Win32IDE_2.jpg > >Maximizing the window does fix the problem, but it's much more practical >to have several windows visible at once. > >I'm running 1024 * 768, small fonts on one Win2k machine, and a much >higher resolution (also small fonts) on the Win 98 machine. >All of the machines use completely different graphics cards/drives (one is >a Laptop with an LCD) I have tried to reproduce your graphics in PythonWin and have failed!. It looks like the visible window is the Interactive Window, yet "[Interactive Window]" does not appear in any title bar, nor do the minimize/restore/maximize/close buttons for the active window. How did you start PythonWin? Bob Gailer bgailer@alum.rpi.edu 303 442 2625 -------------- next part -------------- --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.500 / Virus Database: 298 - Release Date: 7/10/2003 From GK-lists at ninebynine.org Wed Jul 16 18:09:32 2003 From: GK-lists at ninebynine.org (Graham Klyne) Date: Thu Jul 17 12:24:31 2003 Subject: [python-win32] Win32 WaitableTimers and Python? Message-ID: <5.1.0.14.2.20030716165434.01e503f0@127.0.0.1> Hi, I've been hunting through the book "Python Programming on Win32", associated web pages, and Googling the web in general, without much success, for an indication of whether CreateWaitableTimer and friends can be used from Python; cf. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createwaitabletimer.asp In particular, I'm looking to use timers to do periodic polling functions in a service process. I think I can use win32api.sleep for now, but I don't like hogging a thread in this way. Being a service process, I think the window-based timers are inappropriate (if not impossible) to use here. Any thoughts? (I'm not subscribed to this list, so please copy me on any comments.) Thanks. #g ------------------- Graham Klyne PGP: 0FAA 69FF C083 000B A2E9 A131 01B9 1C7A DBCA CB5E From jens.jorgensen at tallan.com Thu Jul 17 15:02:50 2003 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Thu Jul 17 15:02:50 2003 Subject: [python-win32] Win32 WaitableTimers and Python? In-Reply-To: <5.1.0.14.2.20030716165434.01e503f0@127.0.0.1> References: <5.1.0.14.2.20030716165434.01e503f0@127.0.0.1> Message-ID: <3F16F2DA.5010109@tallan.com> No a priori reason you could not use them but they do not seem to be in the win32event module wherein they'd likely be found if they were present. No need to let that stop you though. You could either write your own c(++) extension module or even better you could use the ctypes module. With ctypes if you wanted to wait 60 seconds you'd do this: from ctypes import * import win32event, win32api h = windll.kernel32.CreateWaitableTimerA(None, 0, None) dt = c_longlong(-60L * 10L**(9-2)) dt_p = pointer(dt) windll.kernel32.SetWaitableTimer(h, dt_p, 0, None, None, 0) win32event.WaitForSingleObject(h, win32event.INFINITE) win32api.CloseHandle(h) The ctypes home page is: http://starship.python.net/crew/theller/ctypes/ Graham Klyne wrote: > Hi, > > I've been hunting through the book "Python Programming on Win32", > associated web pages, and Googling the web in general, without much > success, for an indication of whether CreateWaitableTimer and friends > can be used from Python; cf. > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createwaitabletimer.asp > > > In particular, I'm looking to use timers to do periodic polling > functions in a service process. I think I can use win32api.sleep for > now, but I don't like hogging a thread in this way. Being a service > process, I think the window-based timers are inappropriate (if not > impossible) to use here. > > Any thoughts? > > (I'm not subscribed to this list, so please copy me on any comments.) > > Thanks. > > #g > > > ------------------- > Graham Klyne > > PGP: 0FAA 69FF C083 000B A2E9 A131 01B9 1C7A DBCA CB5E > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From tony at tcapp.com Thu Jul 17 15:31:50 2003 From: tony at tcapp.com (Tony Cappellini) Date: Thu Jul 17 17:31:52 2003 Subject: [python-win32] Last 6 lines on screen are not visible, when PythonWin is not Maximized In-Reply-To: <5.2.1.1.0.20030717085808.027f8140@66.28.54.253> Message-ID: <20030717141947.D78026-100000@yamato.yamato.com> > I have tried to reproduce your graphics in PythonWin and have failed!. It > looks like the visible window is the Interactive Window, yet "[Interactive > Window]" does not appear in any title bar, nor do the > minimize/restore/maximize/close buttons for the active window. How did you > start PythonWin? I have a shorcut to the executable C:\Apps\Python222\Lib\site-packages\Pythonwin\Pythonwin.exe I didn't even notice the lack of "INteractive Window" until you mentioned it.. The Title bar for the Interactive Window goes away, when I maximize the Interactive Window. When I do that, the Title Bar fr the application becomes active- and there is only one window. If I click on the Restore button for the Application, then the Interactive window Title BAr reappears, as a separate title bar, from the Win32 IDE/Application. From GK-lists at ninebynine.org Thu Jul 17 22:22:11 2003 From: GK-lists at ninebynine.org (Graham Klyne) Date: Thu Jul 17 17:46:55 2003 Subject: [python-win32] Win32 WaitableTimers and Python? In-Reply-To: <3F16F2DA.5010109@tallan.com> References: <5.1.0.14.2.20030716165434.01e503f0@127.0.0.1> <5.1.0.14.2.20030716165434.01e503f0@127.0.0.1> Message-ID: <5.1.0.14.2.20030717203215.01e31458@127.0.0.1> Thanks, that's a useful pointer. (It turns out that I'd forgotten the wait methods have a built-in timeout that may be just enough for my purposes. But that's good to have as a backup.) #g -- At 14:02 17/07/03 -0500, Jens B. Jorgensen wrote: >No a priori reason you could not use them but they do not seem to be in >the win32event module wherein they'd likely be found if they were present. >No need to let that stop you though. You could either write your own c(++) >extension module or even better you could use the ctypes module. With >ctypes if you wanted to wait 60 seconds you'd do this: > >from ctypes import * >import win32event, win32api > >h = windll.kernel32.CreateWaitableTimerA(None, 0, None) >dt = c_longlong(-60L * 10L**(9-2)) >dt_p = pointer(dt) >windll.kernel32.SetWaitableTimer(h, dt_p, 0, None, None, 0) >win32event.WaitForSingleObject(h, win32event.INFINITE) >win32api.CloseHandle(h) > >The ctypes home page is: http://starship.python.net/crew/theller/ctypes/ > >Graham Klyne wrote: > >>Hi, >> >>I've been hunting through the book "Python Programming on Win32", >>associated web pages, and Googling the web in general, without much >>success, for an indication of whether CreateWaitableTimer and friends can >>be used from Python; cf. >> >>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createwaitabletimer.asp >> >> >>In particular, I'm looking to use timers to do periodic polling functions >>in a service process. I think I can use win32api.sleep for now, but I >>don't like hogging a thread in this way. Being a service process, I >>think the window-based timers are inappropriate (if not impossible) to >>use here. >> >>Any thoughts? >> >>(I'm not subscribed to this list, so please copy me on any comments.) >> >>Thanks. >> >>#g >> >> >>------------------- >>Graham Klyne >> >>PGP: 0FAA 69FF C083 000B A2E9 A131 01B9 1C7A DBCA CB5E >> >> >>_______________________________________________ >>Python-win32 mailing list >>Python-win32@python.org >>http://mail.python.org/mailman/listinfo/python-win32 > > >-- >Jens B. Jorgensen >jens.jorgensen@tallan.com > >"With a focused commitment to our clients and our people, we deliver value >through customized technology solutions" ------------------- Graham Klyne PGP: 0FAA 69FF C083 000B A2E9 A131 01B9 1C7A DBCA CB5E From happy_ca_camper at yahoo.com Fri Jul 18 11:19:42 2003 From: happy_ca_camper at yahoo.com (Brian Mahoney) Date: Fri Jul 18 13:19:44 2003 Subject: [python-win32] FrameMaker programming via FrameMaker API COM? OLE? What? Message-ID: <20030718171942.89558.qmail@web20701.mail.yahoo.com> I'm biting the bullet and looking at wrapping the C-language FrameMaker API in Python. Adobe FrameMaker Windows documentation describes a COM session where a client can connect to the running FrameMaker session and use the full FrameMaker API library to control FM. However, before I start wrapping the API, my first Python extension, I would like to understand the FrameMaker COM/OLE, at least see if I can do the initial connection via existing Python modules. Everything, including the session connection is done through the API, so I learn nothing from that documentation. My previous OLE experience started and ended with the first version of OLE for 16-bit Windows so I am not up on current OLE/COM terminology. The Visual Studio OLE/COM object viewer, under "All Objects" shows me a 32-bit FrameMaker API InProcServer32 = ole32.dll LocalServer32 = ...FrameMaker.exe /Automation /iconic /nosplash The most interesting interfaces are IFrameMakerSession0 and IFrameMakerSession1 They list a CLSID with an IFrameMakerSession0_PSFactory with an InprocServer32 = ...\afmfdk.dll Does this tell me what kind of server I have for FrameMaker or is it only telling me stuff about the FrameMaker API client, and what I do in Python to expose any interface? __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com From jens.jorgensen at tallan.com Fri Jul 18 13:36:28 2003 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Fri Jul 18 13:36:26 2003 Subject: [python-win32] FrameMaker programming via FrameMaker API COM? OLE? What? In-Reply-To: <20030718171942.89558.qmail@web20701.mail.yahoo.com> References: <20030718171942.89558.qmail@web20701.mail.yahoo.com> Message-ID: <3F18301C.20704@tallan.com> You can probably do all of this without creating a C extension module. You'd use the win32 extensions COM support. As long as the type library is automation compatible it will work. You'll first probably want to generate a COM wrapper library with /Lib/site-packages/win32com/client/makepy.py. This script will throw up a GUI that will allow you to select the type library for the FrameMaker API. By default the script will generate the wrapper library as a module named by the type library's GUID, version, and LCID and store it in Lib/site-packages/win32com/gen_py/. You'd then access it in your script with: from win32com.client import gencache FM = gencache.EnsureModule(, , , ) And then FM will be a python module. For example I use the VSS COM API with: VSS = gencache.EnsureModule('{783CD4E0-9D54-11CF-B8EE-00608CC9A71F}', 0, 5, 1) The sticking point here if of course that you need to know the guid, version, and LCID. This is not a big deal really though. You can use the OLE View tool that comes with Visual Studio to lookup the library by name under the Type Libraries tree and then when you select it in the right pane you'll see something like: TypeLib + {783CD4E0-9D54-11CF-B8EE-00608CC9A71F} + 5.1 = Microsoft SourceSafe 6.0 Type Library + 0 + win32 = ... The version is there (5.1) and the LCID is the integer under that. Then just follow the API's documentation. The identifier will be the same. You may find minor weirdness where objects have "properties" that take params. Sometimes for these python has to generate get and set methods to handle these with generated names. Should you hit something like this just look at the generated wrapper .py and you should be able to see what wrapper methods have been created. Other than that the type lib Enums will be under .constants Good luck! Brian Mahoney wrote: >I'm biting the bullet and looking at wrapping the >C-language FrameMaker API in Python. Adobe FrameMaker >Windows documentation describes a COM session where a >client can connect to the running FrameMaker session >and use the full FrameMaker API library to control FM. > > >However, before I start wrapping the API, my first >Python extension, I would like to understand the >FrameMaker COM/OLE, at least see if I can do the >initial connection via existing Python modules. >Everything, including the session connection is done >through the API, so I learn nothing from that >documentation. My previous OLE experience started and >ended with the first version of OLE for 16-bit Windows >so I am not up on current OLE/COM terminology. > >The Visual Studio OLE/COM object viewer, under "All >Objects" shows me a 32-bit FrameMaker API >InProcServer32 = ole32.dll >LocalServer32 = ...FrameMaker.exe /Automation /iconic >/nosplash >The most interesting interfaces are >IFrameMakerSession0 and IFrameMakerSession1 >They list a CLSID with an >IFrameMakerSession0_PSFactory >with an InprocServer32 = ...\afmfdk.dll > >Does this tell me what kind of server I have for >FrameMaker or is it only telling me stuff about the >FrameMaker API client, and what I do in Python to >expose any interface? > > >__________________________________ >Do you Yahoo!? >SBC Yahoo! DSL - Now only $29.95 per month! >http://sbc.yahoo.com > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From happy_ca_camper at yahoo.com Fri Jul 18 13:46:18 2003 From: happy_ca_camper at yahoo.com (Brian Mahoney) Date: Fri Jul 18 15:46:22 2003 Subject: [python-win32] FrameMaker programming via FrameMaker API COM? OLE? What? In-Reply-To: <3F18301C.20704@tallan.com> Message-ID: <20030718194618.79011.qmail@web20710.mail.yahoo.com> For FrameMaker I can find no typelib. In the regedit entry for the CLSID of FrameMaker API and all other strings with "FrameMaker" there is no TypeLib entry and nothing in the OLE/COM Object Viewer Type Libraries list. So, can I query any useful thing via COM FrameMaker from Python, or do I just start wrapping? --- "Jens B. Jorgensen" wrote: > You can probably do all of this without creating a C > extension module. > You'd use the win32 extensions COM support. As long > as the type library > is automation compatible it will work. You'll first > probably want to > generate a COM wrapper library with dir>/Lib/site-packages/win32com/client/makepy.py. > This script will throw > up a GUI that will allow you to select the type > library for the > FrameMaker API. By default the script will generate > the wrapper library > as a module named by the type library's GUID, > version, and LCID and > store it in Lib/site-packages/win32com/gen_py/. > You'd then access it in > your script with: > > from win32com.client import gencache > FM = gencache.EnsureModule(, , ver #>, ) > > And then FM will be a python module. For example I > use the VSS COM API with: > VSS = > gencache.EnsureModule('{783CD4E0-9D54-11CF-B8EE-00608CC9A71F}', > 0, > 5, 1) > > The sticking point here if of course that you need > to know the guid, > version, and LCID. This is not a big deal really > though. You can use the > OLE View tool that comes with Visual Studio to > lookup the library by > name under the Type Libraries tree and then when you > select it in the > right pane you'll see something like: > > TypeLib > + {783CD4E0-9D54-11CF-B8EE-00608CC9A71F} > + 5.1 = Microsoft SourceSafe 6.0 Type Library > + 0 > + win32 = > ... > > The version is there (5.1) and the LCID is the > integer under that. > > Then just follow the API's documentation. The > identifier will be the > same. You may find minor weirdness where objects > have "properties" that > take params. Sometimes for these python has to > generate get and set > methods to handle these with generated names. Should > you hit something > like this just look at the generated wrapper .py and > you should be able > to see what wrapper methods have been created. Other > than that the type > lib Enums will be under .constants > > Good luck! > > Brian Mahoney wrote: > > >I'm biting the bullet and looking at wrapping the > >C-language FrameMaker API in Python. Adobe > FrameMaker > >Windows documentation describes a COM session where > a > >client can connect to the running FrameMaker > session > >and use the full FrameMaker API library to control > FM. > > > > > >However, before I start wrapping the API, my first > >Python extension, I would like to understand the > >FrameMaker COM/OLE, at least see if I can do the > >initial connection via existing Python modules. > >Everything, including the session connection is > done > >through the API, so I learn nothing from that > >documentation. My previous OLE experience started > and > >ended with the first version of OLE for 16-bit > Windows > >so I am not up on current OLE/COM terminology. > > > >The Visual Studio OLE/COM object viewer, under "All > >Objects" shows me a 32-bit FrameMaker API > >InProcServer32 = ole32.dll > >LocalServer32 = ...FrameMaker.exe /Automation > /iconic > >/nosplash > >The most interesting interfaces are > >IFrameMakerSession0 and IFrameMakerSession1 > >They list a CLSID with an > >IFrameMakerSession0_PSFactory > >with an InprocServer32 = ...\afmfdk.dll > > > >Does this tell me what kind of server I have for > >FrameMaker or is it only telling me stuff about the > >FrameMaker API client, and what I do in Python to > >expose any interface? > > > > > >__________________________________ > >Do you Yahoo!? > >SBC Yahoo! DSL - Now only $29.95 per month! > >http://sbc.yahoo.com > > > >_______________________________________________ > >Python-win32 mailing list > >Python-win32@python.org > >http://mail.python.org/mailman/listinfo/python-win32 > > > > > > -- > Jens B. Jorgensen > jens.jorgensen@tallan.com > > "With a focused commitment to our clients and our > people, we deliver value through customized > technology solutions" > > __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com From theller at python.net Fri Jul 18 22:52:27 2003 From: theller at python.net (Thomas Heller) Date: Fri Jul 18 16:16:06 2003 Subject: [python-win32] Re: FrameMaker programming via FrameMaker API COM? OLE? What? References: <3F18301C.20704@tallan.com> <20030718194618.79011.qmail@web20710.mail.yahoo.com> Message-ID: Brian Mahoney writes: > For FrameMaker I can find no typelib. In the regedit > entry for the CLSID of FrameMaker API and all other > strings with "FrameMaker" there is no TypeLib entry > and nothing in the OLE/COM Object Viewer Type > Libraries list. > > So, can I query any useful thing via COM FrameMaker > from Python, or do I just start wrapping? I don't know, but *before* you start wrapping take a look at http://starship.python.net/crew/theller/ctypes/ Thomas From kj7ny at yahoo.com Mon Jul 21 11:58:00 2003 From: kj7ny at yahoo.com (kj7ny) Date: Mon Jul 21 14:53:09 2003 Subject: [python-win32] Service on Win2k and Timer Message-ID: I have read several posts here that appear to address my issue but they all went way over my head! Hopefully I can get an answer here that is 'dumbed down' enough for me to understand it :) I believe I am trying to do pretty much the same thing as Sean in the post: "Executing a remote process via WMI in Win32." ... but not nearly at the same advanced level. (I'm not sure I need to go the WMI route.) I am writing Python code to perform remote updates of software across a WAN (all Win2K machines). However, at this point, all I have to do is unzip one or more files and tweak some config settings. (It may be enhanced to do more in the future but that will depend upon the success of this effort.) I control the entire process with a MySQL database. I have no problems with any access permissions, with any MySQL access, with the unzip or tweak processes. I started the utility by using the py2exe Windows Service sample code. I have a service that runs well (as far as I can tell). I have code that does the processing once it is fired off (it isn't completely finished but I anticipate no major surprises). The issue is my lack of understanding of how to correctly create the timer event within the service. I created a while(1) loop with a time.sleep(nsecs) which works, but I can't stop the service without first killing the while(1) loop and I am not convinced that I am not using up too much of the processor and making this thing a hog that I won't be able to use. During development, I am running a time.sleep(5) to time.sleep(60) just so I can keep testing. In real life, it will probably be checking in somewhere from once an hour to once a day. How should I create a timer within the service so that this thing is as unintrusive as possible when it isn't actually performing an update and so that it runs nicely as a service and can be started and stopped gracefully? Thanks, From happy_ca_camper at yahoo.com Tue Jul 22 09:50:25 2003 From: happy_ca_camper at yahoo.com (Brian Mahoney) Date: Tue Jul 22 11:50:38 2003 Subject: [python-win32] Re: FrameMaker programming via FrameMaker API COM? OLE? What? In-Reply-To: Message-ID: <20030722155025.57656.qmail@web20714.mail.yahoo.com> I was out for a few days. I had looked at CTYPES as an alternative and looked again. I realize now that any FrameMaker API calls only end up in the DLLs which I create as compiled C programs acting as clients of FrameMaker. There is no DLL for FrameMaker wrapping the API, so it appears there no practical interface for directly using COM/OLE or using CTYPE. The existing DLLs betweeen FrameMaker and any program I write are only DLLs that marshall activities, they don't have any FrameMaker API that is open to me or documented. At least as far as I can see. I have some ideas for the FrameMaker API wrapper from the Adobe AfterEffects API Python wrapper at http://opensource.adobe.com (not very active) They wrapped that API and seem to have some good ideas for handling arguments, etc. Thank you for the suggestions. --- Thomas Heller wrote: > Brian Mahoney writes: > > > For FrameMaker I can find no typelib. In the > regedit > > entry for the CLSID of FrameMaker API and all > other > > strings with "FrameMaker" there is no TypeLib > entry > > and nothing in the OLE/COM Object Viewer Type > > Libraries list. > > > > So, can I query any useful thing via COM > FrameMaker > > from Python, or do I just start wrapping? > > I don't know, but *before* you start wrapping take a > look at > http://starship.python.net/crew/theller/ctypes/ > > Thomas > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com From null-python-win32 at tinfoilhat.ca Tue Jul 22 12:08:02 2003 From: null-python-win32 at tinfoilhat.ca (Sean) Date: Tue Jul 22 12:33:28 2003 Subject: [python-win32] PDC vs VLAN cage match. Message-ID: Recently VLANS were setup on the network I use. Since then the GetServers or win32net.NetServerEnum functions only return the names of the machines on the same VLAN as the PDC. This I understand but unfortunately I need to get the name of every machine on the entire domain (which spans vlans). The two PDC's both have all the machine's in their list. Is there a way to get the contents of the listing (via NT4 Server Manger)? Is it possible to just enumerate all the members of a NT domain regardless of wheter you get broadcasts from each member? Is there some specific thing I have to set in windows to allow it to 'see' machines beyond it's VLAN? Any pointers in the right direction would be appriciated, -- Sean "A computer lets you make more mistakes faster than any other human invention in history, with the possible exception of handguns and tequila." - Mitch Ratcliffe From mailings at johnnydebris.net Tue Jul 22 19:28:20 2003 From: mailings at johnnydebris.net (Guido Wesdorp) Date: Tue Jul 22 12:34:00 2003 Subject: [python-win32] Services, non-registered Python and import path problem Message-ID: <3F1D6624.6090401@johnnydebris.net> Hello there! For one of our products (an XMLRPC server that converts XML files of a specific format to Word documents using COM) I'm building an installer (Windows only, obviously :) and now I have a problem I don't know how to solve. My setup is somewhat complicated: the installer places a full Python distribution (together with Twisted and PyXML) somewhere on disk and does NOT register itself in the registry. That way I hope to be able to avoid clashes with other Python versions installed (especially the modules in the Python Lib dir should be sandboxed: PyXML overwrites some core modules and I don't want to interfere with what the user already has installed, also I don't want to overwrite possibly newer installs of PyXML or Twisted), which seems to work just fine so far. However, when I register the app as an NT service, there are two weird things I run into: the Python version called seems to be another one than the one I installed (although I use the installed one to register the service with: obviously that is not enough and Windows dives back to the one that is registered in the Registry, don't know what happens if no Python is installed at all) and also, no matter what I do (yes, I've played around with setting sys.path correctly) some modules can not be found. Do any of those problems sound familiar? If so, is there a way to work around/solve them? Help would be greatly appreciated... Cheers, Guido Wesdorp, Infrae (Holland) From dave at psys.org Tue Jul 22 13:13:40 2003 From: dave at psys.org (d.w. harks) Date: Tue Jul 22 13:13:45 2003 Subject: [python-win32] PDC vs VLAN cage match. In-Reply-To: References: Message-ID: <20030722171339.GB3345@psys.org> In our last episode, Sean expounded thusly: > Recently VLANS were setup on the network I use. > > Since then the GetServers or win32net.NetServerEnum functions only return > the names of the machines on the same VLAN as the PDC. This I understand > but unfortunately I need to get the name of every machine on the entire > domain (which spans vlans). The two PDC's both have all the machine's in > their list. Is there a way to get the contents of the listing (via NT4 > Server Manger)? Is it possible to just enumerate all the members of a > NT domain regardless of wheter you get broadcasts from each member? > > Is there some specific thing I have to set in windows to allow it to 'see' > machines beyond it's VLAN? > > Any pointers in the right direction would be appriciated, > > -- > Sean Are you using WINS? dave -- David W. Harks http://dwblog.psys.org From null at tinfoilhat.ca Tue Jul 22 12:52:11 2003 From: null at tinfoilhat.ca (Sean) Date: Tue Jul 22 13:54:05 2003 Subject: [python-win32] PDC vs VLAN cage match. In-Reply-To: <20030722171339.GB3345@psys.org> Message-ID: ->Are you using WINS? -> Yes. -- Sean "A computer lets you make more mistakes faster than any other human invention in history, with the possible exception of handguns and tequila." - Mitch Ratcliffe From dave at psys.org Tue Jul 22 14:08:00 2003 From: dave at psys.org (d.w. harks) Date: Tue Jul 22 14:08:04 2003 Subject: [python-win32] PDC vs VLAN cage match. In-Reply-To: <20030722171339.GB3345@psys.org> References: <20030722171339.GB3345@psys.org> Message-ID: <20030722180800.GC3345@psys.org> In our last episode, d.w. harks expounded thusly: > In our last episode, Sean expounded thusly: > > Recently VLANS were setup on the network I use. > > > > Since then the GetServers or win32net.NetServerEnum functions only return > > the names of the machines on the same VLAN as the PDC. This I understand > > but unfortunately I need to get the name of every machine on the entire > > domain (which spans vlans). The two PDC's both have all the machine's in > > their list. Is there a way to get the contents of the listing (via NT4 > > Server Manger)? Is it possible to just enumerate all the members of a > > NT domain regardless of wheter you get broadcasts from each member? > > > > Is there some specific thing I have to set in windows to allow it to 'see' > > machines beyond it's VLAN? > > > > Any pointers in the right direction would be appriciated, > > > > -- > > Sean > > Are you using WINS? > > dave OK, another way to do it would be to use ADSI with the WinNT provider and do a listing of everything on the domain, like this: import win32com.client adsi = win32com.client.Dispatch("ADsNameSpaces") nt = adsi.GetObject("", "WinNT:") dom = nt.OpenDSObject("WinNT://DOM", "user", "password", 0) dom.Filter = ["computer"] for comp in dom: print comp.Name -- David W. Harks http://dwblog.psys.org From ausum_studio at hotmail.com Wed Jul 23 06:05:38 2003 From: ausum_studio at hotmail.com (Ausum Studio) Date: Wed Jul 23 06:05:43 2003 Subject: [python-win32] Triggering a browser window from a python service Message-ID: I'm trying to create local alerts for my W2K server running Zope, and those will take the form of browser's pop-ups. I've tested: def trigger_window(url): import webbrowser webbrowser.open(url) and it works fine from a standalone Zope (via an ExternalMethod), except when it runs as a win32 service. In Zope's list I've been suggested to ask for help here, as this seems to be a limitation of pythonservice.exe or perhaps a limitation of nt services at all. Is there a workaround? :) Thanks in advance, Ausum From tim.golden at viacom-outdoor.co.uk Wed Jul 23 12:21:16 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Wed Jul 23 06:26:07 2003 Subject: [python-win32] Service on Win2k and Timer Message-ID: > kj7ny wrote: > I believe I am trying to do pretty much the same thing as Sean in the > post: "Executing a remote process via WMI in Win32." ... but not nearly > at the same advanced level. (I'm not sure I need to go the WMI route.) Using WMI isn't necessarily advanced, altho' it needn't be what you want, either. > I am writing Python code to perform remote updates of software across a > WAN (all Win2K machines). ... > I control the entire process with a MySQL database. This doesn't quite give enough information. Do you have a MySQL database on each machine? Do you simply have one on a master machine which holds updated settings? Something else? > I have no problems with any access permissions, with any MySQL access, > with the unzip or tweak processes. Good > I started the utility by using the py2exe Windows Service sample code. > I have a service that runs well (as far as I can tell). So far, I can't see where a service comes into it. > The issue is my lack of understanding of how to correctly create the > timer event within the service. I can't see what the timer is for, either... [... snip sensible-sounding stuff about time.sleep ...] Could you give an outline of what the process is doing, eg (guess): I have a service on each client machine, waiting for a command from a central machine which controls updates on the basis of information in a MySQL database. The client service needs to wake up every hour to check for any changes to software and then to do whatever unzipping and tweaking is necessary. At all other times, the service should lie low and consume no resources. Is this close? Have I got the wrong idea? I'm quite happy to make suggestions, either with or without WMI, but I'd rather know more clearly what you're trying to do. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From pf_moore at yahoo.co.uk Wed Jul 23 14:13:01 2003 From: pf_moore at yahoo.co.uk (Paul Moore) Date: Wed Jul 23 08:22:38 2003 Subject: [python-win32] Re: Triggering a browser window from a python service References: Message-ID: "Ausum Studio" writes: > I'm trying to create local alerts for my W2K server running Zope, and those > will take the form of browser's pop-ups. I've tested: > > def trigger_window(url): > import webbrowser > webbrowser.open(url) > > and it works fine from a standalone Zope (via an ExternalMethod), except > when it runs as a win32 service. Windows services don't have access to the screen (the "Desktop") by default. You need to change the (Zope?) service to set the "interact with the desktop" property on. Paul. -- This signature intentionally left blank From romerchat at hotmail.com Wed Jul 23 16:23:51 2003 From: romerchat at hotmail.com (Reuven Abliyev) Date: Wed Jul 23 08:32:15 2003 Subject: [python-win32] UNICODE strings Message-ID: I using ACCESS & ADO Database contains some data in Hebrew connect to DB - OK getting Recordset - OK BUT when I'm trying to load data I've got into COMBOBOX I'm getting this message: UnicodeError: ASCII encoding error: ordinal not in range(128) How can I solve this From jens.jorgensen at tallan.com Wed Jul 23 10:32:02 2003 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Wed Jul 23 10:31:57 2003 Subject: [python-win32] UNICODE strings In-Reply-To: References: Message-ID: <3F1E9C62.9040904@tallan.com> Your question is unfortunately too vague to tell you how to solve this. The error you're getting though is occuring because you're somehow (possibly inadvertently) converting a unicode string (returned from the recordset) into a "regular" (ascii) string. You probably shouldn't be doing the conversion at all since the data (hebrew) is not encodable in ascii. Since it is unclear how you're doing what it is your doing though it is hard to tell you how to get the combobox and not end up doing this ascii conversion. Perhaps you could post some code as well so we can see what's happening? Reuven Abliyev wrote: >I using ACCESS & ADO >Database contains some data in Hebrew >connect to DB - OK >getting Recordset - OK >BUT >when I'm trying to load data I've got into COMBOBOX >I'm getting this message: >UnicodeError: ASCII encoding error: ordinal not in range(128) > >How can I solve this > > > > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From romerchat at hotmail.com Thu Jul 24 14:00:09 2003 From: romerchat at hotmail.com (Reuven Abliyev) Date: Thu Jul 24 06:01:05 2003 Subject: [python-win32] Re: UNICODE strings References: <3F1E9C62.9040904@tallan.com> Message-ID: Here the code I'm using: self.__rs.Open ("select CategoryID, CategoryName from Category;", self.__conn, 1) lstCategoryNames=[] while not self.__rs.EOF: lstCategoryNames.append((self.__rs.Fields("CategoryName").Value)) self.__rs.MoveNext() wxStaticText(self, -1, "????", pos=(675,80)) self.cbCategory = wxComboBox(self, wxNewId(), lstCategoryNames[0], wxPoint(450,80), wxSize(220, -1), lstCategoryNames, style=wxCB_READONLY | wxCB_DROPDOWN) Here the FULL error screen Traceback (most recent call last): File "C:\Documents and Settings\Owner\My Documents\Reuven\Lessons\ExamTest.py" , line 213, in ? pnlEditSong(frame, wxNewId()) File "C:\Documents and Settings\Owner\My Documents\Reuven\Lessons\ExamTest.py" , line 67, in __init__ lstCategoryNames, style=wxCB_READONLY | wxCB_DROPDOWN) File "C:\Python22\Lib\site-packages\wxPython\controls.py", line 330, in __init __ self.this = apply(controlsc.new_wxComboBox,_args,_kwargs) TypeError: Unable to convert string 12:58:51: Debug: e:\projects\wx\src\msw\app.cpp(439): 'UnregisterClass(canvas)' failed with error 0x00000584 (class still has open windows.). "Jens B. Jorgensen" wrote in message news:3F1E9C62.9040904@tallan.com... > Your question is unfortunately too vague to tell you how to solve this. > The error you're getting though is occuring because you're somehow > (possibly inadvertently) converting a unicode string (returned from the > recordset) into a "regular" (ascii) string. > > You probably shouldn't be doing the conversion at all since the data > (hebrew) is not encodable in ascii. Since it is unclear how you're doing > what it is your doing though it is hard to tell you how to get the > combobox and not end up doing this ascii conversion. Perhaps you could > post some code as well so we can see what's happening? > > Reuven Abliyev wrote: > > >I using ACCESS & ADO > >Database contains some data in Hebrew > >connect to DB - OK > >getting Recordset - OK > >BUT > >when I'm trying to load data I've got into COMBOBOX > >I'm getting this message: > >UnicodeError: ASCII encoding error: ordinal not in range(128) > > > >How can I solve this > > > > > > > > > >_______________________________________________ > >Python-win32 mailing list > >Python-win32@python.org > >http://mail.python.org/mailman/listinfo/python-win32 > > > > > > -- > Jens B. Jorgensen > jens.jorgensen@tallan.com > > "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From jens.jorgensen at tallan.com Thu Jul 24 11:08:21 2003 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Thu Jul 24 11:08:12 2003 Subject: [python-win32] Re: UNICODE strings In-Reply-To: References: <3F1E9C62.9040904@tallan.com> Message-ID: <3F1FF665.4060008@tallan.com> Thanks Reuven, that's just what we needed. The bad news is that it looks like the error is occurring within the wxWindows code as it is trying to convert that string in some way. You'll need to go talk to the wxWindows folks about this one. Reuven Abliyev wrote: >Here the code I'm using: > >self.__rs.Open ("select CategoryID, CategoryName from Category;", >self.__conn, 1) > lstCategoryNames=[] > while not self.__rs.EOF: > >lstCategoryNames.append((self.__rs.Fields("CategoryName").Value)) > self.__rs.MoveNext() > > wxStaticText(self, -1, "????", pos=(675,80)) > > self.cbCategory = wxComboBox(self, wxNewId(), lstCategoryNames[0], >wxPoint(450,80), wxSize(220, -1), > lstCategoryNames, style=wxCB_READONLY | wxCB_DROPDOWN) > >Here the FULL error screen > >Traceback (most recent call last): > File "C:\Documents and Settings\Owner\My >Documents\Reuven\Lessons\ExamTest.py" >, line 213, in ? > pnlEditSong(frame, wxNewId()) > File "C:\Documents and Settings\Owner\My >Documents\Reuven\Lessons\ExamTest.py" >, line 67, in __init__ > lstCategoryNames, style=wxCB_READONLY | wxCB_DROPDOWN) > File "C:\Python22\Lib\site-packages\wxPython\controls.py", line 330, in >__init >__ > self.this = apply(controlsc.new_wxComboBox,_args,_kwargs) >TypeError: Unable to convert string >12:58:51: Debug: e:\projects\wx\src\msw\app.cpp(439): >'UnregisterClass(canvas)' >failed with error 0x00000584 (class still has open windows.). > > > > >"Jens B. Jorgensen" wrote in message >news:3F1E9C62.9040904@tallan.com... > > >>Your question is unfortunately too vague to tell you how to solve this. >>The error you're getting though is occuring because you're somehow >>(possibly inadvertently) converting a unicode string (returned from the >>recordset) into a "regular" (ascii) string. >> >>You probably shouldn't be doing the conversion at all since the data >>(hebrew) is not encodable in ascii. Since it is unclear how you're doing >>what it is your doing though it is hard to tell you how to get the >>combobox and not end up doing this ascii conversion. Perhaps you could >>post some code as well so we can see what's happening? >> >>Reuven Abliyev wrote: >> >> >> >>>I using ACCESS & ADO >>>Database contains some data in Hebrew >>>connect to DB - OK >>>getting Recordset - OK >>>BUT >>>when I'm trying to load data I've got into COMBOBOX >>>I'm getting this message: >>>UnicodeError: ASCII encoding error: ordinal not in range(128) >>> >>>How can I solve this >>> >>> >>> >>> >>>_______________________________________________ >>>Python-win32 mailing list >>>Python-win32@python.org >>>http://mail.python.org/mailman/listinfo/python-win32 >>> >>> >>> >>> >>-- >>Jens B. Jorgensen >>jens.jorgensen@tallan.com >> >>"With a focused commitment to our clients and our people, we deliver value >> >> >through customized technology solutions" > > > > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" From bgailer at alum.rpi.edu Sun Jul 27 15:15:16 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Sun Jul 27 16:16:44 2003 Subject: [python-win32] how to call an api for which no wrapper is provided Message-ID: <5.2.1.1.0.20030727141358.02d76f10@66.28.54.253> Is there a way to call an api for which no wrapper is provided? I'm needing to use SQLConfigDataSource. Bob Gailer bgailer@alum.rpi.edu 303 442 2625 -------------- next part -------------- --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.500 / Virus Database: 298 - Release Date: 7/10/2003 From bgailer at alum.rpi.edu Sun Jul 27 20:51:00 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Sun Jul 27 21:52:26 2003 Subject: [python-win32] how to call an api for which no wrapper is provided Message-ID: <5.2.1.1.0.20030727195040.02c119d0@66.28.54.253> > Is there a way to call an api for which no wrapper is provided? I'm needing to use SQLConfigDataSource. AMOQ: ctypes Bob Gailer bgailer@alum.rpi.edu 303 442 2625 -------------- next part -------------- --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.500 / Virus Database: 298 - Release Date: 7/10/2003 From parente at cs.unc.edu Mon Jul 28 14:59:12 2003 From: parente at cs.unc.edu (Peter Parente) Date: Mon Jul 28 14:51:35 2003 Subject: [python-win32] Interface from object Message-ID: <001301c35531$f40088a0$49820298@cs.unc.edu> I'm trying to obtain an IMarkupServices interface from an IHTMLDocument object using MSHTML. I have the document object, which has a corresponding class in the code generated by makepy. The IMarkupServices interface does not have a class in the generated python file, but does have a vtables entry. Is there a way to access the IMarkupServices interface? I imagine I have to user QueryInterface on the document object, and provide it with the IID of the markup interface. When I try to do just that, I get an error reporting that the object has no method QueryInterface. Any help would be greatly appreciated. Thanks, Peter Parente -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20030728/115758a0/attachment.htm From janez.jere at void.si Tue Jul 29 11:08:22 2003 From: janez.jere at void.si (Janez Jere) Date: Tue Jul 29 04:08:05 2003 Subject: [python-win32] DispatchWithEvents Message-ID: Hi, I still haven't solved my DispatchWithEvents problem: Sample code, which works when conObj is created with Dispatch. Any suggestions? bellow is error output, and complete source. Janez =========================== if 0: conObj = Dispatch('AdoDB.Connection') else: conObj = DispatchWithEvents('AdoDB.Connection', AdoConnectionEventsLog) conObj.logFile = sys.stdout #conObj.Open('SQLOLEDB.1;Password="";Persist Security Info=True;User ID=sa;Initial Catalog=Northwind;Data Source=myserver') conObj.Open(file("c:/etc/connStr.txt").read()) cmd= Dispatch("ADODB.Command") cmd.ActiveConnection = conObj cmd.CommandText = 'select count(*) from customers ' rs, cnt = cmd.Execute() print 'Cust count:', rs.Fields[0].Value Output when dispatched with events ============================ WillConnect: OnConnectComplete OnWillExecute: select count(*) from customers OnExecuteComplete Traceback (most recent call last): File "C:\cvs\jj\py\ado_events.py", line 38, in ? rs, cnt = cmd.Execute() File "C:\usr\python\lib\site-packages\win32com\gen_py\EF53050B-882E-4776-B643-EDA 472E8E3F2x0x2x7.py", line 1822, in Execute return self._ApplyTypes_(5, 1, (9, 0), ((16396, 18), (16396, 17), (3, 49)), 'Execute', '{00000556-0000-0010-8000-00AA006D2EA4}',RecordsAffected, Parameters, Options) File "C:\usr\python\lib\site-packages\win32com\client\__init__.py", line 445, in _ApplyTypes_ return self._get_good_object_(apply(self._oleobj_.InvokeTypes, (dispid, 0, wFlags, retType, argTypes) + args), user, resultCLSID) pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft OLE DB Provider for SQL Server', 'Command text was not set for the command object.', None, 0, -2147217908), None) Complete code: ============================================================= from win32com.client import Dispatch, gencache, DispatchWithEvents import sys adoTLB=gencache.EnsureModule('{EF53050B-882E-4776-B643-EDA472E8E3F2}', 0, 2, 7) adoRS=gencache.EnsureModule('{00000300-0000-0010-8000-00AA006D2EA4}', 0, 2, 7) class AdoConnectionEventsLog(object): def OnConnectComplete(self, pError, adStatus, pConnection): self.logFile.write(u'OnConnectComplete\n') def OnCommitTransComplete(self, pError, adStatus, pConnection): self.logFile.write(u'OnCommitTransComplete\n') def OnInfoMessage(self, pError, adStatus, pConnection): self.logFile.write(u'OnInfoMessage\n') def OnDisconnect(self, adStatus, pConnection): self.logFile.write(u'OnDisconnect\n') def OnBeginTransComplete(self, TransactionLevel, pError, adStatus, pConnection): self.logFile.write(u'OnBeginTransComplete\n') def OnRollbackTransComplete(self, pError, adStatus, pConnection): self.logFile.write(u'OnRollbackTransComplete\n') def OnExecuteComplete(self, RecordsAffected, pError, adStatus, pCommand, pRecordset, pConnection): self.logFile.write(u'OnExecuteComplete\n') def OnWillExecute(self, Source, CursorType, LockType, Options, adStatus, pCommand, pRecordset, pConnection): self.logFile.write(u'OnWillExecute: %s\n' % Source) def OnWillConnect(self, ConnectionString, UserID, Password, Options, adStatus, pConnection): #self.logFile.write("OnWillConnect UserID: %s")# % UserID) self.logFile.write(u'WillConnect: %s\n' % UserID) if 0: conObj = Dispatch('AdoDB.Connection') else: conObj = DispatchWithEvents('AdoDB.Connection', AdoConnectionEventsLog) conObj.logFile = sys.stdout #conObj.Open('SQLOLEDB.1;Password="";Persist Security Info=True;User ID=sa;Initial Catalog=Northwind;Data Source=myserver') conObj.Open(file("c:/etc/connStr.txt").read()) cmd= Dispatch("ADODB.Command") cmd.ActiveConnection = conObj cmd.CommandText = 'select count(*) from customers ' rs, cnt = cmd.Execute() print 'Cust count:', rs.Fields[0].Value From pf_moore at yahoo.co.uk Tue Jul 29 22:04:14 2003 From: pf_moore at yahoo.co.uk (Paul Moore) Date: Tue Jul 29 16:03:14 2003 Subject: [python-win32] Re: DispatchWithEvents References: Message-ID: "Janez Jere" writes: > Hi, I still haven't solved my DispatchWithEvents problem: > > Sample code, which works when conObj is created with Dispatch. > Any suggestions? bellow is error output, and complete source. No idea really, but when I hashed together a sample DispatchWithEvents test a while ago, I had all of the callback functions' parameters default to pythoncom.Missing - for example: def OnWillExecute(self, Source=pythoncom.Missing, CursorType=pythoncom.Missing, LockType=pythoncom.Missing, Options=pythoncom.Missing, adStatus=pythoncom.Missing, pCommand=pythoncom.Missing, pRecordset=pythoncom.Missing, pConnection=pythoncom.Missing): pass Whether the fact that you don't do this matters (maybe ADO is treating whatever it's passing which *isn't* Missing as an invalid value), I don't know. But maybe it'd be worth putting in the defaults and seeing if that made a difference. All I do recall is that getting ADO events working was tricky. I gave up long before I ever found an application which justified the effort :-) Hope this helps, Paul. -- This signature intentionally left blank From janez.jere at void.si Wed Jul 30 00:33:20 2003 From: janez.jere at void.si (Janez Jere) Date: Tue Jul 29 17:32:52 2003 Subject: [python-win32] Re: DispatchWithEvents In-Reply-To: Message-ID: > > No idea really, but when I hashed together a sample DispatchWithEvents > test a while ago, I had all of the callback functions' parameters > default to pythoncom.Missing - for example: Thanks, but this is not the solution. I thing that callbacks are ok. because in the following example the same update statement works with Execute method on connection, but fails with execute on command. So I think that I am dealing with an issue inside python COM libraries, where object created with Dispatch is talking with object created with DispatchWithEvents. Same functionality is more than trivial in borland c++ builder or delphi, so it must be more than simple in python too. Example: print '-'*30 conObj.Execute("update customers set companyname=companyname where customerid='alfki'") print '-'*30 cmd= Dispatch("ADODB.Command") cmd.ActiveConnection = conObj cmd.CommandText = "update customers set companyname=companyname where customerid='alfki'" rs, cnt = cmd.Execute() Will produce following output: ------------------------------ OnWillExecute: update customers set companyname=companyname where customerid='alfki' OnExecuteComplete ------------------------------ OnWillExecute: update customers set companyname=companyname where customerid='alfki' OnExecuteComplete Traceback (most recent call last): File "C:\cvs\jj\py\ado_events.py", line 42, in ? rs, cnt = cmd.Execute() File "C:\usr\python\lib\site-packages\win32com\gen_py\EF53050B-882E-4776-B643-EDA 472E8E3F2x0x2x7.py", line 1822, in Execute return self._ApplyTypes_(5, 1, (9, 0), ((16396, 18), (16396, 17), (3, 49)), 'Execute', '{00000556-0000-0010-8000-00AA006D2EA4}',RecordsAffected, Parameters, Options) File "C:\usr\python\lib\site-packages\win32com\client\__init__.py", line 445, in _ApplyTypes_ return self._get_good_object_(apply(self._oleobj_.InvokeTypes, (dispid, 0, wFlags, retType, argTypes) + args), user, resultCLSID) pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft OLE DB Provider for SQL Server', 'Command text was not set for the command object.', None, 0, -2147217908), None) From mailings at johnnydebris.net Wed Jul 30 13:15:18 2003 From: mailings at johnnydebris.net (Guido Wesdorp) Date: Wed Jul 30 06:22:01 2003 Subject: [python-win32] COM problems when Python is not in registry Message-ID: <3F279AB6.5090603@johnnydebris.net> Hi there! I'm writing a Windows installer for some application, and now I have some wierd COM problems. My application starts, but at some point it seems to lose the COM connection (resulting in an attribute error on the object returned, does a faulty COM initialization result None or so?). I don't have a clue why it does so, but it seems to happen consistently after a while. The setup I use is somewhat strange, since I don't register any Python stuff to the registry, so also all COM modules and all are loaded through a code snippet (written by Mark Hammond, I think) that imports pywintypes22.dll and pythoncom22.dll using win32api instead of just importing them the usual way (which somehow doesn't work without using the registry). This seems to work okay, since part of the COM calls can be made, but after a while it still freezes (this might be at a point where the import code is called again, may be part of the problem). The code I use to import the dlls is pasted on the bottom of this posting. Does anyone have a clue what the problem can be? Cheers, Guido Wesdorp, Infrae (Holland) Code to import pywintypes22.dll and pythoncom22.dll: ------------------------------------------------------------------------------------------ import win32api, imp def magic_import(modulename, filename): # win32 can find the DLL name. h = win32api.LoadLibrary(filename) found = win32api.GetModuleFileName(h) # Python can load the module mod = imp.load_module(modulename, None, found, ('.dll', 'rb', imp.C_EXTENSION)) # inject it into the global module list. sys.modules[modulename] = mod # And finally inject it into the namespace. globals()[modulename] = mod win32api.FreeLibrary(h) try: import pywintypes except ImportError: magic_import("pywintypes", "pywintypes22.dll") try: import pythoncom except ImportError: magic_import("pythoncom", "pythoncom22.dll") ------------------------------------------------------------------------------------------ Source: http://www.faqts.com/knowledge_base/view.phtml/aid/4408 From kbond at free.fr Wed Jul 30 23:11:12 2003 From: kbond at free.fr (kbond) Date: Wed Jul 30 16:38:39 2003 Subject: [python-win32] How to add a record to a record list?? Message-ID: <3F282660.70204@free.fr> Hello, I am sorry for this long mail but I am completly stuck with the following problem I hope that someone will be able to help me even if my problem is link to a propriatary software. I am trying to translate into python some very basic VB script using an application called SMARTEAM. I getting a pb to add a record to a record list. I think I am missing something but I don't know what here It is an extract of the VB source script: Sub Main() Dim RecList As Object Dim SmRecord As Object Dim SpecRecValArrays() As String Dim HeaderCnt As Integer,i As Integer On Error GoTo ErrorTreat '================================Creating an SmRecordList object=============================== Set RecList = CreateObject("SmRecList.SmRecordList") '================================Filling SmRecordList with headers and values=============================== RecList.AddHeader "First Name",20,sdtchar RecList.AddHeader "Last Name",20,sdtchar RecList.AddHeader "ID",20,sdtchar RecList.AddHeader "Date of birth",8,sdtDate ' Adding first record Values RecList.Value("First Name",0) = "Joe" RecList.Value("Last Name",0) = "Smith" RecList.Value("ID",0) = "2145687-9" RecList.FormattedValueAsString("Date of birth",0,"dd/mm/yyyy") = "23/06/1968" 'Adding second record values RecList.Value("First Name",1) = "Sue" RecList.Value("Last Name",1) = "Ellen" RecList.Value("ID",1) = "7654980-7" RecList.FormattedValueAsString("Date of birth",1,"dd/mm/yyyy") = "12/10/1977" the translation in python give me something like this: import win32com.client #===========================Creating an SmRecordList object===================== recList=win32com.client.Dispatch("SmRecList.SmRecordList") #================Filling SmRecordList with headers and values=================== recList.AddHeader("FirstName", 20, 1) #####my fist problem I do not understand why recList.AddHeader ("Last Name",20,1) ####I cannot give name of the Standard Data recList.AddHeader ("ID",20,7) ####Type but I Have to give the rank of this data type in the enum. #==========================Adding first record Values=========================== #Here is my major problem I cannot a valu to the first Record #Till now I have tried the following syntaxe but none of them was ok ###----1---- recList.Value("FirstName",0,"joe") File "E:\users\install\Python23\Lib\site-packages\wxPython\tools\boa\ExternalLib\PythonInterpreter.py", line 69, in push exec code in self.locals File "", line 1, in ? '''exceptions.TypeError : Value() takes at most 3 arguments (4 given)''' ###----2---- recList.Value("FirstName",1) = "joe" '''exceptions.SyntaxError : can't assign to function call''' ###----3---- recList.Value("FirstName",1)[0] = "joe" File "E:\users\install\Python23\Lib\site-packages\wxPython\tools\boa\ExternalLib\PythonInterpreter.py", line 69, in push exec code in self.locals File "", line 1, in ? '''exceptions.TypeError : object does not support item assignment''' ###----4---- recList.Value("FirstName",1)[1] = "joe" File "E:\users\install\Python23\Lib\site-packages\wxPython\tools\boa\ExternalLib\PythonInterpreter.py", line 69, in push exec code in self.locals File "", line 1, in ? '''exceptions.TypeError : object does not support item assignment''' ###----5---- recList.Value("FirstName")[1] = "joe" File "E:\users\install\Python23\Lib\site-packages\wxPython\tools\boa\ExternalLib\PythonInterpreter.py", line 69, in push exec code in self.locals File "", line 1, in ? File "", line 2, in Value File "E:\users\install\Python23\lib\site-packages\win32com\client\dynamic.py", line 240, in _ApplyTypes_ result = apply(self._oleobj_.InvokeTypes, (dispid, LCID, wFlags, retType, argTypes) + args) '''pywintypes.com_error : (-2147352562, 'Invalid number of parameters.', None, None)''' ###----6---- recList.Value("FirstName",1)[0] = "joe" File "E:\users\install\Python23\Lib\site-packages\wxPython\tools\boa\ExternalLib\PythonInterpreter.py", line 69, in push exec code in self.locals File "", line 1, in ? '''exceptions.TypeError : object does not support item assignment''' ###----7---- >>> recList.Value("FirstName",0)[0] = "joe" File "E:\users\install\Python23\Lib\site-packages\wxPython\tools\boa\ExternalLib\PythonInterpreter.py", line 69, in push exec code in self.locals File "", line 1, in ? '''exceptions.TypeError : object does not support item assignment''' ###----7---- ..... ###----Added explanation---- recList.Value > ###the method exist isn't it Any suggestion are welcom I am running out of idea. If you need more explanation do not hesitate to ask me. From bgailer at alum.rpi.edu Wed Jul 30 16:00:23 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Wed Jul 30 17:01:52 2003 Subject: [python-win32] How to add a record to a record list?? In-Reply-To: <3F282660.70204@free.fr> Message-ID: <5.2.1.1.0.20030730145528.02c47b20@66.28.54.253> At 10:11 PM 7/30/2003 +0200, kbond wrote: >Hello, > >I am sorry for this long mail but I am completly stuck with the following >problem I hope that someone will >be able to help me even if my problem is link to a propriatary software. > >I am trying to translate into python some very basic VB script using an >application called SMARTEAM. >I getting a pb to add a record to a record list. >I think I am missing something but I don't know what > >here It is an extract of the VB source script: > >Sub Main() > Dim RecList As Object > Dim SmRecord As Object > Dim SpecRecValArrays() As String > Dim HeaderCnt As Integer,i As Integer > > > On Error GoTo ErrorTreat >'================================Creating an SmRecordList >object=============================== > Set RecList = CreateObject("SmRecList.SmRecordList") > >'================================Filling SmRecordList with headers and >values=============================== > RecList.AddHeader "First Name",20,sdtchar > RecList.AddHeader "Last Name",20,sdtchar > RecList.AddHeader "ID",20,sdtchar > RecList.AddHeader "Date of birth",8,sdtDate > ' Adding first record Values > RecList.Value("First Name",0) = "Joe" > RecList.Value("Last Name",0) = "Smith" > RecList.Value("ID",0) = "2145687-9" > RecList.FormattedValueAsString("Date of birth",0,"dd/mm/yyyy") = > "23/06/1968" > > 'Adding second record values > RecList.Value("First Name",1) = "Sue" > RecList.Value("Last Name",1) = "Ellen" > RecList.Value("ID",1) = "7654980-7" > RecList.FormattedValueAsString("Date of birth",1,"dd/mm/yyyy") = > "12/10/1977" > >the translation in python give me something like this: > >import win32com.client > >#===========================Creating an SmRecordList >object===================== > >recList=win32com.client.Dispatch("SmRecList.SmRecordList") > >#================Filling SmRecordList with headers and >values=================== >recList.AddHeader("FirstName", 20, 1) #####my fist problem I do not >understand why >recList.AddHeader ("Last Name",20,1) ####I cannot give name of the >Standard Data >recList.AddHeader ("ID",20,7) ####Type but I Have to >give the rank of this data type in the enum. > >#==========================Adding first record >Values=========================== >#Here is my major problem I cannot a valu to the first Record >#Till now I have tried the following syntaxe but none of them was ok >###----1---- >recList.Value("FirstName",0,"joe") > File > "E:\users\install\Python23\Lib\site-packages\wxPython\tools\boa\ExternalLib\PythonInterpreter.py", > line 69, in push > exec code in self.locals > File "", line 1, in ? >'''exceptions.TypeError : Value() takes at most 3 arguments (4 given)''' >###----2---- >recList.Value("FirstName",1) = "joe" >'''exceptions.SyntaxError : can't assign to function call''' In VB () are overloaded; they can mead a function call or an indexing operation. Set RecList = CreateObject("SmRecList.SmRecordList") ' is an example of a function call RecList.Value("First Name",0) = "Joe" ' is an example of indexed assignment In Python indexing and indexed assignment is expressed using [] So try recList.Value["FirstName",1] = "joe" [snip] Bob Gailer bgailer@alum.rpi.edu 303 442 2625 -------------- next part -------------- --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.500 / Virus Database: 298 - Release Date: 7/10/2003 From jeff at ccvcorp.com Wed Jul 30 15:31:13 2003 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed Jul 30 17:30:11 2003 Subject: [python-win32] How to add a record to a record list?? References: <3F282660.70204@free.fr> Message-ID: <3F283921.5070508@ccvcorp.com> kbond wrote: > import win32com.client > > recList=win32com.client.Dispatch("SmRecList.SmRecordList") > > recList.AddHeader("FirstName", 20, 1) #####my fist problem I do not > understand why > recList.AddHeader ("Last Name",20,1) ####I cannot give name of the > Standard Data > recList.AddHeader ("ID",20,7) ####Type but I Have > to give the rank of this data type in the enum. This is because PythonCom cannot automatically get information from a type library, as VB does. You need to run MakePy on your type library (from PythonWin, select "COM MakePy Utility" from the Tools menu, then find the type library for SmRecList). Once you've done that, then PythonCom should understand the constants and enums that are used by the COM object. (MakePy will create a set of Python files in its own subdirectory that will then automatically translate for methods that access that COM object.) There's other subtle benefits to using MakePy, so I'd strongly recommend doing so any time you have a type library available (which should be the case for many, if not most, commercial COM objects). > #==========================Adding first record > Values=========================== > #Here is my major problem I cannot a valu to the first Record > #Till now I have tried the following syntaxe but none of them was ok > ###----1---- > recList.Value("FirstName",0,"joe") > File > "E:\users\install\Python23\Lib\site-packages\wxPython\tools\boa\ExternalLib\PythonInterpreter.py", > line 69, in push > exec code in self.locals > File "", line 1, in ? > '''exceptions.TypeError : Value() takes at most 3 arguments (4 given)''' It looks like VB is treating Value as a property, rather than as a straightforward attribute or method. Python doesn't have properties as such. (Well, new versions of Python are introducing properties on new-style classes, but all of this is much more recent than the PythonCom apparatus, so it's beside the point here.) In order for Python to properly simulate properties and things like in/out parameters, it needs to know the type and purpose of arguments. This is one of the things that MakePy does. So, I *think* that if you run MakePy, this example will work. Jeff Shannon Technician/Programmer Credit International From gelbardn at tripwire.com Wed Jul 30 16:32:52 2003 From: gelbardn at tripwire.com (Nate Gelbard) Date: Wed Jul 30 18:33:26 2003 Subject: [python-win32] monitoring process vm size Message-ID: Hello, I was looking into the win32pdh library but am unsure if it is what I am after. I'm trying to write a python script to monitor the vm size (and perhaps cpu utilization) of a handful of JVMs on Win2k and XP. The MKS toolkit outputs wrong results under XP with the ps command. Is win32pdh what I am after, or is there another interface to the Task Manager? thanks --( Nate Gelbard, QA Engineer --( Tripwire, Inc., The Integrity Assurance Company From tim.golden at viacom-outdoor.co.uk Thu Jul 31 09:42:59 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu Jul 31 03:47:32 2003 Subject: [python-win32] monitoring process vm size Message-ID: > From: Nate Gelbard [mailto:gelbardn@tripwire.com] > I'm trying to write a python script to monitor > the vm size (and perhaps cpu utilization) > of a handful of JVMs on Win2k and XP. > Is win32pdh what I am after, or is there another > interface to the Task Manager? Can't claim to be an expert here, but WMI can give you quite a lot of info about processes. Get hold of the wmi module from http://tgolden.sc.sabren.com/python/wmi.html and try something like the following: import wmi computer = wmi.WMI () for process in computer.Win32_Process (): print process This will list various attributes of all the processes currently running on the local computer. You can specify a remote computer in the WMI constructor, and/or can keep track of when processes are started or stopped or go over a certain limit etc. HTH. TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ From parente at cs.unc.edu Thu Jul 31 13:28:05 2003 From: parente at cs.unc.edu (Peter Parente) Date: Thu Jul 31 12:35:09 2003 Subject: [python-win32] Event return values Message-ID: <3F294395.2090200@cs.unc.edu> Hi, How do return values in COM events work in win32com? I'm handling events for an Internet Explorer WebBrowser control. According to the doc, to prevent events from being handled by the control after my event handler has fired, I must return a variant value of false from the event handler. Is there a way to do this or is the function that called my event handler automatically passing back some default value to the control? Thanks for any help, Pete From Rudy.Schockaert at pandora.be Thu Jul 31 22:02:04 2003 From: Rudy.Schockaert at pandora.be (Rudy Schockaert) Date: Thu Jul 31 15:02:15 2003 Subject: [python-win32] Network configuration change notification Message-ID: <3F2967AC.6040506@pandora.be> Hi, I would like to write a Python application that sits and waits in the background (a service I guess) for changes in my network configuration on my laptop. I want to reconfigure my system depending on the network I'm connected to. I want to change proxy settings map drives, set default printer, ...... I found on MSDN Library that there is a IPHLPAPI.dll taht provides a NotifyAddrChange function. That far I got. Now I should be able to call that function from Python and be notified somehow when my ip-address changes. Any that can point me in the right direction? I was thinking of using ctypes for it but maybe there are easier ways to do this, TIA, Rudy From Jim.Vickroy at noaa.gov Thu Jul 31 14:14:42 2003 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Jul 31 15:14:44 2003 Subject: [python-win32] Network configuration change notification References: <3F2967AC.6040506@pandora.be> Message-ID: <3F296AA1.250C327@noaa.gov> You may wish to investigate "ctypes" which allows you to directly access DLL functions from Python. A relevant link is: http://starship.python.net/crew/theller/ctypes/ Rudy Schockaert wrote: > Hi, > > I would like to write a Python application that sits and waits in the > background (a service I guess) for changes in my network configuration > on my laptop. I want to reconfigure my system depending on the network > I'm connected to. > I want to change proxy settings map drives, set default printer, ...... > I found on MSDN Library that there is a IPHLPAPI.dll taht provides a > NotifyAddrChange function. That far I got. Now I should be able to call > that function from Python and be notified somehow when my ip-address > changes. > > Any that can point me in the right direction? I was thinking of using > ctypes for it but maybe there are easier ways to do this, > > TIA, > > Rudy > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32