From mhammond at skippinet.com.au Sun Jun 1 00:24:42 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 1 Jun 2008 08:24:42 +1000 Subject: [python-win32] pywin32 build 211 released In-Reply-To: <4841593F.7040401@gmail.com> References: <003b01c8c2ee$8ec50260$ac4f0720$@com.au> <4841593F.7040401@gmail.com> Message-ID: <00a401c8c36d$25cb2120$71616360$@com.au> > I just ran the installer. Under Help - About it claims to be build > 210.9! Bugger - that was a breakdown in my packaging process :( pywin32.version.txt still has 210.9 in it, but you certainly have build 211 there. My apologies - you can edit this .txt file if it worries you. Cheers, Mark From aleksandrv at berkeley.edu Mon Jun 2 20:19:28 2008 From: aleksandrv at berkeley.edu (shurik) Date: Mon, 2 Jun 2008 11:19:28 -0700 (PDT) Subject: [python-win32] Exception setting a string using COM In-Reply-To: <48409C53.8020205@probo.com> References: <7918C1A70119A34887246E1DEC04C65302A7B27A@coemailsrv.coe.berkeley.edu> <48409C53.8020205@probo.com> Message-ID: <17606929.post@talk.nabble.com> I was able to resolve this. The file application was interacting with resided on a network share. Once I copied it to a local volume I was able to manipulate the string without a problem. Thanks, Aleksandr Tim Roberts wrote: > > Aleksandr VLADIMIRSKIY wrote: >> I'm attempting to set a string value using a COM interface to an >> application. I get the following traceback. Could anyone help me >> understand the nature of the error or how I might begin to discover it? >> ... >> >> In [11]: item.Path = "" >> --------------------------------------------------------------------------- >> pywintypes.com_error Traceback (most >> recent call last) >> >> C:\ >> >> c:\python24\lib\site-packages\win32com\client\__init__.py in >> __setattr__(self, attr, value) >> 461 except KeyError: >> 462 raise AttributeError, "'%s' object has no >> attribute '%s'" % (repr(self), attr) >> --> 463 self._oleobj_.Invoke(*(args + (value,) + >> defArgs)) >> 464 def _get_good_single_object_(self, obj, obUserName=None, >> resultCLSID=None): >> 465 return _get_good_single_object_(obj, obUserName, >> resultCLSID) >> >> com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, >> -2147467259), None) >> > > -2147467259 is 80004005, which is the rather unhelpful E_FAIL. > > Sometimes, when it is mapping a settable/gettable property, the Python > COM mapper creates a separate method for setting. You might try: > item.setPath( "" ) > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- View this message in context: http://www.nabble.com/Exception-setting-a-string-using-COM-tp17570153p17606929.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From hanni.ali at gmail.com Mon Jun 2 10:36:13 2008 From: hanni.ali at gmail.com (Hanni Ali) Date: Mon, 2 Jun 2008 09:36:13 +0100 Subject: [python-win32] building pywin32 on Server 2003 x64 In-Reply-To: <005601c8c310$b23fd540$16bf7fc0$@com.au> References: <789d27b10805300600p24997328x737b8a831361f179@mail.gmail.com> <02d701c8c2a5$c722fb10$5568f130$@com.au> <0BCB4AE868D8934A8B3DCE3A58126A89022AF3A7@tewk-mbpf3> <002f01c8c2e5$754ab9f0$5fe02dd0$@com.au> <789d27b10805310137j48c7dcefr8b7d103ce88833c8@mail.gmail.com> <005601c8c310$b23fd540$16bf7fc0$@com.au> Message-ID: <789d27b10806020136x71ab2b1bt917e910365c918be@mail.gmail.com> Hi Mark Pedantic side-note: best I can tell, all the compilers are x86 binaries, so > even on a 64bit OS, we are still cross-compiling :) You are of course correct, I should have said I am developing on a 64 bit machine. > Grab the source .zip for build 211 now it is fresh, but otherwise, a work > around would be to update CVS from home, then run "setup.py sdist" and move > the resulting .zip file to work. Spotted that and thanks for the setup tip, I also spotted there is a 2.6 64 bit build this seemed to install ok with python 2.6 ok, so I will probably just use that. What compiler was used for this package? > I agree for 32bit builds, but IMO the 64 bit builds are somewhat different > - > the lack of 64bit binaries for most python 2.5 extensions implies to me > that > x64 on 2.6 isn't any risker; particularly when talking about 2.5 builds > using an "unsupported" compiler. From pywin32's POV, I'm quite certain > more > people are testing x64 using 2.6 builds than 2.5. Point duly noted, I will examine 2.6 instead then and see how it goes. SO long as I can get all the tests running without any problems then I will be happy, and by the time we deploy it looks like 2.6 should be pretty much ready. Thanks again, Hanni -------------- next part -------------- An HTML attachment was scrubbed... URL: From mc at mclaveau.com Mon Jun 2 22:12:38 2008 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 2 Jun 2008 22:12:38 +0200 Subject: [python-win32] pythoncom warning: PyVARDESC Message-ID: <8664A6B76E874A81A7DAC6DAD0C3C59D@MCI1330> Hi! Since release 211, I have dozens & dozens messages, like this: pythoncom warning: PyVARDESC ctor has unknown varkind (3) - returning None pythoncom warning: PyVARDESC ctor has unknown varkind (3) - returning None pythoncom warning: PyVARDESC ctor has unknown varkind (3) - returning None pythoncom warning: PyVARDESC ctor has unknown varkind (3) - returning None No problem when I run my scripts. But, I don't understand the message (the worst: it is not even in French!). If somebody has an explanation (easy to understand), thanks in advance. Michel Claveau From le.dahut at laposte.net Mon Jun 2 17:46:31 2008 From: le.dahut at laposte.net (le dahut) Date: Mon, 02 Jun 2008 17:46:31 +0200 Subject: [python-win32] Vista, _winreg and "Access denied" In-Reply-To: <027001c8c002$46d3c390$d47b4ab0$@com.au> References: <483BDFCA.6020807@laposte.net> <027001c8c002$46d3c390$d47b4ab0$@com.au> Message-ID: <484415D7.4010308@laposte.net> Hello, I've passed some time reading the MS coding guide for Vista http://msdn.microsoft.com/en-us/library/bb756973.aspx It explains that an app requiring administrator rights (modify HKLM, write in C:\Windows\, etc.) will always return "Access denied" or ask the user for UAC if it's launched with the appropriate manifest or with "runas". You can personalize the UAC prompt by a short description of your program and an icon. In short, if your user app does something like that, rewrite it using a service. Mark Hammond a ?crit : >> With Vista (XP works fine), when using SetValueEx in a script ran by an >> administrator I get "Access Denied". I know that's it's due to UAC so >> does someone know how to do a 'sudo' when using something else than >> CreateProcess ? > > The short version of my understanding of Vista and UAC: Firstly, an > existing process can not be elevated - once you are running, you are out of > luck - your option is, basically, re-execute yourself requesting elevation > and have the new process retry the operation (the exception is when you are > using a COM object - in which case you can ask for an "elevated" COM object > - but that is rare, so I'm treating it as the exception :) If you want to > reexecute yourself, IIUC you are limited to calling ShellExecute(Ex), with > the "verb" set to "runas" - which can be a PITA, but I'm not aware of other > options. My current best guess for when you might *need* to do this if is > win32com.shell.IsUserAnAdmin() returns true (which needs pywin32-211, which > I promise is in the process of being tested right now :) > > As Tim said though, please read MSDN and all other references you can find, > and please correct me if I'm wrong/mistaken/confused/etc for everyone elses > benefit... > > Cheers, > > Mark > > > From vernondcole at gmail.com Mon Jun 2 19:11:06 2008 From: vernondcole at gmail.com (Vernon Cole) Date: Mon, 2 Jun 2008 11:11:06 -0600 Subject: [python-win32] pywin32 build 211 released In-Reply-To: <003b01c8c2ee$8ec50260$ac4f0720$@com.au> References: <003b01c8c2ee$8ec50260$ac4f0720$@com.au> Message-ID: Mark: The main download link at https://sourceforge.net/projects/pywin32/ is still pointing to version 210. My quick test of 211 seems fine. In particular the adodbapi project software lands just where it should and works just as it should. As soon as the pywin32 main download is switched to version 211, I will change the adodbapi project page to point there. Adodbapi will then become obsolete as a separate project. -- Vernon Cole On Sat, May 31, 2008 at 1:18 AM, Mark Hammond wrote: > Hi all, > I've finally released pywin32 build 211! > > These days, it almost goes without saying that Roger Upole again > contributed > significant changes, and various other people also contributed bits and > pieces - the full change notes are at: > https://sourceforge.net/project/shownotes.php?release_id=603349 > > Given there have been a large number of changes since the last release, I > recommend you exercise caution before upgrading production systems; > however, > this release has been extensively tested recently, so I don't anticipate > any > problems. > > Get it now via > https://sourceforge.net/project/showfiles.php?group_id=78018 > > Cheers, > > Mark > > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Tue Jun 3 00:04:15 2008 From: vernondcole at gmail.com (Vernon Cole) Date: Mon, 2 Jun 2008 16:04:15 -0600 Subject: [python-win32] adodbapi SQL access micro how-to (pywin32 build 211) Message-ID: I've just had a success story with the adodbapi now included in build 211, and thought it would be a good idea to let everyone know how to do it. My application ran a very gnarly SQL script against master..sysprocesses to identify blocked SQL requests. It tended to crash python when the MSSQL server was running badly, which was, of course, when I needed it most. It happened again today. I replaced: import dbi, odbc conn = odbc.odbc("Oasis Data/oareport/xxxxx") with: import adodbapi conn = adodbapi.connect("DSN=Oasis Data; Uid=oareport; Pwd=xxxxx") and presto! the script runs with no errors and no other changes. A working example of creating and connecting to a Microsoft Access type (a.k.a. "jet") database can be found in Lib/site-packages/adodbapi/tests/adodbapitestconfig.py. There are also MSSQL, mysql, and AS400 examples in that file. Connection string examples for many other situations can be found at www.connectionstrings.com -- Vernon Cole -------------- next part -------------- An HTML attachment was scrubbed... URL: From aleksandrv at berkeley.edu Mon Jun 2 18:42:27 2008 From: aleksandrv at berkeley.edu (Aleksandr VLADIMIRSKIY) Date: Mon, 2 Jun 2008 09:42:27 -0700 Subject: [python-win32] Exception setting a string using COM In-Reply-To: <48409C53.8020205@probo.com> References: <7918C1A70119A34887246E1DEC04C65302A7B27A@coemailsrv.coe.berkeley.edu> <48409C53.8020205@probo.com> Message-ID: <7918C1A70119A34887246E1DEC04C65302A7B309@coemailsrv.coe.berkeley.edu> Hello Tim, Thank you for your reply. I tried to use the setPath method and no luck: In [26]: item.setPath('') --------------------------------------------------------------------------- exceptions.AttributeError Traceback (most recent call last) C:\coe\ c:\python24\lib\site-packages\win32com\client\__init__.py in __getattr__(self, attr) 452 args=self._prop_map_get_.get(attr) 453 if args is None: --> 454 raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) 455 return self._ApplyTypes_(*args) 456 AttributeError: '' object has no attribute 'setPath' I did dir(item) and there were no set/get methods, just the ones provided by the application's COM. The item.Path attribute appears to just be a unicode string. Aleksandr -----Original Message----- From: python-win32-bounces+aleksandrv=berkeley.edu at python.org [mailto:python-win32-bounces+aleksandrv=berkeley.edu at python.org] On Behalf Of Tim Roberts Sent: Friday, May 30, 2008 5:31 PM To: Python-Win32 List Subject: Re: [python-win32] Exception setting a string using COM Aleksandr VLADIMIRSKIY wrote: > I'm attempting to set a string value using a COM interface to an application. I get the following traceback. Could anyone help me understand the nature of the error or how I might begin to discover it? > ... > > In [11]: item.Path = "" > --------------------------------------------------------------------------- > pywintypes.com_error Traceback (most recent call last) > > C:\ > > c:\python24\lib\site-packages\win32com\client\__init__.py in __setattr__(self, attr, value) > 461 except KeyError: > 462 raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) > --> 463 self._oleobj_.Invoke(*(args + (value,) + defArgs)) > 464 def _get_good_single_object_(self, obj, obUserName=None, resultCLSID=None): > 465 return _get_good_single_object_(obj, obUserName, resultCLSID) > > com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, > 0, -2147467259), None) > -2147467259 is 80004005, which is the rather unhelpful E_FAIL. Sometimes, when it is mapping a settable/gettable property, the Python COM mapper creates a separate method for setting. You might try: item.setPath( "" ) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From Ron at FascinatingElectronics.com Tue Jun 3 00:30:10 2008 From: Ron at FascinatingElectronics.com (Ron Jackson) Date: Mon, 2 Jun 2008 15:30:10 -0700 Subject: [python-win32] USB CDC-class support with win32file, exception processing issues Message-ID: When USB communication device class devices are installed in Windows they appear as COMxxx ports, just like legacy serial ports. They are different in that many RS-232 device parameters don't apply (such as baud rate, handshaking, etc). Also, since they are USB devices they may be suspended while remaining connected (as when the computer goes into sleep mode), or may be unplugged at any time. I am creating a simple Python communications library to support USB-CDC devices, ignoring the unused legacy features but adding suspend and disconnect support. I have found some problems with exception processing that is making this problematic. win32file.WriteFile works well. If the device is suspended I get pywintypes.error (31, 'WriteFile', 'A device attached to the system is not functioning.'). If the device is unplugged I get pywintypes.error (1167, 'WriteFile', 'The device is not connected.'). I can find out if there are any characters in the input buffer using win32file.ClearCommError. Its exception reporting half-way works. If the device is suspended I get pywintypes.error (31, 'ClearCommError', 'A device attached to the system is not functioning.'). But if the device is unplugged I get no error reported at all. win32file.ReadFile provides neither of these errors. Either suspended or unplugged just causes ReadFile to hang. I can get ReadFile to return if I set a timeout, but no error is reported so I don't know if it returned because the device hasn't sent the data yet, or because the device is suspended or disconnected. Is there some way to get ReadFile to report errors 31 and 1167 like WriteFile does? Or is there some other way to determine port status as "attached but not functioning" or "not connected"? Thanks for the help! -- Ron From mhammond at skippinet.com.au Tue Jun 3 02:04:15 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 3 Jun 2008 10:04:15 +1000 Subject: [python-win32] pywin32 build 211 released In-Reply-To: References: <003b01c8c2ee$8ec50260$ac4f0720$@com.au> Message-ID: <00af01c8c50d$5e791760$1b6b4620$@com.au> Seeing as nothing has caught fire in the few days since I made the release, I updated the SF page to point at build 211 - it does still have a note that b210 is the "most recent stable version", so I think it's a good compromise :) Cheers, Mark From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Vernon Cole Sent: Tuesday, 3 June 2008 3:11 AM To: Mark Hammond Cc: python-win32 at python.org Subject: Re: [python-win32] pywin32 build 211 released Mark: The main download link at https://sourceforge.net/projects/pywin32/ is still pointing to version 210. My quick test of 211 seems fine. In particular the adodbapi project software lands just where it should and works just as it should. As soon as the pywin32 main download is switched to version 211, I will change the adodbapi project page to point there. Adodbapi will then become obsolete as a separate project. -- Vernon Cole On Sat, May 31, 2008 at 1:18 AM, Mark Hammond wrote: Hi all, I've finally released pywin32 build 211! These days, it almost goes without saying that Roger Upole again contributed significant changes, and various other people also contributed bits and pieces - the full change notes are at: https://sourceforge.net/project/shownotes.php?release_id=603349 Given there have been a large number of changes since the last release, I recommend you exercise caution before upgrading production systems; however, this release has been extensively tested recently, so I don't anticipate any problems. Get it now via https://sourceforge.net/project/showfiles.php?group_id=78018 Cheers, Mark _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From rwupole at msn.com Tue Jun 3 02:19:07 2008 From: rwupole at msn.com (Roger Upole) Date: Mon, 2 Jun 2008 20:19:07 -0400 Subject: [python-win32] pywin32 build 211 released Message-ID: Mark Hammond wrote: > Seeing as nothing has caught fire in the few days since I made the > release, > I updated the SF page to point at build 211 - it does still have a note > that > b210 is the "most recent stable version", so I think it's a good > compromise > :) > > Cheers, > > Mark Now that you mention it, my power supply flamed out. If I determine it was due to build 211, I'll file a bug report. ;) Roger From rwupole at msn.com Tue Jun 3 02:27:55 2008 From: rwupole at msn.com (Roger Upole) Date: Mon, 2 Jun 2008 20:27:55 -0400 Subject: [python-win32] adodbapi SQL access micro how-to (pywin32 build 211) Message-ID: Vernon Cole wrote: > I've just had a success story with the adodbapi now included in build 211, > and thought it would be a good idea to let everyone know how to do it. > > My application ran a very gnarly SQL script against master..sysprocesses > to > identify blocked SQL requests. It tended to crash python when the MSSQL > server was running badly, which was, of course, when I needed it most. It > happened again today. > > I replaced: > import dbi, odbc > conn = odbc.odbc("Oasis Data/oareport/xxxxx") > > with: > import adodbapi > conn = adodbapi.connect("DSN=Oasis Data; Uid=oareport; Pwd=xxxxx") > > and presto! the script runs with no errors and no other changes. > > A working example of creating and connecting to a Microsoft Access type > (a.k.a. "jet") database can be found in > Lib/site-packages/adodbapi/tests/adodbapitestconfig.py. There are also > MSSQL, mysql, and AS400 examples in that file. > > Connection string examples for many other situations can be found at > www.connectionstrings.com > -- > Vernon Cole Tim Golden is starting a collection of snippets and examples here: http://timgolden.me.uk/python-on-windows/ You might want to ask if he could add a section for database operations. Roger From mhammond at skippinet.com.au Tue Jun 3 03:04:51 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 3 Jun 2008 11:04:51 +1000 Subject: [python-win32] pythoncom warning: PyVARDESC In-Reply-To: <8664A6B76E874A81A7DAC6DAD0C3C59D@MCI1330> References: <8664A6B76E874A81A7DAC6DAD0C3C59D@MCI1330> Message-ID: <00c001c8c515$d6c503c0$844f0b40$@com.au> > Since release 211, I have dozens & dozens messages, like this: > > pythoncom warning: PyVARDESC ctor has unknown varkind (3) - returning > None > pythoncom warning: PyVARDESC ctor has unknown varkind (3) - returning > None > pythoncom warning: PyVARDESC ctor has unknown varkind (3) - returning > None > pythoncom warning: PyVARDESC ctor has unknown varkind (3) - returning > None > > No problem when I run my scripts. But, I don't understand the message > (the > worst: it is not even in French!). > If somebody has an explanation (easy to understand), thanks in advance. It happens as part of the makepy generation process, apparently when processing the "default" value for params. In b210 and earlier, when pythoncom saw a VARDESC it didn't understand, it silently returned None, but in b211, as you see, it generates a warning as it implies there is something pywin32 needs to fix (the *bad* think about such warnings is that there is nothing the person seeing the warning can do to resolve it other than ask about it, as you have done) It appears we are hitting a VARKIND of VAR_DISPATCH. Does it happen for you on any typelibs I'm likely to have installed? Any idea what in your typelibs could cause this, so I can repro it in the test suite? Cheers, Mark. From mhammond at skippinet.com.au Tue Jun 3 03:35:12 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 3 Jun 2008 11:35:12 +1000 Subject: [python-win32] USB CDC-class support with win32file, exception processing issues In-Reply-To: References: Message-ID: <00cb01c8c51a$15ffdb10$41ff9130$@com.au> I'm afraid I don't have many insights. Using overlapped IO may solve your problem of not knowing if an error occurred or not, but I don't think it will solve your general problem. One thing that might be worth looking at are "device notifications", which may be able to inform you of the removal - see win32\Demos\win32gui_devicenotify.py in build 211 for an example (I think that only will see mass-storage devices, but if you dig around MSDN you may have luck) Cheers, Mark > -----Original Message----- > From: python-win32-bounces at python.org [mailto:python-win32- > bounces at python.org] On Behalf Of Ron Jackson > Sent: Tuesday, 3 June 2008 8:30 AM > To: python-win32 at python.org > Subject: [python-win32] USB CDC-class support with win32file, exception > processing issues > > When USB communication device class devices are installed in Windows > they appear as COMxxx ports, just like legacy serial ports. They are > different in that many RS-232 device parameters don't apply (such as > baud rate, handshaking, etc). Also, since they are USB devices they > may be suspended while remaining connected (as when the computer goes > into sleep mode), or may be unplugged at any time. > > I am creating a simple Python communications library to support > USB-CDC devices, ignoring the unused legacy features but adding > suspend and disconnect support. I have found some problems with > exception processing that is making this problematic. > > win32file.WriteFile works well. If the device is suspended I get > pywintypes.error (31, 'WriteFile', 'A device attached to the system is > not functioning.'). If the device is unplugged I get pywintypes.error > (1167, 'WriteFile', 'The device is not connected.'). > > I can find out if there are any characters in the input buffer using > win32file.ClearCommError. Its exception reporting half-way works. If > the device is suspended I get pywintypes.error (31, 'ClearCommError', > 'A device attached to the system is not functioning.'). But if the > device is unplugged I get no error reported at all. > > win32file.ReadFile provides neither of these errors. Either suspended > or unplugged just causes ReadFile to hang. I can get ReadFile to > return if I set a timeout, but no error is reported so I don't know if > it returned because the device hasn't sent the data yet, or because > the device is suspended or disconnected. > > Is there some way to get ReadFile to report errors 31 and 1167 like > WriteFile does? Or is there some other way to determine port status as > "attached but not functioning" or "not connected"? > > Thanks for the help! > > -- Ron > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From mail at timgolden.me.uk Tue Jun 3 10:33:02 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 03 Jun 2008 09:33:02 +0100 Subject: [python-win32] pythoncom warning: PyVARDESC In-Reply-To: <00c001c8c515$d6c503c0$844f0b40$@com.au> References: <8664A6B76E874A81A7DAC6DAD0C3C59D@MCI1330> <00c001c8c515$d6c503c0$844f0b40$@com.au> Message-ID: <484501BE.3070804@timgolden.me.uk> Mark Hammond wrote: >> Since release 211, I have dozens & dozens messages, like this: >> >> pythoncom warning: PyVARDESC ctor has unknown varkind (3) - returning >> None >> pythoncom warning: PyVARDESC ctor has unknown varkind (3) - returning >> None >> pythoncom warning: PyVARDESC ctor has unknown varkind (3) - returning >> None >> pythoncom warning: PyVARDESC ctor has unknown varkind (3) - returning >> None >> >> No problem when I run my scripts. But, I don't understand the message >> (the >> worst: it is not even in French!). >> If somebody has an explanation (easy to understand), thanks in advance. > > It happens as part of the makepy generation process, apparently when > processing the "default" value for params. In b210 and earlier, when > pythoncom saw a VARDESC it didn't understand, it silently returned None, but > in b211, as you see, it generates a warning as it implies there is something > pywin32 needs to fix (the *bad* think about such warnings is that there is > nothing the person seeing the warning can do to resolve it other than ask > about it, as you have done) > > It appears we are hitting a VARKIND of VAR_DISPATCH. Does it happen for you > on any typelibs I'm likely to have installed? Any idea what in your > typelibs could cause this, so I can repro it in the test suite? MAPI.Session definitely does this TJG From mail at timgolden.me.uk Tue Jun 3 10:40:13 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 03 Jun 2008 09:40:13 +0100 Subject: [python-win32] Vista, _winreg and "Access denied" In-Reply-To: <484415D7.4010308@laposte.net> References: <483BDFCA.6020807@laposte.net> <027001c8c002$46d3c390$d47b4ab0$@com.au> <484415D7.4010308@laposte.net> Message-ID: <4845036D.4060907@timgolden.me.uk> le dahut wrote: > Hello, > I've passed some time reading the MS coding guide for Vista > http://msdn.microsoft.com/en-us/library/bb756973.aspx > > It explains that an app requiring administrator rights (modify HKLM, > write in C:\Windows\, etc.) will always return "Access denied" or ask > the user for UAC if it's launched with the appropriate manifest or with > "runas". > You can personalize the UAC prompt by a short description of your > program and an icon. > > In short, if your user app does something like that, rewrite it using a > service. Thanks for getting back with the info. TJG From mail at timgolden.me.uk Tue Jun 3 10:33:56 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 03 Jun 2008 09:33:56 +0100 Subject: [python-win32] Vista, _winreg and "Access denied" In-Reply-To: <484415D7.4010308@laposte.net> References: <483BDFCA.6020807@laposte.net> <027001c8c002$46d3c390$d47b4ab0$@com.au> <484415D7.4010308@laposte.net> Message-ID: <484501F4.1000605@timgolden.me.uk> le dahut wrote: > Hello, > I've passed some time reading the MS coding guide for Vista > http://msdn.microsoft.com/en-us/library/bb756973.aspx > > It explains that an app requiring administrator rights (modify HKLM, > write in C:\Windows\, etc.) will always return "Access denied" or ask > the user for UAC if it's launched with the appropriate manifest or with > "runas". > You can personalize the UAC prompt by a short description of your > program and an icon. > > In short, if your user app does something like that, rewrite it using a > service. Thanks for getting back with the info. TJG From mail at timgolden.me.uk Wed Jun 4 14:20:20 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 04 Jun 2008 13:20:20 +0100 Subject: [python-win32] pywin32 build 211 released Message-ID: <48468884.5050902@timgolden.me.uk> And for those who are interested, I've updated the online docs I've cloned at: http://timgolden.me.uk/pywin32-docs to the new version. There's also a crude diff set which basically reflects the subversion status of the HTML I produce, but which might be of interest as an alternative view of the changes. http://timgolden.me.uk/pywin32-docs/changes.html TJG From stephane.poirot at linbox.com Wed Jun 4 14:29:15 2008 From: stephane.poirot at linbox.com (stephane.poirot) Date: Wed, 04 Jun 2008 14:29:15 +0200 Subject: [python-win32] Service does not start at windows boot but at user's login Message-ID: <48468A9B.8010401@linbox.com> Good morning, I'm currently building an application which involves two different processes : one is a service and the other one is a simple client. My client starts at user's login and the service should start at windows boot. I say 'should' because it seems that the service actually starts at user's login too : I put logs in the event log and I noticed that the service starts almost 7 to 10 seconds after the client, which is not what is expected. Service's properties are : run automatically on System account, no dependencies. The code of my service is based on the one found in the book : Oreilly, Python Programming on Win32, at chapter 18.6 : Sample Service Written in Python. Furthermore, my two processes communicate through a named pipe, and the problem aforementioned involves that the communication is not possible : indeed, the service, who should start before the client, creates the pipe and waits for a client connection. Client has just to open the pipe to connect. But obviously if the client starts before the service, an error occurs because no pipe is created so far. I did a lot of searches to solve this problem, but haven't found any issue yet. I first thought that the problem came from pythonservice.exe, which hosts my service : it may take longer time to load than common other windows services. That's why I converted my service into a .exe thanks to py2exe. Then the path in service's properties has changed to this executable. But the problem remains : service still starts after client. However, the problem only occurs at first user's login after machine's boot : if he disconnects and somebody connects after, without reboot, the service is still running, which is normal. That's why I would ask if anyone has an idea for solving this problem. Thank you in advance for your answers. St?phane POIROT From mhammond at skippinet.com.au Wed Jun 4 15:17:39 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 4 Jun 2008 23:17:39 +1000 Subject: [python-win32] Service does not start at windows boot but at user's login In-Reply-To: <48468A9B.8010401@linbox.com> References: <48468A9B.8010401@linbox.com> Message-ID: <019101c8c645$60684b70$2138e250$@com.au> XP and Vista both pull a few tricks to get you logged on before all services have started - there are no guarantees that all services will be started before any user programs. It's probably best to just have your client deal with the situation (either by blindly, but smartly, retrying, or by querying the service status and waiting until it is reporting it is started.) Cheers, Mark > -----Original Message----- > From: python-win32-bounces at python.org [mailto:python-win32- > bounces at python.org] On Behalf Of stephane.poirot > Sent: Wednesday, 4 June 2008 10:29 PM > To: python-win32 at python.org > Subject: [python-win32] Service does not start at windows boot but at > user's login > > Good morning, > > I'm currently building an application which involves two different > processes : one is a service and the other one is a simple client. > My client starts at user's login and the service should start at > windows > boot. I say 'should' because it seems that the service > actually starts at user's login too : I put logs in the event log and I > noticed that the service starts almost 7 to 10 seconds after > the client, which is not what is expected. Service's properties are : > run automatically on System account, no dependencies. > The code of my service is based on the one found in the book : Oreilly, > Python Programming on Win32, at chapter 18.6 : > Sample Service Written in Python. > > > Furthermore, my two processes communicate through a named pipe, and the > problem aforementioned involves that the communication > is not possible : indeed, the service, who should start before the > client, creates the pipe and waits for a client connection. Client has > just > to open the pipe to connect. But obviously if the client starts before > the service, an error occurs because no pipe is created so far. > > I did a lot of searches to solve this problem, but haven't found any > issue yet. > I first thought that the problem came from pythonservice.exe, which > hosts my service : it may take longer time > to load than common other windows services. That's why I converted my > service into a .exe thanks to py2exe. Then the path in service's > properties has changed to this executable. But the problem remains : > service still starts after client. > However, the problem only occurs at first user's login after machine's > boot : if he disconnects and somebody connects after, without reboot, > the service is > still running, which is normal. > > That's why I would ask if anyone has an idea for solving this problem. > Thank you in advance for your answers. > > St?phane POIROT > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From mhammond at skippinet.com.au Wed Jun 4 15:59:45 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 4 Jun 2008 23:59:45 +1000 Subject: [python-win32] pythoncom warning: PyVARDESC In-Reply-To: <484501BE.3070804@timgolden.me.uk> References: <8664A6B76E874A81A7DAC6DAD0C3C59D@MCI1330> <00c001c8c515$d6c503c0$844f0b40$@com.au> <484501BE.3070804@timgolden.me.uk> Message-ID: <019601c8c64b$41bd9710$c538c530$@com.au> Tim: > > It appears we are hitting a VARKIND of VAR_DISPATCH. Does it happen > > for you on any typelibs I'm likely to have installed? Any idea what > > in your typelibs could cause this, so I can repro it in the test suite? > MAPI.Session definitely does this Sadly I don't have that installed :( I think I forgot to select that option when installing Outlook 2007. EnsureDispatch("Outlook.Application") doesn't show the problem for me either - so I guess I'll see about installing MAPI support tomorrow. In the meantime, any other takers? :) Cheers, Mark From Kyle.Rickey at bakerhughes.com Wed Jun 4 23:26:22 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Wed, 4 Jun 2008 16:26:22 -0500 Subject: [python-win32] Standby/Hibernate Message-ID: <59FACAE10BA736419936C90B4E60D45922505A@MSGHOUMBX07.ent.bhicorp.com> What do I need to do to put my local computer into standby? I found the function: win32api.InitiateSystemShutdown("INT8Y4Y3B1", "Tom Sucks", 300, False, False) but it seems to only shutdown/restart. -Kyle Rickey From bgailer at gmail.com Thu Jun 5 02:15:45 2008 From: bgailer at gmail.com (bob gailer) Date: Wed, 04 Jun 2008 20:15:45 -0400 Subject: [python-win32] Service does not start at windows boot but at user's login In-Reply-To: <48468A9B.8010401@linbox.com> References: <48468A9B.8010401@linbox.com> Message-ID: <48473031.7060706@gmail.com> stephane.poirot wrote: > Good morning, > > I'm currently building an application which involves two different > processes : one is a service and the other one is a simple client. > My client starts at user's login and the service should start at > windows boot. I say 'should' because it seems that the service > actually starts at user's login too : I put logs in the event log and > I noticed that the service starts almost 7 to 10 seconds after > the client, which is not what is expected. Service's properties are : > run automatically on System account, no dependencies. > The code of my service is based on the one found in the book : > Oreilly, Python Programming on Win32, at chapter 18.6 : > Sample Service Written in Python. > > > Furthermore, my two processes communicate through a named pipe, and > the problem aforementioned involves that the communication is not > possible : indeed, the service, who should start before the client, > creates the pipe and waits for a client connection. Client has just to > open the pipe to connect. But obviously if the client starts before > the service, an error occurs because no pipe is created so far. > > I did a lot of searches to solve this problem, but haven't found any > issue yet. > I first thought that the problem came from pythonservice.exe, which > hosts my service : it may take longer time > to load than common other windows services. That's why I converted my > service into a .exe thanks to py2exe. Then the path in service's > properties has changed to this executable. But the problem remains : > service still starts after client. > However, the problem only occurs at first user's login after machine's > boot : if he disconnects and somebody connects after, without reboot, > the service is still running, which is normal. I run Windows 2003 Server with automatic logon. It seems to me that some services are started after the logon. I base this on noting that I get the Some Services Did Not Start alert many seconds after my desktop has appeared. Could the client repeatedly try connecting with some reasonable delay between connection attempts? -- Bob Gailer 919-636-4239 Chapel Hill, NC From stephane.poirot at linbox.com Thu Jun 5 10:21:10 2008 From: stephane.poirot at linbox.com (spoirot) Date: Thu, 05 Jun 2008 10:21:10 +0200 Subject: [python-win32] Service does not start at windows boot but at user's login In-Reply-To: <48473031.7060706@gmail.com> References: <48468A9B.8010401@linbox.com> <48473031.7060706@gmail.com> Message-ID: <4847A1F6.7060403@linbox.com> bob gailer wrote : > > I run Windows 2003 Server with automatic logon. It seems to me that > some services are started after the logon. I base this on noting that > I get the Some Services Did Not Start alert many seconds after my > desktop has appeared. > > Could the client repeatedly try connecting with some reasonable delay > between connection attempts? > Mark Hammond wrote : > XP and Vista both pull a few tricks to get you logged on before all > services have started - there are no guarantees that all services will > be started before any user programs. It's probably best to just have > your client deal with the situation (either by blindly, but smartly, > retrying, or by querying the service status and waiting until it is > reporting it is started.) Thank you for feedback. I have already solved the problem of the connection of the client after the service : the client waits until the server has started. It works by putting a delay between each connection attempt, but I prefered play with exception returned when the pipe isn't opened yet : I wait until this exception occur : when the pipe has just opened, my client works. If I put a delay, I have chances not to see the opening of the pipe when it just occurs. But the big problem is that my service has to alter some registry keys in HKLM hive, and these changes have to be done after any user login : indeed, I would like to set these keys at windows boot in order that when anyone logs in, the changes take effect. If the changes are done at user's login, (which is the case because the service starts after the client) then they will only be effective when the user reboots, so the user has to reboot and it's not what I want : I want to put changes at windows boot so that when a user logs in, changes are validated and he doesn't have to reboot. I use a Vmware Server Console with Windows XP Service pack 2 on it. I noticed some time synchronization problems as my clock was very quick : one minute in the reality almost equals to 3 on the machine. It could have an influence on the boot of my programs. I solved this problem with Vmware tools, so I could synchronize clock with my host operating system, but it changes nothing to the main problem... From mail at timgolden.me.uk Thu Jun 5 10:30:14 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 05 Jun 2008 09:30:14 +0100 Subject: [python-win32] Standby/Hibernate In-Reply-To: <59FACAE10BA736419936C90B4E60D45922505A@MSGHOUMBX07.ent.bhicorp.com> References: <59FACAE10BA736419936C90B4E60D45922505A@MSGHOUMBX07.ent.bhicorp.com> Message-ID: <4847A416.6040204@timgolden.me.uk> Rickey, Kyle W wrote: > What do I need to do to put my local computer into standby? I found the > function: > > win32api.InitiateSystemShutdown("INT8Y4Y3B1", "Tom Sucks", 300, False, > False) > > but it seems to only shutdown/restart. You need the SetSystemPowerState [1] function from kernel32. (And your process will need to enable SeShutdown as well). import ctypes import win32api import win32security # # Enable the SeShutdown privilege (which must be present in your # token in the first place) # priv_flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY hToken = win32security.OpenProcessToken ( win32api.GetCurrentProcess (), priv_flags ) priv_id = win32security.LookupPrivilegeValue ( None, win32security.SE_SHUTDOWN_NAME ) old_privs = win32security.AdjustTokenPrivileges ( hToken, 0, [(privilege_id, win32security.SE_PRIVILEGE_ENABLED)] ) # # Params: # True=> Standby; False=> Hibernate # True=> Force closedown; False=> Don't force # ctypes.windll.kernel32.SetSystemPowerState (True, True) TJG [1] http://msdn.microsoft.com/en-us/library/aa373206(VS.85).aspx From mail at timgolden.me.uk Thu Jun 5 12:42:02 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 05 Jun 2008 11:42:02 +0100 Subject: [python-win32] Service does not start at windows boot but at user's login In-Reply-To: <4847A1F6.7060403@linbox.com> References: <48468A9B.8010401@linbox.com> <48473031.7060706@gmail.com> <4847A1F6.7060403@linbox.com> Message-ID: <4847C2FA.2020307@timgolden.me.uk> spoirot wrote: > But the big problem is that my service has to alter some registry keys > in HKLM hive, and these changes have to be done after any user login : > indeed, > I would like to set these keys at windows boot in order that when anyone > logs in, the changes take effect. If the changes are done at user's login, > (which is the case because the service starts after the client) then > they will only be effective when the user reboots, so the user has to > reboot and > it's not what I want : I want to put changes at windows boot so that > when a user logs in, changes are validated and he doesn't have to reboot. Not really my area of expertise, but might it be possible to use one of the RunOnce keys in your circumstances? http://support.microsoft.com/kb/137367 TJG From dlabal at gmail.com Thu Jun 5 12:44:46 2008 From: dlabal at gmail.com (Petr Dlabal) Date: Thu, 5 Jun 2008 11:44:46 +0100 Subject: [python-win32] Autocad automation via COM Message-ID: <3d26fb440806050344w3dbb9791r1c185c0f684dbdbc@mail.gmail.com> Hello, I'm new in this mailing list. I'd like to discuss this problem with pywin32 and autocad: autocad awaiting parameters to functions as variants, but in fact, it must be for example array of doubles x,y,z. The problem and some fix by patching build.py script is described here: http://www.mail-archive.com/python-win32 at python.org/msg01445.html Descibed fix (by AutocadTranslateMap) works fine, except in one (or two) situations: Autocad ActiveViewport.SnapBasePoint property awaiting 2-element array of doubles x,y (unlike many other functions awaiting 3-element array of doubles x,y,z). In this situation it fails and autocad raises error about wrong parameter. If you print ActiveViewport.SnapBasePoint you will get (0.0,0.0). In Dan Glassman's fix (http://www.mail-archive.com/python-win32 at python.org/msg01445.html) in AutocadTranslateMap you can see snapbasepoint parameter here with 8197 type, which I think is array of doubles. I don't understand COM, I'm not programmer, I'm only user, so please, can somebody help me with this problem? I can send patched build.py (patched as described in http://www.mail-archive.com/python-win32 at python.org/msg01445.html) and I can send gencache file gen_py/EE2303F2-4EF6-42F6-92AB-4241221FF278x0x2x5.py where you can see defined "SnapBasePoint": ((13, LCID, 4, 0),()),... and in other places (I don't fully understand what it means). Thank you very much for any information / help. PD From stephane.poirot at linbox.com Thu Jun 5 15:44:47 2008 From: stephane.poirot at linbox.com (spoirot) Date: Thu, 05 Jun 2008 15:44:47 +0200 Subject: [python-win32] Service does not start at windows boot but at user's login In-Reply-To: <48473031.7060706@gmail.com> References: <48468A9B.8010401@linbox.com> <48473031.7060706@gmail.com> Message-ID: <4847EDCF.70306@linbox.com> bob gailer wrote : > > Not really my area of expertise, but might it be possible to use one > of the RunOnce keys in your circumstances? > My client starts at user's login. This is made by putting a value in the Run key of HKLM hive. My Service is configured to start automatically at windows boot. For a program whose path is set in a RunOnce key, it obviously only starts once, but it's still at user's login and not at windows boot. I am still working on that problem, I'll post as soon as I get news. Thanks, SP From mail at timgolden.me.uk Thu Jun 5 10:30:14 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 05 Jun 2008 09:30:14 +0100 Subject: [python-win32] Standby/Hibernate In-Reply-To: <59FACAE10BA736419936C90B4E60D45922505A@MSGHOUMBX07.ent.bhicorp.com> References: <59FACAE10BA736419936C90B4E60D45922505A@MSGHOUMBX07.ent.bhicorp.com> Message-ID: <4847A416.6040204@timgolden.me.uk> <<< No Message Collected >>> From gauthier.sg at wanadoo.fr Thu Jun 5 18:32:29 2008 From: gauthier.sg at wanadoo.fr (Serge Gauthier) Date: Thu, 5 Jun 2008 18:32:29 +0200 Subject: [python-win32] event Makepy question Message-ID: <004b01c8c729$bfc73830$0a01a8c0@bureauserge> Hi, To develop a interface to a COM library under Boa Constructor and WxPython, Python 2.5, I had to use the makepy utility to generate the classes file. I show you a part of this file: from win32com.client import CoClassBaseClass # This CoClass is known by the name 'PcommServer.PmacDevice.1' class PmacDevice(CoClassBaseClass): # A CoClass # PmacDevice Class CLSID = IID('{B544D2BD-354C-456E-9E88-20F71625E7DF}') coclass_sources = [ _IPmacDeviceEvents, ] default_source = _IPmacDeviceEvents coclass_interfaces = [ IPmacDevice, ] default_interface = IPmacDevice I can call PmacDevice() class and everything works well to communicate with the card. There is events managed in the library and I don't know how to use them? There is nothing in the file concerning this class. Do you have a example or tutorial ? Thanks a lot. Serge Gauthier -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kyle.Rickey at bakerhughes.com Thu Jun 5 21:00:05 2008 From: Kyle.Rickey at bakerhughes.com (Rickey, Kyle W) Date: Thu, 5 Jun 2008 14:00:05 -0500 Subject: [python-win32] Standby/Hibernate In-Reply-To: <4847A416.6040204@timgolden.me.uk> References: <59FACAE10BA736419936C90B4E60D45922505A@MSGHOUMBX07.ent.bhicorp.com> <4847A416.6040204@timgolden.me.uk> Message-ID: <59FACAE10BA736419936C90B4E60D45922536F@MSGHOUMBX07.ent.bhicorp.com> Thanks Tim. That did the trick. I need to do more digging on MSDN. Most of the google results I hit were people trying to prevent standby/hibernate. Thanks again. -Kyle Rickey -----Original Message----- From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of Tim Golden Sent: Thursday, June 05, 2008 3:30 AM Cc: python-win32 at python.org Subject: Re: [python-win32] Standby/Hibernate Rickey, Kyle W wrote: > What do I need to do to put my local computer into standby? I found the > function: > > win32api.InitiateSystemShutdown("INT8Y4Y3B1", "Tom Sucks", 300, False, > False) > > but it seems to only shutdown/restart. You need the SetSystemPowerState [1] function from kernel32. (And your process will need to enable SeShutdown as well). import ctypes import win32api import win32security # # Enable the SeShutdown privilege (which must be present in your # token in the first place) # priv_flags = win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY hToken = win32security.OpenProcessToken ( win32api.GetCurrentProcess (), priv_flags ) priv_id = win32security.LookupPrivilegeValue ( None, win32security.SE_SHUTDOWN_NAME ) old_privs = win32security.AdjustTokenPrivileges ( hToken, 0, [(privilege_id, win32security.SE_PRIVILEGE_ENABLED)] ) # # Params: # True=> Standby; False=> Hibernate # True=> Force closedown; False=> Don't force # ctypes.windll.kernel32.SetSystemPowerState (True, True) TJG [1] http://msdn.microsoft.com/en-us/library/aa373206(VS.85).aspx _______________________________________________ python-win32 mailing list python-win32 at python.org http://mail.python.org/mailman/listinfo/python-win32 From le.dahut at laposte.net Fri Jun 6 17:47:42 2008 From: le.dahut at laposte.net (le dahut) Date: Fri, 06 Jun 2008 17:47:42 +0200 Subject: [python-win32] Vista, _winreg and "Access denied" In-Reply-To: <4845036D.4060907@timgolden.me.uk> References: <483BDFCA.6020807@laposte.net> <027001c8c002$46d3c390$d47b4ab0$@com.au> <484415D7.4010308@laposte.net> <4845036D.4060907@timgolden.me.uk> Message-ID: <48495C1E.8030703@laposte.net> To complete this, the application is launched at logon (via Userinit registry key). It rewrites paths to StartMenu and Desktop according to the type of logon (Domain or Local). Actually it only rewrites when it is a local session and user IsAnAdmin. The application as to re-run itself using ShellExecute so it has to know if it already runs elevated or not. To do this I must use : GetTokenInformation( hToken, TokenElevationType ) Unfortunately win32security.TokenElevationType (18) is not available. And GetTokenInformation(hToken, 18) returns >>> win32security.GetTokenInformation(hToken, 18) Traceback (most recent call last): File "", line 1, in pywintypes.error: (87, 'GetTokenInformation - size call', 'The parameter is incorrect') Is it possible to do this using ctypes ? How ? Tim Golden wrote : > le dahut wrote: >> Hello, >> I've passed some time reading the MS coding guide for Vista >> http://msdn.microsoft.com/en-us/library/bb756973.aspx >> >> It explains that an app requiring administrator rights (modify HKLM, >> write in C:\Windows\, etc.) will always return "Access denied" or ask >> the user for UAC if it's launched with the appropriate manifest or >> with "runas". >> You can personalize the UAC prompt by a short description of your >> program and an icon. >> >> In short, if your user app does something like that, rewrite it using >> a service. > > Thanks for getting back with the info. > > TJG > > > From mail at timgolden.me.uk Fri Jun 6 22:09:03 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 06 Jun 2008 21:09:03 +0100 Subject: [python-win32] Vista, _winreg and "Access denied" In-Reply-To: <48495C1E.8030703@laposte.net> References: <483BDFCA.6020807@laposte.net> <027001c8c002$46d3c390$d47b4ab0$@com.au> <484415D7.4010308@laposte.net> <4845036D.4060907@timgolden.me.uk> <48495C1E.8030703@laposte.net> Message-ID: <4849995F.4010000@timgolden.me.uk> le dahut wrote: > To complete this, the application is launched at logon (via Userinit > registry key). It rewrites paths to StartMenu and Desktop according to > the type of logon (Domain or Local). > Actually it only rewrites when it is a local session and user IsAnAdmin. > The application as to re-run itself using ShellExecute so it has to know > if it already runs elevated or not. > > To do this I must use : > GetTokenInformation( > hToken, > TokenElevationType > ) > > Unfortunately win32security.TokenElevationType (18) is not available. > And GetTokenInformation(hToken, 18) returns > >>> win32security.GetTokenInformation(hToken, 18) > Traceback (most recent call last): > File "", line 1, in > pywintypes.error: (87, 'GetTokenInformation - size call', 'The parameter > is incorrect') > > > Is it possible to do this using ctypes ? How ? I'm not running Vista, so I can only go so far with this, but with the latest pywin32 v211, this works: import win32api import win32security hToken = win32security.OpenProcessToken ( win32api.GetCurrentProcess (), win32security.TOKEN_QUERY ) print win32security.GetTokenInformation ( hToken, win32security.TokenType ) print win32security.TokenElevationType That last bit is in there just to show that the constant is available, even if my XP box can't make use of it. Assuming that there may be some kind of bug in the pywin32 code, that last call could be done in ctypes like this: import ctypes from ctypes.wintypes import HANDLE import win32api import win32security hToken = win32security.OpenProcessToken ( win32api.GetCurrentProcess (), win32security.TOKEN_QUERY ) token_information = ctypes.c_uint (0) return_length = ctypes.c_uint (0) GetTokenInformation = ctypes.windll.advapi32.GetTokenInformation GetTokenInformation ( HANDLE (int (hToken)), win32security.TokenType, ctypes.byref (token_information), ctypes.sizeof (token_information), ctypes.byref (return_length) ) print token_information # # Should print 1, representing primary token # TJG [ BTW I consider it a testimony to the developers and maintainers of the pywin32 and ctypes extensions that: (a) this code works at all (b) it worked first time even though I'd typed it up directly in an email (c) it remains remarkably readable, in spite of calling the Windows API directly. ] From mhammond at skippinet.com.au Sat Jun 7 03:10:57 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 7 Jun 2008 11:10:57 +1000 Subject: [python-win32] Vista, _winreg and "Access denied" In-Reply-To: <48495C1E.8030703@laposte.net> References: <483BDFCA.6020807@laposte.net> <027001c8c002$46d3c390$d47b4ab0$@com.au> <484415D7.4010308@laposte.net> <4845036D.4060907@timgolden.me.uk> <48495C1E.8030703@laposte.net> Message-ID: <03b701c8c83b$5e015370$1a03fa50$@com.au> > The application as to re-run itself using ShellExecute so it has to > know > if it already runs elevated or not. > > To do this I must use : > GetTokenInformation( > hToken, > TokenElevationType > ) What about: >>> from win32com.shell import shell >>> shell.IsUserAnAdmin() True ? See the docs though, to ensure you correctly handle the win2k etc cases (and it requires build 211) Alterntively, it seems to me that you can maybe *assume* you are not elevated first time you are run, and always attempt to re-execute yourself. For example: %python -c "import win32api;win32api.ShellExecute(0, 'runas', 'notepad.exe', None, '', 1)" If run from a normal command prompt, it will prompt for elevation - but if the command prompt is already elevated, it silently opens notepad. So, you could try something like: * Arrange for 'myprogram.exe' to be started. * myprogram.exe checks for a '-no-elevate' command line - if not there, it just re-executes itself, but *with* the '-no-elevate' param. Although this will always execute your program twice, it will only prompt for elevation when necessary. As you imply that the most common case is likely to *not* be elevated in the first instance, the net result is the same. Cheers, Mark From ahziem1 at mailbolt.com Sat Jun 7 22:22:04 2008 From: ahziem1 at mailbolt.com (Andrew Z) Date: Sat, 07 Jun 2008 14:22:04 -0600 Subject: [python-win32] Error 'Member not found' in Word.Basic automation Message-ID: <1212870124.9957.1257286855@webmail.messagingengine.com> I would like to automate Word 95 through 2007 using Word.Basic. The code works fine on Windows XP + Word 95, but it fails on Windows XP + Word 2007. Code: import win32com.client app = win32com.client.Dispatch("Word.Basic") app.AppShow() Error: File "", line 2, in AppShow pywintypes.com_error: (-2147352573, 'Member not found.', None, None) Also, the equivalent code works fine in Word 2007 with Windows Scripting Host (VBS). Set objWord = CreateObject("Word.Basic") objWord.AppShow() Andrew -- http://www.fastmail.fm - The professional email service From opekar at eccam.com Sun Jun 8 13:47:14 2008 From: opekar at eccam.com (Vaclav Opekar) Date: Sun, 08 Jun 2008 13:47:14 +0200 Subject: [python-win32] IE control via DWebBrowserEvents2 Message-ID: <484BC6C2.5010405@eccam.com> Hello all, I'm trying to embed IE to a GTK app and control IE behavior via the DWebBrowserEvents2 interface. Embedding works, events like OnBeforeNavigate2 or OnNewWindow2 are comming fine but when I try to return (from the callback) a Cancel value which suppose stop IE from next page loading or new explorer window creation, the program either crashes or doesn't prevent IE from moving to next page or opening a new window. Any idea how I could approach this problem? Bellow are details and code snippets. Thanks a lot, Vasek ->I've used this example as a base http://pywin32.cvs.sourceforge.net/pywin32/pywin32/com/win32comext/axcontrol/demos/container_ie.py?revision=1.2&view=markup ->generated the stubs using python makepy.py C:\WINDOWS\system32\shdocvw.dll ->defined callback class using the generated classes (DWebBrowserEvents2) class BrowserCB(DWebBrowserEvents2): def __init__(self, oobj): DWebBrowserEvents2.__init__(self, oobj) #Cancel is in/out param in COM def OnBeforeNavigate2(self, pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel): if URL != "about:blank" : # return 1 # <- this crashes IE return True # this doesnt work - doesn stop IE to move to non blank page # Cancel is in/out param in COM def OnNewWindow2(self, ppDisp=defaultNamedNotOptArg, Cancel=defaultNamedNotOptArg): print "OnNewWindow2" return True # returns pythoncom error: Python error invoking COM method. -> callback class registration snippet browser.DoVerb(axcontrol.OLEIVERB_SHOW, None, site, -1, self.hwnd, rect) b2 = Dispatch(browser.QueryInterface(pythoncom.IID_IDispatch)) self.browser2 = b2 self.eventSink = BrowserCB(self.browser2) #only this line was added to the above example from CVS From mhammond at skippinet.com.au Mon Jun 9 01:56:48 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 9 Jun 2008 09:56:48 +1000 Subject: [python-win32] IE control via DWebBrowserEvents2 In-Reply-To: <484BC6C2.5010405@eccam.com> References: <484BC6C2.5010405@eccam.com> Message-ID: <04d301c8c9c3$53495660$f9dc0320$@com.au> If this is being used in a control, you probably need one extra "out" param used by the control window framework in pythonwin. In my code, I've been unable to effectively cancel the OnBeforeNavigate2 event though, but I don't think its related to pywin32. I could get the OnNewWindow3 event to cancel though, with code like: def OnNewWindow3(self, ppDisp, Cancel, dwFlags, bstrUrlContext, bstrUrl): #print "NewWindow", `bstrUrlContext`, `bstrUrl` if i_want_to_cancel_it: # cancel the event return 0, None, True That first out param is the extra one I referred to above, and I can't recall what the 2nd out param is but the 3rd is 'Cancel' Hope this helps, Mark > -----Original Message----- > From: python-win32-bounces at python.org [mailto:python-win32- > bounces at python.org] On Behalf Of Vaclav Opekar > Sent: Sunday, 8 June 2008 9:47 PM > To: python-win32 at python.org > Subject: [python-win32] IE control via DWebBrowserEvents2 > > Hello all, > I'm trying to embed IE to a GTK app and control IE behavior via the > DWebBrowserEvents2 interface. > Embedding works, events like OnBeforeNavigate2 or OnNewWindow2 are > comming fine but when I try to return (from the callback) a Cancel > value which suppose stop IE from next page loading or new explorer > window creation, the program either crashes or doesn't prevent IE from > moving to next page or opening a new window. > > Any idea how I could approach this problem? > > Bellow are details and code snippets. > > Thanks a lot, > Vasek > > ->I've used this example as a base > http://pywin32.cvs.sourceforge.net/pywin32/pywin32/com/win32comext/axco > ntrol/demos/container_ie.py?revision=1.2&view=markup > > ->generated the stubs using > python makepy.py C:\WINDOWS\system32\shdocvw.dll > > ->defined callback class using the generated classes > (DWebBrowserEvents2) > class BrowserCB(DWebBrowserEvents2): > def __init__(self, oobj): > DWebBrowserEvents2.__init__(self, oobj) > > #Cancel is in/out param in COM > def OnBeforeNavigate2(self, pDisp, URL, Flags, TargetFrameName, > PostData, Headers, Cancel): > if URL != "about:blank" : > # return 1 # <- this crashes IE > return True # this doesnt work - doesn stop IE to move to > non blank page > > # Cancel is in/out param in COM > def OnNewWindow2(self, ppDisp=defaultNamedNotOptArg, > Cancel=defaultNamedNotOptArg): > print "OnNewWindow2" > return True # returns pythoncom error: Python error invoking > COM > method. > > > -> callback class registration snippet > browser.DoVerb(axcontrol.OLEIVERB_SHOW, None, site, -1, > self.hwnd, rect) > b2 = Dispatch(browser.QueryInterface(pythoncom.IID_IDispatch)) > self.browser2 = b2 > self.eventSink = BrowserCB(self.browser2) #only this line was > added to the above example from CVS > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From le.dahut at laposte.net Mon Jun 9 11:53:52 2008 From: le.dahut at laposte.net (le dahut) Date: Mon, 09 Jun 2008 11:53:52 +0200 Subject: [python-win32] pywin32 build 211 released In-Reply-To: <003b01c8c2ee$8ec50260$ac4f0720$@com.au> References: <003b01c8c2ee$8ec50260$ac4f0720$@com.au> Message-ID: <484CFDB0.6010304@laposte.net> I encounter a problem when trying to install it. I get prompted by a secure window (a window with some keys icons) asking me if I want to run it with my account with(out) security against virus or with another account. None of the 3 possibilities works for me. Any idea ? Mark Hammond a ?crit : > Hi all, > I've finally released pywin32 build 211! > > These days, it almost goes without saying that Roger Upole again contributed > significant changes, and various other people also contributed bits and > pieces - the full change notes are at: > https://sourceforge.net/project/shownotes.php?release_id=603349 > > Given there have been a large number of changes since the last release, I > recommend you exercise caution before upgrading production systems; however, > this release has been extensively tested recently, so I don't anticipate any > problems. > > Get it now via https://sourceforge.net/project/showfiles.php?group_id=78018 > > Cheers, > > Mark > > From le.dahut at laposte.net Mon Jun 9 11:57:13 2008 From: le.dahut at laposte.net (le dahut) Date: Mon, 09 Jun 2008 11:57:13 +0200 Subject: [python-win32] pywin32 build 211 released In-Reply-To: <484CFDB0.6010304@laposte.net> References: <003b01c8c2ee$8ec50260$ac4f0720$@com.au> <484CFDB0.6010304@laposte.net> Message-ID: <484CFE79.6010007@laposte.net> Actually it works with XP SP2 but not with XP without SP. le dahut a ?crit : > I encounter a problem when trying to install it. I get prompted by a > secure window (a window with some keys icons) asking me if I want to run > it with my account with(out) security against virus or with another > account. > None of the 3 possibilities works for me. Any idea ? > > > > Mark Hammond a ?crit : >> Hi all, >> I've finally released pywin32 build 211! >> >> These days, it almost goes without saying that Roger Upole again >> contributed >> significant changes, and various other people also contributed bits and >> pieces - the full change notes are at: >> https://sourceforge.net/project/shownotes.php?release_id=603349 >> >> Given there have been a large number of changes since the last release, I >> recommend you exercise caution before upgrading production systems; >> however, >> this release has been extensively tested recently, so I don't >> anticipate any >> problems. >> >> Get it now via >> https://sourceforge.net/project/showfiles.php?group_id=78018 >> >> Cheers, >> >> Mark >> >> From christof.ecker at googlemail.com Mon Jun 9 12:02:19 2008 From: christof.ecker at googlemail.com (Christof Ecker) Date: Mon, 9 Jun 2008 12:02:19 +0200 Subject: [python-win32] Webbrowser control and Tab Navigation Message-ID: <99a8d4630806090302t33a8a369sb7a69ef94b4af4e3@mail.gmail.com> Hi all, I am using the webbrowser control (internet explorer) as display component in a project. Unfortunately the Tab and Enter keys do not work, i.e. it is impossible to switch between input fields of the displayed html-page and it is impossible to enter a newline in an input field. The shortened listing is below. Can anyone help? Christof # file htmlwidget.py import wx from wx.lib.activexwrapper import MakeActiveXClass import win32com.client.gencache browserModule = win32com.client.gencache.EnsureModule( "{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}", 0, 1, 1) # Flags to be used with the RefreshPage method REFRESH_NORMAL = 0 REFRESH_IFEXPIRED = 1 REFRESH_CONTINUE = 2 REFRESH_COMPLETELY = 3 # Flags to be used with LoadUrl, Navigate, Navigate2 methods NAV_OpenInNewWindow = 0x1 NAV_NoHistory = 0x2 NAV_NoReadFromCache = 0x4 NAV_NoWriteToCache = 0x8 NAV_AllowAutosearch = 0x10 NAV_BrowserBar = 0x20 NAV_Hyperlink = 0x40 class HtmlView(wx.Panel): url = None _needs_update = False def __init__(self, parent): wx.Panel.__init__( self, parent, -1, style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN|wx.NO_FULL_REPAINT_ON_RESIZE ) ## # Make a new class that derives from the WebBrowser class in the # COM module imported above. This class also derives from wxWindow and # implements the machinery needed to integrate the two worlds. theClass = MakeActiveXClass(browserModule.WebBrowser, eventObj=self) # Create an instance of that class self.ie = theClass(self, -1) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.ie, 1, wx.EXPAND) self.SetSizer(sizer) self.ie.offline = False def SetChanged(self): self._needs_update = True if self.IsShownOnScreen(): wx.CallAfter(self.update) def Navigate2(self, url): self.ie.Navigate2(url, Flags=NAV_NoReadFromCache|NAV_NoWriteToCache|NAV_NoHistory) if __name__ == '__main__': app = wx.PySimpleApp() frame = wx.Frame(None, -1) sizer = wx.BoxSizer(wx.VERTICAL) win1 = HtmlView(frame) win1.Navigate2("http://www.google.com") sizer.Add(win1, 1, wx.EXPAND) win1.Show() import wx.py.shell win = wx.py.shell.Shell(frame, -1) sizer.Add(win, 1, wx.EXPAND) frame.SetSizer(sizer) frame.Show(True) app.MainLoop() From gauthier.sg at wanadoo.fr Mon Jun 9 14:31:53 2008 From: gauthier.sg at wanadoo.fr (Serge Gauthier) Date: Mon, 9 Jun 2008 14:31:53 +0200 Subject: [python-win32] How to use event class ? Message-ID: <00bb01c8ca2c$cc835530$0a01a8c0@bureauserge> Hi, To develop a interface to a COM library under Boa Constructor and WxPython, Python 2.5, I had to use the makepy utility to generate the classes file. I show you a part of this file: class _IPmacDeviceEvents: """_IPmacDeviceEvents Interface""" CLSID = CLSID_Sink = IID('{D1C5C7C8-5E0C-495E-9AAF-85B146DA5F13}') coclass_clsid = IID('{B544D2BD-354C-456E-9E88-20F71625E7DF}') _public_methods_ = [] # For COM Server support _dispid_to_func_ = { 5 : "OnUnsolicited", 3 : "OnError", 4 : "OnInterrupt", 2 : "OnProgress", 1 : "OnMessage", 6 : "OnDataReady", } def __init__(self, oobj = None): if oobj is None: self._olecp = None else: import win32com.server.util from win32com.server.policy import EventHandlerPolicy cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContainer) cp=cpc.FindConnectionPoint(self.CLSID_Sink) cookie=cp.Advise(win32com.server.util.wrap(self, usePolicy=EventHandlerPolicy)) self._olecp,self._olecp_cookie = cp,cookie def __del__(self): try: self.close() except pythoncom.com_error: pass def close(self): if self._olecp is not None: cp,cookie,self._olecp,self._olecp_cookie = self._olecp,self._olecp_cookie,None,None cp.Unadvise(cookie) def _query_interface_(self, iid): import win32com.server.util if iid==self.CLSID_Sink: return win32com.server.util.wrap(self) # Event Handlers # If you create handlers, they should have the following prototypes: # def OnUnsolicited(self, Device=defaultNamedNotOptArg, Msg=defaultNamedNotOptArg): # """method Unsolicited""" # def OnError(self, Device=defaultNamedNotOptArg, FileName=defaultNamedNotOptArg, ErrorID=defaultNamedNotOptArg, LineNum=defaultNamedNotOptArg # , Line=defaultNamedNotOptArg): # """method Error""" # def OnInterrupt(self, Device=defaultNamedNotOptArg, lLevel=defaultNamedNotOptArg): # """method Interrupt""" # def OnProgress(self, Device=defaultNamedNotOptArg, dwPercent=defaultNamedNotOptArg): # """method Progress""" # def OnMessage(self, Device=defaultNamedNotOptArg, Msg=defaultNamedNotOptArg, bNewLine=defaultNamedNotOptArg): # """method Message""" # def OnDataReady(self, Device=defaultNamedNotOptArg): # """method DataReady""" ; ; ; from win32com.client import CoClassBaseClass # This CoClass is known by the name 'PcommServer.PmacDevice.1' class PmacDevice(CoClassBaseClass): # A CoClass # PmacDevice Class CLSID = IID('{B544D2BD-354C-456E-9E88-20F71625E7DF}') coclass_sources = [ _IPmacDeviceEvents, ] default_source = _IPmacDeviceEvents coclass_interfaces = [ IPmacDevice, ] default_interface = IPmacDevice I can call PmacDevice() class without problem and everything works well to communicate with the card. How to use the events managed in the library ? Do you have a example or tutorial ? Thanks a lot. Serge Gauthier -- J'utilise la version gratu?te de SPAMfighter pour utilisateurs priv?s. Ce programme a supprim?1939 d'e-mails spam ? ce jour. Les utilisateurs qui paient n'ont pas ce message dans leurse-mails. Obtenez la version gratuite de SPAMfighter ici: http://www.spamfighter.com/lfr -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdriscoll at co.marshall.ia.us Mon Jun 9 15:21:10 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Mon, 09 Jun 2008 08:21:10 -0500 Subject: [python-win32] IE control via DWebBrowserEvents2 In-Reply-To: <484BC6C2.5010405@eccam.com> References: <484BC6C2.5010405@eccam.com> Message-ID: <484D2E46.1070306@co.marshall.ia.us> Vaclav Opekar wrote: >
Hello all, > I'm trying to embed IE to a GTK app and control IE behavior via the > DWebBrowserEvents2 interface. > Embedding works, events like OnBeforeNavigate2 or OnNewWindow2 are > comming fine but when I try to return (from the callback) a Cancel > value which suppose stop IE from next page loading or new explorer > window creation, the program either crashes or doesn't prevent IE > from moving to next page or opening a new window. > > Any idea how I could approach this problem? > > Bellow are details and code snippets. > > Thanks a lot, > Vasek > There's also at least one non-pywin32 solution that I keep hearing about called the PAMIE project. You might find it helpful: http://pamie.sourceforge.net/ If nothing else, the source from the project might give you some ideas on how to approach the problem. ------------------- Mike Driscoll Blog: http:\\blog.pythonlibrary.org Python Extension Building Network: http:\\www.pythonlibrary.org From stephane.poirot at linbox.com Mon Jun 9 15:44:34 2008 From: stephane.poirot at linbox.com (spoirot) Date: Mon, 09 Jun 2008 15:44:34 +0200 Subject: [python-win32] Python Service does not start at Windows boot but at user's logon Message-ID: <484D33C2.7080909@linbox.com> Good morning everyone, I may have found an issue for my problem : I've made the service RpcSs (Remote Procedure Call SubSystem) dependent from my own service. Thus, RpcSs will only start when my own service has started. It seems to work. A drawback is that if I want to stop my service before shutdown , all dependant services will stop also, and some of them do not stop properly. Indeed, RpcSs has a lot of services depending of it. But it's already a solution. I hope this could help other people. SP From le.dahut at laposte.net Mon Jun 9 16:40:18 2008 From: le.dahut at laposte.net (le dahut) Date: Mon, 09 Jun 2008 16:40:18 +0200 Subject: [python-win32] Service does not start at windows boot but at user's login In-Reply-To: <48468A9B.8010401@linbox.com> References: <48468A9B.8010401@linbox.com> Message-ID: <484D40D2.9040503@laposte.net> I suppose that the user's program throws an exception if the service isn't started yet. I propose this : while True: try: do_what_fails_if_service_isn_t_started break except: time.sleep(0.5) I've this problem when using wipfw and twisted's reactor. stephane.poirot wrote : > Good morning, > > I'm currently building an application which involves two different > processes : one is a service and the other one is a simple client. > My client starts at user's login and the service should start at windows > boot. I say 'should' because it seems that the service > actually starts at user's login too : I put logs in the event log and I > noticed that the service starts almost 7 to 10 seconds after > the client, which is not what is expected. Service's properties are : > run automatically on System account, no dependencies. > The code of my service is based on the one found in the book : Oreilly, > Python Programming on Win32, at chapter 18.6 : > Sample Service Written in Python. > > > Furthermore, my two processes communicate through a named pipe, and the > problem aforementioned involves that the communication > is not possible : indeed, the service, who should start before the > client, creates the pipe and waits for a client connection. Client has just > to open the pipe to connect. But obviously if the client starts before > the service, an error occurs because no pipe is created so far. > > I did a lot of searches to solve this problem, but haven't found any > issue yet. > I first thought that the problem came from pythonservice.exe, which > hosts my service : it may take longer time > to load than common other windows services. That's why I converted my > service into a .exe thanks to py2exe. Then the path in service's > properties has changed to this executable. But the problem remains : > service still starts after client. > However, the problem only occurs at first user's login after machine's > boot : if he disconnects and somebody connects after, without reboot, > the service is > still running, which is normal. > > That's why I would ask if anyone has an idea for solving this problem. > Thank you in advance for your answers. > > St?phane POIROT From mhammond at skippinet.com.au Tue Jun 10 01:20:42 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 10 Jun 2008 09:20:42 +1000 Subject: [python-win32] pywin32 build 211 released In-Reply-To: <484CFDB0.6010304@laposte.net> References: <003b01c8c2ee$8ec50260$ac4f0720$@com.au> <484CFDB0.6010304@laposte.net> Message-ID: <058901c8ca87$76463f10$62d2bd30$@com.au> > I encounter a problem when trying to install it. I get prompted by a > secure window (a window with some keys icons) asking me if I want to > run > it with my account with(out) security against virus or with another > account. > None of the 3 possibilities works for me. Any idea ? When you say none of the possibilities work, how exactly do they fail? I'm sure I could extend the OS check to only attempt elevation on XP with SP1, but it would be nice to have a better understanding of the failure before doing that (eg, while testing this, I found Win2k also seems to support the 'runas' ShellExecute API - but it behaves slightly differently, and IsUserAnAdmin() isn't available. So if it (basically) works on Win2k, I'd be surprised it fails worse on XP without SP1. Cheers, Mark From mhammond at skippinet.com.au Tue Jun 10 01:20:42 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 10 Jun 2008 09:20:42 +1000 Subject: [python-win32] Python Service does not start at Windows boot but at user's logon In-Reply-To: <484D33C2.7080909@linbox.com> References: <484D33C2.7080909@linbox.com> Message-ID: <058a01c8ca87$7b9b4c30$72d1e490$@com.au> > I may have found an issue for my problem : I've made the service RpcSs > (Remote Procedure Call SubSystem) > dependent from my own service. Thus, RpcSs will only start when my own > service has started. > It seems to work. A drawback is that Another drawback is that if your service fails for any reason, a fairly important part of Windows will also fail to work. The RPCSS service isn't *really* dependent on your service; abusing service dependencies for this reason is (IMO) courting much bigger problems. Cheers, Mark From mdriscoll at co.marshall.ia.us Tue Jun 10 15:27:14 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Tue, 10 Jun 2008 08:27:14 -0500 Subject: [python-win32] Webbrowser control and Tab Navigation In-Reply-To: <99a8d4630806090302t33a8a369sb7a69ef94b4af4e3@mail.gmail.com> References: <99a8d4630806090302t33a8a369sb7a69ef94b4af4e3@mail.gmail.com> Message-ID: <484E8132.7050308@co.marshall.ia.us> Christof Ecker wrote: > Hi all, > > I am using the webbrowser control (internet explorer) as display > component in a project. Unfortunately the Tab and Enter keys do not > work, i.e. it is impossible to switch between input fields of the > displayed html-page and it is impossible to enter a newline in an > input field. > > The shortened listing is below. > > Can anyone help? > > Christof > > > # file htmlwidget.py > import wx > > from wx.lib.activexwrapper import MakeActiveXClass > import win32com.client.gencache > browserModule = win32com.client.gencache.EnsureModule( > "{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}", 0, 1, 1) > > > # Flags to be used with the RefreshPage method > REFRESH_NORMAL = 0 > REFRESH_IFEXPIRED = 1 > REFRESH_CONTINUE = 2 > REFRESH_COMPLETELY = 3 > > > # Flags to be used with LoadUrl, Navigate, Navigate2 methods > NAV_OpenInNewWindow = 0x1 > NAV_NoHistory = 0x2 > NAV_NoReadFromCache = 0x4 > NAV_NoWriteToCache = 0x8 > NAV_AllowAutosearch = 0x10 > NAV_BrowserBar = 0x20 > NAV_Hyperlink = 0x40 > > > class HtmlView(wx.Panel): > url = None > > _needs_update = False > def __init__(self, parent): > wx.Panel.__init__( > self, parent, -1, > style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN|wx.NO_FULL_REPAINT_ON_RESIZE > ) > ## > # Make a new class that derives from the WebBrowser class in the > # COM module imported above. This class also derives from wxWindow and > # implements the machinery needed to integrate the two worlds. > theClass = MakeActiveXClass(browserModule.WebBrowser, eventObj=self) > > # Create an instance of that class > self.ie = theClass(self, -1) > > sizer = wx.BoxSizer(wx.VERTICAL) > sizer.Add(self.ie, 1, wx.EXPAND) > self.SetSizer(sizer) > self.ie.offline = False > > > def SetChanged(self): > self._needs_update = True > if self.IsShownOnScreen(): > wx.CallAfter(self.update) > > def Navigate2(self, url): > self.ie.Navigate2(url, > Flags=NAV_NoReadFromCache|NAV_NoWriteToCache|NAV_NoHistory) > > > if __name__ == '__main__': > app = wx.PySimpleApp() > frame = wx.Frame(None, -1) > sizer = wx.BoxSizer(wx.VERTICAL) > win1 = HtmlView(frame) > win1.Navigate2("http://www.google.com") > sizer.Add(win1, 1, wx.EXPAND) > win1.Show() > > import wx.py.shell > win = wx.py.shell.Shell(frame, -1) > sizer.Add(win, 1, wx.EXPAND) > frame.SetSizer(sizer) > frame.Show(True) > > app.MainLoop() > > You might want to re-post this to the wxPython user's group just in case you're missing a wx method. I use wxPython extensively, but I'm not familiar with that particular widget. The link to the mail list is below: http://wxpython.org/maillist.php Also, there's the PAMIE project which you may or may not find useful: http://pamie.sourceforge.net/ I personally have used the SendKeys module to automate IE, however it's rather like black magic and kind of sucks: http://www.rutherfurd.net/python/sendkeys/ ------------------- Mike Driscoll Blog: http:\\blog.pythonlibrary.org Python Extension Building Network: http:\\www.pythonlibrary.org From rwupole at msn.com Wed Jun 11 01:07:43 2008 From: rwupole at msn.com (Roger Upole) Date: Tue, 10 Jun 2008 19:07:43 -0400 Subject: [python-win32] How to use event class ? Message-ID: First, you create a class that implements the event methods as detailed in the comments. Then you use win32com.client.DispatchWithEvents to create the object and hook the events to your class. hth Roger From christof.ecker at googlemail.com Wed Jun 11 10:36:21 2008 From: christof.ecker at googlemail.com (Christof Ecker) Date: Wed, 11 Jun 2008 10:36:21 +0200 Subject: [python-win32] Webbrowser control and Tab Navigation In-Reply-To: <484E8132.7050308@co.marshall.ia.us> References: <99a8d4630806090302t33a8a369sb7a69ef94b4af4e3@mail.gmail.com> <484E8132.7050308@co.marshall.ia.us> Message-ID: <99a8d4630806110136rc101280t8dcc10f9fe527fcc@mail.gmail.com> 2008/6/10 Mike Driscoll : > Christof Ecker wrote: >> >> Hi all, >> >> I am using the webbrowser control (internet explorer) as display >> component in a project. Unfortunately the Tab and Enter keys do not >> work, i.e. it is impossible to switch between input fields of the >> displayed html-page and it is impossible to enter a newline in an >> input field. >> >> The shortened listing is below. >> >> Can anyone help? >> > You might want to re-post this to the wxPython user's group just in case > you're missing a wx method. I use wxPython extensively, but I'm not familiar > with that particular widget. The link to the mail list is below: > > http://wxpython.org/maillist.php > > Also, there's the PAMIE project which you may or may not find useful: > http://pamie.sourceforge.net/ > > I personally have used the SendKeys module to automate IE, however it's > rather like black magic and kind of sucks: > http://www.rutherfurd.net/python/sendkeys/ > This turned out to be a wxpython specific problem and not a IE problem as I thought. The solution is to use the IE widget of wx (wx.lib.iewin.IEHtmlWindow). Thanks for the help, Christof PAMIE is quite impressive, I should have known it before. > ------------------- > Mike Driscoll > > Blog: http:\\blog.pythonlibrary.org > Python Extension Building Network: http:\\www.pythonlibrary.org > > > From stephane.poirot at linbox.com Wed Jun 11 11:05:52 2008 From: stephane.poirot at linbox.com (spoirot) Date: Wed, 11 Jun 2008 11:05:52 +0200 Subject: [python-win32] Python Service does not start at Windows boot but at user's logon In-Reply-To: <058a01c8ca87$7b9b4c30$72d1e490$@com.au> References: <484D33C2.7080909@linbox.com> <058a01c8ca87$7b9b4c30$72d1e490$@com.au> Message-ID: <484F9570.2080107@linbox.com> Mark Hammond wrote : > Another drawback is that if your service fails for any reason, a fairly > important part of Windows will also fail to work. The RPCSS service isn't > *really* dependent on your service; abusing service dependencies for this > reason is (IMO) courting much bigger problems. > > I totally agree with you. I have found another dependency to use : Themes, which is less heavy than RPCSS. This works, but it does not make exactly what I want. Indeed, I would like to set some values in a HKLM subkey at windows boot, in order that changes are effective as soon as a user logs in after boot sequence. In my case, registry values are well written, but changes aren't effective yet... So user needs to reboot. I tried to use the FlushKey() method from _winreg module in order to immediately write changes to registry. Changes are written, but not effective. I thought that user's login refreshed the registry, and then changes could have taken effect, but it seems not to be really the case. Is there any other Python _winreg method that could force registry changes to become effective as soon as changes are written into the registry ? Regards, SP From singhai.nish at gmail.com Wed Jun 11 18:05:13 2008 From: singhai.nish at gmail.com (kNish) Date: Wed, 11 Jun 2008 21:35:13 +0530 Subject: [python-win32] python procedure in maya Message-ID: <81bfef2e0806110905t79b568eeoc0b17b452d3df229@mail.gmail.com> Hi, 1) how do I source a python script thru MEL. 2) Execute a python script thru MEL (python("");) Brgds, kNish -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Jun 11 18:55:12 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 11 Jun 2008 09:55:12 -0700 Subject: [python-win32] python procedure in maya In-Reply-To: <81bfef2e0806110905t79b568eeoc0b17b452d3df229@mail.gmail.com> References: <81bfef2e0806110905t79b568eeoc0b17b452d3df229@mail.gmail.com> Message-ID: <48500370.8040302@probo.com> kNish wrote: > Hi, > > 1) how do I source a python script thru MEL. > > 2) Execute a python script thru MEL > > (python("");) This is not a PyWin32 question. You need to find a Maya mailing list. There appear to be a lot of good resources on Google. A few minutes with Google seems to show that the "pySource" command in MEL executes a Python file, or you can execute short snippet by saying: py "print 'Hello!' " -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Jun 11 18:59:34 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 11 Jun 2008 09:59:34 -0700 Subject: [python-win32] Python Service does not start at Windows boot but at user's logon In-Reply-To: <484F9570.2080107@linbox.com> References: <484D33C2.7080909@linbox.com> <058a01c8ca87$7b9b4c30$72d1e490$@com.au> <484F9570.2080107@linbox.com> Message-ID: <48500476.5030401@probo.com> spoirot wrote: >> > I totally agree with you. I have found another dependency to use : > Themes, which is less heavy than RPCSS. > This works, but it does not make exactly what I want. Plus, it is simply not an acceptable practice for you to change some other service's dependencies. > Indeed, I would like to set some values in a HKLM subkey > at windows boot, in order that changes are effective as soon as a user > logs in after boot sequence. Why? What are you really trying to do here? What you're describing sounds like a perfect vector for malware and trojan horses. You can certainly have a domain login script that gets executed very early in the login sequence. That's how most corporate environments enforce their IT policies. > In my case, > registry values are well written, but changes aren't effective yet... > So user needs to reboot. > I tried to use the FlushKey() method from _winreg module in order to > immediately write changes to registry. > Changes are written, but not effective. I thought that user's login > refreshed the registry, and then changes could > have taken effect, but it seems not to be really the case. Which registry entries are you changing? Perhaps there is another way. > Is there any other Python _winreg method that could force registry > changes to become effective as soon as > changes are written into the registry ? This is just not the right question. Any changes take effect immediately, but if some other process has already read the value, there's nothing you can do, unless there's a way to notify the other process to re-read its settings. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From tnelson at onresolve.com Wed Jun 11 22:03:17 2008 From: tnelson at onresolve.com (Trent Nelson) Date: Wed, 11 Jun 2008 21:03:17 +0100 Subject: [python-win32] Hooking in NTLM... Message-ID: <6167796BFEB5D0438720AC212E89A6B00787274C@exchange.onresolve.com> Howdy, Mark, I vaguely recall a brief chat we had at PyCon where you said you'd hooked NTLM into, um, some sort of web-enabled Python environment ;-) I can't remember the details (hope you can!), but I'm interested in whatever you came up with. Currently, if I want to 'seamlessly' get a user's Windows domain login credentials, I set up httpd with mod_auth_sspi then redirect/proxy to a Python web-aware program (i.e. something on Twisted). Would be nice to hook the NTLM stuff directly into the Python request/response http level, if possible. Trent. From mhammond at skippinet.com.au Thu Jun 12 00:59:01 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 12 Jun 2008 08:59:01 +1000 Subject: [python-win32] Hooking in NTLM... In-Reply-To: <6167796BFEB5D0438720AC212E89A6B00787274C@exchange.onresolve.com> References: <6167796BFEB5D0438720AC212E89A6B00787274C@exchange.onresolve.com> Message-ID: <081a01c8cc16$bfda4a00$3f8ede00$@com.au> Check out win32\demos\security\sspi - there you should find enough info to get you started, including a *client* that uses NTLM to authenticate with a server (which means in practice, you probably need to configure IIS for NTLM auth to test this) The issue with integrating it into httplib or similar is that the authentication process is quite different than http basic auth. In summary, NTLM is a multi-step challenge/response system - ie, you end up taking a number of requests, often 3, to get a "secure" channel. Further, it is the channel itself which is secured - eg, the socket. Once the socket is closed, you must re-authenticate from scratch again - the info you negotiated in your first connection is no longer any use. The only way I could find to integrate this with a httplib style class was to implement an "onrequest callback" - a hook that the connection class would call with the raw headers etc, and a way for that callback to modifiy the request headers and tell the class to retry the operation with the new headers. At some stage, the callback will hopefully return a result indicating auth is complete, so no further retries are necessary and comms can continue without further worrying about auth until the socket closes. Further, it then had to associate the authentication token with the socket itself. Hope this helps - check out the sspi demos and let me know if you have any questions (the server side of the authentication dance is almost identical to the client side, as you will see) Cheers, Mark > -----Original Message----- > From: python-win32-bounces at python.org [mailto:python-win32- > bounces at python.org] On Behalf Of Trent Nelson > Sent: Thursday, 12 June 2008 6:03 AM > To: python-win32 at python.org > Subject: [python-win32] Hooking in NTLM... > > Howdy, > > Mark, I vaguely recall a brief chat we had at PyCon where you said > you'd hooked NTLM into, um, some sort of web-enabled Python environment > ;-) I can't remember the details (hope you can!), but I'm interested > in whatever you came up with. Currently, if I want to 'seamlessly' get > a user's Windows domain login credentials, I set up httpd with > mod_auth_sspi then redirect/proxy to a Python web-aware program (i.e. > something on Twisted). > > Would be nice to hook the NTLM stuff directly into the Python > request/response http level, if possible. > > Trent. > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From mani.sabri at gmail.com Thu Jun 12 05:12:59 2008 From: mani.sabri at gmail.com (mani sabri) Date: Thu, 12 Jun 2008 06:42:59 +0330 Subject: [python-win32] Embedding python in a win32 dll and a wx thread Message-ID: <48508678.39e9220a.4757.ffff9d43@mx.google.com> Hello everyone It's a big post but I think it's an interesting problem and the result may become a good recipe for embedding python in many applications in windows. I'm on winxp sp2 using python 2.4 unicode, wxpython 2.8.7 unicode and vs2003... I'm embedding python in a non opensource financial application which only lets me to import a dll in scripts which it calls experts. These experts have three functions: 1-init: which is called when you attach your expert to a chart. 2-start: which is called whenever a new price (quote) is received. 3-deinit: which is called when you remove your expert from a chart. For embedding python I thought of these 3 steps: -In 'init' I call initpython and startshell from my dll which initializes python[2], imports wx and starts a shell[3]. - In 'start' I send data to python for computation! (not relevant for now) - In 'deinit' I exit wx app[4] and finalize python[5]. Everything works fine for the first time (python initialize/shell start/ shell terminate/ python finalize) But after a while I realized that I need to reinitialize python and start all over again. The problem is that I have no control over loading and unloading my dll Which means that the dll stays attached to the application process after detaching from a chart and somehow it becomes the source of evil the second time I try to attach it to a chart and I get this traceback[1] in the pystartshell function when I try to create the wx app. Whats the problem? If as the traceback says I'm not in main thread why it works the first time? The application manual says it detaches the dll from the process when the expert is removed from a chart. And I check the dllmain detach case and it was true!!! Is it the problem of some thread remaining active after finalizing python (or dllmain detach)? How can I know if a thread remains alive after dllmain detach? Is it usefull to fully unload the dll and the dlls the python loads when I import wx from memory with win32 api freelibray? I tried it[6] without and change in results, is it any other way to do it? Any suggestion is welcomed, I'm a newbie, please criticize! I will be the most grateful person on earth if you guide me! Best regards, Mani Ps: I tried to attach a 5kb zip file containing the dll source and a mocking application that produces the same error but I got mail delivery failure. If you are the angle who is going to help me ;) let me know and I will send you the source codes via email. [1] Traceback (most recent call last): File "C:\Python24\lib\site-packages\wx-2.8-msw-unicode\wx\py\shell.py", line 1416, in OnUpdateUI if id in (wx.ID_CUT, wx.ID_CLEAR): AttributeError: 'NoneType' object has no attribute 'ID_CUT' Traceback (most recent call last): File "C:\Python24\lib\site-packages\wx-2.8-msw-unicode\wx\_misc.py", line 1341, in Notify self.notify() File "C:\Python24\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 14470, in Notify self.result = self.callable(*self.args, **self.kwargs) File "C:\Python24\lib\site-packages\wx-2.8-msw-unicode\wx\_windows.py", line 1071, in SplitVertically return _windows_.SplitterWindow_SplitVertically(*args, **kwargs) wx._core.PyAssertionError: C++ assertion "wxThread::IsMain()" failed at ..\..\src\msw\evtloop.cpp(244) in wxEventLoop::Dispatch(): only the main thread can process Windows messages Traceback (most recent call last): File "C:\Python24\lib\site-packages\wx-2.8-msw-unicode\wx\py\shell.py", line 1416, in OnUpdateUI if id in (wx.ID_CUT, wx.ID_CLEAR): AttributeError: 'NoneType' object has no attribute 'ID_CUT' [2] EXPFUNC void __stdcall initPython(void) { Py_Initialize(); PyEval_InitThreads(); m_mainThreadState = PyThreadState_Get(); PyEval_ReleaseLock(); } [3] // this function is called in a separate thread Pystartshell(void *data) { PyEval_AcquireLock(); PyThreadState* pInterpreter = Py_NewInterpreter(); PyObject *globals = PyDict_New(); PyDict_SetItemString(globals, "__builtins__", PyEval_GetBuiltins()); PyDict_SetItemString(globals,"wx",PyImport_ImportModule("wx")); PyRun_String("from wx.py import crust\n" "app = wx.PySimpleApp(redirect=False)\n" "frame = crust.CrustFrame(locals={'myApp':app})\n" "frame.Show()\n" ,Py_file_input,globals,globals); // app is global so I can exit this thread before finalizing python app = PyDict_GetItemString(globals,"app"); Py_INCREF(app); PyObject_CallFunctionObjArgs(PyObject_GetAttrString( app,"MainLoop"),NULL); Py_DECREF(globals); Py_EndInterpreter(pInterpreter); PyEval_ReleaseLock(); _endthread(); } [4] //calling the exit function of wx application void exit(void *a) { PyEval_AcquireLock(); PyThreadState* pInterpreter = Py_NewInterpreter(); PyObject_CallFunctionObjArgs(PyObject_GetAttrString(app, "Exit"),NULL); Py_EndInterpreter(pInterpreter); PyEval_ReleaseLock(); _endthread(); } [5] EXPFUNC void __stdcall deinitPython(void) { HANDLE ex = (HANDLE) _beginthread(exit,0,NULL); WaitForSingleObject(ex,INFINITE); PyEval_AcquireLock(); Py_DECREF(app); PyThreadState_Swap(m_mainThreadState); Py_Finalize(); } [6] HINSTANCE a1 = LoadLibraryEx("c:\\python24\\lib\\site-packages\\wx-2.8-msw-unicode\\wx\\_co re_.pyd", NULL,LOAD_WITH_ALTERED_SEARCH_PATH); HINSTANCE a2 = LoadLibraryEx("c:\\python24\\lib\\site-packages\\wx-2.8-msw-unicode\\wx\\wxm sw28uh_vc.dll", NULL,LOAD_WITH_ALTERED_SEARCH_PATH); HINSTANCE a3 = LoadLibraryEx("c:\\python24\\lib\\site-packages\\wx-2.8-msw-unicode\\wx\\_gd i_.pyd", NULL,LOAD_WITH_ALTERED_SEARCH_PATH); HINSTANCE a4 = LoadLibraryEx("c:\\python24\\lib\\site-packages\\wx-2.8-msw-unicode\\wx\\_wi ndows_.pyd", NULL,LOAD_WITH_ALTERED_SEARCH_PATH); HINSTANCE a5 = LoadLibraryEx("c:\\python24\\lib\\site-packages\\wx-2.8-msw-unicode\\wx\\_co ntrols_.pyd", NULL,LOAD_WITH_ALTERED_SEARCH_PATH); HINSTANCE a6 = LoadLibraryEx("c:\\python24\\lib\\site-packages\\wx-2.8-msw-unicode\\wx\\_mi sc_.pyd", NULL,LOAD_WITH_ALTERED_SEARCH_PATH); HINSTANCE a7 = LoadLibraryEx("c:\\python24\\lib\\site-packages\\wx-2.8-msw-unicode\\wx\\_st c.pyd", NULL,LOAD_WITH_ALTERED_SEARCH_PATH); HINSTANCE a8 = LoadLibraryEx("c:\\python24\\lib\\site-packages\\wx-2.8-msw-unicode\\wx\\wxm sw28uh_stc_vc.dll", NULL,LOAD_WITH_ALTERED_SEARCH_PATH); FreeLibrary(a1); FreeLibrary(a2); FreeLibrary(a3); FreeLibrary(a4); FreeLibrary(a5); FreeLibrary(a6); FreeLibrary(a7); FreeLibrary(a8); FreeLibrary(a1); FreeLibrary(a2); FreeLibrary(a3); FreeLibrary(a4); FreeLibrary(a5); FreeLibrary(a6); FreeLibrary(a7); FreeLibrary(a8); a1=a2=a3=a4=a5=a6=a7=a8=NULL; -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Thu Jun 12 11:08:39 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 12 Jun 2008 19:08:39 +1000 Subject: [python-win32] Embedding python in a win32 dll and a wx thread In-Reply-To: <48508678.39e9220a.4757.ffff9d43@mx.google.com> References: <48508678.39e9220a.4757.ffff9d43@mx.google.com> Message-ID: <08b101c8cc6b$e99fa560$bcdef020$@com.au> > Everything works fine for the first time (python initialize/shell start/ shell > terminate/ python finalize) But after a while I realized that I need to > reinitialize python and start all over again. > The problem is that I have no control over loading and unloading my dll > Which means that the dll stays attached to the application process after > detaching from a chart and somehow it becomes the source of evil the > second time I try to attach it to a chart and I get this traceback[1] in > the pystartshell function when I try to create the wx app. Sadly, Python dies in a number of creative ways with multiple init/finalize cycles. I'd suggest simply not even trying to unload Python - just keep a flag for yourself. This means it might be almost impossible to ever call Py_Finalize (calling from your DllMain as you are unloaded is unlikely to be reliable either) - Windows will cope - but exit hooks and finalizers for objects which are still alive will not run. If it is any consolation, Python is also never finalized when a win32com object causes Python to be loaded into a process either... Cheers, Mark From leegold at fastmail.fm Sun Jun 15 23:04:48 2008 From: leegold at fastmail.fm (leegold) Date: Sun, 15 Jun 2008 17:04:48 -0400 Subject: [python-win32] Keystrokes Python Message-ID: <1213563888.10852.1258579857@webmail.messagingengine.com> Wondered if Python could solve this problem: I have laptop with XP. To adjust screen contrast I hit FN key then F11. It does not work well - I end up with too little/much contrast - the key combo does not provide the granularity/fine adjustment I want. There's no 0-100 bar graph as well. It's probably tied with the ACPI - Advanced Configuration and Power Interface too which I know very little about - If I reset the BIOS to defaults, monitor settings seem to go back to normal. What I thought of doing was somehow programatically recreate one (1) FN-F11 keystoke message and see what effect it has. Probably complicating the problem is that pressing FN-F11 one rasies contrast and then pressing it again lowers contrast... Are there some doable Python methods for this? I'm not a guru but link me and I'd give it a try. Thanks, Lee G. From boblatest at googlemail.com Mon Jun 16 11:51:17 2008 From: boblatest at googlemail.com (Robert Latest) Date: Mon, 16 Jun 2008 11:51:17 +0200 Subject: [python-win32] Problems connecting to an MS Access (.mdb) file Message-ID: Hello folks, At work I have to use an MS Access database. Actually it's two databases (or .mdb files, anyway): One is the "master" file that contains all the relevant data in tables, and the other one seems to act a s a "GUI client" which connects to the first one. Anyway, I have to go through dozens of data records each day, but for most of them whatever it is I'm having to do could be easily automated by a script, and that's what I'm trying to do. Tthe "master" DB resides on a networked drive, and I made a local copy to test out my script. When this was finished I pointed the script at the real master, but got the error message below. According to a password recovery tool I found on the Net (passwordrecovery4msaccess.jar), neither GUI nor master DB carry a password. Ah yes, of course I've spoken to the IT guy. He doesn't like my messing with his DB. But as this very stupid task eats up a lot of my work time, I want to hack it. Here's the error message: ----------- PythonWin 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyright information. Traceback (most recent call last): File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript exec codeObject in __main__.__dict__ File "H:\ADB-python.py", line 8, in conn = odbc.odbc(conn_str) dbi.operation-error: [Microsoft][ODBC Microsoft Access Driver]Allgemeiner Fehler Registrierungsschl?ssel 'Temporary (volatile) Jet DSN for process 0xfd0 Thread 0xfa4 DBC 0x349644 Jet' kann nicht ge?ffnet werden. in LOGIN ----------- Thanks, robert From gerdusvanzyl at gmail.com Mon Jun 16 14:06:38 2008 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Mon, 16 Jun 2008 14:06:38 +0200 Subject: [python-win32] Problems connecting to an MS Access (.mdb) file In-Reply-To: References: Message-ID: <91882ea90806160506u142771a8nc495ff59cd4d2b28@mail.gmail.com> >From some googling it seems to be a file permission problem. see http://www.bellaonline.com/articles/art17684.asp and http://support.microsoft.com/?scid=kb%3Ben-us%3B315456 As a workaround you can make a local access database, use link tables to connect to the remote database, then point your script to your local database which will then indirectly work on the remote database. :-) ~Gerdus On Mon, Jun 16, 2008 at 11:51 AM, Robert Latest wrote: > Hello folks, > > At work I have to use an MS Access database. Actually it's two > databases (or .mdb files, anyway): One is the "master" file that > contains all the relevant data in tables, and the other one seems to > act a s a "GUI client" which connects to the first one. > > Anyway, I have to go through dozens of data records each day, but for > most of them whatever it is I'm having to do could be easily automated > by a script, and that's what I'm trying to do. > > Tthe "master" DB resides on a networked drive, and I made a > local copy to test out my script. When this was finished I pointed the > script at the real master, but got the error message below. > > According to a password recovery tool I found on the Net > (passwordrecovery4msaccess.jar), neither GUI nor master DB carry a > password. > > Ah yes, of course I've spoken to the IT guy. He doesn't like my > messing with his DB. But as this very stupid task eats up a lot of my > work time, I want to hack it. > > Here's the error message: > ----------- > PythonWin 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit > (Intel)] on win32. > Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' > for further copyright information. > Traceback (most recent call last): > File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", > line 312, in RunScript > exec codeObject in __main__.__dict__ > File "H:\ADB-python.py", line 8, in > conn = odbc.odbc(conn_str) > dbi.operation-error: [Microsoft][ODBC Microsoft Access > Driver]Allgemeiner Fehler Registrierungsschl?ssel 'Temporary > (volatile) Jet DSN for process 0xfd0 Thread 0xfa4 DBC 0x349644 Jet' > kann nicht ge?ffnet werden. in LOGIN > ----------- > > Thanks, > robert > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From mc at mclaveau.com Mon Jun 16 17:59:44 2008 From: mc at mclaveau.com (Michel Claveau) Date: Mon, 16 Jun 2008 17:59:44 +0200 Subject: [python-win32] pythoncom warning: PyVARDESC In-Reply-To: <00c001c8c515$d6c503c0$844f0b40$@com.au> References: <8664A6B76E874A81A7DAC6DAD0C3C59D@MCI1330> <00c001c8c515$d6c503c0$844f0b40$@com.au> Message-ID: Hi! Sorry for late... An example: Create the file C:\tst3.htm, with this content: AAAAAAA
BBBBBBB
then use this Python script: import win32com.client import time navig = win32com.client.Dispatch('InternetExplorer.Application') navig.Navigate(r'file:///C:/tst3.htm') time.sleep(0.5) window = navig.Document.parentWindow print window.ooo.txt and, you have: pythoncom warning: PyVARDESC ctor has unknown varkind (3) - returning None pythoncom warning: PyVARDESC ctor has unknown varkind (3) - returning None pythoncom warning: PyVARDESC ctor has unknown varkind (3) - returning None Mark Hammond is a genious Good day (night?) -- Michel Claveau From timr at probo.com Mon Jun 16 19:36:07 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 16 Jun 2008 10:36:07 -0700 Subject: [python-win32] Keystrokes Python In-Reply-To: <1213563888.10852.1258579857@webmail.messagingengine.com> References: <1213563888.10852.1258579857@webmail.messagingengine.com> Message-ID: <4856A487.1070309@probo.com> leegold wrote: > Wondered if Python could solve this problem: > > I have laptop with XP. To adjust screen contrast I hit FN key then F11. > It does not work well - I end up with too little/much contrast - the key > combo does not provide the granularity/fine adjustment I want. There's > no 0-100 bar graph as well. It's probably tied with the ACPI - Advanced > Configuration and Power Interface too which I know very little about - > If I reset the BIOS to defaults, monitor settings seem to go back to > normal. > > What I thought of doing was somehow programatically recreate one (1) > FN-F11 keystoke message and see what effect it has. > This is, in general, not possible. The Fn keystrokes are trapped and handled by the BIOS. When one of them does something that a Windows driver needs to know about, the BIOS fires some kind of event (like an ACPI event). The Fn keys themselves never get to Windows. There is no "Fn" key in the standard virtual key set, so there is no way for you to simulate one. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From le.dahut at laposte.net Tue Jun 17 11:18:50 2008 From: le.dahut at laposte.net (le dahut) Date: Tue, 17 Jun 2008 11:18:50 +0200 Subject: [python-win32] pywin32 build 211 released In-Reply-To: <058901c8ca87$76463f10$62d2bd30$@com.au> References: <003b01c8c2ee$8ec50260$ac4f0720$@com.au> <484CFDB0.6010304@laposte.net> <058901c8ca87$76463f10$62d2bd30$@com.au> Message-ID: <4857817A.3080008@laposte.net> I suppose that you use "runas" in order to get run in real administrator mode. There are several ways to get an installer run automatically in real admin mode : #1 : the name of the .exe must contain "setup" or "install" keyword. This make the UAC detect it as an installer and asks the user for a elevation confirmation. #2 : the .exe must have a manifest that contains : """ ... (I use the "python.exe.manifest" in which I add the following) """ I've put the manifest directly in the .exe using py2exe and : 'other_resources': [(24, 1, mymanifest)], "24" is where the manifest should be. #3 Maybe someone could complete here ...? Hope this helps. Mark Hammond a ?crit : >> I encounter a problem when trying to install it. I get prompted by a >> secure window (a window with some keys icons) asking me if I want to >> run >> it with my account with(out) security against virus or with another >> account. >> None of the 3 possibilities works for me. Any idea ? > > When you say none of the possibilities work, how exactly do they fail? > > I'm sure I could extend the OS check to only attempt elevation on XP with > SP1, but it would be nice to have a better understanding of the failure > before doing that (eg, while testing this, I found Win2k also seems to > support the 'runas' ShellExecute API - but it behaves slightly differently, > and IsUserAnAdmin() isn't available. So if it (basically) works on Win2k, > I'd be surprised it fails worse on XP without SP1. > > Cheers, > > Mark > > > From mhammond at skippinet.com.au Tue Jun 17 14:14:02 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 17 Jun 2008 22:14:02 +1000 Subject: [python-win32] pywin32 build 211 released In-Reply-To: <4857817A.3080008@laposte.net> References: <003b01c8c2ee$8ec50260$ac4f0720$@com.au> <484CFDB0.6010304@laposte.net> <058901c8ca87$76463f10$62d2bd30$@com.au> <4857817A.3080008@laposte.net> Message-ID: <016d01c8d073$b57354b0$2059fe10$@com.au> > I suppose that you use "runas" in order to get run in real > administrator mode. "runas" can actually refer to a couple of things. One is in the manifest that you refer to, but another alternative is for your executable to use ShellExecute, with a verb of "runas" to re-execute itself. > #2 : the .exe must have a manifest that contains : > """ > ... (I use the "python.exe.manifest" in which I add the following) > > > > level="requireAdministrator" > uiAccess="false"/> > > > > """ > > > I've put the manifest directly in the .exe using py2exe and : > 'other_resources': [(24, 1, mymanifest)], > "24" is where the manifest should be. I'm not sure this will work (and I'm not sure if you are saying it does or doesn't work). To check it works, you should use the 'mt.exe' tool that comes with the MSVC compilers and Platform SDKs to check it can extract a manifest, and it is as you expect. Yet another alternative is to use mt.exe *after* py2exe has run to embed the manifest in the final executable. Note however that it is rare you need the py2exe created executable to run as administrator - it is the *installer* for the py2exe program that generally needs this. > #3 Maybe someone could complete here ...? Hope the above help. Cheers, Mark From le.dahut at laposte.net Tue Jun 17 17:23:02 2008 From: le.dahut at laposte.net (le dahut) Date: Tue, 17 Jun 2008 17:23:02 +0200 Subject: [python-win32] pywin32 build 211 released In-Reply-To: <016d01c8d073$b57354b0$2059fe10$@com.au> References: <003b01c8c2ee$8ec50260$ac4f0720$@com.au> <484CFDB0.6010304@laposte.net> <058901c8ca87$76463f10$62d2bd30$@com.au> <4857817A.3080008@laposte.net> <016d01c8d073$b57354b0$2059fe10$@com.au> Message-ID: <4857D6D6.8060607@laposte.net> Mark Hammond wrote : >> #2 : the .exe must have a manifest that contains : >> """ >> ... (I use the "python.exe.manifest" in which I add the following) >> >> >> >> > level="requireAdministrator" >> uiAccess="false"/> >> >> >> >> """ >> >> >> I've put the manifest directly in the .exe using py2exe and : >> 'other_resources': [(24, 1, mymanifest)], >> "24" is where the manifest should be. > > I'm not sure this will work (and I'm not sure if you are saying it does or > doesn't work). To check it works, you should use the 'mt.exe' tool that > comes with the MSVC compilers and Platform SDKs to check it can extract a > manifest, and it is as you expect. Actually this works fine, it was only an idea that you can use to make pywin32 installable on XP without service pack : * on XP it will have the classic behaviour (like with pywin32-210) * on Vista, user will be prompted for an elevation I suppose that you don't use py2exe but maybe you can add an embedded manifest in your installer. http://msdn.microsoft.com/en-us/library/bb756929.aspx > > Yet another alternative is to use mt.exe *after* py2exe has run to embed the > manifest in the final executable. > > Note however that it is rare you need the py2exe created executable to run > as administrator - it is the *installer* for the py2exe program that > generally needs this. > >> #3 Maybe someone could complete here ...? > > Hope the above help. > > Cheers, > > Mark > > > From ghankiewicz at rastertech.es Wed Jun 18 09:59:51 2008 From: ghankiewicz at rastertech.es (Grzegorz Adam Hankiewicz) Date: Wed, 18 Jun 2008 09:59:51 +0200 Subject: [python-win32] pywin32 build 211 released In-Reply-To: <003b01c8c2ee$8ec50260$ac4f0720$@com.au> References: <003b01c8c2ee$8ec50260$ac4f0720$@com.au> Message-ID: <4858C077.5010309@rastertech.es> Mark Hammond escribi?: > Hi all, > I've finally released pywin32 build 211! Is there any attribute in some module I could check to make sure that the imported module corresponds to this build? I can't find some sort of "global" pywin32 module with this information. I'm writting safety checks for our build process that verify that the installed/imported module of all external software matches an expected version string. Example: import sys if sys.version_info != EXPECTED_PYTHON_VERSION: raise Some_error_class -- Rastertech Espa?a S.A. Grzegorz Adam Hankiewicz /Jefe de Producto TeraVial/ C/ Perfumer?a 21. Nave I. Pol?gono industrial La Mina 28770 Colmenar Viejo. Madrid (Espa?a) Tel. +34 918 467 390 (Ext.17) *?* Fax +34 918 457 889 ghankiewicz at rastertech.es *?* www.rastertech.es From mhammond at skippinet.com.au Wed Jun 18 14:04:55 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 18 Jun 2008 22:04:55 +1000 Subject: [python-win32] pywin32 build 211 released In-Reply-To: <4858C077.5010309@rastertech.es> References: <003b01c8c2ee$8ec50260$ac4f0720$@com.au> <4858C077.5010309@rastertech.es> Message-ID: <005901c8d13b$9c0ef240$d42cd6c0$@com.au> > Mark Hammond escribi?: > > Hi all, > > I've finally released pywin32 build 211! > > Is there any attribute in some module I could check to make sure that > the imported module corresponds to this build? I can't find some sort > of > "global" pywin32 module with this information. Apart from the fact I screwed up the version number with build 211, there is a pywin32.version.txt file in the site-packages directory (use distutils to find that path). Alternatively, use the win32api file version functions to get the version numbers from any of the .dll/.pyd/.exe files. FWIW, here is how Pythonwin's Help->About menu does it: # Get the build number - written by installers. # For distutils build, read pywin32.version.txt import distutils.sysconfig site_packages = distutils.sysconfig.get_python_lib(plat_specific=1) try: build_no = open(os.path.join(site_packages, "pywin32.version.txt")).read().strip() ver = "pywin32 build %s" % build_no except EnvironmentError: ver = None if ver is None: # See if we are Part of Active Python ver = _GetRegistryValue("SOFTWARE\\ActiveState\\ActivePython", "CurrentVersion") if ver is not None: ver = "ActivePython build %s" % (ver,) if ver is None: ver = "" HTH, Mark From mc at mclaveau.com Thu Jun 19 08:22:58 2008 From: mc at mclaveau.com (Michel Claveau) Date: Thu, 19 Jun 2008 08:22:58 +0200 Subject: [python-win32] P3K? Message-ID: <8243CB76094841ADA86A35A2C38E48E6@MCI1330> Hi! P3K (aka Python-3000, or Python 3) release 3.0b1 is coming. Is Pywin32 on P3K planned for soon? Thank you, by advance Michel Claveau From mhammond at skippinet.com.au Fri Jun 20 01:07:08 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 20 Jun 2008 09:07:08 +1000 Subject: [python-win32] P3K? In-Reply-To: <8243CB76094841ADA86A35A2C38E48E6@MCI1330> References: <8243CB76094841ADA86A35A2C38E48E6@MCI1330> Message-ID: <000301c8d261$40f94dc0$c2ebe940$@com.au> > P3K (aka Python-3000, or Python 3) release 3.0b1 is coming. > Is Pywin32 on P3K planned for soon? AFAIK, Roger has looked into this a little, and some of his efforts towards making the win32 modules natively Unicode are an effort towards this - but I'm not aware of any serious work on this as yet. There will obviously be 2 sides to this - the .py code and the .cpp code - running the .py code through 2to3 might be an interesting exercise, and expose 10 year old code screaming for a cleanup which can be done independently. This might mean we might need to get a little more brutal about which Python versions we support moving forward - eg, is 2.3 and earlier support still necessary if it costs pain for this transition? But in case you can't tell, I personally haven't looked at this at all ;) Cheers, Mark From vernondcole at gmail.com Fri Jun 20 04:39:11 2008 From: vernondcole at gmail.com (Vernon Cole) Date: Thu, 19 Jun 2008 20:39:11 -0600 Subject: [python-win32] P3K? In-Reply-To: <000301c8d261$40f94dc0$c2ebe940$@com.au> References: <8243CB76094841ADA86A35A2C38E48E6@MCI1330> <000301c8d261$40f94dc0$c2ebe940$@com.au> Message-ID: I vote FOR dropping 2.3 and earlier support and moving to 2.6 / 3.0 syntax as soon as possible. My reasons for this are selfish... adodbapi is already restricted to 2.3 and later, since it uses decimal numbers to return SQL data from some numeric columns. ;-) Archives of older releases of pywin are kept on sourceforge for those precious few who are locked into an older python version. Onward and upward, I say! -------------- next part -------------- An HTML attachment was scrubbed... URL: From mc at mclaveau.com Fri Jun 20 07:19:52 2008 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 20 Jun 2008 07:19:52 +0200 Subject: [python-win32] P3K? In-Reply-To: References: <8243CB76094841ADA86A35A2C38E48E6@MCI1330> <000301c8d261$40f94dc0$c2ebe940$@com.au> Message-ID: <82E5EAE8478D4F759985A81A4B206218@MCI1330> Hi! > I vote FOR dropping 2.3 and earlier support and moving to 2.6 / 3.0 syntax > as soon as possible. +1 > older releases of pywin are kept on sourceforge for ... ...(older) users of older python version. or: "(older) users of older python version will use older releases of pywin" @-salutations -- Michel Claveau From rwupole at msn.com Fri Jun 20 09:32:02 2008 From: rwupole at msn.com (Roger Upole) Date: Fri, 20 Jun 2008 03:32:02 -0400 Subject: [python-win32] P3K? Message-ID: Vernon Cole wrote: >I vote FOR dropping 2.3 and earlier support and moving to 2.6 / 3.0 syntax > as soon as possible. > > My reasons for this are selfish... adodbapi is already restricted to 2.3 > and > later, since it uses decimal numbers to return SQL data from some numeric > columns. ;-) > > Archives of older releases of pywin are kept on sourceforge for those > precious few who are locked into an older python version. > > > Onward and upward, I say! Building for Python 3 is going to take a lot of work. There are many incompatible changes to the C api (and I'm not even sure they're guaranteed not to change again before the next release). The basic layout of python objects has been revised, which will make it very difficult to continue to build from the same sources, as can be done now for 2.2-2.6. Also, the buffer interface has changed drastically, and Pywin32 makes extensive use of buffers. As things stand right now, upward is a steep climb. Dropping 2.3 doesn't really gain us much while we're still supporting 2.5, which is still the most recent stable release. Python 2.6 may be useful for transitioning the python code toward 3.0, but it doesn't help with the C++ sources. Roger From mc at mclaveau.com Fri Jun 20 09:56:13 2008 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 20 Jun 2008 09:56:13 +0200 Subject: [python-win32] P3K? In-Reply-To: References: Message-ID: <774495BD552D4BDAB312226446817241@MCI1330> Hi! You (& MH) already proved your know-how. IMO, the best way is: made as you want... @-salutations Michel Claveau From ThorstenRiesberg at gmx.de Fri Jun 20 16:01:32 2008 From: ThorstenRiesberg at gmx.de (thorsten riesberg) Date: Fri, 20 Jun 2008 16:01:32 +0200 Subject: [python-win32] Embedded Python & win32api Message-ID: <20080620140132.97380@gmx.net> Hello everyone, I'm getting crasy about embedding python-win32 in a c++ application. PyRun_SimpleString("import win32api") failes with the error message: ImportError: No module named win32api. Every thing works fine if i use the PythonShell. The problem is not! related to the actual sys.path. I found the problem x-times on the net but never a solution that works. If somebody has a solution, thanks in advance!! Best Regards, Thorsten -- Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten Browser-Versionen downloaden: http://www.gmx.net/de/go/browser From python at bdurham.com Fri Jun 20 16:57:45 2008 From: python at bdurham.com (python at bdurham.com) Date: Fri, 20 Jun 2008 10:57:45 -0400 Subject: [python-win32] Capturing a Python script's Task Manager statistics Message-ID: <1213973865.18018.1259503939@webmail.messagingengine.com> Anyone know of a way to have a Python script capture its own Task Manager statistics? I have a long running Python script whose CPU, memory, disk i/o, and network traffic I would like to monitor. An alternative more generic approach would be to run an 'observer' script that would monitor all Task Manager statistics so I could watch multiple scripts. Motivation: I would like to track this script's resource requirements and if the script detects its exceeding some pre-defined resource limits for a certain amount of time, to send out an alert. Any suggestions (or recommendation on a 3rd party that does the same) appreciated. Thank you, Malcolm From larry.bates at websafe.com Fri Jun 20 17:20:06 2008 From: larry.bates at websafe.com (Larry Bates) Date: Fri, 20 Jun 2008 10:20:06 -0500 Subject: [python-win32] Capturing a Python script's Task Manager statistics In-Reply-To: <1213973865.18018.1259503939@webmail.messagingengine.com> References: <1213973865.18018.1259503939@webmail.messagingengine.com> Message-ID: python at bdurham.com wrote: > Anyone know of a way to have a Python script capture its own Task > Manager statistics? > > I have a long running Python script whose CPU, memory, disk i/o, and > network traffic I would like to monitor. > > An alternative more generic approach would be to run an 'observer' > script that would monitor all Task Manager statistics so I could watch > multiple scripts. > > Motivation: I would like to track this script's resource requirements > and if the script detects its exceeding some pre-defined resource limits > for a certain amount of time, to send out an alert. > > Any suggestions (or recommendation on a 3rd party that does the same) > appreciated. > > Thank you, > Malcolm Suggestion: Convert it to a service and then you can get at the statistics by hooking the Windows Performance Monitor. Great description of how you would do this in "Python Programming on Win32" book. -Larry From mail at timgolden.me.uk Fri Jun 20 17:33:05 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 20 Jun 2008 16:33:05 +0100 Subject: [python-win32] Capturing a Python script's Task Manager statistics In-Reply-To: <1213973865.18018.1259503939@webmail.messagingengine.com> References: <1213973865.18018.1259503939@webmail.messagingengine.com> Message-ID: <485BCDB1.2000405@timgolden.me.uk> python at bdurham.com wrote: > Anyone know of a way to have a Python script capture its own Task > Manager statistics? > > I have a long running Python script whose CPU, memory, disk i/o, and > network traffic I would like to monitor. > > An alternative more generic approach would be to run an 'observer' > script that would monitor all Task Manager statistics so I could watch > multiple scripts. > > Motivation: I would like to track this script's resource requirements > and if the script detects its exceeding some pre-defined resource limits > for a certain amount of time, to send out an alert. This is the kind of thing which WMI was probably designed for. Zenoss [1] uses it, for example, and I have had correspondence with several people who used my wmi module [2] for this sort of thing. One caveat: WMI is basically a uniform layer over the more complex API. It's *not* the fastest thing on earth and less so when filtered through a Python wrapper round a Dispatch-based wrapper round the WMI COM interface. YMMV. There *are* specific performance classes [3] but often you'll just want to watch the attributes for the Win32_Process [4] class (possibly specifying by process_id). You can either poll, or you can use the WMI event model.[5][6] TJG [1] http://www.zenoss.com/ [2] http://timgolden.me.uk/python/wmi.html [3] http://msdn.microsoft.com/en-us/library/aa392397(VS.85).aspx [4] http://msdn.microsoft.com/en-us/library/aa394372(VS.85).aspx [5] http://msdn.microsoft.com/en-us/library/aa393013(VS.85).aspx [6] http://tgolden.sc.sabren.com/python/wmi-tutorial.html#monitoring From vernondcole at gmail.com Fri Jun 20 17:38:43 2008 From: vernondcole at gmail.com (Vernon Cole) Date: Fri, 20 Jun 2008 09:38:43 -0600 Subject: [python-win32] P3K? In-Reply-To: <82E5EAE8478D4F759985A81A4B206218@MCI1330> References: <8243CB76094841ADA86A35A2C38E48E6@MCI1330> <000301c8d261$40f94dc0$c2ebe940$@com.au> <82E5EAE8478D4F759985A81A4B206218@MCI1330> Message-ID: > > > > older releases of pywin are kept on sourceforge for ... >> > > ...(older) users of older python version. > > or: "(older) users of older python version will use older releases of > pywin" > > > @-salutations > -- > Michel Claveau > > * OLDER * ! Humph! For the information of you children, I learned to program in FORTRAN II. My first hands-on computer was a PDP-8 with 4096 12-bit words of core memory. It took 15 minutes to boot EDUBASIC into that 4K, since it carried only a 110 baud punched paper tape reader (on a real Teletype brand TTY) for storage media. If you ever wondered why BASIC was such a stupid language look what it ran on. Still, it was wonderful to have 5 1/2 digits of floating point in those days before the scientific pocket calculator was invented. A great deal of homework was done with interactive mode console operation, using something like: LET R = 1.234E-5 PRINT 3.14159 * R * R (Thanks, Guido, for putting that handy capability into python. I've missed it over the years.) But I digress... Just know that it was a _really_ancient_ geek who said "onward." -- Vernon Cole (older), and proud of it. ... Whew! Okay, I'm done now. Pretend I never said any of that. Back to work. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mc at mclaveau.com Fri Jun 20 21:55:11 2008 From: mc at mclaveau.com (Michel Claveau) Date: Fri, 20 Jun 2008 21:55:11 +0200 Subject: [python-win32] P3K? In-Reply-To: References: <8243CB76094841ADA86A35A2C38E48E6@MCI1330> <000301c8d261$40f94dc0$c2ebe940$@com.au> <82E5EAE8478D4F759985A81A4B206218@MCI1330> Message-ID: <12827618FDA449879178D5438A183805@MCI1330> Hi! > For the information of you children "children" me? Thank you ! :o)))))))))))))))))))))))))))))))))) I had started, also, with FORTRAN. On a ICL, with perforated cards. Then: GAP, XTran, APL, Basic (on Alcyane, very before MS, Apple & Cie). Then: Texas-instrument, PET (Commodore), TRS-80 (Tandy), Sirius (& Victor), IBM, T1100 (Toshiba, the fisrt true laptop), etc. etc. But, it was at the previous millenium. The future is P3K. @-salutations -- Michel Claveau From mhammond at skippinet.com.au Sat Jun 21 04:06:28 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 21 Jun 2008 12:06:28 +1000 Subject: [python-win32] Embedded Python & win32api In-Reply-To: <20080620140132.97380@gmx.net> References: <20080620140132.97380@gmx.net> Message-ID: <009301c8d343$70022f00$50068d00$@com.au> > I'm getting crasy about embedding python-win32 in a c++ application. > > PyRun_SimpleString("import win32api") failes with the error message: > > ImportError: No module named win32api. Try setting the "verbose" flag (I can't recall how to spell that via the C API) and you should end up with info about the paths being searched - that will help to determine if it is a simple sys.path issue. If that seems correct, try starting with 'import pywintypes' - win32api depends on pywintypesxx.dll - but in general, failure to locate the missing DLL will result in an error dialog before the import error, and as you didn't mention that, I'm guessing you didn't see it. Any serious embedding will want a debug version of Python and pywin32 anyway, so the other alternative is to trace through the execution in a debug build - eg, set a break-point at an approproate place inside the import machinery. You will need to build python and pywin32 from source to do that, but its not that hard once you have the compiler installed. Good luck, Mark From howard at eegsoftware.com Sat Jun 21 21:17:24 2008 From: howard at eegsoftware.com (Howard Lightstone) Date: Sat, 21 Jun 2008 12:17:24 -0700 Subject: [python-win32] Embedded Python & win32api Message-ID: <485CF154.17381.C6A62D11@howard.eegsoftware.com> > > I'm getting crasy about embedding python-win32 in a c++ application. --snip-- I had the same issue. Here is the sequence I evolved from both 2.2 and 2.5 implementations (and working in production code although this code IS just at part of the stuff): // some tables I use char *plines[]= { "import sys\n", "", "@", "@\\dlls", "@\\libs", "@\\win32\\lib", "@\\win32", // my special stuff was here - notably my DebugWin to catch // stdout/stderr and pop them up in a tk window NULL }; // a utility function char * doubleup(char *input) { static char ans[MAX_PATH]; char *a = ans; while (*input) { if (*input == '\\') *a++ = '\\'; *a++ = *input++; if (a >= &ans[MAX_PATH-1]) break; } *a++=0; // ensure 0 termination return ans; } // the fragment from my main where I set things up // please note..... not every variable is defined in this fragment!! p=getenv("PATH"); if (!p) { MessageBox(GetDesktopWindow(), "No PATH found!!!","***** Failure",MB_OK); exit(4); } if (strlen(p) >= sizeof(lpath)) { MessageBox(GetDesktopWindow(),"PATH too long","*****Failure",MB_OK); exit(4); } strncpy(lpath,"PATH=",sizeof(lpath)); strncpy(ulpath,p,sizeof(ulpath)); _strupr(ulpath); i=0; if (!strstr(ulpath,"mylocalpath\\PYTHON25\\DLLS")) { i=1; } strncat(lpath,p,sizeof(lpath)); strncpy(local,StartupDir,sizeof(local)); _strupr(local); if (!strstr(ulpath,local)) { i |= 2; } // make sure I come first in paths- // otherwise stupid Windoze can't find some DLLs if the are included // by other DLLs since the search path is DIFFERENT than that used by //the first inclusion (usually) if (i) { ulpath[0]=0; if (i & 2) { // put me first strncat(ulpath,local,sizeof(ulpath); strncat(ulpath,";",sizeof(ulpath)); } if (i & 1) { // put my local Python dirs at the the beginning of the path!!!! strncat(ulpath,"mylocalpath\\Python25;mylocalpath\\Python25\\DLLs;", sizeof(ulpath)); } strncat(ulpath,lpath,sizeof(ulpath)); _putenv(lpath); } _putenv("PYTHONHOME=mylocalpath\\Python25"); _putenv("PYTHONPATH="); // remove from environment - it never worked correctly //using TCL??? _putenv("TCL_LIBRARY=mylocalpath\\python25\\tcl\\tcl8.4"); // moving on // put my startup path here too so I can 'find' modules to import strncpy(local,"sys.path.insert(0, '"); strcat(local,doubleup(StartupDir)); strcat(local,"')\n"); plines[1]=_strdup(local); // alt this and now we are finally ready to do some "pythoning" /* Pass argv[0] to the Python interpreter */ Py_SetProgramName(filename); // this is the "startup" filename with a path on it /* Initialize the Python interpreter. Required. */ Py_Initialize(); // initialize thread support PyEval_InitThreads(); // different logic goes in here if if using Python before 2.5 PySys_SetArgv(1, argvx); // some array is REQUIRED else error on argv !!!!! // this pre-imports some modules for me for (i=0;plines[i];++i) { char *pl; pl=plines[i]; if (pl[0] == '@') { strcpy(local,"sys.path.append('"); strcat(local,doubleup("mylocalpath\\Python25)); strcat(local,doubleup(&pl[1])); strcat(local,"')\n"); pl=local; } // execute some python code emsg[0]=0; if (PyRun_SimpleString(pl) == -1) { PyErr_Fetch (&ptype, &pvalue, &ptrace); sprintf(local,"err on %s \n\n%s",plines[i],emsg); MessageBox(NULL,local,"Error",MB_OK ); } } // this point, the interpreter is working and has had some basic modules imported // I have callbacks from python into my C++ code so.... PyImport_AddModule("pyaccess"); Py_InitModule("pyaccess", pyaccess_methods); // start me up ans=PyRun_SimpleString("import mymainpythonmodule\n"); // note that all my Python code actually runs in this import (mymainpythonmodule) // but something else could run/rerun at this point From bgailer at gmail.com Sun Jun 22 04:40:28 2008 From: bgailer at gmail.com (bob gailer) Date: Sat, 21 Jun 2008 22:40:28 -0400 Subject: [python-win32] P3K? In-Reply-To: <12827618FDA449879178D5438A183805@MCI1330> References: <8243CB76094841ADA86A35A2C38E48E6@MCI1330> <000301c8d261$40f94dc0$c2ebe940$@com.au> <82E5EAE8478D4F759985A81A4B206218@MCI1330> <12827618FDA449879178D5438A183805@MCI1330> Message-ID: <485DBB9C.1080101@gmail.com> IBM 650 anyone? Punched card i/o. 2000 word drum memory ( each word = 10 decimal digits). First language: machine language. Then assembler and a precursor of Basic called Classmate. PL/I Then the first breath of fresh air: APL. A lot like Python in that it made programming a LOT easier. On and on ... Now Python. Still longing for a way to integrate some aspects of APL into Python. -- Bob Gailer 919-636-4239 Chapel Hill, NC From rdahlstrom at directedge.com Mon Jun 23 12:54:36 2008 From: rdahlstrom at directedge.com (Dahlstrom, Roger) Date: Mon, 23 Jun 2008 06:54:36 -0400 Subject: [python-win32] P3K? References: <8243CB76094841ADA86A35A2C38E48E6@MCI1330> <000301c8d261$40f94dc0$c2ebe940$@com.au> <82E5EAE8478D4F759985A81A4B206218@MCI1330> <12827618FDA449879178D5438A183805@MCI1330> <485DBB9C.1080101@gmail.com> Message-ID: Well *I* used to line up rocks in to ones and zeros. Then I had a toucan that would interpret them, and chisel the gui on to a stone tablet. I still remember how upset everyone was when we introduced papyrus. From gerdusvanzyl at gmail.com Mon Jun 23 13:29:32 2008 From: gerdusvanzyl at gmail.com (Gerdus van Zyl) Date: Mon, 23 Jun 2008 13:29:32 +0200 Subject: [python-win32] P3K? In-Reply-To: References: <8243CB76094841ADA86A35A2C38E48E6@MCI1330> <000301c8d261$40f94dc0$c2ebe940$@com.au> <82E5EAE8478D4F759985A81A4B206218@MCI1330> <12827618FDA449879178D5438A183805@MCI1330> <485DBB9C.1080101@gmail.com> Message-ID: <91882ea90806230429p76feb0afv8378d949db5d8a05@mail.gmail.com> And of course REAL programmers use butterflies. http://xkcd.com/378/ On Mon, Jun 23, 2008 at 12:54 PM, Dahlstrom, Roger wrote: > Well *I* used to line up rocks in to ones and zeros. Then I had a toucan that would interpret them, and chisel the gui on to a stone tablet. I still remember > how upset everyone was when we introduced papyrus. > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From Mark.English at rbccm.com Mon Jun 23 13:51:54 2008 From: Mark.English at rbccm.com (English, Mark) Date: Mon, 23 Jun 2008 12:51:54 +0100 Subject: [python-win32] P3K? In-Reply-To: References: <8243CB76094841ADA86A35A2C38E48E6@MCI1330> <000301c8d261$40f94dc0$c2ebe940$@com.au> <82E5EAE8478D4F759985A81A4B206218@MCI1330> <12827618FDA449879178D5438A183805@MCI1330><485DBB9C.1080101@gmail.com> Message-ID: <75EF75D50F2523408605799EE2DD030E1DA085@SXLP-002.fg.rbc.com> > -----Original Message----- ] On Behalf Of Dahlstrom, Roger > Sent: 23 June 2008 11:55 > Cc: python-win32 at python.org > Subject: Re: [python-win32] P3K? > > Well *I* used to line up rocks in to ones and zeros. Then I > had a toucan that would interpret them, and chisel the gui on > to a stone tablet. I still remember how upset everyone was > when we introduced papyrus. *I* worked on the first OS for the amoeba. [little known fact: the original had teeth] _______________________________________________________________________ This email is intended only for the use of the individual(s) to whom it is addressed and may be privileged and confidential. Unauthorised use or disclosure is prohibited. If you receive this e-mail in error, please advise immediately and delete the original message without copying, using, or telling anyone about its contents. This message may have been altered without your or our knowledge and the sender does not accept any liability for any errors or omissions in the message. This message does not create or change any contract. Royal Bank of Canada and its subsidiaries accept no responsibility for damage caused by any viruses contained in this email or its attachments. Emails may be monitored. RBC Capital Markets is a business name used by branches and subsidiaries of Royal Bank of Canada, including Royal Bank of Canada, London branch and Royal Bank of Canada Europe Limited. In accordance with English law requirements, details regarding Royal Bank of Canada Europe Limited are set out below: ROYAL BANK OF CANADA EUROPE LIMITED Registered in England and Wales 995939 Registered Address: 71 Queen Victoria Street, London, EC4V 4DE. Authorised and regulated by the Financial Service Authority. Member of the London Stock Exchange From grickert at coldstorage.com Mon Jun 23 14:38:06 2008 From: grickert at coldstorage.com (Gerrat Rickert) Date: Mon, 23 Jun 2008 08:38:06 -0400 Subject: [python-win32] P3K? In-Reply-To: <485DBB9C.1080101@gmail.com> References: <8243CB76094841ADA86A35A2C38E48E6@MCI1330> <000301c8d261$40f94dc0$c2ebe940$@com.au> <82E5EAE8478D4F759985A81A4B206218@MCI1330> <12827618FDA449879178D5438A183805@MCI1330> <485DBB9C.1080101@gmail.com> Message-ID: +1 for APL integration! ;o) Numpy is nice, but can't touch APL... ...of course, it wasn't a challenge to write an obfuscated one-liner in APL - it was standard practice! Gerrat Rickert -----Original Message----- From: bob gailer [mailto:bgailer at gmail.com] Sent: Saturday, June 21, 2008 10:40 PM Cc: python-win32 at python.org Subject: Re: [python-win32] P3K? IBM 650 anyone? Punched card i/o. 2000 word drum memory ( each word = 10 decimal digits). First language: machine language. Then assembler and a precursor of Basic called Classmate. PL/I Then the first breath of fresh air: APL. A lot like Python in that it made programming a LOT easier. On and on ... Now Python. Still longing for a way to integrate some aspects of APL into Python. -- Bob Gailer 919-636-4239 Chapel Hill, NC From mdriscoll at co.marshall.ia.us Mon Jun 23 16:26:04 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Mon, 23 Jun 2008 09:26:04 -0500 Subject: [python-win32] Querying the VNC Service fails sometimes Message-ID: <485FB27C.4050405@co.marshall.ia.us> Hi, In one of my login scripts for work, I run a query to see if the VNC service is running using the win32serviceutil module. The code for that I am using looks something like this: import win32serviceutil serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1] This works in 99.99% of cases. However, I have on user that keeps getting the following traceback: Traceback (most recent call last): File "\\ourServer\pathName\PostLogon.py", line 207, in ? serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1] File "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", line 479, in QueryServiceStatus hs = SmartOpenService(hscm, serviceName, win32service.SERVICE_QUERY_STATUS) File "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", line 81, in SmartOpenService name = _GetServiceShortName(name) File "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", line 62, in _GetServiceShortName skey = win32api.RegOpenKey(hkey, svc, 0, access) error: (2, 'RegOpenKeyEx', 'The system cannot find the file specified.') I used regmon to try and figure out what part of the Registry my code looks at and it appears to be looking for the "DisplayName" value in HKLM\SYSTEM\CurrentControlSet\Services\winvnc I cannot see a difference in this user's registry versus my own, which does not have this issue. However, I can duplicate the error by connecting to the user's PC's registry using the _winreg module and querying the "DisplayName" value, like this: QueryValue(key, 'DisplayName') Which give me this traceback: Traceback (most recent call last): File "", line 1, in QueryValue(key, 'DisplayName') WindowsError: [Error 2] The system cannot find the file specified But if I use use _winreg's EnumValue, I get this: >>> EnumValue(key, 4) ('DisplayName', u'VNC Server', 1) What the!? Does anyone have any suggestions? Maybe a better way to get the information? I only need to know if the service is running or not, and if not, to start it. Thanks! ------------------- Mike Driscoll Blog: http://blog.pythonlibrary.org Python Extension Building Network: http://www.pythonlibrary.org From mail at timgolden.me.uk Mon Jun 23 16:36:15 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 23 Jun 2008 15:36:15 +0100 Subject: [python-win32] Querying the VNC Service fails sometimes In-Reply-To: <485FB27C.4050405@co.marshall.ia.us> References: <485FB27C.4050405@co.marshall.ia.us> Message-ID: <485FB4DF.1060405@timgolden.me.uk> Mike Driscoll wrote: [... snip problems checking service status ...] Well I've no idea if this suggestion will actually work round whatever the issue is but... ... you can use WMI to query service info. (You knew I was going to say that, didn't you?) Example you can modify: http://tgolden.sc.sabren.com/python/wmi_cookbook.html#automatic_services TJG From mdriscoll at co.marshall.ia.us Mon Jun 23 17:06:45 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Mon, 23 Jun 2008 10:06:45 -0500 Subject: [python-win32] Querying the VNC Service fails sometimes In-Reply-To: <485FB27C.4050405@co.marshall.ia.us> References: <485FB27C.4050405@co.marshall.ia.us> Message-ID: <485FBC05.1000309@co.marshall.ia.us> Mike Driscoll wrote: > Hi, > > In one of my login scripts for work, I run a query to see if the VNC > service is running using the win32serviceutil module. The code for > that I am using looks something like this: > > > import win32serviceutil > serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1] > > > This works in 99.99% of cases. However, I have on user that keeps > getting the following traceback: > > Traceback (most recent call last): > File "\\ourServer\pathName\PostLogon.py", line 207, in ? > serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1] > File > "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", > line 479, in QueryServiceStatus > hs = SmartOpenService(hscm, serviceName, > win32service.SERVICE_QUERY_STATUS) > File > "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", > line 81, in SmartOpenService > name = _GetServiceShortName(name) > File > "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", > line 62, in _GetServiceShortName > skey = win32api.RegOpenKey(hkey, svc, 0, access) > error: (2, 'RegOpenKeyEx', 'The system cannot find the file specified.') > > > I used regmon to try and figure out what part of the Registry my code > looks at and it appears to be looking for the "DisplayName" value in > HKLM\SYSTEM\CurrentControlSet\Services\winvnc > > I cannot see a difference in this user's registry versus my own, which > does not have this issue. However, I can duplicate the error by > connecting to the user's PC's registry using the _winreg module and > querying the "DisplayName" value, like this: > > QueryValue(key, 'DisplayName') > > Which give me this traceback: > > Traceback (most recent call last): > File "", line 1, in > QueryValue(key, 'DisplayName') > WindowsError: [Error 2] The system cannot find the file specified > > But if I use use _winreg's EnumValue, I get this: > >>>> EnumValue(key, 4) > ('DisplayName', u'VNC Server', 1) > > What the!? Does anyone have any suggestions? Maybe a better way to get > the information? I only need to know if the service is running or not, > and if not, to start it. > > Thanks! > > I forgot to mention that we use Windows XP, Python 2.4 and PyWin32 version 210. Mike From rwupole at msn.com Mon Jun 23 21:25:58 2008 From: rwupole at msn.com (Roger Upole) Date: Mon, 23 Jun 2008 15:25:58 -0400 Subject: [python-win32] Querying the VNC Service fails sometimes Message-ID: Mike Driscoll wrote: > Mike Driscoll wrote: >> Hi, >> >> In one of my login scripts for work, I run a query to see if the VNC >> service is running using the win32serviceutil module. The code for >> that I am using looks something like this: >> >> >> import win32serviceutil >> serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1] >> >> >> This works in 99.99% of cases. However, I have on user that keeps >> getting the following traceback: >> >> Traceback (most recent call last): >> File "\\ourServer\pathName\PostLogon.py", line 207, in ? >> serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1] >> File >> "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", >> line 479, in QueryServiceStatus >> hs = SmartOpenService(hscm, serviceName, >> win32service.SERVICE_QUERY_STATUS) >> File >> "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", >> line 81, in SmartOpenService >> name = _GetServiceShortName(name) >> File >> "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", >> line 62, in _GetServiceShortName >> skey = win32api.RegOpenKey(hkey, svc, 0, access) >> error: (2, 'RegOpenKeyEx', 'The system cannot find the file specified.') >> >> >> I used regmon to try and figure out what part of the Registry my code >> looks at and it appears to be looking for the "DisplayName" value in >> HKLM\SYSTEM\CurrentControlSet\Services\winvnc >> >> I cannot see a difference in this user's registry versus my own, which >> does not have this issue. However, I can duplicate the error by >> connecting to the user's PC's registry using the _winreg module and >> querying the "DisplayName" value, like this: >> >> QueryValue(key, 'DisplayName') >> >> Which give me this traceback: >> >> Traceback (most recent call last): >> File "", line 1, in >> QueryValue(key, 'DisplayName') >> WindowsError: [Error 2] The system cannot find the file specified >> >> But if I use use _winreg's EnumValue, I get this: >> >>>>> EnumValue(key, 4) >> ('DisplayName', u'VNC Server', 1) >> >> What the!? Does anyone have any suggestions? Maybe a better way to get >> the information? I only need to know if the service is running or not, >> and if not, to start it. >> >> Thanks! >> >> > > I forgot to mention that we use Windows XP, Python 2.4 and PyWin32 > version 210. > > Mike You might want to try build 211. It uses the API function GetServiceKeyName instead of manually enumerating the registry. However, it sounds like you could have a corrupt registry key. Try reinstalling the service and see if that helps. Roger From kevin.horn at gmail.com Mon Jun 23 21:51:59 2008 From: kevin.horn at gmail.com (Kevin Horn) Date: Mon, 23 Jun 2008 14:51:59 -0500 Subject: [python-win32] Querying the VNC Service fails sometimes In-Reply-To: References: Message-ID: <562bcc10806231251g5acc14c6jf1aa01bd4da1247c@mail.gmail.com> Also check the permissions on the problem users registry. I would expect that to cause a different error, but it might be worth checking. Kevin Horn On Mon, Jun 23, 2008 at 2:25 PM, Roger Upole wrote: > > Mike Driscoll wrote: > >> Mike Driscoll wrote: >> >>> Hi, >>> >>> In one of my login scripts for work, I run a query to see if the VNC >>> service is running using the win32serviceutil module. The code for >>> that I am using looks something like this: >>> >>> >>> import win32serviceutil >>> serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1] >>> >>> >>> This works in 99.99% of cases. However, I have on user that keeps >>> getting the following traceback: >>> >>> Traceback (most recent call last): >>> File "\\ourServer\pathName\PostLogon.py", line 207, in ? >>> serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1] >>> File >>> >>> "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", >>> line 479, in QueryServiceStatus >>> hs = SmartOpenService(hscm, serviceName, >>> win32service.SERVICE_QUERY_STATUS) >>> File >>> >>> "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", >>> line 81, in SmartOpenService >>> name = _GetServiceShortName(name) >>> File >>> >>> "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", >>> line 62, in _GetServiceShortName >>> skey = win32api.RegOpenKey(hkey, svc, 0, access) >>> error: (2, 'RegOpenKeyEx', 'The system cannot find the file specified.') >>> >>> >>> I used regmon to try and figure out what part of the Registry my code >>> looks at and it appears to be looking for the "DisplayName" value in >>> HKLM\SYSTEM\CurrentControlSet\Services\winvnc >>> >>> I cannot see a difference in this user's registry versus my own, which >>> does not have this issue. However, I can duplicate the error by >>> connecting to the user's PC's registry using the _winreg module and >>> querying the "DisplayName" value, like this: >>> >>> QueryValue(key, 'DisplayName') >>> >>> Which give me this traceback: >>> >>> Traceback (most recent call last): >>> File "", line 1, in >>> QueryValue(key, 'DisplayName') >>> WindowsError: [Error 2] The system cannot find the file specified >>> >>> But if I use use _winreg's EnumValue, I get this: >>> >>> EnumValue(key, 4) >>>>>> >>>>> ('DisplayName', u'VNC Server', 1) >>> >>> What the!? Does anyone have any suggestions? Maybe a better way to get >>> the information? I only need to know if the service is running or not, >>> and if not, to start it. >>> >>> Thanks! >>> >>> >>> >> I forgot to mention that we use Windows XP, Python 2.4 and PyWin32 >> version 210. >> >> Mike >> > > You might want to try build 211. It uses the API function > GetServiceKeyName instead of manually enumerating the > registry. > > However, it sounds like you could have a corrupt registry key. > Try reinstalling the service and see if that helps. > > Roger > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdriscoll at co.marshall.ia.us Mon Jun 23 22:05:30 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Mon, 23 Jun 2008 15:05:30 -0500 Subject: [python-win32] Querying the VNC Service fails sometimes In-Reply-To: <485FB4DF.1060405@timgolden.me.uk> References: <485FB27C.4050405@co.marshall.ia.us> <485FB4DF.1060405@timgolden.me.uk> Message-ID: <4860020A.9060503@co.marshall.ia.us> Tim, >
Mike > Driscoll wrote: > [... snip problems checking service status ...] > > Well I've no idea if this suggestion will actually work > round whatever the issue is but... > > ... you can use WMI to query service info. (You knew I > was going to say that, didn't you?) I knew you'd have some idea...you almost always do...I may try build 211 first since WMI always tends to slow my login scripts down significantly. Other than that, WMI is a very cool tool. > > Example you can modify: > > http://tgolden.sc.sabren.com/python/wmi_cookbook.html#automatic_services > > TJG > >
Thanks. I'll read up on it and see if I can get it to work on my development machine. That way I'll have it for backup if the 211 idea falls through. Mike From mdriscoll at co.marshall.ia.us Mon Jun 23 22:07:54 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Mon, 23 Jun 2008 15:07:54 -0500 Subject: [python-win32] Querying the VNC Service fails sometimes In-Reply-To: References: Message-ID: <4860029A.403@co.marshall.ia.us> Roger Upole wrote: >
> Mike Driscoll wrote: >> Mike Driscoll wrote: >>> Hi, >>> >>> In one of my login scripts for work, I run a query to see if the VNC >>> service is running using the win32serviceutil module. The code for >>> that I am using looks something like this: >>> >>> >>> import win32serviceutil >>> serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1] >>> >>> >>> This works in 99.99% of cases. However, I have on user that keeps >>> getting the following traceback: >>> >>> Traceback (most recent call last): >>> File "\\ourServer\pathName\PostLogon.py", line 207, in ? >>> serviceState = win32serviceutil.QueryServiceStatus('VNC Server')[1] >>> File >>> "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", >>> >>> line 479, in QueryServiceStatus >>> hs = SmartOpenService(hscm, serviceName, >>> win32service.SERVICE_QUERY_STATUS) >>> File >>> "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", >>> >>> line 81, in SmartOpenService >>> name = _GetServiceShortName(name) >>> File >>> "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", >>> >>> line 62, in _GetServiceShortName >>> skey = win32api.RegOpenKey(hkey, svc, 0, access) >>> error: (2, 'RegOpenKeyEx', 'The system cannot find the file >>> specified.') >>> >>> >>> I used regmon to try and figure out what part of the Registry my code >>> looks at and it appears to be looking for the "DisplayName" value in >>> HKLM\SYSTEM\CurrentControlSet\Services\winvnc >>> >>> I cannot see a difference in this user's registry versus my own, which >>> does not have this issue. However, I can duplicate the error by >>> connecting to the user's PC's registry using the _winreg module and >>> querying the "DisplayName" value, like this: >>> >>> QueryValue(key, 'DisplayName') >>> >>> Which give me this traceback: >>> >>> Traceback (most recent call last): >>> File "", line 1, in >>> QueryValue(key, 'DisplayName') >>> WindowsError: [Error 2] The system cannot find the file specified >>> >>> But if I use use _winreg's EnumValue, I get this: >>> >>>>>> EnumValue(key, 4) >>> ('DisplayName', u'VNC Server', 1) >>> >>> What the!? Does anyone have any suggestions? Maybe a better way to get >>> the information? I only need to know if the service is running or not, >>> and if not, to start it. >>> >>> Thanks! >>> >>> >> >> I forgot to mention that we use Windows XP, Python 2.4 and PyWin32 >> version 210. >> >> Mike > > You might want to try build 211. It uses the API function > GetServiceKeyName instead of manually enumerating the > registry. That's good to know. > > However, it sounds like you could have a corrupt registry key. > Try reinstalling the service and see if that helps. > > Roger > > >
I keep forgetting that registry keys can get corrupt. I'll try that if the 211 idea doesn't work and then I'll give the WMI solution of Golden's a go. Mike From mc at mclaveau.com Tue Jun 24 07:04:02 2008 From: mc at mclaveau.com (Michel Claveau) Date: Tue, 24 Jun 2008 07:04:02 +0200 Subject: [python-win32] Querying the VNC Service fails sometimes In-Reply-To: <485FB27C.4050405@co.marshall.ia.us> References: <485FB27C.4050405@co.marshall.ia.us> Message-ID: <7AE17005BA4B4FEEBE1E7AF7A93481AF@MCI1330> Hi! Can you try to wrap command-line SC? Example of command-line : sc query winvnc Example of wrap: def clwrap(commande, cdir='.'): import os if cdir!='.': os.chdir(cdir) a = os.popen(commande) return a.read() print clwrap('sc query winsvc') @-salutations Michel Claveau From mail at timgolden.me.uk Tue Jun 24 07:06:41 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 24 Jun 2008 06:06:41 +0100 Subject: [python-win32] Querying the VNC Service fails sometimes In-Reply-To: <4860020A.9060503@co.marshall.ia.us> References: <485FB27C.4050405@co.marshall.ia.us> <485FB4DF.1060405@timgolden.me.uk> <4860020A.9060503@co.marshall.ia.us> Message-ID: <486080E1.8080903@timgolden.me.uk> Mike Driscoll wrote: > Tim, > >>
Mike >> Driscoll wrote: >> [... snip problems checking service status ...] >> >> Well I've no idea if this suggestion will actually work >> round whatever the issue is but... >> >> ... you can use WMI to query service info. (You knew I >> was going to say that, didn't you?) > > I knew you'd have some idea...you almost always do... :) > I may try build 211 first since WMI always tends to slow > my login scripts down significantly. Good point. Certainly while I do often recommend my wmi module for things, it is a (Python) layer over a (Python/C) layer over an API layer. And none of that's going to make it any faster. TJG From mdriscoll at co.marshall.ia.us Tue Jun 24 16:19:03 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Tue, 24 Jun 2008 09:19:03 -0500 Subject: [python-win32] Querying the VNC Service fails sometimes In-Reply-To: <562bcc10806231251g5acc14c6jf1aa01bd4da1247c@mail.gmail.com> References: <562bcc10806231251g5acc14c6jf1aa01bd4da1247c@mail.gmail.com> Message-ID: <48610257.6040506@co.marshall.ia.us> Kevin, > Also check the permissions on the problem users registry. I would > expect that to cause a different error, but it might be worth checking. Most users are local admins. And it's just been happening for the last couple of weeks, so it's likely what Roger said: a corrupt registry entry. I tried upgrading to 211 last night and am waiting for that user to login again. For some reason, after upgrading to 211, I am getting an import error on my wx module. Are these tied together in some weird way? > > Kevin Horn > > On Mon, Jun 23, 2008 at 2:25 PM, Roger Upole > wrote: > > > Mike Driscoll wrote: > > Mike Driscoll wrote: > > Hi, > > In one of my login scripts for work, I run a query to see > if the VNC > service is running using the win32serviceutil module. The > code for > that I am using looks something like this: > > > import win32serviceutil > serviceState = win32serviceutil.QueryServiceStatus('VNC > Server')[1] > > > This works in 99.99% of cases. However, I have on user > that keeps > getting the following traceback: > > Traceback (most recent call last): > File "\\ourServer\pathName\PostLogon.py", line 207, in ? > serviceState = win32serviceutil.QueryServiceStatus('VNC > Server')[1] > File > "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", > line 479, in QueryServiceStatus > hs = SmartOpenService(hscm, serviceName, > win32service.SERVICE_QUERY_STATUS) > File > "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", > line 81, in SmartOpenService > name = _GetServiceShortName(name) > File > "\\ourServer\pathName\Python24\lib\site-packages\win32\lib\win32serviceutil.py", > line 62, in _GetServiceShortName > skey = win32api.RegOpenKey(hkey, svc, 0, access) > error: (2, 'RegOpenKeyEx', 'The system cannot find the > file specified.') > > > > > > > I forgot to mention that we use Windows XP, Python 2.4 and PyWin32 > version 210. > > Mike > > > You might want to try build 211. It uses the API function > GetServiceKeyName instead of manually enumerating the > registry. > > However, it sounds like you could have a corrupt registry key. > Try reinstalling the service and see if that helps. > > Roger > Mike From tibor.arpas at infinit.sk Tue Jun 24 17:46:44 2008 From: tibor.arpas at infinit.sk (Tibor Arpas) Date: Tue, 24 Jun 2008 17:46:44 +0200 Subject: [python-win32] import cx_Oracle in ASP Message-ID: <19a7c8c20806240846m73230d12i268fdd2f8fe198ce@mail.gmail.com> Hi, I'm trying to connect to database from ASP. I reduced my source to the following snippet: <%@ LANGUAGE = Python%> <% import sys for s in sys.path: Response.Write(s) Response.Write("
") import cx_Oracle %> After invoking the asp page I get the following result: C:\ActivePython25\lib\site-packages\setuptools-0.6c8-py2.5.egg C:\ActivePython25\lib\site-packages\cx_oracle-4.3.3-py2.5-win32.egg C:\ActivePython25\lib\site-packages\owslib-0.3-py2.5.egg C:\ActivePython25\lib\site-packages\tilecache-2.02-py2.5.egg C:\ActivePython25\lib\site-packages\paste-1.6-py2.5.egg C:\ActivePython25\lib\site-packages\pysqlite-2.4.1-py2.5-win32.egg C:\ActivePython25\lib\site-packages\pil-1.1.6-py2.5-win32.egg C:\WINDOWS\system32\python25.zip C:\ActivePython25\Lib C:\ActivePython25\DLLs C:\ActivePython25\Lib\lib-tk c:\windows\system32\inetsrv C:\ActivePython25 C:\ActivePython25\lib\site-packages C:\ActivePython25\lib\site-packages\win32 C:\ActivePython25\lib\site-packages\win32\lib C:\ActivePython25\lib\site-packages\Pythonwin Python ActiveX Scripting Engine error '80020009' Traceback (most recent call last): File "
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from win32com.client import DispatchEx >>> ie=DispatchEx('InternetExplorer.Application') >>> ie.Visible=True >>> ie.Visible=False >>> ie.Navigate('c:/temp/javascripttest/onkeyup.html') >>> ie.Visible=True >>> e=ie.Document.CreateEventObject() >>> e.keyCode=65 >>> ie.Document.all.inp.FireEvent("onkeyup",e) True >>> ie.Document.lastKeyCode 0 On the html document displayed on the browser I see "0" is appended. The event object that I created with new keyCode didn't get passed. Now with comtypes: >>> from comtypes.client import CreateObject >>> ie2=CreateObject("InternetExplorer.Application") >>> ie2.Visible=True >>> ie2.Navigate('c:/temp/javascripttest/onkeyup.html') 0 >>> e2=ie2.Document.CreateEventObject() >>> e2.keyCode=65 >>> ie2.Document.all.inp.FireEvent("onkeyup",e2) True >>> ie2.Document.lastKeyCode Traceback (most recent call last): File "", line 1, in File "C:\Python25\Lib\site-packages\comtypes\__init__.py", line 216, in __geta ttr__ raise AttributeError(name) AttributeError: lastKeyCode Accessing lastKeyCode from ie2.Document wasn't possible but the event obejct is passed successfully -- I see 65 appended to the document. In summary, there are one big problem and one minor problem. The first is about pywin32's inability to pass FireEvent's second argument. The second is about comtypes inability to access Document's attributes. From juneaftn at gmail.com Wed Jun 25 07:34:32 2008 From: juneaftn at gmail.com (June Kim) Date: Wed, 25 Jun 2008 14:34:32 +0900 Subject: [python-win32] FireEvent : comtypes work but win32com fails, why? In-Reply-To: <6f80c1520806242158o68df55d4n9cc2f21569bd2dc0@mail.gmail.com> References: <6f80c1520806242158o68df55d4n9cc2f21569bd2dc0@mail.gmail.com> Message-ID: <6f80c1520806242234w3b591ce1h7dd70772c8b8f1cd@mail.gmail.com> 2008/6/25 June Kim : > IE's FireEvent works with a single argument, for example, > FireEvent("onKeyUp"). However, it doesn't work with two arguments : > FireEvent("onKeyUp",event). > > But It works without a problem with comtypes. > > See the following example to reproduce and compare: > > > file: c:/temp/javascripttest/onkeyup.html > > > > onkeyup > > > > >
> > > > > Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on > win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> from win32com.client import DispatchEx >>>> ie=DispatchEx('InternetExplorer.Application') >>>> ie.Visible=True >>>> ie.Visible=False >>>> ie.Navigate('c:/temp/javascripttest/onkeyup.html') >>>> ie.Visible=True >>>> e=ie.Document.CreateEventObject() >>>> e.keyCode=65 >>>> ie.Document.all.inp.FireEvent("onkeyup",e) > True >>>> ie.Document.lastKeyCode > 0 > > On the html document displayed on the browser I see "0" is appended. > The event object that I created with new keyCode didn't get passed. > > Now with comtypes: > >>>> from comtypes.client import CreateObject >>>> ie2=CreateObject("InternetExplorer.Application") >>>> ie2.Visible=True >>>> ie2.Navigate('c:/temp/javascripttest/onkeyup.html') > 0 >>>> e2=ie2.Document.CreateEventObject() >>>> e2.keyCode=65 >>>> ie2.Document.all.inp.FireEvent("onkeyup",e2) > True >>>> ie2.Document.lastKeyCode > Traceback (most recent call last): > File "", line 1, in > File "C:\Python25\Lib\site-packages\comtypes\__init__.py", line 216, in __geta > ttr__ > raise AttributeError(name) > AttributeError: lastKeyCode > > Accessing lastKeyCode from ie2.Document wasn't possible but the event > obejct is passed successfully -- I see 65 appended to the document. > > > In summary, there are one big problem and one minor problem. The first > is about pywin32's inability to pass FireEvent's second argument. The > second is about comtypes inability to access Document's attributes. > The minor problem is solvable with: comtypes.client.dynamic.Dispatch(ie2.Document).lastKeyCode even though I am not sure if this is the right way. From mhammond at skippinet.com.au Wed Jun 25 08:51:35 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 25 Jun 2008 16:51:35 +1000 Subject: [python-win32] FireEvent : comtypes work but win32com fails, why? In-Reply-To: <6f80c1520806242234w3b591ce1h7dd70772c8b8f1cd@mail.gmail.com> References: <6f80c1520806242158o68df55d4n9cc2f21569bd2dc0@mail.gmail.com> <6f80c1520806242234w3b591ce1h7dd70772c8b8f1cd@mail.gmail.com> Message-ID: <041801c8d68f$ec480770$c4d81650$@com.au> > > In summary, there are one big problem and one minor problem. The > > first > > is about pywin32's inability to pass FireEvent's second argument. I can't explain that :( I've stepped through the code, and it seems we are passing a VT_VARIANT containing a VT_BYREF|VT_DISPATCH. I'm afraid I'm not familiar enough with comtypes to know how it is passing that param. Cheers, Mark From mdriscoll at co.marshall.ia.us Wed Jun 25 15:23:00 2008 From: mdriscoll at co.marshall.ia.us (Mike Driscoll) Date: Wed, 25 Jun 2008 08:23:00 -0500 Subject: [python-win32] Querying the VNC Service fails sometimes In-Reply-To: <03cc01c8d66a$72086790$561936b0$@com.au> References: <562bcc10806231251g5acc14c6jf1aa01bd4da1247c@mail.gmail.com> <48610257.6040506@co.marshall.ia.us> <03cc01c8d66a$72086790$561936b0$@com.au> Message-ID: <486246B4.5070406@co.marshall.ia.us> Mark, >> fter upgrading to 211, I am getting >> an >> import error on my wx module. Are these tied together in some weird >> way? >> > > Not that I can think of, and build 211 didn't add any funky new import > tricks or anything. However, build 211 is packing the MFC DLL now, so > *that* could be related - try removing the MFC that is installed in the > site-packages\pythonwin directory. What does the import error say? > > Cheers, > > Mark > > I still don't know what caused the error exactly, but I got it fixed by deleting the wx install and reinstalling it. I did the same with ctypes as it was giving me version mis-match issues. I don't know why I was so absent-minded yesterday. But for completeness, here's the traceback: Traceback (most recent call last): File "\\path\to\my\scripts\Utilities\SoScripts.py", line 105, in ? import printer_dlg File "\\path\to\my\scripts\printer_dlg.py", line 12, in ? import wx ImportError: No module named wx Thanks for all the tips, guys. Mike From theller at ctypes.org Wed Jun 25 16:03:12 2008 From: theller at ctypes.org (Thomas Heller) Date: Wed, 25 Jun 2008 16:03:12 +0200 Subject: [python-win32] FireEvent : comtypes work but win32com fails, why? In-Reply-To: <041801c8d68f$ec480770$c4d81650$@com.au> References: <6f80c1520806242158o68df55d4n9cc2f21569bd2dc0@mail.gmail.com> <6f80c1520806242234w3b591ce1h7dd70772c8b8f1cd@mail.gmail.com> <041801c8d68f$ec480770$c4d81650$@com.au> Message-ID: Mark Hammond schrieb: >> > In summary, there are one big problem and one minor problem. The >> > first >> > is about pywin32's inability to pass FireEvent's second argument. > > I can't explain that :( I've stepped through the code, and it seems we are > passing a VT_VARIANT containing a VT_BYREF|VT_DISPATCH. I'm afraid I'm not > familiar enough with comtypes to know how it is passing that param. I think that comtypes passes a VT_DISPATCH type in the DISPPARAMS VARIANTARG field. Thomas From theller at ctypes.org Wed Jun 25 16:06:26 2008 From: theller at ctypes.org (Thomas Heller) Date: Wed, 25 Jun 2008 16:06:26 +0200 Subject: [python-win32] FireEvent : comtypes work but win32com fails, why? In-Reply-To: <6f80c1520806242158o68df55d4n9cc2f21569bd2dc0@mail.gmail.com> References: <6f80c1520806242158o68df55d4n9cc2f21569bd2dc0@mail.gmail.com> Message-ID: June Kim schrieb: > IE's FireEvent works with a single argument, for example, > FireEvent("onKeyUp"). However, it doesn't work with two arguments : > FireEvent("onKeyUp",event). > > But It works without a problem with comtypes. > > See the following example to reproduce and compare: > > > file: c:/temp/javascripttest/onkeyup.html > > > > onkeyup > > > > >
> > > [...] > > Now with comtypes: > >>>> from comtypes.client import CreateObject >>>> ie2=CreateObject("InternetExplorer.Application") >>>> ie2.Visible=True >>>> ie2.Navigate('c:/temp/javascripttest/onkeyup.html') > 0 >>>> e2=ie2.Document.CreateEventObject() >>>> e2.keyCode=65 >>>> ie2.Document.all.inp.FireEvent("onkeyup",e2) > True >>>> ie2.Document.lastKeyCode > Traceback (most recent call last): > File "", line 1, in > File "C:\Python25\Lib\site-packages\comtypes\__init__.py", line 216, in __geta > ttr__ > raise AttributeError(name) > AttributeError: lastKeyCode > > Accessing lastKeyCode from ie2.Document wasn't possible but the event > obejct is passed successfully -- I see 65 appended to the document. > I would guess that dynamically added attributes can only be accessed via the IDispatchEx interface. Does anybody know if it is possible to access these attributes with DispInvoke calls? comtypes does not (yet?) support IDispatchEx. Thomas From mhammond at skippinet.com.au Wed Jun 25 16:58:15 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 26 Jun 2008 00:58:15 +1000 Subject: [python-win32] FireEvent : comtypes work but win32com fails, why? In-Reply-To: References: <6f80c1520806242158o68df55d4n9cc2f21569bd2dc0@mail.gmail.com> <6f80c1520806242234w3b591ce1h7dd70772c8b8f1cd@mail.gmail.com> <041801c8d68f$ec480770$c4d81650$@com.au> Message-ID: <047101c8d6d3$e5bdbdc0$b1393940$@com.au> Thomas: > Mark Hammond schrieb: > >> > In summary, there are one big problem and one minor problem. The > >> > first > >> > is about pywin32's inability to pass FireEvent's second argument. > > > > I can't explain that :( I've stepped through the code, and it seems > > we are passing a VT_VARIANT containing a VT_BYREF|VT_DISPATCH. I'm > > afraid I'm not familiar enough with comtypes to know how it is > > passing that param. > > I think that comtypes passes a VT_DISPATCH type in the DISPPARAMS > VARIANTARG field. That is what I suspected - pywin32 is adding an extra level of indirection. When pywin32 sees VT_VARIANT, it takes it literally - it supplies a variant of type VT_VARIANT (ie, the variant itself holds a variant), and that "child" variant is what holds the real value. If I understand what you are saying, comtypes just supplies the variant with the real type directly in place (ie, a variant with a 'vartype' of VT_VARIANT isn't ever returned by comtypes). Is that correct? If so, I guess I should give that a whirl and hope nothing else in the test suite breaks ;) Thanks, Mark From theller at ctypes.org Wed Jun 25 17:30:36 2008 From: theller at ctypes.org (Thomas Heller) Date: Wed, 25 Jun 2008 17:30:36 +0200 Subject: [python-win32] FireEvent : comtypes work but win32com fails, why? In-Reply-To: <047101c8d6d3$e5bdbdc0$b1393940$@com.au> References: <6f80c1520806242158o68df55d4n9cc2f21569bd2dc0@mail.gmail.com> <6f80c1520806242234w3b591ce1h7dd70772c8b8f1cd@mail.gmail.com> <041801c8d68f$ec480770$c4d81650$@com.au> <047101c8d6d3$e5bdbdc0$b1393940$@com.au> Message-ID: Mark Hammond schrieb: > Thomas: >> Mark Hammond schrieb: >> >> > In summary, there are one big problem and one minor problem. The >> >> > first >> >> > is about pywin32's inability to pass FireEvent's second argument. >> > >> > I can't explain that :( I've stepped through the code, and it seems >> > we are passing a VT_VARIANT containing a VT_BYREF|VT_DISPATCH. I'm >> > afraid I'm not familiar enough with comtypes to know how it is >> > passing that param. >> >> I think that comtypes passes a VT_DISPATCH type in the DISPPARAMS >> VARIANTARG field. > > That is what I suspected - pywin32 is adding an extra level of indirection. > When pywin32 sees VT_VARIANT, it takes it literally - it supplies a variant > of type VT_VARIANT (ie, the variant itself holds a variant), and that > "child" variant is what holds the real value. I do not know where you see the VT_VARIANT. Here is the IDL defn: [id(0x80010452)] VARIANT_BOOL FireEvent( [in] BSTR bstrEventName, [in, optional] VARIANT* pvarEventObject); and the comtypes wrapper snippet: DISPMETHOD([dispid(-2147417006)], VARIANT_BOOL, 'FireEvent', ( ['in'], BSTR, 'bstrEventName' ), ( ['in', 'optional'], POINTER(VARIANT), 'pvarEventObject' )), > If I understand what you are > saying, comtypes just supplies the variant with the real type directly in > place (ie, a variant with a 'vartype' of VT_VARIANT isn't ever returned by > comtypes). Since the is a pure dispinterface, comtypes uses Invoke to call the method, without doing any parameter conversions - it directly packs the supplied parameters into the DISPPARAMS rgvarg array. The 'e2' parameter in the OP's code is a IHTMLEventObj COM pointer which is derived from IDispatch, so comtypes makes a VT_DISPATCH variant typecode. > Is that correct? If so, I guess I should give that a whirl and > hope nothing else in the test suite breaks ;) Thats what test suites are for... Thomas PS: Do you know the answer to the question that I posted in the other reply to this thread (short version: does pywin32 use IDispatchEx)? From mhammond at skippinet.com.au Thu Jun 26 01:33:16 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 26 Jun 2008 09:33:16 +1000 Subject: [python-win32] FireEvent : comtypes work but win32com fails, why? In-Reply-To: References: <6f80c1520806242158o68df55d4n9cc2f21569bd2dc0@mail.gmail.com> <6f80c1520806242234w3b591ce1h7dd70772c8b8f1cd@mail.gmail.com> <041801c8d68f$ec480770$c4d81650$@com.au> <047101c8d6d3$e5bdbdc0$b1393940$@com.au> Message-ID: <04d901c8d71b$d901c5c0$8b055140$@com.au> > I do not know where you see the VT_VARIANT. > > Here is the IDL defn: > > [id(0x80010452)] > VARIANT_BOOL FireEvent( > [in] BSTR bstrEventName, > [in, optional] VARIANT* pvarEventObject); > > and the comtypes wrapper snippet: > DISPMETHOD([dispid(-2147417006)], VARIANT_BOOL, 'FireEvent', > ( ['in'], BSTR, 'bstrEventName' ), > ( ['in', 'optional'], POINTER(VARIANT), > 'pvarEventObject' )), Yeah - when win32com gets the type info, it is told the variable is a "VT_BYREF|VT_VARIANT - eg: def FireEvent(self, bstrEventName=defaultNamedNotOptArg, pvarEventObject=defaultNamedOptArg): return self._oleobj_.InvokeTypes(-2147417006, LCID, 1, (11, 0), ((8, 1), (16396, 17)),bstrEventName , pvarEventObject) 16396, 17 == (VT_BYREF|VT_VARIANT, PARAMFLAG_FOPT|PARAMFLAG_FIN) so pythoncom's type converter sees this type tuple, and tries to create a variant with the exact type specified. It would seem I must treat VT_VARIANT as a special case (the returned vartype in that case can be anything and is driven by the type of the param) > > Is that correct? If so, I guess I should give that a whirl and > > hope nothing else in the test suite breaks ;) > > Thats what test suites are for... I'm more worried that the change will break something that some obscure program relies on (ie, I hope the test suite shows the change is backwards compatible) > PS: Do you know the answer to the question that I posted in the other > reply to this > thread (short version: does pywin32 use IDispatchEx)? It doesn't in win32com.client (ie, not when calling objects, as in this example). win32com.server does IDispatchEx though (mainly as IE itself is one of the only IDispatchEx users around. IDispatchEx was desgined for ActiveScripting to offer javascript style semantics to an IDispatch-ish interface. Cheers, Mark From ThorstenRiesberg at gmx.de Thu Jun 26 08:50:11 2008 From: ThorstenRiesberg at gmx.de (thorsten riesberg) Date: Thu, 26 Jun 2008 08:50:11 +0200 Subject: [python-win32] Embedded Python and multithreading Message-ID: <20080626065011.201580@gmx.net> Hi all, can anybody explain me why the following code is not running: // #include "stdafx.h" #include #include #include #include "Python.h" DWORD WINAPI Callback1( LPVOID lpvData){ PyObject *pName, *pModule, *pDict, *pFunc, *pValue; PyThreadState* tcur = PyThreadState_Get() ; PyThreadState_Swap(NULL); PyThreadState_Clear(tcur); PyThreadState_Delete(tcur); // release the GIL as PyEval_InitThreads // implicitly acquires the GIL PyEval_ReleaseLock(); PyGILState_STATE gstate; for(int i = 0; i < 20; i++){ gstate = PyGILState_Ensure(); pName = PyString_FromString("test1"); pModule = PyImport_Import(pName); pDict = PyModule_GetDict(pModule); pFunc = PyDict_GetItemString(pDict, "test"); if (PyCallable_Check(pFunc)) { pValue = PyObject_CallObject(pFunc, NULL); } else { PyErr_Print(); } // Clean up Py_DECREF(pModule); Py_DECREF(pName); PyGILState_Release(gstate); Sleep(1000); } return TRUE; }; DWORD WINAPI Callback2( LPVOID lpvData){ PyObject *pName, *pModule, *pDict, *pFunc, *pValue; PyThreadState* tcur = PyThreadState_Get() ; PyThreadState_Swap(NULL); PyThreadState_Clear(tcur); PyThreadState_Delete(tcur); // release the GIL as PyEval_InitThreads // implicitly acquires the GIL PyEval_ReleaseLock(); PyGILState_STATE gstate; for(int i = 0; i < 20; i++){ gstate = PyGILState_Ensure(); pName = PyString_FromString("test1"); pModule = PyImport_Import(pName); // pDict and pFunc are borrowed references pDict = PyModule_GetDict(pModule); pFunc = PyDict_GetItemString(pDict, "test"); if (PyCallable_Check(pFunc)) { pValue = PyObject_CallObject(pFunc, NULL); } else { PyErr_Print(); } // Clean up Py_DECREF(pModule); Py_DECREF(pName); PyGILState_Release(gstate); Sleep(1000); } return TRUE; }; int main(int argc, char *argv[]) { Py_Finalize(); Py_Initialize(); PyEval_InitThreads(); DWORD threadID; CreateThread(NULL,10000 ,Callback1,(LPVOID)NULL,0,&threadID); CreateThread(NULL,10000 ,Callback2,(LPVOID)NULL,0,&threadID); getchar(); Py_Finalize(); return 0; } If I start just one Thread: CreateThread(NULL,10000 ,Callback1,(LPVOID)NULL,0,&threadID); //CreateThread(NULL,10000 ,Callback2,(LPVOID)NULL,0,&threadID); every thing is fine. The second thread stops with: Fatal Python error: PyThreadState_Get: no current thread Thanks in advance Thorsten -- GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen! Jetzt dabei sein: http://www.shortview.de/?mc=sv_ext_mf at gmx From mhammond at skippinet.com.au Thu Jun 26 10:55:11 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 26 Jun 2008 18:55:11 +1000 Subject: [python-win32] Embedded Python and multithreading In-Reply-To: <20080626065011.201580@gmx.net> References: <20080626065011.201580@gmx.net> Message-ID: <055b01c8d76a$5aaf6b10$100e4130$@com.au> > PyThreadState* tcur = PyThreadState_Get() ; > > PyThreadState_Swap(NULL); > PyThreadState_Clear(tcur); > PyThreadState_Delete(tcur); > > // release the GIL as PyEval_InitThreads > // implicitly acquires the GIL > PyEval_ReleaseLock(); > > PyGILState_STATE gstate; It's not necessary to do both the PyThreadState stuff *and* the PyGILState stuff - just remove all the lines I quoted, except for the last, from both callbacks and things should improve. Cheers, Mark From juneaftn at gmail.com Thu Jun 26 11:36:14 2008 From: juneaftn at gmail.com (June Kim) Date: Thu, 26 Jun 2008 18:36:14 +0900 Subject: [python-win32] FireEvent : comtypes work but win32com fails, why? In-Reply-To: <04d901c8d71b$d901c5c0$8b055140$@com.au> References: <6f80c1520806242158o68df55d4n9cc2f21569bd2dc0@mail.gmail.com> <6f80c1520806242234w3b591ce1h7dd70772c8b8f1cd@mail.gmail.com> <041801c8d68f$ec480770$c4d81650$@com.au> <047101c8d6d3$e5bdbdc0$b1393940$@com.au> <04d901c8d71b$d901c5c0$8b055140$@com.au> Message-ID: <6f80c1520806260236j7ba289bo8e8484f1e77beaef@mail.gmail.com> What roundabouts would you recommend to make FireEvent work with pywin32 module? My clients are mostly installed with pywin32, and switching to comtypes is a risk now. 2008/6/26, Mark Hammond : > > I do not know where you see the VT_VARIANT. > > > > Here is the IDL defn: > > > > [id(0x80010452)] > > VARIANT_BOOL FireEvent( > > [in] BSTR bstrEventName, > > [in, optional] VARIANT* pvarEventObject); > > > > and the comtypes wrapper snippet: > > DISPMETHOD([dispid(-2147417006)], VARIANT_BOOL, 'FireEvent', > > ( ['in'], BSTR, 'bstrEventName' ), > > ( ['in', 'optional'], POINTER(VARIANT), > > 'pvarEventObject' )), > > Yeah - when win32com gets the type info, it is told the variable is a > "VT_BYREF|VT_VARIANT - eg: > > def FireEvent(self, bstrEventName=defaultNamedNotOptArg, > pvarEventObject=defaultNamedOptArg): > return self._oleobj_.InvokeTypes(-2147417006, LCID, 1, (11, > 0), ((8, 1), (16396, 17)),bstrEventName > , pvarEventObject) > > 16396, 17 == (VT_BYREF|VT_VARIANT, PARAMFLAG_FOPT|PARAMFLAG_FIN) > > so pythoncom's type converter sees this type tuple, and tries to create a > variant with the exact type specified. It would seem I must treat > VT_VARIANT as a special case (the returned vartype in that case can be > anything and is driven by the type of the param) > > > > Is that correct? If so, I guess I should give that a whirl and > > > hope nothing else in the test suite breaks ;) > > > > Thats what test suites are for... > > I'm more worried that the change will break something that some obscure > program relies on (ie, I hope the test suite shows the change is backwards > compatible) > > > PS: Do you know the answer to the question that I posted in the other > > reply to this > > thread (short version: does pywin32 use IDispatchEx)? > > It doesn't in win32com.client (ie, not when calling objects, as in this > example). win32com.server does IDispatchEx though (mainly as IE itself is > one of the only IDispatchEx users around. IDispatchEx was desgined for > ActiveScripting to offer javascript style semantics to an IDispatch-ish > interface. > > Cheers, > > Mark > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From chester_lab at fltg.net Thu Jun 26 14:01:21 2008 From: chester_lab at fltg.net (FT) Date: Thu, 26 Jun 2008 08:01:21 -0400 Subject: [python-win32] How Do You Make Your Speech or SAPI 5 Voices Portable? Message-ID: <001d01c8d785$25b4b080$0301a8c0@brucetower> Hi! I am a visually impaired programmer and just joined the Win32 list to possibly learn how to make my own screen reader, thus have to learn the in's and out's of windows. I am sending, attached, a simple version of my voice package and 2 different test modules. Have not learned all the list comprehension approaches, but may do so in just this simple package. For it would come in handy in the Create method at the end of the module. I am asking if anyone has played with or used the built in SAPI 5 Microsoft voices and tts engine and or tried to make the voices portable so they are not required to be installed by the user? I also have the eSpeak voices in and they also did not get compiled into the py2exe package. I found out when sending the test to a friend the voices were not there except the built in voices on there machine. It would be nice to bundle them into a package so as not to have that person hunt them down. Granted they could be placed on a CD or a web site for download, but I have not gotten that far yet and would be nice to do it all in one. You can test my module and see if you like it or can use it. The only one I have not tested yet is the bookmark method. Have not had a need for it yet, but will soon test it. The Voice2.py is a wxpython module test and allows you to adjust the Volume, Rate, and Pitch of the voice or voices installed. NOTE: If you do make an executable you may also after compiling the Voice2.py get an error if you do not have MSVcp71.dll, mfc71.dll, and gdiplus.dll copied into your setup.py file. In other words a copy command to copy the dll's from your system32 folder. For if you do not, some computers it is run on will fail if they do not have those dll's installed. It would appear that they are not automatically copied. I am assuming that most of you probably have all the C dll's and such and may not need the note, but those who do not will need the dll's. #FORCE THE NEEDED DLL'S OR COMMENT THEM OUT! shutil.copy("c:/windows/system32/msvcp71.dll", os.path.join(os.getcwd(), "dist", "msvcp71.dll")) shutil.copy("c:/windows/system32/msvcp71.dll", os.path.join(os.getcwd(), "dist", "mfc71.dll")) shutil.copy("c:/windows/system32/msvcp71.dll", os.path.join(os.getcwd(), "dist", "gdiplus.dll")) I hope someone has tried to make a portable voice package, but knowing that more than 95% of programmers are sighted a may have to search a lot. But if anyone knows how please let me know. Bruce -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Sapi5.py URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Voice2.py URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: TestSapi.py URL: From timr at probo.com Thu Jun 26 19:49:08 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 26 Jun 2008 10:49:08 -0700 Subject: [python-win32] How Do You Make Your Speech or SAPI 5 Voices Portable? In-Reply-To: <001d01c8d785$25b4b080$0301a8c0@brucetower> References: <001d01c8d785$25b4b080$0301a8c0@brucetower> Message-ID: <4863D694.6000705@probo.com> FT wrote: > NOTE: > If you do make an executable you may also after compiling the Voice2.py > get an error if you do not > have MSVcp71.dll, mfc71.dll, and gdiplus.dll copied into your setup.py file. > In other words a copy command to > copy the dll's from your system32 folder. For if you do not, some computers > it is run on will fail if they do not have those dll's installed. It would > appear that they are not automatically copied. > > I am assuming that most of you probably have all the C dll's and such > and may not need the note, but those who do not will need the dll's. > > #FORCE THE NEEDED DLL'S OR COMMENT THEM OUT! > shutil.copy("c:/windows/system32/msvcp71.dll", os.path.join(os.getcwd(), > "dist", "msvcp71.dll")) > shutil.copy("c:/windows/system32/msvcp71.dll", os.path.join(os.getcwd(), > "dist", "mfc71.dll")) > shutil.copy("c:/windows/system32/msvcp71.dll", os.path.join(os.getcwd(), > "dist", "gdiplus.dll")) > These DLLs should have been loaded on every Windows XP by Windows Update, so anyone with a recent system should have them. However, that short snippet has a couple of problems. First, you assume that everyone's Windows directory is called "c:/windows". Second, you are copying all three files to the same destination name. Instead, do something like this: dest = os.path.join( os.environ['WINDIR'], 'system32' ) for dll in ("msvcp71.dll", "mfc71.dll", "gdiplus.dll"): if not os.path.isfile( os.path.join( dest, dll ) ): shutil.copy( os.path.join( dest, dll ), os.path.join( 'dist', dll ) ) You may think this is nitpicking, and you're probably right, but once you start trying to release code into the wild, you have to start thinking about the issues you encounter in the strange and magical world of the average user. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From chester_lab at fltg.net Thu Jun 26 21:23:13 2008 From: chester_lab at fltg.net (FT) Date: Thu, 26 Jun 2008 15:23:13 -0400 Subject: [python-win32] How Do You Make Your Speech or SAPI 5Voices Portable? References: <001d01c8d785$25b4b080$0301a8c0@brucetower> <4863D694.6000705@probo.com> Message-ID: <00c301c8d7c2$19e27d40$0201a8c0@brucetower> FT wrote: > NOTE: > If you do make an executable you may also after compiling the Voice2.py ----snip---- > I am assuming that most of you probably have all the C dll's and such These DLLs should have been loaded on every Windows XP by Windows Update, so anyone with a recent system should have them. However, that short snippet has a couple of problems. First, you assume that everyone's Windows directory is called "c:/windows". Second, you are copying all three files to the same destination name. Instead, do something like this: dest = os.path.join( os.environ['WINDIR'], 'system32' ) for dll in ("msvcp71.dll", "mfc71.dll", "gdiplus.dll"): if not os.path.isfile( os.path.join( dest, dll ) ): shutil.copy( os.path.join( dest, dll ), os.path.join( 'dist', dll ) ) You may think this is nitpicking, and you're probably right, but once you start trying to release code into the wild, you have to start thinking about the issues you encounter in the strange and magical world of the average user. -- Tim Roberts, timr at probo.com Hi Tim, Thanks for the info, but I was just placing an example. Also, I am limited to the SP1 for my screen reader program will not work on any later versions, thus no updates. But I had those dll's from loading other software and not getting updates. In the end, it was just an example. Yes, I am new to this and that example is a good one, but I noticed that my computer did in fact have the dll, and was not loaded, so why? Well, py2exe had to be forced to loaded them into the directory from mine, thus my directory path is that path and was my example NOW: The real issue was my desire to find out how voices from my computer can be loaded and sent along with my package. So I would need your expertise on that, for you gave a nice example for the search path, now I would need to know how py2exe can be told to load voice engines and zip them up with the program and function at the user end. I have been told about a GUI2EXE but when downloading that it says it is corrupted. INNO was mentioned as well, so how would a person package into the final exe to also run the voices if the other users computer does not have any tts engine installed? Bruce From timr at probo.com Thu Jun 26 23:02:39 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 26 Jun 2008 14:02:39 -0700 Subject: [python-win32] How Do You Make Your Speech or SAPI 5Voices Portable? In-Reply-To: <00c301c8d7c2$19e27d40$0201a8c0@brucetower> References: <001d01c8d785$25b4b080$0301a8c0@brucetower> <4863D694.6000705@probo.com> <00c301c8d7c2$19e27d40$0201a8c0@brucetower> Message-ID: <486403EF.4070402@probo.com> FT wrote: > Yes, I am new to this and that example is a good one, but I noticed that > my computer did in fact have the dll, and was not loaded, so why? Well, > py2exe had to be forced to loaded them into the directory from mine, thus my > directory path is that path and was my example > Hmmm, yes, I responded without fully realizing what you were doing. You should be able to get py2exe to load those DLLs from their original locations, as long as it can figure out you need them. > The real issue was my desire to find out how voices from my computer can > be loaded and sent along with my package. So I would need your expertise on > that, for you gave a nice example for the search path, now I would need to > know how py2exe can be told to load voice engines and zip them up with the > program and function at the user end. I have been told about a GUI2EXE but > when downloading that it says it is corrupted. INNO was mentioned as well, > so how would a person package into the final exe to also run the voices if > the other users computer does not have any tts engine installed? > Well, with py2exe, you can certainly load additional files into your zip. In your "setup.py" file, one of the parameters to the setup() function is "data_files", which is a list of files to be packed into the zip. Perhaps you could add a quick check at the beginning of your script that checks for the presence of a speech engine, and runs the installer if it isn't there. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From cappy2112 at gmail.com Thu Jun 26 23:44:00 2008 From: cappy2112 at gmail.com (Tony Cappellini) Date: Thu, 26 Jun 2008 14:44:00 -0700 Subject: [python-win32] How Do You Make Your Speech or SAPI 5 Voices Message-ID: <8249c4ac0806261444t1f387126w38e49907e7997405@mail.gmail.com> Message: 1 Date: Thu, 26 Jun 2008 08:01:21 -0400 From: "FT" Subject: [python-win32] How Do You Make Your Speech or SAPI 5 Voices Portable? To: Message-ID: <001d01c8d785$25b4b080$0301a8c0 at brucetower> Content-Type: text/plain; charset="iso-8859-1" This doesn't address your portability issue, but is provided as an FYI. Peter Parente already has a nice Python wrapper from the Microsoft Speech API- PyTTS http://sourceforge.net/project/showfiles.php?group_id=65529&package_id=74248 -------------- next part -------------- An HTML attachment was scrubbed... URL: From chester_lab at fltg.net Fri Jun 27 00:28:10 2008 From: chester_lab at fltg.net (FT) Date: Thu, 26 Jun 2008 18:28:10 -0400 Subject: [python-win32] How Do You Make Your Speech or SAPI 5 Voices References: <8249c4ac0806261444t1f387126w38e49907e7997405@mail.gmail.com> Message-ID: <004901c8d7db$f7138380$0201a8c0@brucetower> From: Tony Cappellini Message: 1 Date: Thu, 26 Jun 2008 08:01:21 -0400 From: "FT" Subject: [python-win32] How Do You Make Your Speech or SAPI 5 Voices Portable? To: This doesn't address your portability issue, but is provided as an FYI. Peter Parente already has a nice Python wrapper from the Microsoft Speech API- PyTTS http://sourceforge.net/project/showfiles.php?group_id=65529&package_id=74248 Hi Tony, Thanks, but I had used that first. My methods are simple, and essentially identical, but I added the pitch method, for he did not include it. Do not know why, did not ask him, but I am using the SAPI 5 and do a check to see if it is loaded onto the machine. Yet doing that check I do not do anything if the False comes back. I have not added other methods to it, at least not in my test samples. But, the question of most importance is how to have my py2exe also include the wrapper for installing a speech engine if none exist on the destination computer. Which would mean as tim had mentioned, have it pop up an install, which would mean have them go to a link, or have the install in the data folder or as is and run the install. But that means porting in up to 35 megs or more to run the SAPI 5. But having said that from XP on in windows machines the SAPI 5 is installed, but is Vista compatible? For I have heard so many nightmarish stories about Vista, there is no guarantee. Anyway, in response to your suggestion, I have pyTTS on my machine, studied there methods, took a look at what the SAPI has and decided to write my own, learn it, and expand on it. To allow a simple speech method for anyone to use. It is not written in C and relies only on SAPI 5 engine methods, along with XML commands. In other words a simple speech to plug into anyones program/game. So, the engine part may not be an issue except for older machines, I am interested in porting voices only. The eSpeak install is a small install, as is the extra SAPI 5 voices, Mike and Mary are. I do no that the NVDA project exists, but when asking them how they do it I was told to learn it on my own. In the NVDA project it appears they install up to 4 voice engines, including eSpeak and SAPI, and was wondering how they did it. Anyway, I will just keep on asking until I stumble onto the way by accident. Which is what I did when searching for the stream file to use for the save and read of .wav files. It took over 30 searches to find it. I had to just get the search parms exact before finding the needed format for the file stream in comtypes. Now that I found out how that is installed, now I may have found the one Microsoft variable that eluded me when looking at there sapi help. Which means I might be able to write all the commands inside the com types, but have not bothered to yet. The pyTTS does not allow you to use a simple name for voices, but eSpeak is as long as Microsoft. But I list the voices in my test sapi file. And when using them I search for the space in the name and default to -1 if not found, but in both cases add one to start at the proper position. Time to get moving on, this response is getting too long. Bruce -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhammond at skippinet.com.au Fri Jun 27 04:00:33 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 27 Jun 2008 12:00:33 +1000 Subject: [python-win32] How Do You Make Your Speech or SAPI 5 Voices In-Reply-To: <004901c8d7db$f7138380$0201a8c0@brucetower> References: <8249c4ac0806261444t1f387126w38e49907e7997405@mail.gmail.com> <004901c8d7db$f7138380$0201a8c0@brucetower> Message-ID: <00ca01c8d7f9$983a5f50$c8af1df0$@com.au> > But, the question of most importance is how to have my py2exe also > include the wrapper for installing a speech engine if none exist > on the destination computer. What you probably need is to create an installer for your py2exe project, using something like Inno, NSIS or WiX. This installer could then include the setup file for the speech engine and ask it to silently install. Exactly how that would be done depends on the installer you choose and how the speech engine redistributable is package. Then, your py2exe application can just assume it is there, safe in the knowledge that the installer took care of things. I hope that answers the question you were asking :) Cheers, Mark From chester_lab at fltg.net Fri Jun 27 05:10:54 2008 From: chester_lab at fltg.net (FT) Date: Thu, 26 Jun 2008 23:10:54 -0400 Subject: [python-win32] How Do You Make Your Speech or SAPI 5 Voices References: <8249c4ac0806261444t1f387126w38e49907e7997405@mail.gmail.com> <004901c8d7db$f7138380$0201a8c0@brucetower> <00ca01c8d7f9$983a5f50$c8af1df0$@com.au> Message-ID: <000301c8d803$701a6a60$0201a8c0@brucetower> > But, the question of most importance is how to have my py2exe also > include the wrapper for installing a speech engine if none exist > on the destination computer. What you probably need is to create an installer for your py2exe project, using something like Inno, NSIS or WiX. This installer could then include the setup file for the speech engine and ask it to silently install. Exactly how that would be done depends on the installer you choose and how the speech engine redistributable is package. Then, your py2exe application can just assume it is there, safe in the knowledge that the installer took care of things. I hope that answers the question you were asking :) Cheers, Mark Hi Mark, It almost does, for I have to look into how the speech setup is handled. I have a version of INNO installed but have not used it yet. I also have the SAPI 5 add voices and the eSpeak install, but not SAPI 4 and any other free source. Will have to look up the description on how to use INNO. Since the py2exe was not including the DLL's when doing my setup, I first had to find out why then get a proper way to include them, which is what other projects also found out. Tim gave me the pointer to the system folder, but gave the reverse description for the receiving end and not the py2exe end so this is what I did for the DLL's for the py2exe setup.py includes: sys_src = os.path.join( os.environ['WINDIR'], 'system32' ) for dll in ("msvcp71.dll", "mfc71.dll", "gdiplus.dll"): if not os.path.isfile( os.path.join( dist_dir, dll ) ): shutil.copy( os.path.join( sys_src, dll ), os.path.join( dist_dir, dll ) ) It works fine now, now on to figuring out the INNO and hope it is screen reader friendly on windows. Text versions is always the best, I mean text screen and not graphical screen. Thanks, Bruce From le.dahut at laposte.net Fri Jun 27 10:36:39 2008 From: le.dahut at laposte.net (le dahut) Date: Fri, 27 Jun 2008 10:36:39 +0200 Subject: [python-win32] Get listening ports Message-ID: <4864A697.6020207@laposte.net> Hello, I'm looking for an API that can do netstat calls to return a list of listenign ports and maybe a process attached to it. Any idea ? K. From juneaftn at gmail.com Fri Jun 27 10:52:40 2008 From: juneaftn at gmail.com (June Kim) Date: Fri, 27 Jun 2008 17:52:40 +0900 Subject: [python-win32] COM and threading Message-ID: <6f80c1520806270152r6c8b1704wffeca94b86d68e0e@mail.gmail.com> Running the following code results in an attribute error: Exception in thread Thread-1: Traceback (most recent call last): File "C:\Python25\lib\threading.py", line 486, in __bootstrap_inner self.run() File "testcom.py", line 10, in run print self.ie.locationUrl File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 500, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: InternetExplorer.Application.locationUrl It seems like the COM object isn't properly passed to the new thread. Any roundabouts? #testcom.py from win32com.client import * import pythoncom import time, threading, sys class Work(threading.Thread): def run(self): pythoncom.CoInitialize() print self.ie.locationUrl pythoncom.CoUninitialize() ie=DispatchEx("InternetExplorer.Application") ie.Navigate("http://www.google.com") while ie.Busy: time.sleep(0.1) print ie.locationUrl w=Work() w.ie=ie w.start() w.join() From mail at timgolden.me.uk Fri Jun 27 17:56:52 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 27 Jun 2008 16:56:52 +0100 Subject: [python-win32] COM and threading In-Reply-To: <6f80c1520806270152r6c8b1704wffeca94b86d68e0e@mail.gmail.com> References: <6f80c1520806270152r6c8b1704wffeca94b86d68e0e@mail.gmail.com> Message-ID: <48650DC4.50109@timgolden.me.uk> June Kim wrote: > Running the following code results in an attribute error: > > Exception in thread Thread-1: > Traceback (most recent call last): > File "C:\Python25\lib\threading.py", line 486, in __bootstrap_inner > self.run() > File "testcom.py", line 10, in run > print self.ie.locationUrl > File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 500, in > __getattr__ > raise AttributeError, "%s.%s" % (self._username_, attr) > AttributeError: InternetExplorer.Application.locationUrl > > It seems like the COM object isn't properly passed to the new thread. > Any roundabouts? Welcome to the wonderful world of COM and threading. Basically, the IWebBrowser2 object which is behind the InternetExplorer control cannot be passed as such between threads. To pass it between threads you need to marshal it and pass the resulting istream to the other thread which will then unmarshal it again. There's some sample code below which does this, but you might want to consider another approach, depending on what your app is trying to do, such as creating an IE object per thread and/or passing native Python objects between threads with Queues etc. TJG import os, sys import threading import time import pythoncom import win32com.client class Work (threading.Thread): def __init__ (self, marshalled_ie): threading.Thread.__init__ (self) self.marshalled_ie = marshalled_ie def run (self): pythoncom.CoInitialize () ie = win32com.client.Dispatch ( pythoncom.CoGetInterfaceAndReleaseStream ( self.marshalled_ie, pythoncom.IID_IDispatch ) ) print "Threaded LocationURL:", ie.LocationURL pythoncom.CoUninitialize () ie = win32com.client.Dispatch ("InternetExplorer.Application") ie.Visible = 1 ie.Navigate ("http://python.org") while ie.Busy: time.sleep (1) print "LocationURL:", ie.LocationURL marshalled_ie = pythoncom.CoMarshalInterThreadInterfaceInStream ( pythoncom.IID_IDispatch, ie ) work = Work (marshalled_ie) work.start () work.join () ie.Quit () From mail at timgolden.me.uk Fri Jun 27 18:14:21 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 27 Jun 2008 17:14:21 +0100 Subject: [python-win32] Get listening ports In-Reply-To: <4864A697.6020207@laposte.net> References: <4864A697.6020207@laposte.net> Message-ID: <486511DD.3050407@timgolden.me.uk> le dahut wrote: > Hello, > > I'm looking for an API that can do netstat calls to return a list of > listenign ports and maybe a process attached to it. You need the IP Helpers API http://msdn.microsoft.com/en-us/library/ms886687.aspx I'm afraid I've never used it, though, so you'll have to scout around for examples. TJG From coreconcern at gmail.com Sat Jun 28 02:18:56 2008 From: coreconcern at gmail.com (Aaron Colichia) Date: Fri, 27 Jun 2008 19:18:56 -0500 Subject: [python-win32] comtypes question: getactiveobject(ie.__clsid) says 'operation unavailsble' Message-ID: New to the pywin32 user list I've read a couple of articles stating that IE doesn't register with the ROT. It was geared toward IE4, but I am not sure if I am running into this or if I am not doing something right. I question my syntax because I was certain it worked once. Both CreateObject and GetActiveObject take 'progid' which can be a clsid, or the string representation of the application's clsid eg. InternetExplorer.Application.. here is what i am trying on xp sp2 ie6-7 from comtypes.client import GetActiveObject, CreateObject ie = CreateObject('InternetExplorer.Application') ie.Visible False ie.Visible = True ie.Navigate('http://google.com') 0 (Seems good at this point) newIe = GetActiveObject('InternetExplorer.Application') 'exception in blah blah' Windows Error: ( Operation Unavailable ) The same results if I use the seemingly good ie.__clsid I've also tried passing ie._iid_ and str(ie.__clsid) and str(ie._iid_) Is this all the same problem with IE not registering with ROT? Thanks, Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Sat Jun 28 13:33:34 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Sat, 28 Jun 2008 12:33:34 +0100 Subject: [python-win32] comtypes question: getactiveobject(ie.__clsid) says 'operation unavailsble' In-Reply-To: References: Message-ID: <4866218E.8050602@timgolden.me.uk> Aaron Colichia wrote: > New to the pywin32 user list > > I've read a couple of articles stating that IE doesn't register with the > ROT. It was geared toward IE4, but I am not sure if I am running into > this or if I am not doing something right. In short, everything I've come across -- even quite recently -- regarding IE suggests that it still doesn't register itself with the ROT. You either have to do the EnumWindow / FindWindow dance and then send keystrokes etc., or pursue one of the slightly esoteric solutions posted about which involve creating COM objects to act as proxies for browser sessions. Never done it, I'm afraid, but it doesn't look any less ugly than any other COM-based solution I've seen. Might be worth seeing if the developers behind PAMIE [1] have already undergone this particular pain. TJG [1] http://pamie.sourceforge.net/ From mani.sabri at gmail.com Sat Jun 28 18:03:28 2008 From: mani.sabri at gmail.com (mani sabri) Date: Sat, 28 Jun 2008 19:33:28 +0330 Subject: [python-win32] overlaped namedpipe client with CreateFile instead of CallNamedPipe Message-ID: <486652ca.1f588c0a.5b17.4328@mx.google.com> Hi In M.Hammonds "python programming on win32" chapter 18 there is a pipe service and a client [1] which use CallNamedPipe. I changed the service to accept messages bigger than its buffer [2]. Does anybody know how to rewrite the client with CreateFile method so it can accept bigger that buffer messages too? My attempt [3] which mimics http://msdn.microsoft.com/en-us/library/aa365592(VS.85).aspx fails with following message: pywintypes.error: (121, 'WaitNamedPipe', 'The semaphore timeout period has expired.') Best regards, Mani [1] -------------------------------------------------------------- # PipeServiceClient.py # # A client for testing the PipeService. # # Usage: # # PipeServiceClient.py message import win32pipe import sys import string if __name__=='__main__': message = string.join(sys.argv[1:]) pipeName = "\\\\.\\pipe\\PyPipeService" data = win32pipe.CallNamedPipe(pipeName, message, 512, 0) print "The service sent back:" print data [2]-------------------------------------------------------------- hr, data = win32file.ReadFile(pipeHandle, 256) if (win32api.GetLastError() == winerror.ERROR_MORE_DATA): t,t,remains = win32pipe.PeekNamedPipe(pipeHandle,0) hr,d2 = win32file.ReadFile(pipeHandle, remains) data = data + d2 [3]-------------------------------------------------------------- import win32pipe import winerror import pywintypes import win32file import win32security import cPickle as pickle from cPickle import HIGHEST_PROTOCOL if __name__=='__main__': message = pickle.dumps(range(1000),HIGHEST_PROTOCOL) pipeName = "\\\\.\\pipe\\pyPipe" saAttr = win32security.SECURITY_ATTRIBUTES() saAttr.SetSecurityDescriptorDacl ( 1, None, 0 ) pipeHandle = win32file.CreateFile(pipeName, win32file.GENERIC_READ | win32file.GENERIC_WRITE, 0, None, win32file.OPEN_EXISTING, win32file.FILE_FLAG_OVERLAPPED|win32file.FILE_ATTRIBUTE_NORMAL, None) win32pipe.WaitNamedPipe(pipeName,2000) win32pipe.SetNamedPipeHandleState(pipeHandle, win32pipe.PIPE_READMODE_MESSAGE, None, None) win32file.WriteFile(pipeHandle, message) hr, data = win32file.ReadFile(pipeHandle, 256) #TODO: read the remains of the message print 'len(data):',len(data) print "The service sent back:" print pickle.loads(data) From marcus at internetnowasp.net Sat Jun 28 17:51:11 2008 From: marcus at internetnowasp.net (Marcus Low) Date: Sat, 28 Jun 2008 23:51:11 +0800 Subject: [python-win32] Get listening ports In-Reply-To: <486511DD.3050407@timgolden.me.uk> References: <4864A697.6020207@laposte.net> <486511DD.3050407@timgolden.me.uk> Message-ID: <48665DEF.7040005@internetnowasp.net> Hi, Yup ip helpers the way, but alternatively if u want a simple routine, u can launch the netstat -a -b after u createprocess with the appropriate flags and pipe the information to ur buffer, then just parse the buffer and get the information, all these can be done without seeing an ugly cmd console popping out. I have the whole code in win32 C++ though, maybe there is an equivalent python code around. Marcus. Tim Golden wrote: > le dahut wrote: >> Hello, >> >> I'm looking for an API that can do netstat calls to return a list of >> listenign ports and maybe a process attached to it. > > You need the IP Helpers API > > http://msdn.microsoft.com/en-us/library/ms886687.aspx > > I'm afraid I've never used it, though, so you'll have > to scout around for examples. > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From mhammond at skippinet.com.au Sun Jun 29 03:23:29 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 29 Jun 2008 11:23:29 +1000 Subject: [python-win32] overlaped namedpipe client with CreateFile instead of CallNamedPipe In-Reply-To: <486652ca.1f588c0a.5b17.4328@mx.google.com> References: <486652ca.1f588c0a.5b17.4328@mx.google.com> Message-ID: <021501c8d986$beb42060$3c1c6120$@com.au> > In M.Hammonds "python programming on win32" chapter 18 there is a pipe > service and a client [1] which use CallNamedPipe. I changed the service > to > accept messages bigger than its buffer [2]. Does anybody know how to > rewrite > the client with CreateFile method so it can accept bigger that buffer > messages too? > My attempt [3] which mimics > http://msdn.microsoft.com/en-us/library/aa365592(VS.85).aspx fails with > following message: > pywintypes.error: (121, 'WaitNamedPipe', 'The semaphore timeout period > has expired.') ... > [2]-------------------------------------------------------------- > hr, data = win32file.ReadFile(pipeHandle, 256) > if (win32api.GetLastError() == winerror.ERROR_MORE_DATA): > t,t,remains = win32pipe.PeekNamedPipe(pipeHandle,0) > hr,d2 = win32file.ReadFile(pipeHandle, remains) > data = data + d2 A loop like the following works for me: hr = winerror.ERROR_MORE_DATA got = [] while hr == winerror.ERROR_MORE_DATA: hr, data = ReadFile(hPipe, 256) got.append(data) data = ''.join(got) I can also make code like the MSDN example work: hr, data = ReadFile(hPipe, 256) if hr == winerror.ERROR_MORE_DATA: t,t,remains = PeekNamedPipe(hPipe,0) print "remains is", remains hr,d2 = ReadFile(hPipe, remains) data = data + d2 But that will cause the second ReadFile to read the rest of the message regardless of the size. It should be fairly easy to modify that to a loop, but I'm not sure what PeekNamedPipe offers in this case (ie, just doing blocking reads should be fine in this case, as you generally can't start processing until the entire message is received anyway) If you keep having problems making it work, please attach your complete modified test code so we can run it and check it out. Cheers, Mark From mhammond at skippinet.com.au Sun Jun 29 03:33:32 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 29 Jun 2008 11:33:32 +1000 Subject: [python-win32] comtypes question: getactiveobject(ie.__clsid) says 'operation unavailsble' In-Reply-To: <4866218E.8050602@timgolden.me.uk> References: <4866218E.8050602@timgolden.me.uk> Message-ID: <021801c8d988$274aeae0$75e0c0a0$@com.au> > In short, everything I've come across -- even quite recently -- > regarding IE suggests that it still doesn't register itself > with the ROT. FWIW, the "COM Browser" in pythonwin enumerates the ROT (and yeah, IE doesn't seem to be there) Cheers, Mark From rwupole at msn.com Sun Jun 29 03:48:43 2008 From: rwupole at msn.com (Roger Upole) Date: Sat, 28 Jun 2008 21:48:43 -0400 Subject: [python-win32] comtypes question: getactiveobject(ie.__clsid) says Message-ID: I think the officially sanctioned way to get a running IE instance is now to enumerate the shell windows: import win32com.client shellwindows_guid='{9BA05972-F6A8-11CF-A442-00A0C90A8F39}' for sw in win32com.client.Dispatch(shellwindows_guid): print sw.LocationName From mc at mclaveau.com Sun Jun 29 09:42:57 2008 From: mc at mclaveau.com (Michel Claveau) Date: Sun, 29 Jun 2008 09:42:57 +0200 Subject: [python-win32] return & tuples (& lists) In-Reply-To: References: Message-ID: Hi! Not a question. Only a little note... (for readers without Sunday activity) In (pure) Python, consider this code: def ftest(): vret=(111,222,333) return(vret) print ftest() #give: (111, 222, 333) In (COM) Python, the same method of the class of a dynamic-COM-server give other return: def ftest(): vret=(111,222,333) return(vret) pv = win32com.client.Dispatch('....... print pv.ftest() #give: 111 In (pure) Python, this code: def ftest(): vret=(111,222,333) return(vret,) #note the comma! print ftest() #give: ((111, 222, 333),) In (COM) Python, the same method of the class of a dynamic-COM-server give other return: def ftest(): vret=(111,222,333) return(vret,) #note the comma! pv = win32com.client.Dispatch('....... print pv.ftest() #give: (111, 222, 333) Another detail: def ftest(): vret=[111,222,333] #list in the place of tuple return(vret) pv = win32com.client.Dispatch('....... print pv.ftest() #give: (111, 222, 333) And, to finish: in COM, return(vret) & return(vret,) give the same result. I wish you marvellous Sunday, with sun, bathe and aperitif. -- Michel Claveau From larry.bates at websafe.com Mon Jun 30 03:30:36 2008 From: larry.bates at websafe.com (Larry Bates) Date: Sun, 29 Jun 2008 20:30:36 -0500 Subject: [python-win32] return & tuples (& lists) In-Reply-To: References: Message-ID: Michel Claveau wrote: > Hi! > > Not a question. Only a little note... (for readers without Sunday > activity) > > > In (pure) Python, consider this code: > def ftest(): > vret=(111,222,333) > return(vret) > > print ftest() #give: (111, 222, 333) > > > In (COM) Python, the same method of the class of a dynamic-COM-server > give other return: > def ftest(): > vret=(111,222,333) > return(vret) > > pv = win32com.client.Dispatch('....... > print pv.ftest() #give: 111 > > > > In (pure) Python, this code: > def ftest(): > vret=(111,222,333) > return(vret,) #note the comma! > > print ftest() #give: ((111, 222, 333),) > > > In (COM) Python, the same method of the class of a dynamic-COM-server > give other return: > def ftest(): > vret=(111,222,333) > return(vret,) #note the comma! > > pv = win32com.client.Dispatch('....... > print pv.ftest() #give: (111, 222, 333) > > > Another detail: > def ftest(): > vret=[111,222,333] #list in the place of tuple > return(vret) > > pv = win32com.client.Dispatch('....... > print pv.ftest() #give: (111, 222, 333) > > > And, to finish: in COM, return(vret) & return(vret,) give the same > result. > > > > I wish you marvellous Sunday, with sun, bathe and aperitif. Misunderstanding about return values: > def ftest(): > vret=(111,222,333) > return(vret) This is the same as: return vret because the outer () are discarded as they are superfluous. You could write return ((((vret)))) and it would do the same thing. It still gets intrepreted as return tuple(111,222,333). COM obviously treats things differently. If you have a tuple and want to return it, just return it: return vret If you want to wrap objects in a tuple to return it, I would recommend using the build in tuple() command as the parenthesis can be confusing: return tuple(111,222,333). The reason return (vret,) works is because it is the same as: return tuple(tuple(111,222,333) (the trailing comma is the key here and is what tells python you mean a tuple instead of the "normal" parenthesis meaning. May seem inconsistent, but I don't believe it really is. -Larry From luke.stedman at gmail.com Mon Jun 30 10:39:35 2008 From: luke.stedman at gmail.com (Luke Stedman) Date: Mon, 30 Jun 2008 09:39:35 +0100 Subject: [python-win32] Running Python HTTPServer as Windows Service Message-ID: <159697800806300139s117e2449q910afdd64059edcf@mail.gmail.com> Hey guys, I am in the process of trying to setup a Python HTTPServer as a Windows Service. I have a set of scripts that run the web server and a wrapper batch file, they both work fine when I run them manually. I used the process outlined at http://agiletesting.blogspot.com/2005/09/running-python-script-as-windows.html to setup a Service and added the correct values to the registry. When I start the service it appears to work but the web server isn't running. Can anyone offer any further information/advice? Many thanks Luke Stedman From luke.stedman at gmail.com Mon Jun 30 10:55:25 2008 From: luke.stedman at gmail.com (Luke Stedman) Date: Mon, 30 Jun 2008 09:55:25 +0100 Subject: [python-win32] Running Python HTTPServer as Windows Service In-Reply-To: <159697800806300139s117e2449q910afdd64059edcf@mail.gmail.com> References: <159697800806300139s117e2449q910afdd64059edcf@mail.gmail.com> Message-ID: <159697800806300155v6ec965cfvc117a82df4a9738a@mail.gmail.com> Ignore me...have identified the problem.... In the listings given it says that a one of the values under the Parameter key for the registry entry for the service should be "AppDir", it should actually be "AppDirectory". Following on from this, can anyone advise me on solution to stopping/killing the web server when it is stopped in the service window? Cheers Luke 2008/6/30 Luke Stedman : > Hey guys, > > I am in the process of trying to setup a Python HTTPServer as a Windows Service. > > I have a set of scripts that run the web server and a wrapper batch > file, they both work fine when I run them manually. > > I used the process outlined at > http://agiletesting.blogspot.com/2005/09/running-python-script-as-windows.html > to setup a Service and added the correct values to the registry. > > When I start the service it appears to work but the web server isn't running. > > Can anyone offer any further information/advice? > > Many thanks > Luke Stedman > From le.dahut at laposte.net Mon Jun 30 15:22:57 2008 From: le.dahut at laposte.net (le dahut) Date: Mon, 30 Jun 2008 15:22:57 +0200 Subject: [python-win32] Get listening ports In-Reply-To: <48665DEF.7040005@internetnowasp.net> References: <4864A697.6020207@laposte.net> <486511DD.3050407@timgolden.me.uk> <48665DEF.7040005@internetnowasp.net> Message-ID: <4868DE31.6090801@laposte.net> I've found this : http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/392572 But maybe those APIs are available in pywin32 ? Marcus Low wrote : > > Hi, > > Yup ip helpers the way, but alternatively if u want a simple routine, u > can launch the netstat -a -b after u createprocess with the appropriate > flags and pipe the information > to ur buffer, then just parse the buffer and get the information, all > these can be done without seeing an ugly cmd console popping out. I have > the whole code in win32 C++ though, maybe there is an equivalent python > code around. > > Marcus. > > Tim Golden wrote: >> le dahut wrote: >>> Hello, >>> >>> I'm looking for an API that can do netstat calls to return a list of >>> listenign ports and maybe a process attached to it. >> >> You need the IP Helpers API >> >> http://msdn.microsoft.com/en-us/library/ms886687.aspx >> >> I'm afraid I've never used it, though, so you'll have >> to scout around for examples. >> >> TJG From mail at timgolden.me.uk Mon Jun 30 16:33:42 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 30 Jun 2008 15:33:42 +0100 Subject: [python-win32] Get listening ports In-Reply-To: <4868DE31.6090801@laposte.net> References: <4864A697.6020207@laposte.net> <486511DD.3050407@timgolden.me.uk> <48665DEF.7040005@internetnowasp.net> <4868DE31.6090801@laposte.net> Message-ID: <4868EEC6.4090508@timgolden.me.uk> le dahut wrote: > I've found this : > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/392572 That's great. I never thought of looking in the cookbook. > But maybe those APIs are available in pywin32 ? Don't think so. Roger/Mark? TJG From marcus at internetnowasp.net Mon Jun 30 18:06:50 2008 From: marcus at internetnowasp.net (Marcus Low) Date: Tue, 01 Jul 2008 00:06:50 +0800 Subject: [python-win32] Get listening ports In-Reply-To: <4868EEC6.4090508@timgolden.me.uk> References: <4864A697.6020207@laposte.net> <486511DD.3050407@timgolden.me.uk> <48665DEF.7040005@internetnowasp.net> <4868DE31.6090801@laposte.net> <4868EEC6.4090508@timgolden.me.uk> Message-ID: <4869049A.3090707@internetnowasp.net> Excellent find. Hmm..i think we might have enough new win32 recipes and content to warrant a new book on Python for Windows programming. The last book was like ...8 years ago? (well ya i know this topic have pop-up way too many times) Tim Golden wrote: > le dahut wrote: >> I've found this : >> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/392572 > > That's great. I never thought of looking in the cookbook. > >> But maybe those APIs are available in pywin32 ? > > Don't think so. Roger/Mark? > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > From mail at timgolden.me.uk Mon Jun 30 18:14:09 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Mon, 30 Jun 2008 17:14:09 +0100 Subject: [python-win32] Get listening ports In-Reply-To: <4869049A.3090707@internetnowasp.net> References: <4864A697.6020207@laposte.net> <486511DD.3050407@timgolden.me.uk> <48665DEF.7040005@internetnowasp.net> <4868DE31.6090801@laposte.net> <4868EEC6.4090508@timgolden.me.uk> <4869049A.3090707@internetnowasp.net> Message-ID: <48690651.6070004@timgolden.me.uk> Marcus Low wrote: > Excellent find. > Hmm..i think we might have enough new win32 recipes and content to > warrant a new book on Python for Windows programming. > The last book was like ...8 years ago? (well ya i know this topic have > pop-up way too many times) I'm struggling (in both senses) to find the time to fill in my new Python-on-Windows site. I'll definitely have a space for this kind of thing, even if its only a link to a useful recipe. TJG http://timgolden.me.uk/python-on-windows/ [definitely a work in progress, but definitely in progress] From timr at probo.com Mon Jun 30 19:27:34 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 30 Jun 2008 10:27:34 -0700 Subject: [python-win32] return & tuples (& lists) In-Reply-To: References: Message-ID: <48691786.9070800@probo.com> Larry Bates wrote: > Michel Claveau wrote: >> >> Not a question. Only a little note... (for readers without Sunday >> activity) > > ... > If you have a tuple and want to return it, just return it: return vret > > If you want to wrap objects in a tuple to return it, I would recommend > using the build in tuple() command as the parenthesis can be > confusing: return tuple(111,222,333). > > The reason return (vret,) works is because it is the same as: return > tuple(tuple(111,222,333) (the trailing comma is the key here and is > what tells python you mean a tuple instead of the "normal" parenthesis > meaning. > > May seem inconsistent, but I don't believe it really is. Well, regardless of his typos, there is clearly at least ONE inconsistency here, in that returning a tuple behaves differently in the COM and non-COM cases. Returning a scalar or a list works the same in both cases. I don't know whether that's a well-documented side effect of some other process, or if it is a bug, but it is inconsistent. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc.