From kbond at free.fr Sat Aug 2 12:35:26 2003 From: kbond at free.fr (kbond) Date: Sat Aug 2 10:42:33 2003 Subject: [python-win32] How to add a record to a record list?? In-Reply-To: <3F283921.5070508@ccvcorp.com> References: <3F282660.70204@free.fr> <3F283921.5070508@ccvcorp.com> Message-ID: <3F2B85DE.3080804@free.fr> Hello , Thank you for your tip but unfortunatly I am still stuck with my problem. As you told me I ran MakePy on all the libraries some how related to SMARTEAM including the SmRecList. After few seconds the system told me that it had genrated a file "C85E7012-8B4F-11D1-8E20-00A02498EA3Cx0x1x0.py" I included in this mail some piece of this file if you need the file to help me I can send it to you. Until now I didn't manage to get it working I have the feeling that it is just a problem of syntax. you will find below the command I type in the interpreter the error message and the function in the file generated by makepy. I hope that I provide you all the information you need to help me else please' do not hesitate to ask. Thank you for your help >>> recList.Value["FirstName",0] = "joe" Traceback (most recent call last): File "", line 1, in ? TypeError: object does not support item assignment >>> recList.Value["FirstName",1] = "joe" Traceback (most recent call last): File "", line 1, in ? TypeError: object does not support item assignment # The method SetValue is actually a property, but must be used as a method to correctly pass the arguments def SetValue(self, HeaderName=defaultNamedNotOptArg, arg1=defaultUnnamedArg): """Retrieves, sets or adds a value to the object. Specified by header name.""" return self._oleobj_.InvokeTypes(0, LCID, 4, (24, 0), ((8, 1), (12, 1)),HeaderName, arg1) recList.SetValue("FirstName",0) ="joe" Traceback (SyntaxError: can't assign to function call >>> recList.SetValue["FirstName",0] ="joe" Traceback (most recent call last): File "", line 1, in ? File "E:\users\install\Python23\lib\site-packages\win32com\client\dynamic.py", line 460, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: SmRecList.SmRecordList.SetValue >>> recList.SetValue["FirstName",1] ="joe" Traceback (most recent call last): File "", line 1, in ? File "E:\users\install\Python23\lib\site-packages\win32com\client\dynamic.py", line 460, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: SmRecList.SmRecordList.SetValue # The method SetValueByIndex is actually a property, but must be used as a method to correctly pass the arguments def SetValueByIndex(self, HeaderIndex=defaultNamedNotOptArg, arg1=defaultUnnamedArg): """Retrieves, sets or adds a value to the object. Specified by header index.""" return self._oleobj_.InvokeTypes(2, LCID, 4, (24, 0), ((3, 1), (12, 1)),HeaderIndex, arg1) >>> recList.SetValueByIndex("FirstName", 0) = "joe" Traceback (SyntaxError: can't assign to function call >>> recList.SetValueByIndex("FirstName", 0) = "joe" Traceback (SyntaxError: can't assign to function call >>> recList.SetValueByIndex["FirstName", 0] = "joe" Traceback (most recent call last): File "", line 1, in ? File "E:\users\install\Python23\lib\site-packages\win32com\client\dynamic.py", line 460, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: SmRecList.SmRecordList.SetValueByIndex # The method Value is actually a property, but must be used as a method to correctly pass the arguments def Value(self, HeaderName=defaultNamedNotOptArg): """Retrieves, sets or adds a value to the object. Specified by header name.""" return self._ApplyTypes_(0, 2, (12, 10), ((8, 1),), 'Value', None,HeaderName) >>> recList.Value["joe","FirstName"] Traceback (most recent call last): File "", line 1, in ? TypeError: unsubscriptable object >>> recList.Value["FirstName", "joe"] Traceback (most recent call last): File "", line 1, in ? TypeError: unsubscriptable object >>> recList.Value["FirstName", 0]= "joe" Traceback (most recent call last): File "", line 1, in ? TypeError: object does not support item assignment Jeff Shannon wrote: > 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 pascor at hotpop.com Sat Aug 2 15:50:16 2003 From: pascor at hotpop.com (Ray Pasco) Date: Sat Aug 2 14:50:30 2003 Subject: [python-win32] Close the P2EXE DOS window ? Message-ID: <3F2C07E8.5050604@hotpop.com> I'm making a stand-alone app using p2exe. Is there a way to close the unused DOS window but leave the GUI running ? Or, perhaps, just have it automatically minimized ? Is there a way to tinker with PY2EXE's parameters ? From theller at python.net Sat Aug 2 21:56:50 2003 From: theller at python.net (Thomas Heller) Date: Sat Aug 2 14:57:42 2003 Subject: [python-win32] Re: Close the P2EXE DOS window ? References: <3F2C07E8.5050604@hotpop.com> Message-ID: Ray Pasco writes: > I'm making a stand-alone app using p2exe. Is there a way to close the > unused DOS window but leave the GUI running ? Or, perhaps, just have > it automatically minimized ? Is there a way to tinker with PY2EXE's > parameters ? Build your app with the -w command line flag, or name the script 'myapp.pyw' instead of 'myapp.py', and the dos window will never appear. Thomas From Martin.Moellenbeck at t-online.de Sun Aug 3 10:26:31 2003 From: Martin.Moellenbeck at t-online.de (=?iso-8859-1?Q?Martin_M=F6llenbeck?=) Date: Sun Aug 3 03:26:45 2003 Subject: AW: [python-win32] Close the P2EXE DOS window ? In-Reply-To: <3F2C07E8.5050604@hotpop.com> Message-ID: <000201c35990$8ff49780$0200a8c0@joshua> hi, you must use py2exe with the parameter --windows. regarts Martin > -----Urspr?ngliche Nachricht----- > Von: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org] Im Auftrag von Ray Pasco > Gesendet: Samstag, 2. August 2003 20:50 > An: python-win32@python.org > Betreff: [python-win32] Close the P2EXE DOS window ? > > > I'm making a stand-alone app using p2exe. Is there a way to > close the > unused DOS window > but leave the GUI running ? Or, perhaps, just have it > automatically > minimized ? > Is there a way to tinker with PY2EXE's parameters ? > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python> -win32 > From toxicpulse at sbcglobal.net Sun Aug 3 17:05:55 2003 From: toxicpulse at sbcglobal.net (ryan) Date: Sun Aug 3 19:20:43 2003 Subject: [python-win32] settin wallpaper Message-ID: <001201c35a13$cba67c70$c8e8a540@nbth9wpsmjuio5> the win32 python extentions don't seem to have "SysParametersInfo()" and i need it to set the wallpaper in windows. cyptes has a "SysParametersInfoA()" function but wont let me use the SPI_SETDESKWALLPAPER attribute. anyone have any ideas how i can set the windows wallpaper from a python program? -ryan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20030803/784c4624/attachment.htm From forestiero at qwest.net Sun Aug 3 18:56:13 2003 From: forestiero at qwest.net (DogWalker) Date: Sun Aug 3 20:56:25 2003 Subject: [python-win32] settin wallpaper References: <001201c35a13$cba67c70$c8e8a540@nbth9wpsmjuio5> Message-ID: <005901c35a23$3566f180$93920043@presario> Try this: windll.user32.SystemParametersInfoA(..... You were calling the wrong function. If you just mistyped it in your email, repost with the pertinent code, including the value you used for SPI_SETDESKWALLPAPER and pertinent import statements. HTH ----- Original Message ----- From: ryan To: python-win32@python.org Sent: Sunday, August 03, 2003 4:05 PM Subject: [python-win32] settin wallpaper the win32 python extentions don't seem to have "SysParametersInfo()" and i need it to set the wallpaper in windows. cyptes has a "SysParametersInfoA()" function but wont let me use the SPI_SETDESKWALLPAPER attribute. anyone have any ideas how i can set the windows wallpaper from a python program? -ryan ---------------------------------------------------------------------------- -- _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20030803/99680729/attachment.htm From forestiero at qwest.net Sun Aug 3 19:56:58 2003 From: forestiero at qwest.net (DogWalker) Date: Sun Aug 3 21:57:07 2003 Subject: [python-win32] settin wallpaper References: <001201c35a13$cba67c70$c8e8a540@nbth9wpsmjuio5> <005901c35a23$3566f180$93920043@presario> <001701c35a23$c8586fa0$c8e8a540@nbth9wpsmjuio5> Message-ID: <006c01c35a2b$b1ce80a0$93920043@presario> As the exception says: You must define 'SPI_SETDESKWALLPAPER' . from win32con import SPI_SETDESKWALLPAPER -- or-- from win32con import * -- or -- SPI_SETDESKWALLPAPER = 0x14 -- or -- Use 0x14 or 20 in place of SPI_SETDESKWALLPAPER in the function call HTH ----- Original Message ----- From: ryan To: DogWalker Sent: Sunday, August 03, 2003 6:00 PM Subject: Re: [python-win32] settin wallpaper thats what i was doing, sorry for the typeo.. >>> from ctypes import * >>> windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, 'C:\pics\closeu p.jpg', 0) Traceback (most recent call last): File "", line 1, in ? NameError: name 'SPI_SETDESKWALLPAPER' is not defined ----- Original Message ----- From: DogWalker To: Python-win32@python.org Sent: Sunday, August 03, 2003 5:56 PM Subject: Re: [python-win32] settin wallpaper Try this: windll.user32.SystemParametersInfoA(..... You were calling the wrong function. If you just mistyped it in your email, repost with the pertinent code, including the value you used for SPI_SETDESKWALLPAPER and pertinent import statements. HTH ----- Original Message ----- From: ryan To: python-win32@python.org Sent: Sunday, August 03, 2003 4:05 PM Subject: [python-win32] settin wallpaper the win32 python extentions don't seem to have "SysParametersInfo()" and i need it to set the wallpaper in windows. cyptes has a "SysParametersInfoA()" function but wont let me use the SPI_SETDESKWALLPAPER attribute. anyone have any ideas how i can set the windows wallpaper from a python program? -ryan _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From forestiero at qwest.net Sun Aug 3 22:38:58 2003 From: forestiero at qwest.net (DogWalker) Date: Mon Aug 4 00:39:14 2003 Subject: [python-win32] settin wallpaper Message-ID: <009c01c35a42$53e713a0$93920043@presario> I have no knowledge of the function, never used it. The following is the MSDN documentation on the last parameter, which may be helpful. But you should proceed the string that names the file with an 'r': r'C:\pics\closeup.jpg' or double the backslashes, you are most certainly not getting what you think. You should also check the result: if not windll.user32....: raise WinError() HTH ---------------------------------------------------------------------------- ---- fWinIni [in] If a system parameter is being set, specifies whether the user profile is to be updated, and if so, whether the WM_SETTINGCHANGE message is to be broadcast to all top-level windows to notify them of the change. This parameter can be zero if you don't want to update the user profile or broadcast the WM_SETTINGCHANGE message, or it can be one or more of the following values. Value Action SPIF_UPDATEINIFILE Writes the new system-wide parameter setting to the user profile. SPIF_SENDCHANGE Broadcasts the WM_SETTINGCHANGE message after updating the user profile. SPIF_SENDWININICHANGE Same as SPIF_SENDCHANGE. ---------------------------------------------------------------------------- ---- ----- Original Message ----- From: "ryan" To: "DogWalker" Sent: Sunday, August 03, 2003 7:30 PM Subject: Re: [python-win32] settin wallpaper > is there somethin extra i have to do to make it take affect after i call the > function: > > windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, > 'C:\pics\closeup.jpg', 0) > > because nothin happened after i entered it > > ----- Original Message ----- > From: "DogWalker" > To: > Sent: Sunday, August 03, 2003 6:56 PM > Subject: Re: [python-win32] settin wallpaper > > > > As the exception says: You must define 'SPI_SETDESKWALLPAPER' . > > > > from win32con import SPI_SETDESKWALLPAPER > > > > -- or-- > > > > from win32con import * > > > > -- or -- > > > > SPI_SETDESKWALLPAPER = 0x14 > > > > -- or -- > > > > Use 0x14 or 20 in place of SPI_SETDESKWALLPAPER in the function call > > > > HTH > > > > ----- Original Message ----- > > From: ryan > > To: DogWalker > > Sent: Sunday, August 03, 2003 6:00 PM > > Subject: Re: [python-win32] settin wallpaper > > > > > > thats what i was doing, sorry for the typeo.. > > > > >>> from ctypes import * > > >>> windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, > > 'C:\pics\closeu > > p.jpg', 0) > > Traceback (most recent call last): > > File "", line 1, in ? > > NameError: name 'SPI_SETDESKWALLPAPER' is not defined > > ----- Original Message ----- > > From: DogWalker > > To: Python-win32@python.org > > Sent: Sunday, August 03, 2003 5:56 PM > > Subject: Re: [python-win32] settin wallpaper > > > > > > Try this: > > > > windll.user32.SystemParametersInfoA(..... > > > > You were calling the wrong function. If you just mistyped it in your > email, > > repost with the pertinent code, including the value you used for > > SPI_SETDESKWALLPAPER and pertinent import statements. > > > > HTH > > ----- Original Message ----- > > From: ryan > > To: python-win32@python.org > > Sent: Sunday, August 03, 2003 4:05 PM > > Subject: [python-win32] settin wallpaper > > > > > > the win32 python extentions don't seem to have "SysParametersInfo()" and i > > need it to set the wallpaper in windows. > > > > cyptes has a "SysParametersInfoA()" function but wont let me use the > > SPI_SETDESKWALLPAPER attribute. > > > > anyone have any ideas how i can set the windows wallpaper from a python > > program? > > > > -ryan > > > > > > > > _______________________________________________ > > Python-win32 mailing list > > Python-win32@python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > > > > > _______________________________________________ > > Python-win32 mailing list > > Python-win32@python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > > > > > _______________________________________________ > > Python-win32 mailing list > > Python-win32@python.org > > http://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20030803/0ea1b701/attachment.htm From null-python-win32 at tinfoilhat.ca Mon Aug 4 00:39:11 2003 From: null-python-win32 at tinfoilhat.ca (null-python-win32@tinfoilhat.ca) Date: Mon Aug 4 00:59:55 2003 Subject: [python-win32] PDC vs VLAN cage match. Message-ID: I'm still having little luck enumerating across VLANs. Though the following bit of code was suggested by Mr. Harks did help: >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 Any sources for documenatation on this? Specifically the ADsNameSpaces stuff? This is a pretty different approach than using WMI, maybe it's the same thing though I'm not qualified to tell. As far as win32sdk stuff is concerned I'm jumping into that pool without checking if it has water in it first. It is extremly interesting though the lack of descriptive documentation is a bit troubling. I'm sure this documentation exists though I'm having a hard time finding it. I could really use some book or site suggestions. -- 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 richard.philips at ua.ac.be Mon Aug 4 11:20:56 2003 From: richard.philips at ua.ac.be (Richard Philips) Date: Mon Aug 4 12:55:11 2003 Subject: [python-win32] Getting the associated icon of a file type Message-ID: <3F2E1768.9070604@ua.ac.be> Hello all, How can I retrieve the associated icon of a file type ? I tried the following: def getDefaultIcon(filename): '''Retrieve the default icon of a filename''' (root, extension) = os.path.splitext(filename) if extension: value_name = _winreg.QueryValue(_winreg.HKEY_CLASSES_ROOT, extension) try: value_name = _winreg.QueryValue(_winreg.HKEY_CLASSES_ROOT, extension) except _winreg.error: value_name = None else: value_name = None if value_name: try: icon = _winreg.QueryValue(_winreg.HKEY_CLASSES_ROOT, value_name + "\\DefaultIcon") except _winreg.error: icon = None else: icon = None return icon if __name__ == "__main__": print getDefaultIcon("icon.html") print getDefaultIcon("icon.py") This works fine. The result is: 1) None 2) *.ico file (e.g. D:\Python\Py.ico) 3) *.dll, *.exe 4) "%1" (e.g. .html -> "%1") 1) and 2) are ok for me. 3) and 4) pose problems. Any help on this issue would be helpful. Thanks, Richard -- ================================================================ Dr. Richard PHILIPS University of Antwerp Systemmanager Anet Phone: +32 3 820.21.53 Fax: +32 3 820.21.59 GSM: 0478/36.76.28 Email: Richard.Philips@ua.ac.be ================================================================ From jeff at ccvcorp.com Mon Aug 4 10:56:28 2003 From: jeff at ccvcorp.com (Jeff Shannon) Date: Mon Aug 4 12:55:31 2003 Subject: [python-win32] How to add a record to a record list?? References: <3F282660.70204@free.fr> <3F283921.5070508@ccvcorp.com> <3F2B85DE.3080804@free.fr> Message-ID: <3F2E903C.80909@ccvcorp.com> kbond wrote: > # The method Value is actually a property, but must be used as > a method to correctly pass the arguments > def Value(self, HeaderName=defaultNamedNotOptArg): > """Retrieves, sets or adds a value to the object. > Specified by header name.""" > return self._ApplyTypes_(0, 2, (12, 10), ((8, 1),), > 'Value', None,HeaderName) > > >>> recList.Value["joe","FirstName"] > Traceback (most recent call last): > File "", line 1, in ? > TypeError: unsubscriptable object > >>> recList.Value["FirstName", "joe"] > Traceback (most recent call last): > File "", line 1, in ? > TypeError: unsubscriptable object > >>> recList.Value["FirstName", 0]= "joe" > Traceback (most recent call last): > File "", line 1, in ? > TypeError: object does not support item assignment I'm not sure what the API for this recordlist is, so it's hard for me to say just what the appropriate syntax is here, but here's a few ideas to (hopefully) help you figure it out. These properties all say they must be used as a method. That means you'll need to use parentheses rather than square brackets. Also, as you've seen, you cannot assign to the result of a method call, i.e. 'recList.Value(...) = name' is an error. In order to provide the value that you want to set the field to, you'll have to include that as a parameter in the method call -- that is, "joe" needs to be inside the parentheses. Thus, I believe that you'll need to use something along the lines of one of these: reclist.Value("FirstName", "joe") reclist.Value("FirstName", 0, "joe") Hope that helps... Jeff Shannon Technician/Programmer Credit International From python-win32 at netchan.cotse.net Mon Aug 4 16:48:04 2003 From: python-win32 at netchan.cotse.net (python-win32@netchan.cotse.net) Date: Mon Aug 4 16:49:09 2003 Subject: [python-win32] New IE instance instead of reusing an existing one Message-ID: <001e01c35ac9$c1b07840$94873b81@gyogyi> The following snippet creates only one instance of IE. Why? ------------------------------------------------------------- ie1 = win32com.client.Dispatch("InternetExplorer.Application") ie1.Visible = 1 ie2 = win32com.client.Dispatch("InternetExplorer.Application") ie2.Visible = 1 ------------------------------------------------------------- How can I force Dispatch to create a new instance? Thanks, Sandor From python-win32 at netchan.cotse.net Mon Aug 4 18:13:03 2003 From: python-win32 at netchan.cotse.net (python-win32@netchan.cotse.net) Date: Mon Aug 4 18:13:48 2003 Subject: [python-win32] New IE instance instead of reusing an existing one In-Reply-To: <001e01c35ac9$c1b07840$94873b81@gyogyi> Message-ID: <002a01c35ad5$948ba720$94873b81@gyogyi> For the archives: Using DispatchEx instead of Dispatch solves the problem Sandor > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org] On Behalf Of > python-win32@netchan.cotse.net > Sent: Monday, August 04, 2003 3:48 PM > To: python-win32@python.org > Subject: [python-win32] New IE instance instead of reusing an > existing one > > > The following snippet creates only one instance of IE. Why? > > ------------------------------------------------------------- > ie1 = win32com.client.Dispatch("InternetExplorer.Application") > ie1.Visible = 1 > > ie2 = win32com.client.Dispatch("InternetExplorer.Application") > ie2.Visible = 1 > ------------------------------------------------------------- > > How can I force Dispatch to create a new instance? > > Thanks, > Sandor > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > From dave at psys.org Mon Aug 4 18:55:23 2003 From: dave at psys.org (d.w. harks) Date: Mon Aug 4 18:55:27 2003 Subject: [python-win32] PDC vs VLAN cage match. In-Reply-To: References: Message-ID: <20030804225523.GA11972@psys.org> With carefully-arranged electrons, null-python-win32@tinfoilhat.ca wrote: > I'm still having little luck enumerating across VLANs. > Though the following bit of code was suggested by Mr. Harks did help: > > >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 > > Any sources for documenatation on this? Specifically the ADsNameSpaces > stuff? This is a pretty different approach than using WMI, maybe it's the > same thing though I'm not qualified to tell. > > As far as win32sdk stuff is concerned I'm jumping into that pool without > checking if it has water in it first. It is extremly interesting though > the lack of descriptive documentation is a bit troubling. > > I'm sure this documentation exists though I'm having a hard time finding it. > I could really use some book or site suggestions. > > -- > Sean > You'll find that after the win32com.client.Dispatch() call, nearly every single line of that code is almost identical to the VBScript or Visual Basic code found on MSDN or in an ADSI programming book. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/adsi/active_directory_service_interfaces_adsi.asp?frame=true --the home for ADSI coders http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdir/adsi/adsi_objects_of_winnt.asp --Objects of the WinNT provider Essentially, you won't find Pythonic documentation; you'll have to translate the VB, VBScript, or C++ -- but that's fairly trivial, once you get the hang of it. Good luck! dave -- David W. Harks http://dwblog.psys.org From janez.jere at void.si Tue Aug 5 02:44:37 2003 From: janez.jere at void.si (Janez Jere) Date: Mon Aug 4 19:44:17 2003 Subject: [python-win32] dispatch tuple Message-ID: Hello pycom wizards! is it posible to write such an object that its method will return a tuple to it caller. In my case ideal output (x) would be x == (1234, 4321) import win32com.server.util, win32com.client class C: _public_methods_ = ['foo'] _com_interfaces_ = [] def foo(self): return (1234,4321) ow = win32com.server.util.wrap(C() ) o = win32com.client.Dispatch(ow) x = o.foo() print 'type', type(x) print x ============= output: type 1234 Janez From Paul.Moore at atosorigin.com Tue Aug 5 17:34:57 2003 From: Paul.Moore at atosorigin.com (Moore, Paul) Date: Tue Aug 5 11:36:11 2003 Subject: [python-win32] How do I control Windows Media Player from Python? Message-ID: <16E1010E4581B049ABC51D4975CEDB8802C09689@UKDCX001.uk.int.atosorigin.com> I'd like to be able to connect to Windows Media Player from Python. As my first (simple) example, I'd like to get the name of the currently playing track, which seems to be as easy as name = Player.currentMedia.name but - and here's the problem - I need Player to be a Dispatch object pointing to the (currently running) Windows Media Player instance. No matter how I try, I can't get this step. I can find nothing in the MSDN documentation (which spends most of its time explaining how to embed media in a web page...) Can anyone help? Thanks, Paul Moore From toxicpulse at sbcglobal.net Wed Aug 6 17:43:49 2003 From: toxicpulse at sbcglobal.net (ryan) Date: Wed Aug 6 19:48:45 2003 Subject: [python-win32] os.system problem Message-ID: <004d01c35c74$96844b40$4beaa540@nbth9wpsmjuio5> how do you properly quote an os.system() call so i can load a file on a command line argument. i have tried: os.system('C:\\"foo bar"\\some.exe %s' % filename) but for some reason thats only loading some.exe, but not on filename -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20030806/fdd22d88/attachment.htm From david at graniteweb.com Wed Aug 6 23:19:06 2003 From: david at graniteweb.com (David Rock) Date: Thu Aug 7 00:41:27 2003 Subject: [python-win32] os.system problem In-Reply-To: <004d01c35c74$96844b40$4beaa540@nbth9wpsmjuio5> References: <004d01c35c74$96844b40$4beaa540@nbth9wpsmjuio5> Message-ID: <20030807031906.GA26518@wdfs.graniteweb.com> * ryan [2003-08-06 16:43]: > how do you properly quote an os.system() call so i can load a file on a command line argument. i have tried: > > os.system('C:\\"foo bar"\\some.exe %s' % filename) > > but for some reason thats only loading some.exe, but not on filename I usually do something like this: command = 'C:\\"foo bar"\\some.exe %s' % filename os.system( command ) -- David Rock david@graniteweb.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 232 bytes Desc: not available Url : http://mail.python.org/pipermail/python-win32/attachments/20030806/34f1ca74/attachment.bin From mailings at johnnydebris.net Thu Aug 7 11:47:28 2003 From: mailings at johnnydebris.net (Guido Wesdorp) Date: Thu Aug 7 04:55:17 2003 Subject: [python-win32] os.system problem In-Reply-To: <004d01c35c74$96844b40$4beaa540@nbth9wpsmjuio5> References: <004d01c35c74$96844b40$4beaa540@nbth9wpsmjuio5> Message-ID: <3F321220.4040105@johnnydebris.net> ryan wrote: > os.system('C:\\"foo bar"\\some.exe %s' % filename) I think you need to place the double quotes around the full path (I prepended the string with an 'r' so the backslashes don't have to be escaped): os.system(r'"c:\foo bar\some.exe" %s' % filename) should work afaik. Cheers, Guido From henning.i.fagge at ericsson.com Thu Aug 7 16:00:09 2003 From: henning.i.fagge at ericsson.com (Henning Fagge I (GR/ETO)) Date: Thu Aug 7 11:03:05 2003 Subject: [python-win32] How to catch events from nested com objects Message-ID: <6F936E2F8E16234BA8D88B2EE833833203906EDF@esealnt912.al.sw.ericsson.se> I have program where I dispatch a server with the command: object=DispatchWithEvents("DebugMuxSrv.DebugMux",IDebugMuxEvents) When I connect equipment to my PC I can se that the events specified in IDebugMuxEvents are called. >From object I can get all connected target and dataproviders: for Target in object.Targets: #Within each target there could be severeal Dataproviders for DataProvider in Target.DataProvider: #HOW should i catch events provided by DataProvider #Is it possible to: DispatchWithEvent(DataProvider,IDataProvidersEvents) The problems is that when the dataproviders has some data for me they generate the event 'OnDataAvailable', but how should I connect the class IDataProviderEvents to the DataProvider object. I have the solution for this written i C, but I don't know how to do it in python: BOOL CComThread::ConnectToServer ( IDataProvider* pDataProvider ) { HRESULT hr = E_FAIL; BOOL bRet = FALSE; if ( pDataProvider != NULL ) { LPUNKNOWN lpUnk = NULL; m_pSink = new CDataProviderSink ( m_hWndEditBox, m_hWndChildFrame ); hr = pDataProvider->QueryInterface ( IID_IDispatch, (LPVOID*)&m_pobjDispatch ); if ( SUCCEEDED ( hr ) ) { if ( m_pSink != NULL ) { lpUnk = m_pSink->GetIDispatch ( FALSE ); if ( lpUnk != NULL ) { if ( AfxConnectionAdvise ( m_pobjDispatch, DIID__IDataProviderEvents, lpUnk, FALSE, &m_dwCookie ) ) { m_bIsConnected = TRUE; bRet = TRUE; DBGOUT ( 2, _T("DataProviderEvents up'n running.") ); } else DBGOUT ( 2, _T("FAILED to setup the DataProviderEvents.") ); } } } } return bRet; } ****************************************'* Full print of program: ****************************************** from win32com.client import DispatchWithEvents, Dispatch,getevents,WithEvents import msvcrt, pythoncom import time, sys import types import threading import gendbgmux defaultNamedOptArg=pythoncom.Empty defaultNamedNotOptArg=pythoncom.Empty defaultUnnamedArg=pythoncom.Empty class IDataProviderEvents: def __init__(self): print 80*"I" 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" connected=0 IDB=None print "Starting DBGMux" object=DispatchWithEvents("DebugMuxSrv.DebugMux",IDebugMuxEvents) start=time.time() while (time.time()-start)<10: time.sleep(2) pythoncom.PumpWaitingMessages() for Target in object.Targets: 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(): IDB=DataProvider print "Connect SUCCESS" connected=1 else: print "Connect FAILED" connected=0 if connected: packet=Dispatch("DebugMuxSrv.DataPacket.1") print "Sending dir command, which should cause a event(OnDataAvailable)" packet.Data="dir\n" IDB.Send(packet) if connected: print "Disconnected to server" IDB.Disconnect() print "Exit timeout" From coxchen at nature.ee.ncku.edu.tw Fri Aug 8 15:45:38 2003 From: coxchen at nature.ee.ncku.edu.tw (Cox Chen) Date: Fri Aug 8 02:44:48 2003 Subject: [python-win32] How to print a PDF file? Message-ID: <20030808143218.36BC.COXCHEN@nature.ee.ncku.edu.tw> I'd like to print a PDF file without manipulating Acrobat Reader. So, I decide to accomplish this through "Acrobat Control for ActiveX". Here is my code snippet, #-------- >>> from win32com.client import Dispatch >>> pdf = Dispatch('PDF.PdfCtrl.5') >>> pdf >>> pdf.LoadFile('c:\\test.pdf') Traceback (most recent call last): File "", line 1, in ? File "win32com\gen_py\CA8A9783-280D-11CF-A24D-444553540000x0x1x3.py", line 35, in LoadFile return self._oleobj_.InvokeTypes(2, LCID, 1, (11, 0), ((8, 0),),fileName) com_error: (-2147418113, '\xa8a\xc3\xf8\xa9\xca\xaa\xba\xa5\xa2\xb1\xd1', None, None) When opening the PDF file, I got above error message. Is there any missing part that I should complete before loading PDF file ? Can anyone help? Thanks! -Cox Chen From paul at prescod.net Fri Aug 8 15:03:29 2003 From: paul at prescod.net (Paul Prescod) Date: Fri Aug 8 17:04:07 2003 Subject: [python-win32] Py2exe, Active-X and CAB Message-ID: <3F341021.3080809@prescod.net> Has anyone made a Web-downloadable, CAB-compressed Active-X using py2exe? I'm trying to use py2exe and cabarac to build an Active-X and am having trouble getting the browser to recognize it and register it. I believe that this is due to the fact that Python loads pythoncom.dll (and pyds?) using LoadLibrary instead of statically referring to them. The problem is that regsvr32 tries to load our someobject.dll and the someobject.dll doesn't know how to find the library it depends upon because (I'm told) LoadLibrary isn't smart enough to use the DLL as the base for library searches. Any ideas? Paul Prescod From theller at python.net Sat Aug 9 01:12:50 2003 From: theller at python.net (Thomas Heller) Date: Fri Aug 8 18:13:06 2003 Subject: [python-win32] Re: Py2exe, Active-X and CAB References: <3F341021.3080809@prescod.net> Message-ID: <1xvvx0gt.fsf@python.net> Paul Prescod writes: > Has anyone made a Web-downloadable, CAB-compressed Active-X using py2exe? > > I'm trying to use py2exe and cabarac to build an Active-X and am > having trouble getting the browser to recognize it and register it. I > believe that this is due to the fact that Python loads pythoncom.dll > (and pyds?) using LoadLibrary instead of statically referring to > them. The problem is that regsvr32 tries to load our someobject.dll > and the someobject.dll doesn't know how to find the library it depends > upon because (I'm told) LoadLibrary isn't smart enough to use the DLL > as the base for library searches. > > Any ideas? Install pythoncomxx.dll on the path somewhere. Is this possible for a cab? (Although I'm not sure py2exe can currently handle this, but it could be fixed.) Isn't this also the readson that it lives in the system directory even in the normal win32all distribution? Thomas From toxicpulse at sbcglobal.net Sat Aug 9 00:33:08 2003 From: toxicpulse at sbcglobal.net (ryan) Date: Sat Aug 9 02:36:11 2003 Subject: [python-win32] py2exe probs Message-ID: <008c01c35e40$19d0fb70$0dbd7643@nbth9wpsmjuio5> hi, ive always used py2exe and its worked for me but recently i made additions to my code and upgraded to python 2.3, pygame 2.3 and py2exe for python 2.3 and i get this error when i run the exe of my program, but never when i just run the source: Pygame Parachute Traceback: File "res.pyc", line 107, in command_show_res_modes Fatal Python error: (pygame parachute) Segmentation Fault I have no idea why its doin this, i added the use of "PIL" and "ctypes" to my code so either one or both of those are conflicting with py2exe, or py2exe for python 2.3 is buggy, i can't put my finger on it, anyone have any idea? -ryan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20030808/904e8872/attachment.htm From coxchen at nature.ee.ncku.edu.tw Tue Aug 12 22:16:23 2003 From: coxchen at nature.ee.ncku.edu.tw (Cox Chen) Date: Tue Aug 12 09:16:06 2003 Subject: [python-win32] How to print a PDF file? In-Reply-To: References: <20030808143218.36BC.COXCHEN@nature.ee.ncku.edu.tw> Message-ID: <20030812205610.B20E.COXCHEN@nature.ee.ncku.edu.tw> I found a solution to my problem. Though it's tedious and not so transparent, it is acceptable now. :-( >>> from win32com.client import Dispatch >>> ie = Dispatch('InternetExplorer.Application') >>> ie.Visible = 1 >>> ie.Navigate2('c:\\dscV1.pdf') >>> pdfViewer = ie.Document.embeds[0] >>> pdfViewer.Print() If the Acrobat Reader is installed correctly, when using IE navigating to target PDF file, an embeded object, instance of Acrobat Control for ActiveX, is instantiated to display that PDF file. ie.Document.embeds returns a set of COMObjects embeded in a HTML Document. Here, the first (only) embeding COMObject is the instance of Acrobat Control for ActiveX. Check http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie40/html/msdn_lassesen.asp for further information about HTML Document. I'm curious that is it possible to create a blank window and embed into an COMObject, just as Acrobat Control for ActiveX is embedded in Internet Explorer ? -Cox Chen From gelbardn at tripwire.com Wed Aug 13 16:43:37 2003 From: gelbardn at tripwire.com (Nate Gelbard) Date: Wed Aug 13 18:43:45 2003 Subject: [python-win32] getting a remote file Message-ID: Hi, Using WMI, how can I get the contents of a remote file? I need to harvest a text file containing a version string and return the contents over WMI. Any suggestions? --( Nate Gelbard, QA Engineer --( Tripwire, Inc., The Integrity Assurance Company From zopedope at optonline.net Fri Aug 22 11:39:14 2003 From: zopedope at optonline.net (Bentzion Schochet) Date: Fri Aug 22 18:20:08 2003 Subject: [python-win32] Explorer Bar in Python? In-Reply-To: <000401c366aa$1a934b40$6401a8c0@BensLaptop> Message-ID: <001b01c368bb$298c27d0$6401a8c0@BensLaptop> I would like to know if it is possible to implement an Explorer Bar in python. Has anyone done this? I see from SpamBayes that AddIns to Outlook are doable and was hoping someone could point me in the right direction to do something similar for ExplorerBars. I have read that there might be some problems implementing some interfaces with pythoncom. The explorer bar need to implement the following interfaces IClassFactory, IDeskBand, IObjectWithSite and IPersistStream. For starters I'd just like to know if it is even possible to create one with just Python, additionally if anyone has done this I would appreciate any sample code. Thanks in advance, Ben From lehmanap at cs.purdue.edu Fri Aug 22 13:58:55 2003 From: lehmanap at cs.purdue.edu (Aaron Patrick Lehmann) Date: Sat Aug 23 06:53:44 2003 Subject: [python-win32] Accessing another user's Exchange Calendar Message-ID: <20030822175855.GA16996@lore.cs.purdue.edu> Hello-- I'm trying to write a service that will log in as one user, and then set and cancel appointments from other users that it is authorized to change. I've managed to do this by allowing the program to log on to exchange as those users, but I am worried that that might present a security risk. Is there a way to programmatically access Calendar folders as a delegate, and so make an electronic "secretary"? Failing that, is there a way to make use of standard permissions to achieve this? I know it is possible in outlook, but I've been unable to find the proper methods to do it from python. Thanks in advance, Aaron Lehmann -- Old hold for new construction. --Gene Ray www.timecube.com From cq at htec.demon.co.uk Thu Aug 21 13:21:57 2003 From: cq at htec.demon.co.uk (Christopher Quinn) Date: Sat Aug 23 09:50:24 2003 Subject: [python-win32] excel access... Message-ID: <3F44AB55.2070003@htec.demon.co.uk> hello list. i'm making a first foray into the windows world and using pythonCOM to access fields of an excel spreadsheet. all seemed ok till i inquired the value of a cell containing a function which retrieved in turn it's value over DDE from another application (a stock price feed). i opened the spreadsheet with the update option set and so expected excel to deliver a real result. unfortunately it returns -2146826259 every time. my question then is: should i be doing something other than Cells(x,y).Value to extract the data at some instant? i suspect i perhaps cannot use the COM interface to do what i want... -- thanks. - chris From zopedope at optonline.net Sat Aug 23 22:48:29 2003 From: zopedope at optonline.net (Bentzion Schochet) Date: Sun Aug 24 08:20:30 2003 Subject: [python-win32] Explorer Bar in Python? In-Reply-To: Message-ID: <001c01c369e1$d3101330$6401a8c0@BensLaptop> Which one? I have looked through all of them and could use just a bit more help. Thanks -----Original Message----- From: Keith J. Farmer [mailto:kfarmer@thuban.org] Sent: Friday, August 22, 2003 8:31 PM To: Bentzion Schochet; python-win32@python.org Subject: RE: [python-win32] Explorer Bar in Python? If you look through the demos section of the win32all installation, you'll find exactly this. -----Original Message----- From: Bentzion Schochet [mailto:zopedope@optonline.net] Sent: Fri 8/22/2003 7:39 AM I would like to know if it is possible to implement an Explorer Bar in python. Has anyone done this? From lj440 at yahoo.com Sat Aug 23 16:02:27 2003 From: lj440 at yahoo.com (Lynn Jennin) Date: Sun Aug 24 11:59:19 2003 Subject: [python-win32] Missing python23.dll, trying again Message-ID: <20030823220227.70426.qmail@web20420.mail.yahoo.com> After installing python, using Python-2.3.exe, the install log shows: .. File Copy: C:\Python23\libs\python23.lib | 07-29-2003 | 18:54:36 | | 178732 | 2582a307 Non-System File: File Copy: C:\WINDOWS\system32\python23.dll | 07-29-2003 | 18:54:34 | 2.3.150.1012 | 974900 | 102acdeb Made Dir: C:\Python23\Lib File Copy: C:\Python23\Lib\BaseHTTPServer.py | 06-03-2003 | 20:23:48 | | 21948 | dc524b55 .. But after 2 installs, I still can't find python23.dll. Is there a way to just get this DLL file? Thanks! --------------------------------- Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20030823/a7779064/attachment.htm From kfarmer at thuban.org Fri Aug 22 19:31:18 2003 From: kfarmer at thuban.org (Keith J. Farmer) Date: Sun Aug 24 12:58:35 2003 Subject: [python-win32] Explorer Bar in Python? Message-ID: If you look through the demos section of the win32all installation, you'll find exactly this. -----Original Message----- From: Bentzion Schochet [mailto:zopedope@optonline.net] Sent: Fri 8/22/2003 7:39 AM I would like to know if it is possible to implement an Explorer Bar in python. Has anyone done this? From kfarmer at thuban.org Sun Aug 24 13:29:45 2003 From: kfarmer at thuban.org (Keith J. Farmer) Date: Sun Aug 24 16:17:14 2003 Subject: [python-win32] Explorer Bar in Python? Message-ID: Well, it *used* to be there. I'd suggestion asking Mark Hammond. I think he wrote the one I saw. ---------- Keith J. Farmer kfarmer@thuban.org http://www.thuban.org -----Original Message----- From: Bentzion Schochet [mailto:zopedope@optonline.net] Sent: Saturday, August 23, 2003 18:48 Which one? I have looked through all of them and could use just a bit more help. From null-python-win32 at tinfoilhat.ca Fri Aug 22 12:11:15 2003 From: null-python-win32 at tinfoilhat.ca (Sean) Date: Sun Aug 24 18:45:53 2003 Subject: [python-win32] Ping? Message-ID: Does anyone know of an ping module that will work with Windows? I'm currently using os.popen("ping -n1 host") but it's terribly slow when using it a few hundred times. After enumerating my domain of machines I'm trying to ping them to determine if they are active before connecting to them via WMI (which takes forever to timeout). -- Sean From jeff at ccvcorp.com Mon Aug 25 11:54:39 2003 From: jeff at ccvcorp.com (Jeff Shannon) Date: Mon Aug 25 14:38:44 2003 Subject: [python-win32] excel access... References: <3F44AB55.2070003@htec.demon.co.uk> Message-ID: <3F4A4D5F.7040207@ccvcorp.com> Christopher Quinn wrote: > hello list. > > i'm making a first foray into the windows world and using pythonCOM to > access fields of an excel spreadsheet. > all seemed ok till i inquired the value of a cell containing a function > which retrieved in turn it's value over DDE from another application (a > stock price feed). > i opened the spreadsheet with the update option set and so expected > excel to deliver a real result. unfortunately it returns -2146826259 > every time. > my question then is: should i be doing something other than > Cells(x,y).Value to extract the data at some instant? It's been quite some time since I really looked at this, and I never did get around to actually working on automating the use of functions, but I believe that Excel uses a field other than Value to store functions. I suspect that, for cells containing functions, the Value will always be irrelevant. You'll have to look in the VBA docs included in Excel to determine the function attribute name; I believe that there's also a way to prod the COM server into calling that function for you and returning a result. Jeff Shannon Technician/Programmer Credit International From wolf at circle-cross.org Mon Aug 25 13:41:37 2003 From: wolf at circle-cross.org (Wolf Logan) Date: Mon Aug 25 15:51:31 2003 Subject: [python-win32] Ping? References: Message-ID: <049701c36b40$e5def8e0$04bc7f43@circlecross.home> here's the one I use on win2K: http://www.python.org/~jeremy/python.html ----- Original Message ----- From: "Sean" Sent: Friday, August 22, 2003 9:11 AM > Does anyone know of an ping module that will work with Windows? > > I'm currently using os.popen("ping -n1 host") but it's terribly slow when > using it a few hundred times. > > After enumerating my domain of machines I'm trying to ping them to > determine if they are active before connecting to them via WMI (which > takes forever to timeout). From Eric.Rasmussen at ATK.com Mon Aug 25 14:01:03 2003 From: Eric.Rasmussen at ATK.com (Rasmussen, Eric (I.S.)) Date: Mon Aug 25 15:54:06 2003 Subject: [python-win32] Profiling in Dev Studio Message-ID: We have about 300 Python script test cases for our C++/MFC application. Due to the nature of Python, we can run all 300 scripts with one command and check to see that they ran successfully. Is there any way to implement the Dev Studio Profiler from Python so that we can test for line/function coverage? Eric Rasmussen 435-863-5482 From cq at htec.demon.co.uk Tue Aug 26 02:01:18 2003 From: cq at htec.demon.co.uk (Christopher Quinn) Date: Mon Aug 25 20:01:38 2003 Subject: [python-win32] excel access... In-Reply-To: <3F4A4D5F.7040207@ccvcorp.com> References: <3F44AB55.2070003@htec.demon.co.uk> <3F4A4D5F.7040207@ccvcorp.com> Message-ID: <3F4AA34E.1070304@htec.demon.co.uk> thanks folks. i stumbled upon ActiveWorkbook.OpenLinks() which allows .Value's to provide data proper. cheers, chris Jeff Shannon wrote: > Christopher Quinn wrote: > >> hello list. >> >> i'm making a first foray into the windows world and using pythonCOM to >> access fields of an excel spreadsheet. >> all seemed ok till i inquired the value of a cell containing a >> function which retrieved in turn it's value over DDE from another >> application (a stock price feed). >> i opened the spreadsheet with the update option set and so expected >> excel to deliver a real result. unfortunately it returns -2146826259 >> every time. >> my question then is: should i be doing something other than >> Cells(x,y).Value to extract the data at some instant? > > > It's been quite some time since I really looked at this, and I never did > get around to actually working on automating the use of functions, but I > believe that Excel uses a field other than Value to store functions. I > suspect that, for cells containing functions, the Value will always be > irrelevant. You'll have to look in the VBA docs included in Excel to > determine the function attribute name; I believe that there's also a way > to prod the COM server into calling that function for you and returning > a result. > > Jeff Shannon > Technician/Programmer > Credit International > > -- thanks. - chris From tim.golden at viacom-outdoor.co.uk Tue Aug 26 15:29:58 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Tue Aug 26 09:35:21 2003 Subject: [python-win32] getting a remote file Message-ID: From: Nate Gelbard [mailto:gelbardn@tripwire.com] > Using WMI, how can I get the contents of a remote file? > I need to harvest a text file containing a version string > and return the contents over WMI. Any suggestions? I don't think there's a terribly easy answer to this: WMI isn't a file transfer protocol, and while you could use the Copy method of a CIM_DataFile object to copy a file, that's no better than using any other method within Windows. ie if you can do: for f in wmi.WMI ().CIM_DataFile (Name="c:\\temp\\blah.txt"): f.Copy (r"\\my_machine\blah\%s" % f.Name) then you could probably do something like: shutil.copyfile (r"\\othermachine\blah\blah.txt", r"\\my_machine\blah\blah.txt") unless I've missed your point. Please feel free to jump in and point out my shortsightedness. 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 henni at brainbot.com Wed Aug 27 21:25:55 2003 From: henni at brainbot.com (Thorsten Henninger) Date: Wed Aug 27 14:26:50 2003 Subject: [python-win32] win32pdh api_error Message-ID: <3F4CF7B3.5030300@brainbot.com> Hi all, the win32pdh.EnumObjectItems does not work on my system: >>> win32api.GetSystemInfo() (0, 4096, 65536, 2147418111, 1, 1, 586, 65536, (6, 2051)) >>> win32pdh.EnumObjectItems(None,None,"Process", win32pdh.PERF_DETAIL_ADVANCED) Traceback (most recent call last): File "", line 1, in ? api_error: (-1073738824, 'EnumObjectItems for buffer size', 'No error message is available') Traceback (most recent call last): File "C:\Python22\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ ile "C:\Python22\lib\site-packages\win32\lib\win32pdhutil.py", line 118, in ? ShowAllProcesses() File "C:\Python22\lib\site-packages\win32\lib\win32pdhutil.py", line 67, in ShowAllProcesses items, instances = win32pdh.EnumObjectItems(None,None,object, win32pdh.PERF_DETAIL_WIZARD) api_error: (-1073738824, 'EnumObjectItems for buffer size', 'No error message is available')henni@news:~$ has anybod else the same problems? regards, Thorsten --- brainbot technologies AG boppstrasse . 64 . 55118 mainz . germany fon +49 6131 211639-1 . fax +49 6131 211639-2 http://brainbot.com/ mailto:henni@brainbot.com From enlavin at yahoo.com Wed Aug 27 13:02:26 2003 From: enlavin at yahoo.com (Miguel Hernandez) Date: Wed Aug 27 15:03:01 2003 Subject: [python-win32] DDE Hotlinks with Python Message-ID: <20030827190226.3256.qmail@web40808.mail.yahoo.com> Hello, I have seen an old post (http://dbforums.com/t552213.html) refering to the support for dde hot links in win32all. With dde module I can build a DDE server that notifies clients (VB and Delphi clients) of changes (using SetData method) and it works great. The problem is that I also need to code a dde client that can be notified of changes from a server. I browsed the source code of dde module and I think it can't be done, but I'm not a win32 guru. Can anybody tell me if that can be done with dde module bundled with win3all? Thanks in advance. ===== -- char*p="char*p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);} Miguel Hernandez Martos __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com From mmoales at fluent.com Wed Aug 27 16:42:56 2003 From: mmoales at fluent.com (Mark Moales) Date: Wed Aug 27 15:43:44 2003 Subject: [python-win32] Entering commands at Python prompt... Message-ID: <3F4D09C0.E35ECFCF@fluent.com> Hi, I have a simple Python file that creates a process using CreateProcess and kills it using GenerateConsoleCtrlEvent. When I run this file, it works great. However, when I try to issue these commands at the Python prompt, I always get: pywintypes.error: (87, 'GenerateConsoleCtrlEvent', 'The parameter is incorrect.') Can someone explain to me why this is happening? I'm really just curious. Thanks, Mark -------------- next part -------------- import win32process import win32con import win32api si = win32process.STARTUPINFO() result = win32process.CreateProcess( "C:\\Python23\\python.exe", None, None, None, 0, win32con.CREATE_NEW_CONSOLE | win32con.CREATE_NEW_PROCESS_GROUP, None, None, si) win32api.GenerateConsoleCtrlEvent( win32con.CTRL_BREAK_EVENT, result[2]) -------------- next part -------------- A non-text attachment was scrubbed... Name: mmoales.vcf Type: text/x-vcard Size: 270 bytes Desc: Card for Mark Moales Url : http://mail.python.org/pipermail/python-win32/attachments/20030827/d4498f30/mmoales.vcf From null-python-win32 at tinfoilhat.ca Wed Aug 27 18:46:34 2003 From: null-python-win32 at tinfoilhat.ca (Sean) Date: Wed Aug 27 18:57:55 2003 Subject: [python-win32] Domain iteration (for the archive and general knowledge). Message-ID: The following code gets around the problem where your network is segmented on different VLANs and broadcasts are not being propogated. It uses the 'ADsNameSpaces' to enumerate all the items in the "Server Manager" application under NT4. The caveat here is that this solution is slow on large numbers of machines because I've not found a ping module which works with python 2.2+ and use popen instead. The is_responding() function is the problem for this reason. Machines need to be checked if they are responding (especially if you want to use WMI features as it takes FOREVER for the WMI connect to timeout) every invocation otherwise I'd pickle the domains list between program calls. The code posted below is just cut/pasted and modified from a class I've written and only contains enough code to determine what machines are in the NT domain and which are online. The result of enumerate() is a list of names for machines that are both in the domain and responding. You can iterate through this list using WMI stuff and lots of fun (and time saving) will result. Any ideas, suggestions or comments? Any ideas how to make it faster? def enumerate(): # change MY_NT_DOMAIN to your NT domain name. adsi = win32com.client.Dispatch("ADsNameSpaces") nt = adsi.GetObject("","WinNT:") result = nt.OpenDSObject("WinNT://MY_NT_DOMAIN","","",0) result.Filter = ["computer"] # what other items can be 'filtered'? domain = [] for machine in result: domain.append(machine.Name) return domain # made global so the expressions are not 'compliled' every call. # using the regex library as the output of ping would be multiple lines not_found = re.compile("Unknown host",re.M) not_responding = re.compile("Request timed out.",re.M) def is_responding(name): cmd = "ping -n 1 %s" % name # only need one ping request. output = os.popen(cmd,"r") response = output.read() value = 0 # It could be useful to differentiate if a machine name doesn't # resolve or it is not responding to pings. if not_found.search(response): value = 1 elif not_responding.search(response): value = 2 else: value = 0 return value # Main loop. for machine in enumerate(): if is_responding() != 0: print machine," is not responding." else: print machine," is responding. -- Sean From tim.golden at viacom-outdoor.co.uk Thu Aug 28 10:11:16 2003 From: tim.golden at viacom-outdoor.co.uk (Tim Golden) Date: Thu Aug 28 04:16:36 2003 Subject: [python-win32] Domain iteration (for the archive and general knowledge). Message-ID: From: Sean [mailto:null-python-win32@tinfoilhat.ca] > The following code gets around the problem where your network is segmented > on different VLANs and broadcasts are not being propogated. It uses the > 'ADsNameSpaces' to enumerate all the items in the "Server Manager" > application under NT4. [snip explanation and code] Brilliant! It's running on my machine now with only a couple of changes: 1) The final line is lacking a trailing double-quote (cut-and-paste error?) 2) The is_responding () call in the preantepenultimate line (!) -- the fourth from the bottom -- needs to be is_responding (machine) Thanks very much. 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 sergej.pioch at rz.uni-freiburg.de Thu Aug 28 16:14:12 2003 From: sergej.pioch at rz.uni-freiburg.de (Sergej Pioch) Date: Thu Aug 28 10:07:46 2003 Subject: [python-win32] win32 Service and Networkdrive Trouble... Message-ID: <3F4E0024.4060506@rz.uni-freiburg.de> Hello everybody, I'm pretty new to python and I try to write a UPS-Software. The Script should run as a windows service and get Information from a network device, in this case a mapped network drive. It should search for a file .bat and run the command contained in it as a systemcall (i.e. a 'shutdown -s -f -t 0'). Almost everything works fine, as long as I use the Python interactive commandline or the script itself for testing. Run as service, the script cannot find the specified Path - neither if the script is started as user 'SERVICE' nor in any other Account. The eventlog shows the following errormessage: >> The instance's SvcRun() method failed File "C:\Python22\Lib\site-packages\win32\lib\win32serviceutil.py", line 635, in SvcRun self.SvcDoRun() File "PATH_TO_PROGRAM", line 40, in SvcDoRun None) pywintypes.api_error: (3, 'CreateFile', 'The system cannot find the path specified.') And here is a snipplet of the services mainloop: >> while X==1: rc = win32event.WaitForSingleObject(self.hWaitStop, 1) if rc==win32event.WAIT_OBJECT_0: break else: Content = CreateFile(\ Directory,\ GENERIC_READ,\ FILE_SHARE_READ,\ None,\ OPEN_EXISTING,\ 0,\ None) Action = ReadFile(Content, 256) Content.Close() if Action[0]==0: os.system(Action[1]) X=0 else: continue where Directory is a predefined value. I took everything out of the book 'Python on Win32 programming' and nailed it all together. Since I worked on it for four days now and got no clue how to fix this I thought it would be better to contact a mailinglist for help. Has anyone any idea? Best Sergej From null-python-win32 at tinfoilhat.ca Thu Aug 28 10:24:05 2003 From: null-python-win32 at tinfoilhat.ca (Sean) Date: Thu Aug 28 10:26:38 2003 Subject: [python-win32] win32 Service and Networkdrive Trouble... In-Reply-To: <3F4E0024.4060506@rz.uni-freiburg.de> Message-ID: ->Almost everything works fine, as long as I use the Python interactive ->commandline or the script itself for testing. Run as service, the script ->cannot find the specified Path - neither if the script is started as ->user 'SERVICE' nor in any other Account. The eventlog shows the ->following errormessage: -> I'm pretty new to python (and Windows coding for that matter) but one thing I found out is that under windows Window's mapped drives are dependant on the 'user profile.' This may be part of the problem (unless I completely misread your post). My approach to a problem of mapping drives remotely was to use the psexec application and use the 'net' commands but I found deleteing shares just wouldn't be allowed and creating shares were only temporary until the machine rebooted (despite the persistent flag). I've also tried running programs remotely which use network shares and that just doesn't work either. I know you are getting a file remotely but a service may not have network maps available to it due to the profile restrictions. In general for network apps I found a push is better than a pull. What I mean is that is less problematic to have the client drop files to the machine that deals with them instead of the 'server' application running around looking for the files. While this might not solve your problem it is something to think about in terms of design. Then again, I could be approaching the whole problem wrong. -- Sean From Jim.Vickroy at noaa.gov Thu Aug 28 09:25:27 2003 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Aug 28 10:27:11 2003 Subject: [python-win32] win32 Service and Networkdrive Trouble... References: <3F4E0024.4060506@rz.uni-freiburg.de> Message-ID: <3F4E10D7.9088BE82@noaa.gov> Hello Sergej, Until someone more knowledgeable than I responds, you might try running the Service in debug mode (command line option 'debug' rather than 'start'). That redirects all messages (including event log messages) to the console. Its puzzling that you can run it (successfully) from the same account that the Service uses. As an aside, you do not need all of those trailing backslashes in your code; Content = CreateFile( Directory, GENERIC_READ, FILE_SHARE_READ, None, OPEN_EXISTING, 0, None) should work just fine. Sergej Pioch wrote: > Hello everybody, > > I'm pretty new to python and I try to write a UPS-Software. The Script > should run as a windows service and get Information from a network > device, in this case a mapped network drive. It should search for a file > .bat and run the command contained in it as a systemcall (i.e. > a 'shutdown -s -f -t 0'). > > Almost everything works fine, as long as I use the Python interactive > commandline or the script itself for testing. Run as service, the script > cannot find the specified Path - neither if the script is started as > user 'SERVICE' nor in any other Account. The eventlog shows the > following errormessage: > > >> The instance's SvcRun() method failed > File > "C:\Python22\Lib\site-packages\win32\lib\win32serviceutil.py", line 635, > in SvcRun > self.SvcDoRun() > File "PATH_TO_PROGRAM", line 40, in SvcDoRun > None) > pywintypes.api_error: (3, 'CreateFile', 'The system cannot find > the path specified.') > > And here is a snipplet of the services mainloop: > > >> while X==1: > rc = win32event.WaitForSingleObject(self.hWaitStop, 1) > if rc==win32event.WAIT_OBJECT_0: > break > else: > Content = CreateFile(\ > Directory,\ > GENERIC_READ,\ > FILE_SHARE_READ,\ > None,\ > OPEN_EXISTING,\ > 0,\ > None) > Action = ReadFile(Content, 256) > Content.Close() > if Action[0]==0: > os.system(Action[1]) > X=0 > else: > continue > > where Directory is a predefined value. I took everything out of the book > 'Python on Win32 programming' and nailed it all together. Since I worked > on it for four days now and got no clue how to fix this I thought it > would be better to contact a mailinglist for help. > > Has anyone any idea? > > Best > > Sergej > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From null-python-win32 at tinfoilhat.ca Thu Aug 28 10:45:08 2003 From: null-python-win32 at tinfoilhat.ca (Sean) Date: Thu Aug 28 10:45:37 2003 Subject: [python-win32] Domain iteration (for the archive and general knowledge). In-Reply-To: Message-ID: ->Brilliant! It's running on my machine now with only a couple of changes: -> ->1) The final line is lacking a trailing -> double-quote (cut-and-paste error?) ->2) The is_responding () call in the -> preantepenultimate line (!) -- the fourth -> from the bottom -- needs to be is_responding (machine) -> I'm sure there was at least one error in that. :) In my actual code base I put all this into a class and made sure to cache the available hosts so multiple calls won't take years to run. I'm using it to deal with more than 200 machines and a very dirty and unmaintained "Server Manager" table so iterations are pretty darned slow (my best guess is due to using popen("ping....) so often ). It's been extremely helpful as of late when managment asks me how many nVidia cards we have or how many machines have less than 2GB of RAM. Just yesterday I used it to find out which machines had a drive incorrectly mapped or not at all. By hand this would have taken our tech at least a full day instead of five minutes by the script so I don't mind waiting for it when the results are worth it. Not to mention our tech's work load is more manageable. ->Thanks very much. -> No problem, glad it helped though since it's in the archive some poor sap like myself won't have to spend the day figuring this out. :) I want to refine this more so if you can think of anything I should fix or add let me know. -- Sean From sergej.pioch at rz.uni-freiburg.de Thu Aug 28 18:11:18 2003 From: sergej.pioch at rz.uni-freiburg.de (Sergej Pioch) Date: Thu Aug 28 11:12:55 2003 Subject: [python-win32] win32 Service and Networkdrive Trouble... References: <3F4E0024.4060506@rz.uni-freiburg.de> <3F4E10D7.9088BE82@noaa.gov> Message-ID: <3F4E1B96.4080402@rz.uni-freiburg.de> Jim Vickroy wrote: Thank you all for the fast answers! >Until someone more knowledgeable than I responds, you might try running the >Service in debug mode (command line option 'debug' rather than 'start'). >That redirects all messages (including event log messages) to the console. >Its puzzling that you can run it (successfully) from the same account that >the Service uses. > > Pretty nice: When I run the Service in debug-mode, either from calling it with the debug switch from commandline or debug it with 'C:\Python22\Lib\site-packages\win32\PythonService.exe -debug ', I just get a suitable result - just like calling parts of the code on the commandline... Best Sergej From Jim.Vickroy at noaa.gov Thu Aug 28 13:23:56 2003 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu Aug 28 14:26:18 2003 Subject: [python-win32] Entering commands at Python prompt... References: <3F4D09C0.E35ECFCF@fluent.com> Message-ID: <3F4E48BC.59631E87@noaa.gov> Hi Mark, No answers but some questions: When you say: "run these commands at the Python prompt" do you mean the interactive prompt within Pythonwin? If so, have you tried running them from with IDLE and/or from within the interactive command line interpreter prompt? Mark Moales wrote: > Hi, > > I have a simple Python file that creates a process using CreateProcess > and kills it using GenerateConsoleCtrlEvent. When I run this file, it > works great. However, when I try to issue these commands at the Python > prompt, I always get: > > pywintypes.error: (87, 'GenerateConsoleCtrlEvent', 'The parameter is > incorrect.') > > Can someone explain to me why this is happening? I'm really just > curious. > > Thanks, > > Mark > > ------------------------------------------------------------------------ > import win32process > import win32con > import win32api > > si = win32process.STARTUPINFO() > result = win32process.CreateProcess( > "C:\\Python23\\python.exe", > None, > None, > None, > 0, > win32con.CREATE_NEW_CONSOLE | win32con.CREATE_NEW_PROCESS_GROUP, > None, > None, > si) > > win32api.GenerateConsoleCtrlEvent( > win32con.CTRL_BREAK_EVENT, > result[2]) > > ------------------------------------------------------------------------ > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From mmoales at fluent.com Thu Aug 28 15:41:05 2003 From: mmoales at fluent.com (Mark Moales) Date: Thu Aug 28 14:41:47 2003 Subject: [python-win32] Entering commands at Python prompt... References: <3F4D09C0.E35ECFCF@fluent.com> <3F4E48BC.59631E87@noaa.gov> Message-ID: <3F4E4CC1.37316256@fluent.com> Hi Jim, I'm actually just using the regular Python command prompt (i.e. python.exe). For grins, I tried Idle and Pythonwin, and I get a slightly different error there: error: (6, 'GenerateConsoleCtrlEvent', 'The handle is invalid.') Mark Jim Vickroy wrote: > > Hi Mark, > > No answers but some questions: > > When you say: "run these commands at the Python prompt" do you mean the > interactive prompt within Pythonwin? If so, have you tried running them from > with IDLE and/or from within the interactive command line interpreter prompt? > > Mark Moales wrote: > > > Hi, > > > > I have a simple Python file that creates a process using CreateProcess > > and kills it using GenerateConsoleCtrlEvent. When I run this file, it > > works great. However, when I try to issue these commands at the Python > > prompt, I always get: > > > > pywintypes.error: (87, 'GenerateConsoleCtrlEvent', 'The parameter is > > incorrect.') > > > > Can someone explain to me why this is happening? I'm really just > > curious. > > > > Thanks, > > > > Mark > > > > ------------------------------------------------------------------------ > > import win32process > > import win32con > > import win32api > > > > si = win32process.STARTUPINFO() > > result = win32process.CreateProcess( > > "C:\\Python23\\python.exe", > > None, > > None, > > None, > > 0, > > win32con.CREATE_NEW_CONSOLE | win32con.CREATE_NEW_PROCESS_GROUP, > > None, > > None, > > si) > > > > win32api.GenerateConsoleCtrlEvent( > > win32con.CTRL_BREAK_EVENT, > > result[2]) > > > > ------------------------------------------------------------------------ > > _______________________________________________ > > Python-win32 mailing list > > Python-win32@python.org > > http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- A non-text attachment was scrubbed... Name: mmoales.vcf Type: text/x-vcard Size: 270 bytes Desc: Card for Mark Moales Url : http://mail.python.org/pipermail/python-win32/attachments/20030828/19ce58fb/mmoales.vcf From matt at clondiag.com Fri Aug 29 10:06:29 2003 From: matt at clondiag.com (Matthias Kirst) Date: Fri Aug 29 03:02:13 2003 Subject: [python-win32] Re: win32pdh api_error Message-ID: <006901c36dfc$123d9dc0$3701a8c0@silberpfeil> Try: win32pdh.EnumObjectItems(None,None,"Prozess", win32pdh.PERF_DETAIL_ADVANCED) if it is a german windows version. Matthias Kirst matt@clondiag.com www.clondiag.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20030829/6723d44c/attachment.htm