From greg.antal at ata-e.com Wed Oct 1 02:10:46 2008 From: greg.antal at ata-e.com (Greg Antal) Date: Tue, 30 Sep 2008 17:10:46 -0700 Subject: [python-win32] ByRef params not working with PythonCOM Message-ID: <48E2C006.5030301@ata-e.com> An HTML attachment was scrubbed... URL: From larry.bates at websafe.com Wed Oct 1 06:56:37 2008 From: larry.bates at websafe.com (Larry Bates) Date: Tue, 30 Sep 2008 23:56:37 -0500 Subject: [python-win32] Extending DLL search path? In-Reply-To: References: Message-ID: Arve Knudsen wrote: > Hi > > I have a C++ program which embeds Python and is itself modularized > into several DLLs. The Python part (extensions) of the application > again links to these DLLs, the problem is the containing catalog (also > containing the executable itself) is not on the PATH, so the DLLs > aren't resolved when loading the Python extensions. Is there any smart > way of extending the DLL search path at runtime? > > Thanks, > Arve Take a look at apppath registry entries. -Larry From larry.bates at websafe.com Wed Oct 1 06:58:18 2008 From: larry.bates at websafe.com (Larry Bates) Date: Tue, 30 Sep 2008 23:58:18 -0500 Subject: [python-win32] NT service and login prompt In-Reply-To: <48E22C76.2090908@laposte.net> References: <48E22C76.2090908@laposte.net> Message-ID: le dahut wrote: > Hello, > Is it possible to tell windows to wait a python service has started > before the login prompt is displayed ? Probably not, but why would you want to implement something that does? Share your use case with us and perhaps we can be of more assistance. -Larry From mail at timgolden.me.uk Wed Oct 1 10:11:45 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 01 Oct 2008 09:11:45 +0100 Subject: [python-win32] NT service and login prompt In-Reply-To: References: <48E22C76.2090908@laposte.net> Message-ID: <48E330C1.1070107@timgolden.me.uk> Larry Bates wrote: > le dahut wrote: >> Hello, >> Is it possible to tell windows to wait a python service has started >> before the login prompt is displayed ? > > Probably not, but why would you want to implement something that does? > Share your use case with us and perhaps we can be of more assistance. Have a look at this thread from earlier this year: http://mail.python.org/pipermail/python-win32/2008-June/007686.html (which the OP contributed to, by the look of it) But I don't think, in the general case, that it's possible. OP: weren't you trying to do something fancy with GINA or something similar last year? Was it successful? TJG From le.dahut at laposte.net Wed Oct 1 10:51:47 2008 From: le.dahut at laposte.net (le dahut) Date: Wed, 01 Oct 2008 10:51:47 +0200 Subject: [python-win32] NT service and login prompt In-Reply-To: <48E330C1.1070107@timgolden.me.uk> References: <48E22C76.2090908@laposte.net> <48E330C1.1070107@timgolden.me.uk> Message-ID: <48E33A23.6090902@laposte.net> Tim Golden wrote : > > Larry Bates wrote: >> le dahut wrote: >>> Hello, >>> Is it possible to tell windows to wait a python service has started >>> before the login prompt is displayed ? >> >> Probably not, but why would you want to implement something that >> does? Share your use case with us and perhaps we can be of more >> assistance. > > Have a look at this thread from earlier this year: > > http://mail.python.org/pipermail/python-win32/2008-June/007686.html > > (which the OP contributed to, by the look of it) > But I don't think, in the general case, that it's possible. > > OP: weren't you trying to do something fancy with GINA or > something similar last year? Was it successful? > > TJG > > Yes, I was trying to intercept user's logon. I've done it using userinit registry key, a python NT service and a python service running on the PDC. My problem is also that the service has to be available at logon time to do some administrative stuff. It seems that the policy "gpedit" > Computer Configuration\Administrative Templates\System\Logon\ "Always wait for the network at computer startup and logon" (registry key HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Winlogon : SyncForegroundPolicy=1) can help me. Putting a loop to wait the service is up can also be a good idea. From mail at timgolden.me.uk Wed Oct 1 10:57:42 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 01 Oct 2008 09:57:42 +0100 Subject: [python-win32] NT service and login prompt In-Reply-To: <48E33A23.6090902@laposte.net> References: <48E22C76.2090908@laposte.net> <48E330C1.1070107@timgolden.me.uk> <48E33A23.6090902@laposte.net> Message-ID: <48E33B86.6070903@timgolden.me.uk> le dahut wrote: > Yes, I was trying to intercept user's logon. I've done it using userinit > registry key, a python NT service and a python service running on the PDC. > > My problem is also that the service has to be available at logon time to > do some administrative stuff. > > It seems that the policy "gpedit" > Computer > Configuration\Administrative Templates\System\Logon\ "Always wait for > the network at computer startup and logon" (registry key > HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows > NT\CurrentVersion\Winlogon : SyncForegroundPolicy=1) can help me. > > Putting a loop to wait the service is up can also be a good idea. I'd be very interested (on behalf of anyone else who might also be!) to see how this one resolves itself... Thanks TJG From ricercar at infinito.it Wed Oct 1 14:51:42 2008 From: ricercar at infinito.it (ricercar at infinito.it) Date: Wed, 1 Oct 2008 14:51:42 +0200 Subject: [python-win32] COM server and function parameters Message-ID: <19f4eb4b774af06d8b80d1bc6b6e7aae@82.48.249.79> Hi all, this is my first time here. I looked into the archive but found no answer to a question that probably is simple (I hope). I need to implement a COM server and I got the interface in IDL format. Unfortunately to me some functions have a declaration like this: HRESULT func([in] BSTR param1, [in] VARIANT_BOOL param2, [out] BSTR *param3); While the first two parameters should not give problems, I don't know how to translate the last one. A comment in the interface says that I need to allocate the BSTR with SysAllocString. There's a python method to do this? Or what parameter do I get in the python function. I write a def like: def func(param1, param2, param3): pass And on the same line I have a function declared as: HRESULT func2([out] IEnumString ** param1); Again I don't know how to handle the param. Excuse me if the question is trivial and thanks for any help, Enrico From vinaya at adobe.com Wed Oct 1 19:23:55 2008 From: vinaya at adobe.com (Vinay Anantharaman) Date: Wed, 1 Oct 2008 10:23:55 -0700 Subject: [python-win32] Outlook 2007 through COM. Wrong count in Outbox. Stale Object? Message-ID: <0DAF2B31FBCEB6439F63FA7F91601F74036ADC81@namail3.corp.adobe.com> Hi, I am trying to automate sending and receiving using win32com. I execute the SendAndRecieve() function. The synchronization events indicate that messages were sent. However, the Outbox count indicates there are messages still there. I manually open Outlook and look at the UI and it indicates the Outbox is empty and the message was sent at the time of the programmatic SendAndRecieve. It feels like the Folder object's collection of items is 'stale'. There are no functions to 'refresh' according to the Outlook documentation. Do I need to do a Dispatch on this Folder object or something to guarantee I have the latest one? Thanks, Vinay Anantharaman From mhammond at skippinet.com.au Thu Oct 2 01:19:50 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 2 Oct 2008 09:19:50 +1000 Subject: [python-win32] COM server and function parameters In-Reply-To: <19f4eb4b774af06d8b80d1bc6b6e7aae@82.48.249.79> References: <19f4eb4b774af06d8b80d1bc6b6e7aae@82.48.249.79> Message-ID: <053001c9241c$36faf370$a4f0da50$@com.au> > Hi all, > this is my first time here. I looked into the archive but found no > answer to > a question that probably is simple (I hope). > I need to implement a COM server and I got the interface in IDL format. > Unfortunately to me some functions have a declaration like this: > > HRESULT func([in] BSTR param1, [in] VARIANT_BOOL param2, [out] BSTR > *param3); > > While the first two parameters should not give problems, I don't know > how > to translate the last one. A comment in the interface says that I need > to > allocate the BSTR with SysAllocString. There's a python method to do > this? Just return a string - pythoncom will do the SysAllocString() for you. Please see the 'pippo' examples in the win32com directory - they show how to hookup a typelib with your com object implementation. ie, your methodn will take 2 args (apart from 'self') and return a string. > Or what parameter do I get in the python function. I write a def like: > > def func(param1, param2, param3): > pass > > > And on the same line I have a function declared as: > > HRESULT func2([out] IEnumString ** param1); > > Again I don't know how to handle the param. > > Excuse me if the question is trivial and thanks for any help, Similarly - just return an object. In this case you need to return a Python instance that implemented IEnumString. Cheers, Mark From ricercar at infinito.it Thu Oct 2 08:46:42 2008 From: ricercar at infinito.it (ricercar at infinito.it) Date: Thu, 2 Oct 2008 08:46:42 +0200 Subject: [python-win32] COM server and function parameters Message-ID: <74cd37f245fc92ed6110d252c055a8e6@79.6.250.202> At 09.19 02/10/2008 +1000, you wrote: >Just return a string - pythoncom will do the SysAllocString() for you. >Please see the 'pippo' examples in the win32com directory - they show how to >hookup a typelib with your com object implementation. It's incredible how simple is the answer, I searched a lot but I didn't realized that the solution was the simpler one! Thank you very much for your help, I will look at the example Enrico From mani.sabri at gmail.com Fri Oct 3 09:45:19 2008 From: mani.sabri at gmail.com (mani sabri) Date: Fri, 3 Oct 2008 07:45:19 -0000 Subject: [python-win32] DDE advise Message-ID: <48e5cd94.1401420a.24c4.ffffdc8c@mx.google.com> Hello everyone Does anybody know how to use a DDE server that implements Advise mechanism instead of Request? Best regards Mani From stian.prg at gmail.com Fri Oct 3 21:14:08 2008 From: stian.prg at gmail.com (Stian) Date: Fri, 3 Oct 2008 21:14:08 +0200 Subject: [python-win32] win32console attach problems Message-ID: <9d60787d0810031214k1cf46ff1qfb56e7e94eaef68a@mail.gmail.com> Hi, I'm experiencing concurring problems when attempting to attach to a console using the PyWin32 win32console. I have an application which may attach to a console, send ctrl+c to it and then detach - using win32console. If I do this "too soon" after the console is started the AttachConsole fails, throwing an exception. Fair enough. My issue is that after one such a failing attempt all following AttachConsole attempts will fail the same way. My first thought was that perhaps it is somewhat attached even though it fails. So I put in a call to FreeConsole to be called each time before AttachConsole ? in a different try-except clause. No luck. So; any ideas why am I unable to attach to this console when I know it has started up properly - just because it failed once? If I don't get one early failing attempt all the win32console functions runs like a charm each time. Here is a simplified variant of my function: def my_func(self): try: win32console.FreeConsole() except: pass try: win32console.AttachConsole(pid) win32console.GenerateConsoleCtrlEvent( win32console.CTRL_C_EVENT, pid ) win32console.FreeConsole() except: show_error_messagebox(ERROR_MESSAGE_ON_CONSOLE_SHUTDOWN) return False Any comments are welcome. Regards, Stian -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Oct 3 21:46:06 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 03 Oct 2008 12:46:06 -0700 Subject: [python-win32] win32console attach problems In-Reply-To: <9d60787d0810031214k1cf46ff1qfb56e7e94eaef68a@mail.gmail.com> References: <9d60787d0810031214k1cf46ff1qfb56e7e94eaef68a@mail.gmail.com> Message-ID: <48E6767E.2020608@probo.com> Stian wrote: > > > I'm experiencing concurring problems when attempting to attach to a > console using the PyWin32 win32console. I have an application which > may attach to a console, send ctrl+c to it and then detach - using > win32console. If I do this "too soon" after the console is started the > AttachConsole fails, throwing an exception. Fair enough. My issue is > that after one such a failing attempt all following AttachConsole > attempts will fail the same way. What error do you get? MSDN describes several different error returns. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From aivars868 at gmail.com Fri Oct 3 21:56:29 2008 From: aivars868 at gmail.com (aivars) Date: Fri, 3 Oct 2008 22:56:29 +0300 Subject: [python-win32] help with python COM server needed Message-ID: Hello, basically I rewrote an example by Mark Hammond trying to create a simple trial COM server as per his Python programming on Win32 book The problem is that when run from VB6 (Excel VBA) it gives me an error exceptions.typeerror ReturnAmount() takes no arguments (1 given) Google search gives me something like I am calling unbound method. I am quite new in Python so please help my code here: # SimpleCOMServer.py - A sample COM server - almost as small as they come! # # We simply expose a single method in a Python COM object. class Profit(object): _public_methods_ = [ 'ReturnAmount' ] _reg_progid_ = "Aivars.ReturnSaldo" # NEVER copy the following ID # Use "print pythoncom.CreateGuid()" to make a new one. _reg_clsid_ = "{599E3E04-5AEA-4541-B180-CED64F2A71BE}" def ReturnAmount(self): import sqlite3 con = sqlite3.connect("e://pythonexamples//aivars2.db") cur = con.cursor() konts='71302' d1='2008-01-01' d2='2008-09-30' cur.execute("select coalesce(sum(summa),0) as AD from so2 where deb = (?) and date(datums) between (?) and (?)", \ (konts, d1, d2)) ret=cur.fetchone() r=ret[0] return r cur.close() con.commit() con.close() # Add code so that when this script is run by # Python.exe, it self-registers. if __name__=='__main__': print "Registering COM server..." import win32com.server.register win32com.server.register.UseCommandLine(Profit) thanks a lot aivars From timr at probo.com Fri Oct 3 22:09:59 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 03 Oct 2008 13:09:59 -0700 Subject: [python-win32] help with python COM server needed In-Reply-To: References: Message-ID: <48E67C17.7030006@probo.com> aivars wrote: > Hello, > basically I rewrote an example by Mark Hammond trying to create a > simple trial COM server as per his Python programming on Win32 book > The problem is that when run from VB6 (Excel VBA) it gives me an error > > exceptions.typeerror > ReturnAmount() takes no arguments (1 given) > It's true that your ReturnAmount function takes no arguments. How did you call it? > con = sqlite3.connect("e://pythonexamples//aivars2.db") > If you use forward slashes, just use one at a time. If you use backward slashes, THEN you need to double them. > cur = con.cursor() > > konts='71302' > d1='2008-01-01' > d2='2008-09-30' > > cur.execute("select coalesce(sum(summa),0) as AD from so2 > where deb = (?) and date(datums) between (?) and (?)", \ > (konts, d1, d2)) > sqlite3 uses the ? method of parameter substitution. You don't need those extra parentheses (that is, use ? not (?) ). Also, you don't need the backslash at end of line; Python will keep continuing the statement as long as you are inside an open set of parentheses. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From stian.prg at gmail.com Fri Oct 3 22:39:09 2008 From: stian.prg at gmail.com (Stian) Date: Fri, 3 Oct 2008 22:39:09 +0200 Subject: [python-win32] win32console attach problems In-Reply-To: <48E6767E.2020608@probo.com> References: <9d60787d0810031214k1cf46ff1qfb56e7e94eaef68a@mail.gmail.com> <48E6767E.2020608@probo.com> Message-ID: <9d60787d0810031339k416cad55w82f4053fb84400b2@mail.gmail.com> > What error do you get? MSDN describes several different error returns. Actually I was wrong. The first error is "Handle is invalid". Then all following errors are "Access is denied.", which seems to be the same error I get when a console is already attached. But if this was the case - shouldn't it be fixed with the win32console.FreeConsole I always call before attaching? -Stian -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Fri Oct 3 22:49:53 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 03 Oct 2008 13:49:53 -0700 Subject: [python-win32] win32console attach problems In-Reply-To: <9d60787d0810031339k416cad55w82f4053fb84400b2@mail.gmail.com> References: <9d60787d0810031214k1cf46ff1qfb56e7e94eaef68a@mail.gmail.com> <48E6767E.2020608@probo.com> <9d60787d0810031339k416cad55w82f4053fb84400b2@mail.gmail.com> Message-ID: <48E68571.1070107@probo.com> Stian wrote: > > What error do you get? MSDN describes several different error returns. > Actually I was wrong. The first error is "Handle is invalid". Then all > following errors are "Access is denied.", which seems to be the same > error I get when a console is already attached. But if this was the > case - shouldn't it be fixed with the win32console.FreeConsole I > always call before attaching? Well, let me ask a silly question. Are you running this from a "pyw" app, using Pythonw.exe, so you don't have a console of your own? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From aivars868 at gmail.com Sat Oct 4 06:18:17 2008 From: aivars868 at gmail.com (aivars) Date: Sat, 4 Oct 2008 07:18:17 +0300 Subject: [python-win32] help with python COM server needed In-Reply-To: <48E67C17.7030006@probo.com> References: <48E67C17.7030006@probo.com> Message-ID: Thanks, Tim, Your suggestions are OK but the code works called from IDLE - It does not work when called from VB as a COM server. Mark Hammond's example works for me perfectly. I cannot see what I am doing wrong. This is only a trial version and is definitely ugly. The ReturnAmount will take arguments in future version so to speak. this is how I call it from VB: Sub testPython() Dim a Dim response Set a = CreateObject("Aivars.ReturnSaldo") response = a.ReturnAmount() '--->error here Worksheets("Sheet1").Range("a1").Value = response End Sub 2008/10/3 Tim Roberts : > aivars wrote: >> Hello, >> basically I rewrote an example by Mark Hammond trying to create a >> simple trial COM server as per his Python programming on Win32 book >> The problem is that when run from VB6 (Excel VBA) it gives me an error >> >> exceptions.typeerror >> ReturnAmount() takes no arguments (1 given) >> > > It's true that your ReturnAmount function takes no arguments. How did > you call it? > >> con = sqlite3.connect("e://pythonexamples//aivars2.db") >> > > If you use forward slashes, just use one at a time. If you use backward > slashes, THEN you need to double them. > >> cur = con.cursor() >> >> konts='71302' >> d1='2008-01-01' >> d2='2008-09-30' >> >> cur.execute("select coalesce(sum(summa),0) as AD from so2 >> where deb = (?) and date(datums) between (?) and (?)", \ >> (konts, d1, d2)) >> > > sqlite3 uses the ? method of parameter substitution. You don't need > those extra parentheses (that is, use ? not (?) ). Also, you don't need > the backslash at end of line; Python will keep continuing the statement > as long as you are inside an open set of parentheses. > > -- > 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 stef.mientki at gmail.com Sun Oct 5 02:24:28 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Sun, 05 Oct 2008 02:24:28 +0200 Subject: [python-win32] How to determine if a process (known pid) is still running ? Message-ID: <48E8093C.40700@gmail.com> hello, How to determine if a process (known pid) os still running ? Googling the web, I found 1 solution in killing the process, but that's not what I want, I want to reuse the running process. I could also ask a complete list of active processes, but from my experiences that's quite slow. Any better solutions ? thanks, Stef Mientki From jcanto at hispasec.com Sun Oct 5 03:46:08 2008 From: jcanto at hispasec.com (Julio Canto) Date: Sun, 05 Oct 2008 03:46:08 +0200 Subject: [python-win32] How to determine if a process (known pid) is still running ? In-Reply-To: <48E8093C.40700@gmail.com> References: <48E8093C.40700@gmail.com> Message-ID: <48E81C60.8030803@hispasec.com> Stef Mientki escribi?: > hello, > > How to determine if a process (known pid) os still running ? > > Googling the web, I found 1 solution in killing the process, > but that's not what I want, I want to reuse the running process. > > I could also ask a complete list of active processes, > but from my experiences that's quite slow. Probalby win32process.GetExitCodeProcess would be useful for you. -- Regards, Julio Canto | VirusTotal.com | Hispasec Sistemas Lab | Tlf: +34.902.161.025 | Fax: +34.952.028.694 | PGP Key ID: EF618D2B | jcanto at hispasec.com From mail at timgolden.me.uk Sun Oct 5 11:03:49 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Sun, 05 Oct 2008 10:03:49 +0100 Subject: [python-win32] How to determine if a process (known pid) is still running ? In-Reply-To: <48E8093C.40700@gmail.com> References: <48E8093C.40700@gmail.com> Message-ID: <48E882F5.8060507@timgolden.me.uk> Stef Mientki wrote: > How to determine if a process (known pid) os still running ? > > Googling the web, I found 1 solution in killing the process, > but that's not what I want, I want to reuse the running process. > > I could also ask a complete list of active processes, > but from my experiences that's quite slow. > > Any better solutions ? I'm not entirely sure what you're trying to achieve, or what "reuse the running process" means. This WMI snippet will tell you whether a given pid is running or not. As you may know, WMI isn't the fastest thing on earth, but it may be fast enough for you. import wmi pid = int (raw_input ("Enter PID:")) c = wmi.WMI (find_classes=False) for process in c.Win32_Process ([], ProcessId=pid): print "PID %s in use by %s" % (pid, process.Caption) break else: print "PID %d not in use" % pid TJG From stef.mientki at gmail.com Sun Oct 5 11:34:24 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Sun, 05 Oct 2008 11:34:24 +0200 Subject: [python-win32] How to determine if a process (known pid) is still running ? In-Reply-To: <48E882F5.8060507@timgolden.me.uk> References: <48E8093C.40700@gmail.com> <48E882F5.8060507@timgolden.me.uk> Message-ID: <48E88A20.8030507@gmail.com> Tim Golden wrote: > Stef Mientki wrote: >> How to determine if a process (known pid) os still running ? >> >> Googling the web, I found 1 solution in killing the process, >> but that's not what I want, I want to reuse the running process. >> >> I could also ask a complete list of active processes, >> but from my experiences that's quite slow. >> >> Any better solutions ? > > I'm not entirely sure what you're trying to achieve, > or what "reuse the running process" means. ok, maybe I'm totally on the wrong track (I'm just an amateur), because the GetExitCodeProcess, suggested by Julia, gives an error "invalid handle" What I want is quite simple: from my program I want to show chm-help info, so I've the following code 1 if not ( self.Win32_Viewer ) : 2 self.Win32_Viewer = win32help.HtmlHelp ( 0, str(CHM), win32help.HH_DISPLAY_INDEX, '' ) 3 win32help.HtmlHelp ( self.Win32_Viewer, 4 str(CHM), 5 win32help.HH_DISPLAY_INDEX, 6 str ( keyword ) ) Now this works well, until the user has closed the windows help window, in which case line 3 crashes (of course). Now I just did some experiments, and saw that I could probably do enough by only performing line 2 (with a keyword), as this, to my surprise, uses the same help window if one is already opened. Is this indeed A corrrect way ? thanks, Stef > This WMI > snippet will tell you whether a given pid is running > or not. As you may know, WMI isn't the fastest thing > on earth, but it may be fast enough for you. > > > import wmi > > pid = int (raw_input ("Enter PID:")) > > c = wmi.WMI (find_classes=False) > for process in c.Win32_Process ([], ProcessId=pid): > print "PID %s in use by %s" % (pid, process.Caption) > break > else: > print "PID %d not in use" % pid > > > > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From stian.prg at gmail.com Sun Oct 5 15:16:37 2008 From: stian.prg at gmail.com (Stian) Date: Sun, 5 Oct 2008 15:16:37 +0200 Subject: [python-win32] win32console attach problems In-Reply-To: <48E68571.1070107@probo.com> References: <9d60787d0810031214k1cf46ff1qfb56e7e94eaef68a@mail.gmail.com> <48E6767E.2020608@probo.com> <9d60787d0810031339k416cad55w82f4053fb84400b2@mail.gmail.com> <48E68571.1070107@probo.com> Message-ID: <9d60787d0810050616j45f314dbh922fb876bd48ce1b@mail.gmail.com> > Well, let me ask a silly question. Are you running this from a "pyw" > app, using Pythonw.exe, so you don't have a console of your own? Well, that's not a silly question for me - I'm rather new to Python. Anyway - let me tell you a bit more about how this is put together if that may be relevant. I have a GUI written with wxWidgets/wxPython. A .exe-file is created using pyinstaller. I don't think pyw is explicitly used, but I see something about pythonw in the pyinstaller files. Perhaps this is used here? My GUI starts a console using win32process like this: win32process.CreateProcess(None, exe_path, None, None, False, win32con.CREATE_NEW_PROCESS_GROUP | win32con.CREATE_NEW_CONSOLE, None, None, startupinfo) And at a later point - clicking one of the buttons in the GUI - it should kill this console using the mentioned code: def my_func(self): ... try: win32console.FreeConsole() except: pass try: win32console.AttachConsole(pid) win32console.GenerateConsoleCtrlEvent( win32console.CTRL_C_EVENT, pid ) win32console.FreeConsole() except: show_error_messagebox(ERROR_MESSAGE_ON_CONSOLE_SHUTDOWN) return False Does this make it any clarify what may be wrong? Thanks for your time! Stian -------------- next part -------------- An HTML attachment was scrubbed... URL: From schaffer at optonline.net Mon Oct 6 01:08:40 2008 From: schaffer at optonline.net (Les Schaffer) Date: Sun, 05 Oct 2008 19:08:40 -0400 Subject: [python-win32] WMI speed (was: How to determine if a process (known pid) is still running ?) In-Reply-To: <48E882F5.8060507@timgolden.me.uk> References: <48E8093C.40700@gmail.com> <48E882F5.8060507@timgolden.me.uk> Message-ID: <48E948F8.9070004@optonline.net> Tim Golden wrote: > > I'm not entirely sure what you're trying to achieve, > or what "reuse the running process" means. This WMI > snippet will tell you whether a given pid is running > or not. As you may know, WMI isn't the fastest thing > on earth, but it may be fast enough for you. well, since you raise the issue ;-) i am working on a python application that uses WMI to monitor various states of the system while the app goes about its business. we have the app running on about 10 different machines, and 9 out of 10 of the platforms run our WMI queries in milliseconds, whereas on one particular machine, the same query takes about 5 seconds. i am trying to figure out where the delay could be coming from, meaning i need to write some profiling code. but i imagine it could be one of several things: 1. the one machine has a huge WMI database so takes longer to query (but the machine is brand new with little software or special hardware installed) 2. COM code is clunky???, but why so slow on one machine 2. python-COM interface, but whats so special about this one machine... anyone here have similar experience with WMI? many thanks Les Schaffer From joe at omc-international.com.au Mon Oct 6 03:42:58 2008 From: joe at omc-international.com.au (Joe Healy) Date: Mon, 06 Oct 2008 12:42:58 +1100 Subject: [python-win32] ODBC date and time issues Message-ID: <48E96D22.8070505@omc-international.com.au> Hi, We've been having some problems with the dbi odbc interface to databases. The problems have been occurring when using MS SQL server or MS Access databases querying datetimes over daylight savings boundaries. The following table containing both string representations and datetimes demonstrates our problem: ID, Date String, DBI String, DBI long, Count 0, 2008-10-05 00:30:00, Sun Oct 05 00:30:00 2008, 1223130600, 0.000 1, 2008-10-05 00:40:00, Sun Oct 05 00:40:00 2008, 1223131200, 1.000 2, 2008-10-05 00:50:00, Sun Oct 05 00:50:00 2008, 1223131800, 2.000 3, 2008-10-05 01:00:00, Sun Oct 05 01:00:00 2008, 1223132400, 3.000 4, 2008-10-05 01:10:00, Sun Oct 05 01:10:00 2008, 1223133000, 4.000 5, 2008-10-05 01:20:00, Sun Oct 05 01:20:00 2008, 1223133600, 5.000 6, 2008-10-05 01:30:00, Sun Oct 05 01:30:00 2008, 1223134200, 6.000 7, 2008-10-05 01:40:00, Sun Oct 05 01:40:00 2008, 1223134800, 7.000 8, 2008-10-05 01:50:00, Sun Oct 05 01:50:00 2008, 1223135400, 8.000 9, 2008-10-05 02:00:00, Sun Oct 05 01:00:00 2008, 1223132400, 9.000 10, 2008-10-05 02:10:00, Sun Oct 05 01:10:00 2008, 1223133000, 10.000 11, 2008-10-05 02:20:00, Sun Oct 05 01:20:00 2008, 1223133600, 11.000 12, 2008-10-05 02:30:00, Sun Oct 05 01:30:00 2008, 1223134200, 12.000 13, 2008-10-05 02:40:00, Sun Oct 05 01:40:00 2008, 1223134800, 13.000 14, 2008-10-05 02:50:00, Sun Oct 05 01:50:00 2008, 1223135400, 14.000 15, 2008-10-05 03:00:00, Sun Oct 05 03:00:00 2008, 1223136000, 15.000 16, 2008-10-05 03:10:00, Sun Oct 05 03:10:00 2008, 1223136600, 16.000 17, 2008-10-05 03:20:00, Sun Oct 05 03:20:00 2008, 1223137200, 17.000 The first column is a row id, the second is the string version of the date, the third is the datetime column converted to a string and the fourth is the datetime column converted to a long. At row 10 (02:00:00), we see 01:00:00 for the second time. Then at row 16, we then see 03:00:00 onwards. So it appears that the datetimes are being converted to daylight savings only between the hours of 2 and 3. The code to create the database and generate this table is attached. I've also looked at the code for creating these dbiDate objects which is in dateCopy in odbc.cpp and a guess as to the problem is different assumptions about daylight savings from various parts of the C library. The setting of gt.tm_isdst to -1 appears to be the problem to me and I feel (at least for our purposes) that a value of 0 might be more appropriate. Looking at this, it appears that the data we require is available in the dt object: static PyObject *dateCopy(const void *v, int sz) { const TIMESTAMP_STRUCT *dt = (const TIMESTAMP_STRUCT *) v; struct tm gt; gt.tm_isdst = -1; /* figure out DST */ gt.tm_year = dt->year-1900; gt.tm_mon = dt->month-1; gt.tm_mday = dt->day; gt.tm_hour = dt->hour; gt.tm_min = dt->minute; gt.tm_sec = dt->second; return dbiMakeDate(PyInt_FromLong(mktime(>))); } Is it relatively easy to modify or add code to this library to make it return python datetime objects or something with direct access to the original structs values? If I (or someone else) was to do this, would it be likely to be accepted into the main python-win32 library? For our purposes, we are after a naive handling of the datetimes as we need to ensure our calculations are correct across timezone boundaries. Conversion to values in a particular timezone is handled at display time. For reference, we have tested this using python 2.3 and 2.5, builds 203, 211 and 212 of python-win32, with New Zealand and Australian time zone changes for Sept/Oct 2008 on Vista, XP and Server 2003. As an aside, the testDates method in test_odbc.py looks a little bit strange. Is it actually testing against the string 'd' instead of the variable d? Thanks in advance, Joe -------------- next part -------------- A non-text attachment was scrubbed... Name: db_odbc_msaccess_test.py Type: text/x-python Size: 2167 bytes Desc: not available URL: From rwupole at msn.com Mon Oct 6 05:06:18 2008 From: rwupole at msn.com (Roger Upole) Date: Sun, 5 Oct 2008 23:06:18 -0400 Subject: [python-win32] Re: ODBC date and time issues Message-ID: Joe Healy wrote: > > Hi, > > We've been having some problems with the dbi odbc interface to > databases. The problems have been occurring when using MS SQL server or > MS Access databases querying datetimes over daylight savings > boundaries. > > The following table containing both string representations and > datetimes demonstrates our problem: > > ID, Date String, DBI String, DBI long, Count > 0, 2008-10-05 00:30:00, Sun Oct 05 00:30:00 2008, 1223130600, 0.000 > 1, 2008-10-05 00:40:00, Sun Oct 05 00:40:00 2008, 1223131200, 1.000 > 2, 2008-10-05 00:50:00, Sun Oct 05 00:50:00 2008, 1223131800, 2.000 > 3, 2008-10-05 01:00:00, Sun Oct 05 01:00:00 2008, 1223132400, 3.000 > 4, 2008-10-05 01:10:00, Sun Oct 05 01:10:00 2008, 1223133000, 4.000 > 5, 2008-10-05 01:20:00, Sun Oct 05 01:20:00 2008, 1223133600, 5.000 > 6, 2008-10-05 01:30:00, Sun Oct 05 01:30:00 2008, 1223134200, 6.000 > 7, 2008-10-05 01:40:00, Sun Oct 05 01:40:00 2008, 1223134800, 7.000 > 8, 2008-10-05 01:50:00, Sun Oct 05 01:50:00 2008, 1223135400, 8.000 > 9, 2008-10-05 02:00:00, Sun Oct 05 01:00:00 2008, 1223132400, 9.000 > 10, 2008-10-05 02:10:00, Sun Oct 05 01:10:00 2008, 1223133000, 10.000 > 11, 2008-10-05 02:20:00, Sun Oct 05 01:20:00 2008, 1223133600, 11.000 > 12, 2008-10-05 02:30:00, Sun Oct 05 01:30:00 2008, 1223134200, 12.000 > 13, 2008-10-05 02:40:00, Sun Oct 05 01:40:00 2008, 1223134800, 13.000 > 14, 2008-10-05 02:50:00, Sun Oct 05 01:50:00 2008, 1223135400, 14.000 > 15, 2008-10-05 03:00:00, Sun Oct 05 03:00:00 2008, 1223136000, 15.000 > 16, 2008-10-05 03:10:00, Sun Oct 05 03:10:00 2008, 1223136600, 16.000 > 17, 2008-10-05 03:20:00, Sun Oct 05 03:20:00 2008, 1223137200, 17.000 > > The first column is a row id, the second is the string version of the > date, the third is the datetime column converted to a string and the > fourth is the datetime column converted to a long. > > At row 10 (02:00:00), we see 01:00:00 for the second time. Then at row > 16, we then see 03:00:00 onwards. > > So it appears that the datetimes are being converted to daylight > savings only between the hours of 2 and 3. > > The code to create the database and generate this table is attached. > > I've also looked at the code for creating these dbiDate objects which > is in dateCopy in odbc.cpp and a guess as to the problem is different > assumptions about daylight savings from various parts of the C > library. The setting of gt.tm_isdst to -1 appears to be the problem to > me and I feel (at least for our purposes) that a value of 0 might be > more appropriate. > > Looking at this, it appears that the data we require is available in > the dt object: > > static PyObject *dateCopy(const void *v, int sz) > { > const TIMESTAMP_STRUCT *dt = (const TIMESTAMP_STRUCT *) v; > struct tm gt; > gt.tm_isdst = -1; /* figure out DST */ > gt.tm_year = dt->year-1900; > gt.tm_mon = dt->month-1; > gt.tm_mday = dt->day; > gt.tm_hour = dt->hour; > gt.tm_min = dt->minute; > gt.tm_sec = dt->second; > return dbiMakeDate(PyInt_FromLong(mktime(>))); > } > > Is it relatively easy to modify or add code to this library to make it > return python datetime objects or something with direct access to the > original structs values? > > If I (or someone else) was to do this, would it be likely to be > accepted into the main python-win32 library? > > For our purposes, we are after a naive handling of the datetimes as we > need to ensure our calculations are correct across timezone > boundaries. Conversion to values in a particular timezone is handled > at display time. > > For reference, we have tested this using python 2.3 and 2.5, builds > 203, 211 and 212 of python-win32, with New Zealand and Australian time > zone changes for Sept/Oct 2008 on Vista, XP and Server 2003. > > As an aside, the testDates method in test_odbc.py looks a little bit > strange. Is it actually testing against the string 'd' instead of the > variable d? > > Thanks in advance, > > Joe > > -------------------------------------------------------------------------------- > > import os > import tempfile > import pythoncom > from win32com.client.gencache import EnsureDispatch > from win32com.client import constants > > import dbi, odbc > from datetime import datetime, timedelta > > # DB creation copied from test_odbc.py from win32 > > db_filename = os.path.join(tempfile.gettempdir(), "test_odbc.mdb") > if os.path.isfile(db_filename): > os.unlink(db_filename) > > # Create a brand-new database - what is the story with these? > for suffix in (".36", ".35", ".30"): > try: > dbe = EnsureDispatch("DAO.DBEngine" + suffix) > break > except pythoncom.com_error: > pass > else: > raise RuntimeError, "Can't find a DB engine" > > workspace = dbe.Workspaces(0) > > newdb = workspace.CreateDatabase(db_filename, > constants.dbLangGeneral, > constants.dbEncrypt) > > newdb.Close() > > > > > dbConnStr = "Driver={Microsoft Access Driver (*.mdb)};dbq=%s;Uid=;Pwd=;" \ > % (db_filename,) > print dbConnStr > > dbConn = odbc.odbc(dbConnStr) > dbCur = dbConn.cursor() > > createFcTableQuery = ["""create table ODBC_DST_Test ( > ID integer, > DateTime_DBI date, > DateTime_STR varchar(50), > Data float > )"""] > > print > print "Creating DB in %s..." %dbConnStr > > for q in createFcTableQuery: > print q > dbCur.execute(q) > > > # Test commit behaviour > sqlInsertPacket = "INSERT INTO ODBC_DST_Test (ID, DateTime_DBI, > DateTime_STR, Data) \ > values (%d, '%s', '%s', %d)" > > > print > print "Inserting data..." > time = datetime(2008, 10, 5, 0, 30, 0) > endTime = datetime(2008, 10, 5, 3, 30, 0) > i = 0 > while time < endTime: > > thisSqlInsertPacket = sqlInsertPacket % (i, time, time, i) > print thisSqlInsertPacket > dbCur.execute(thisSqlInsertPacket) > > time += timedelta(minutes=10) > i += 1 > > > print > print " ID, Date String, DBI String, DBI long, > Count" > > # Test data dates > dbCur.execute("SELECT * from ODBC_DST_Test") > for r in dbCur.fetchall(): > id, dbidate, strdate, data = r > print "%3d, %s, %s, %d, %7.3f" %(id, strdate, str(dbidate), > long(dbidate), data) > > > dbCur.close() > dbConn.close() > > print > print "Done." Coincidentally, the odbc module has recently been changed to use datetime objects, along with a number of other improvements. (test_odbc.py has been fixed, too) The dbi module is going away completely. If you can build from source, try using the code from CVS. Any help testing is also appreciated. Roger From joe at omc-international.com.au Mon Oct 6 05:47:55 2008 From: joe at omc-international.com.au (Joe Healy) Date: Mon, 06 Oct 2008 14:47:55 +1100 Subject: [python-win32] ODBC date and time issues In-Reply-To: References: Message-ID: <48E98A6B.2040504@omc-international.com.au> Roger, Thanks for this, they were exactly the sort of changes I had in mind, but with very little knowledge about how to go and make them. We will try to build from source, but have not tried this before. We'll let you know how we go with this. We are going to follow the (failed) instructions from http://mail.python.org/pipermail/python-win32/2006-November/005254.html and hope for the best We are also happy to test any builds you send us. We'll know fairly quickly if there have been any behavior changes or problems. Thanks again, Joe Roger Upole wrote: > > Coincidentally, the odbc module has recently been changed to use > datetime objects, > along with a number of other improvements. (test_odbc.py has been > fixed, too) > The dbi module is going away completely. > If you can build from source, try using the code from CVS. Any help > testing is > also appreciated. > > Roger > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From greg.antal at ata-e.com Mon Oct 6 19:10:23 2008 From: greg.antal at ata-e.com (Greg Antal) Date: Mon, 06 Oct 2008 10:10:23 -0700 Subject: [python-win32] ByRef params not working with PythonCOM In-Reply-To: <48E2C006.5030301@ata-e.com> References: <48E2C006.5030301@ata-e.com> Message-ID: <48EA467F.7070500@ata-e.com> An HTML attachment was scrubbed... URL: From timr at probo.com Mon Oct 6 19:52:25 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 06 Oct 2008 10:52:25 -0700 Subject: [python-win32] win32console attach problems In-Reply-To: <9d60787d0810050616j45f314dbh922fb876bd48ce1b@mail.gmail.com> References: <9d60787d0810031214k1cf46ff1qfb56e7e94eaef68a@mail.gmail.com> <48E6767E.2020608@probo.com> <9d60787d0810031339k416cad55w82f4053fb84400b2@mail.gmail.com> <48E68571.1070107@probo.com> <9d60787d0810050616j45f314dbh922fb876bd48ce1b@mail.gmail.com> Message-ID: <48EA5059.8060905@probo.com> Stian wrote: > > Well, let me ask a silly question. Are you running this from a "pyw" > > app, using Pythonw.exe, so you don't have a console of your own? > > Well, that's not a silly question for me - I'm rather new to Python. > Anyway - let me tell you a bit more about how this is put together if > that may be relevant. > I have a GUI written with wxWidgets/wxPython. A .exe-file is created > using pyinstaller. I don't think pyw is explicitly used, but I see > something about pythonw in the pyinstaller files. Perhaps this is used > here? On Windows, by default, scripts with a .py extension are run by Python.exe, which is a console application. If you can write to stdout and see the results in a console window, then you have a console. Scripts with a .pyw extension are run by Pythonw.exe, which is a Windows application. Those scripts do not have a console. If your installer is embedding pythonw.exe as the executioner, then that's probably what you're using. > My GUI starts a console using win32process like this: > ... > Does this make it any clarify what may be wrong? No. ;) I don't see anything immediately obvious. If it were me, I'd write a tiny C application to try the exact same APIs to kill your console app, just to make sure that the sequence does work as expected. Print out the "pid", then pass that to the C app by hand. Remember to make it a Windows app (WinMain instead of main) so that you don't get your own console. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Mon Oct 6 19:57:41 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 06 Oct 2008 10:57:41 -0700 Subject: [python-win32] help with python COM server needed In-Reply-To: References: <48E67C17.7030006@probo.com> Message-ID: <48EA5195.8000202@probo.com> aivars wrote: > this is how I call it from VB: > > Sub testPython() > > Dim a > Dim response > > Set a = CreateObject("Aivars.ReturnSaldo") > response = a.ReturnAmount() '--->error here > > Worksheets("Sheet1").Range("a1").Value = response > End Sub > Function calls in VB with no parameters don't use parens. I think you want this: response = a.ReturnAmount -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From stian.prg at gmail.com Mon Oct 6 21:13:36 2008 From: stian.prg at gmail.com (Stian) Date: Mon, 6 Oct 2008 21:13:36 +0200 Subject: [python-win32] win32console attach problems In-Reply-To: <48EA5059.8060905@probo.com> References: <9d60787d0810031214k1cf46ff1qfb56e7e94eaef68a@mail.gmail.com> <48E6767E.2020608@probo.com> <9d60787d0810031339k416cad55w82f4053fb84400b2@mail.gmail.com> <48E68571.1070107@probo.com> <9d60787d0810050616j45f314dbh922fb876bd48ce1b@mail.gmail.com> <48EA5059.8060905@probo.com> Message-ID: <9d60787d0810061213s2f562c78uf69fa9325c2b4225@mail.gmail.com> > On Windows, by default, scripts with a .py extension are run by > Python.exe, which is a console application. If you can write to stdout > and see the results in a console window, then you have a console. > Scripts with a .pyw extension are run by Pythonw.exe, which is a Windows > application. Those scripts do not have a console. If your installer is > embedding pythonw.exe as the executioner, then that's probably what > you're using. Thanks for enlightening me :) >> Does this make it any clearer what may be wrong? > No. ;) I don't see anything immediately obvious. If it were me, I'd > write a tiny C application to try the exact same APIs to kill your > console app, just to make sure that the sequence does work as expected. > Print out the "pid", then pass that to the C app by hand. Remember to > make it a Windows app (WinMain instead of main) so that you don't get > your own console. First; my wxPython GUI application is basically used to configure and start/stop the console application. Here is what I did now: I start the GUI application and do a too quick stop - making the win32console come into this concurring failing state. Then I start another instance of the same GUI app. This detects the running console application, and I hit the "stop"-button in this new instance. It then attaches to the console and terminates it without problems. If I now start the console application again I am able to stop it without problems from the new instance of the GUI, but with the old instance I still get the same error each time... So, basically the win32console gets into a failing state when it gets the "Handler is invalid." exception, and it doesn't get out of this state even if I call FreeConsole(). So the question is how to clean up this mess. Is there another function I can call? Can I reinitialize the win32console somehow? Create a new instance or get a clean start in some other way..? I feel like this was a silly question, but I'm in the blue here... Thanks! Stian -------------- next part -------------- An HTML attachment was scrubbed... URL: From rwupole at msn.com Tue Oct 7 01:39:07 2008 From: rwupole at msn.com (Roger Upole) Date: Mon, 6 Oct 2008 19:39:07 -0400 Subject: [python-win32] Re: win32console attach problems Message-ID: Stian wrote: >> On Windows, by default, scripts with a .py extension are run by >> Python.exe, which is a console application. If you can write to stdout >> and see the results in a console window, then you have a console. >> Scripts with a .pyw extension are run by Pythonw.exe, which is a Windows >> application. Those scripts do not have a console. If your installer is >> embedding pythonw.exe as the executioner, then that's probably what >> you're using. > > Thanks for enlightening me :) > > >>> Does this make it any clearer what may be wrong? >> No. ;) I don't see anything immediately obvious. If it were me, I'd >> write a tiny C application to try the exact same APIs to kill your >> console app, just to make sure that the sequence does work as expected. >> Print out the "pid", then pass that to the C app by hand. Remember to >> make it a Windows app (WinMain instead of main) so that you don't get >> your own console. > > First; my wxPython GUI application is basically used to configure and > start/stop the console application. Here is what I did now: > > I start the GUI application and do a too quick stop - making the > win32console come into this concurring failing state. Then I start another > instance of the same GUI app. This detects the running console > application, > and I hit the "stop"-button in this new instance. It then attaches to the > console and terminates it without problems. > > If I now start the console application again I am able to stop it without > problems from the new instance of the GUI, but with the old instance I > still > get the same error each time... > > So, basically the win32console gets into a failing state when it gets the > "Handler is invalid." exception, and it doesn't get out of this state even > if I call FreeConsole(). So the question is how to clean up this mess. Is > there another function I can call? Can I reinitialize the win32console > somehow? Create a new instance or get a clean start in some other way..? I > feel like this was a silly question, but I'm in the blue here... > > Thanks! > Stian > I've seen this myself, but couldn't reliably reproduce it. If I recall, allocating a new console, and then immediately freeing it seemed to clear the 'in-between' state. Roger From rwupole at msn.com Tue Oct 7 03:09:19 2008 From: rwupole at msn.com (Roger Upole) Date: Mon, 6 Oct 2008 21:09:19 -0400 Subject: [python-win32] Re: ODBC date and time issues Message-ID: Joe Healy wrote: > Roger, > > Thanks for this, they were exactly the sort of changes I had in mind, > but with very little knowledge about how to go and make them. > > We will try to build from source, but have not tried this before. We'll > let you know how we go with this. We are going to follow the (failed) > instructions from > http://mail.python.org/pipermail/python-win32/2006-November/005254.html > and hope for the best > > We are also happy to test any builds you send us. We'll know fairly > quickly if there have been any behavior changes or problems. > > Thanks again, > > Joe The current code seems to produce correct results for your test case: Which Python version are you working with ? I have an installer built from current CVS for Python 2.5 (32 bit), but can create one for a different version when time permits. Roger From joe at omc-international.com.au Tue Oct 7 07:12:18 2008 From: joe at omc-international.com.au (Joe Healy) Date: Tue, 07 Oct 2008 16:12:18 +1100 Subject: [python-win32] ODBC date and time issues In-Reply-To: References: Message-ID: <48EAEFB2.9060000@omc-international.com.au> Roger Upole wrote: > Joe Healy wrote: >> Roger, >> >> Thanks for this, they were exactly the sort of changes I had in mind, >> but with very little knowledge about how to go and make them. >> >> We will try to build from source, but have not tried this before. >> We'll let you know how we go with this. We are going to follow the >> (failed) instructions from >> http://mail.python.org/pipermail/python-win32/2006-November/005254.html >> and hope for the best >> >> We are also happy to test any builds you send us. We'll know fairly >> quickly if there have been any behavior changes or problems. >> >> Thanks again, >> >> Joe > > The current code seems to produce correct results for your test case: > Great. > Which Python version are you working with ? > I have an installer built from current CVS for Python 2.5 (32 bit), but > can create one for a different version when time permits. > We are working with python 2.5. It would be great if you could send us the installer, we tried yesterday and received the same error as Fuzzyman from the linked email. Thanks, Joe From stian.prg at gmail.com Tue Oct 7 15:36:02 2008 From: stian.prg at gmail.com (Stian) Date: Tue, 7 Oct 2008 15:36:02 +0200 Subject: [python-win32] win32console attach problems In-Reply-To: References: Message-ID: <9d60787d0810070636m1a01a085x56e4cd0997e8472a@mail.gmail.com> > I've seen this myself, but couldn't reliably reproduce it. > If I recall, allocating a new console, and then immediately > freeing it seemed to clear the 'in-between' state. Man, that did the trick! Thanks! I added a win32console.AllocConsole() before the FreeConsole() in the first try-except-clause, and this fixes my problem. However, I do think this look like a hack due to issues in the win32console module, but as long as it works I'm happy. Thanks for all help! Cheers, Stian -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Tue Oct 7 17:57:25 2008 From: vernondcole at gmail.com (Vernon Cole) Date: Tue, 7 Oct 2008 09:57:25 -0600 Subject: [python-win32] ODBC date and time issues In-Reply-To: <48EAEFB2.9060000@omc-international.com.au> References: <48EAEFB2.9060000@omc-international.com.au> Message-ID: On Mon, Oct 6, 2008 at 11:12 PM, Joe Healy wrote: > Roger Upole wrote: > > Which Python version are you working with ? >> I have an installer built from current CVS for Python 2.5 (32 bit), but >> can create one for a different version when time permits. >> >> > We are working with python 2.5. It would be great if you could send us the > installer, we tried yesterday and received the same error as Fuzzyman from > the linked email. > > Thanks, > > Joe > > _______________________________________________ > > Roger: Send a copy to me, too, please. I just ran across an interesting snag with adodbapi, and I want to check these test cases along with my new one. My application crashed suddenly when a user happened to store a value in a datetime column (on MS SQL server) at exactly midnight. The result I got back was a datetime.date, which cannot (for some weird reason) be converted to a datetime.date. I had to write a patch to combine the time back in so I could take it back out later. Nasty. I presume that there is some magic going on somewhere to try to duplicate some special "features" of MS Access. It occurs to me that the same "feature" my also occur in odbc.odbc so I'ld like to try it as well. --- Vernon Cole -------------- next part -------------- An HTML attachment was scrubbed... URL: From vaibhav.s at vieweng.com Tue Oct 7 19:13:12 2008 From: vaibhav.s at vieweng.com (Srivastava, Vaibhav (View Eng)) Date: Tue, 7 Oct 2008 13:13:12 -0400 Subject: [python-win32] How to determine if a process (known pid) Message-ID: <4DD6AB329450D847913EA76D7F3C6B830BECE9B7@valkyrie.ogp.qvii.com> You can "try" using CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); and Process32First(snapshot, &process_entry); I have had some success with this but sometimes this also could not recognize a running process. I am new to Python so am not sure if this available through python's windows API ---------------------------------------------------------------------- Message: 1 Date: Sun, 05 Oct 2008 02:24:28 +0200 From: Stef Mientki Subject: [python-win32] How to determine if a process (known pid) is still running ? To: python-win32 at python.org Message-ID: <48E8093C.40700 at gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed hello, How to determine if a process (known pid) os still running ? Googling the web, I found 1 solution in killing the process, but that's not what I want, I want to reuse the running process. I could also ask a complete list of active processes, but from my experiences that's quite slow. Any better solutions ? thanks, Stef Mientki From timr at probo.com Tue Oct 7 19:40:17 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 07 Oct 2008 10:40:17 -0700 Subject: [python-win32] win32console attach problems In-Reply-To: <9d60787d0810070636m1a01a085x56e4cd0997e8472a@mail.gmail.com> References: <9d60787d0810070636m1a01a085x56e4cd0997e8472a@mail.gmail.com> Message-ID: <48EB9F01.9000300@probo.com> Stian wrote: > > I've seen this myself, but couldn't reliably reproduce it. > > If I recall, allocating a new console, and then immediately > > freeing it seemed to clear the 'in-between' state. > > Man, that did the trick! Thanks! I added a win32console.AllocConsole() > before the FreeConsole() in the first try-except-clause, and this > fixes my problem. However, I do think this look like a hack due to > issues in the win32console module, but as long as it works I'm happy. The win32console module is a very, very thin layer over the API. It doesn't keep any state. My uneducated guess is that you are seeing an issue with the underlying Win32 APIs, not in the win32console module itself. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Wed Oct 8 04:04:53 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 8 Oct 2008 13:04:53 +1100 Subject: [python-win32] ByRef params not working with PythonCOM In-Reply-To: <48EA467F.7070500@ata-e.com> References: <48E2C006.5030301@ata-e.com> <48EA467F.7070500@ata-e.com> Message-ID: <015901c928ea$440f9520$cc2ebf60$@com.au> Try passing pythoncom.Empty for the out param - that will provide a VT_EMPTY param to the object, which it will hopefully accept and fill with the result. Mark From: python-win32-bounces+skippy.hammond=gmail.com at python.org [mailto:python-win32-bounces+skippy.hammond=gmail.com at python.org] On Behalf Of Greg Antal Sent: Tuesday, 7 October 2008 4:10 AM To: python-win32 at python.org Subject: Re: [python-win32] ByRef params not working with PythonCOM Greetings all. I posted this a week ago and had no response, so I'll try again. Any information would be helpful, even if it's just "that all looks right, no idea why it doesn't work." I'll gladly provide more info if needed, or try a different statement of the problem if it isn't clear. Thanks, Greg Antal Gregory W. Antal Senior Technical Advisor ATA Engineering, Inc. 11995 El Camino Real, Suite 200 San Diego, CA 92130 www.ata-e.com greg.antal at ata-e.com 858-480-2072 (Phone) 858-792-8932 (Fax) Greg Antal wrote: Gentlemen: I need to work with a TLB for a finite element pre/post processor called Femap. Its API was built for Visual Basic, and it uses output arguments in many of its functions/methods. Methods with only input arguments and return values work great, but I can't get anywhere with those that have output arguments. Here's the documentation for a method 'Count' of the class 'feSelector': Count ( entityType, nSelected ) Description: This method returns the number of entities of a given type that are currently selected Input: INT4 entityType The entity type to query (node, element, etc) Output: INT4 nSelected The number of "entityType" entities that are currently selected. Return Code: None Here's the code makepy.py generated for this method: def count(self, entityTYPE=defaultNamedNotOptArg, nSelected=pythoncom.Missing): return self._ApplyTypes_(20002, 1, (3, 0), ((3, 1), (16387, 2)), 'count', None,entityTYPE , nSelected) >From all the documentation I've been able to find (including the archives of this mailing list back to September 2005), my Python call should look like this: nSel = zSelect.count(eFemTyps.FT_NODE) When I try that, I get: Traceback (most recent call last): File "", line 1, in File "", line 2, in count com_error: (-2147352561, 'Parameter not optional.', None, None) I've tried supplying the extra parameter, but that results in a 'type mismatch' error, which probably doesn't surprise anyone. Can someone help? Thanks, Greg Antal _____ _______________________________________________ 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 greg.antal at ata-e.com Wed Oct 8 18:51:17 2008 From: greg.antal at ata-e.com (Greg Antal) Date: Wed, 08 Oct 2008 09:51:17 -0700 Subject: [python-win32] ByRef params not working with PythonCOM In-Reply-To: <015901c928ea$440f9520$cc2ebf60$@com.au> References: <48E2C006.5030301@ata-e.com> <48EA467F.7070500@ata-e.com> <015901c928ea$440f9520$cc2ebf60$@com.au> Message-ID: <48ECE505.3030502@ata-e.com> An HTML attachment was scrubbed... URL: From venutaurus539 at gmail.com Thu Oct 9 04:57:10 2008 From: venutaurus539 at gmail.com (venu madhav) Date: Thu, 9 Oct 2008 08:27:10 +0530 Subject: [python-win32] Problem in accessing the Message body of Outlook Inbox. Message-ID: Hi all, How can I access the body of a mail in Outlook Inbox? I tried various options like message.Body or message.Mesg etc. but didn't work. I could get the subject of the mail using message.Subject though. Any help is appreciated. Thanks in advance, Venu -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Thu Oct 9 10:12:31 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 09 Oct 2008 09:12:31 +0100 Subject: [python-win32] Problem in accessing the Message body of Outlook Inbox. In-Reply-To: References: Message-ID: <48EDBCEF.4010107@timgolden.me.uk> venu madhav wrote: > Hi all, > How can I access the body of a mail in Outlook Inbox? I tried > various options like message.Body or message.Mesg etc. but didn't > work. I could get the subject of the mail using message.Subject > though. If you haven't already, check out this page, which will get you started: http://timgolden.me.uk/python/win32_how_do_i/read-my-outlook-inbox.html and check out the CDOLive site referenced from there. Without answering your question directly, and in a spirit of teaching people to fish... The things to search for are "Outlook object model" and "Outlook message body". TJG From le.dahut at laposte.net Thu Oct 9 11:34:44 2008 From: le.dahut at laposte.net (le dahut) Date: Thu, 09 Oct 2008 11:34:44 +0200 Subject: [python-win32] NT service and login prompt In-Reply-To: <48E33B86.6070903@timgolden.me.uk> References: <48E22C76.2090908@laposte.net> <48E330C1.1070107@timgolden.me.uk> <48E33A23.6090902@laposte.net> <48E33B86.6070903@timgolden.me.uk> Message-ID: <48EDD034.8050105@laposte.net> I've put a loop that wait for the service to be up with win32serviceutil.WaitForServiceStatus. Tim Golden a ?crit : > > le dahut wrote: >> Yes, I was trying to intercept user's logon. I've done it using >> userinit registry key, a python NT service and a python service >> running on the PDC. >> >> My problem is also that the service has to be available at logon time >> to do some administrative stuff. >> >> It seems that the policy "gpedit" > Computer >> Configuration\Administrative Templates\System\Logon\ "Always wait for >> the network at computer startup and logon" (registry key >> HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows >> NT\CurrentVersion\Winlogon : SyncForegroundPolicy=1) can help me. >> >> Putting a loop to wait the service is up can also be a good idea. > > > I'd be very interested (on behalf of anyone else who might > also be!) to see how this one resolves itself... > > Thanks > > TJG > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 > > From mail at timgolden.me.uk Thu Oct 9 11:50:15 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 09 Oct 2008 10:50:15 +0100 Subject: [python-win32] NT service and login prompt In-Reply-To: <48EDD034.8050105@laposte.net> References: <48E22C76.2090908@laposte.net> <48E330C1.1070107@timgolden.me.uk> <48E33A23.6090902@laposte.net> <48E33B86.6070903@timgolden.me.uk> <48EDD034.8050105@laposte.net> Message-ID: <48EDD3D7.5050603@timgolden.me.uk> le dahut wrote: > I've put a loop that wait for the service to be up with > win32serviceutil.WaitForServiceStatus. Makes sense. Thanks for getting back. TJG From len200612 at revolutioncontrols.com Thu Oct 9 13:27:28 2008 From: len200612 at revolutioncontrols.com (Len Remmerswaal) Date: Thu, 09 Oct 2008 13:27:28 +0200 Subject: [python-win32] idle detection on system? In-Reply-To: <2b5a48740809221925u1254a23fi160173e4bbeb0696@mail.gmail.com> References: <2b5a48740809221925u1254a23fi160173e4bbeb0696@mail.gmail.com> Message-ID: <48EDEAA0.6000704@revolutioncontrols.com> If your question is still current: Did you try pyHook? (http://www.cs.unc.edu/Research/assist/developer.shtml). I use it in a wxPython app: it provides a message pump. The pyHook callback just increments an integer variable. A timer comes around every second or so to see if the variable changed or not, and if it doesn't during sufficient cycles, you must be idle :-) . Hope this helps, Len On 20:59, Patrick Li wrote: > Hi, > > Does anyone know how I can detect if a system is idle? By idle I am > referring to a user being away from the computer (no keyboard or mouse > movement) for X minutes. Tried searching around but I haven't found > anything that mentions how I can hook into these two events. > > Thanks in advance, > Patrick > From timr at probo.com Thu Oct 9 18:37:12 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 09 Oct 2008 09:37:12 -0700 Subject: [python-win32] Problem in accessing the Message body of Outlook Inbox. In-Reply-To: References: Message-ID: <48EE3338.1030500@probo.com> venu madhav wrote: > Hi all, > How can I access the body of a mail in Outlook Inbox? I tried > various options like message.Body or message.Mesg etc. but didn't > work. I could get the subject of the mail using message.Subject > though. Show us the code you used. There are several ways to get to Outlook, and the solution depends on what you used. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jjpet1 at yahoo.com Fri Oct 10 02:44:27 2008 From: jjpet1 at yahoo.com (jjpet) Date: Thu, 9 Oct 2008 17:44:27 -0700 (PDT) Subject: [python-win32] Please help, run into a COM object issue using the windows media SDK, thanks! Message-ID: <682393.52763.qm@web45105.mail.sp1.yahoo.com> Hello all, I am trying to create an app. that talks to the Microsoft COM object called "wmplayer.ocx", which comes with the windows media SDK. Everything seems to be working fine...... except that it only works when I run it within PythonWin :) What happened when I drove the script from the command line was the player object I created seems to get returned fine, and could be accessed for setting configuration parameters, etc, but it was NOT able to play the audio clip. All I am saying is when running it outside of PythonWin, it only works to some extent...... here is the script: ___________________________________________________________________ import win32com.client class MyEvent: def OnPlayStateChange(self, state): print state mp = win32com.client.DispatchWithEvents('wmplayer.ocx', MyEvent) mp.URL = u'rtsp://rtsp_server_addr/audio_file_name.wmv' mp.controls.play() ___________________________________________________________________ Within PythonWin, the sequence of states get printed indicates the clip was played to completion successfully. When running it from the command line, it never gets into the play state... I am developing it on winXP. Has anybody run into similiar problems before? Working with a COM object that only works properly within PythonWin? Any way to run the script from the command line or any other method without relying on the PythonWin GUI while having the same effect as running it within PythonWin? I was wondering if PythonWin had some binaries that could run a script without launching the GUI editor, but couldn't find any... Any help on this is greatly appreciated, thanks! --Yufeng From mhammond at skippinet.com.au Fri Oct 10 05:37:53 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 10 Oct 2008 14:37:53 +1100 Subject: [python-win32] Please help, run into a COM object issue using the windows media SDK, thanks! In-Reply-To: <682393.52763.qm@web45105.mail.sp1.yahoo.com> References: <682393.52763.qm@web45105.mail.sp1.yahoo.com> Message-ID: <035001c92a89$98094400$c81bcc00$@com.au> > Has anybody run into similiar problems before? Working with a COM > object that only works properly within PythonWin? Any way to run the > script from the command line or any other method without relying on the > PythonWin GUI while having the same effect as running it within > PythonWin? This will happen for true "ActiveX Controls", which is what you are using. wxPython can also host these objects, but a command-line Python can't without lots of plumbing to implement all the interfaces such a control needs... For more examples, see the Pythonwin pywin\Demos\ocx directory. Cheers, Mark From venutaurus539 at gmail.com Fri Oct 10 07:35:59 2008 From: venutaurus539 at gmail.com (venu madhav) Date: Fri, 10 Oct 2008 11:05:59 +0530 Subject: [python-win32] Problem in accessing the Message body of Outlook Inbox. In-Reply-To: <48EE3338.1030500@probo.com> References: <48EE3338.1030500@probo.com> Message-ID: Here is the code: rom win32com.client import Dispatch session = Dispatch("MAPI.session") session.Logon('outlook') # MAPI profile name inbox = session.Inbox for i in range(inbox.Messages.Count): message = inbox.Messages.Item(i + 1) f.write(message.Subject+"\n\n") f.write(message.Body+"\n\n\n") Hope you could get some idea based on this.. Thanks in Advance,, Venu. On Thu, Oct 9, 2008 at 10:07 PM, Tim Roberts wrote: > venu madhav wrote: > > Hi all, > > How can I access the body of a mail in Outlook Inbox? I tried > > various options like message.Body or message.Mesg etc. but didn't > > work. I could get the subject of the mail using message.Subject > > though. > > Show us the code you used. There are several ways to get to Outlook, > and the solution depends on what you used. > > -- > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tangens0 at gmail.com Fri Oct 10 08:01:09 2008 From: tangens0 at gmail.com (Tobias A) Date: Thu, 9 Oct 2008 23:01:09 -0700 (PDT) Subject: [python-win32] pywin32-212 (Python 2.6): cannot run win32 installer on XP (SP3) Message-ID: <19912482.post@talk.nabble.com> Hello All, I recently made a clean install of XP on my office computer and then decided to upgrade to Python 2.6 from Py 2.4.x. Installation of Py 2.6 was smooth (and the multiprocessing package is neat) but when I tried to install pywin32 build 212 for 2.6 windows refused to run the installer. I'm running Win XP (SP3). I downloaded the installer from Sourceforge [pywin32-212.win32-py2.6.exe] and placed it on the desktop (as usual). When I doubleclick on the .exe-file I first get a warning from XP about the publisher not being identified (normal). When I click on "run" I get a message I have never seen before. Unfortunatly I'm running the swedish version of XP. Below is a rough translation (i'm not certain of words in brackets): \pywin32-212.win32-py2.6.exe This program could not be [run/started] because its [configuration] is invalid. The problem may be [rectified] if you reinstall the program. The installer then ends. What could this mean? I get the same message when trying the 210 and 211 builds. Has anything changed in the installer? Are there any DLL:s missing on my system? Regards, Tobias Andersson -- View this message in context: http://www.nabble.com/pywin32-212-%28Python-2.6%29%3A-cannot-run-win32-installer-on-XP-%28SP3%29-tp19912482p19912482.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From mail at timgolden.me.uk Thu Oct 9 11:49:48 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 09 Oct 2008 10:49:48 +0100 Subject: [python-win32] NT service and login prompt In-Reply-To: <48EDD034.8050105@laposte.net> References: <48E22C76.2090908@laposte.net> <48E330C1.1070107@timgolden.me.uk> <48E33A23.6090902@laposte.net> <48E33B86.6070903@timgolden.me.uk> <48EDD034.8050105@laposte.net> Message-ID: <48EDD3BC.9040409@timgolden.me.uk> le dahut wrote: > I've put a loop that wait for the service to be up with > win32serviceutil.WaitForServiceStatus. > > > > Tim Golden a ?crit : >> >> le dahut wrote: >>> Yes, I was trying to intercept user's logon. I've done it using >>> userinit registry key, a python NT service and a python service >>> running on the PDC. >>> >>> My problem is also that the service has to be available at logon time >>> to do some administrative stuff. >>> >>> It seems that the policy "gpedit" > Computer >>> Configuration\Administrative Templates\System\Logon\ "Always wait for >>> the network at computer startup and logon" (registry key >>> HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows >>> NT\CurrentVersion\Winlogon : SyncForegroundPolicy=1) can help me. >>> >>> Putting a loop to wait the service is up can also be a good idea. >> >> >> I'd be very interested (on behalf of anyone else who might >> also be!) to see how this one resolves itself... >> >> Thanks >> >> TJG >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> http://mail.python.org/mailman/listinfo/python-win32 >> >> > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 From tangens0 at gmail.com Fri Oct 10 11:29:40 2008 From: tangens0 at gmail.com (Tobias A) Date: Fri, 10 Oct 2008 02:29:40 -0700 (PDT) Subject: [python-win32] pywin32-212 (Python 2.6): cannot run win32 installer on XP (SP3) [RESOLVED] In-Reply-To: <19912482.post@talk.nabble.com> References: <19912482.post@talk.nabble.com> Message-ID: <19914997.post@talk.nabble.com> Hello again All, This has been resolved. After the re-install of XP i only installed my old copy of VC6. Hanni suggested that I use the setup.py script to build a custom copy. The README suggested that I should install a later copy of VC before building. I installed VC9 (express) and thought I should give the installer another try. This time the installer worked perfectly fine. Thanks to Hanni for his suggestion. Regards, Tobias Andersson Tobias A wrote: > > > I recently made a clean install of XP on my office computer and then > decided to upgrade to Python 2.6 from Py 2.4.x. > > Installation of Py 2.6 was smooth (and the multiprocessing package is > neat) but when I tried to install pywin32 build 212 for 2.6 windows > refused to run the installer. I'm running Win XP (SP3). > > [...] > -- View this message in context: http://www.nabble.com/pywin32-212-%28Python-2.6%29%3A-cannot-run-win32-installer-on-XP-%28SP3%29-tp19912482p19914997.html Sent from the Python - python-win32 mailing list archive at Nabble.com. From timr at probo.com Fri Oct 10 18:20:15 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 10 Oct 2008 09:20:15 -0700 Subject: [python-win32] Problem in accessing the Message body of Outlook Inbox. In-Reply-To: References: <48EE3338.1030500@probo.com> Message-ID: <48EF80BF.9040804@probo.com> venu madhav wrote: > > Here is the code: > > rom win32com.client import Dispatch > > session = Dispatch("MAPI.session") > session.Logon('outlook') # MAPI profile name > inbox = session.Inbox > for i in range(inbox.Messages.Count): > message = inbox.Messages.Item(i + 1) > f.write(message.Subject+"\n\n") > f.write(message.Body+"\n\n\n") > > Hope you could get some idea based on this.. I believe you want the "Text" property, not the "Body" property. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jjpet1 at yahoo.com Fri Oct 10 20:03:29 2008 From: jjpet1 at yahoo.com (jjpet) Date: Fri, 10 Oct 2008 11:03:29 -0700 (PDT) Subject: [python-win32] Please help, run into a COM object issue using the windows media SDK, thanks! In-Reply-To: <035001c92a89$98094400$c81bcc00$@com.au> Message-ID: <706420.86897.qm@web45111.mail.sp1.yahoo.com> Thanks Mark! Does PythonWin (or wxPython) provide any way to drive a script as if running it in the PythonWin GUI? --- On Thu, 10/9/08, Mark Hammond wrote: > From: Mark Hammond > Subject: RE: [python-win32] Please help, run into a COM object issue using the windows media SDK, thanks! > To: jjpet1 at yahoo.com, python-win32 at python.org > Date: Thursday, October 9, 2008, 8:37 PM > > Has anybody run into similiar problems before? Working > with a COM > > object that only works properly within PythonWin? Any > way to run the > > script from the command line or any other method > without relying on the > > PythonWin GUI while having the same effect as running > it within > > PythonWin? > > This will happen for true "ActiveX Controls", > which is what you are using. > wxPython can also host these objects, but a command-line > Python can't > without lots of plumbing to implement all the interfaces > such a control > needs... For more examples, see the Pythonwin > pywin\Demos\ocx directory. > > Cheers, > > Mark From timr at probo.com Fri Oct 10 20:17:39 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 10 Oct 2008 11:17:39 -0700 Subject: [python-win32] Please help, run into a COM object issue using the windows media SDK, thanks! In-Reply-To: <706420.86897.qm@web45111.mail.sp1.yahoo.com> References: <706420.86897.qm@web45111.mail.sp1.yahoo.com> Message-ID: <48EF9C43.2060107@probo.com> jjpet wrote: > Thanks Mark! > > Does PythonWin (or wxPython) provide any way to drive a script as if running it in the PythonWin GUI? > The key, I believe, is that you need a message loop. A standard console app doesn't have one, so it waits forever for a response from a message. Any of the GUI frameworks will supply a message loop. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From arve.knudsen at gmail.com Mon Oct 13 11:14:05 2008 From: arve.knudsen at gmail.com (Arve Knudsen) Date: Mon, 13 Oct 2008 11:14:05 +0200 Subject: [python-win32] Extending DLL search path? In-Reply-To: References: Message-ID: On Wed, Oct 1, 2008 at 6:56 AM, Larry Bates wrote: > Arve Knudsen wrote: >> >> Hi >> >> I have a C++ program which embeds Python and is itself modularized >> into several DLLs. The Python part (extensions) of the application >> again links to these DLLs, the problem is the containing catalog (also >> containing the executable itself) is not on the PATH, so the DLLs >> aren't resolved when loading the Python extensions. Is there any smart >> way of extending the DLL search path at runtime? >> >> Thanks, >> Arve > > Take a look at apppath registry entries. This is pretty strange .. I've now added an App Paths registry entry for my application, and the dependency DLLs are still not being found. This is only a problem with the Python DLLs (.pyd's). Arve From newsham at lava.net Tue Oct 14 00:06:05 2008 From: newsham at lava.net (Tim Newsham) Date: Mon, 13 Oct 2008 12:06:05 -1000 (HST) Subject: [python-win32] how do I build pywin32? In-Reply-To: References: Message-ID: I have downloaded and built python2.4.5 using visual studio 7.1sp1. I have installed windows server 2008 sdk. When I try to build pywin32-212 I get an error: e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /nologo /Ox /MD /W3 /GX /DNDEBUG -DDISTUTILS_BUILD -Icom/win32com/src/include -Iwin32/src -IE:\Python-2.4.5\Python-2.4.5\include -IE:\Python-2.4.5\Python-2.4.5\PC "-IE:\Program Files\Microsoft SDKs\Windows\v6.1\include" /Tpwin32\src\PyACL.cpp /Fobuild \temp.win32-2.4\Release\win32\src\PyACL.obj -DBUILD_PYWINTYPES /YXPyWinTypes.h / Fpbuild\temp.win32-2.4\Release\pywintypes.pch /Zi /Fdbuild\temp.win32-2.4\Release\pywintypes_vc.pdb /EHsc PyACL.cpp E:\Program Files\Microsoft SDKs\Windows\v6.1\Include\specstrings.h(9) : fatal error C1083: Cannot open include file: 'sal.h': No such file or directory error: command '"e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.e xe"' failed with exit status 2 which seems to be some incompatibility between the headers from visual studio 7.1 and the win sdk? What do I need to install to properly build pywin32? Tim Newsham http://www.thenewsh.com/~newsham/ From timr at probo.com Tue Oct 14 00:25:55 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 13 Oct 2008 15:25:55 -0700 Subject: [python-win32] how do I build pywin32? In-Reply-To: References: Message-ID: <48F3CAF3.9060002@probo.com> Tim Newsham wrote: > I have downloaded and built python2.4.5 using visual studio 7.1sp1. > I have installed windows server 2008 sdk. When I try to build > pywin32-212 I get an error: > ... > which seems to be some incompatibility between the headers from > visual studio 7.1 and the win sdk? What do I need to install to > properly build pywin32? It may be worth trying an older version of the SDK. The Vista SDK version of specstrings.h does not try to include sal.h. There is a 5 year gap between VS7.1 and the WS2008 SDK. Why are you building Python from scratch? Just curious. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From newsham at lava.net Tue Oct 14 00:27:07 2008 From: newsham at lava.net (Tim Newsham) Date: Mon, 13 Oct 2008 12:27:07 -1000 (HST) Subject: [python-win32] how do I build pywin32? In-Reply-To: <48F3CAF3.9060002@probo.com> References: <48F3CAF3.9060002@probo.com> Message-ID: > Why are you building Python from scratch? Just curious. I need pdb's to debug a crash. > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. Tim Newsham http://www.thenewsh.com/~newsham/ From newsham at lava.net Tue Oct 14 01:26:07 2008 From: newsham at lava.net (Tim Newsham) Date: Mon, 13 Oct 2008 13:26:07 -1000 (HST) Subject: [python-win32] how do I build pywin32? In-Reply-To: <48F3CAF3.9060002@probo.com> References: <48F3CAF3.9060002@probo.com> Message-ID: >> visual studio 7.1 and the win sdk? What do I need to install to >> properly build pywin32? > > It may be worth trying an older version of the SDK. The Vista SDK > version of specstrings.h does not try to include sal.h. Vista SDK worked a lot better, but did not make it all the way through: e:\pywin32-212\pywin32-212\com\win32comext\mapi\src\PyIMAPIProp.h(6) : error C2143: syntax error : missing ';' before '*' e:\pywin32-212\pywin32-212\com\win32comext\mapi\src\PyIMAPIProp.h(6) : error C2501: 'PyIMAPIProp::GetI' : missing storage-class or type specifiers e:\pywin32-212\pywin32-212\com\win32comext\mapi\src\PyIMAPIProp.h(6) : warning C4183: 'GetI': missing return type; assumed to be a member function returning 'int' e:\pywin32-212\pywin32-212\com\win32comext\mapi\src\PyIProfSect.h(6) : error C2143: syntax error : missing ';' before '*' e:\pywin32-212\pywin32-212\com\win32comext\mapi\src\PyIProfSect.h(6) : error C2501: 'PyIProfSect::GetI' : missing storage-class or type specifiers e:\pywin32-212\pywin32-212\com\win32comext\mapi\src\PyIProfSect.h(6) : warning C4183: 'GetI': missing return type; assumed to be a member function returning 'int' com\win32comext\mapi\src\PyIProfSect.cpp(646) : error C2143: syntax error : missing ';' before '*' com\win32comext\mapi\src\PyIProfSect.cpp(646) : error C2501: 'IProfSect' : missing storage-class or type specifiers com\win32comext\mapi\src\PyIProfSect.cpp(647) : error C2501: 'PyIProfSect::GetI' : missing storage-class or type specifiers com\win32comext\mapi\src\PyIProfSect.cpp(648) : error C2059: syntax error : ')' (either on IMAPIProp or PyObject, probably the former) > Tim Roberts, timr at probo.com Tim Newsham http://www.thenewsh.com/~newsham/ From timr at probo.com Tue Oct 14 01:51:11 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 13 Oct 2008 16:51:11 -0700 Subject: [python-win32] how do I build pywin32? In-Reply-To: References: <48F3CAF3.9060002@probo.com> Message-ID: <48F3DEEF.1060808@probo.com> Tim Newsham wrote: >>> visual studio 7.1 and the win sdk? What do I need to install to >>> properly build pywin32? >> >> It may be worth trying an older version of the SDK. The Vista SDK >> version of specstrings.h does not try to include sal.h. > > Vista SDK worked a lot better, but did not make it all the way through: > > e:\pywin32-212\pywin32-212\com\win32comext\mapi\src\PyIMAPIProp.h(6) : > error C2143: syntax error : missing ';' before '*' > e:\pywin32-212\pywin32-212\com\win32comext\mapi\src\PyIMAPIProp.h(6) : > error C2501: 'PyIMAPIProp::GetI' : missing storage-class or type > specifiers > e:\pywin32-212\pywin32-212\com\win32comext\mapi\src\PyIMAPIProp.h(6) : > warning C4183: 'GetI': missing return type; assumed to be a member > function returning 'int' > e:\pywin32-212\pywin32-212\com\win32comext\mapi\src\PyIProfSect.h(6) : > error C2143: syntax error : missing ';' before '*' > e:\pywin32-212\pywin32-212\com\win32comext\mapi\src\PyIProfSect.h(6) : > error C2501: 'PyIProfSect::GetI' : missing storage-class or type > specifiers > e:\pywin32-212\pywin32-212\com\win32comext\mapi\src\PyIProfSect.h(6) : > warning C4183: 'GetI': missing return type; assumed to be a member > function returning 'int' > com\win32comext\mapi\src\PyIProfSect.cpp(646) : error C2143: syntax > error : missing ';' before '*' > com\win32comext\mapi\src\PyIProfSect.cpp(646) : error C2501: > 'IProfSect' : missing storage-class or type specifiers > com\win32comext\mapi\src\PyIProfSect.cpp(647) : error C2501: > 'PyIProfSect::GetI' : missing storage-class or type specifiers > com\win32comext\mapi\src\PyIProfSect.cpp(648) : error C2059: syntax > error : ')' > > (either on IMAPIProp or PyObject, probably the former) Yes, but that's not sensible. That code hasn't changed in 9 years. IMAPIProp and IProfSect both live in the SDK in mapidefs.h. Didn't you have to install SWIG to run this? What version did you get? Perhaps you should check those files to see if anything looks unusual. Both of them are generated by SWIG. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From newsham at lava.net Tue Oct 14 02:13:27 2008 From: newsham at lava.net (Tim Newsham) Date: Mon, 13 Oct 2008 14:13:27 -1000 (HST) Subject: [python-win32] how do I build pywin32? In-Reply-To: <48F3DEEF.1060808@probo.com> References: <48F3CAF3.9060002@probo.com> <48F3DEEF.1060808@probo.com> Message-ID: > Didn't you have to install SWIG to run this? What version did you get? > Perhaps you should check those files to see if anything looks unusual. > Both of them are generated by SWIG. I didn't install SWIG. I'm using python2.4.5 and pywin32-212.zip. I assume it came with the swig files pregenerated (?). Is there a mechanism for forcing it to regenerate swig files? > Tim Roberts, timr at probo.com Tim Newsham http://www.thenewsh.com/~newsham/ From ricercar at infinito.it Wed Oct 15 18:34:29 2008 From: ricercar at infinito.it (ricercar at infinito.it) Date: Wed, 15 Oct 2008 18:34:29 +0200 Subject: [python-win32] COM server and function parameters Message-ID: <6a6fe74ed20ddff497a8ae2836aaf51b@79.31.184.144> Hi all, I still have some problems with my server. I have a function that should return three parameters defined as: HRESULT GetInfo([out] BSTR *name, [out] BSTR *version, [out] BSTR *description); If I return a tuple with three string I get an error saying that the number of returned parameters is wrong (3 in place of 4). I read this post http://markmail.org/message/rjpdosrliyne65fd and added a fourth parameter as first one with a 0 value (OK). I'm not sure this is a right solution and I'd like to ask if something has changed from that post. Unfortunately I cannot test if the values returned are good since after that call I get another call to another function that raise an exception. The other function is defined as HRESULT func2([out] IEnumString ** param1); I can creat an object that implement IEnumString and return it but after that I get a QueryInterface on it with iid set to IID_NULL (a list of 0s). Of course the answer is that the interface is not implemented. Since I haven't the code that is calling my server I cannot debug that side. The developer of the client assure that he is not emitting that call and that a server he wrote in C++ has no problem. So perhaps the problem is from my side. Is there any reason for a QueryInterface with a null id other that a client calling it explicitly? Have anybody seen this before? Thanks and regards, Enrico From timr at probo.com Wed Oct 15 19:31:40 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 15 Oct 2008 10:31:40 -0700 Subject: [python-win32] COM server and function parameters In-Reply-To: <6a6fe74ed20ddff497a8ae2836aaf51b@79.31.184.144> References: <6a6fe74ed20ddff497a8ae2836aaf51b@79.31.184.144> Message-ID: <48F628FC.1010703@probo.com> ricercar at infinito.it wrote: > Hi all, > I still have some problems with my server. > > I have a function that should return three parameters defined as: > > HRESULT GetInfo([out] BSTR *name, [out] BSTR *version, [out] BSTR > *description); > > If I return a tuple with three string I get an error saying that the number > of returned parameters is wrong (3 in place of 4). I read this post > http://markmail.org/message/rjpdosrliyne65fd > and added a fourth parameter as first one with a 0 value (OK). > I'm not sure this is a right solution and I'd like to ask if something has > changed from that post. > I would think this is fairly clear. Your function returns four things: an HRESULT and three strings. That's what your tuple needs to contain. > Unfortunately I cannot test if the values returned are good since after that > call I get another call to another function that raise an exception. > The other function is defined as > > HRESULT func2([out] IEnumString ** param1); > > I can creat an object that implement IEnumString and return it but after > that I get a QueryInterface on it with iid set to IID_NULL (a list of 0s). > Again, this function returns two things: an HRESULT and an interface. Are you returning a two-tuple? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From venutaurus539 at gmail.com Thu Oct 16 08:11:35 2008 From: venutaurus539 at gmail.com (venu madhav) Date: Thu, 16 Oct 2008 11:41:35 +0530 Subject: [python-win32] Problem in accessing the Message body of Outlook Inbox. In-Reply-To: <48EF80BF.9040804@probo.com> References: <48EE3338.1030500@probo.com> <48EF80BF.9040804@probo.com> Message-ID: Hi all, As of now I got access to the text of the message. Now if I want to access the sender address and the receiver address of a mail how can I do that? I tried giving message.To and message.From both of which didn't work.. :-(. I tried searching in Google for them but couldn't come out with the solution. Thanks in Advance. Venu. On Fri, Oct 10, 2008 at 9:50 PM, Tim Roberts wrote: > venu madhav wrote: > > > > Here is the code: > > > > rom win32com.client import Dispatch > > > > session = Dispatch("MAPI.session") > > session.Logon('outlook') # MAPI profile name > > inbox = session.Inbox > > for i in range(inbox.Messages.Count): > > message = inbox.Messages.Item(i + 1) > > f.write(message.Subject+"\n\n") > > f.write(message.Body+"\n\n\n") > > > > Hope you could get some idea based on this.. > > I believe you want the "Text" property, not the "Body" property. > > -- > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ricercar at infinito.it Thu Oct 16 09:06:52 2008 From: ricercar at infinito.it (ricercar at infinito.it) Date: Thu, 16 Oct 2008 09:06:52 +0200 Subject: [python-win32] COM server and function parameters Message-ID: <0eb0d35718aaa4f1e2e1ec5919a454f2@79.6.250.117> At 10.31 15/10/2008 -0700, you wrote: ricercar at infinito.it wrote: > Hi all, > I still have some problems with my server. > > I have a function that should return three parameters defined as: > > HRESULT GetInfo([out] BSTR *name, [out] BSTR *version, [out] BSTR > *description); > > If I return a tuple with three string I get an error saying that the number > of returned parameters is wrong (3 in place of 4). I read this post > http://markmail.org/message/rjpdosrliyne65fd > and added a fourth parameter as first one with a 0 value (OK). > I'm not sure this is a right solution and I'd like to ask if something has > changed from that post. > >I would think this is fairly clear. Your function returns four things: an HRESULT and three strings. That's what your tuple needs to contain. I was not sure since in the post I read: "After adding an HRESULT as the first element of the returned tuple, I found that the *last* element of the returned tuple was being used as the function's return value instead of the *first* value (or second after the HRESULT?) as expected." I cannot test the actual values I get, but I need to solve the second problem (below). > Unfortunately I cannot test if the values returned are good since after that > call I get another call to another function that raise an exception. > The other function is defined as > > HRESULT func2([out] IEnumString ** param1); > > I can creat an object that implement IEnumString and return it but after > that I get a QueryInterface on it with iid set to IID_NULL (a list of 0s). > >Again, this function returns two things: an HRESULT and an interface. Are you returning a two-tuple? Looking at the code in universal.py (at the end of the file) I understand that HRESULT is mandatory only if you are returning a tuple of results, otherwise if you are returning a single result there's no problem. I tried both methods and it seems ok. The problem is that after having returned the object I get a call (on the object) to QueryInterface with IID_NULL. I received the piece of code that calls this but there's nothing strange: CComPtr e; result = t->func2(&e); and BSTR ret_str = NULL; er = e->Next(1, &ret_str, &fetched); For the Python object I tried both with a class that expose IEnumString interface and with util.ListEnumerator passing pythoncom.IID_IEnumString. I get the same result, the object is correct, the QueryInterface with IID_IEnumString is served and after that the last QueryInterface that I don't know where it comes from. During the weekend I will try to build a small client in C++ and verify it. Thanks anyway, Enrico From ricercar at infinito.it Thu Oct 16 17:51:57 2008 From: ricercar at infinito.it (ricercar at infinito.it) Date: Thu, 16 Oct 2008 17:51:57 +0200 Subject: [python-win32] COM server and function parameters (debug with pippo) Message-ID: <229e302f2f96c48c2538f69683c771e6@79.6.250.117> I have the same problem with pippo_server, the test file in the win32com package. I don't know if somebody can have more info from this. I used a client written with python and comtypes and, with a little effort I can see the call to QueryInterface with IID_NULL (as happens if the caller is a C++ client). The client is very simple (it needs comtypes): ------------------- import comtypes from comtypes.client import * from comtypes.GUID import GUID from ctypes import * tlb_id = GUID('{41059C57-975F-4B36-8FF3-C5117426647A}') GetModule((tlb_id, 1, 0)) import comtypes.gen.TESTSERVERLib as llib obj = CreateObject('Python.Test.Pippo', interface=llib.IPippo) #help(obj) p = obj.Method1() ------------------ To show the problem I registered the pippo_server with the --debug option. Then I changed the function Method1 in this way to have a debug output: def Method1(self): #return wrap(CPippo()) return wrap(CPippo(),useDispatcher=1) Last, in the file policy.py at line 261, at the begin of the _QueryInterface_ function I added a line: print iid The result in PythonWin trace Collector is: Object with win32trace dispatcher created (object=None) Object with win32trace dispatcher created (object=) {00000000-0000-0000-0000-000000000000}Traceback (most recent call last): File "C:Python25Libsite-packageswin32comserverdispatcher.py", line 41, in _QueryInterface_ return self.policy._QueryInterface_(iid) File "C:Python25libsite-packageswin32comserverpolicy.py", line 261, in _QueryInterface_ print iid com_error: (-2147221005, "Stringa dell'interfaccia non valida.", None, None) pythoncom error: Failed to call the universal dispatcher There is a QueryInterface with iid={00000000-0000-0000-0000-000000000000} and I don't know who's doing it. Thanks for any tip, Enrico From timr at probo.com Thu Oct 16 19:27:31 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 16 Oct 2008 10:27:31 -0700 Subject: [python-win32] Problem in accessing the Message body of Outlook Inbox. In-Reply-To: References: <48EE3338.1030500@probo.com> <48EF80BF.9040804@probo.com> Message-ID: <48F77983.3090301@probo.com> venu madhav wrote: > Hi all, > As of now I got access to the text of the message. Now if I > want to access the sender address and the receiver address of a mail > how can I do that? I tried giving message.To and message.From both of > which didn't work.. :-(. I tried searching in Google for them but > couldn't come out with the solution. Are you doing this by guessing, or have you actually read about the CDO Object Model? http://msdn.microsoft.com/en-us/library/ms526930.aspx "To" cannot be a simple property, because a message can have many recipients. In CDO, the MAPI.Message object has a "Recipients" collection, which is a set of "Recipient" objects. Each "Recipient" has Address, Name, and Type properties. The "Sender" property has the From address. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ihasmax at gmail.com Fri Oct 17 02:24:53 2008 From: ihasmax at gmail.com (Max Lynch) Date: Thu, 16 Oct 2008 19:24:53 -0500 Subject: [python-win32] Closed Source Service Message-ID: <3836ec640810161724p7f77909er25fe418f1a116f2a@mail.gmail.com> Hi, I was wondering if it's possible to make a closed source service using python win32 and PythonService.exe? Thanks, Max -------------- next part -------------- An HTML attachment was scrubbed... URL: From larry.bates at websafe.com Fri Oct 17 04:42:26 2008 From: larry.bates at websafe.com (Larry Bates) Date: Thu, 16 Oct 2008 21:42:26 -0500 Subject: [python-win32] Closed Source Service In-Reply-To: <3836ec640810161724p7f77909er25fe418f1a116f2a@mail.gmail.com> References: <3836ec640810161724p7f77909er25fe418f1a116f2a@mail.gmail.com> Message-ID: Max Lynch wrote: > Hi, > I was wondering if it's possible to make a closed source service using > python win32 and PythonService.exe? > > Thanks, > Max > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > http://mail.python.org/mailman/listinfo/python-win32 Depends on what you mean by "closed source". Anything written in Python can be reverse "decompiled" (sorry but I couldn't come up with a better word). But then again, anything written in ANY language can be decompiled as well. Packing it with py2exe and making a full installer using Inno Setup can make that more trouble than it is worth. In today's world the ONLY way to make sure your code isn't decompiled, reverse engineered, etc. (regardless of language) is to have it contact your server (either every time it runs or periodically) and to confirm that a proper license is in place. This does eliminate the possibility of running on a non-Internet connected system (not as much of a limitation as it was a few years ago). If you are asking if you can sell a service written in python, win32, and PythonService.exe, the answer is certainly. -Larry From da6d.fierbaugh at gmail.com Fri Oct 17 07:56:59 2008 From: da6d.fierbaugh at gmail.com (David Fierbaugh) Date: Thu, 16 Oct 2008 22:56:59 -0700 Subject: [python-win32] Closed Source Service In-Reply-To: <3836ec640810161724p7f77909er25fe418f1a116f2a@mail.gmail.com> References: <3836ec640810161724p7f77909er25fe418f1a116f2a@mail.gmail.com> Message-ID: Do you mean because of licensing? On Thu, Oct 16, 2008 at 5:24 PM, Max Lynch wrote: > Hi, > I was wondering if it's possible to make a closed source service using > python win32 and PythonService.exe? > > Thanks, > Max > > _______________________________________________ > 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 tang.jiyu at gmail.com Tue Oct 21 04:50:36 2008 From: tang.jiyu at gmail.com (A.TNG) Date: Tue, 21 Oct 2008 10:50:36 +0800 Subject: [python-win32] Is it possible to write a python app running at background on Windows? Message-ID: Hi, I'm looking for a way to write a python app running at background on Windows. Like some Instant Messenger applications, the app may have a main windows. When user click "close", main window disappears. But the app still runs. If user press some key combo, it may active the app and main window shows again. Since the app runs on Windows and there are many similar apps nowadays, I think It may not so difficult. Is there any nice guy could offer some code snippet or some open source project. So, I could find some hint there. Thanks in advance. -- Best Regards, TANG Jiyu From graemeglass at gmail.com Tue Oct 21 08:55:46 2008 From: graemeglass at gmail.com (Graeme Glass) Date: Tue, 21 Oct 2008 08:55:46 +0200 Subject: [python-win32] Is it possible to write a python app running at background on Windows? In-Reply-To: References: Message-ID: On Tue, Oct 21, 2008 at 4:50 AM, A. TNG wrote: > Hi, > > I'm looking for a way to write a python app running at background on > Windows. > > Like some Instant Messenger applications, the app may have a main > windows. When user click "close", main window disappears. But the app > still runs. If user press some key combo, it may active the app and > main window shows again. Since the app runs on Windows and there are > many similar apps nowadays, I think It may not so difficult. > > Is there any nice guy could offer some code snippet or some open > source project. So, I could find some hint there. > > Thanks in advance. > > -- > Best Regards, > TANG Jiyu > Hey, a simple search for: service +win32 +python and search for: win32 +python +daemon Returns back a multitude of results, loads of which have code snippets and ideas. HTH G -------------- next part -------------- An HTML attachment was scrubbed... URL: From ferdinandsousa at gmail.com Tue Oct 21 10:41:24 2008 From: ferdinandsousa at gmail.com (Ferdinand Sousa) Date: Tue, 21 Oct 2008 14:11:24 +0530 Subject: [python-win32] COM -- Dispatch() parameter Message-ID: Greetings to everyone on the mailing list, To automate Word using COM, we use the Dispatch function: Dispatch("Word.Application") What parameter must be passed to Dispatch to launch Adobe Acrobat 7.0 Professional? Is it the VersionIndependentProgID registry key? Even so, there are so many things in the registry that go like "Acrobat ...", "AcroIE.Helper", "PDFMaker. ..." it is a nightmare to find out what is the correct item you need. My second question is, What parameter must be passed to Dispatch() to start any general application that supports COM automation? Many thanks and regards, Ferdi -------------- next part -------------- An HTML attachment was scrubbed... URL: From mc at mclaveau.com Tue Oct 21 13:45:20 2008 From: mc at mclaveau.com (Michel Claveau) Date: Tue, 21 Oct 2008 13:45:20 +0200 Subject: [python-win32] COM -- Dispatch() parameter In-Reply-To: References: Message-ID: Hi! Launch PythonWin, and use [Tools] "COM Browser" and "COM Makepy" for know the names of COM objects & properties. @-salutations -- Michel Claveau From timr at probo.com Tue Oct 21 19:04:30 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 21 Oct 2008 10:04:30 -0700 Subject: [python-win32] COM -- Dispatch() parameter In-Reply-To: References: Message-ID: <48FE0B9E.2070802@probo.com> Ferdinand Sousa wrote: > > To automate Word using COM, we use the Dispatch function: > Dispatch("Word.Application") > > What parameter must be passed to Dispatch to launch Adobe Acrobat 7.0 > Professional? > Is it the VersionIndependentProgID registry key? Even so, there are so > many things in the registry that go like "Acrobat ...", > "AcroIE.Helper", "PDFMaker. ..." it is a nightmare to find out what is > the correct item you need. Unfortunately, you have to be TOLD this kind of information. It's not possible to extract it through reflection. You can often find documentation for specific applications by searching for the app name plus "com object model". To make it more difficult, Adobe has changed their names from version to version. In the old versions, you wanted "AcroExch.PDDoc" Adobe has a great deal of technical documentation on their web site: http://www.adobe.com/devnet/acrobat/. The detailed COM stuff is in their "Interapplication Communication Reference": http://partners.adobe.com/public/developer/en/acrobat/sdk/IACReference.pdf -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From jacek.pliszka at gmail.com Tue Oct 21 21:09:15 2008 From: jacek.pliszka at gmail.com (Jacek Pliszka) Date: Tue, 21 Oct 2008 21:09:15 +0200 Subject: [python-win32] Feature request: adding unicode method to CDispatch Message-ID: <6adaf9f0810211209v7247118ag2a8f04a7a7c6864d@mail.gmail.com> Hi! Would it be a problem to add __unicode__ method like this: def __unicode__(self): try: return unicode(self.__call__()) except pythoncom.com_error, details: if details[0] not in ERRORS_BAD_CONTEXT: raise return self.__repr__() to class CDispatch in win32com/client/dynamic.py ? It would help me a lot - I need unicode data from objects. Or is there a way to get them ? Thanks for any help, Jacek Pliszka From timr at probo.com Tue Oct 21 22:12:52 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 21 Oct 2008 13:12:52 -0700 Subject: [python-win32] Feature request: adding unicode method to CDispatch In-Reply-To: <6adaf9f0810211209v7247118ag2a8f04a7a7c6864d@mail.gmail.com> References: <6adaf9f0810211209v7247118ag2a8f04a7a7c6864d@mail.gmail.com> Message-ID: <48FE37C4.80405@probo.com> Jacek Pliszka wrote: > Would it be a problem to add __unicode__ method like this: > > def __unicode__(self): > try: > return unicode(self.__call__()) > except pythoncom.com_error, details: > if details[0] not in ERRORS_BAD_CONTEXT: > raise > return self.__repr__() > > to class CDispatch in win32com/client/dynamic.py ? > > It would help me a lot - I need unicode data from objects. > > Or is there a way to get them ? > Can you provide an example where the default behavior doesn't do what you expect? Usually, if a method is returning a string, it will be a Unicode string, because that's the COM standard. If a method returns a single-byte string, it's probably better to convert it yourself. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Oct 22 00:07:35 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 21 Oct 2008 15:07:35 -0700 Subject: [python-win32] Feature request: adding unicode method to CDispatch In-Reply-To: <6adaf9f0810211347x6fc8c323yb9ac46016e77fa06@mail.gmail.com> References: <6adaf9f0810211209v7247118ag2a8f04a7a7c6864d@mail.gmail.com> <48FE37C4.80405@probo.com> <6adaf9f0810211347x6fc8c323yb9ac46016e77fa06@mail.gmail.com> Message-ID: <48FE52A7.4030408@probo.com> Jacek Pliszka wrote: > Hi! > > I have something like this: > > wrd=Dispatch("Word.Application") > doc=wrd.Documents.Open('test.doc') > for j in doc.Tables: > s=unicode(j) > ... here I do a few searches on the date inside the table .... > > How can I do it without the method I mentioned ? I use it here to be > able to do s=unicode(j). > You're relying on a bunch of automatic conversions here, some of which do conversions that you don't want. "j" is not a string here -- it is a Table object. The default property of the Table object is a Range object. The default property of the Range object is the Text object, which IS a Unicode string. So, instead of relying on the default conversions, if you say this explicitly: for j = doc.Tables xxx = j.Range.Text you'll find that xxx *IS* a Unicode string. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Oct 22 00:27:07 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 21 Oct 2008 15:27:07 -0700 Subject: [python-win32] Feature request: adding unicode method to CDispatch In-Reply-To: <48FE52A7.4030408@probo.com> References: <6adaf9f0810211209v7247118ag2a8f04a7a7c6864d@mail.gmail.com> <48FE37C4.80405@probo.com> <6adaf9f0810211347x6fc8c323yb9ac46016e77fa06@mail.gmail.com> <48FE52A7.4030408@probo.com> Message-ID: <48FE573B.7000108@probo.com> Tim Roberts wrote: > > You're relying on a bunch of automatic conversions here, some of which > do conversions that you don't want. > > "j" is not a string here -- it is a Table object. The default property > of the Table object is a Range object. The default property of the > Range object is the Text object, which IS a Unicode string. So, instead > of relying on the default conversions, if you say this explicitly: > > for j = doc.Tables > xxx = j.Range.Text > > you'll find that xxx *IS* a Unicode string. > The astute reader will, of course, have noticed and fixed the silly syntax in my for statement: for j in doc.Tables: xxx = j.Range.Text -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From matherbe at cisco.com Wed Oct 22 01:03:15 2008 From: matherbe at cisco.com (Matt Herbert (matherbe)) Date: Tue, 21 Oct 2008 19:03:15 -0400 Subject: [python-win32] Interacting with the desktop as a service on Vista Message-ID: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com> Hey all, So I have a service that needs to interact with the desktop on a Vista machine. I've read multiple articles about Vista's updated security and it's restrictions on services. So I realize that in order for the service to interact with desktop, I'm going to need to create a new process as a "normal" user, and use some form of IPC between the child process and my service to get at the information I need. I've done some research and found an example program on MSDN titled "Starting an Interactive Client Process in C++" (http://msdn.microsoft.com/en-us/library/aa379608(VS.85).aspx). With a little patience, I translated the program into various win32api calls, and got almost everything working. The one thing I can't seem to get working, is the new child process I create (via CreateProcessAsUser) does not seem to be attached to the winsta0\default desktop. Even though I have explicitly created a STARTUPINFO object and set the lpDesktop to 'winsta0\\default': si = win32process.STARTUPINFO() si.lpDesktop = 'winsta0\\default' pinfo = win32process.CreateProcessAsUser( hToken, None, command, None, None, False, win32con.NORMAL_PRIORITY_CLASS | win32con.CREATE_NEW_CONSOLE, None, None, si) My child process starts up just fine, but is not able to interact with the desktop in any way. When I check in task manager, it shows the session id for the child process as 0, while my "normal" applications (such as firefox) are running under session id 1. (FWIW, the user of the child process is my "normal" (non SYSTEM) user in task manager). I've also tried to force my way onto the default desktop in the child process: hwinsta = win32service.OpenWindowStation( "winsta0", False, win32con.READ_CONTROL) hwinsta.SetProcessWindowStation() hdesk = win32service.OpenDesktop('default', 0, False, DESKTOP_ALL) hdesk.SetThreadDesktop() But when the child tries to do this, it dies with the following exception: Traceback (most recent call last): File "C:\Spawn.py", line 723, in hdesk.SetThreadDesktop() pywintypes.error: (170, 'SetThreadDesktop', 'The requested resource is in use.') I can't figure out where to go from here, so any hints would be greatly appreciated. -Matt From larry.bates at websafe.com Wed Oct 22 06:41:37 2008 From: larry.bates at websafe.com (Larry Bates) Date: Tue, 21 Oct 2008 23:41:37 -0500 Subject: [python-win32] Interacting with the desktop as a service on Vista In-Reply-To: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com> References: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com> Message-ID: Matt Herbert (matherbe) wrote: > Hey all, > > So I have a service that needs to interact with the desktop on a Vista > machine. I've read multiple articles about Vista's updated security and > it's restrictions on services. So I realize that in order for the > service to interact with desktop, I'm going to need to create a new > process as a "normal" user, and use some form of IPC between the child > process and my service to get at the information I need. > > I've done some research and found an example program on MSDN titled > "Starting an Interactive Client Process in C++" > (http://msdn.microsoft.com/en-us/library/aa379608(VS.85).aspx). With a > little patience, I translated the program into various win32api calls, > and got almost everything working. The one thing I can't seem to get > working, is the new child process I create (via CreateProcessAsUser) > does not seem to be attached to the winsta0\default desktop. Even though > I have explicitly created a STARTUPINFO object and set the lpDesktop to > 'winsta0\\default': > > si = win32process.STARTUPINFO() > si.lpDesktop = 'winsta0\\default' > pinfo = win32process.CreateProcessAsUser( > hToken, > None, > command, > None, > None, > False, > win32con.NORMAL_PRIORITY_CLASS | win32con.CREATE_NEW_CONSOLE, > None, > None, > si) > > My child process starts up just fine, but is not able to interact with > the desktop in any way. When I check in task manager, it shows the > session id for the child process as 0, while my "normal" applications > (such as firefox) are running under session id 1. (FWIW, the user of the > child process is my "normal" (non SYSTEM) user in task manager). > > I've also tried to force my way onto the default desktop in the child > process: > > hwinsta = win32service.OpenWindowStation( > "winsta0", False, win32con.READ_CONTROL) > hwinsta.SetProcessWindowStation() > hdesk = win32service.OpenDesktop('default', 0, False, DESKTOP_ALL) > hdesk.SetThreadDesktop() > > But when the child tries to do this, it dies with the following > exception: > > Traceback (most recent call last): > File "C:\Spawn.py", line 723, in > hdesk.SetThreadDesktop() > pywintypes.error: (170, 'SetThreadDesktop', 'The requested resource is > in use.') > > I can't figure out where to go from here, so any hints would be greatly > appreciated. > > -Matt What exactly does 'interact with the desktop' mean to you? If it means that you want a desktop application (maybe something setting in the SystemTray) that can communicate with the service that is relatively easy. I think using threading is probably over-complicating things. The first way is to make your service a socket server and the desktop application a socket client. Pass messages between the two over a socket that is read by the client. I've done this and it doesn't take a lot of code.. One thing I've been looking at is using logging module's socket transport to "feed" a log to a client-side socket server. Now that is the "other way around", but is holds some promise as the logging module is a standard and the client application could be a socket server that collected and displayed the logging messages (which is mostly what SystemTray applications do anyway). Logging is going on all the time, but when the SystemTray application is running/visible it displays the messages to the user. Hope this helps. -Larry From mail at timgolden.me.uk Wed Oct 22 16:20:47 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 22 Oct 2008 15:20:47 +0100 Subject: [python-win32] Interacting with the desktop as a service on Vista In-Reply-To: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com> References: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com> Message-ID: <48FF36BF.7010901@timgolden.me.uk> Matt Herbert (matherbe) wrote: > So I have a service that needs to interact with the desktop on a Vista > machine. I've read multiple articles about Vista's updated security and > it's restrictions on services. So I realize that in order for the > service to interact with desktop, I'm going to need to create a new > process as a "normal" user, and use some form of IPC between the child > process and my service to get at the information I need. Without knowing what the exact problem which you're encountering, it seems to me that you're probably fighting the system. I don't use Vista myself but I seem to remember that the Service security subsystem has been beefed up to make things like this even harder. You don't say exactly what your interaction with the desktop is. Can you not do the usual thing of having a user run a (possibly systray-ed) app in his userspace which comminicates with your service via, say, named pipes (or sockets, or whatever)? Can you come across with more information, such as how your service will be interacting with the desktop? TJG From matherbe at cisco.com Wed Oct 22 19:07:09 2008 From: matherbe at cisco.com (Matt Herbert (matherbe)) Date: Wed, 22 Oct 2008 13:07:09 -0400 Subject: [python-win32] Interacting with the desktop as a service onVista In-Reply-To: <48FF36BF.7010901@timgolden.me.uk> References: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com> <48FF36BF.7010901@timgolden.me.uk> Message-ID: <249A89BAA060C94FA0B93EA6135CC93C0658FA12@xmb-rtp-20b.amer.cisco.com> > -----Original Message----- > From: python-win32-bounces+matherbe=cisco.com at python.org > [mailto:python-win32-bounces+matherbe=cisco.com at python.org] > On Behalf Of Tim Golden > Sent: Wednesday, October 22, 2008 10:21 AM > Cc: python-win32 at python.org > Subject: Re: [python-win32] Interacting with the desktop as a > service onVista > > Matt Herbert (matherbe) wrote: > > So I have a service that needs to interact with the desktop > on a Vista > > machine. I've read multiple articles about Vista's updated security > > and it's restrictions on services. So I realize that in > order for the > > service to interact with desktop, I'm going to need to create a new > > process as a "normal" user, and use some form of IPC > between the child > > process and my service to get at the information I need. > > > Without knowing what the exact problem which you're > encountering, it seems to me that you're probably fighting > the system. I don't use Vista myself but I seem to remember > that the Service security subsystem has been beefed up to > make things like this even harder. > > You don't say exactly what your interaction with the desktop > is. Can you not do the usual thing of having a user run a > (possibly systray-ed) app in his userspace which comminicates > with your service via, say, named pipes (or sockets, or whatever)? > > > Can you come across with more information, such as how your > service will be interacting with the desktop? > > TJG Apologies, I had thought I had provided enough information, but after re-reading my post, I realized I wasn't really describing the problem very well. My situation is I have a python service which runs 24/7. Occasionally The service needs to access windows on the desktop. That is, it needs to enumerate all the windows, find a specific pop-up, and press a button. Now, this was not a problem on XP, but the new service restrictions on vista make it impossible for the Service to access the windows on the interactive desktop (winsta0\default). So I've written a module that runs a simple socket server, which tries to CreateProcessAsUser on a small short lived python script, which will do the work on the desktop. When the child process starts up, it connects back to the service, and waits for commands. Now the problem: From the service (running as the SYSTEM user), I use the CreateProccessAsUser function, to start up my child process as the user 'joe' (who, incidentally, is also logged in to the desktop). The process seems to startup without any problems and even runs as the user 'joe'. However, the child process still is not able to access the windows on the desktop. This is what lead me to the MSDN example (in my original post). In the CreateProcessAsUser documentation (http://msdn.microsoft.com/en-us/library/ms682429.aspx), under the remarks section, it discusses the requirements for the child process to have permissions to interact with desktop. It states that the DACL's of the windows station and the desktop must be updated to grant access to the user represented by the token (acquired via the LogonUser function). So I've done all that, and still I cannot get my child process onto the interactive desktop. FWIW, the child process is short lived and I would prefer to not have to start it up by other means. I really want the service to start the child process. Any Ideas? Thanks -Matt From greg.antal at ata-e.com Wed Oct 22 19:10:40 2008 From: greg.antal at ata-e.com (Greg Antal) Date: Wed, 22 Oct 2008 10:10:40 -0700 Subject: [python-win32] ByRef params not working with PythonCOM In-Reply-To: <48ECE505.3030502@ata-e.com> References: <48E2C006.5030301@ata-e.com> <48EA467F.7070500@ata-e.com> <015901c928ea$440f9520$cc2ebf60$@com.au> <48ECE505.3030502@ata-e.com> Message-ID: <48FF5E90.8070701@ata-e.com> An HTML attachment was scrubbed... URL: From theller at ctypes.org Wed Oct 22 19:28:16 2008 From: theller at ctypes.org (Thomas Heller) Date: Wed, 22 Oct 2008 19:28:16 +0200 Subject: [python-win32] ByRef params not working with PythonCOM In-Reply-To: <48FF5E90.8070701@ata-e.com> References: <48E2C006.5030301@ata-e.com> <48EA467F.7070500@ata-e.com> <015901c928ea$440f9520$cc2ebf60$@com.au> <48ECE505.3030502@ata-e.com> <48FF5E90.8070701@ata-e.com> Message-ID: Greg Antal schrieb: > Hi everybody. > > It's been nearly 2 weeks since I posted this, and nobody has responded. If > anybody has any ideas, I'd be glad to hear them. I'll provide more info on > anything anybody thinks is relevant. Well, a totally different idea would be to try out comtypes with your objects. Thomas From steven.james at gmail.com Wed Oct 22 19:35:43 2008 From: steven.james at gmail.com (Steven James) Date: Wed, 22 Oct 2008 13:35:43 -0400 Subject: [python-win32] Interacting with the desktop as a service onVista In-Reply-To: <249A89BAA060C94FA0B93EA6135CC93C0658FA12@xmb-rtp-20b.amer.cisco.com> References: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com> <48FF36BF.7010901@timgolden.me.uk> <249A89BAA060C94FA0B93EA6135CC93C0658FA12@xmb-rtp-20b.amer.cisco.com> Message-ID: I don't know if this will help, but have you seen this article? http://msdn.microsoft.com/en-us/library/ms683502.aspx It says that services cannot interact with desktop users as of Windows Vista. I guess that's the official word. As with all issues, however, there are ways around it. This is a hack I heard about somewhere...can't find much better than some silly VB code for it right now. The basic idea is to create a "Scheduled Task" that has no schedule (so it won't run). You can then manually call the Scheduled Task from your service. Dim server Dim user Dim password Dim domain Dim taskObj server = "sqe-18" user = "MyAdminUser" password = "MyAdminPassword" domain = "MyDomain" Set service = CreateObject("Schedule.Service") service.Connect server,user,domain,password Set rootFolder = service.GetFolder("\") Set colTasks = rootFolder.GetTasks(0) For Each task In colTasks If (StrComp(task.Name,"RunFooEXE",1) = 0) Then Set taskObj = task.Run("") End If Next The VB code can even be used to create the task and run it on a remote computer (assuming you have proper credentials, etc). Does this help? Sorry I don't have the knowledge to quickly translate this into python/win32, but it should be pretty close already. Steven James On Wed, Oct 22, 2008 at 1:07 PM, Matt Herbert (matherbe) wrote: > > > -----Original Message----- > > From: python-win32-bounces+matherbe=cisco.com at python.org > > [mailto:python-win32-bounces+matherbe = > cisco.com at python.org] > > On Behalf Of Tim Golden > > Sent: Wednesday, October 22, 2008 10:21 AM > > Cc: python-win32 at python.org > > Subject: Re: [python-win32] Interacting with the desktop as a > > service onVista > > > > Matt Herbert (matherbe) wrote: > > > So I have a service that needs to interact with the desktop > > on a Vista > > > machine. I've read multiple articles about Vista's updated security > > > and it's restrictions on services. So I realize that in > > order for the > > > service to interact with desktop, I'm going to need to create a new > > > process as a "normal" user, and use some form of IPC > > between the child > > > process and my service to get at the information I need. > > > > > > Without knowing what the exact problem which you're > > encountering, it seems to me that you're probably fighting > > the system. I don't use Vista myself but I seem to remember > > that the Service security subsystem has been beefed up to > > make things like this even harder. > > > > You don't say exactly what your interaction with the desktop > > is. Can you not do the usual thing of having a user run a > > (possibly systray-ed) app in his userspace which comminicates > > with your service via, say, named pipes (or sockets, or whatever)? > > > > > > Can you come across with more information, such as how your > > service will be interacting with the desktop? > > > > TJG > > Apologies, > > I had thought I had provided enough information, but after re-reading my > post, I realized I wasn't really describing the problem very well. > > My situation is I have a python service which runs 24/7. Occasionally > The service needs to access windows on the desktop. That is, it needs to > enumerate all the windows, find a specific pop-up, and press a button. > Now, this was not a problem on XP, but the new service restrictions on > vista make it impossible for the Service to access the windows on the > interactive desktop (winsta0\default). So I've written a module that > runs a simple socket server, which tries to CreateProcessAsUser on a > small short lived python script, which will do the work on the desktop. > When the child process starts up, it connects back to the service, and > waits for commands. > > Now the problem: From the service (running as the SYSTEM user), I use > the CreateProccessAsUser function, to start up my child process as the > user 'joe' (who, incidentally, is also logged in to the desktop). The > process seems to startup without any problems and even runs as the user > 'joe'. However, the child process still is not able to access the > windows on the desktop. > > This is what lead me to the MSDN example (in my original post). In the > CreateProcessAsUser documentation > (http://msdn.microsoft.com/en-us/library/ms682429.aspx), under the > remarks section, it discusses the requirements for the child process to > have permissions to interact with desktop. It states that the DACL's of > the windows station and the desktop must be updated to grant access to > the user represented by the token (acquired via the LogonUser function). > So I've done all that, and still I cannot get my child process onto the > interactive desktop. > > FWIW, the child process is short lived and I would prefer to not have to > start it up by other means. I really want the service to start the child > process. > > Any Ideas? > > Thanks > -Matt > _______________________________________________ > 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 timr at probo.com Wed Oct 22 19:47:44 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 22 Oct 2008 10:47:44 -0700 Subject: [python-win32] Interacting with the desktop as a service onVista In-Reply-To: <249A89BAA060C94FA0B93EA6135CC93C0658FA12@xmb-rtp-20b.amer.cisco.com> References: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com> <48FF36BF.7010901@timgolden.me.uk> <249A89BAA060C94FA0B93EA6135CC93C0658FA12@xmb-rtp-20b.amer.cisco.com> Message-ID: <48FF6740.7040206@probo.com> Matt Herbert (matherbe) wrote: > My situation is I have a python service which runs 24/7. Occasionally > The service needs to access windows on the desktop. That is, it needs to > enumerate all the windows, find a specific pop-up, and press a button. > Wow, this sounds like an incredible hack impersonating as a feature. For my own curiousity, is this for a test lab somewhere, or is this actually part of a product? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From matherbe at cisco.com Wed Oct 22 20:25:47 2008 From: matherbe at cisco.com (Matt Herbert (matherbe)) Date: Wed, 22 Oct 2008 14:25:47 -0400 Subject: [python-win32] Interacting with the desktop as a service onVista In-Reply-To: <48FF6740.7040206@probo.com> References: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com> <48FF36BF.7010901@timgolden.me.uk><249A89BAA060C94FA0B93EA6135CC93C0658FA12@xmb-rtp-20b.amer.cisco.com> <48FF6740.7040206@probo.com> Message-ID: <249A89BAA060C94FA0B93EA6135CC93C0658FAAC@xmb-rtp-20b.amer.cisco.com> > -----Original Message----- > From: python-win32-bounces+matherbe=cisco.com at python.org > [mailto:python-win32-bounces+matherbe=cisco.com at python.org] > On Behalf Of Tim Roberts > Sent: Wednesday, October 22, 2008 1:48 PM > To: Python-Win32 List > Subject: Re: [python-win32] Interacting with the desktop as a > service onVista > > Matt Herbert (matherbe) wrote: > > My situation is I have a python service which runs 24/7. > Occasionally > > The service needs to access windows on the desktop. That > is, it needs > > to enumerate all the windows, find a specific pop-up, and > press a button. > > > > Wow, this sounds like an incredible hack impersonating as a feature. > For my own curiousity, is this for a test lab somewhere, or > is this actually part of a product? > > -- > 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 > Tim, This is strictly for a test lab. To be more specific it's for automated testing of a product. The product has features that need to be tested both when a user is logged in and when there is nobody logged into the system. For the automation to be able to Test both of these situations, it needs to run as a service. Hence, my dilemma. -Matt From wowberk at gmail.com Thu Oct 23 00:02:55 2008 From: wowberk at gmail.com (wowberk) Date: Thu, 23 Oct 2008 00:02:55 +0200 Subject: [python-win32] problem list process Message-ID: Hello, I have a problem with this code to list the processes. How do I remove the reference to the subject? def P_buscar_proceso(self,proceso,intentos): # P_buscar_proceso(self,proceso,intentos=1): # Se obtiene la lista de procesos y se mira si existe, # Si intento no se define, solo se mira 1 vez import win32pdh contador=0 list = None while contador < intentos: contador = contador + 1 del list list = win32pdh.EnumObjectItems(None, None , 'proceso' , win32pdh.PERF_DETAIL_WIZARD , 0 ) print list x = proceso in list[1] print x if x == 1: result = " "+proceso+" Is Running" print result break else: result = " "+proceso+" Is Not Running..." #win32api.WinExec("+proceso+") print result return(" "+proceso+" Is Not Running...") P_buscar_proceso(None,"processexplorer",1000) Un saludo -------------- next part -------------- An HTML attachment was scrubbed... URL: From jrvilda at gmail.com Thu Oct 23 00:44:19 2008 From: jrvilda at gmail.com (Josu Rodriguez) Date: Thu, 23 Oct 2008 00:44:19 +0200 Subject: [python-win32] problem list process In-Reply-To: References: Message-ID: ok, resolved win32pdh.EnumObjects(None, None, 0, 1) the code ok for Refresh is ... def P_buscar_proceso(self,proceso, > > intentos): > # P_buscar_proceso(self,proceso,intentos=1): > # Se obtiene la lista de procesos y se mira si existe, > # Si intento no se define, solo se mira 1 vez > import win32pdh > contador=0 > list = None > while contador < intentos: > contador = contador + 1 > del list > *win32pdh.EnumObjects(None, None, 0, 1)* > list = win32pdh.EnumObjectItems(None, None , 'proceso' , > win32pdh.PERF_DETAIL_WIZARD , 0 ) > print list > x = proceso in list[1] > print x > if x == 1: > result = " "+proceso+" Is Running" > print result > break > else: > result = " "+proceso+" Is Not Running..." > #win32api.WinExec("+proceso+") > print result > return(" "+proceso+" Is Not Running...") > > > P_buscar_proceso(None,"processexplorer",1000) ----------------------------------- El 23 de octubre de 2008 0:02, wowberk escribi?: > Hello, > > I have a problem with this code to list the processes. How do I remove the > reference to the subject? > > > def P_buscar_proceso(self,proceso,intentos): > # P_buscar_proceso(self,proceso,intentos=1): > # Se obtiene la lista de procesos y se mira si existe, > # Si intento no se define, solo se mira 1 vez > import win32pdh > contador=0 > list = None > while contador < intentos: > contador = contador + 1 > del list > > list = win32pdh.EnumObjectItems(None, None , 'proceso' , > win32pdh.PERF_DETAIL_WIZARD , 0 ) > print list > x = proceso in list[1] > print x > if x == 1: > result = " "+proceso+" Is Running" > print result > break > else: > result = " "+proceso+" Is Not Running..." > #win32api.WinExec("+proceso+") > print result > return(" "+proceso+" Is Not Running...") > > > P_buscar_proceso(None,"processexplorer",1000) > > Un saludo > > -- --- It looks like quality, it sounds like quality, but it's not quite quality. --- -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.james at gmail.com Thu Oct 23 18:54:28 2008 From: steven.james at gmail.com (Steven James) Date: Thu, 23 Oct 2008 12:54:28 -0400 Subject: [python-win32] Interacting with the desktop as a service onVista In-Reply-To: <249A89BAA060C94FA0B93EA6135CC93C0658FAAC@xmb-rtp-20b.amer.cisco.com> References: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com> <48FF36BF.7010901@timgolden.me.uk> <249A89BAA060C94FA0B93EA6135CC93C0658FA12@xmb-rtp-20b.amer.cisco.com> <48FF6740.7040206@probo.com> <249A89BAA060C94FA0B93EA6135CC93C0658FAAC@xmb-rtp-20b.amer.cisco.com> Message-ID: Because I like fun stuff and knowing that people at cisco use hacks like this, here you go, this should work... (cut to snippets because of length) http://snippets.dzone.com/posts/show/6324 As mentioned before, the basic process is to create a disabled Scheduled Task. When you are ready to run it, you enable it, run it, then disable it again. You can supply the credentials. I tried to make everything a variable in the above post. Does not run under Windows XP (there wasn't a Task Scheduler COM interface in XP AFAIK). Steven James On Wed, Oct 22, 2008 at 2:25 PM, Matt Herbert (matherbe) wrote: > > > > -----Original Message----- > > From: python-win32-bounces+matherbe=cisco.com at python.org > > [mailto:python-win32-bounces+matherbe = > cisco.com at python.org] > > On Behalf Of Tim Roberts > > Sent: Wednesday, October 22, 2008 1:48 PM > > To: Python-Win32 List > > Subject: Re: [python-win32] Interacting with the desktop as a > > service onVista > > > > Matt Herbert (matherbe) wrote: > > > My situation is I have a python service which runs 24/7. > > Occasionally > > > The service needs to access windows on the desktop. That > > is, it needs > > > to enumerate all the windows, find a specific pop-up, and > > press a button. > > > > > > > Wow, this sounds like an incredible hack impersonating as a feature. > > For my own curiousity, is this for a test lab somewhere, or > > is this actually part of a product? > > > > -- > > 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 > > > > > Tim, > > This is strictly for a test lab. To be more specific it's for automated > testing of a product. The product has features that need to be tested > both when a user is logged in and when there is nobody logged into the > system. For the automation to be able to Test both of these situations, > it needs to run as a service. Hence, my dilemma. > > -Matt > _______________________________________________ > 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 sidnei at enfoldsystems.com Thu Oct 23 19:04:15 2008 From: sidnei at enfoldsystems.com (Sidnei da Silva) Date: Thu, 23 Oct 2008 15:04:15 -0200 Subject: [python-win32] Interacting with the desktop as a service onVista In-Reply-To: References: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com> <48FF36BF.7010901@timgolden.me.uk> <249A89BAA060C94FA0B93EA6135CC93C0658FA12@xmb-rtp-20b.amer.cisco.com> <48FF6740.7040206@probo.com> <249A89BAA060C94FA0B93EA6135CC93C0658FAAC@xmb-rtp-20b.amer.cisco.com> Message-ID: On Thu, Oct 23, 2008 at 2:54 PM, Steven James wrote: > Because I like fun stuff and knowing that people at cisco use hacks like > this, here you go, this should work... > > (cut to snippets because of length) > http://snippets.dzone.com/posts/show/6324 > > As mentioned before, the basic process is to create a disabled Scheduled > Task. When you are ready to run it, you enable it, run it, then disable it > again. You can supply the credentials. I tried to make everything a variable > in the above post. Does not run under Windows XP (there wasn't a Task > Scheduler COM interface in XP AFAIK). I haven't tried your snippet, but we definitely have used COM to create Scheduled Tasks on Windows all the way back to Windows 2000. I suspect it does work on Windows XP unless it uses some new feature in Vista. -- Sidnei da Silva Enfold Systems http://enfoldsystems.com Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214 Skype zopedc From steven.james at gmail.com Thu Oct 23 19:34:22 2008 From: steven.james at gmail.com (Steven James) Date: Thu, 23 Oct 2008 13:34:22 -0400 Subject: [python-win32] Interacting with the desktop as a service onVista In-Reply-To: References: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com> <48FF36BF.7010901@timgolden.me.uk> <249A89BAA060C94FA0B93EA6135CC93C0658FA12@xmb-rtp-20b.amer.cisco.com> <48FF6740.7040206@probo.com> <249A89BAA060C94FA0B93EA6135CC93C0658FAAC@xmb-rtp-20b.amer.cisco.com> Message-ID: On Thu, Oct 23, 2008 at 1:04 PM, Sidnei da Silva wrote: > On Thu, Oct 23, 2008 at 2:54 PM, Steven James > wrote: > > Because I like fun stuff and knowing that people at cisco use hacks like > > this, here you go, this should work... > > > > (cut to snippets because of length) > > http://snippets.dzone.com/posts/show/6324 > > > > As mentioned before, the basic process is to create a disabled Scheduled > > Task. When you are ready to run it, you enable it, run it, then disable > it > > again. You can supply the credentials. I tried to make everything a > variable > > in the above post. Does not run under Windows XP (there wasn't a Task > > Scheduler COM interface in XP AFAIK). > > I haven't tried your snippet, but we definitely have used COM to > create Scheduled Tasks on Windows all the way back to Windows 2000. I > suspect it does work on Windows XP unless it uses some new feature in > Vista. > > I'm glad to know that it was indeed possible in XP. It appears the Task Scheduler API was updated with Windows Vista/2008 Server. There are references on MSDN to "Task Scheduler 1.0" and "Task Scheduler 2.0" I believe my snippet must use that 2.0 interface. It works only in Vista, but my "just see if it runs" test on XP threw an exception at the Dispatch command. Steven James -------------- next part -------------- An HTML attachment was scrubbed... URL: From Brad.Johnson at ballardtech.com Thu Oct 23 20:49:42 2008 From: Brad.Johnson at ballardtech.com (Brad Johnson) Date: Thu, 23 Oct 2008 18:49:42 +0000 (UTC) Subject: [python-win32] WIN32COM: Cannot get event interface given a wrapped dispatch pointer Message-ID: This problem seems to be related to a post from a while back http://markmail.org/message/moyolyvs5i26vbwr It all comes down to the getevents(clsid) function defined in win32com/client/__init__.py This function expects an incoming clsid, but it never is one. The incoming clsid is _actually_ the IID of the dispatch pointer, derived in from: ti = disp._oleobj_.GetTypeInfo() disp_clsid = ti.GetTypeAttr()[0] The so-called "disp_clsid" will always return the IID of the dispatch interface. Usually, this will still work with the gencache which will map the IID to the class that defines that interface. As long as that class contains a definition for coclass_clsid, it will eventually get to the true coclass class, which will define the default source interface e.g.: # return default outgoing interface for that class klass = gencache.GetClassForCLSID(clsid) try: return klass.default_source except AttributeError: # See if we have a coclass for the interfaces. try: return gencache.GetClassForCLSID(klass.coclass_clsid).default_source except AttributeError: return None However, in our particular applications several different type libraries will import the same interface (and hence IID), which means the look into GetClassForCLSID will fail since it is really passed an IID which is defined in multiple different type libraries. This appears to be a bug relating to thinking the line disp_clsid = ti.GetTypeAttr()[0] will return a CLSID, when it really returns the IID of the interface. From mhammond at skippinet.com.au Fri Oct 24 00:52:15 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 24 Oct 2008 09:52:15 +1100 Subject: [python-win32] WIN32COM: Cannot get event interface given a wrapped dispatch pointer In-Reply-To: References: Message-ID: <033301c93562$00f3bad0$02db3070$@com.au> > However, in our particular applications several different type > libraries will > import the same interface (and hence IID), which means the look into > GetClassForCLSID will fail since it is really passed an IID which is > defined in multiple different type libraries. Eeek. Have you actually imported the other library, or simply copied the interface definition. I'd be surprised to find the same interface defined in 2 typelibs (but not surprised to see cross-typelib references). > This appears to be a bug relating to thinking the line disp_clsid = > ti.GetTypeAttr()[0] will return a CLSID, when it really returns the IID > of the interface. Any suggestions how we should fix this? I'm flat out spending the little Python time I do have on py3k at the moment... Cheers, Mark From Brad.Johnson at ballardtech.com Fri Oct 24 02:00:49 2008 From: Brad.Johnson at ballardtech.com (Brad Johnson) Date: Fri, 24 Oct 2008 00:00:49 +0000 (UTC) Subject: [python-win32] =?utf-8?q?WIN32COM=3A_Cannot_get_event_interface_g?= =?utf-8?q?iven_a=09wrapped_dispatch_pointer?= References: <033301c93562$00f3bad0$02db3070$@com.au> Message-ID: Mark Hammond skippinet.com.au> writes: > > Eeek. Have you actually imported the other library, or simply copied the > interface definition. I'd be surprised to find the same interface defined > in 2 typelibs (but not surprised to see cross-typelib references). > I think I was a bit vague in my post. The interfaces are referenced in other typelibs, but not defined. Unfortunately, in the gencache each one of these references creates their own stub in its own file generated from its own typelib. Hence, when given the IID of a dispatch pointer, the "last guy wins" in the sense that the last typelib generated with makepy will hold the class definition in the dictionary mapCLSIDToClass. This is okay as long as the IID is used once, but since we refer to the IID in multiple typelibs, it breaks when attempting to do any further introspection (like calling WithEvents). > > Any suggestions how we should fix this? I'm flat out spending the little > Python time I do have on py3k at the moment... > So far all I have got is a hack which modifies GetEvents() slightly to do an uncoditional EnsureModule() at the last possible moment using the correct typelib info for the parameters, rather than placing it in the if statement. This will overwrite whatever is currently in mapCLSIDToClass for the IID with the one from its own typelib. I call it a hack because it's slower (obviously), and because it will only work if the dispatch interface is only used in one coclass for that typelib. If there are any more, I don't know what will happen. > Cheers, > > Mark > From matherbe at cisco.com Fri Oct 24 20:25:57 2008 From: matherbe at cisco.com (Matt Herbert (matherbe)) Date: Fri, 24 Oct 2008 14:25:57 -0400 Subject: [python-win32] Interacting with the desktop as a service onVista In-Reply-To: References: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com><48FF36BF.7010901@timgolden.me.uk><249A89BAA060C94FA0B93EA6135CC93C0658FA12@xmb-rtp-20b.amer.cisco.com><48FF6740.7040206@probo.com><249A89BAA060C94FA0B93EA6135CC93C0658FAAC@xmb-rtp-20b.amer.cisco.com> Message-ID: <249A89BAA060C94FA0B93EA6135CC93C065FEEA2@xmb-rtp-20b.amer.cisco.com> Steven, Thanks, I will give this a try. So then, is it fair to say that it is not possible (on Vista) to have a service spawn a process as a different user, and have that new process interact with the desktop? -Matt ________________________________ From: python-win32-bounces+matherbe=cisco.com at python.org [mailto:python-win32-bounces+matherbe=cisco.com at python.org] On Behalf Of Steven James Sent: Thursday, October 23, 2008 12:54 PM To: python-win32 at python.org Subject: Re: [python-win32] Interacting with the desktop as a service onVista Because I like fun stuff and knowing that people at cisco use hacks like this, here you go, this should work... (cut to snippets because of length) http://snippets.dzone.com/posts/show/6324 As mentioned before, the basic process is to create a disabled Scheduled Task. When you are ready to run it, you enable it, run it, then disable it again. You can supply the credentials. I tried to make everything a variable in the above post. Does not run under Windows XP (there wasn't a Task Scheduler COM interface in XP AFAIK). Steven James On Wed, Oct 22, 2008 at 2:25 PM, Matt Herbert (matherbe) wrote: > -----Original Message----- > From: python-win32-bounces+matherbe=cisco.com at python.org > [mailto:python-win32-bounces+matherbe =cisco.com at python.org] > On Behalf Of Tim Roberts > Sent: Wednesday, October 22, 2008 1:48 PM > To: Python-Win32 List > Subject: Re: [python-win32] Interacting with the desktop as a > service onVista > > Matt Herbert (matherbe) wrote: > > My situation is I have a python service which runs 24/7. > Occasionally > > The service needs to access windows on the desktop. That > is, it needs > > to enumerate all the windows, find a specific pop-up, and > press a button. > > > > Wow, this sounds like an incredible hack impersonating as a feature. > For my own curiousity, is this for a test lab somewhere, or > is this actually part of a product? > > -- > 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 > Tim, This is strictly for a test lab. To be more specific it's for automated testing of a product. The product has features that need to be tested both when a user is logged in and when there is nobody logged into the system. For the automation to be able to Test both of these situations, it needs to run as a service. Hence, my dilemma. -Matt _______________________________________________ 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 timr at probo.com Fri Oct 24 20:40:35 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 24 Oct 2008 11:40:35 -0700 Subject: [python-win32] Interacting with the desktop as a service onVista In-Reply-To: <249A89BAA060C94FA0B93EA6135CC93C065FEEA2@xmb-rtp-20b.amer.cisco.com> References: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com><48FF36BF.7010901@timgolden.me.uk><249A89BAA060C94FA0B93EA6135CC93C0658FA12@xmb-rtp-20b.amer.cisco.com><48FF6740.7040206@probo.com><249A89BAA060C94FA0B93EA6135CC93C0658FAAC@xmb-rtp-20b.amer.cisco.com> <249A89BAA060C94FA0B93EA6135CC93C065FEEA2@xmb-rtp-20b.amer.cisco.com> Message-ID: <490216A3.6020302@probo.com> Matt Herbert (matherbe) wrote: > Steven, > > Thanks, I will give this a try. > > So then, is it fair to say that it is not possible (on Vista) to have > a service spawn a process as a different user, and have that new > process interact with the desktop? No, that's not fair to say! The mechanism you are using should work. That's the mechanism Microsoft recommends. There's something going wrong in the process, but the concept is correct. I didn't reply because I couldn't spot the problem off the top of my head, but you are on the right track. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From matherbe at cisco.com Fri Oct 24 22:01:07 2008 From: matherbe at cisco.com (Matt Herbert (matherbe)) Date: Fri, 24 Oct 2008 16:01:07 -0400 Subject: [python-win32] Interacting with the desktop as a service onVista In-Reply-To: <490216A3.6020302@probo.com> References: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com><48FF36BF.7010901@timgolden.me.uk><249A89BAA060C94FA0B93EA6135CC93C0658FA12@xmb-rtp-20b.amer.cisco.com><48FF6740.7040206@probo.com><249A89BAA060C94FA0B93EA6135CC93C0658FAAC@xmb-rtp-20b.amer.cisco.com> <249A89BAA060C94FA0B93EA6135CC93C065FEEA2@xmb-rtp-20b.amer.cisco.com> <490216A3.6020302@probo.com> Message-ID: <249A89BAA060C94FA0B93EA6135CC93C065FEF0E@xmb-rtp-20b.amer.cisco.com> Hey all, So I think I found the missing piece of the riddle. My problem was that the sub process I was creating via CreateProcessAsUser was ending up on the default desktop of terminal services session 0. This is where all services end up on Vista. The interactive desktop, however, is on terminal services session 1 (usually). So, instead of using the LogonUser function, I should have used the WTSQueryUserToken() function to get the token of logged on user (requires SE_TCB_NAME privilege). The long and the short of it, if you have a service that needs to interact with the user, then the basic outline of the steps you will need to perform is: session = WTSGetActiveConsoleSessionId() *[1] token = WTSQueryUserToken(session) CreateProcessAsUser(token, ...) token.Close() You may also need to Impersonate the user if there is question of whether or not the service would be able to access the executable you are trying to run. Also, with this method, you do not have to mess around with the DACL's for the different windows stations and desktops ... Much easier! NOTES: [1] On my python (active state 2.5.1), the WTSGetActiveConsoleSessionId() function raises NotImplementedError. However, I can easily run it by just invoking it through ctypes: ctypes.windll.kernel32.WTSGetActiveConsoleSessionId() Is this a bug? -Matt > -----Original Message----- > From: python-win32-bounces+matherbe=cisco.com at python.org > [mailto:python-win32-bounces+matherbe=cisco.com at python.org] > On Behalf Of Tim Roberts > Sent: Friday, October 24, 2008 2:41 PM > To: Python-Win32 List > Subject: Re: [python-win32] Interacting with the desktop as a > service onVista > > Matt Herbert (matherbe) wrote: > > Steven, > > > > Thanks, I will give this a try. > > > > So then, is it fair to say that it is not possible (on > Vista) to have > > a service spawn a process as a different user, and have that new > > process interact with the desktop? > > No, that's not fair to say! The mechanism you are using should work. > That's the mechanism Microsoft recommends. There's something > going wrong in the process, but the concept is correct. I > didn't reply because I couldn't spot the problem off the top > of my head, but you are on the right track. > > -- > 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 matherbe at cisco.com Fri Oct 24 22:10:16 2008 From: matherbe at cisco.com (Matt Herbert (matherbe)) Date: Fri, 24 Oct 2008 16:10:16 -0400 Subject: [python-win32] Getting a users token Message-ID: <249A89BAA060C94FA0B93EA6135CC93C065FEF1B@xmb-rtp-20b.amer.cisco.com> Hey all, Anybody know how to get a token for the current user? I'm thinking something similar to win32api.GetUserName, but instead it would return the token?? -Matt From timr at probo.com Sat Oct 25 01:19:07 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 24 Oct 2008 16:19:07 -0700 Subject: [python-win32] Getting a users token In-Reply-To: <249A89BAA060C94FA0B93EA6135CC93C065FEF1B@xmb-rtp-20b.amer.cisco.com> References: <249A89BAA060C94FA0B93EA6135CC93C065FEF1B@xmb-rtp-20b.amer.cisco.com> Message-ID: <490257EB.1010504@probo.com> Matt Herbert (matherbe) wrote: > Anybody know how to get a token for the current user? I'm thinking > something similar to win32api.GetUserName, but instead it would return > the token?? > I suspect you want OpenProcessToken or OpenThreadToken, assuming your process is running as the current user. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From mhammond at skippinet.com.au Sat Oct 25 02:23:57 2008 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 25 Oct 2008 11:23:57 +1100 Subject: [python-win32] Interacting with the desktop as a service onVista In-Reply-To: <249A89BAA060C94FA0B93EA6135CC93C065FEF0E@xmb-rtp-20b.amer.cisco.com> References: <249A89BAA060C94FA0B93EA6135CC93C0658F781@xmb-rtp-20b.amer.cisco.com><48FF36BF.7010901@timgolden.me.uk><249A89BAA060C94FA0B93EA6135CC93C0658FA12@xmb-rtp-20b.amer.cisco.com><48FF6740.7040206@probo.com><249A89BAA060C94FA0B93EA6135CC93C0658FAAC@xmb-rtp-20b.amer.cisco.com> <249A89BAA060C94FA0B93EA6135CC93C065FEEA2@xmb-rtp-20b.amer.cisco.com> <490216A3.6020302@probo.com> <249A89BAA060C94FA0B93EA6135CC93C065FEF0E@xmb-rtp-20b.amer.cisco.com> Message-ID: <03bb01c93637$faf39b60$f0dad220$@com.au> > [1] On my python (active state 2.5.1), the > WTSGetActiveConsoleSessionId() function raises NotImplementedError. > However, I can easily run it by just invoking it through ctypes: > ctypes.windll.kernel32.WTSGetActiveConsoleSessionId() Is this a bug? It is a bug, and I've just checked in a fix (that function is in kernel32.dll, not in wtsapi32.dll as we assumed.) Cheers, Mark From lubomir.kamensky at gmail.com Sat Oct 25 19:02:10 2008 From: lubomir.kamensky at gmail.com (=?ISO-8859-1?Q?Lubom=EDr_Kamensk=FD?=) Date: Sat, 25 Oct 2008 19:02:10 +0200 Subject: [python-win32] Problem with IIS 7 and python asp pages Message-ID: <1cf372c00810251002m623ff0d3o745eac0eb36ea7ef@mail.gmail.com> Dear All, I am using Python interpreter as script interpreter in ASP pages for many years. Moving from Server 2003 to Server 2008 I have problem to run classic ASP pages with Python interpreter on IIS 7. I have the Python scripting engine registered. (Python 2.6, Python for Windows extensions - pywin32-212.win32-py2.6) For this simple asp page: <%@ LANGUAGE = Python %> <% Response.Write("Hello") %> I get the error: HTTP/1.1 500 Server Error Please help me. With kind regards Lubas -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckkart at hoc.net Sat Oct 25 22:02:02 2008 From: ckkart at hoc.net (Christian K.) Date: Sat, 25 Oct 2008 22:02:02 +0200 Subject: [python-win32] force outlook ui update Message-ID: Hi, I apologize for asking a not specifically python related question but I have no idea where to ask (pointers welcome, too). I noticed that after having written e.g. to the PR_SUBJECT of a mapi IMessage, e.g.: msg = self.msgstore._OpenEntry(self.id, None, mapi.MAPI_BEST_ACCESS) msg.SetProps([(PR_SUBJECT, self._subject)]) msg.SaveChanges(mapi.KEEP_OPEN_READWRITE) the subject field in the inbox list changes immedately but the subject line of the message itself (either shown in the embedded panel or in its own frame) does not. After a couple of other actions, i.e. selecting and deslecting other items the message subject will be updated in every place. Is there a way to force an UI update? Regards, Christian From timr at probo.com Mon Oct 27 18:36:15 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 27 Oct 2008 10:36:15 -0700 Subject: [python-win32] force outlook ui update In-Reply-To: References: Message-ID: <4905FC0F.3030706@probo.com> Christian K. wrote: > > I noticed that after having written e.g. to the PR_SUBJECT of a mapi > IMessage, e.g.: > > msg = self.msgstore._OpenEntry(self.id, None, mapi.MAPI_BEST_ACCESS) > msg.SetProps([(PR_SUBJECT, self._subject)]) > msg.SaveChanges(mapi.KEEP_OPEN_READWRITE) > > the subject field in the inbox list changes immedately but the subject > line of the message itself (either shown in the embedded panel or in > its own frame) does not. After a couple of other actions, i.e. > selecting and deslecting other items the message subject will be > updated in every place. > > Is there a way to force an UI update? No. MAPI controls the mail engine, not the user interface. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From xiaolin_zhuo at yahoo.com.cn Mon Oct 27 21:25:06 2008 From: xiaolin_zhuo at yahoo.com.cn (Xiaolin (Jolin) Zhuo) Date: Tue, 28 Oct 2008 04:25:06 +0800 (CST) Subject: [python-win32] Change Property of Microsoft Office Document Imaging 2003 Viewer Control Message-ID: <407057.71556.qm@web15003.mail.cnb.yahoo.com> Hello, I?m trying to use Microsoft Office Document Imaging in Python. Here?s the reference for MODI Viewer Control. http://msdn.microsoft.com/en-us/library/aa167614(office.11).aspx It is said that, Loading a Document into the Viewer Control You can load a document into the viewer control by using either of the following properties: * Set the control's FileName property to the name of an existing MDI or TIF file. * Set the control's Document property to a document that is already loaded in memory. (In this case, the Filename property remains empty.) I am able to create an instance of MODI.Document and MiDocViewer.MiDocView, but I had a problem loading the Document. The Document property is still None after I assigned a Document object to it. The FileName property is still an empty string after I assigned a file name to it. My code is as following: >>> import win32com.client >>> win32com.client.gencache.EnsureModule('{A5EDEDF4-2BBC-45F3-822B-E60C278A1A79}',0,11,0) >>> doc = win32com.client.Dispatch("MODI.Document") >>> doc.Create("C:\some.file.TIF") >>> view = win32com.client.Dispatch("MiDocViewer.MiDocView") >>> view.FileName = "C:\some.file.TIF" >>> view.FileName u'' >>> view.Document = doc >>> view.Document >>> print view.Document None >>> Could anyone help me with how to load a Document into the Viewer Control please? Thanks in advance! Jolin -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.antal at ata-e.com Tue Oct 28 19:05:35 2008 From: greg.antal at ata-e.com (Greg Antal) Date: Tue, 28 Oct 2008 11:05:35 -0700 Subject: [python-win32] ByRef params not working with PythonCOM In-Reply-To: <48FF5E90.8070701@ata-e.com> References: <48E2C006.5030301@ata-e.com> <48EA467F.7070500@ata-e.com> <015901c928ea$440f9520$cc2ebf60$@com.au> <48ECE505.3030502@ata-e.com> <48FF5E90.8070701@ata-e.com> Message-ID: <4907546F.3010700@ata-e.com> An HTML attachment was scrubbed... URL: From ckkart at hoc.net Wed Oct 29 09:46:17 2008 From: ckkart at hoc.net (Christan K.) Date: Wed, 29 Oct 2008 08:46:17 +0000 (UTC) Subject: [python-win32] force outlook ui update References: <4905FC0F.3030706@probo.com> Message-ID: Tim Roberts probo.com> writes: > > Christian K. wrote: > > > the subject field in the inbox list changes immedately but the subject > > line of the message itself (either shown in the embedded panel or in > > its own frame) does not. After a couple of other actions, i.e. > > selecting and deslecting other items the message subject will be > > updated in every place. > > > > Is there a way to force an UI update? > > No. MAPI controls the mail engine, not the user interface. Actually I did not expect to find something within mapi. Do you have any ideas where to look for these gui related issues? Thanks, Christian From mail at timgolden.me.uk Wed Oct 29 09:55:36 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 29 Oct 2008 08:55:36 +0000 Subject: [python-win32] force outlook ui update In-Reply-To: References: <4905FC0F.3030706@probo.com> Message-ID: <49082508.3020904@timgolden.me.uk> Christan K. wrote: > Tim Roberts probo.com> writes: > >> Christian K. wrote: >> >>> the subject field in the inbox list changes immedately but the subject >>> line of the message itself (either shown in the embedded panel or in >>> its own frame) does not. After a couple of other actions, i.e. >>> selecting and deslecting other items the message subject will be >>> updated in every place. >>> >>> Is there a way to force an UI update? >> No. MAPI controls the mail engine, not the user interface. > > Actually I did not expect to find something within mapi. Do you have any ideas > where to look for these gui related issues? You'll probably want to automate the Outlook Application itself via its IDispatch COM interface ("Outlook.Application"). There you do have some degree of control over the interface. I think that if you need more than that, you'll have to look at Outlook plugins and perhaps take a look at the Spambayes project for some examples there. TJG From timr at probo.com Wed Oct 29 18:08:42 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 29 Oct 2008 10:08:42 -0700 Subject: [python-win32] force outlook ui update In-Reply-To: References: <4905FC0F.3030706@probo.com> Message-ID: <4908989A.7070505@probo.com> Christan K. wrote: > Tim Roberts probo.com> writes: > >> Christian K. wrote: >> >>> the subject field in the inbox list changes immedately but the subject >>> line of the message itself (either shown in the embedded panel or in >>> its own frame) does not. After a couple of other actions, i.e. >>> selecting and deslecting other items the message subject will be >>> updated in every place. >>> >>> Is there a way to force an UI update? >>> >> No. MAPI controls the mail engine, not the user interface. >> > > Actually I did not expect to find something within mapi. Do you have any ideas > where to look for these gui related issues? > I guess it depends on what you are really trying to do, and on how general you need this to be. MAPI is an abstraction. There is no promise that MAPI requests will have any effect at all on a user interface. The fact that you are seeing something update at all surprises me. The effect would be very different if you happened to be running a different MAPI provider. It might not even show a UI at all. If what you really want to do is control Outlook, then Tim G is right -- you need to control Outlook through Outlook's object model. If what you really want to do is send email, then MAPI is a more general answer, but you give up the user interface. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ckkart at hoc.net Thu Oct 30 10:13:08 2008 From: ckkart at hoc.net (Christan K.) Date: Thu, 30 Oct 2008 09:13:08 +0000 (UTC) Subject: [python-win32] force outlook ui update References: <4905FC0F.3030706@probo.com> <4908989A.7070505@probo.com> Message-ID: Tim Roberts probo.com> writes: > > Christan K. wrote: > > Tim Roberts probo.com> writes: > > > >> Christian K. wrote: > >> > >>> the subject field in the inbox list changes immedately but the subject > >>> line of the message itself (either shown in the embedded panel or in > >>> its own frame) does not. After a couple of other actions, i.e. > >>> selecting and deslecting other items the message subject will be > >>> updated in every place. > >>> > >>> Is there a way to force an UI update? > >>> > >> No. MAPI controls the mail engine, not the user interface. > >> > > > > Actually I did not expect to find something within mapi. Do you have any ideas > > where to look for these gui related issues? > > > > I guess it depends on what you are really trying to do, and on how > general you need this to be. MAPI is an abstraction. There is no > promise that MAPI requests will have any effect at all on a user > interface. The fact that you are seeing something update at all > surprises me. The effect would be very different if you happened to be > running a different MAPI provider. It might not even show a UI at all. > > If what you really want to do is control Outlook, then Tim G is right -- > you need to control Outlook through Outlook's object model. If what you > really want to do is send email, then MAPI is a more general answer, but > you give up the user interface. Thank you both for your comments. In fact I naivly assumed that, thinking in terms of a mvc pattern, the outlook gui was the view and mapi manipulated the model so that the gui would be aware of every change in the model. Obviously this is not the case. I am using the msgstore module from the spambayes project to modify the mail subjects according to some special rules, triggered by clicking on CommandBarButtons. So I guess I wil have to look into Outlook's object model as Tim G. suggested. Thanks, Christian From timr at probo.com Thu Oct 30 18:07:26 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 30 Oct 2008 10:07:26 -0700 Subject: [python-win32] force outlook ui update In-Reply-To: References: <4905FC0F.3030706@probo.com> <4908989A.7070505@probo.com> Message-ID: <4909E9CE.9000606@probo.com> Christan K. wrote: > Thank you both for your comments. In fact I naivly assumed that, thinking in > terms of a mvc pattern, the outlook gui was the view and mapi manipulated the > model so that the gui would be aware of every change in the model. Obviously > this is not the case. That is not an unreasonable expectation, but unfortunately, that is not the case. MAPI is a general-purpose email interface. The model is that there is some anonymous and faceless server that is offering to handle MAPI requests. MAPI was actually developed well before Outlook; Outlook offers MAPI services only because it is sensible for it to do so, but it's an add-on. It's not a core part of Outlook's world, and as you can see, the integration is not particularly tight. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From aleksandrv at berkeley.edu Thu Oct 30 18:16:06 2008 From: aleksandrv at berkeley.edu (Aleksandr VLADIMIRSKIY) Date: Thu, 30 Oct 2008 10:16:06 -0700 Subject: [python-win32] Python and Microsoft Media Server Message-ID: <7918C1A70119A34887246E1DEC04C653038975C1@coemailsrv.coe.berkeley.edu> Hello, I have a request to test validity of a set of videos hosted on a Microsoft Media Server. It doesn't appear that the standard library urllib urlopen method is capable of reading mms:// urls. Is there a Python library that could help in this case? Thank you, Aleksandr Vladimirskiy Web Developer College of Engineering, Dean's Office UC Berkeley 412 O'Brien Hall 510-642-6385 From timr at probo.com Thu Oct 30 18:34:51 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 30 Oct 2008 10:34:51 -0700 Subject: [python-win32] Python and Microsoft Media Server In-Reply-To: <7918C1A70119A34887246E1DEC04C653038975C1@coemailsrv.coe.berkeley.edu> References: <7918C1A70119A34887246E1DEC04C653038975C1@coemailsrv.coe.berkeley.edu> Message-ID: <4909F03B.6070707@probo.com> Aleksandr VLADIMIRSKIY wrote: > Hello, > > I have a request to test validity of a set of videos hosted on a Microsoft Media Server. It doesn't appear that the standard library urllib urlopen method is capable of reading mms:// urls. Is there a Python library that could help in this case? > MMS is a proprietary protocol invented by Microsoft: http://msdn.microsoft.com/en-us/library/cc234711.aspx. It's similar to RTSP, and uses TCP port 1755. When you say "test the validity", what exactly do you mean? Are you just trying to figure out whether the URL is alive or not? I think you could use the socket module to send a ping request to the port and see if you get a response. If you are actually trying to figure out whether the movie is playable, then you'll have to use a media player of some kind. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc.