From niki@vintech.bg Tue Apr 1 08:37:39 2003 From: niki@vintech.bg (Niki Spahiev) Date: Tue, 01 Apr 2003 11:37:39 +0300 Subject: [python-win32] Embedded WebBrowser, take 3 - MFC embedding issues In-Reply-To: <20030331154908.87057.qmail@web40811.mail.yahoo.com> References: <20030331154908.87057.qmail@web40811.mail.yahoo.com> Message-ID: <3E894FD3.2080207@vintech.bg> Itamar S.-T. wrote: > So I guess this means my subclass needs to do this? > I.e. override the PreTranslateMessage method in my activex.Control? > win32all installs app hook to call PreTranslateMessage AFAIK. Check its implementation. HTH Niki Spahiev From lbates@syscononline.com Tue Apr 1 15:28:21 2003 From: lbates@syscononline.com (Larry Bates) Date: Tue, 1 Apr 2003 09:28:21 -0600 Subject: [python-win32] Using py2exe with COM server question Message-ID: <01d701c2f863$54c0d6d0$3f00a8c0@larrywxp> I have written a Python COM server that is working properly if Python is installed on the machine. I wanted to use py2exe to "freeze" this into single .EXE for installation on machines that DO NOT have Python installed. I came across a "recipe" found at: http://aspn.activestate.com/ASPN/Mail/Message/543304 that ALMOST explains how to make this happen. Problem: I'm confused about how to 'properly' handle the _reg_clsid_ attribute of the class. It is my understanding that this needs to come from pythoncom.CreateGuid() on the machine where the COM object is being installed and it is unique to that machine. If this is the case, what is the best way to make this happen in a 'frozen' COM object? The example shown has a hard coded GUID and that just doesn't seem right for distribution to other machines. Thanks in advance for any information. Larry Bates email: lbates@syscononline.com From wolf@circle-cross.org Tue Apr 1 19:30:38 2003 From: wolf@circle-cross.org (Wolf Logan) Date: Tue, 1 Apr 2003 11:30:38 -0800 Subject: [python-win32] Using py2exe with COM server question References: <01d701c2f863$54c0d6d0$3f00a8c0@larrywxp> Message-ID: <0cf301c2f885$2d675240$139f7943@circlecross.home> CreateGuid() will create (in most cases) a CLSID that is unique. that means that no one else will ever produce that same CLSID. in that case, you can distribute your package with that CLSID hard-coded, and it'll work just fine -- it willnever collide with another CLSID. non-python objects that are distributed in other ways also use a hard-coded CLSID. the trick is to create a *new* CLSID when your object is revised sufficiently that its interface changes. ----- Original Message ----- From: "Larry Bates" Sent: Tuesday, April 01, 2003 7:28 AM > Problem: > > I'm confused about how to 'properly' handle the _reg_clsid_ > attribute of the class. It is my understanding that this needs > to come from pythoncom.CreateGuid() on the machine where the COM > object is being installed and it is unique to that machine. > If this is the case, what is the best way to make this happen in > a 'frozen' COM object? The example shown has a hard coded GUID > and that just doesn't seem right for distribution to other machines. From corydodt@yahoo.com Tue Apr 1 21:15:07 2003 From: corydodt@yahoo.com (Cory Dodt) Date: Tue, 1 Apr 2003 13:15:07 -0800 (PST) Subject: [python-win32] Re: Using py2exe with COM server question In-Reply-To: <20030401170013.24869.23042.Mailman@mail.python.org> Message-ID: <20030401211507.84569.qmail@web10005.mail.yahoo.com> > I'm confused about how to 'properly' handle the _reg_clsid_ > attribute of the class. It is my understanding that this needs > to come from pythoncom.CreateGuid() on the machine where the COM > object is being installed and it is unique to that machine. Guid stands for 'globally unique ID', with emphasis on the word global. The recipe shows the guid hard-coded because that really is the right way to do it. A Guid is a promise that any object with this clsid conforms to the same interface as every other object with that guid, on any machine, anywhere in the universe. It's perfectly ok to 'print pythoncom.CreateGuid()' in an interactive browser and paste that into your _reg_clsid_. __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://platinum.yahoo.com From Christophe.Brunain@health.fgov.be Wed Apr 2 06:46:03 2003 From: Christophe.Brunain@health.fgov.be (Brunain Christophe) Date: Wed, 2 Apr 2003 08:46:03 +0200 Subject: [python-win32] Problem with COM and MsExcel Message-ID: <2C6114AD6C6B10418D0B505E08B511220345A3@andromede.HEALTH.FGOV.BE> Hello all ! I begin tu use python win and the COM features I try to do a little scripyt that takes a text file (an unload from a database) and to put it in an excel worksheet It works good, but only one time the second time I execute the script, i only se the menubar and the = toolbar on the top of the screen, the document itself is not displaying I see only what was my screen before the execution of the script If i close all the excel sheets and look in the task manager, I see an EXCEL.EXE still running If i make an "end process" it works, but if i try to run the script = once again, it makes an error. here is the script i use import win32com.client ex =3D win32com.client.Dispatch("Excel.Application") ex.Visible =3D 1 ex.Workbooks.Open("C:\\test\\test.xls") ex.Run("SaveText","C:\\test\\codes", "C:\\test\\codes2.xls") ex.Quit and the traceback i got when i close the excel.exe and run the script = once again PythonWin 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on = win32. Portions Copyright 1994-2001 Mark Hammond (mhammond@skippinet.com.au) - = see 'Help/About PythonWin' for further copyright information. Traceback (most recent call last): File "C:\Python22\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py"= , line 307, in RunScript debugger.run(codeObject, __main__.__dict__, start_stepping=3D0) File = "C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\__init__.py", line 60, in run _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) File = "C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\debugger.py", line 591, in run exec cmd in globals, locals File "C:\test\test1.py", line 4, in ? ex.Visible =3D 1 File "C:\Python22\lib\site-packages\win32com\client\dynamic.py", line = 504, in __setattr__ raise AttributeError, "Property '%s.%s' can not be set." % (self._username_, attr) AttributeError: Property 'Excel.Application.Visible' can not be set. Does someone know what's wrong ? i've looked in the archives of this mailing list but i haven't found :( Thanks a lot for your answers PS : Sorry if my english is not so good Brunain Christophe Service informatique de l'expertise m=E9dicale SPF Sant=E9 Publique, S=E9curit=E9 de la chaine alimentaire et = Environnement From nielssteenkrogh@hotmail.com Wed Apr 2 17:45:31 2003 From: nielssteenkrogh@hotmail.com (Niels Steen Krogh) Date: Wed, 02 Apr 2003 19:45:31 +0200 Subject: [python-win32] Re: Problem with COM and MsExcel (Brunain Christophe) Message-ID: Hi! This script might help you - use CoInitialize ..... It helped me in a situation similar to yours. Good luck Niels from win32com.client import Dispatch from pythoncom import CoInitialize,CoUninitialize CoInitialize() #start com thread - kan udelades, men vil mindske stabiliteten o=Dispatch("Excel.Application") #start excel o.Visible=0 #excel kører i baggrunden o.Workbooks.Open(Filename='c:\\dokumenter\\mappe14.xls') #get the workbook o.Workbooks(1).Sheets(1).Cells.Clear() #clear the workbook sht=o.Workbooks(1).Sheets(1) #peg på ark 1 sht.Range(sht.Cells(1,1),sht.Cells(len(data),len(data[0]))).Value=data #put a range of data (tupple formatted) o.Workbooks(1).Save() #gem regneark o.Workbooks(1).Close(SaveChanges='0') #close workbook without dialog o.Quit() #luk excel del o #slet objekt del sht #slet objekt del data #slet objekt CoUninitialize() #close com thread Cand. Polit. Niels Steen Krogh Solsortvej 44 2000 F. Tlf: 3888 8613 ZiteLab / Empower your data >From: python-win32-request@python.org >Reply-To: python-win32@python.org >To: python-win32@python.org >Subject: Python-win32 digest, Vol 1 #325 - 3 msgs >Date: Wed, 02 Apr 2003 12:00:14 -0500 > >Send Python-win32 mailing list submissions to > python-win32@python.org > >To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-win32 >or, via email, send a message with subject or body 'help' to > python-win32-request@python.org > >You can reach the person managing the list at > python-win32-admin@python.org > >When replying, please edit your Subject line so it is more specific >than "Re: Contents of Python-win32 digest..." > > >Today's Topics: > > 1. Re: Using py2exe with COM server question (Wolf Logan) > 2. Re: Using py2exe with COM server question (Cory Dodt) > 3. Problem with COM and MsExcel (Brunain Christophe) > >--__--__-- > >Message: 1 >From: "Wolf Logan" >To: >Subject: Re: [python-win32] Using py2exe with COM server question >Date: Tue, 1 Apr 2003 11:30:38 -0800 > >CreateGuid() will create (in most cases) a CLSID that is unique. that means >that no one else will ever produce that same CLSID. in that case, you can >distribute your package with that CLSID hard-coded, and it'll work just >fine -- it willnever collide with another CLSID. > >non-python objects that are distributed in other ways also use a hard-coded >CLSID. the trick is to create a *new* CLSID when your object is revised >sufficiently that its interface changes. > >----- Original Message ----- >From: "Larry Bates" >Sent: Tuesday, April 01, 2003 7:28 AM > > > > Problem: > > > > I'm confused about how to 'properly' handle the _reg_clsid_ > > attribute of the class. It is my understanding that this needs > > to come from pythoncom.CreateGuid() on the machine where the COM > > object is being installed and it is unique to that machine. > > If this is the case, what is the best way to make this happen in > > a 'frozen' COM object? The example shown has a hard coded GUID > > and that just doesn't seem right for distribution to other machines. > > > >--__--__-- > >Message: 2 >Date: Tue, 1 Apr 2003 13:15:07 -0800 (PST) >From: Cory Dodt >To: python-win32@python.org >Subject: [python-win32] Re: Using py2exe with COM server question > > > I'm confused about how to 'properly' handle the _reg_clsid_ > > attribute of the class. It is my understanding that this needs > > to come from pythoncom.CreateGuid() on the machine where the COM > > object is being installed and it is unique to that machine. > >Guid stands for 'globally unique ID', with emphasis on the word global. >The recipe shows the guid hard-coded because that really is the right way >to do it. A Guid is a promise that any object with this clsid conforms to >the same interface as every other object with that guid, on any machine, >anywhere in the universe. > >It's perfectly ok to 'print pythoncom.CreateGuid()' in an interactive >browser and paste that into your _reg_clsid_. > > >__________________________________________________ >Do you Yahoo!? >Yahoo! Tax Center - File online, calculators, forms, and more >http://platinum.yahoo.com > > >--__--__-- > >Message: 3 >From: Brunain Christophe >To: "Pythonwin (E-mail)" >Date: Wed, 2 Apr 2003 08:46:03 +0200 >Subject: [python-win32] Problem with COM and MsExcel > >Hello all ! > >I begin tu use python win and the COM features > >I try to do a little scripyt that takes a text file (an unload from a >database) and to put it in an excel worksheet > >It works good, but only one time > >the second time I execute the script, i only se the menubar and the = >toolbar >on the top of the screen, the document itself is not displaying > >I see only what was my screen before the execution of the script > >If i close all the excel sheets and look in the task manager, I see an >EXCEL.EXE still running > >If i make an "end process" it works, but if i try to run the script = >once >again, it makes an error. > >here is the script i use > >import win32com.client > >ex =3D win32com.client.Dispatch("Excel.Application") >ex.Visible =3D 1 >ex.Workbooks.Open("C:\\test\\test.xls") >ex.Run("SaveText","C:\\test\\codes", "C:\\test\\codes2.xls") >ex.Quit > >and the traceback i got when i close the excel.exe and run the script = >once >again > >PythonWin 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on = >win32. >Portions Copyright 1994-2001 Mark Hammond (mhammond@skippinet.com.au) - = >see >'Help/About PythonWin' for further copyright information. >Traceback (most recent call last): > File >"C:\Python22\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py"= >, >line 307, in RunScript > debugger.run(codeObject, __main__.__dict__, start_stepping=3D0) > File = >"C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\__init__.py", >line 60, in run > _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) > File = >"C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\debugger.py", >line 591, in run > exec cmd in globals, locals > File "C:\test\test1.py", line 4, in ? > ex.Visible =3D 1 > File "C:\Python22\lib\site-packages\win32com\client\dynamic.py", line = >504, >in __setattr__ > raise AttributeError, "Property '%s.%s' can not be set." % >(self._username_, attr) >AttributeError: Property 'Excel.Application.Visible' can not be set. > >Does someone know what's wrong ? >i've looked in the archives of this mailing list but i haven't found :( > >Thanks a lot for your answers > >PS : >Sorry if my english is not so good > >Brunain Christophe >Service informatique de l'expertise m=E9dicale >SPF Sant=E9 Publique, S=E9curit=E9 de la chaine alimentaire et = >Environnement > > > >--__--__-- > >_______________________________________________ >Python-win32 mailing list >Python-win32@python.org >http://mail.python.org/mailman/listinfo/python-win32 > > >End of Python-win32 Digest _________________________________________________________________ Send søde postkort til søde mennesker http://www.msn.dk/postkort From paul@prescod.net Wed Apr 2 19:32:06 2003 From: paul@prescod.net (Paul Prescod) Date: Wed, 02 Apr 2003 11:32:06 -0800 Subject: [python-win32] "Casting" COM objects Message-ID: <3E8B3AB6.6060202@prescod.net> Consider the following case: class A: def foo(self): pass class B(A): def bar(self): pass class C(A): def car(self): pass Now pretend Python had static typing: class Z: def __init__(self, thing): self.thing = thing def get_A() returns A: return self.thing Now in statically typed languages like C or IDL, it is perfectly legal for C to return a "B" because a B isa A. Then, client code casts from an A reference to a B reference to get access to the bar() function. Now imagine the code above is the output of MakePy. The object returned by MakePy is a B wrapped in a proxy for an A. What I would like to know is whether there is a function out there that can take the _oleobj_ pointer and determine at runtime what the best proxy is for it. I've figured out how to do some casting "manually" by importing a gen_py'd module and selecting the right class, but I wonder if there is an easier way Paul Prescod From jens.jorgensen@tallan.com Wed Apr 2 20:39:46 2003 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Wed, 02 Apr 2003 14:39:46 -0600 Subject: [python-win32] "Casting" COM objects In-Reply-To: <3E8B3AB6.6060202@prescod.net> References: <3E8B3AB6.6060202@prescod.net> Message-ID: <3E8B4A92.2010604@tallan.com> Based on the fact that makepy does its work by looking through type libraries it would be possible for it to generate the type traversal mechanisms you speak of, but unfortunately (or fortunately?) it doesn't as far as I know. The wrapper classes that are generated seem to be more geared towards representing interfaces (thank goodness) rather than the VB way of typing objects according to class and then making the interface the same as the default interface. It would certainly be possible for makepy to generated wrapper classes that could remember what classID they came from and in that case be able to safely support type-traversal methods such as you suggest but this doesn't seem to be the case. "casting" the type by passing the python object reference you have to the constructor of the object wrapping the interface you want is the method that I use. Paul Prescod wrote: > Consider the following case: > > class A: > def foo(self): pass > > class B(A): > def bar(self): pass > > class C(A): > def car(self): pass > > Now pretend Python had static typing: > > class Z: > def __init__(self, thing): > self.thing = thing > > def get_A() returns A: > return self.thing > > Now in statically typed languages like C or IDL, it is perfectly legal > for C to return a "B" because a B isa A. Then, client code casts from > an A reference to a B reference to get access to the bar() function. > > Now imagine the code above is the output of MakePy. The object > returned by MakePy is a B wrapped in a proxy for an A. What I would > like to know is whether there is a function out there that can take > the _oleobj_ pointer and determine at runtime what the best proxy is > for it. I've figured out how to do some casting "manually" by > importing a gen_py'd module and selecting the right class, but I > wonder if there is an easier way > > Paul Prescod > > > _______________________________________________ > 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 paul@prescod.net Thu Apr 3 02:13:36 2003 From: paul@prescod.net (Paul Prescod) Date: Wed, 02 Apr 2003 18:13:36 -0800 Subject: [python-win32] "Casting" COM objects In-Reply-To: <3E8B4A92.2010604@tallan.com> References: <3E8B3AB6.6060202@prescod.net> <3E8B4A92.2010604@tallan.com> Message-ID: <3E8B98D0.4090100@prescod.net> Jens B. Jorgensen wrote: > Based on the fact that makepy does its work by looking through type > libraries it would be possible for it to generate the type traversal > mechanisms you speak of, but unfortunately (or fortunately?) it doesn't > as far as I know. I was thinking more of a feature I could call explicitly at runtime than something baked into the interfaces, rather than a new feature for makepy. > ... casting" the type by passing the python object reference you > have to the constructor of the object wrapping the interface you want is > the method that I use. The problem is it can be inconvienent or impossible to figure out what constructor is appropriate. I'm thinking of something more dynamic where I don't tell it what to do, I just tell it: "figure out what class you are." Paul Prescod From vishnu_mahendra@yahoo.com Thu Apr 3 06:59:23 2003 From: vishnu_mahendra@yahoo.com (vishnu mahendra) Date: Wed, 2 Apr 2003 22:59:23 -0800 (PST) Subject: [python-win32] including activex in python Message-ID: <20030403065923.56865.qmail@web40807.mail.yahoo.com> hello sir, can you tell me how to include a activex control and how to set the properties to that. i am working in pythonwin and i want to create a data report from mysql table using the existing activex control. can you help me with that. or can you please tell me where can i find more information on python and activex. thank you in advance, vishnu __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://tax.yahoo.com From ful_tom@yahoo.com Thu Apr 3 07:51:14 2003 From: ful_tom@yahoo.com (Tom) Date: Wed, 2 Apr 2003 23:51:14 -0800 (PST) Subject: [python-win32] RE:Problem with COM and MsExcel Message-ID: <20030403075114.50265.qmail@web41707.mail.yahoo.com> Hi, try add at end command ex = None. This will close Excel object. Tomas From: Brunain Christophe To: "Pythonwin (E-mail)" Date: Wed, 2 Apr 2003 08:46:03 +0200 Subject: [python-win32] Problem with COM and MsExcel Hello all ! I begin tu use python win and the COM features I try to do a little scripyt that takes a text file (an unload from a database) and to put it in an excel worksheet It works good, but only one time the second time I execute the script, i only se the menubar and the = toolbar on the top of the screen, the document itself is not displaying I see only what was my screen before the execution of the script If i close all the excel sheets and look in the task manager, I see an EXCEL.EXE still running If i make an "end process" it works, but if i try to run the script = once again, it makes an error. here is the script i use import win32com.client ex =3D win32com.client.Dispatch("Excel.Application") ex.Visible =3D 1 ex.Workbooks.Open("C:\\test\\test.xls") ex.Run("SaveText","C:\\test\\codes", "C:\\test\\codes2.xls") ex.Quit and the traceback i got when i close the excel.exe and run the script = once again PythonWin 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on = win32. Portions Copyright 1994-2001 Mark Hammond (mhammond@skippinet.com.au) - = see 'Help/About PythonWin' for further copyright information. Traceback (most recent call last): File "C:\Python22\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py"= , line 307, in RunScript debugger.run(codeObject, __main__.__dict__, start_stepping=3D0) File = "C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\__init__.py", line 60, in run _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) File = "C:\Python22\lib\site-packages\Pythonwin\pywin\debugger\debugger.py", line 591, in run exec cmd in globals, locals File "C:\test\test1.py", line 4, in ? ex.Visible =3D 1 File "C:\Python22\lib\site-packages\win32com\client\dynamic.py", line = 504, in __setattr__ raise AttributeError, "Property '%s.%s' can not be set." % (self._username_, attr) AttributeError: Property 'Excel.Application.Visible' can not be set. Does someone know what's wrong ? i've looked in the archives of this mailing list but i haven't found :( Thanks a lot for your answers PS : Sorry if my english is not so good Brunain Christophe Service informatique de l'expertise m=E9dicale SPF Sant=E9 Publique, S=E9curit=E9 de la chaine alimentaire et = Environnement __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://tax.yahoo.com From jens.jorgensen@tallan.com Thu Apr 3 15:32:49 2003 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Thu, 03 Apr 2003 09:32:49 -0600 Subject: [python-win32] "Casting" COM objects In-Reply-To: <3E8B98D0.4090100@prescod.net> References: <3E8B3AB6.6060202@prescod.net> <3E8B4A92.2010604@tallan.com> <3E8B98D0.4090100@prescod.net> Message-ID: <3E8C5421.7070001@tallan.com> Paul Prescod wrote: > Jens B. Jorgensen wrote: > >> Based on the fact that makepy does its work by looking through type >> libraries it would be possible for it to generate the type traversal >> mechanisms you speak of, but unfortunately (or fortunately?) it >> doesn't as far as I know. > > > I was thinking more of a feature I could call explicitly at runtime > than something baked into the interfaces, rather than a new feature > for makepy. That's where we'd get into trouble though since for any given COM object there isn't a way to know what class it came from. You can try to get the IPersist interface to find out the CLSID but getting the CLSID doesn't tell you anything about what other interfaces. If you want to "downcast" the pointer or get another interface supported by the object you have to have prior knowledge. Even then this kind of downcasting cannot be done as downcasting anyway, you have to QueryInterface for it. This prior knowledge has to come from a type library. There is no mechanism to take an interface pointer and get the type library that describes the class that interface came from. Since the only way to do this is from a type library that's why I suggested it could be added to makepy. >> ... casting" the type by passing the python object reference you have >> to the constructor of the object wrapping the interface you want is >> the method that I use. > > > The problem is it can be inconvienent or impossible to figure out what > constructor is appropriate. I'm thinking of something more dynamic > where I don't tell it what to do, I just tell it: "figure out what > class you are." It is inconvenient, I know. It is no wonder more recent models such as Java and CLR support a "reflection" interface to discover type information about an object pointer eh? -- 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 paul@prescod.net Thu Apr 3 22:49:58 2003 From: paul@prescod.net (Paul Prescod) Date: Thu, 03 Apr 2003 14:49:58 -0800 Subject: [python-win32] "Casting" COM objects In-Reply-To: <3E8C5421.7070001@tallan.com> References: <3E8B3AB6.6060202@prescod.net> <3E8B4A92.2010604@tallan.com> <3E8B98D0.4090100@prescod.net> <3E8C5421.7070001@tallan.com> Message-ID: <3E8CBA96.3000203@prescod.net> Jens B. Jorgensen wrote: > ... > > It is inconvenient, I know. It is no wonder more recent models such as > Java and CLR support a "reflection" interface to discover type > information about an object pointer eh? I didn't know that COM lacked that. Thanks for the info. Still, there is at least enough reflection in there to support dispatch interfaces. Would it be feasible for the classes generated by MakePy to "try" a method call or property assignment even if it wasn't known at compile time? Is the underlying object used in a dynamic dispatch interface versus a Makepy interface basically the same object? If so, the Makepy classes could try the dynamic approach before giving up and throwing an exception... Paul Prescod From jens.jorgensen@tallan.com Thu Apr 3 23:14:32 2003 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Thu, 03 Apr 2003 17:14:32 -0600 Subject: [python-win32] "Casting" COM objects In-Reply-To: <3E8CBA96.3000203@prescod.net> References: <3E8B3AB6.6060202@prescod.net> <3E8B4A92.2010604@tallan.com> <3E8B98D0.4090100@prescod.net> <3E8C5421.7070001@tallan.com> <3E8CBA96.3000203@prescod.net> Message-ID: <3E8CC058.1040302@tallan.com> Paul Prescod wrote: > Jens B. Jorgensen wrote: > >> ... >> >> It is inconvenient, I know. It is no wonder more recent models such >> as Java and CLR support a "reflection" interface to discover type >> information about an object pointer eh? > > > I didn't know that COM lacked that. Thanks for the info. > > > Still, there is at least enough reflection in there to support > dispatch interfaces. Even this is not strictly true. The only type information is known from the type library. The dispatch interface literally let's you try to lookup a method or propery by name. If it isn't there then you don't get anything. It won't give you a list of things that you can call, it just let's you try to look something by its name. The type library enumerates what methods and "properties" (these are really methods too by the way) are supported by the object. > Would it be feasible for the classes generated by MakePy to "try" a > method call or property assignment even if it wasn't known at compile > time? Is the underlying object used in a dynamic dispatch interface > versus a Makepy interface basically the same object? If so, the Makepy > classes could try the dynamic approach before giving up and throwing > an exception... If you used the dispatch methods directly to try to lookup the method/property name then you can indeed do this. I have never tried this myself. I wouldn't think it would be all that hard to arrange for the makepy-generated code to attempt to lookup names that it doesn't already have. -- 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 bjarrett@garcoschools.org Fri Apr 4 17:12:56 2003 From: bjarrett@garcoschools.org (Brian Jarrett) Date: Fri, 4 Apr 2003 09:12:56 -0800 Subject: [python-win32] need help in creating a username generator Message-ID: <0067E36738F75E4BB04832584BAED63C0168DA@localdns.garcoschools.org> Hello all. I'm new to Python and I've been working on some scripts to automate the = creation of user accounts on our network. I work in a school district, = so I want the school secretaries to use a webpage to create student user = accounts and I will have the administrations staff create employee user = accounts and email boxes. What I want to do is create some sort of object or function that would = take a variable number of "rules" and apply them to information = specified (firstname, lastname, middle initial, graduation year) to come = up with a username for the individual. If the first username is already = used, then it would try applying the next "rule" until it came up with a = unique name. Since I have two classes of users (Employees and Students) = I will have two separate sets of rules. I already have code that checks my Active Directory to see if a username = has not been used. I just need something to generate the username to = test. Of course I could hardcode how I'd want to slice up first and last = names, etc, to get a username, but I thought I'd make it more flexible = and then release it for others to use if they wanted. The rules I'd be using would be something like: Employees: Try first initial + last name Try first initial + middle initial + last name Students: Try first initial + last name + last 2 digits of grad year Try first initial + middle initial + last name + last 2 digits of grad = year Try first two letters of first name + last name + last 2 digits of grad = year Any ideas on how to do this would be appreciated. Mainly I'm concerned = with making the rules persistent but easily changed and flexible enough = to add/remove data to use and how to specify the use of said data. Brian Jarrett Network Administrator Garfield County School District 16 From dave@psys.org Fri Apr 4 19:57:18 2003 From: dave@psys.org (d.w. harks) Date: Fri, 4 Apr 2003 13:57:18 -0600 (CST) Subject: [python-win32] need help in creating a username generator In-Reply-To: <0067E36738F75E4BB04832584BAED63C0168DA@localdns.garcoschools.org> References: <0067E36738F75E4BB04832584BAED63C0168DA@localdns.garcoschools.org> Message-ID: <26101.66.99.8.89.1049486238.squirrel@psysmail.psys.org> I do this, but not in nearly so flexible a manner. Guess I'm lazy. :-) I just have the function generate three different possible usernames, based on the user's first, middle and last names, and append the results to a list. I've never had the situation come up where I can't get a unique username...but I work for a small university, and we only have about 1500 users. Then, it checks each one against AD, and the first one that is not already taken gets assigned to the user. I could see this working with a list of function references which could be selected at runtime from a pool of available username-generation functions...i.e.: def stuOne(name): def stuTwo(name): def genUserName(name): funcList = [ stuOne, stuTwo, ...] # generate this with your setup code optionList = [] for func in funcList: optionList.append(func(name)) Just a thought. dave Brian Jarrett said: > Hello all. > > I'm new to Python and I've been working on some scripts to automate the > creation of user accounts on our network. I work in a school district, so > I want the school secretaries to use a webpage to create student user > accounts and I will have the administrations staff create employee user > accounts and email boxes. > > What I want to do is create some sort of object or function that would > take a variable number of "rules" and apply them to information specified > (firstname, lastname, middle initial, graduation year) to come up with a > username for the individual. If the first username is already used, then > it would try applying the next "rule" until it came up with a unique name. > Since I have two classes of users (Employees and Students) I will have > two separate sets of rules. > > I already have code that checks my Active Directory to see if a username > has not been used. I just need something to generate the username to > test. > > Of course I could hardcode how I'd want to slice up first and last names, > etc, to get a username, but I thought I'd make it more flexible and then > release it for others to use if they wanted. > > The rules I'd be using would be something like: > > Employees: > Try first initial + last name > Try first initial + middle initial + last name > > Students: > Try first initial + last name + last 2 digits of grad year > Try first initial + middle initial + last name + last 2 digits of grad > year > Try first two letters of first name + last name + last 2 digits of grad > year > > Any ideas on how to do this would be appreciated. Mainly I'm concerned > with making the rules persistent but easily changed and flexible enough to > add/remove data to use and how to specify the use of said data. > > Brian Jarrett > Network Administrator > Garfield County School District 16 > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > -- d.w. harks http://dwblog.psys.org From bjarrett@garcoschools.org Fri Apr 4 23:42:26 2003 From: bjarrett@garcoschools.org (Brian Jarrett) Date: Fri, 4 Apr 2003 15:42:26 -0800 Subject: [python-win32] need help in creating a username generator Message-ID: <0067E36738F75E4BB04832584BAED63C016C09@localdns.garcoschools.org> Thanks... I'll give it a try and post my results back here. Brian -----Original Message----- From: d.w. harks [mailto:dave@psys.org] Sent: Friday, April 04, 2003 12:57 PM To: python-win32@python.org Subject: Re: [python-win32] need help in creating a username generator I do this, but not in nearly so flexible a manner. Guess I'm lazy. :-) I just have the function generate three different possible usernames, based on the user's first, middle and last names, and append the results to a list. I've never had the situation come up where I can't get a = unique username...but I work for a small university, and we only have about = 1500 users. Then, it checks each one against AD, and the first one that is not = already taken gets assigned to the user. I could see this working with a list of function references which could = be selected at runtime from a pool of available username-generation functions...i.e.: def stuOne(name): def stuTwo(name): def genUserName(name): funcList =3D [ stuOne, stuTwo, ...] # generate this with your setup = code optionList =3D [] for func in funcList: optionList.append(func(name)) Just a thought. dave Brian Jarrett said: > Hello all. > > I'm new to Python and I've been working on some scripts to automate = the > creation of user accounts on our network. I work in a school = district, so > I want the school secretaries to use a webpage to create student user > accounts and I will have the administrations staff create employee = user > accounts and email boxes. > > What I want to do is create some sort of object or function that would > take a variable number of "rules" and apply them to information = specified > (firstname, lastname, middle initial, graduation year) to come up with = a > username for the individual. If the first username is already used, = then > it would try applying the next "rule" until it came up with a unique = name. > Since I have two classes of users (Employees and Students) I will = have > two separate sets of rules. > > I already have code that checks my Active Directory to see if a = username > has not been used. I just need something to generate the username to > test. > > Of course I could hardcode how I'd want to slice up first and last = names, > etc, to get a username, but I thought I'd make it more flexible and = then > release it for others to use if they wanted. > > The rules I'd be using would be something like: > > Employees: > Try first initial + last name > Try first initial + middle initial + last name > > Students: > Try first initial + last name + last 2 digits of grad year > Try first initial + middle initial + last name + last 2 digits of grad > year > Try first two letters of first name + last name + last 2 digits of = grad > year > > Any ideas on how to do this would be appreciated. Mainly I'm = concerned > with making the rules persistent but easily changed and flexible = enough to > add/remove data to use and how to specify the use of said data. > > Brian Jarrett > Network Administrator > Garfield County School District 16 > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > --=20 d.w. harks http://dwblog.psys.org _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From vishnu_mahendra@yahoo.com Sat Apr 5 14:48:38 2003 From: vishnu_mahendra@yahoo.com (vishnu mahendra) Date: Sat, 5 Apr 2003 06:48:38 -0800 (PST) Subject: [python-win32] including activex control in python Message-ID: <20030405144838.34767.qmail@web40803.mail.yahoo.com> there is an activex control for creating reports from database, since i am not familiar with including activex modules in python, can anyone tell me how to generate a report from table using data report control. thank you in advance, vishnu __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, forms, and more http://tax.yahoo.com From robinjim@earthlink.net Sat Apr 5 15:57:21 2003 From: robinjim@earthlink.net (robin and jim) Date: Sat, 5 Apr 2003 08:57:21 -0700 Subject: [python-win32] including activex control in python References: <20030405144838.34767.qmail@web40803.mail.yahoo.com> Message-ID: <011401c2fb8c$0c4077e0$ea113b41@robinjim> You might try looking at: http://www.e-coli.net/pyado.html ----- Original Message ----- From: "vishnu mahendra" To: Sent: Saturday, April 05, 2003 07:48 AM Subject: [python-win32] including activex control in python > there is an activex control for creating reports from > database, since i am not familiar with including > activex modules in python, > can anyone tell me how to generate a report from table > using data report control. > thank you in advance, > vishnu > > __________________________________________________ > Do you Yahoo!? > Yahoo! Tax Center - File online, calculators, forms, and more > http://tax.yahoo.com > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From radix@twistedmatrix.com Sun Apr 6 03:04:38 2003 From: radix@twistedmatrix.com (Christopher Armstrong) Date: Sat, 5 Apr 2003 21:04:38 -0500 Subject: [python-win32] win32process.CreateProcess alternative that takes an array Message-ID: <20030406020438.GD956@radii> Twisted uses win32process.CreateProcess for its Process running on win32. This is bad, because CreateProcess needs a string - right now we just to a " ".join on the arguments to the program, but obviously that totally breaks when some of the arguments have spaces in them. Is there an alternative to CreateProcess that takes a list of arguments rather than a string? Is there even an unwrapped win32 call that takes an array? I really don't want to mess with trying to automatically quote the arguments that have spaces. -- Twisted | Christopher Armstrong: International Man of Twistery Radix | Release Manager, Twisted Project ---------+ http://twistedmatrix.com/users/radix.twistd/ From David.Orr@hwe.com.au Sun Apr 6 07:58:40 2003 From: David.Orr@hwe.com.au (David Orr) Date: Sun, 6 Apr 2003 14:58:40 +0800 Subject: [python-win32] extract and load address book from exchange Message-ID: > I am working for a company that in turn has 4+ companies within it. They > each have their own exchange server and I need to set up each server so > that they have all the details (address book / global address list) from > every other server. I expect that I will have to set up a process that > runs each night to update this info on each server. > > Any hints / code / links appreciated. > > David Orr > Development Analyst Programmer > Henry Walker Eltin > email: david.orr@hwe.com.au > From David.Orr@hwe.com.au Sun Apr 6 07:45:37 2003 From: David.Orr@hwe.com.au (David Orr) Date: Sun, 6 Apr 2003 14:45:37 +0800 Subject: [python-win32] extract and load address book from exchange Message-ID: I am working for a company that in turn has 4+ companies within it. They each have their own exchange server and I need to set up each server so that they have all the details (address book / global address list) from every other server. I expect that I will have to set up a process that runs each night to update this info on each server. Any hints / code / links appreciated. David Orr Development Analyst Programmer Henry Walker Eltin email: david.orr@hwe.com.au From dave@psys.org Sun Apr 6 18:02:30 2003 From: dave@psys.org (David W. Harks) Date: Sun, 6 Apr 2003 12:02:30 -0500 Subject: [python-win32] extract and load address book from exchange In-Reply-To: References: Message-ID: <200304061202.30987.dave@psys.org> For our Active Directory, we pull user data out of an Oracle database and insert it into the AD using Python. The process for you would be pretty straightforward -- use ADSI via win32com.client and do an LDAP query which returns all of the data you're looking to share between domains, and then update the other domains with that data, also using win32com.client with ADSI. I would assume you'd be able to just add a separate Org Unit for each sub-company and just create Contacts for the users on the other domains. I strongly recommend making some sort of intermediate data type; we created a class called PyRecSet which is essentially a list of dictionaries containing a predetermined set of fields that represent our "mapping" of Oracle tables to AD attributes. This class also includes the ability to write out its contents to a .csv file for debugging purposes...it took almost no time to write and yet has been the most valuable debugging tool. You should be able to use Microsoft's VBScript examples in their ADSI reference online to help figure out how to do the search and how to do the creation/updating of users; just remember that to instantiate the COM objects you have to call 'win32com.client.Dispatch' rather than 'Dim foo as ADsUser' or whatever. From there, things are pretty much the same, and you can mostly treat the COM objects as Python classes. (Don't forget, though, to use Unicode strings!) If you need sample code, let me know and I can post some this week. Good luck! dave On Sunday 06 April 2003 12:45 am, David Orr expounded thusly: > I am working for a company that in turn has 4+ companies within it. They > each have their own exchange server and I need to set up each server so > that they have all the details (address book / global address list) from > every other server. I expect that I will have to set up a process that > runs each night to update this info on each server. > > Any hints / code / links appreciated. > > David Orr > Development Analyst Programmer > Henry Walker Eltin > email: david.orr@hwe.com.au > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 -- David W. Harks http://dwblog.psys.org From Paul.Moore@atosorigin.com Mon Apr 7 09:53:40 2003 From: Paul.Moore@atosorigin.com (Moore, Paul) Date: Mon, 7 Apr 2003 09:53:40 +0100 Subject: [python-win32] win32process.CreateProcess alternative that takes an array Message-ID: <16E1010E4581B049ABC51D4975CEDB88619A2E@UKDCX001.uk.int.atosorigin.com> From: Christopher Armstrong [mailto:radix@twistedmatrix.com] > Twisted uses win32process.CreateProcess for its Process running > on win32. This is bad, because CreateProcess needs a string > - right now we just to a " ".join on the arguments to the > program, but obviously that totally breaks when some of the > arguments have spaces in them. Is there an alternative to > CreateProcess that takes a list of arguments rather than a > string? Is there even an unwrapped win32 call that takes an > array? I really don't want to mess with trying to automatically > quote the arguments that have spaces. I don't believe there is. The fundamental construct in Windows is the command line. CreateProcess passes a command line to the process, and the process retrieves that command line via GetCommandLine. All splitting of this command line into a set of arguments is handled entirely by user code. It's a fundamental difference between the Unix approach and the Windows approach. (You can argue endlessly over which is better, but that's fruitless - it's just a fact you have to deal with.) Creating a command line from an argv list in such a way that a user program will recreate the same argv list is dependent on the code used by the C runtime of the program called, and hence is impossible in complete generality, although it's not hard for 99% of cases. As long as you don't care much about what happens to an argument like you're going to be OK :-) The code in Python for os.exec* (I believe) just punts to the CRT with which Python was built, and so isn't much use. For a comprehensive (and complex) answer, I believe TCL implements a cross-platform exec call. Alternatively, rethink the higher level - why are you joining a list of arguments in the first place? Could you respecify the higher level to not require the user to pass a list, but pass a command line on Windows? I believe that the key argument for argv in Unix is security - you don't go through the shell's (complex and powerful) command line splitting routines. On Windows, that argument is reversed - by supplying a command line, you don't go through an error-prone process of combining and resplitting. Hope this helps (but it probably doesn't :-)) Paul. From olson@mcs.anl.gov Mon Apr 7 12:29:01 2003 From: olson@mcs.anl.gov (Robert Olson) Date: Mon, 07 Apr 2003 06:29:01 -0500 Subject: [python-win32] win32process.CreateProcess alternative that takes an array In-Reply-To: <16E1010E4581B049ABC51D4975CEDB88619A2E@UKDCX001.uk.int.ato sorigin.com> Message-ID: <5.2.0.9.2.20030407062651.0211f2a0@pop.mcs.anl.gov> At 09:53 AM 4/7/2003 +0100, Moore, Paul wrote: >Creating a command line from an argv list in such a way that a >user program will recreate the same argv list is dependent on the >code used by the C runtime of the program called, and hence is >impossible in complete generality, although it's not hard for 99% >of cases. As long as you don't care much about what happens to >an argument like you're going >to be OK :-) The formula that I've stumbled onto that appears to work, even with arguments with embedded spaces, is this: ""cmdname" "arg1" "arg2" ..." where the string passed to os.spawn or os.popen is indeed entirely wrapped in quotes. I think this works because the argument is passed to cmd for execution.. The annoying thing is that this introduces a nonportability, where for win32 the whole thing is quoted, but for linux it cannot be. --bob From Paul.Moore@atosorigin.com Mon Apr 7 12:49:54 2003 From: Paul.Moore@atosorigin.com (Moore, Paul) Date: Mon, 7 Apr 2003 12:49:54 +0100 Subject: [python-win32] win32process.CreateProcess alternative that takes an array Message-ID: <16E1010E4581B049ABC51D4975CEDB880113D9F6@UKDCX001.uk.int.atosorigin.com> From: Robert Olson [mailto:olson@mcs.anl.gov] > The formula that I've stumbled onto that appears to work, even > with arguments with embedded spaces, is this: > ""cmdname" "arg1" "arg2" ..." > where the string passed to os.spawn or os.popen is indeed entirely > wrapped in quotes. The discussion is about CreateProcess, not os.spawn/os.popen. But I'd suspect that this will fail for os.popen if arg1 were to end in a backslash, or if it contained a double quote character. Paul From bjarrett@garcoschools.org Mon Apr 7 16:27:30 2003 From: bjarrett@garcoschools.org (Brian Jarrett) Date: Mon, 7 Apr 2003 08:27:30 -0700 Subject: [python-win32] UPDATE: need help in creating a username generator Message-ID: <0067E36738F75E4BB04832584BAED63C0168DC@localdns.garcoschools.org> OK, here's the code I've created so far. Keep in mind that I'm new to = python and am using what I've learned. If you have a more elegant (and = functional) way to do this, please enlighten me! *grin* One thing I = don't like is the limited way I can specify "slicing" operations. I = guess to be really fancy I'd have to define each rule element as a = function like was originally suggested to me. Any other ideas? #a sample dictionary for testing only #the keys used in the dictionary need to be referenced in rule elements. mydata =3D = {'fname':'Bob','mname':'Charles','lname':'Jones','gradyear':'2003'} #add rule elements here #must use the key used in the dictionary passed followed by a list #indicating the start and stop points of a slicing operation. To #specify the end of a string without knowing the actual length use '*' finitial =3D ['fname',[0,1]] # this element will take the first = character of fname lfull =3D ['lname',[0,'*']] # this element will take ALL of lname minitial =3D ['mname',[0,1]] # this element takes first character of = mname abbrgradyear =3D ['gradyear',[2,'*']] #this element takes the last 2 = characters of gradyear, #which should be a string of 4 = characters ALWAYS #now build rules from the rule elements #a rule element can be used in more than one rule student1 =3D [finitial, lfull, abbrgradyear] student2 =3D [finitial,minitial,lfull,abbrgradyear] employee1 =3D [finitial, lfull] employee2 =3D [finitial, minitial, lfull] #now build a ruleset placing the rules in the order you wish them to be = tried student =3D [student1,student2] employee =3D [employee1,employee2] #functions to handle rule elements =20 def renderelement(inputdata, element): text =3D inputdata[element[0]] lowerbound =3D element[1][0] upperbound =3D element[1][1] if upperbound =3D=3D '*': upperbound =3D len(text) return text[lowerbound:upperbound] def applyrule(inputdata,rule): fulltext =3D '' for ruleelement in rule: fulltext =3D fulltext + renderelement(inputdata,ruleelement) return fulltext =09 def applyruleset(inputdata,ruleset): ''' This function returns a list of strings created from the ruleset = selected ''' textlist =3D [] for rule in ruleset: textlist.append(applyrule(inputdata,rule)) return textlist -----Original Message----- From: d.w. harks [mailto:dave@psys.org] Sent: Friday, April 04, 2003 12:57 PM To: python-win32@python.org Subject: Re: [python-win32] need help in creating a username generator I do this, but not in nearly so flexible a manner. Guess I'm lazy. :-) I just have the function generate three different possible usernames, based on the user's first, middle and last names, and append the results to a list. I've never had the situation come up where I can't get a = unique username...but I work for a small university, and we only have about = 1500 users. Then, it checks each one against AD, and the first one that is not = already taken gets assigned to the user. I could see this working with a list of function references which could = be selected at runtime from a pool of available username-generation functions...i.e.: def stuOne(name): def stuTwo(name): def genUserName(name): funcList =3D [ stuOne, stuTwo, ...] # generate this with your setup = code optionList =3D [] for func in funcList: optionList.append(func(name)) Just a thought. dave Brian Jarrett said: > Hello all. > > I'm new to Python and I've been working on some scripts to automate = the > creation of user accounts on our network. I work in a school = district, so > I want the school secretaries to use a webpage to create student user > accounts and I will have the administrations staff create employee = user > accounts and email boxes. > > What I want to do is create some sort of object or function that would > take a variable number of "rules" and apply them to information = specified > (firstname, lastname, middle initial, graduation year) to come up with = a > username for the individual. If the first username is already used, = then > it would try applying the next "rule" until it came up with a unique = name. > Since I have two classes of users (Employees and Students) I will = have > two separate sets of rules. > > I already have code that checks my Active Directory to see if a = username > has not been used. I just need something to generate the username to > test. > > Of course I could hardcode how I'd want to slice up first and last = names, > etc, to get a username, but I thought I'd make it more flexible and = then > release it for others to use if they wanted. > > The rules I'd be using would be something like: > > Employees: > Try first initial + last name > Try first initial + middle initial + last name > > Students: > Try first initial + last name + last 2 digits of grad year > Try first initial + middle initial + last name + last 2 digits of grad > year > Try first two letters of first name + last name + last 2 digits of = grad > year > > Any ideas on how to do this would be appreciated. Mainly I'm = concerned > with making the rules persistent but easily changed and flexible = enough to > add/remove data to use and how to specify the use of said data. > > Brian Jarrett > Network Administrator > Garfield County School District 16 > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > --=20 d.w. harks http://dwblog.psys.org _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From bjarrett@garcoschools.org Mon Apr 7 22:33:18 2003 From: bjarrett@garcoschools.org (Brian Jarrett) Date: Mon, 7 Apr 2003 14:33:18 -0700 Subject: [python-win32] My username generator Message-ID: <0067E36738F75E4BB04832584BAED63C0168DD@localdns.garcoschools.org> Below is my code listing for generating a list of possible usernames. I = think I've made this modular enough to really work in just about any = situation that was needed. I changed the kludgy was I was defining what = to use in each string with a function so you can do whatever you want to = each string, get them all concatenated and then spit out a list of = these. I don't know if it could be used for things other than generating = usernames, but it should work. (Maybe generating a directory name for = user's web pages?) Again, if you see any way for me to further improve this, let me know. = I'm happy enough with it now to start using it as is. Brian P.S. Thanks for the tip of creating function lists, D.W. that did work = out well. start code ###################### import string #a sample dictionary for testing only #the keys used in the dictionary need to be referenced in rule elements. mydata =3D = {'fname':'Bob','mname':'Charles','lname':'Jones','gradyear':'2003'} #add rule elements here #these must be functions that will work with the value #of one key from the dictionary. def finitial(inputdata): ''' Takes first name and returns lowercase first letter ''' text =3D inputdata['fname'][0] text =3D string.lower(text) return text def lfull(inputdata): ''' Takes last name and returns it in lowercase ''' text =3D inputdata['lname'] text =3D string.lower(text) return text def minitial(inputdata): ''' Takes middle name and returns lowercase first letter ''' text =3D inputdata['mname'][0] text =3D string.lower(text) return text def abbrgradyear (inputdata): ''' Takes the graduation year and returns the last 2 digits ''' text =3D inputdata['gradyear'][2:] return text #now build rules from the rule elements #a rule element can be used in more than one rule #the rule elements will be applied in order student1 =3D [finitial, lfull, abbrgradyear] student2 =3D [finitial,minitial,lfull,abbrgradyear] employee1 =3D [finitial, lfull] employee2 =3D [finitial, minitial, lfull] #now build a ruleset placing the rules in the order you wish them to be = tried student =3D [student1,student2] employee =3D [employee1,employee2] #functions to handle rules def applyrule(inputdata, rule): ''' Returns a string made from the rule elements specified in the = rule''' fulltext =3D '' for func in rule: fulltext =3D fulltext + func(inputdata) return fulltext def applyruleset(inputdata,ruleset): ''' This function returns a list of strings created from the ruleset = selected ''' textlist =3D [] for rule in ruleset: textlist.append(applyrule(inputdata,rule)) return textlist From mhammond@skippinet.com.au Mon Apr 7 23:56:12 2003 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 8 Apr 2003 08:56:12 +1000 Subject: [python-win32] Re: How to create Windows directory shortcut from Python (answered) In-Reply-To: <5.2.0.9.0.20030318211443.02dd4e18@junk> Message-ID: While this is fine, it can be done without wshell - win32com.shell contains all you need, and I have posted such solutions to comp.lang.python a number of times. Mark > -----Original Message----- > From: python-win32-admin@python.org > [mailto:python-win32-admin@python.org]On Behalf Of G. Ken Holman > Sent: Wednesday, 19 March 2003 1:24 PM > To: python-win32@python.org > Subject: [python-win32] Re: How to create Windows directory shortcut > from Python (answered) > > > With many thanks to Paul Prescod who related the answer to me off-list, I > downloaded the Windows extensions found at: > > http://starship.python.net/crew/mhammond/win32/ > > and used the following code that created a directory shortcut on > my T drive > named "test" that points to the "ftemp" directory (also on T): > > import sys > import win32com.client > > shell = win32com.client.Dispatch("WScript.Shell") > shortcut = shell.CreateShortCut("t:\\test.lnk") > shortcut.Targetpath = "t:\\ftemp" > shortcut.save() > > Note that when I used "/" instead of "\\" in the pathnames the > shortcut was > *not* created properly. > > At 2003-03-17 15:34 -0500, I wrote: > >Hi! > > > >I'm wondering if anyone has figured out how to create a Windows > directory > >shortcut (Windows equivalent of a linked directory) from within a Python > >application. > > > >I can create a shortcut from the Windows Explorer by a right-click copy > >and selecting "Create Shortcuts Here" ... I'm looking for a Python > >solution to do the same action. > > > >I had anticipated the Windows implementation of os.symlink() would have > >done it, but there appears to be no implementation of os.symlink() under > >Windows. > > > >I could find nothing in a search of the archive of this list. > > > >Thanks for any help you can be! > > > >................. Ken > > > -- > Upcoming hands-on in-depth XSLT/XPath and/or XSL-FO > North America: June 16-20, 2003 > > G. Ken Holman mailto:gkholman@CraneSoftwrights.com > Crane Softwrights Ltd. http://www.CraneSoftwrights.com/z/ > Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) > ISBN 0-13-065196-6 Definitive XSLT and XPath > ISBN 0-13-140374-5 Definitive XSL-FO > ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath > ISBN 1-894049-10-1 Practical Formatting Using XSL-FO > Male Breast Cancer Awareness http://www.CraneSoftwrights.com/z/bc > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > From mhammond@skippinet.com.au Mon Apr 7 23:59:15 2003 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 8 Apr 2003 08:59:15 +1000 Subject: [python-win32] Indexing COM Objects In-Reply-To: <67B3A7DA6591BE439001F2736233351211E33E@XCH-NW-28.nw.nos.boeing.com> Message-ID: Com object pointers have a rule on how to test for identity, and win32com supports it. So ob._oleobj_ == ob2._oleobj_ will return true if the exact same underlying pointer is used for both objects. id() of these objects will *not*. Mark. > -----Original Message----- > From: python-win32-admin@python.org > [mailto:python-win32-admin@python.org]On Behalf Of Erignac, Charles A > Sent: Thursday, 27 March 2003 8:24 AM > To: Bob Gailer; python-win32@python.org > Subject: RE: [python-win32] Indexing COM Objects > > > I manipulate COM objects through their Python wrapper (static > dispatch). Supposing that myObject is such an object, would > id(myObject._oleobj_) return a unique key to the underlying COM object? > In other words, if I cast myObject into another wrapper class as in > myOtherObject = Cast(myObject,myOtherClass) > would myOtherObject._oleobj_ be the same object as myObject._oleobj_? > > Charles > > -----Original Message----- > From: Bob Gailer [mailto:bgailer@alum.rpi.edu] > Sent: Wednesday, March 26, 2003 12:36 PM > To: Erignac, Charles A; python-win32@python.org > Subject: Re: [python-win32] Indexing COM Objects > > > At 12:03 PM 3/26/2003 -0800, Erignac, Charles A wrote: > >I would like to use COM objects as keys for a dictionary. It seems that > >they do not have the indexing property. Is one of their property > a unique > >indexable key? > > AFAIK that's a nono. What are you trying to accomplish? Perhaps there's a > workaround. > > Bob Gailer > PLEASE NOTE NEW EMAIL ADDRESS bgailer@alum.rpi.edu > 303 442 2625 > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From mhammond@skippinet.com.au Tue Apr 8 00:02:19 2003 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 08 Apr 2003 09:02:19 +1000 Subject: [python-win32] Web-embeddable ActiveX In-Reply-To: <3E869716.1010903@prescod.net> Message-ID: > I was writing up a tutorial on how to embed Python binary COM controls > in web pages when I realized that I had only experienced "success" > because I had registered the control. Really, the web-embedded control > wasn't being downloaded at all. > > I need it to work in a download, like this: > > ID="stemTest" CODEBASE="stem.cab"> > > > I have a feeling that maybe I need an Installer built with this patch: > > http://trixie.triqs.com/pipermail/installer/2002-December/000233.html > > Is that the problem? Yep. There is a theory that "regsvr32" has extensions to allow Pythoncomxx.dll to do the registration for arbitary .py objects. While pythoncom has support for this, I have never digged into it in any detail - back when I looked at it, that regsvr support was very new and not widely deployed. > Let's say I build or borrow an appropriate set of > binaries, should I then expect that the right way to do this is to build > a CAB with cabarc or to build a monolithic DLL that represents the whole > control? I think the cab. I'd love to get this working well, and py2exe is on my list too - spambayes has given me a real life project to use it on :) Sorry for the delay, Mark. From mhammond@skippinet.com.au Tue Apr 8 00:14:31 2003 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 8 Apr 2003 09:14:31 +1000 Subject: [python-win32] "Casting" COM objects In-Reply-To: <3E8B3AB6.6060202@prescod.net> Message-ID: [Paul] > Consider the following case: > > class A: > def foo(self): pass > > class B(A): > def bar(self): pass > > class C(A): > def car(self): pass > > Now pretend Python had static typing: > > class Z: > def __init__(self, thing): > self.thing = thing > > def get_A() returns A: > return self.thing > > Now in statically typed languages like C or IDL, it is perfectly legal > for C to return a "B" because a B isa A. Then, client code casts from an > A reference to a B reference to get access to the bar() function. I think you are looking for the (fairly new) win32com.client.CastTo() method - this takes an object and a class name. I came across this in the Outlook object model: Outlook has a "CommandBarItem" object, and subclasses for different types of items (CommandBarPopup, CommandBarButton, etc). There is an "AddControl()" method that takes the type of the object as a param, but it is prototypes as returning the base "CommandBarItem". I call: ob = whatever.AddControl(..., type_popup,...) # ob is CommandBarItem ob = CastTo(ob, "CommandBarPopup") # ob is CommandBarPopup And magic happens :) 'ob' is different, but as per a previous coincidental post, they will compare equal. I *think* that is what you were asking :) Mark. From mhammond@skippinet.com.au Tue Apr 8 00:20:37 2003 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 8 Apr 2003 09:20:37 +1000 Subject: [python-win32] win32process.CreateProcess alternative that takes an array In-Reply-To: <5.2.0.9.2.20030407062651.0211f2a0@pop.mcs.anl.gov> Message-ID: I've nothing to add to Paul's exellent answer - at the end of the day, someone has to call CreateProcess[Ex](), as that is the only Windows API call to do it. > in quotes. I think this works because the argument is passed to cmd for > execution.. I don't think that is true. Python's os.popen() explicitly uses COMSPEC so that some vague shell semantics are maintained, but CreateProcess is the raw, low-level API that creates exactly what you ask. Mark. From paul@prescod.net Tue Apr 8 01:51:44 2003 From: paul@prescod.net (Paul Prescod) Date: Mon, 07 Apr 2003 17:51:44 -0700 Subject: [python-win32] "Casting" COM objects In-Reply-To: References: Message-ID: <3E921D20.2020802@prescod.net> Mark Hammond wrote: > I think you are looking for the (fairly new) win32com.client.CastTo() >... > > I *think* that is what you were asking :) Exatly. It is so new that my copy of pythonwin doesn't have it. But that's not a big deal, my workaround is good enough for now and I'll use this when the time comes. But over time, my question changed. It became: "how can I get dynamic behaviour out of a makepy'd class." One suggestion is that MakePy's __getattr__ could fall back to trying to do a dynamic dispatch. If you're going to raise an exception anyhow, you might as well be sure that the thing you're trying to do is going to fail. The downside of this is that it might allow people to inefficiently call methods that are missing in the static interface and not know why it is so slow. Case errors in particular might be worrisome. So perhaps we would add a keyword parameter to the MakePy class: "dynamicfallback = true". Once you turn this on, you get the convenience of dynamic dispatch but you may lose some performance when the static method isn't available. Another strategy might be to have a method called AsDynamic() or AsDispatch() that allows you to call methods that aren't in the statically generated interface. e.g. foo = bar.AsDynamic().bar() Except for the performance, I prefer all of these to CastTo (just a little) because they feel more like programming in Python (dynamic, performance is secondary) than like programming in Java (static, with type declarations and casts to ensure high performance). Paul Prescod From mhammond@skippinet.com.au Tue Apr 8 03:44:09 2003 From: mhammond@skippinet.com.au (Mark Hammond) Date: Tue, 8 Apr 2003 12:44:09 +1000 Subject: [python-win32] "Casting" COM objects In-Reply-To: <3E921D20.2020802@prescod.net> Message-ID: > > I *think* that is what you were asking :) > > Exatly. It is so new that my copy of pythonwin doesn't have it. But > that's not a big deal, my workaround is good enough for now and I'll use > this when the time comes. > > But over time, my question changed. It became: "how can I get dynamic > behaviour out of a makepy'd class." One suggestion is that MakePy's > __getattr__ could fall back to trying to do a dynamic dispatch. If > you're going to raise an exception anyhow, you might as well be sure > that the thing you're trying to do is going to fail. The downside of > this is that it might allow people to inefficiently call methods that > are missing in the static interface and not know why it is so slow. Case > errors in particular might be worrisome. I'm not sure this will work. The problem is the vague distinction between COM "classes" and "interfaces". In general, we can introspect all interfaces supported by a class. However, given just an interface, we often can't instrospect back to "what class do you belong to?". IDispatch does provide some help here, but longer term we want to support "vtable" interfaces being called, and ideally we should provide an identical interface to an object regardless of the access method. To take thus further, we can not assume that just because a given class nominates that is supports an interface, that all such interfaces are from that class. Given just the interface, we could start poking around to try and see if it really *is* one of those classes, but this doesn't sound right. To be quite honest, I am not 100% clear on how classes and interfaces really relate at an IDispatch level - a class looks very much like an interface from IDispatch's point of view - ie, the object returned from Dispatch() is generally a class - it is just that makepy generally converts it to the default interface. Unfortunately, my time is thin and no one else has recently contributed in a meaningful way to the COM work - too many things to work on, and not enough incentive :) I'd be more than happy to help anyone else with their efforts in cleaning some of this stuff up. In particular, what makes sense in a vtable enabled future. Mark. From theller@python.net Tue Apr 8 07:53:13 2003 From: theller@python.net (Thomas Heller) Date: 08 Apr 2003 08:53:13 +0200 Subject: [python-win32] Re: Web-embeddable ActiveX References: <3E869716.1010903@prescod.net> Message-ID: <8yulv5t2.fsf@python.net> Znex Unzzbaq jevgrf: > > V jnf jevgvat hc n ghgbevny ba ubj gb rzorq Clguba ovanel PBZ pbagebyf > > va jro cntrf jura V ernyvmrq gung V unq bayl rkcrevraprq "fhpprff" > > orpnhfr V unq ertvfgrerq gur pbageby. Ernyyl, gur jro-rzorqqrq pbageby > > jnfa'g orvat qbjaybnqrq ng nyy. > > > > V arrq vg gb jbex va n qbjaybnq, yvxr guvf: > > > > > VQ="fgrzGrfg" PBQRONFR="fgrz.pno"> > > > > > > V unir n srryvat gung znlor V arrq na Vafgnyyre ohvyg jvgu guvf cngpu: > > > > uggc://gevkvr.gevdf.pbz/cvcreznvy/vafgnyyre/2002-Qrprzore/000233.ugzy > > > > Vf gung gur ceboyrz? > > Lrc. Gurer vf n gurbel gung "ertfie32" unf rkgrafvbaf gb nyybj > Clgubapbzkk.qyy gb qb gur ertvfgengvba sbe neovgnel .cl bowrpgf. Juvyr > clgubapbz unf fhccbeg sbe guvf, V unir arire qvttrq vagb vg va nal qrgnvy - > onpx jura V ybbxrq ng vg, gung ertfie fhccbeg jnf irel arj naq abg jvqryl > qrcyblrq. > > > Yrg'f fnl V ohvyq be obeebj na nccebcevngr frg bs > > ovanevrf, fubhyq V gura rkcrpg gung gur evtug jnl gb qb guvf vf gb ohvyq > > n PNO jvgu pnonep be gb ohvyq n zbabyvguvp QYY gung ercerfragf gur jubyr > > pbageby? > > V guvax gur pno. V'q ybir gb trg guvf jbexvat jryy, naq cl2rkr vf ba zl > yvfg gbb - fcnzonlrf unf tvira zr n erny yvsr cebwrpg gb hfr vg ba :) Znex, V unir va zvaq n arj irefvba bs cl2rkr juvpu fubhyq fbyir dhvgr fbzr ceboyrzf. Orsber lbh fgneg gb jbex ba vg, or fher gb pbagnpg zr. Gubznf From theller@python.net Tue Apr 8 08:04:19 2003 From: theller@python.net (Thomas Heller) Date: 08 Apr 2003 09:04:19 +0200 Subject: [python-win32] Re: Web-embeddable ActiveX References: <3E869716.1010903@prescod.net> <8yulv5t2.fsf@python.net> Message-ID: Thomas Heller writes: > Znex Unzzbaq jevgrf: > > > > V jnf jevgvat hc n ghgbevny ba ubj gb rzorq Clguba ovanel PBZ pbagebyf > > > va jro cntrf jura V ernyvmrq gung V unq bayl rkcrevraprq "fhpprff" > > > orpnhfr V unq ertvfgrerq gur pbageby. Ernyyl, gur jro-rzorqqrq pbageby > > > jnfa'g orvat qbjaybnqrq ng nyy. [and so on]. It seems I cannot remember the key combo I have to hit to insert a CC: header with gnus. C-c C-r C-c wasn't correct, this sent out a rot-13 encoded version of the message I had in mind. Sorry for this, here is the decoded version: Mark Hammond writes: > > I was writing up a tutorial on how to embed Python binary COM controls > > in web pages when I realized that I had only experienced "success" > > because I had registered the control. Really, the web-embedded control > > wasn't being downloaded at all. > > > > I need it to work in a download, like this: > > > > > ID="stemTest" CODEBASE="stem.cab"> > > > > > > I have a feeling that maybe I need an Installer built with this patch: > > > > http://trixie.triqs.com/pipermail/installer/2002-December/000233.html > > > > Is that the problem? > > Yep. There is a theory that "regsvr32" has extensions to allow > Pythoncomxx.dll to do the registration for arbitary .py objects. While > pythoncom has support for this, I have never digged into it in any detail - > back when I looked at it, that regsvr support was very new and not widely > deployed. > > > Let's say I build or borrow an appropriate set of > > binaries, should I then expect that the right way to do this is to build > > a CAB with cabarc or to build a monolithic DLL that represents the whole > > control? > > I think the cab. I'd love to get this working well, and py2exe is on my > list too - spambayes has given me a real life project to use it on :) Mark, I have in mind a new version of py2exe which should solve quite some problems. Before you start to work on it, be sure to contact me. Thomas From BAlmond@russreid.com Tue Apr 8 17:50:29 2003 From: BAlmond@russreid.com (Brian Almond) Date: Tue, 08 Apr 2003 09:50:29 -0700 Subject: [python-win32] Definitive COM book? was:"Casting" COM objects Message-ID: > "Mark Hammond" >Unfortunately, my time is thin and no one else has >recently contributed in a meaningful way to the COM >work - too many things to work on, and not enough >incentive :) I'd be more than happy to help anyone >else with their efforts in cleaning some of this stuff >up. In particular, what makes sense in a vtable >enabled future. A little OT, but something your comments made me think of: What is the current, definitive book on COM? (For the people who would like to some day contribute to things like the above. That is, what is the best reference available for a "COM tools" implementor.) I seem to recall hearing positive things about Don Box's "Essential COM" in the past, but I don't know if it has been surpassed by other books in the time since it was first published. (If it matters - I'm currently not working with .NET at all, but could be in the future.) -Brian From jens.jorgensen@tallan.com Tue Apr 8 21:04:29 2003 From: jens.jorgensen@tallan.com (Jens B. Jorgensen) Date: Tue, 08 Apr 2003 15:04:29 -0500 Subject: [python-win32] Definitive COM book? was:"Casting" COM objects In-Reply-To: References: Message-ID: <3E932B4D.60404@tallan.com> Brian Almond wrote: >>"Mark Hammond" >>Unfortunately, my time is thin and no one else has >>recently contributed in a meaningful way to the COM >>work - too many things to work on, and not enough >>incentive :) I'd be more than happy to help anyone >>else with their efforts in cleaning some of this stuff >>up. In particular, what makes sense in a vtable >>enabled future. >> >> > >A little OT, but something your comments made >me think of: > >What is the current, definitive book on COM? >(For the people who would like to some day >contribute to things like the above. That is, >what is the best reference available for a >"COM tools" implementor.) > >I seem to recall hearing positive things about >Don Box's "Essential COM" in the past, but I >don't know if it has been surpassed by other >books in the time since it was first published. > >(If it matters - I'm currently not working with >.NET at all, but could be in the future.) > >-Brian >python-win32 > > Don't know how other's on this list feel but I consider "Essential COM" to be just as the title suggests. The only thing I don't like is Don's explanation of apartments. I'm not saying there is anything wrong with it except for the fact that for the way my brain works it didn't gel for me. -- 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 mhammond@skippinet.com.au Wed Apr 9 01:21:44 2003 From: mhammond@skippinet.com.au (Mark Hammond) Date: Wed, 9 Apr 2003 10:21:44 +1000 Subject: [python-win32] Definitive COM book? was:"Casting" COM objects In-Reply-To: <3E932B4D.60404@tallan.com> Message-ID: > Don't know how other's on this list feel but I consider > "Essential COM" to be just as the title suggests. The only thing > I don't like is Don's explanation of apartments. I'm not saying > there is anything wrong with it except for the fact that for the > way my brain works it didn't gel for me. I'm not surprised! I found the tiny section on COM apartments the hardest part of our book to write. Mark. From mhammond@skippinet.com.au Wed Apr 9 01:21:41 2003 From: mhammond@skippinet.com.au (Mark Hammond) Date: Wed, 9 Apr 2003 10:21:41 +1000 Subject: [python-win32] Re: Web-embeddable ActiveX In-Reply-To: Message-ID: > It seems I cannot remember the key combo I have to hit to insert a CC: > header with gnus. C-c C-r C-c wasn't correct, this sent out a rot-13 > encoded version of the message I had in mind. Sorry for this, here is > the decoded version: That would have been funny enough on its own, as a "cute sig" people collect. The fact that I actually saw it happen 2 seconds ago made it excruciatingly funny :) I'm sure there is a lesson in there somewhere, but not sure what it is :) Mark. From duanev@io.com Tue Apr 8 17:26:39 2003 From: duanev@io.com (duane voth) Date: Tue, 8 Apr 2003 11:26:39 -0500 Subject: [python-win32] how do I sink Mscomm32 events? Message-ID: <20030408112639.A3888@io.com> After studying everything I can find via google on python-win32, mscomm32, and DispatchWithEvents, I've pieced together the following test code: >>> from win32com.client import DispatchWithEvents >>> class CommEvents: def OnComm(self): print self >>> com1 = DispatchWithEvents('MSCOMMLib.MSComm.1', CommEvents) >>> com1.CommPort = 1 >>> com1.Settings = "115200,N,8,1" >>> com1.PortOpen = 1 >>> com1.InputLen = 0 >>> com1.Handshaking = 2 >>> com1.RTSEnable = 1 >>> com1.Output = "ATDT555-1234" + chr(13)+'\n\n' >>> print 'Event:', com1.CommEvent Event: 0 >>> com1.InBufferCount 3 >>> There are no errors, and "ATDT555-1234" is sent to device attached to my COM1 port, but I don't get any events. I'm expecting to see some kind of output from the print in OnComm whenever a character is received by the COM1 serial port. Must I do something to get the dispatcher to run? (I'm quite COM illiterate) Are threads assumed to exist or must I create them, enabled them, or unblock them? Duane From mcfadden@ford-consulting.com Wed Apr 9 18:31:50 2003 From: mcfadden@ford-consulting.com (Dudley McFadden) Date: Wed, 9 Apr 2003 10:31:50 -0700 Subject: [python-win32] VB COM tip: watch out for mixed case Message-ID: This is a multi-part message in MIME format. ------=_NextPart_000_000C_01C2FE83.54D6F660 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit (KUDOS) I am new to Python and am writing my first COM-aware Python script that does some "real work" (i.e. generating some revenue for my firm). I want to say how *easy* it is to do COM in Python thanks to many of you out there. I am impressed with the functionality of modules such as gencache and they save me a lot of effort. For example, I changed one of the interfaces in a Visual Basic COM server, and Python picked it up and automatically upgraded the MinorVersion at run time without my lifting a finger. Bravo. Now, a note to others dealing with VB6 COM DLLs: I had a truly annoying bug and after three hours of trial and error I discovered why. It lies in the way VB maintains upper and lower case in public methods and properties. As you know, VB and COM are case-insensitive, whereas Python is case-sensitive. However, (and this is helpful when you are aware it is happening) VB "auto-changes" case on your Property and Sub and Funtion names. This doesn't always happen consistently with Class names: you can change the case of Class names in the .cls file, but at compile time it uses the case of the class names in the .vbp file. (Or, the other way around, particularly if you check files in and out using Visual SourceSafe 5). However, for interfaces that are Implemented (meaning, you have "Private Sub Interface_Method" methods in your "Multiuse" CoClasses), the case of the Method name is not automatically made consistent. Example: I had properties named "PathName" and "Pathname" (inconsistently) which did not get cannonized to either form. Module win32com created wrappers with whatever case got compiled in to the VB DLL. I had difficulty accessing those methods from Python. Then, truly irksome, when I returned to VB and tried to manually make these names consistently cased (that is, rename them all to "Pathname"), VB sometimes unexpectedly them back to "PathName" when compiling. Curses! Summary: if your win32 COM Python script accesses some methods and properties in a VB DLL but balks at others, confirm that (1) the DLL's wrapper script in the gen_py folder, (2) your VB source code, and (3) the compiled VB DLL are using names with consistent case. Dudley McFadden David Ford Consulting Engineers, Inc. Sacramento, California, US ------=_NextPart_000_000C_01C2FE83.54D6F660 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable VB COM tip: watch out for mixed case

(KUDOS) I am new to Python and am writing my first = COM-aware Python script that does some "real work" (i.e. = generating some revenue for my firm).  I want to say how *easy* it = is to do COM in Python thanks to many of you out there. I am impressed = with the functionality of modules such as gencache and they save me a = lot of effort. For example, I changed one of the interfaces in a Visual = Basic COM server, and Python picked it up and automatically upgraded the = MinorVersion at run time without my lifting a finger.  = Bravo.

Now, a note to others dealing with VB6 COM DLLs: I had = a truly annoying bug and after three hours of trial and error I = discovered why. It lies in the way VB maintains upper and lower case in = public methods and properties.

As you know, VB and COM are case-insensitive, whereas = Python is case-sensitive.  However, (and this is helpful when you = are aware it is happening) VB "auto-changes" case on your = Property and Sub and Funtion names.  This doesn't always happen = consistently with Class names:  you can change the case of Class = names in the .cls file, but at compile time it uses the case of the = class names in the .vbp file. (Or, the other way around, particularly if = you check files in and out using Visual SourceSafe 5).  However, = for interfaces that are Implemented (meaning, you have "Private Sub = Interface_Method" methods in your "Multiuse" CoClasses), = the case of the Method name is not automatically made consistent.  =

Example:  I had properties named = "PathName" and "Pathname" (inconsistently) which did = not get cannonized to either form. Module win32com created wrappers with = whatever case got compiled in to the VB DLL. I had difficulty accessing = those methods from Python. Then, truly irksome, when I returned to VB = and tried to manually make these names consistently cased (that is, = rename them all to "Pathname"), VB sometimes unexpectedly them = back to "PathName" when compiling. Curses!

Summary: if your win32 COM Python script accesses some = methods and properties in a VB DLL but balks at others, confirm that (1) = the DLL's wrapper script in the gen_py folder, (2) your VB source code, = and (3) the compiled VB DLL are using names with consistent = case.

Dudley McFadden
David Ford Consulting Engineers, Inc.
Sacramento, California, US

------=_NextPart_000_000C_01C2FE83.54D6F660-- From Michael.Nugent@Cendant-TRG.com Wed Apr 9 20:55:05 2003 From: Michael.Nugent@Cendant-TRG.com (Nugent, Michael) Date: Wed, 9 Apr 2003 15:55:05 -0400 Subject: [python-win32] Creating a URL link Message-ID: <840C139B79E7CC4496B2594E9E35E96794F633@floexmailbe2.ffci.com> Creating a URL link

I am trying to create a URL link with = these properties:

[InternetShortcut]
URL=3Dhttp://www.xyz.com/fasst/
IconIndex=3D0
IconFile=3DC:\C\FASST_icon.ico

I have attempted to use win32com.shell, = but that seems to address .lnk shortcuts and not .url
Web searches only find scripts for = .lnk
Any suggestions would be = appreciated.
Thanks
Mike

From softex@hn.vnn.vn Thu Apr 10 03:10:28 2003 From: softex@hn.vnn.vn (Hung, Le Khanh) Date: Thu, 10 Apr 2003 09:10:28 +0700 Subject: [python-win32] how to save a dictionary (as is) Message-ID: <000e01c2ff06$6de8dfa0$5919a8c0@hungsoftex> This is a multi-part message in MIME format. ------=_NextPart_000_000B_01C2FF41.077A5510 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Dear friends! I don't know how to save a dictionary (as is) to a file and load it = afterward. Please help me! Thanks Hung ------=_NextPart_000_000B_01C2FF41.077A5510 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Dear friends!
I don't know how to save a dictionary = (as is) to a=20 file and load it afterward.
Please help me!
Thanks
Hung
------=_NextPart_000_000B_01C2FF41.077A5510-- From Paul.Moore@atosorigin.com Thu Apr 10 14:58:30 2003 From: Paul.Moore@atosorigin.com (Moore, Paul) Date: Thu, 10 Apr 2003 14:58:30 +0100 Subject: [python-win32] how to save a dictionary (as is) Message-ID: <16E1010E4581B049ABC51D4975CEDB880113DA0F@UKDCX001.uk.int.atosorigin.com> This is a multi-part message in MIME format. ------_=_NextPart_001_01C2FF69.443EB648 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Check out the pickle module (in the standard library). This isn't = particularly a Win32 issue. Paul. -----Original Message----- From: Hung, Le Khanh [mailto:softex@hn.vnn.vn] Sent: 10 April 2003 03:10 To: python-win32@python.org Subject: [python-win32] how to save a dictionary (as is) Dear friends! I don't know how to save a dictionary (as is) to a file and load it = afterward. Please help me! Thanks Hung ------_=_NextPart_001_01C2FF69.443EB648 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Check out the pickle module (in the standard library). This = isn't=20 particularly a Win32 issue.
Paul.
-----Original Message-----
From: Hung, Le Khanh=20 [mailto:softex@hn.vnn.vn]
Sent: 10 April 2003 = 03:10
To:=20 python-win32@python.org
Subject: [python-win32] how to save = a=20 dictionary (as is)

Dear friends!
I don't know how to save a dictionary = (as is) to=20 a file and load it afterward.
Please help me!
Thanks
Hung
------_=_NextPart_001_01C2FF69.443EB648-- From KKGOLFER@aol.com Thu Apr 10 16:31:36 2003 From: KKGOLFER@aol.com (KKGOLFER@aol.com) Date: Thu, 10 Apr 2003 11:31:36 -0400 Subject: [python-win32] Help with a report generator Message-ID: <5C36072A.41F032CC.006F9B01@aol.com> Has anyone used Python to generate reports.....specifically, I need to take tables and graphs out of an Excel Workbook and put them into various slides in a PowerPoint file. Has anyone done that? I had just about decided that Python was not a good tool for this.....that there are other, simpler ways, like hyperlinks. But am willing to give it a try if the consensus is this is a good use of Python to automate this process. I am new to Python and do not have a programming background, but thought if I had code that was similar, I could modify it. Thank you. From nugentm@myrealbox.com Thu Apr 10 19:06:25 2003 From: nugentm@myrealbox.com (Mike Nugent) Date: Thu, 10 Apr 2003 14:06:25 -0400 Subject: [python-win32] Creating a URL link Message-ID: <1049997985.a2b94600nugentm@myrealbox.com> I have attempted to use win32com.shell, but that seems to address .lnk shor= tcuts and not .url. Web searches only find scripts for .lnk Any suggestions would be appreciated. Thanks Mike Sorry about the previous HTML post. From bgailer@alum.rpi.edu Thu Apr 10 20:29:24 2003 From: bgailer@alum.rpi.edu (Bob Gailer) Date: Thu, 10 Apr 2003 13:29:24 -0600 Subject: [python-win32] Help with a report generator In-Reply-To: <5C36072A.41F032CC.006F9B01@aol.com> Message-ID: <5.2.0.9.0.20030410115227.03a5dec0@66.28.54.253> --=======5880361======= Content-Type: text/plain; x-avg-checked=avg-ok-78695C68; charset=us-ascii; format=flowed Content-Transfer-Encoding: 8bit At 11:31 AM 4/10/2003 -0400, KKGOLFER@aol.com wrote: > I need to take tables and graphs out of an Excel Workbook and put them > into various slides in a PowerPoint file. Using win32com.client you can create instances of excel and powerpoint, then use VBA commands to extract things from excel and add them to powerpoint. Try thsi: import win32com.client ex = win32com.client.Dispatch("excel.application") ex.visible = 1 # so you can see the application wb = ex.workbooks.open('c:\\foo.xls') wk = ex.Worksheets(1) # worksheet chartobject1 = wk.chartobjects(1) chartobject1.Copy() pp = win32com.client.Dispatch("powerpoint.application") pp.visible=1 pt = pp.presentations.open('c:\\foo.ppt') sl = pt.slides(1) pp.activewindow.view.paste() This is only an example. VBA provides a lot more functionality. Bob Gailer bgailer@alum.rpi.edu 303 442 2625 --=======5880361======= Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-78695C68 Content-Disposition: inline --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.467 / Virus Database: 266 - Release Date: 4/1/2003 --=======5880361=======-- From gumbright at taltrade.com Fri Apr 11 14:46:16 2003 From: gumbright at taltrade.com (Guy Umbright) Date: Fri Apr 11 14:46:21 2003 Subject: [python-win32] Prob w/ win32com under XP (very weird) Message-ID: <45CE1FBFCDAD2E4DA84B49F2F866FC4F18321F@talchiexch02.taltrade.com> (a little longish, sorry) I have COM based test harness for a component I am responsible that I script with python, hence win32com. I recently install WinXP Pro and reinstalled Python 2.2.2 (along with win32com). None of my scripts will work now (but that isn't the weird part...) All my scripts start with the following: Now when I try to run them, I get an error (from the annoying little 'send us the error' dialog) AppName: python.exe AppVer: 0.0.0.0 ModName: python22.dll ModVer: 2.2.2150.1011 Offset: 00039e79 So as a sanity check I went to the command line and into interactive mode and did: >> from win32com.client import Dispatch I get the same crash. Damn. OK lets try >> import win32com.client Hey that seems OK, lets try again just for laughs: >> from win32com.client import Dispatch It works this time! So this sequence works in interactive mode. >> import win32com.client >> from win32com.client import Dispatch >> pycomhack = Dispatch("myCOMthingy.myCOMthingy") >> pycomhack.SetSession("A",4) The SetSession call works fine (as do any others). So I put it into a script and try it, same error. and if I trim it down, it still dies on the "from win32com..." line. Honestly I am not sure where to begin. I know I can build python debug and run it in the debugger, but I figured I would ask before I resort to that (though I suspect I will have to). Does anyone have any ideas of what to look at before I go there? Or pehaps someone has experienced something similar? All punditry happily accepted. Thanks Guy Umbright This electronic mail message and any attached files contain information intended for the exclusive use of the individual or entity to whom it is addressed and may contain information that is proprietary, privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any viewing, copying, disclosure or distribution of this information may be subject to legal restriction or sanction. Please notify the sender, by electronic mail or telephone, of any unintended recipients and delete the original message without making any copies. From gumbright at taltrade.com Fri Apr 11 15:01:15 2003 From: gumbright at taltrade.com (Guy Umbright) Date: Fri Apr 11 15:26:05 2003 Subject: [python-win32] Prob w/ win32com under XP (very weird) - addenda Message-ID: <45CE1FBFCDAD2E4DA84B49F2F866FC4FF68680@talchiexch02.taltrade.com> A little more fiddling reveals that: works just fine as a script. So the core problem here is for some reason it doesn't like: from win32com.client import Dispatch in a script anymore. [====start original message====] (a little longish, sorry) I have COM based test harness for a component I am responsible that I script with python, hence win32com. I recently install WinXP Pro and reinstalled Python 2.2.2 (along with win32com). None of my scripts will work now (but that isn't the weird part...) All my scripts start with the following: Now when I try to run them, I get an error (from the annoying little 'send us the error' dialog) AppName: python.exe AppVer: 0.0.0.0 ModName: python22.dll ModVer: 2.2.2150.1011 Offset: 00039e79 So as a sanity check I went to the command line and into interactive mode and did: >> from win32com.client import Dispatch I get the same crash. Damn. OK lets try >> import win32com.client Hey that seems OK, lets try again just for laughs: >> from win32com.client import Dispatch It works this time! So this sequence works in interactive mode. >> import win32com.client >> from win32com.client import Dispatch >> pycomhack = Dispatch("myCOMthingy.myCOMthingy") >> pycomhack.SetSession("A",4) The SetSession call works fine (as do any others). So I put it into a script and try it, same error. and if I trim it down, it still dies on the "from win32com..." line. Honestly I am not sure where to begin. I know I can build python debug and run it in the debugger, but I figured I would ask before I resort to that (though I suspect I will have to). Does anyone have any ideas of what to look at before I go there? Or pehaps someone has experienced something similar? All punditry happily accepted. Thanks Guy Umbright This electronic mail message and any attached files contain information intended for the exclusive use of the individual or entity to whom it is addressed and may contain information that is proprietary, privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any viewing, copying, disclosure or distribution of this information may be subject to legal restriction or sanction. Please notify the sender, by electronic mail or telephone, of any unintended recipients and delete the original message without making any copies. From mhammond at skippinet.com.au Sat Apr 12 14:26:09 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri Apr 11 23:27:10 2003 Subject: [python-win32] ANNOUNCE: Python for Windows extensions now at SourceForge Message-ID: <3E978751.5060800@skippinet.com.au> The Python for Windows extensions are now hosted at SourceForge. The project page can be located via https://pywin32.sourceforge.net This will mean nothing to most people. The win32all packages will still be downloaded from my starship page. However, the following does change: * I will be tracking all bugs at sourceforge. I still have plenty of bugs to add out of my inbox, but in the meantime, add your favourite! There is a mailing list for bugs at: https://lists.sourceforge.net/lists/listinfo/pywin32-bugs * The CVS repository has now moved to sourceforge. The old pythonpros repository currently still works, but no further updates will be made there. See the CVS instructions at the sourceforge page (noting that along with the "Root", the top directory name has also changed from "PyWin32" to "pywin32".) * CVS checkin messages will now also be managed by sourceforge. Unfortunately, I am not able to bulk-subscribe the current subscribers to the new list. So everyone subscribed to win32-checkins@pythonpros.com (CCd) will need to re-subscribe at: https://lists.sourceforge.net/lists/listinfo/pywin32-checkins Many thanks to Greg Stein, who has kindly managed the existing CVS repository and mailing list for the last many years, and spent a lot of time on administration! Cheers, Mark. From bjarrett at garcoschools.org Mon Apr 14 08:08:23 2003 From: bjarrett at garcoschools.org (Brian Jarrett) Date: Mon Apr 14 10:08:59 2003 Subject: [python-win32] Prob w/ win32com under XP (very weird) - addenda Message-ID: <0067E36738F75E4BB04832584BAED63C016C1C@localdns.garcoschools.org> I had a problem similar to this on an XP workstation recently. I had found that when I was using PythonWin as my editor, that it was having problem with indents and I would get an error message in the interactive window sometimes when hitting . I turned on the End-of-Line markers and found that some of my lines had only a "CR" showing at the end, not a "CR LF". I had to go to the end of the line, delete and then hit again to get it to show up correctly. I've also had problems with trying to import other .py files that were in the same directory. I would get a "not found" error unless I opened up the referenced file and saved. Then the original script doing the import would find the file just fine. I hope this helps some, just a few other wierd things I've found in working with Python. I'm using ActivePython 2.2.2 by the way. Brian -----Original Message----- From: Guy Umbright [mailto:gumbright@taltrade.com] Sent: Friday, April 11, 2003 1:01 PM To: python-win32@python.org Subject: [python-win32] Prob w/ win32com under XP (very weird) - addenda A little more fiddling reveals that: works just fine as a script. So the core problem here is for some reason it doesn't like: from win32com.client import Dispatch in a script anymore. [====start original message====] (a little longish, sorry) I have COM based test harness for a component I am responsible that I script with python, hence win32com. I recently install WinXP Pro and reinstalled Python 2.2.2 (along with win32com). None of my scripts will work now (but that isn't the weird part...) All my scripts start with the following: Now when I try to run them, I get an error (from the annoying little 'send us the error' dialog) AppName: python.exe AppVer: 0.0.0.0 ModName: python22.dll ModVer: 2.2.2150.1011 Offset: 00039e79 So as a sanity check I went to the command line and into interactive mode and did: >> from win32com.client import Dispatch I get the same crash. Damn. OK lets try >> import win32com.client Hey that seems OK, lets try again just for laughs: >> from win32com.client import Dispatch It works this time! So this sequence works in interactive mode. >> import win32com.client >> from win32com.client import Dispatch >> pycomhack = Dispatch("myCOMthingy.myCOMthingy") >> pycomhack.SetSession("A",4) The SetSession call works fine (as do any others). So I put it into a script and try it, same error. and if I trim it down, it still dies on the "from win32com..." line. Honestly I am not sure where to begin. I know I can build python debug and run it in the debugger, but I figured I would ask before I resort to that (though I suspect I will have to). Does anyone have any ideas of what to look at before I go there? Or pehaps someone has experienced something similar? All punditry happily accepted. Thanks Guy Umbright This electronic mail message and any attached files contain information intended for the exclusive use of the individual or entity to whom it is addressed and may contain information that is proprietary, privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any viewing, copying, disclosure or distribution of this information may be subject to legal restriction or sanction. Please notify the sender, by electronic mail or telephone, of any unintended recipients and delete the original message without making any copies. _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From paul at prescod.net Mon Apr 14 09:09:44 2003 From: paul at prescod.net (Paul Prescod) Date: Mon Apr 14 11:10:18 2003 Subject: [python-win32] Web-embeddable ActiveX In-Reply-To: References: Message-ID: <3E9ACF38.4030107@prescod.net> Mark Hammond wrote: > ... >>Let's say I build or borrow an appropriate set of >>binaries, should I then expect that the right way to do this is to build >>a CAB with cabarc or to build a monolithic DLL that represents the whole >>control? > > I think the cab. I'd love to get this working well, and py2exe is on my > list too - spambayes has given me a real life project to use it on :) I'm not clear on whether you're saying that you've built Active-X CABs and they work okay (with the installer patch) or whether you want to make them work okay when you get an opportunity. Paul Prescod From lbates at syscononline.com Wed Apr 16 13:47:32 2003 From: lbates at syscononline.com (Larry Bates) Date: Wed Apr 16 13:51:33 2003 Subject: [python-win32] py2exe and services Message-ID: <03e201c30440$42295950$3f00a8c0@larrywxp> Does anyone know of a way to install py2exe services and have them start automatically (e.g. like the --start auto install option you can use on regular Python services). I want my services to restart if the server gets rebooted and would prefer not to be forced to manually modify the service through services manager control panel applet). Seems that py2exe doesn't have many of the options found on command line for regular Python services. I also seem to be forced into using NET START/STOP to start py2exe services because the .EXE can't seem to start itself. If I execute it stand alone I get: syncusersservice.exe syncusersservice.exe - Python Service Manager Options: -install - Install this service. -remove - Remove this service. -debug [parms] - debug the service. Starting service - this may take several seconds - please wait... Could not start the service - error 997 I'm hoping someone out there has already encountered/solved this problem. Thanks in advance. Regards, Larry Bates Syscon, Inc. From scottprive at earthlink.net Wed Apr 16 19:54:28 2003 From: scottprive at earthlink.net (Scott Prive) Date: Wed Apr 16 18:33:43 2003 Subject: [python-win32] win32net.NetUseAdd buglet (or doc buglet) Message-ID: <006101c3046b$236ca3c0$0601a8c0@scottprive.com> Hello, Under Python 2.2.2 (ActiveState) I'm attempting to use win32net.NetUseAdd... I think there's a bug in the API wrapper. The module/method docs I found on ActiveState for win32net.NetUseAdd, state that share info is passed to the function in the form of a dictionary. There's no example usage [sorry to complain, wish there were...] but it does point me to MSDN for more info. The problem? The MSDN documentation has example usage (share path, user, password etc.). But in their example they call password, "password".... the Pythin win32 wrapper doesn't understand ['password'] (and does not raise an exception on its use), but it DOES understand ['passwd']. So either MSDN is wrong or the wrapper's got a buglet. :-) I'm new but learning, so my follow-up to this is, "Is there a way I could have verified the argument requirements of a function"? In this case, I could not find a .py file... I could only find win32net.pyd binary file (and perhaps there would have been a command to query a function's needs, in the dubugger) -Scott The code looks like: import win32net data = {} data['remote'] = r'\\mypdc.example.com\myshare' data['local'] = 'Z:' data['password'] = 'foo' # This will FAIL with "bad password or username" # data['passwd'] = 'foo' data['user'] = 'foo' data['asg_type'] = 0 win32net.NetUseAdd(None,1,data) -Scott From scottprive at earthlink.net Thu Apr 17 00:36:21 2003 From: scottprive at earthlink.net (Scott Prive) Date: Wed Apr 16 23:15:41 2003 Subject: [python-win32] win32net.NetUseAdd buglet (or doc buglet) References: <020501c3046d$5115dec0$530f8490@eden> Message-ID: <007001c30492$8444bee0$0601a8c0@scottprive.com> ----- Original Message ----- From: "Mark Hammond" To: "'Scott Prive'" Sent: Wednesday, April 16, 2003 7:10 PM Subject: RE: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > > that share info is passed to the function in the form of a dictionary. > > There's no example usage [sorry to complain, wish there > > were...] but it does > > point me to MSDN for more info. > > I think you will find examples in the Python Programming on Win32 book. Actually I -have- your book :-) Until I finish Lutz' Programming Python, your Win32 is serving as a reference (it's next tho!). Searching the index, I did not see win32net.NetUseAdd (other win32net relatives are listed). ... It could be an index omission, in which case I'll see it eventually. > > > > > The problem? > > > > The MSDN documentation has example usage (share path, user, > > password etc.). > > But in their example they call password, "password".... the > > Pythin win32 > > wrapper doesn't understand ['password'] (and does not raise > > an exception on > > its use), but it DOES understand ['passwd']. > > > > So either MSDN is wrong or the wrapper's got a buglet. :-) > > None of these wrappers raise an exception on a bad attribute name - they > should. But in this case, the attribute is certainly named "password". I > expect that simply the underlying Win32 call is failing for you. > > Mark. I'm certain it appears only to work with 'passwd', but if something's going on under the hood it's quite interesting. Below is an interactive session, followed by the actual code. You can see the difference between the two functions is the password entry. I've tried this with other accounts. The same credentials were tested under CMD.EXE using 'net use'. The accounts exist on a win2K Server PDC, which is the same server I'm mounting the share from. Each time I tested, I started from a clean slate and verified nothing (at all) is listed under plain 'net use' When I get a mount from my function (under 'passwd'), I validate it by echoing text to a file on Z:\test.txt. If the 'password' function ran, which never provided a mount, this step yields a "system cannot find the path specified." Any thoughts? Thanks. -Scott ---------- interactive ------------ E:\scott\Komodo\ntlm_cifs>dir z: The system cannot find the path specified. E:\scott\Komodo\ntlm_cifs>python ActivePython 2.2.2 Build 224 (ActiveState Corp.) based on Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from testmap import * >>> mountShare >>> mountShare() This drive letter was in use, so I'll unmount it Good. Verified drive letter is not already mounted. Traceback (most recent call last): File "", line 1, in ? File "testmap.py", line 20, in mountShare win32net.NetUseAdd(None,1,data) pywintypes.api_error: (1326, 'NetUseAdd', 'Logon failure: unknown user name or b ad password.') >>> mountShare2() This drive letter was in use, so I'll unmount it Good. Verified drive letter is not already mounted. >>> ----------------code--------------- #!/usr/bin/python import string, sys, win32file, win32net def mountShare(): """A CIFS mount interface, wraps win32 API call NetUseAdd""" #see ASPN docs win32wnet.NetUseAdd and win32net.NetUseAdd try: print "This drive letter was in use, so I'll unmount it" unmountShare() except: print 'Good. Verified drive letter is not already mounted. ' data = { 'remote' : r'\\rogue.scottprive.com\account1', 'local' : 'Z:', 'password' : 'foo', 'user' : 'foo', 'asg_type' : 0, } win32net.NetUseAdd(None,1,data) def mountShare2(): """A CIFS mount interface, wraps win32 API call NetUseAdd""" #see ASPN docs win32wnet.NetUseAdd and win32net.NetUseAdd try: print "This drive letter was in use, so I'll unmount it" unmountShare() except: print 'Good. Verified drive letter is not already mounted. ' data = { 'remote' : r'\\rogue.scottprive.com\account1', 'local' : 'Z:', 'passwd' : 'foo', 'user' : 'foo', 'asg_type' : 0, } win32net.NetUseAdd(None,1,data) def unmountShare(): win32net.NetUseDel(None,'Z:',0) def main(): mountShare() mountShare2() if __name__ == '__main__': main() From lin at centurysoftware.com.my Thu Apr 17 19:44:17 2003 From: lin at centurysoftware.com.my (Norlin Abd Rahim) Date: Thu Apr 17 06:42:27 2003 Subject: [python-win32] Access and python Message-ID: <3E9E8581.4010605@centurysoftware.com.my> Hi, Is it possible to do Database Utilities > Compact and Repair database in Access using python?..If it can be done, how? TIA From theller at python.net Thu Apr 17 14:28:13 2003 From: theller at python.net (Thomas Heller) Date: Thu Apr 17 09:28:14 2003 Subject: [python-win32] Re: py2exe and services References: <03e201c30440$42295950$3f00a8c0@larrywxp> Message-ID: "Larry Bates" writes: > Does anyone know of a way to install py2exe services and have > them start automatically (e.g. like the --start auto install > option you can use on regular Python services). I want my > services to restart if the server gets rebooted and would prefer > not to be forced to manually modify the service through services > manager control panel applet). Seems that py2exe doesn't have > many of the options found on command line for regular Python > services. I also seem to be forced into using NET START/STOP to > start py2exe services because the .EXE can't seem to start > itself. If I execute it stand alone I get: > > syncusersservice.exe > syncusersservice.exe - Python Service Manager > Options: > -install - Install this service. > -remove - Remove this service. > -debug [parms] - debug the service. > > Starting service - this may take several seconds - please wait... > Could not start the service - error 997 > > I'm hoping someone out there has already encountered/solved this > problem. I did only provide the absolute minimum needed (install and remove a service), because this is all implemented in C (and actually copied from the win32all sources). The rest can be configured from the control panel services applet. Better than to reimplement in C the functionality which is already in win32serviceutil.py would be to change the C code to call win32serviceutil. But I have no time currently for py2exe, unfortunately. Another great idea would be to rewrite PythonService.cpp with ctypes. This would even make the special casing for services in py2exe unneeded. Thomas From bgailer at alum.rpi.edu Thu Apr 17 11:04:46 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Thu Apr 17 12:04:55 2003 Subject: [python-win32] Access and python In-Reply-To: <3E9E8581.4010605@centurysoftware.com.my> Message-ID: <5.2.0.9.0.20030417100129.01a158e8@66.28.54.253> At 06:44 PM 4/17/2003 +0800, Norlin Abd Rahim wrote: >Is it possible to do Database Utilities > Compact and Repair database in >Access using python? For Access 2000 and (I assume) later: >>> import win32com.client >>> a = win32com.client.Dispatch("access.application") >>> a.DBEngine.CompactDatabase("c:\\db1.mdb", "c:\\db2.mdb") win32com.client is part of Mark Hammond's winall package. c:\\db1.mdb is the database to be compacted & repaired c:\\db2.mdb is the file to which the resulting database will be written. 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.467 / Virus Database: 266 - Release Date: 4/1/2003 From bgailer at alum.rpi.edu Thu Apr 17 11:11:46 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Thu Apr 17 12:11:55 2003 Subject: [python-win32] Access and python In-Reply-To: <5.2.0.9.0.20030417100129.01a158e8@66.28.54.253> References: <3E9E8581.4010605@centurysoftware.com.my> Message-ID: <5.2.0.9.0.20030417101053.02fb8488@66.28.54.253> >win32com.client is part of Mark Hammond's winall package. I meant win32all. 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.467 / Virus Database: 266 - Release Date: 4/1/2003 From softex at hn.vnn.vn Thu Apr 17 09:26:51 2003 From: softex at hn.vnn.vn (Hung, Le Khanh) Date: Thu Apr 17 12:21:25 2003 Subject: [python-win32] About embedding Python Message-ID: <003201c30480$6cef6860$5919a8c0@hungsoftex> Dear Sir! Please tell me how to embed Python Interpreter into my C++Builder Windows program Best regards Hung -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20030417/4d28b2b3/attachment.htm From janez.jere at void.si Thu Apr 17 14:16:56 2003 From: janez.jere at void.si (Janez Jere) Date: Thu Apr 17 12:21:27 2003 Subject: [python-win32] brk() broken in 152? Message-ID: Hi, I installed win32all 152, and pywin.debugger.brk() is no longer working. So I would like to know if there is something wrong with my installation or with brk(). # copy following lines in a file and run it from command line print 0 import pywin.debugger pywin.debugger.brk() # at this point a pythonwin gui must be shown print 1 Thanks, Janez JERE From scottprive at earthlink.net Thu Apr 17 19:08:47 2003 From: scottprive at earthlink.net (Scott Prive) Date: Thu Apr 17 17:48:06 2003 Subject: [python-win32] differences between ActiveState Python and Standard Python + win32all? Message-ID: <04c601c3052d$eb99ac90$0601a8c0@scottprive.com> Hi all, I probably should start by saying "thanks for this list" and the time spent answering questions. My first post should not have been a complaint about what appeared to be a binding that didn't match the docs. Thanks again, Mark/all :-D Onto my second question: If I am not misunderstanding, for Windows users there are two platforms for win32 programming? One is ActiveState, and the other is standard python.org with Mark's win32all extension. Do I have this correct? If so, should I use one over the other and/or are there major differences (within the context of win32 programming). I grabbed the AS installer simply because it's all in one. Thanks again, Scott From bgailer at alum.rpi.edu Thu Apr 17 17:19:24 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Thu Apr 17 18:19:38 2003 Subject: [python-win32] differences between ActiveState Python and Standard Python + win32all? In-Reply-To: <04c601c3052d$eb99ac90$0601a8c0@scottprive.com> Message-ID: <5.2.0.9.0.20030417161754.03047a18@66.28.54.253> At 06:08 PM 4/17/2003 -0400, Scott Prive wrote: >If I am not misunderstanding, for Windows users there are two platforms for >win32 programming? One is ActiveState, and the other is standard python.org >with Mark's win32all extension. > >Do I have this correct? > >If so, should I use one over the other and/or are there major differences >(within the context of win32 programming). I grabbed the AS installer simply >because it's all in one. AFAIK those are 2 ways to get the same thing. The only difference I know is that Mark's changes will appear in his distribution first; it takes time for ActiveState to catch up. 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.467 / Virus Database: 266 - Release Date: 4/1/2003 From scottprive at earthlink.net Thu Apr 17 20:05:59 2003 From: scottprive at earthlink.net (Scott Prive) Date: Thu Apr 17 18:45:21 2003 Subject: [python-win32] differences between ActiveState Python and Standard Python + win32all? References: <5.2.0.9.0.20030417161754.03047a18@66.28.54.253> Message-ID: <04e301c30535$eac10630$0601a8c0@scottprive.com> Thanks Bob. Is there a command to query Python modules to see what "version" it at? In other words, a method I can use to track how far behind my installed ActiveState? thanks.. -Scott ----- Original Message ----- From: "Bob Gailer" To: "Scott Prive" ; Sent: Thursday, April 17, 2003 6:19 PM Subject: Re: [python-win32] differences between ActiveState Python and Standard Python + win32all? > At 06:08 PM 4/17/2003 -0400, Scott Prive wrote: > >If I am not misunderstanding, for Windows users there are two platforms for > >win32 programming? One is ActiveState, and the other is standard python.org > >with Mark's win32all extension. > > > >Do I have this correct? > > > >If so, should I use one over the other and/or are there major differences > >(within the context of win32 programming). I grabbed the AS installer simply > >because it's all in one. > > AFAIK those are 2 ways to get the same thing. The only difference I know is > that Mark's changes will appear in his distribution first; it takes time > for ActiveState to catch up. > > Bob Gailer > bgailer@alum.rpi.edu > 303 442 2625 > ---------------------------------------------------------------------------- ---- > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.467 / Virus Database: 266 - Release Date: 4/1/2003 > From lin at centurysoftware.com.my Fri Apr 18 11:11:16 2003 From: lin at centurysoftware.com.my (Norlin Abd Rahim) Date: Thu Apr 17 22:09:27 2003 Subject: [python-win32] Access and Python again Message-ID: <3E9F5EC4.7070107@centurysoftware.com.my> Hello, If i have an excel file and want to export it to Access using python win, how is that? TIA From ful_tom at yahoo.com Fri Apr 18 01:01:21 2003 From: ful_tom at yahoo.com (Tom) Date: Fri Apr 18 03:01:54 2003 Subject: [python-win32] Re: Access and python Message-ID: <20030418070121.53415.qmail@web41704.mail.yahoo.com> There is more ways how do it: 1. Simple use access command line options /compact or /repair. For example : msaccess.exe dbase.mdb /compact More in MsAccess help or http://support.microsoft.com/default.aspx?scid=KB;en-us;158937 2. Use automation import win32com.client access = win32com.client.Dispatch("Access.Application.8") dbName="c:\\source.mdb" newName="c:\\new.mdb" access.DbEngine.RepairDatabase(dbName) # or access.DbEngine.CompactDatabase( dbName, newName) access.Quit() del access Tomas Guano Fulajtar __________________________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo http://search.yahoo.com From bgailer at alum.rpi.edu Fri Apr 18 09:23:44 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Fri Apr 18 10:23:55 2003 Subject: [python-win32] MakePy In-Reply-To: <3E9F5EC4.7070107@centurysoftware.com.my> Message-ID: <5.2.0.9.0.20030418082138.01a16410@66.28.54.253> Choosing Tools -> COM makepy utility yielded: >>> Failed to execute command: from win32com.client import makepy;makepy.main() Traceback (most recent call last): File "E:\Python22\lib\site-packages\Pythonwin\pywin\framework\toolmenu.py", line 103, in HandleToolCommand exec "%s\n" % pyCmd File "", line 1, in ? File "E:\Python22\lib\site-packages\win32com\client\makepy.py", line 352, in main GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, bForDemand = bForDemand, bBuildHidden = hiddenSpec) File "E:\Python22\lib\site-packages\win32com\client\makepy.py", line 205, in GenerateFromTypeLibSpec typelibs = GetTypeLibsForSpec(typelibInfo) File "E:\Python22\lib\site-packages\win32com\client\makepy.py", line 157, in GetTypeLibsForSpec tlbs = selecttlb.FindTlbsWithDescription(arg) File "E:\Python22\lib\site-packages\win32com\client\selecttlb.py", line 100, in FindTlbsWithDescription items = EnumTlbs() File "E:\Python22\lib\site-packages\win32com\client\selecttlb.py", line 68, in EnumTlbs key2 = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, "Typelib\\%s" % (iid)) error: (5, 'RegOpenKeyEx', 'Access is denied.') This happened on Win NT Terminal Server logged in as administrator. 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.467 / Virus Database: 266 - Release Date: 4/1/2003 From jens.jorgensen at tallan.com Fri Apr 18 10:56:06 2003 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Fri Apr 18 10:56:17 2003 Subject: [python-win32] MakePy In-Reply-To: <5.2.0.9.0.20030418082138.01a16410@66.28.54.253> References: <5.2.0.9.0.20030418082138.01a16410@66.28.54.253> Message-ID: <3EA01206.3040403@tallan.com> I think this seems pretty clearly an NT perms problem, not a Python problem. Not that I wouldn't offer some help if I had a thought on why this is occurring, but I don't. For some reason that user does not have permission. You should be able to add permission to read that key, I'm not sure why administrator would not have permission but according to the OS, it doesn't! Are you really logged in as the local account Administrator or perhaps an account that belongs to the administrator group or domain admins group? (Not that those other possibilities should have trouble accessing that key.) Very strange indeed. Bob Gailer wrote: > Choosing Tools -> COM makepy utility yielded: > >>> Failed to execute command: > from win32com.client import makepy;makepy.main() > Traceback (most recent call last): > File > "E:\Python22\lib\site-packages\Pythonwin\pywin\framework\toolmenu.py", > line 103, in HandleToolCommand > exec "%s\n" % pyCmd > File "", line 1, in ? > File "E:\Python22\lib\site-packages\win32com\client\makepy.py", line > 352, in main > GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, > bForDemand = bForDemand, bBuildHidden = hiddenSpec) > File "E:\Python22\lib\site-packages\win32com\client\makepy.py", line > 205, in GenerateFromTypeLibSpec > typelibs = GetTypeLibsForSpec(typelibInfo) > File "E:\Python22\lib\site-packages\win32com\client\makepy.py", line > 157, in GetTypeLibsForSpec > tlbs = selecttlb.FindTlbsWithDescription(arg) > File "E:\Python22\lib\site-packages\win32com\client\selecttlb.py", > line 100, in FindTlbsWithDescription > items = EnumTlbs() > File "E:\Python22\lib\site-packages\win32com\client\selecttlb.py", > line 68, in EnumTlbs > key2 = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, > "Typelib\\%s" % (iid)) > error: (5, 'RegOpenKeyEx', 'Access is denied.') > > This happened on Win NT Terminal Server logged in as administrator. > > Bob Gailer > bgailer@alum.rpi.edu > 303 442 2625 -- 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 softex at hn.vnn.vn Fri Apr 18 15:12:26 2003 From: softex at hn.vnn.vn (Hung, Le Khanh) Date: Fri Apr 18 11:14:47 2003 Subject: [python-win32] Re: Python-win32 Digest, Vol 1, Issue 336 References: Message-ID: <00a401c3057a$1f792d50$5919a8c0@hungsoftex> Dear Sir! Please tell me how to embed Python Interpreter into my C++Builder Windows program Best regards Hung From jens.jorgensen at tallan.com Fri Apr 18 11:34:07 2003 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Fri Apr 18 11:34:06 2003 Subject: [python-win32] Re: Python-win32 Digest, Vol 1, Issue 336 In-Reply-To: <00a401c3057a$1f792d50$5919a8c0@hungsoftex> References: <00a401c3057a$1f792d50$5919a8c0@hungsoftex> Message-ID: <3EA01AEF.10103@tallan.com> Download and install the ActivePython package from www.activestate.com. Open up the on-line documentation. Look under Python Documentation-->Extending and Embedding-->Embedding Python in Another Application. Read instructions. That should give you all you need to know and is a much better introduction than any of us could probably write in an email. Hung, Le Khanh wrote: >Dear Sir! >Please tell me how to embed Python Interpreter into my C++Builder Windows >program >Best regards >Hung > > -- 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 Fri Apr 18 11:31:16 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Fri Apr 18 12:31:26 2003 Subject: [python-win32] Access and python In-Reply-To: <3E9F50E0.10506@centurysoftware.com.my> References: <5.2.0.9.0.20030417100129.01a158e8@66.28.54.253> Message-ID: <5.2.0.9.0.20030418095721.02fa4620@66.28.54.253> At 09:12 AM 4/18/2003 +0800, Norlin Abd Rahim wrote: > U're saying that the file to which the resulting database will be written means that do i need to create that as an empty database > or it will be automatically created? I recommend: - start Access - Tools -> Macro -> Visual Basic Editor - View -> Object Browser (ensure that Access or All Libraries is selected in the top combo box). This will show you the Access Objects - scroll to and click on Application in the left pane - scroll to and click on DBEngine in the right pane - scroll to and click on CompactDatabase in the right pane. The call syntax should appear below. - Press F1 - this should bring up the help application showing CompactDatabase and the meanings of the parameters. > If i have an excel file and want to export it to Access using python win, how is that? Have you brought excel files into Access manually? If so do you remember using Import? In the Visual Basic help window - click the Answer Wizard tab - type "import excel" - click search This should display below the TransferSpreadsheet Action. Actions belong to access macros. To run an Action using Visual Basic, you use the DoCmd Method. - return to the object browser - scroll left to & click DoCmd - scroll right to & click TransferSpreadsheet - Press F1 My hope is that these guidelines will assist you in finding things out by yourself. Not that we have objections to helping, but our time is limited, and we are all best off when we know how to look things up. HTH Be aware that the Visual Basic help window will have contents that are determined by what's in the top combo box in the Object Browser. If you are not finding what you want, return to the Object Browser & ensure that Access or All Libraries is selected in the top combo box 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.467 / Virus Database: 266 - Release Date: 4/1/2003 From scottprive at earthlink.net Fri Apr 18 14:03:22 2003 From: scottprive at earthlink.net (Scott Prive) Date: Fri Apr 18 12:42:44 2003 Subject: [python-win32] Re: Python-win32 Digest, Vol 1, Issue 336 References: <00a401c3057a$1f792d50$5919a8c0@hungsoftex> Message-ID: <006c01c305cc$6cc06040$0601a8c0@scottprive.com> Hello Hung, I am new to Python so I cannot directly answer your question, however... Try Google: http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=embedding+python&btnG =Google+Search These links in particular look interesting. http://www.mcmillan-inc.com/embed.html http://www.python.org/doc/current/ext/ext.html http://aspn.activestate.com/ASPN/Python/Reference/Products/ActivePython/pyth on/ext/embedding.html -Scott ----- Original Message ----- From: "Hung, Le Khanh" To: Sent: Friday, April 18, 2003 3:12 AM Subject: [python-win32] Re: Python-win32 Digest, Vol 1, Issue 336 > Dear Sir! > Please tell me how to embed Python Interpreter into my C++Builder Windows > program > Best regards > Hung > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From Dan.Kruger at vancoservices.com Fri Apr 18 15:30:11 2003 From: Dan.Kruger at vancoservices.com (Dan Kruger) Date: Fri Apr 18 15:28:16 2003 Subject: [python-win32] MakePy Message-ID: Ooops just realized I sent this reply to just Bob.. Darn Groupwise.. Anyway.. I've had this occur on XP and 2000, but not NT. You don't happen to have one of the more recent Crystal Reports installed, do you? There's a known issue that one of the newer Crystal Reports installs will create registry keys that are only accessable at the "System" security level (the one above admin). Any attempts to read these at any level lower than System will force a crash... be it python, VB's COM object browser, etc. They did have a patch you have to run as a system-level user (which is done by the "AT" command in the dos prompt).. but I'm afraid I don't know the URL off the top of my head. Hope that helps. Dan >>> "Jens B. Jorgensen" 04/18/03 09:56AM >>> I think this seems pretty clearly an NT perms problem, not a Python problem. Not that I wouldn't offer some help if I had a thought on why this is occurring, but I don't. For some reason that user does not have permission. You should be able to add permission to read that key, I'm not sure why administrator would not have permission but according to the OS, it doesn't! Are you really logged in as the local account Administrator or perhaps an account that belongs to the administrator group or domain admins group? (Not that those other possibilities should have trouble accessing that key.) Very strange indeed. Bob Gailer wrote: > Choosing Tools -> COM makepy utility yielded: > >>> Failed to execute command: > from win32com.client import makepy;makepy.main() > Traceback (most recent call last): > File > "E:\Python22\lib\site-packages\Pythonwin\pywin\framework\toolmenu.py", > line 103, in HandleToolCommand > exec "%s\n" % pyCmd > File "", line 1, in ? > File "E:\Python22\lib\site-packages\win32com\client\makepy.py", line > 352, in main > GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, > bForDemand = bForDemand, bBuildHidden = hiddenSpec) > File "E:\Python22\lib\site-packages\win32com\client\makepy.py", line > 205, in GenerateFromTypeLibSpec > typelibs = GetTypeLibsForSpec(typelibInfo) > File "E:\Python22\lib\site-packages\win32com\client\makepy.py", line > 157, in GetTypeLibsForSpec > tlbs = selecttlb.FindTlbsWithDescription(arg) > File "E:\Python22\lib\site-packages\win32com\client\selecttlb.py", > line 100, in FindTlbsWithDescription > items = EnumTlbs() > File "E:\Python22\lib\site-packages\win32com\client\selecttlb.py", > line 68, in EnumTlbs > key2 = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, > "Typelib\\%s" % (iid)) > error: (5, 'RegOpenKeyEx', 'Access is denied.') > > This happened on Win NT Terminal Server logged in as administrator. > > Bob Gailer > bgailer@alum.rpi.edu > 303 442 2625 -- 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 From bgailer at alum.rpi.edu Fri Apr 18 15:24:48 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Fri Apr 18 16:25:00 2003 Subject: [python-win32] MakePy In-Reply-To: Message-ID: <5.2.0.9.0.20030418141811.0304de78@66.28.54.253> Original: Choosing Tools -> COM makepy utility yielded: >>> Failed to execute command: from win32com.client import makepy;makepy.main() Traceback (most recent call last): [snip] File "E:\Python22\lib\site-packages\win32com\client\selecttlb.py", line 68, in EnumTlbs key2 = win32api.RegOpenKey(win32con.HKEY_CLASSES_ROOT, "Typelib\\%s" % (iid)) error: (5, 'RegOpenKeyEx', 'Access is denied.') This happened on Win NT Terminal Server logged in as administrator. At 09:59 AM 4/18/2003 -0500, Dan Kruger wrote: >You don't happen to have one of the more recent Crystal Reports installed, >do you? There's a known issue that one of the newer Crystal Reports >installs will create registry keys that are only accessable at the >"System" security level (the one above admin). Any attempts to read these >at any level lower than System will force a crash... be it python, VB's >COM object browser, etc. I added some try..except statements around the calls to RegOpenKey, and printed the offending keys. Then looked one up in the registry; lo and behold it was gray (protected). Running the program & ignoring the protected keys brought up the listbox and I could complete the makepy operation. There were 814 protected keys! I recommend that the official release be so modified. I assume this means I enter a bug report. 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.467 / Virus Database: 266 - Release Date: 4/1/2003 From scottprive at earthlink.net Fri Apr 18 17:55:21 2003 From: scottprive at earthlink.net (Scott Prive) Date: Fri Apr 18 16:34:45 2003 Subject: [python-win32] win32net.NetUseAdd buglet (or doc buglet) References: <020501c3046d$5115dec0$530f8490@eden> <007001c30492$8444bee0$0601a8c0@scottprive.com> Message-ID: <00ea01c305ec$d40899a0$0601a8c0@scottprive.com> Hi all, I replied to Mark/All, but I think anyone could jump in with an answer. The example code is ready to run and I included output from the debugger. Please someone try it out and tell me if my results were reproducible. Basically NetUseAdd() -- on my system at least -- seems to require the key ['passwd'] and fails with ['password']. Mark says the reverse condition should be true, which leads me to wonder... what am I doing wrong? Should I ditch ActiveState and use python.org + win32all? I'll do that if necessary and is the source of my problem. thanks a bunch, Scott ----- Original Message ----- From: "Scott Prive" To: "Mark Hammond" ; Sent: Wednesday, April 16, 2003 11:36 PM Subject: Re: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > > ----- Original Message ----- > From: "Mark Hammond" > To: "'Scott Prive'" > Sent: Wednesday, April 16, 2003 7:10 PM > Subject: RE: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > > > > > that share info is passed to the function in the form of a dictionary. > > > There's no example usage [sorry to complain, wish there > > > were...] but it does > > > point me to MSDN for more info. > > > > I think you will find examples in the Python Programming on Win32 book. > > Actually I -have- your book :-) > Until I finish Lutz' Programming Python, your Win32 is serving as a > reference (it's next tho!). > > Searching the index, I did not see win32net.NetUseAdd (other win32net > relatives are listed). > ... It could be an index omission, in which case I'll see it eventually. > > > > > > > > > The problem? > > > > > > The MSDN documentation has example usage (share path, user, > > > password etc.). > > > But in their example they call password, "password".... the > > > Pythin win32 > > > wrapper doesn't understand ['password'] (and does not raise > > > an exception on > > > its use), but it DOES understand ['passwd']. > > > > > > So either MSDN is wrong or the wrapper's got a buglet. :-) > > > > None of these wrappers raise an exception on a bad attribute name - they > > should. But in this case, the attribute is certainly named "password". I > > expect that simply the underlying Win32 call is failing for you. > > > > Mark. > > I'm certain it appears only to work with 'passwd', but if something's going > on under the hood it's quite interesting. Below is an interactive session, > followed by the actual code. > > You can see the difference between the two functions is the password entry. > I've tried this with other accounts. The same credentials were tested under > CMD.EXE using 'net use'. The accounts exist on a win2K Server PDC, which is > the same server I'm mounting the share from. Each time I tested, I started > from a clean slate and verified nothing (at all) is listed under plain 'net > use' > > When I get a mount from my function (under 'passwd'), I validate it by > echoing text to a file on Z:\test.txt. > If the 'password' function ran, which never provided a mount, this step > yields a "system cannot find the path specified." > > Any thoughts? Thanks. > -Scott > > ---------- interactive ------------ > E:\scott\Komodo\ntlm_cifs>dir z: > The system cannot find the path specified. > > E:\scott\Komodo\ntlm_cifs>python > ActivePython 2.2.2 Build 224 (ActiveState Corp.) based on > Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> from testmap import * > >>> mountShare > > >>> mountShare() > This drive letter was in use, so I'll unmount it > Good. Verified drive letter is not already mounted. > Traceback (most recent call last): > File "", line 1, in ? > File "testmap.py", line 20, in mountShare > win32net.NetUseAdd(None,1,data) > pywintypes.api_error: (1326, 'NetUseAdd', 'Logon failure: unknown user name > or b > ad password.') > >>> mountShare2() > This drive letter was in use, so I'll unmount it > Good. Verified drive letter is not already mounted. > >>> > > ----------------code--------------- > #!/usr/bin/python > > import string, sys, win32file, win32net > > def mountShare(): > """A CIFS mount interface, wraps win32 API call NetUseAdd""" > #see ASPN docs win32wnet.NetUseAdd and win32net.NetUseAdd > try: > print "This drive letter was in use, so I'll unmount it" > unmountShare() > except: > print 'Good. Verified drive letter is not already mounted. ' > data = { > 'remote' : r'\\rogue.scottprive.com\account1', > 'local' : 'Z:', > 'password' : 'foo', > 'user' : 'foo', > 'asg_type' : 0, > } > win32net.NetUseAdd(None,1,data) > > def mountShare2(): > """A CIFS mount interface, wraps win32 API call NetUseAdd""" > #see ASPN docs win32wnet.NetUseAdd and win32net.NetUseAdd > try: > print "This drive letter was in use, so I'll unmount it" > unmountShare() > except: > print 'Good. Verified drive letter is not already mounted. ' > data = { > 'remote' : r'\\rogue.scottprive.com\account1', > 'local' : 'Z:', > 'passwd' : 'foo', > 'user' : 'foo', > 'asg_type' : 0, > } > win32net.NetUseAdd(None,1,data) > > def unmountShare(): > win32net.NetUseDel(None,'Z:',0) > > > def main(): > mountShare() > mountShare2() > > if __name__ == '__main__': main() > > > > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From jens.jorgensen at tallan.com Fri Apr 18 16:56:59 2003 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Fri Apr 18 16:57:00 2003 Subject: [python-win32] win32net.NetUseAdd buglet (or doc buglet) In-Reply-To: <00ea01c305ec$d40899a0$0601a8c0@scottprive.com> References: <020501c3046d$5115dec0$530f8490@eden> <007001c30492$8444bee0$0601a8c0@scottprive.com> <00ea01c305ec$d40899a0$0601a8c0@scottprive.com> Message-ID: <3EA0669B.6070304@tallan.com> Scott, According to the docs I'm looking at NetUseAdd doesn't accept username at all. However, why not use win32wnet.WNetAddConnection2 instead? I tried this out on my box and it worked great. Here's what I did: win32wnet.WNetAddConnection2(win32netcon.RESOURCETYPE_DISK, 'y:', '\\\\servername\\sharename', None, 'domain\\username', 'password', 0) It worked great. Scott Prive wrote: >Hi all, > >I replied to Mark/All, but I think anyone could jump in with an answer. > >The example code is ready to run and I included output from the debugger. >Please someone try it out and tell me if my results were reproducible. > >Basically NetUseAdd() -- on my system at least -- seems to require the key >['passwd'] and fails with ['password']. Mark says the reverse condition >should be true, which leads me to wonder... what am I doing wrong? Should I >ditch ActiveState and use python.org + win32all? I'll do that if necessary >and is the source of my problem. > >thanks a bunch, >Scott > > > > >----- Original Message ----- >From: "Scott Prive" >To: "Mark Hammond" ; >Sent: Wednesday, April 16, 2003 11:36 PM >Subject: Re: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > > > > >>----- Original Message ----- >>From: "Mark Hammond" >>To: "'Scott Prive'" >>Sent: Wednesday, April 16, 2003 7:10 PM >>Subject: RE: [python-win32] win32net.NetUseAdd buglet (or doc buglet) >> >> >> >> >>>>that share info is passed to the function in the form of a dictionary. >>>>There's no example usage [sorry to complain, wish there >>>>were...] but it does >>>>point me to MSDN for more info. >>>> >>>> >>>I think you will find examples in the Python Programming on Win32 book. >>> >>> >>Actually I -have- your book :-) >>Until I finish Lutz' Programming Python, your Win32 is serving as a >>reference (it's next tho!). >> >>Searching the index, I did not see win32net.NetUseAdd (other win32net >>relatives are listed). >>... It could be an index omission, in which case I'll see it eventually. >> >> >> >>>>The problem? >>>> >>>>The MSDN documentation has example usage (share path, user, >>>>password etc.). >>>>But in their example they call password, "password".... the >>>>Pythin win32 >>>>wrapper doesn't understand ['password'] (and does not raise >>>>an exception on >>>>its use), but it DOES understand ['passwd']. >>>> >>>>So either MSDN is wrong or the wrapper's got a buglet. :-) >>>> >>>> >>>None of these wrappers raise an exception on a bad attribute name - they >>>should. But in this case, the attribute is certainly named "password". >>> >>> >I > > >>>expect that simply the underlying Win32 call is failing for you. >>> >>>Mark. >>> >>> >>I'm certain it appears only to work with 'passwd', but if something's >> >> >going > > >>on under the hood it's quite interesting. Below is an interactive >> >> >session, > > >>followed by the actual code. >> >>You can see the difference between the two functions is the password >> >> >entry. > > >>I've tried this with other accounts. The same credentials were tested >> >> >under > > >>CMD.EXE using 'net use'. The accounts exist on a win2K Server PDC, which >> >> >is > > >>the same server I'm mounting the share from. Each time I tested, I started >>from a clean slate and verified nothing (at all) is listed under plain >> >> >'net > > >>use' >> >>When I get a mount from my function (under 'passwd'), I validate it by >>echoing text to a file on Z:\test.txt. >>If the 'password' function ran, which never provided a mount, this step >>yields a "system cannot find the path specified." >> >>Any thoughts? Thanks. >>-Scott >> >>---------- interactive ------------ >>E:\scott\Komodo\ntlm_cifs>dir z: >>The system cannot find the path specified. >> >>E:\scott\Komodo\ntlm_cifs>python >>ActivePython 2.2.2 Build 224 (ActiveState Corp.) based on >>Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)] on win32 >>Type "help", "copyright", "credits" or "license" for more information. >> >> >>>>>from testmap import * >>>>>mountShare >>>>> >>>>> >> >> >> >>>>>mountShare() >>>>> >>>>> >>This drive letter was in use, so I'll unmount it >>Good. Verified drive letter is not already mounted. >>Traceback (most recent call last): >> File "", line 1, in ? >> File "testmap.py", line 20, in mountShare >> win32net.NetUseAdd(None,1,data) >>pywintypes.api_error: (1326, 'NetUseAdd', 'Logon failure: unknown user >> >> >name > > >>or b >>ad password.') >> >> >>>>>mountShare2() >>>>> >>>>> >>This drive letter was in use, so I'll unmount it >>Good. Verified drive letter is not already mounted. >> >> >>----------------code--------------- >>#!/usr/bin/python >> >>import string, sys, win32file, win32net >> >>def mountShare(): >> """A CIFS mount interface, wraps win32 API call NetUseAdd""" >> #see ASPN docs win32wnet.NetUseAdd and win32net.NetUseAdd >> try: >> print "This drive letter was in use, so I'll unmount it" >> unmountShare() >> except: >> print 'Good. Verified drive letter is not already mounted. ' >> data = { >> 'remote' : r'\\rogue.scottprive.com\account1', >> 'local' : 'Z:', >> 'password' : 'foo', >> 'user' : 'foo', >> 'asg_type' : 0, >> } >> win32net.NetUseAdd(None,1,data) >> >>def mountShare2(): >> """A CIFS mount interface, wraps win32 API call NetUseAdd""" >> #see ASPN docs win32wnet.NetUseAdd and win32net.NetUseAdd >> try: >> print "This drive letter was in use, so I'll unmount it" >> unmountShare() >> except: >> print 'Good. Verified drive letter is not already mounted. ' >> data = { >> 'remote' : r'\\rogue.scottprive.com\account1', >> 'local' : 'Z:', >> 'passwd' : 'foo', >> 'user' : 'foo', >> 'asg_type' : 0, >> } >> win32net.NetUseAdd(None,1,data) >> >>def unmountShare(): >> win32net.NetUseDel(None,'Z:',0) >> >> >>def main(): >> mountShare() >> mountShare2() >> >>if __name__ == '__main__': main() >> >> >> >> >> >> >>_______________________________________________ >>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 > > -- 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 scottprive at earthlink.net Fri Apr 18 18:55:20 2003 From: scottprive at earthlink.net (Scott Prive) Date: Fri Apr 18 17:34:43 2003 Subject: [python-win32] win32net.NetUseAdd buglet (or doc buglet) References: <020501c3046d$5115dec0$530f8490@eden> <007001c30492$8444bee0$0601a8c0@scottprive.com> <00ea01c305ec$d40899a0$0601a8c0@scottprive.com> <3EA0669B.6070304@tallan.com> Message-ID: <00fe01c305f5$36623cc0$0601a8c0@scottprive.com> Hi Jens, Thank you for your reply and your suggestion. The reason I picked NetUseAdd() was it was what showed up in my Google search for "python drive map" -- I did not know about win32wnet.WNetAddConnection2... I'm used to wrapping shell commands in functions... naturally I want to get away from such silliness :-) Re: NetUseAdd(), what docs were you looking at? I could see on the ActiveState documentation online, that gave a brief description of the API NetUseAdd()... then referred to the MSDN website for more info, which did show a username/password. You can see in my output, it actually *does* work (or seems to even if I interact with the mount manually). I just noticed the win32wnet wrappers have MUCH better documentation... is win32net depreciated or otherwise less desired than win32wnet (should I read into it that way)? I'll work with your suggestion, thanks again. Next time I have a problem like this I won't assume the first API I found is the only one that can do the task either. :-) -Scott ----- Original Message ----- From: "Jens B. Jorgensen" To: "Scott Prive" Cc: Sent: Friday, April 18, 2003 4:56 PM Subject: Re: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > Scott, > > According to the docs I'm looking at NetUseAdd doesn't accept username > at all. However, why not use win32wnet.WNetAddConnection2 instead? I > tried this out on my box and it worked great. Here's what I did: > > win32wnet.WNetAddConnection2(win32netcon.RESOURCETYPE_DISK, 'y:', > '\\\\servername\\sharename', None, 'domain\\username', 'password', 0) > > It worked great. > > Scott Prive wrote: > > >Hi all, > > > >I replied to Mark/All, but I think anyone could jump in with an answer. > > > >The example code is ready to run and I included output from the debugger. > >Please someone try it out and tell me if my results were reproducible. > > > >Basically NetUseAdd() -- on my system at least -- seems to require the key > >['passwd'] and fails with ['password']. Mark says the reverse condition > >should be true, which leads me to wonder... what am I doing wrong? Should I > >ditch ActiveState and use python.org + win32all? I'll do that if necessary > >and is the source of my problem. > > > >thanks a bunch, > >Scott > > > > > > > > > >----- Original Message ----- > >From: "Scott Prive" > >To: "Mark Hammond" ; > >Sent: Wednesday, April 16, 2003 11:36 PM > >Subject: Re: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > > > > > > > > > >>----- Original Message ----- > >>From: "Mark Hammond" > >>To: "'Scott Prive'" > >>Sent: Wednesday, April 16, 2003 7:10 PM > >>Subject: RE: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > >> > >> > >> > >> > >>>>that share info is passed to the function in the form of a dictionary. > >>>>There's no example usage [sorry to complain, wish there > >>>>were...] but it does > >>>>point me to MSDN for more info. > >>>> > >>>> > >>>I think you will find examples in the Python Programming on Win32 book. > >>> > >>> > >>Actually I -have- your book :-) > >>Until I finish Lutz' Programming Python, your Win32 is serving as a > >>reference (it's next tho!). > >> > >>Searching the index, I did not see win32net.NetUseAdd (other win32net > >>relatives are listed). > >>... It could be an index omission, in which case I'll see it eventually. > >> > >> > >> > >>>>The problem? > >>>> > >>>>The MSDN documentation has example usage (share path, user, > >>>>password etc.). > >>>>But in their example they call password, "password".... the > >>>>Pythin win32 > >>>>wrapper doesn't understand ['password'] (and does not raise > >>>>an exception on > >>>>its use), but it DOES understand ['passwd']. > >>>> > >>>>So either MSDN is wrong or the wrapper's got a buglet. :-) > >>>> > >>>> > >>>None of these wrappers raise an exception on a bad attribute name - they > >>>should. But in this case, the attribute is certainly named "password". > >>> > >>> > >I > > > > > >>>expect that simply the underlying Win32 call is failing for you. > >>> > >>>Mark. > >>> > >>> > >>I'm certain it appears only to work with 'passwd', but if something's > >> > >> > >going > > > > > >>on under the hood it's quite interesting. Below is an interactive > >> > >> > >session, > > > > > >>followed by the actual code. > >> > >>You can see the difference between the two functions is the password > >> > >> > >entry. > > > > > >>I've tried this with other accounts. The same credentials were tested > >> > >> > >under > > > > > >>CMD.EXE using 'net use'. The accounts exist on a win2K Server PDC, which > >> > >> > >is > > > > > >>the same server I'm mounting the share from. Each time I tested, I started > >>from a clean slate and verified nothing (at all) is listed under plain > >> > >> > >'net > > > > > >>use' > >> > >>When I get a mount from my function (under 'passwd'), I validate it by > >>echoing text to a file on Z:\test.txt. > >>If the 'password' function ran, which never provided a mount, this step > >>yields a "system cannot find the path specified." > >> > >>Any thoughts? Thanks. > >>-Scott > >> > >>---------- interactive ------------ > >>E:\scott\Komodo\ntlm_cifs>dir z: > >>The system cannot find the path specified. > >> > >>E:\scott\Komodo\ntlm_cifs>python > >>ActivePython 2.2.2 Build 224 (ActiveState Corp.) based on > >>Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)] on win32 > >>Type "help", "copyright", "credits" or "license" for more information. > >> > >> > >>>>>from testmap import * > >>>>>mountShare > >>>>> > >>>>> > >> > >> > >> > >>>>>mountShare() > >>>>> > >>>>> > >>This drive letter was in use, so I'll unmount it > >>Good. Verified drive letter is not already mounted. > >>Traceback (most recent call last): > >> File "", line 1, in ? > >> File "testmap.py", line 20, in mountShare > >> win32net.NetUseAdd(None,1,data) > >>pywintypes.api_error: (1326, 'NetUseAdd', 'Logon failure: unknown user > >> > >> > >name > > > > > >>or b > >>ad password.') > >> > >> > >>>>>mountShare2() > >>>>> > >>>>> > >>This drive letter was in use, so I'll unmount it > >>Good. Verified drive letter is not already mounted. > >> > >> > >>----------------code--------------- > >>#!/usr/bin/python > >> > >>import string, sys, win32file, win32net > >> > >>def mountShare(): > >> """A CIFS mount interface, wraps win32 API call NetUseAdd""" > >> #see ASPN docs win32wnet.NetUseAdd and win32net.NetUseAdd > >> try: > >> print "This drive letter was in use, so I'll unmount it" > >> unmountShare() > >> except: > >> print 'Good. Verified drive letter is not already mounted. ' > >> data = { > >> 'remote' : r'\\rogue.scottprive.com\account1', > >> 'local' : 'Z:', > >> 'password' : 'foo', > >> 'user' : 'foo', > >> 'asg_type' : 0, > >> } > >> win32net.NetUseAdd(None,1,data) > >> > >>def mountShare2(): > >> """A CIFS mount interface, wraps win32 API call NetUseAdd""" > >> #see ASPN docs win32wnet.NetUseAdd and win32net.NetUseAdd > >> try: > >> print "This drive letter was in use, so I'll unmount it" > >> unmountShare() > >> except: > >> print 'Good. Verified drive letter is not already mounted. ' > >> data = { > >> 'remote' : r'\\rogue.scottprive.com\account1', > >> 'local' : 'Z:', > >> 'passwd' : 'foo', > >> 'user' : 'foo', > >> 'asg_type' : 0, > >> } > >> win32net.NetUseAdd(None,1,data) > >> > >>def unmountShare(): > >> win32net.NetUseDel(None,'Z:',0) > >> > >> > >>def main(): > >> mountShare() > >> mountShare2() > >> > >>if __name__ == '__main__': main() > >> > >> > >> > >> > >> > >> > >>_______________________________________________ > >>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 > > > > > > -- > 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 Fri Apr 18 19:57:30 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Fri Apr 18 20:57:37 2003 Subject: [python-win32] makepy, Word & Case sensitivity Message-ID: <5.2.0.9.0.20030418185507.0303ab50@66.28.54.253> Before running makepy on MS Word, properties were case insensitive. Thus one could refer to visible or Visible. Aftert running makepy on MS Word properties are case sensitive. Only Visible is valid. That has cost a bunch of debugging time. 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.467 / Virus Database: 266 - Release Date: 4/1/2003 From jens.jorgensen at tallan.com Sat Apr 19 11:41:21 2003 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Sat Apr 19 11:43:28 2003 Subject: [python-win32] win32net.NetUseAdd buglet (or doc buglet) In-Reply-To: <00fe01c305f5$36623cc0$0601a8c0@scottprive.com> References: <020501c3046d$5115dec0$530f8490@eden> <007001c30492$8444bee0$0601a8c0@scottprive.com> <00ea01c305ec$d40899a0$0601a8c0@scottprive.com> <3EA0669B.6070304@tallan.com> <00fe01c305f5$36623cc0$0601a8c0@scottprive.com> Message-ID: <3EA16E21.2060201@tallan.com> Scott Prive wrote: >Hi Jens, > >Thank you for your reply and your suggestion. > >The reason I picked NetUseAdd() was it was what showed up in my Google >search for "python drive map" -- I did not know about >win32wnet.WNetAddConnection2... I'm used to wrapping shell commands in >functions... naturally I want to get away from such silliness :-) > >Re: NetUseAdd(), what docs were you looking at? I could see on the >ActiveState documentation online, that gave a brief description of the API >NetUseAdd()... then referred to the MSDN website for more info, which did >show a username/password. You can see in my output, it actually *does* work >(or seems to even if I interact with the mount manually). > Hmm, ok. I must have been looking at the wrong struct. The one I was looking at just had a password and I couldn't get the thing to work for me. I was referring to my copy of MSDN Library (1999! often more accurate as it portrays things as they are with the computers I work with rather than how Microsoft would like them to be). >I just noticed the win32wnet wrappers have MUCH better documentation... is >win32net depreciated or otherwise less desired than win32wnet (should I read >into it that way)? > Actually it was the MSDN Library docs that noted that if the targeted platform is win32 then you can use WNetAddConnection2. Although I haven't used the WNet* apis very much that doc suggests to me that the WNet* stuff is newer. > >I'll work with your suggestion, thanks again. Next time I have a problem >like this I won't assume the first API I found is the only one that can do >the task either. :-) > Oh most definitely especially when it comes to the win32 apis since they have evolved but continue to carry much of their ancient baggage. -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3108 bytes Desc: S/MIME Cryptographic Signature Url : http://mail.python.org/pipermail/python-win32/attachments/20030419/a2e3ae0e/smime.bin From graham.bloice at trihedral.com Mon Apr 21 13:47:37 2003 From: graham.bloice at trihedral.com (Graham Bloice) Date: Mon Apr 21 07:48:14 2003 Subject: [python-win32] Visual Source Safe Automation Message-ID: <000901c307fb$cf7912f0$2201a8c0@GRAHAM> I'm attempting to use PythonCOM to drive Visual SourceSafe (VSS). I've used PythonCOM before, but I'm struggling with VSS. I've run MakePy on the type library, and I get a module when calling EnsureModule(): ss = win32com.client.gencache.EnsureModule('{783CD4E0-9D54-11CF-B8EE-00608CC9A71F }', 0, 5, 1) but how do I then instantiate an instance and get the dispatch interface ? Graham Bloice Software Developer Trihedral UK Limited Tel: +44 (0)1224 332238 Mail: mailto:graham.bloice@trihedral.com From graham.bloice at trihedral.com Mon Apr 21 14:14:50 2003 From: graham.bloice at trihedral.com (Graham Bloice) Date: Mon Apr 21 08:15:25 2003 Subject: [python-win32] RE: Visual Source Safe Automation Message-ID: <000d01c307ff$9c633c70$2201a8c0@GRAHAM> Please ignore my last message. It's as simple as: ss = win32com.client.dispatch('SourceSafe') Graham Bloice From email2et at yahoo.com Sun Apr 20 23:54:19 2003 From: email2et at yahoo.com (ET Planet) Date: Mon Apr 21 10:08:39 2003 Subject: [python-win32] Black out screen Message-ID: <20030421055419.50668.qmail@web20206.mail.yahoo.com> Hi, I made a mistake by installing both Python2.2 (for windows) > and ActivePython2.2 on the same PC running on Win2K. Python2.2 was > installed first before ActivePython. Subsequently, a friend passed > me a Python-based Net Send program together with GUI. However, > even when I run the source codes, my screen will black out while > the message was being sent. In fact, for some of my programs that > does a external calling of other .exe programs, my screen blacks > out during the period it is running. I had uninstalled both > Python2.2 and ActivePython2.2 and reinstall the ActivePython2.2 but > the same problem persisted. Uninstalling this and reinstalling > Python2.2, the same problem persisted as well. Was there some > configuration conflict? As it I've not seen any documentation on > this, I'm not sure where the problem really is. Thanks, anybody got any idea what happened?ET --------------------------------- Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20030420/4348cd73/attachment.htm From lbates at syscononline.com Mon Apr 21 10:30:33 2003 From: lbates at syscononline.com (Larry Bates) Date: Mon Apr 21 10:35:01 2003 Subject: [python-win32] RE: Python-win32 Digest, Vol 1, Issue 340 In-Reply-To: Message-ID: <009b01c30812$91dc8e10$3f00a8c0@larrywxp> Just jumping in here. I've successfully used NetUseAdd to dynamically map drives inside of my programs. Don't forget that things must be passed to NetUseAdd as unicode strings inside the dictionary. Here is a code snippet from a working program: use_dict={} use_dict['local']=unicode(local) use_dict['remote']=unicode(remote) use_dict['password']=unicode(password) use_dict['username']=unicode(username) # # Now add this drive mapping # try: win32net.NetUseAdd(None, 2, use_dict) except: print "Unable to map %s to %s" % (local, remote) where local=, remote=, password=, username=. FYI, Larry Bates Syscon, Inc. -----Original Message----- From: python-win32-bounces@python.org [mailto:python-win32-bounces@python.org]On Behalf Of python-win32-request@python.org Sent: Saturday, April 19, 2003 11:03 AM To: python-win32@python.org Subject: Python-win32 Digest, Vol 1, Issue 340 Send Python-win32 mailing list submissions to python-win32@python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-win32 or, via email, send a message with subject or body 'help' to python-win32-request@python.org You can reach the person managing the list at python-win32-owner@python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-win32 digest..." Today's Topics: 1. Re: win32net.NetUseAdd buglet (or doc buglet) (Scott Prive) 2. makepy, Word & Case sensitivity (Bob Gailer) 3. Re: win32net.NetUseAdd buglet (or doc buglet) (Jens B. Jorgensen) ---------------------------------------------------------------------- Message: 1 Date: Fri, 18 Apr 2003 17:55:20 -0400 From: "Scott Prive" Subject: Re: [python-win32] win32net.NetUseAdd buglet (or doc buglet) To: "Jens B. Jorgensen" Cc: python-win32@python.org Message-ID: <00fe01c305f5$36623cc0$0601a8c0@scottprive.com> Content-Type: text/plain; charset="iso-8859-1" Hi Jens, Thank you for your reply and your suggestion. The reason I picked NetUseAdd() was it was what showed up in my Google search for "python drive map" -- I did not know about win32wnet.WNetAddConnection2... I'm used to wrapping shell commands in functions... naturally I want to get away from such silliness :-) Re: NetUseAdd(), what docs were you looking at? I could see on the ActiveState documentation online, that gave a brief description of the API NetUseAdd()... then referred to the MSDN website for more info, which did show a username/password. You can see in my output, it actually *does* work (or seems to even if I interact with the mount manually). I just noticed the win32wnet wrappers have MUCH better documentation... is win32net depreciated or otherwise less desired than win32wnet (should I read into it that way)? I'll work with your suggestion, thanks again. Next time I have a problem like this I won't assume the first API I found is the only one that can do the task either. :-) -Scott ----- Original Message ----- From: "Jens B. Jorgensen" To: "Scott Prive" Cc: Sent: Friday, April 18, 2003 4:56 PM Subject: Re: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > Scott, > > According to the docs I'm looking at NetUseAdd doesn't accept username > at all. However, why not use win32wnet.WNetAddConnection2 instead? I > tried this out on my box and it worked great. Here's what I did: > > win32wnet.WNetAddConnection2(win32netcon.RESOURCETYPE_DISK, 'y:', > '\\\\servername\\sharename', None, 'domain\\username', 'password', 0) > > It worked great. > > Scott Prive wrote: > > >Hi all, > > > >I replied to Mark/All, but I think anyone could jump in with an answer. > > > >The example code is ready to run and I included output from the debugger. > >Please someone try it out and tell me if my results were reproducible. > > > >Basically NetUseAdd() -- on my system at least -- seems to require the key > >['passwd'] and fails with ['password']. Mark says the reverse condition > >should be true, which leads me to wonder... what am I doing wrong? Should I > >ditch ActiveState and use python.org + win32all? I'll do that if necessary > >and is the source of my problem. > > > >thanks a bunch, > >Scott > > > > > > > > > >----- Original Message ----- > >From: "Scott Prive" > >To: "Mark Hammond" ; > >Sent: Wednesday, April 16, 2003 11:36 PM > >Subject: Re: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > > > > > > > > > >>----- Original Message ----- > >>From: "Mark Hammond" > >>To: "'Scott Prive'" > >>Sent: Wednesday, April 16, 2003 7:10 PM > >>Subject: RE: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > >> > >> > >> > >> > >>>>that share info is passed to the function in the form of a dictionary. > >>>>There's no example usage [sorry to complain, wish there > >>>>were...] but it does > >>>>point me to MSDN for more info. > >>>> > >>>> > >>>I think you will find examples in the Python Programming on Win32 book. > >>> > >>> > >>Actually I -have- your book :-) > >>Until I finish Lutz' Programming Python, your Win32 is serving as a > >>reference (it's next tho!). > >> > >>Searching the index, I did not see win32net.NetUseAdd (other win32net > >>relatives are listed). > >>... It could be an index omission, in which case I'll see it eventually. > >> > >> > >> > >>>>The problem? > >>>> > >>>>The MSDN documentation has example usage (share path, user, > >>>>password etc.). > >>>>But in their example they call password, "password".... the > >>>>Pythin win32 > >>>>wrapper doesn't understand ['password'] (and does not raise > >>>>an exception on > >>>>its use), but it DOES understand ['passwd']. > >>>> > >>>>So either MSDN is wrong or the wrapper's got a buglet. :-) > >>>> > >>>> > >>>None of these wrappers raise an exception on a bad attribute name - they > >>>should. But in this case, the attribute is certainly named "password". > >>> > >>> > >I > > > > > >>>expect that simply the underlying Win32 call is failing for you. > >>> > >>>Mark. > >>> > >>> > >>I'm certain it appears only to work with 'passwd', but if something's > >> > >> > >going > > > > > >>on under the hood it's quite interesting. Below is an interactive > >> > >> > >session, > > > > > >>followed by the actual code. > >> > >>You can see the difference between the two functions is the password > >> > >> > >entry. > > > > > >>I've tried this with other accounts. The same credentials were tested > >> > >> > >under > > > > > >>CMD.EXE using 'net use'. The accounts exist on a win2K Server PDC, which > >> > >> > >is > > > > > >>the same server I'm mounting the share from. Each time I tested, I started > >>from a clean slate and verified nothing (at all) is listed under plain > >> > >> > >'net > > > > > >>use' > >> > >>When I get a mount from my function (under 'passwd'), I validate it by > >>echoing text to a file on Z:\test.txt. > >>If the 'password' function ran, which never provided a mount, this step > >>yields a "system cannot find the path specified." > >> > >>Any thoughts? Thanks. > >>-Scott > >> > >>---------- interactive ------------ > >>E:\scott\Komodo\ntlm_cifs>dir z: > >>The system cannot find the path specified. > >> > >>E:\scott\Komodo\ntlm_cifs>python > >>ActivePython 2.2.2 Build 224 (ActiveState Corp.) based on > >>Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)] on win32 > >>Type "help", "copyright", "credits" or "license" for more information. > >> > >> > >>>>>from testmap import * > >>>>>mountShare > >>>>> > >>>>> > >> > >> > >> > >>>>>mountShare() > >>>>> > >>>>> > >>This drive letter was in use, so I'll unmount it > >>Good. Verified drive letter is not already mounted. > >>Traceback (most recent call last): > >> File "", line 1, in ? > >> File "testmap.py", line 20, in mountShare > >> win32net.NetUseAdd(None,1,data) > >>pywintypes.api_error: (1326, 'NetUseAdd', 'Logon failure: unknown user > >> > >> > >name > > > > > >>or b > >>ad password.') > >> > >> > >>>>>mountShare2() > >>>>> > >>>>> > >>This drive letter was in use, so I'll unmount it > >>Good. Verified drive letter is not already mounted. > >> > >> > >>----------------code--------------- > >>#!/usr/bin/python > >> > >>import string, sys, win32file, win32net > >> > >>def mountShare(): > >> """A CIFS mount interface, wraps win32 API call NetUseAdd""" > >> #see ASPN docs win32wnet.NetUseAdd and win32net.NetUseAdd > >> try: > >> print "This drive letter was in use, so I'll unmount it" > >> unmountShare() > >> except: > >> print 'Good. Verified drive letter is not already mounted. ' > >> data = { > >> 'remote' : r'\\rogue.scottprive.com\account1', > >> 'local' : 'Z:', > >> 'password' : 'foo', > >> 'user' : 'foo', > >> 'asg_type' : 0, > >> } > >> win32net.NetUseAdd(None,1,data) > >> > >>def mountShare2(): > >> """A CIFS mount interface, wraps win32 API call NetUseAdd""" > >> #see ASPN docs win32wnet.NetUseAdd and win32net.NetUseAdd > >> try: > >> print "This drive letter was in use, so I'll unmount it" > >> unmountShare() > >> except: > >> print 'Good. Verified drive letter is not already mounted. ' > >> data = { > >> 'remote' : r'\\rogue.scottprive.com\account1', > >> 'local' : 'Z:', > >> 'passwd' : 'foo', > >> 'user' : 'foo', > >> 'asg_type' : 0, > >> } > >> win32net.NetUseAdd(None,1,data) > >> > >>def unmountShare(): > >> win32net.NetUseDel(None,'Z:',0) > >> > >> > >>def main(): > >> mountShare() > >> mountShare2() > >> > >>if __name__ == '__main__': main() > >> > >> > >> > >> > >> > >> > >>_______________________________________________ > >>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 > > > > > > -- > Jens B. Jorgensen > jens.jorgensen@tallan.com > > "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" > > ------------------------------ Message: 2 Date: Fri, 18 Apr 2003 18:57:30 -0600 From: Bob Gailer Subject: [python-win32] makepy, Word & Case sensitivity To: python-win32@python.org Message-ID: <5.2.0.9.0.20030418185507.0303ab50@66.28.54.253> Content-Type: text/plain; charset="us-ascii" Before running makepy on MS Word, properties were case insensitive. Thus one could refer to visible or Visible. Aftert running makepy on MS Word properties are case sensitive. Only Visible is valid. That has cost a bunch of debugging time. 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.467 / Virus Database: 266 - Release Date: 4/1/2003 ------------------------------ Message: 3 Date: Sat, 19 Apr 2003 10:41:21 -0500 From: "Jens B. Jorgensen" Subject: Re: [python-win32] win32net.NetUseAdd buglet (or doc buglet) To: Scott Prive Cc: python-win32@python.org Message-ID: <3EA16E21.2060201@tallan.com> Content-Type: text/plain; charset="us-ascii" Scott Prive wrote: >Hi Jens, > >Thank you for your reply and your suggestion. > >The reason I picked NetUseAdd() was it was what showed up in my Google >search for "python drive map" -- I did not know about >win32wnet.WNetAddConnection2... I'm used to wrapping shell commands in >functions... naturally I want to get away from such silliness :-) > >Re: NetUseAdd(), what docs were you looking at? I could see on the >ActiveState documentation online, that gave a brief description of the API >NetUseAdd()... then referred to the MSDN website for more info, which did >show a username/password. You can see in my output, it actually *does* work >(or seems to even if I interact with the mount manually). > Hmm, ok. I must have been looking at the wrong struct. The one I was looking at just had a password and I couldn't get the thing to work for me. I was referring to my copy of MSDN Library (1999! often more accurate as it portrays things as they are with the computers I work with rather than how Microsoft would like them to be). >I just noticed the win32wnet wrappers have MUCH better documentation... is >win32net depreciated or otherwise less desired than win32wnet (should I read >into it that way)? > Actually it was the MSDN Library docs that noted that if the targeted platform is win32 then you can use WNetAddConnection2. Although I haven't used the WNet* apis very much that doc suggests to me that the WNet* stuff is newer. > >I'll work with your suggestion, thanks again. Next time I have a problem >like this I won't assume the first API I found is the only one that can do >the task either. :-) > Oh most definitely especially when it comes to the win32 apis since they have evolved but continue to carry much of their ancient baggage. -- Jens B. Jorgensen jens.jorgensen@tallan.com "With a focused commitment to our clients and our people, we deliver value through customized technology solutions" -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3108 bytes Desc: S/MIME Cryptographic Signature Url : http://mail.python.org/pipermail/python-win32/attachments/20030419/a2e3ae0e/ smime-0001.bin ------------------------------ _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 End of Python-win32 Digest, Vol 1, Issue 340 ******************************************** From softex at hn.vnn.vn Mon Apr 21 11:36:00 2003 From: softex at hn.vnn.vn (Hung, Le Khanh) Date: Mon Apr 21 13:30:51 2003 Subject: [python-win32] About Embeeding python in C++Builder Message-ID: <005701c307b7$26e669b0$5919a8c0@hungsoftex> Dear friends! I tryed to embed python in C++Builder 5 I've made converting python22.lib to C++Builder format and then tryed to run simple example but Link errors appeared: " Unresolved external __Py_RefTotal referenced from UNIT1.OBJ " " Unresolved external __Py_Dealloc referenced from UNIT1.OBJ " Please help me! what else i should include in my C++ project? Thanks Hung -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20030421/a7c2ae65/attachment.htm From scottprive at earthlink.net Mon Apr 21 16:13:40 2003 From: scottprive at earthlink.net (Scott Prive) Date: Mon Apr 21 14:52:57 2003 Subject: [python-win32] RE: Python-win32 Digest, Vol 1, Issue 340 References: <009b01c30812$91dc8e10$3f00a8c0@larrywxp> Message-ID: <008301c3083a$1f6b31b0$0601a8c0@scottprive.com> Thanks Larry. I have not used unicode in my scripts, but I can see I better learn since parts of the API require it. My one remaining question for anyone is why my sample code (see earlier post) actually -worked- using a key called 'passwd'? The seeming fact that 'passwd' worked seems a bit odd. (Not that I am stuck... I have solutions now... I just want to ensure that if there is a bug, that it doesn't escape tracking...) -Scott ----- Original Message ----- From: "Larry Bates" To: Sent: Monday, April 21, 2003 10:30 AM Subject: [python-win32] RE: Python-win32 Digest, Vol 1, Issue 340 > Just jumping in here. I've successfully used > NetUseAdd to dynamically map drives inside of > my programs. Don't forget that things must > be passed to NetUseAdd as unicode strings > inside the dictionary. > > Here is a code snippet from a working program: > > > use_dict={} > use_dict['local']=unicode(local) > use_dict['remote']=unicode(remote) > use_dict['password']=unicode(password) > use_dict['username']=unicode(username) > # > # Now add this drive mapping > # > try: win32net.NetUseAdd(None, 2, use_dict) > except: > print "Unable to map %s to %s" % (local, remote) > > where local=, remote=, > password=, username=. > > FYI, > Larry Bates > Syscon, Inc. > > -----Original Message----- > From: python-win32-bounces@python.org > [mailto:python-win32-bounces@python.org]On Behalf Of > python-win32-request@python.org > Sent: Saturday, April 19, 2003 11:03 AM > To: python-win32@python.org > Subject: Python-win32 Digest, Vol 1, Issue 340 > > > Send Python-win32 mailing list submissions to > python-win32@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-win32 > or, via email, send a message with subject or body 'help' to > python-win32-request@python.org > > You can reach the person managing the list at > python-win32-owner@python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Python-win32 digest..." > > > Today's Topics: > > 1. Re: win32net.NetUseAdd buglet (or doc buglet) (Scott Prive) > 2. makepy, Word & Case sensitivity (Bob Gailer) > 3. Re: win32net.NetUseAdd buglet (or doc buglet) (Jens B. Jorgensen) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Fri, 18 Apr 2003 17:55:20 -0400 > From: "Scott Prive" > Subject: Re: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > To: "Jens B. Jorgensen" > Cc: python-win32@python.org > Message-ID: <00fe01c305f5$36623cc0$0601a8c0@scottprive.com> > Content-Type: text/plain; charset="iso-8859-1" > > Hi Jens, > > Thank you for your reply and your suggestion. > > The reason I picked NetUseAdd() was it was what showed up in my Google > search for "python drive map" -- I did not know about > win32wnet.WNetAddConnection2... I'm used to wrapping shell commands in > functions... naturally I want to get away from such silliness :-) > > Re: NetUseAdd(), what docs were you looking at? I could see on the > ActiveState documentation online, that gave a brief description of the API > NetUseAdd()... then referred to the MSDN website for more info, which did > show a username/password. You can see in my output, it actually *does* work > (or seems to even if I interact with the mount manually). > > I just noticed the win32wnet wrappers have MUCH better documentation... is > win32net depreciated or otherwise less desired than win32wnet (should I read > into it that way)? > > I'll work with your suggestion, thanks again. Next time I have a problem > like this I won't assume the first API I found is the only one that can do > the task either. :-) > > -Scott > > > > > > ----- Original Message ----- > From: "Jens B. Jorgensen" > To: "Scott Prive" > Cc: > Sent: Friday, April 18, 2003 4:56 PM > Subject: Re: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > > > > Scott, > > > > According to the docs I'm looking at NetUseAdd doesn't accept username > > at all. However, why not use win32wnet.WNetAddConnection2 instead? I > > tried this out on my box and it worked great. Here's what I did: > > > > win32wnet.WNetAddConnection2(win32netcon.RESOURCETYPE_DISK, 'y:', > > '\\\\servername\\sharename', None, 'domain\\username', 'password', 0) > > > > It worked great. > > > > Scott Prive wrote: > > > > >Hi all, > > > > > >I replied to Mark/All, but I think anyone could jump in with an answer. > > > > > >The example code is ready to run and I included output from the debugger. > > >Please someone try it out and tell me if my results were reproducible. > > > > > >Basically NetUseAdd() -- on my system at least -- seems to require the > key > > >['passwd'] and fails with ['password']. Mark says the reverse condition > > >should be true, which leads me to wonder... what am I doing wrong? Should > I > > >ditch ActiveState and use python.org + win32all? I'll do that if > necessary > > >and is the source of my problem. > > > > > >thanks a bunch, > > >Scott > > > > > > > > > > > > > > >----- Original Message ----- > > >From: "Scott Prive" > > >To: "Mark Hammond" ; > > >Sent: Wednesday, April 16, 2003 11:36 PM > > >Subject: Re: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > > > > > > > > > > > > > > >>----- Original Message ----- > > >>From: "Mark Hammond" > > >>To: "'Scott Prive'" > > >>Sent: Wednesday, April 16, 2003 7:10 PM > > >>Subject: RE: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > > >> > > >> > > >> > > >> > > >>>>that share info is passed to the function in the form of a dictionary. > > >>>>There's no example usage [sorry to complain, wish there > > >>>>were...] but it does > > >>>>point me to MSDN for more info. > > >>>> > > >>>> > > >>>I think you will find examples in the Python Programming on Win32 book. > > >>> > > >>> > > >>Actually I -have- your book :-) > > >>Until I finish Lutz' Programming Python, your Win32 is serving as a > > >>reference (it's next tho!). > > >> > > >>Searching the index, I did not see win32net.NetUseAdd (other win32net > > >>relatives are listed). > > >>... It could be an index omission, in which case I'll see it eventually. > > >> > > >> > > >> > > >>>>The problem? > > >>>> > > >>>>The MSDN documentation has example usage (share path, user, > > >>>>password etc.). > > >>>>But in their example they call password, "password".... the > > >>>>Pythin win32 > > >>>>wrapper doesn't understand ['password'] (and does not raise > > >>>>an exception on > > >>>>its use), but it DOES understand ['passwd']. > > >>>> > > >>>>So either MSDN is wrong or the wrapper's got a buglet. :-) > > >>>> > > >>>> > > >>>None of these wrappers raise an exception on a bad attribute name - > they > > >>>should. But in this case, the attribute is certainly named "password". > > >>> > > >>> > > >I > > > > > > > > >>>expect that simply the underlying Win32 call is failing for you. > > >>> > > >>>Mark. > > >>> > > >>> > > >>I'm certain it appears only to work with 'passwd', but if something's > > >> > > >> > > >going > > > > > > > > >>on under the hood it's quite interesting. Below is an interactive > > >> > > >> > > >session, > > > > > > > > >>followed by the actual code. > > >> > > >>You can see the difference between the two functions is the password > > >> > > >> > > >entry. > > > > > > > > >>I've tried this with other accounts. The same credentials were tested > > >> > > >> > > >under > > > > > > > > >>CMD.EXE using 'net use'. The accounts exist on a win2K Server PDC, which > > >> > > >> > > >is > > > > > > > > >>the same server I'm mounting the share from. Each time I tested, I > started > > >>from a clean slate and verified nothing (at all) is listed under plain > > >> > > >> > > >'net > > > > > > > > >>use' > > >> > > >>When I get a mount from my function (under 'passwd'), I validate it by > > >>echoing text to a file on Z:\test.txt. > > >>If the 'password' function ran, which never provided a mount, this step > > >>yields a "system cannot find the path specified." > > >> > > >>Any thoughts? Thanks. > > >>-Scott > > >> > > >>---------- interactive ------------ > > >>E:\scott\Komodo\ntlm_cifs>dir z: > > >>The system cannot find the path specified. > > >> > > >>E:\scott\Komodo\ntlm_cifs>python > > >>ActivePython 2.2.2 Build 224 (ActiveState Corp.) based on > > >>Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)] on win32 > > >>Type "help", "copyright", "credits" or "license" for more information. > > >> > > >> > > >>>>>from testmap import * > > >>>>>mountShare > > >>>>> > > >>>>> > > >> > > >> > > >> > > >>>>>mountShare() > > >>>>> > > >>>>> > > >>This drive letter was in use, so I'll unmount it > > >>Good. Verified drive letter is not already mounted. > > >>Traceback (most recent call last): > > >> File "", line 1, in ? > > >> File "testmap.py", line 20, in mountShare > > >> win32net.NetUseAdd(None,1,data) > > >>pywintypes.api_error: (1326, 'NetUseAdd', 'Logon failure: unknown user > > >> > > >> > > >name > > > > > > > > >>or b > > >>ad password.') > > >> > > >> > > >>>>>mountShare2() > > >>>>> > > >>>>> > > >>This drive letter was in use, so I'll unmount it > > >>Good. Verified drive letter is not already mounted. > > >> > > >> > > >>----------------code--------------- > > >>#!/usr/bin/python > > >> > > >>import string, sys, win32file, win32net > > >> > > >>def mountShare(): > > >> """A CIFS mount interface, wraps win32 API call NetUseAdd""" > > >> #see ASPN docs win32wnet.NetUseAdd and win32net.NetUseAdd > > >> try: > > >> print "This drive letter was in use, so I'll unmount it" > > >> unmountShare() > > >> except: > > >> print 'Good. Verified drive letter is not already mounted. ' > > >> data = { > > >> 'remote' : r'\\rogue.scottprive.com\account1', > > >> 'local' : 'Z:', > > >> 'password' : 'foo', > > >> 'user' : 'foo', > > >> 'asg_type' : 0, > > >> } > > >> win32net.NetUseAdd(None,1,data) > > >> > > >>def mountShare2(): > > >> """A CIFS mount interface, wraps win32 API call NetUseAdd""" > > >> #see ASPN docs win32wnet.NetUseAdd and win32net.NetUseAdd > > >> try: > > >> print "This drive letter was in use, so I'll unmount it" > > >> unmountShare() > > >> except: > > >> print 'Good. Verified drive letter is not already mounted. ' > > >> data = { > > >> 'remote' : r'\\rogue.scottprive.com\account1', > > >> 'local' : 'Z:', > > >> 'passwd' : 'foo', > > >> 'user' : 'foo', > > >> 'asg_type' : 0, > > >> } > > >> win32net.NetUseAdd(None,1,data) > > >> > > >>def unmountShare(): > > >> win32net.NetUseDel(None,'Z:',0) > > >> > > >> > > >>def main(): > > >> mountShare() > > >> mountShare2() > > >> > > >>if __name__ == '__main__': main() > > >> > > >> > > >> > > >> > > >> > > >> > > >>_______________________________________________ > > >>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 > > > > > > > > > > -- > > Jens B. Jorgensen > > jens.jorgensen@tallan.com > > > > "With a focused commitment to our clients and our people, we deliver value > through customized technology solutions" > > > > > > > > ------------------------------ > > Message: 2 > Date: Fri, 18 Apr 2003 18:57:30 -0600 > From: Bob Gailer > Subject: [python-win32] makepy, Word & Case sensitivity > To: python-win32@python.org > Message-ID: <5.2.0.9.0.20030418185507.0303ab50@66.28.54.253> > Content-Type: text/plain; charset="us-ascii" > > Before running makepy on MS Word, properties were case insensitive. Thus > one could refer to visible or Visible. Aftert running makepy on MS Word > properties are case sensitive. Only Visible is valid. That has cost a bunch > of debugging time. > > 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.467 / Virus Database: 266 - Release Date: 4/1/2003 > > ------------------------------ > > Message: 3 > Date: Sat, 19 Apr 2003 10:41:21 -0500 > From: "Jens B. Jorgensen" > Subject: Re: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > To: Scott Prive > Cc: python-win32@python.org > Message-ID: <3EA16E21.2060201@tallan.com> > Content-Type: text/plain; charset="us-ascii" > > Scott Prive wrote: > > >Hi Jens, > > > >Thank you for your reply and your suggestion. > > > >The reason I picked NetUseAdd() was it was what showed up in my Google > >search for "python drive map" -- I did not know about > >win32wnet.WNetAddConnection2... I'm used to wrapping shell commands in > >functions... naturally I want to get away from such silliness :-) > > > >Re: NetUseAdd(), what docs were you looking at? I could see on the > >ActiveState documentation online, that gave a brief description of the API > >NetUseAdd()... then referred to the MSDN website for more info, which did > >show a username/password. You can see in my output, it actually *does* work > >(or seems to even if I interact with the mount manually). > > > Hmm, ok. I must have been looking at the wrong struct. The one I was > looking at just had a password and I couldn't get the thing to work for > me. I was referring to my copy of MSDN Library (1999! often more > accurate as it portrays things as they are with the computers I work > with rather than how Microsoft would like them to be). > > >I just noticed the win32wnet wrappers have MUCH better documentation... is > >win32net depreciated or otherwise less desired than win32wnet (should I > read > >into it that way)? > > > Actually it was the MSDN Library docs that noted that if the targeted > platform is win32 then you can use WNetAddConnection2. Although I > haven't used the WNet* apis very much that doc suggests to me that the > WNet* stuff is newer. > > > > >I'll work with your suggestion, thanks again. Next time I have a problem > >like this I won't assume the first API I found is the only one that can do > >the task either. :-) > > > Oh most definitely especially when it comes to the win32 apis since they > have evolved but continue to carry much of their ancient baggage. > > -- > Jens B. Jorgensen > jens.jorgensen@tallan.com > > "With a focused commitment to our clients and our people, we deliver value > through customized technology solutions" > > -------------- next part -------------- > A non-text attachment was scrubbed... > Name: smime.p7s > Type: application/x-pkcs7-signature > Size: 3108 bytes > Desc: S/MIME Cryptographic Signature > Url : > http://mail.python.org/pipermail/python-win32/attachments/20030419/a2e3ae0e/ > smime-0001.bin > > ------------------------------ > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > End of Python-win32 Digest, Vol 1, Issue 340 > ******************************************** > > > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From batyi at mail.ru Tue Apr 22 23:20:31 2003 From: batyi at mail.ru (Petr Gladkikh) Date: Tue Apr 22 11:20:42 2003 Subject: [python-win32] Makepy odds? Message-ID: <3730703435.20030422222031@mail.ru> Hello. I have used "win32com.client.gencache.EnsureDispatch('ProgramName')" to generate interface wrappers. Classes in subdirectory of ...\Lib\site-packages\win32com\gen_py\ seems to be OK. But when I try i = win32com.client.Dispatch("ProgramName") Python complains that name "DispatchBaseClass" in declaration "class IClassName(DispatchBaseClass)" is not defined. When I have added "from win32com.client import DispatchBaseClass" before that declaration it works well then. Is it some misconfiguration or perhaps a bug in gencache? -- Best regards, Petr mailto:batyi@mail.ru From mike.owens at allscripts.com Tue Apr 22 10:31:56 2003 From: mike.owens at allscripts.com (Mike Owens) Date: Tue Apr 22 13:15:54 2003 Subject: [python-win32] RE: About Embeeding python in C++Builder Message-ID: <497A92218B5DC14DAA9CE3B2B3D7EF0A023439@ptmail.pttownsend.allscripts.com> It sounds like you haven't added the Python library to the project. Add the lib to the project so the linker knows about it. >> Dear friends! >> >> I tryed to embed python in C++Builder 5 >> I've made converting python22.lib to C++Builder format and then tryed to run simple example >> but Link errors appeared: >> " Unresolved external __Py_RefTotal referenced from UNIT1.OBJ " >> " Unresolved external __Py_Dealloc referenced from UNIT1.OBJ " >> Please help me! what else i should include in my C++ project? >> >> Thanks >> Hung From paul.browning at bristol.ac.uk Tue Apr 22 21:28:39 2003 From: paul.browning at bristol.ac.uk (Paul Browning) Date: Tue Apr 22 15:29:57 2003 Subject: [python-win32] Generating Postscript from Word Message-ID: <49096096.1051043319@[192.168.1.73]> I was reading the code snippets in Hammond & Robertson and have figured that from win32com.client import Dispatch myWord = Dispatch('Word.Application') myWord.Visible = 1 myWord.Documents.Add('f:\\tests\\test1.doc') myWord.PrintOut() gives me hard-copy on my currently selected printer. However, I'd like to generate Postscript silently from Word. Doing myWord.ActivePrinter = 'Apple LaserWriter 16/600 PS' selects the right driver but I how do I pass a filename for the output so as to avoid the dialogue box that pops up? TIA Paul -- The Library, Tyndall Avenue, Univ. of Bristol, Bristol, BS8 1TJ, UK E-mail: paul.browning@bristol.ac.uk URL: http://www.bris.ac.uk/ From bgailer at alum.rpi.edu Tue Apr 22 14:49:00 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Tue Apr 22 15:49:09 2003 Subject: [python-win32] Generating Postscript from Word In-Reply-To: <49096096.1051043319@[192.168.1.73]> Message-ID: <5.2.0.9.0.20030422134502.0300b6b8@66.28.54.253> At 08:28 PM 4/22/2003 +0100, Paul Browning wrote: >from win32com.client import Dispatch >myWord = Dispatch('Word.Application') >myWord.Visible = 1 >myWord.Documents.Add('f:\\tests\\test1.doc') >myWord.PrintOut() > >gives me hard-copy on my currently selected printer. > >However, I'd like to generate Postscript silently from Word. Doing > >myWord.ActivePrinter = 'Apple LaserWriter 16/600 PS' > >selects the right driver but I how do I pass a filename >for the output so as to avoid the dialogue box that >pops up? doc = myWord.Documents.Add('f:\\tests\\test1.doc') myWord.doc.PrintOut() Make friends with the object browser in the visual basic editor under word. You could look up PrintOut and see which objects it applies to. 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.467 / Virus Database: 266 - Release Date: 4/1/2003 From paul.browning at bristol.ac.uk Tue Apr 22 22:24:32 2003 From: paul.browning at bristol.ac.uk (Paul Browning) Date: Tue Apr 22 16:26:07 2003 Subject: [python-win32] Generating Postscript from Word In-Reply-To: <5.2.0.9.0.20030422134502.0300b6b8@66.28.54.253> References: <5.2.0.9.0.20030422134502.0300b6b8@66.28.54.253> Message-ID: <52448406.1051046672@[192.168.1.73]> --On 22 April 2003 13:49 -0600 Bob Gailer wrote: >> However, I'd like to generate Postscript silently from Word. Doing >> >> myWord.ActivePrinter = 'Apple LaserWriter 16/600 PS' >> >> selects the right driver but I how do I pass a filename >> for the output so as to avoid the dialogue box that >> pops up? > > doc = myWord.Documents.Add('f:\\tests\\test1.doc') > myWord.doc.PrintOut() > > Make friends with the object browser in the visual basic editor under > word. You could look up PrintOut and see which objects it applies to. Wow - thanks. That's a voyage of discovery. I guess this is the right info: Sub PrintOut([Background], [Append], [Range], [OutputFileName], [From], [To], [Item], [Copies], [Pages], [PageType], [PrintToFile], [Collate], [FileName], [ActivePrinterMacGX], [ManualDuplexPrint], [PrintZoomColumn], [PrintZoomRow], [PrintZoomPaperWidth], [PrintZoomPaperHeight]) So I should do something like: myWord.PrintOut(FileName='f:\\tests\\test1.ps', PrintToFile=1) or myWord.PrintOut(OutputFileName='f:\\tests\\test1.ps', PrintToFile=1) ? I've tried those and a few others without success. How do I approach this without wild guessing? Paul -- The Library, Tyndall Avenue, Univ. of Bristol, Bristol, BS8 1TJ, UK E-mail: paul.browning@bristol.ac.uk URL: http://www.bris.ac.uk/ From bgailer at alum.rpi.edu Tue Apr 22 16:18:14 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Tue Apr 22 17:18:23 2003 Subject: [python-win32] Generating Postscript from Word In-Reply-To: <52448406.1051046672@[192.168.1.73]> References: <5.2.0.9.0.20030422134502.0300b6b8@66.28.54.253> <5.2.0.9.0.20030422134502.0300b6b8@66.28.54.253> Message-ID: <5.2.0.9.0.20030422151634.02fcc568@66.28.54.253> At 09:24 PM 4/22/2003 +0100, Paul Browning wrote: >--On 22 April 2003 13:49 -0600 Bob Gailer wrote: > >>>However, I'd like to generate Postscript silently from Word. Doing >>> >>>myWord.ActivePrinter = 'Apple LaserWriter 16/600 PS' >>> >>>selects the right driver but I how do I pass a filename >>>for the output so as to avoid the dialogue box that >>>pops up? >> >>doc = myWord.Documents.Add('f:\\tests\\test1.doc') >>myWord.doc.PrintOut() >> >>Make friends with the object browser in the visual basic editor under >>word. You could look up PrintOut and see which objects it applies to. > >Wow - thanks. That's a voyage of discovery. I guess this is the right info: > >Sub PrintOut([Background], [Append], [Range], [OutputFileName], [From], >[To], [Item], [Copies], [Pages], [PageType], [PrintToFile], [Collate], >[FileName], [ActivePrinterMacGX], [ManualDuplexPrint], [PrintZoomColumn], >[PrintZoomRow], [PrintZoomPaperWidth], [PrintZoomPaperHeight]) > >So I should do something like: > >myWord.PrintOut(FileName='f:\\tests\\test1.ps', PrintToFile=1) >or >myWord.PrintOut(OutputFileName='f:\\tests\\test1.ps', PrintToFile=1) Please review my code above (myWord.doc.PrintOut()) . You should use the PrintOut() method of the document object not the application object.. 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.467 / Virus Database: 266 - Release Date: 4/1/2003 From mhammond at skippinet.com.au Wed Apr 23 10:59:56 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Apr 22 20:00:33 2003 Subject: [python-win32] makepy, Word & Case sensitivity In-Reply-To: <5.2.0.9.0.20030418185507.0303ab50@66.28.54.253> Message-ID: <000b01c3092b$4717ed60$530f8490@eden> > Before running makepy on MS Word, properties were case > insensitive. Thus > one could refer to visible or Visible. Aftert running makepy > on MS Word > properties are case sensitive. Only Visible is valid. That > has cost a bunch > of debugging time. This is documented pretty much everywhere that makepy is documented :) There is really nothing I can do about this, other than to introduce hacks so makepy generated objects are case insensitive, and that just isn't Python! Mark. From mhammond at skippinet.com.au Wed Apr 23 11:28:44 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Apr 22 20:29:40 2003 Subject: [python-win32] win32net.NetUseAdd buglet (or doc buglet) In-Reply-To: <00fe01c305f5$36623cc0$0601a8c0@scottprive.com> Message-ID: <001301c3092f$4d0fcd60$530f8490@eden> > Re: NetUseAdd(), what docs were you looking at? I could see on the > ActiveState documentation online, that gave a brief > description of the API > NetUseAdd()... Their online docs say "Help file built: 06/04/01", but their docs are as bad as what I have here - it says almost nothing!! I can't see how these docs gave you *any* info about the structure names, without manually looking for the PyUSE_INFO structures. I have updated the docs to at least point to the relevent USE_INFO structure documentation, and it is here that you find the magic attribute names needed (or in the MSDN docs on these same structures). ActiveState are a little behind in their releases, but the last major update to win32net was ages ago. > then referred to the MSDN website for more > info, which did > show a username/password. What URL? > You can see in my output, it > actually *does* work > (or seems to even if I interact with the mount manually). Note that these functions will generally ignore elements they don't understand. So check that your code actually needs this item at all. > I just noticed the win32wnet wrappers have MUCH better > documentation... is > win32net depreciated or otherwise less desired than win32wnet > (should I read > into it that way)? The win32wnet functions are designed for "simple" tasks, and are available on Windows 9x. win32net is more for administration tasks, and is only available for NT. win32net can do a real lot, but getting your head around these level "structure-dictionaries" can be hard. Mark. From bgailer at alum.rpi.edu Tue Apr 22 19:48:25 2003 From: bgailer at alum.rpi.edu (Bob Gailer) Date: Tue Apr 22 20:48:31 2003 Subject: [python-win32] makepy, Word & Case sensitivity In-Reply-To: <000b01c3092b$4717ed60$530f8490@eden> References: <5.2.0.9.0.20030418185507.0303ab50@66.28.54.253> Message-ID: <5.2.0.9.0.20030422184741.03061bd0@66.28.54.253> At 09:59 AM 4/23/2003 +1000, Mark Hammond wrote: > > Before running makepy on MS Word, properties were case > > insensitive. Thus > > one could refer to visible or Visible. Aftert running makepy > > on MS Word > > properties are case sensitive. Only Visible is valid. That > > has cost a bunch > > of debugging time. > >This is documented pretty much everywhere that makepy is documented :) >There is really nothing I can do about this, other than to introduce hacks >so makepy generated objects are case insensitive, and that just isn't >Python! I guess then that I'd prefer to have the non-makepy interfaces also case sensitive. 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.467 / Virus Database: 266 - Release Date: 4/1/2003 From mhammond at skippinet.com.au Wed Apr 23 12:25:34 2003 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue Apr 22 21:26:45 2003 Subject: [python-win32] makepy, Word & Case sensitivity In-Reply-To: <5.2.0.9.0.20030422184741.03061bd0@66.28.54.253> Message-ID: <001301c30937$3d7317b0$530f8490@eden> > I guess then that I'd prefer to have the non-makepy > interfaces also case > sensitive. But I can't do that either - that is up to the object implementation. Mark. From batyi at mail.ru Wed Apr 23 19:04:04 2003 From: batyi at mail.ru (Petr Gladkikh) Date: Wed Apr 23 07:04:13 2003 Subject: [python-win32] EnsureDispatch function Message-ID: <160801722115.20030423180404@mail.ru> Hello. In my last posting I asked about win32com.client.gencache.EnsureDispatch(...) function. Here is what I have find out. If to use "win32com.client.gencache.EnsureDispatch('SourceSafe', 1)" (latter parameter is by default). This function generates Python classes in subdirectory of ...\win32com\gen_py. These generated files lack "from win32com.client import DispatchBaseClass" instruction. If to call "win32com.client.gencache.EnsureDispatch('SourceSafe', 0)" the function generates class files right in ...\win32com\gen_py and these files have said import instruction. Here is an exerpt: """ from win32com.client import DispatchBaseClass class IVSS(DispatchBaseClass): """ Because I need some constants related to SourceSafe interface I need generated classes to get these constants and call in form "win32com.client.gencache.EnsureDispatch('SourceSafe', 0)" works fine for me. -- Best regards, Petr mailto:batyi@mail.ru From scottprive at earthlink.net Wed Apr 23 11:54:17 2003 From: scottprive at earthlink.net (Scott Prive) Date: Wed Apr 23 10:33:29 2003 Subject: [python-win32] win32net.NetUseAdd buglet (or doc buglet) References: <001301c3092f$4d0fcd60$530f8490@eden> Message-ID: <000701c309a8$37920ce0$0601a8c0@scottprive.com> ----- Original Message ----- From: "Mark Hammond" To: "'Scott Prive'" Cc: Sent: Tuesday, April 22, 2003 8:28 PM Subject: RE: [python-win32] win32net.NetUseAdd buglet (or doc buglet) > > Re: NetUseAdd(), what docs were you looking at? I could see on the > > ActiveState documentation online, that gave a brief > > description of the API > > NetUseAdd()... > > Their online docs say "Help file built: 06/04/01", but their docs are as bad > as what I have here - it says almost nothing!! I can't see how these docs > gave you *any* info about the structure names, without manually looking for > the PyUSE_INFO structures. I have updated the docs to at least point to the > relevent USE_INFO structure documentation, and it is here that you find the > magic attribute names needed (or in the MSDN docs on these same structures). > > ActiveState are a little behind in their releases, but the last major update > to win32net was ages ago. It's been asserted on the activepython list that it "should" now be safe to install your win32all 15x over AS Python's version, even if you use Komodo (I do). I'll try this first, but switch distributions entirely if I must in order to run the latest. > > > then referred to the MSDN website for more > > info, which did > > show a username/password. > > What URL? http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/net mgmt/netuseadd.asp > > > You can see in my output, it > > actually *does* work > > (or seems to even if I interact with the mount manually). > > Note that these functions will generally ignore elements they don't > understand. So check that your code actually needs this item at all. You nailed it. I did some initial testing before my post, but became misled and didn't isolate it enough. What probably happened is my initial code (both 'password' and 'passwd') sent non-unicode strings. Whatever this translated into (probably nonsense), the function returned 'bad username or password' but only when I used the ['password'] key. I don't know unicode well, but except for my ['remote'] key, everything else should look the same in unicode, no? If not, can you detect non-unicode strings and throw a specific exception for it? Of course, I know you're overloaded with work so the question is theoretical. :-) Jens sent me a corrected snippet that used unicode. I triple checked and tightened my share permissions (removing 'Everyone') and this is indeed working the way it is expected to. > > > I just noticed the win32wnet wrappers have MUCH better > > documentation... is > > win32net depreciated or otherwise less desired than win32wnet > > (should I read > > into it that way)? > > The win32wnet functions are designed for "simple" tasks, and are available > on Windows 9x. win32net is more for administration tasks, and is only > available for NT. win32net can do a real lot, but getting your head around > these level "structure-dictionaries" can be hard. Understood; I'll use each when appropriate. I also start front-to-back reading of your book today -- I hope it has been sucessful for you. :-D > > Mark. > From scottprive at earthlink.net Wed Apr 23 12:12:33 2003 From: scottprive at earthlink.net (Scott Prive) Date: Wed Apr 23 10:51:48 2003 Subject: [python-win32] win32net.NetUseAdd buglet (or doc buglet) References: <001301c3092f$4d0fcd60$530f8490@eden> <000701c309a8$37920ce0$0601a8c0@scottprive.com> Message-ID: <001101c309aa$c48de630$0601a8c0@scottprive.com> > What probably happened is my initial code (both 'password' and 'passwd') > sent non-unicode strings. Whatever this translated into (probably nonsense), > the function returned 'bad username or password' but only when I used the > ['password'] key. ...and of course I meant to say, when I used ['passwd'] this unknown key was dropped... so it used my current credentials, which "worked" because I still had "Everyone" enabled on the share. Tightening the share revealed this. -Scott From KKGOLFER at aol.com Tue Apr 22 14:51:52 2003 From: KKGOLFER at aol.com (KKGOLFER@aol.com) Date: Wed Apr 23 12:00:01 2003 Subject: [python-win32] Quick Question Message-ID: <1CF5DBDA.5EF3E1BC.006F9B01@aol.com> I guess because I am new and not a programmer, I don't know the right term for this, so I haven't had any luck looking it up in the books I have..... What I want to do is to build in a delay for a few (maybe 10-20) seconds, while I go to another program and paste something...... Here's the suggestion I got, but so far, I don't see it working. "for i in range(1, 25): amsgui.Yield()" The only other option I can think of is to add an alert (using an API for the software package I am using Python with).....but I really don't want to add any more keystrokes than I already have....... Thank you very much for your suggestions. Karol From Jim.Vickroy at noaa.gov Wed Apr 23 11:35:50 2003 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Wed Apr 23 12:35:56 2003 Subject: [python-win32] Quick Question References: <1CF5DBDA.5EF3E1BC.006F9B01@aol.com> Message-ID: <3EA6C0E6.AF651C26@noaa.gov> Look at the time module, in the standard Python distribution, and the sleep() function in particular to see if that meets your needs. KKGOLFER@aol.com wrote: > I guess because I am new and not a programmer, I don't know the right term for this, so I haven't had any luck looking it up in the books I have..... > > What I want to do is to build in a delay for a few (maybe 10-20) seconds, while I go to another program and paste something...... > > Here's the suggestion I got, but so far, I don't see it working. > > "for i in range(1, 25): > amsgui.Yield()" > > The only other option I can think of is to add an alert (using an API for the software package I am using Python with).....but I really don't want to add any more keystrokes than I already have....... > > Thank you very much for your suggestions. > > Karol > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 From jasonou at yahoo.com Wed Apr 23 14:14:57 2003 From: jasonou at yahoo.com (Jingzhao Ou) Date: Wed Apr 23 16:15:08 2003 Subject: [python-win32] Command history in PythonWin In-Reply-To: <3EA6C0E6.AF651C26@noaa.gov> Message-ID: <20030423201457.10998.qmail@web80101.mail.yahoo.com> Hi, all, I am now using PythonWin on my WinXP. It is very good and I like it very much. However, I cannot find out how to get the command history in it. If this is available, would any one mind telling me? Thanks a lot! Best regards, Jingzhao From jens.jorgensen at tallan.com Wed Apr 23 16:33:13 2003 From: jens.jorgensen at tallan.com (Jens B. Jorgensen) Date: Wed Apr 23 16:33:41 2003 Subject: [python-win32] Command history in PythonWin In-Reply-To: <20030423201457.10998.qmail@web80101.mail.yahoo.com> References: <20030423201457.10998.qmail@web80101.mail.yahoo.com> Message-ID: <3EA6F889.9010403@tallan.com> If you mean what I think you mean try hitting CTRL- Jingzhao Ou wrote: >Hi, all, > >I am now using PythonWin on my WinXP. It is very good and I like it very much. >However, I cannot find out how to get the command history in it. If this is >available, would any one mind telling me? Thanks a lot! > >Best regards, >Jingzhao > >_______________________________________________ >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 magnus at thinkware.se Wed Apr 23 23:42:56 2003 From: magnus at thinkware.se (Magnus =?iso-8859-1?Q?Lyck=E5?=) Date: Wed Apr 23 16:42:02 2003 Subject: [python-win32] Command history in PythonWin In-Reply-To: <20030423201457.10998.qmail@web80101.mail.yahoo.com> References: <3EA6C0E6.AF651C26@noaa.gov> Message-ID: <5.2.1.1.0.20030423224203.0267eee8@www.thinkware.se> At 13:14 2003-04-23 -0700, Jingzhao Ou wrote: >I am now using PythonWin on my WinXP. It is very good and I like it very much. >However, I cannot find out how to get the command history in it. If this is >available, would any one mind telling me? Thanks a lot! Ctrl-ArrowUp/Down -- Magnus Lycka (It's really Lyckå), magnus@thinkware.se Thinkware AB, Sweden, www.thinkware.se I code Python ~ The shortest path from thought to working program From jasonou at yahoo.com Wed Apr 23 14:54:20 2003 From: jasonou at yahoo.com (Jingzhao Ou) Date: Wed Apr 23 16:54:24 2003 Subject: [python-win32] Command history in PythonWin In-Reply-To: <5.2.1.1.0.20030423224203.0267eee8@www.thinkware.se> Message-ID: <20030423205420.67860.qmail@web80107.mail.yahoo.com> Hi, Jens and Magnus, Thanks a lot! That is exactly what I want. Great! Best regards, Jingzhao --- Magnus Lyckå wrote: > At 13:14 2003-04-23 -0700, Jingzhao Ou wrote: > >I am now using PythonWin on my WinXP. It is very good and I like it very > much. > >However, I cannot find out how to get the command history in it. If this is > >available, would any one mind telling me? Thanks a lot! > > Ctrl-ArrowUp/Down > From nsis5 at allstate.com Fri Apr 25 10:30:06 2003 From: nsis5 at allstate.com (Sison, Nick) Date: Fri Apr 25 10:30:53 2003 Subject: [python-win32] Python install in CMD Message-ID: <4DF4786A05BDCA4BA5AC004319816880028A7607@a0001-xpo0113-s.hodc.ad.allstate.com> Best regards to all! I was wondering if someone can tell me if there is a /switch I can add to the Python executable at the Command Prompt to do a "silent" install using the default settings without any prompting? Any information is greatly appreciated... Thanks! ps. This in in a Win2000 environment... Nick From vishnu_mahendra at yahoo.com Fri Apr 25 09:43:39 2003 From: vishnu_mahendra at yahoo.com (vishnu mahendra) Date: Fri Apr 25 11:44:18 2003 Subject: [python-win32] printing(hardcopy) error in python in windows Message-ID: <20030425154339.40322.qmail@web40805.mail.yahoo.com> sir, can you help me to print a hard copy. i am using python2.0 in win32 using dot matrix as my default printer.i have pythonwin too. i searched and i got something simillar to printing but --------------------------------------- import win32print def rawprint(data="hai",jobname='TEST DOC',printerName=None): if printerName==None: printerName=win32print.GetDefaultPrinter() print printerName printerHandle=win32print.OpenPrinter(printerName) print printerHandle printJob=win32print.StartDocPrinter(printerHandle,1,(jobname,None,None)) print printJob win32print.WritePrinter(printerHandle,data) win32print.EndDocPrinter(printerHandle) win32print.ClosePrinter(printerHandle) rawprint() ---------------------------------------- error: Epson LX-300 4304748 Traceback (innermost last): File "d:/pro/printerfun.py", line 13, in ? rawprint() File "d:/pro/printerfun.py", line 8, in rawprint printJob=win32print.StartDocPrinter(printerHandle,1,(jobname,None,None)) AttributeError: StartDocPrinter i also gone through pythonwin help and i found PyCPrintInfo Object. i tried my best, i have not found how to use that object.please help me. thank you in advance, vishnu __________________________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo http://search.yahoo.com From theller at python.net Fri Apr 25 16:46:35 2003 From: theller at python.net (Thomas Heller) Date: Fri Apr 25 11:46:37 2003 Subject: [python-win32] Re: Python install in CMD References: <4DF4786A05BDCA4BA5AC004319816880028A7607@a0001-xpo0113-s.hodc.ad.allstate.com> Message-ID: <7k9ieg3k.fsf@python.net> "Sison, Nick" writes: > Best regards to all! > > I was wondering if someone can tell me if there is a /switch I can add to > the Python executable at the Command Prompt to do a "silent" install using > the default settings without any prompting? > I've posted this before, but here we go again: the command line options for Wise created installers. It seems /S is what you need. Thomas Option Function /T Install in Test mode. /X pathname Extracts files to pathname. /Z pathname Extracts files to pathname, then reboots. /M Runs installation in manual mode, prompting for system directories such as Windows, System, etc. /M=filename Specifies a value file for installation. See Set Variable for more information on reading variables. /M1 Displays the name of each self-registering .OCX or .DLL as it is registered. /M2 Reserved for internal use by the Wise Installation System during debugging sessions. /M5=dir_name During installation, temporary files are written to the hard drive. On some locked-down machines with restricted privileges, these temporary files might fail to write, resulting in a failed installation. Use this command line option to specify a directory name for a directory to which the user has write privileges. /S Silent mode, automatic mode with no user choices. ? 2001 Wise Solutions, Inc. All Rights Reserved. This documentation and the accompanying software are copyrighted materials. Making unauthorized copies is prohibited by law. From nsis5 at allstate.com Fri Apr 25 15:02:38 2003 From: nsis5 at allstate.com (Sison, Nick) Date: Fri Apr 25 15:04:09 2003 Subject: [python-win32] Re: Python install in CMD Message-ID: <4DF4786A05BDCA4BA5AC004319816880028A760F@a0001-xpo0113-s.hodc.ad.allstate.com> Thanks! I will try that. Will this also apply to the Win32all-152.exe package? -----Original Message----- From: Thomas Heller [mailto:theller@python.net] Sent: Friday, April 25, 2003 10:45 AM To: python-win32@python.org Subject: [python-win32] Re: Python install in CMD "Sison, Nick" writes: > Best regards to all! > > I was wondering if someone can tell me if there is a /switch I can add to > the Python executable at the Command Prompt to do a "silent" install using > the default settings without any prompting? > I've posted this before, but here we go again: the command line options for Wise created installers. It seems /S is what you need. Thomas Option Function /T Install in Test mode. /X pathname Extracts files to pathname. /Z pathname Extracts files to pathname, then reboots. /M Runs installation in manual mode, prompting for system directories such as Windows, System, etc. /M=filename Specifies a value file for installation. See Set Variable for more information on reading variables. /M1 Displays the name of each self-registering .OCX or .DLL as it is registered. /M2 Reserved for internal use by the Wise Installation System during debugging sessions. /M5=dir_name During installation, temporary files are written to the hard drive. On some locked-down machines with restricted privileges, these temporary files might fail to write, resulting in a failed installation. Use this command line option to specify a directory name for a directory to which the user has write privileges. /S Silent mode, automatic mode with no user choices. ? 2001 Wise Solutions, Inc. All Rights Reserved. This documentation and the accompanying software are copyrighted materials. Making unauthorized copies is prohibited by law. _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32 From theller at python.net Fri Apr 25 20:16:26 2003 From: theller at python.net (Thomas Heller) Date: Fri Apr 25 15:16:27 2003 Subject: [python-win32] Re: Python install in CMD References: <4DF4786A05BDCA4BA5AC004319816880028A760F@a0001-xpo0113-s.hodc.ad.allstate.com> Message-ID: "Sison, Nick" writes: > Thanks! I will try that. Will this also apply to the Win32all-152.exe > package? AFAIK, this applies to win32all.exe and python-2.x.exe installers. Thomas From lin at centurysoftware.com.my Mon Apr 28 14:05:01 2003 From: lin at centurysoftware.com.my (Norlin Abd Rahim) Date: Mon Apr 28 01:03:35 2003 Subject: [python-win32] Updating table in Access References: <4DF4786A05BDCA4BA5AC004319816880028A7607@a0001-xpo0113-s.hodc.ad.allstate.com> <7k9ieg3k.fsf@python.net> Message-ID: <3EACB67D.6090601@centurysoftware.com.my> Hi, I have a script : import win32com.client a = win32com.client.Dispatch("access.application") a.DoCmd.TransferSpreadsheet(0,0,"ut_message","new.xls",True) a.DoCmd.TransferSpreadsheet(0,0,"ts_description","desc.xls",True) i've tried few times that if i open the database that i want to update , it works. But now, when i tried it again its not updating. Is this script correct and while running it the database that i want to update must be opened? TIA From sensegin at yahoo.com Mon Apr 28 07:35:49 2003 From: sensegin at yahoo.com (sense gin) Date: Mon Apr 28 09:35:53 2003 Subject: [python-win32] py2exe question Message-ID: <20030428133549.74164.qmail@web14205.mail.yahoo.com> Dear Win32 Python experts, Hi, I am newbie to py2exe, I came to know py2exe from starship http://starship.python.net/crew/theller/py2exe. It is so impressive and it's really a fantastic tools to compile py scripts into exe and dll files in Win32 environment. I have a question here. Hope that you can help me. Scenario: (1) I am using using Python 2.2.2 and py2exe 0.3.3. I have writen 5 py scripts (a.py, b.py, c.py ...) in c:\www\scripts. (2) I want to compile all these py scripts to exe files into c:\www\cgi-bin. So that, I could execute from web. (3) How to compile multiple py scripts and maintain single copy of python22.dll and *.pyd in c:\www\cgi-bin? Example: $ cd c:\www\cgi-bin $ dir/w a.exe, b.exe, c.exe, d.exe, e.exe python22.dll, _sre.pyd Anyone know the way to do it? Appreciate on your help. Thanks in advance. Regards, Sensegin --------------------------------- Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20030428/8f4e9d8a/attachment.htm From sensegin at yahoo.com Mon Apr 28 07:25:50 2003 From: sensegin at yahoo.com (sense gin) Date: Mon Apr 28 12:33:01 2003 Subject: [python-win32] py2exe question Message-ID: <20030428132550.29011.qmail@web14201.mail.yahoo.com> Dear Python Win32 experts, Hi, I am newbie to py2exe, I came to know py2exe from starship. It is so impressive and it's really a fantastic tools to compile py scripts and all necessary libs into dll and exe files in Win32 environment.I have a question here. Hope that you can help me. Scenario: (1) I am using using Python 2.2.2 and py2exe 0.3.3. I have writen 5 py scripts (a.py, b.py, c.py ...) in c:\www\scripts. (2) I want to compile all these py scripts to exe files into c:\www\cgi-bin. So that, I could execute from web. (3) How to compile multiple py scripts and maintain single copy of python22.dll and *.pyd in c:\www\cgi-bin?Example: $ cd c:\www\cgi-bin $ dir/w a.exe, b.exe, c.exe, d.exe, e.exe python22.dll, _sre.pyd Anyone know the way to do it? Appreciate on your help. Thanks in advance. Regards, Sensegin --------------------------------- Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-win32/attachments/20030428/6dfad4a4/attachment.htm From magnus at thinkware.se Wed Apr 30 03:59:46 2003 From: magnus at thinkware.se (Magnus =?iso-8859-1?Q?Lyck=E5?=) Date: Tue Apr 29 20:58:50 2003 Subject: [python-win32] py2exe question In-Reply-To: <20030428133549.74164.qmail@web14205.mail.yahoo.com> Message-ID: <5.2.1.1.0.20030430024349.02693ac0@www.thinkware.se> At 06:35 2003-04-28 -0700, sense gin wrote: >(3) How to compile multiple py scripts and maintain >single copy of python22.dll and *.pyd in >c:\www\cgi-bin? If you have the option, you could make one handler script which imports a, b, c ... and run p2exe on that to get just a single file. Something like this (untested): # handler.py import cgi, a, b, c f = cgi.FieldStorage() action = f['action'].value if action in ['a', 'b', 'c']: locals()[action].main() This means that you use the url http://x/cgi-bin/handler.exe?action=a&x=1&y=2 instead of http://x/cgi-bin/a.exe?x=1&y=2 etc. It also means that a.py etc must be written as modules with a main function, but that's probably a good idea anyway... In Unix you would also have the possibility to make links with different names to handler.exe, and let it work like this instead: # handler.py import os, a, b, c f = os.environ() action = f['SCRIPT_NAME'].split('/')[-1] if action in ['a', 'b', 'c']: locals()[action].main() Then you you wouldn't have to change the URLs, but unfortunately, Windows shortcuts aren't anywhere near as useful as hard or symbolic links in Unix. -- Magnus Lycka (It's really Lyckå), magnus@thinkware.se Thinkware AB, Sweden, www.thinkware.se I code Python ~ The shortest path from thought to working program